foldkit 0.134.0 → 0.136.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 (64) hide show
  1. package/dist/asyncData/asyncData.d.ts +4 -6
  2. package/dist/asyncData/asyncData.d.ts.map +1 -1
  3. package/dist/asyncData/asyncData.js +4 -6
  4. package/dist/command/brand.d.ts +9 -0
  5. package/dist/command/brand.d.ts.map +1 -0
  6. package/dist/command/brand.js +15 -0
  7. package/dist/command/index.d.ts +119 -24
  8. package/dist/command/index.d.ts.map +1 -1
  9. package/dist/command/index.js +66 -26
  10. package/dist/command/interruptible/interruptible.d.ts +9 -94
  11. package/dist/command/interruptible/interruptible.d.ts.map +1 -1
  12. package/dist/command/interruptible/interruptible.js +9 -75
  13. package/dist/command/interruptible/public.d.ts +1 -1
  14. package/dist/command/interruptible/public.d.ts.map +1 -1
  15. package/dist/command/interruptible/public.js +1 -1
  16. package/dist/command/public.d.ts +1 -1
  17. package/dist/command/public.d.ts.map +1 -1
  18. package/dist/customElement/index.d.ts +3 -0
  19. package/dist/customElement/index.d.ts.map +1 -1
  20. package/dist/customElement/index.js +3 -1
  21. package/dist/http/http.d.ts +4 -7
  22. package/dist/http/http.d.ts.map +1 -1
  23. package/dist/http/http.js +4 -7
  24. package/dist/managedResource/managedResource.d.ts +21 -10
  25. package/dist/managedResource/managedResource.d.ts.map +1 -1
  26. package/dist/managedResource/managedResource.js +6 -1
  27. package/dist/port/port.d.ts +8 -9
  28. package/dist/port/port.d.ts.map +1 -1
  29. package/dist/port/port.js +8 -9
  30. package/dist/test/apps/colorPicker.d.ts +28 -0
  31. package/dist/test/apps/colorPicker.d.ts.map +1 -0
  32. package/dist/test/apps/colorPicker.js +43 -0
  33. package/dist/test/apps/counter.d.ts +3 -1
  34. package/dist/test/apps/counter.d.ts.map +1 -1
  35. package/dist/test/apps/counter.js +20 -6
  36. package/dist/test/apps/crashOnRender.d.ts.map +1 -1
  37. package/dist/test/apps/crashOnRender.js +4 -1
  38. package/dist/test/apps/drafts.d.ts +1 -2
  39. package/dist/test/apps/drafts.d.ts.map +1 -1
  40. package/dist/test/apps/drafts.js +7 -2
  41. package/dist/test/apps/feedSocket.d.ts +74 -0
  42. package/dist/test/apps/feedSocket.d.ts.map +1 -0
  43. package/dist/test/apps/feedSocket.js +69 -0
  44. package/dist/test/apps/formChild.d.ts.map +1 -1
  45. package/dist/test/apps/formChild.js +8 -2
  46. package/dist/test/apps/login.d.ts.map +1 -1
  47. package/dist/test/apps/login.js +4 -1
  48. package/dist/test/apps/resumeUpload.d.ts.map +1 -1
  49. package/dist/test/apps/resumeUpload.js +12 -5
  50. package/dist/test/apps/scorePanel.d.ts +32 -0
  51. package/dist/test/apps/scorePanel.d.ts.map +1 -0
  52. package/dist/test/apps/scorePanel.js +19 -0
  53. package/dist/test/apps/uploads.d.ts +4 -4
  54. package/dist/test/apps/uploads.d.ts.map +1 -1
  55. package/dist/test/apps/uploads.js +10 -1
  56. package/dist/test/internal.d.ts +2 -2
  57. package/dist/test/internal.js +1 -1
  58. package/dist/test/scene.d.ts +79 -7
  59. package/dist/test/scene.d.ts.map +1 -1
  60. package/dist/test/scene.js +204 -24
  61. package/dist/test/story.d.ts +5 -6
  62. package/dist/test/story.d.ts.map +1 -1
  63. package/dist/test/story.js +1 -2
  64. package/package.json +1 -1
@@ -35,7 +35,10 @@ export const reloadedSources = [
35
35
  { kind: 'Book', id: '1' },
36
36
  { kind: 'Book', id: '' },
37
37
  ];
38
- export const ReloadSources = Command.define('ReloadSources', LoadedSources)(Effect.succeed(LoadedSources({ sources: reloadedSources })));
38
+ export const ReloadSources = Command.define('ReloadSources', {
39
+ messages: [LoadedSources],
40
+ execute: Effect.succeed(LoadedSources({ sources: reloadedSources })),
41
+ });
39
42
  // INIT
40
43
  export const validSources = [
41
44
  { kind: 'Book', id: '1' },
@@ -1,6 +1,5 @@
1
1
  import { Effect, Schema as S } from 'effect';
2
2
  import * as Command from '../../command/index.js';
3
- import * as Interruptible from '../../command/interruptible/index.js';
4
3
  import type { Document, HtmlBuilder } from '../../html/index.js';
5
4
  export declare const SaveStatus: S.Literals<readonly ["Editing", "Saving", "Saved"]>;
6
5
  export type SaveStatus = typeof SaveStatus.Type;
@@ -21,7 +20,7 @@ export declare const SaveDraftArgs: S.Struct<{
21
20
  readonly revision: S.Number;
22
21
  }>;
23
22
  export type SaveDraftArgs = typeof SaveDraftArgs.Type;
24
- export declare const SaveDraft: Interruptible.DefinitionWithArgsNameKeyed<"SaveDraft", {
23
+ export declare const SaveDraft: import("../../command/interruptible/interruptible.js").DefinitionWithArgsNameKeyed<"SaveDraft", {
25
24
  readonly revision: S.Number;
26
25
  }, Effect.Effect<{
27
26
  readonly _tag: "SucceededSaveDraft";
@@ -1 +1 @@
1
- {"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../../../src/test/apps/drafts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,aAAa,MAAM,sCAAsC,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAMhE,eAAO,MAAM,UAAU,qDAA6C,CAAA;AACpE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAE/C,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,gBAAgB,8EAAwB,CAAA;AACrD,eAAO,MAAM,kBAAkB;;EAE7B,CAAA;AAEF,eAAO,MAAM,OAAO;;IAAkD,CAAA;AACtE,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,aAAa;;EAAmC,CAAA;AAC7D,MAAM,MAA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eAAO,MAAM,MAAM,GACjB,OAAO,KAAK,EACZ,SAAS,OAAO,KACf,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAYxD,CAAA;AAIH,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,QAU5D,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Effect, Match as M, Schema as S } from 'effect';
2
- import * as Interruptible from '../../command/interruptible/index.js';
2
+ import * as Command from '../../command/index.js';
3
3
  import { m } from '../../message/index.js';
4
4
  import { evo } from '../../struct/index.js';
5
5
  // MODEL
@@ -16,7 +16,12 @@ export const SucceededSaveDraft = m('SucceededSaveDraft', {
16
16
  export const Message = S.Union([ClickedSaveDraft, SucceededSaveDraft]);
17
17
  // COMMAND
18
18
  export const SaveDraftArgs = S.Struct({ revision: S.Number });
19
- export const SaveDraft = Interruptible.define('SaveDraft', SaveDraftArgs.fields, SucceededSaveDraft)(({ revision }) => Effect.as(Effect.never, SucceededSaveDraft({ revision })));
19
+ export const SaveDraft = Command.define('SaveDraft', {
20
+ args: SaveDraftArgs.fields,
21
+ messages: [SucceededSaveDraft],
22
+ interrupt: true,
23
+ execute: ({ revision }) => Effect.as(Effect.never, SucceededSaveDraft({ revision })),
24
+ });
20
25
  // INIT
21
26
  export const initialModel = { revision: 0, status: 'Editing' };
22
27
  // UPDATE
@@ -0,0 +1,74 @@
1
+ import { Option, Schema as S } from 'effect';
2
+ import type { Html, HtmlBuilder } from '../../html/index.js';
3
+ import * as ManagedResource from '../../managedResource/index.js';
4
+ export declare const Model: S.Struct<{
5
+ readonly isFeedOpen: S.Boolean;
6
+ readonly status: S.Literals<readonly ["Disconnected", "Connected", "Failed"]>;
7
+ }>;
8
+ export type Model = typeof Model.Type;
9
+ export declare const ClickedToggleFeed: import("../../schema/index.js").CallableTaggedStruct<"ClickedToggleFeed", {}>;
10
+ export declare const AcquiredFeedSocket: import("../../schema/index.js").CallableTaggedStruct<"AcquiredFeedSocket", {
11
+ socketId: S.String;
12
+ }>;
13
+ export declare const ReleasedFeedSocket: import("../../schema/index.js").CallableTaggedStruct<"ReleasedFeedSocket", {}>;
14
+ export declare const FailedAcquireFeedSocket: import("../../schema/index.js").CallableTaggedStruct<"FailedAcquireFeedSocket", {
15
+ error: S.String;
16
+ }>;
17
+ export declare const Message: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"ClickedToggleFeed", {}>, import("../../schema/index.js").CallableTaggedStruct<"AcquiredFeedSocket", {
18
+ socketId: S.String;
19
+ }>, import("../../schema/index.js").CallableTaggedStruct<"ReleasedFeedSocket", {}>, import("../../schema/index.js").CallableTaggedStruct<"FailedAcquireFeedSocket", {
20
+ error: S.String;
21
+ }>]>;
22
+ export type Message = typeof Message.Type;
23
+ export type FeedSocket = Readonly<{
24
+ socketId: string;
25
+ }>;
26
+ export declare const feedResources: {
27
+ feedSocket: ManagedResource.Entry<{
28
+ readonly isFeedOpen: boolean;
29
+ readonly status: "Disconnected" | "Connected" | "Failed";
30
+ }, {
31
+ readonly _tag: "ClickedToggleFeed";
32
+ } | {
33
+ readonly _tag: "AcquiredFeedSocket";
34
+ readonly socketId: string;
35
+ } | {
36
+ readonly _tag: "ReleasedFeedSocket";
37
+ } | {
38
+ readonly _tag: "FailedAcquireFeedSocket";
39
+ readonly error: string;
40
+ }, Option.Option<{
41
+ readonly channel: string;
42
+ }>, Readonly<{
43
+ socketId: string;
44
+ }>, ManagedResource.ManagedResourceService<"FeedSocket">, (socket: Readonly<{
45
+ socketId: string;
46
+ }>) => {
47
+ readonly _tag: "AcquiredFeedSocket";
48
+ readonly socketId: string;
49
+ }>;
50
+ presence: ManagedResource.Entry<{
51
+ readonly isFeedOpen: boolean;
52
+ readonly status: "Disconnected" | "Connected" | "Failed";
53
+ }, {
54
+ readonly _tag: "ClickedToggleFeed";
55
+ } | {
56
+ readonly _tag: "AcquiredFeedSocket";
57
+ readonly socketId: string;
58
+ } | {
59
+ readonly _tag: "ReleasedFeedSocket";
60
+ } | {
61
+ readonly _tag: "FailedAcquireFeedSocket";
62
+ readonly error: string;
63
+ }, Option.Option<null>, string, ManagedResource.ManagedResourceService<"Presence">, () => {
64
+ readonly _tag: "AcquiredFeedSocket";
65
+ readonly socketId: string;
66
+ }>;
67
+ };
68
+ export declare const initialModel: {
69
+ readonly isFeedOpen: boolean;
70
+ readonly status: "Disconnected" | "Connected" | "Failed";
71
+ };
72
+ export declare const update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<never>];
73
+ export declare const view: (model: Model, h: HtmlBuilder<Message>) => Html;
74
+ //# sourceMappingURL=feedSocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedSocket.d.ts","sourceRoot":"","sources":["../../../src/test/apps/feedSocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEzE,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,KAAK,eAAe,MAAM,gCAAgC,CAAA;AAMjE,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,iBAAiB,+EAAyB,CAAA;AACvD,eAAO,MAAM,kBAAkB;;EAE7B,CAAA;AACF,eAAO,MAAM,kBAAkB,gFAA0B,CAAA;AACzD,eAAO,MAAM,uBAAuB;;EAElC,CAAA;AAEF,eAAO,MAAM,OAAO;;;;IAKlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAMvD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;kBANoB,MAAM;;kBAAN,MAAM;;;;;;;;;;;;;;;;;;;;;;CA2BjD,CAAA;AAIH,eAAO,MAAM,YAAY;;;CAGvB,CAAA;AAIF,eAAO,MAAM,MAAM,GACjB,OAAO,KAAK,EACZ,SAAS,OAAO,KACf,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAerC,CAAA;AAIH,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,IAU1D,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { Boolean, Effect, Match as M, Option, Schema as S } from 'effect';
2
+ import * as ManagedResource from '../../managedResource/index.js';
3
+ import { m } from '../../message/index.js';
4
+ import { evo } from '../../struct/index.js';
5
+ // MODEL
6
+ export const Model = S.Struct({
7
+ isFeedOpen: S.Boolean,
8
+ status: S.Literals(['Disconnected', 'Connected', 'Failed']),
9
+ });
10
+ // MESSAGE
11
+ export const ClickedToggleFeed = m('ClickedToggleFeed');
12
+ export const AcquiredFeedSocket = m('AcquiredFeedSocket', {
13
+ socketId: S.String,
14
+ });
15
+ export const ReleasedFeedSocket = m('ReleasedFeedSocket');
16
+ export const FailedAcquireFeedSocket = m('FailedAcquireFeedSocket', {
17
+ error: S.String,
18
+ });
19
+ export const Message = S.Union([
20
+ ClickedToggleFeed,
21
+ AcquiredFeedSocket,
22
+ ReleasedFeedSocket,
23
+ FailedAcquireFeedSocket,
24
+ ]);
25
+ const FeedSocketResource = ManagedResource.tag()('FeedSocket');
26
+ const PresenceResource = ManagedResource.tag()('Presence');
27
+ export const feedResources = ManagedResource.make()(entry => ({
28
+ feedSocket: entry(S.Option(S.Struct({ channel: S.String })), {
29
+ resource: FeedSocketResource,
30
+ modelToMaybeRequirements: model => model.isFeedOpen ? Option.some({ channel: 'general' }) : Option.none(),
31
+ acquire: () => Effect.succeed({ socketId: 'live' }),
32
+ release: () => Effect.void,
33
+ onAcquired: socket => AcquiredFeedSocket({ socketId: socket.socketId }),
34
+ onReleased: () => ReleasedFeedSocket(),
35
+ onAcquireError: error => FailedAcquireFeedSocket({ error: String(error) }),
36
+ }),
37
+ presence: entry(S.Option(S.Null), {
38
+ resource: PresenceResource,
39
+ modelToMaybeRequirements: model => model.isFeedOpen ? Option.some(null) : Option.none(),
40
+ acquire: () => Effect.succeed('online'),
41
+ release: () => Effect.void,
42
+ onAcquired: () => AcquiredFeedSocket({ socketId: 'presence' }),
43
+ onReleased: () => ReleasedFeedSocket(),
44
+ onAcquireError: error => FailedAcquireFeedSocket({ error: String(error) }),
45
+ }),
46
+ }));
47
+ // INIT
48
+ export const initialModel = Model.make({
49
+ isFeedOpen: false,
50
+ status: 'Disconnected',
51
+ });
52
+ // UPDATE
53
+ export const update = (model, message) => M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
54
+ ClickedToggleFeed: () => [evo(model, { isFeedOpen: Boolean.not }), []],
55
+ AcquiredFeedSocket: () => [evo(model, { status: () => 'Connected' }), []],
56
+ ReleasedFeedSocket: () => [
57
+ evo(model, { status: () => 'Disconnected' }),
58
+ [],
59
+ ],
60
+ FailedAcquireFeedSocket: () => [
61
+ evo(model, { status: () => 'Failed' }),
62
+ [],
63
+ ],
64
+ }));
65
+ // VIEW
66
+ export const view = (model, h) => h.div([], [
67
+ h.span([h.Role('status')], [model.status]),
68
+ h.button([h.OnClick(ClickedToggleFeed()), h.Role('button')], [model.isFeedOpen ? 'Close feed' : 'Open feed']),
69
+ ]);
@@ -1 +1 @@
1
- {"version":3,"file":"formChild.d.ts","sourceRoot":"","sources":["../../../src/test/apps/formChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAKjD,eAAO,MAAM,UAAU;;EAErB,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAI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B,CAAA;AACF,eAAO,MAAM,oBAAoB,kFAA4B,CAAA;AAE7D,eAAO,MAAM,aAAa;;;;sFAAmD,CAAA;AAC7E,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAIrD,eAAO,MAAM,kBAAkB,EAAE,WAIhC,CAAA;AAID,eAAO,MAAM,YAAY,GACvB,aAAa,WAAW,EACxB,SAAS,aAAa,KACrB,SAAS,CAAC,WAAW,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAqCpE,CAAA"}
@@ -21,8 +21,14 @@ export const RequestedSave = m('RequestedSave', { id: S.String });
21
21
  export const RequestedCancel = m('RequestedCancel');
22
22
  export const ChildOutMessage = S.Union([RequestedSave, RequestedCancel]);
23
23
  // CHILD COMMAND
24
- export const SubmitForm = Command.define('SubmitForm', SucceededSubmit)(Effect.sync(() => SucceededSubmit({ id: 'abc' })));
25
- export const ResetForm = Command.define('ResetForm', CompletedReset)(Effect.sync(() => CompletedReset()));
24
+ export const SubmitForm = Command.define('SubmitForm', {
25
+ messages: [SucceededSubmit],
26
+ execute: Effect.sync(() => SucceededSubmit({ id: 'abc' })),
27
+ });
28
+ export const ResetForm = Command.define('ResetForm', {
29
+ messages: [CompletedReset],
30
+ execute: Effect.sync(() => CompletedReset()),
31
+ });
26
32
  // CHILD INIT
27
33
  export const initialChildModel = { status: 'Idle' };
28
34
  // CHILD UPDATE
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/test/apps/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAK5D,eAAO,MAAM,KAAK;;;;;;EAMhB,CAAA;AAEF,MAAM,MAAM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BAAqB;;EAEhC,CAAA;AACF,eAAO,MAAM,kBAAkB;;EAA+C,CAAA;AAC9E,eAAO,MAAM,aAAa,2EAAqB,CAAA;AAE/C,eAAO,MAAM,OAAO;;;;;;;;+EAOlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY;;;iBAGvB,CAAA;AAIF,eAAO,MAAM,YAAY,EAAE,KAM1B,CAAA;AAID,eAAO,MAAM,MAAM,GACjB,OAAO,KAAK,EACZ,SAAS,OAAO,KACf,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAyBxD,CAAA;AAIH,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,IA8E5D,CAAA"}
@@ -27,7 +27,10 @@ export const Message = S.Union([
27
27
  ClickedLogout,
28
28
  ]);
29
29
  // COMMAND
30
- export const Authenticate = Command.define('Authenticate', SucceededAuthenticate, FailedAuthenticate)(Effect.sync(() => SucceededAuthenticate({ username: 'alice' })));
30
+ export const Authenticate = Command.define('Authenticate', {
31
+ messages: [SucceededAuthenticate, FailedAuthenticate],
32
+ execute: Effect.sync(() => SucceededAuthenticate({ username: 'alice' })),
33
+ });
31
34
  // INIT
32
35
  export const initialModel = {
33
36
  email: '',
@@ -1 +1 @@
1
- {"version":3,"file":"resumeUpload.d.ts","sourceRoot":"","sources":["../../../src/test/apps/resumeUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAM5D,eAAO,MAAM,KAAK;;;;EAIhB,CAAA;AAEF,MAAM,MAAM,KAAK,G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AAC3D,eAAO,MAAM,cAAc;;EAEzB,CAAA;AACF,eAAO,MAAM,qBAAqB,mFAA6B,CAAA;AAC/D,eAAO,MAAM,oBAAoB;;EAE/B,CAAA;AACF,eAAO,MAAM,iBAAiB,+EAAyB,CAAA;AACvD,eAAO,MAAM,mBAAmB,iFAA2B,CAAA;AAE3D,eAAO,MAAM,OAAO;;;;oKAOlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY;;;;;iBAUvB,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;iBAQ5B,CAAA;AAIF,eAAO,MAAM,YAAY,EAAE,KAI1B,CAAA;AAID,KAAK,YAAY,GAAG,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AAE7E,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,SAAS,OAAO,KAAG,YA+BrD,CAAA;AAsBH,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,IAmB5D,CAAA"}
@@ -29,11 +29,18 @@ export const Message = S.Union([
29
29
  ClickedRemoveResume,
30
30
  ]);
31
31
  // COMMAND
32
- export const SelectResume = Command.define('SelectResume', SelectedResume, CancelledSelectResume)(File.select(['application/pdf']).pipe(Effect.map(Option.match({
33
- onNone: () => CancelledSelectResume(),
34
- onSome: file => SelectedResume({ file }),
35
- }))));
36
- export const ReadResumePreview = Command.define('ReadResumePreview', { file: File.File }, SucceededReadPreview, FailedReadPreview)(({ file }) => File.readAsDataUrl(file).pipe(Effect.map(dataUrl => SucceededReadPreview({ dataUrl })), Effect.catch(() => Effect.succeed(FailedReadPreview()))));
32
+ export const SelectResume = Command.define('SelectResume', {
33
+ messages: [SelectedResume, CancelledSelectResume],
34
+ execute: File.select(['application/pdf']).pipe(Effect.map(Option.match({
35
+ onNone: () => CancelledSelectResume(),
36
+ onSome: file => SelectedResume({ file }),
37
+ }))),
38
+ });
39
+ export const ReadResumePreview = Command.define('ReadResumePreview', {
40
+ args: { file: File.File },
41
+ messages: [SucceededReadPreview, FailedReadPreview],
42
+ execute: ({ file }) => File.readAsDataUrl(file).pipe(Effect.map(dataUrl => SucceededReadPreview({ dataUrl })), Effect.catch(() => Effect.succeed(FailedReadPreview()))),
43
+ });
37
44
  // INIT
38
45
  export const initialModel = {
39
46
  maybeResume: Option.none(),
@@ -0,0 +1,32 @@
1
+ import { Schema as S } from 'effect';
2
+ import type { Html } from '../../html/index.js';
3
+ export declare const Model: S.Struct<{
4
+ readonly score: S.Number;
5
+ }>;
6
+ export type Model = typeof Model.Type;
7
+ export declare const ClickedIncrement: import("../../schema/index.js").CallableTaggedStruct<"ClickedIncrement", {}>;
8
+ export declare const Message: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"ClickedIncrement", {}>]>;
9
+ export type Message = typeof Message.Type;
10
+ export declare const initialModel: {
11
+ readonly score: number;
12
+ };
13
+ export declare const update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<never>];
14
+ export type ViewInputs = Readonly<{
15
+ label: string;
16
+ toView: (content: Readonly<{
17
+ label: string;
18
+ score: number;
19
+ }>) => Html;
20
+ }>;
21
+ export declare const view: import("../../html/submodel.js").SubmodelView<{
22
+ readonly score: number;
23
+ }, {
24
+ readonly _tag: "ClickedIncrement";
25
+ }, Readonly<{
26
+ label: string;
27
+ toView: (content: Readonly<{
28
+ label: string;
29
+ score: number;
30
+ }>) => Html;
31
+ }>>;
32
+ //# sourceMappingURL=scorePanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorePanel.d.ts","sourceRoot":"","sources":["../../../src/test/apps/scorePanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAO/C,eAAO,MAAM,KAAK;;EAAgC,CAAA;AAClD,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,gBAAgB,8EAAwB,CAAA;AAErD,eAAO,MAAM,OAAO,kGAA8B,CAAA;AAClD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY;;CAA2B,CAAA;AAIpD,eAAO,MAAM,MAAM,GACjB,OAAO,KAAK,EACZ,SAAS,OAAO,KACf,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAMrC,CAAA;AAIH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAA;CACtE,CAAC,CAAA;AAEF,eAAO,MAAM,IAAI;;;;;WAJR,MAAM;YACL,CAAC,OAAO,EAAE,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI;GAetE,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { Match as M, Number, Schema as S } from 'effect';
2
+ import { m } from '../../message/index.js';
3
+ import { evo } from '../../struct/index.js';
4
+ import { defineView } from '../../submodel/public.js';
5
+ // MODEL
6
+ export const Model = S.Struct({ score: S.Number });
7
+ // MESSAGE
8
+ export const ClickedIncrement = m('ClickedIncrement');
9
+ export const Message = S.Union([ClickedIncrement]);
10
+ // INIT
11
+ export const initialModel = Model.make({ score: 0 });
12
+ // UPDATE
13
+ export const update = (model, message) => M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
14
+ ClickedIncrement: () => [evo(model, { score: Number.increment }), []],
15
+ }));
16
+ export const view = defineView((model, viewInputs, h) => h.div([], [
17
+ viewInputs.toView({ label: viewInputs.label, score: model.score }),
18
+ h.button([h.OnClick(ClickedIncrement()), h.Role('button')], ['Increment']),
19
+ ]));
@@ -53,17 +53,17 @@ export declare const UploadFileArgs: S.Struct<{
53
53
  export type UploadFileArgs = typeof UploadFileArgs.Type;
54
54
  export declare const UploadFile: Interruptible.DefinitionWithArgs<"UploadFile", {
55
55
  readonly uploadId: S.Number;
56
- }, {
56
+ }, Pick<{
57
57
  readonly uploadId: number;
58
- }, Effect.Effect<{
58
+ }, "uploadId">, Effect.Effect<{
59
59
  readonly _tag: "SucceededUploadFile";
60
60
  readonly uploadId: number;
61
61
  }, never, never>>;
62
62
  export declare const CancelUploadFile: ({ uploadId }: UploadFileArgs) => Readonly<{
63
63
  name: "UploadFile.Interrupt";
64
- args: {
64
+ args: Pick<{
65
65
  readonly uploadId: number;
66
- };
66
+ }, "uploadId">;
67
67
  interruptsKey: string;
68
68
  effect: Effect.Effect<{
69
69
  readonly _tag: "CompletedCancelUploadFile";
@@ -1 +1 @@
1
- {"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../../src/test/apps/uploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAsB,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEvE,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,aAAa,MAAM,sCAAsC,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAMhE,eAAO,MAAM,YAAY,mEAKvB,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD,eAAO,MAAM,MAAM;;;EAGjB,CAAA;AACF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC,eAAO,MAAM,KAAK;;;;;;EAGhB,CAAA;AACF,MAAM,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Number, Schema as S } from 'effect';
2
+ import * as Command from '../../command/index.js';
2
3
  import * as Interruptible from '../../command/interruptible/index.js';
3
4
  import { m } from '../../message/index.js';
4
5
  import { evo } from '../../struct/index.js';
@@ -43,7 +44,15 @@ export const Message = S.Union([
43
44
  ]);
44
45
  // COMMAND
45
46
  export const UploadFileArgs = S.Struct({ uploadId: S.Number });
46
- export const UploadFile = Interruptible.define('UploadFile', UploadFileArgs.fields, ({ uploadId }) => String(uploadId), SucceededUploadFile, FailedUploadFile)(({ uploadId }) => Effect.as(Effect.never, SucceededUploadFile({ uploadId })));
47
+ export const UploadFile = Command.define('UploadFile', {
48
+ args: UploadFileArgs.fields,
49
+ messages: [SucceededUploadFile, FailedUploadFile],
50
+ interrupt: {
51
+ keyFields: ['uploadId'],
52
+ toKey: ({ uploadId }) => String(uploadId),
53
+ },
54
+ execute: ({ uploadId }) => Effect.as(Effect.never, SucceededUploadFile({ uploadId })),
55
+ });
47
56
  export const CancelUploadFile = ({ uploadId }) => UploadFile.Interrupt({ uploadId }, outcome => CompletedCancelUploadFile({ uploadId, outcome }));
48
57
  // INIT
49
58
  export const initialModel = { uploadId: 0, uploads: [] };
@@ -12,7 +12,7 @@ import { type MountDefinition } from '../mount/index.js';
12
12
  * without the test restating it. Absent on synthetic matchers built for
13
13
  * formatting; treated as empty then.
14
14
  *
15
- * `key` is present on Commands built with `Command.Interruptible.define`:
15
+ * `key` is present on Commands built with an interruptible `Command.define`:
16
16
  * such Commands may stay pending across Messages (they model long-running
17
17
  * work). `interruptsKey` is present on Interrupt Commands: resolving one
18
18
  * drops every pending Command holding that key, mirroring the runtime
@@ -144,7 +144,7 @@ export declare const assertExactCommands: (commands: ReadonlyArray<AnyCommand>,
144
144
  /** Throws if there are any pending Commands. */
145
145
  export declare const assertZeroCommands: (commands: ReadonlyArray<AnyCommand>) => void;
146
146
  /** Throws when trying to send a message with unresolved Commands. Keyed
147
- * Commands (built with `Command.Interruptible.define`) and Interrupt
147
+ * Commands (built with an interruptible `Command.define`) and Interrupt
148
148
  * Commands are exempt: they model in-flight async work that legitimately
149
149
  * stays pending while later Messages arrive, so a story can dispatch the
150
150
  * Message that interrupts a keyed Command, or keep typing while a
@@ -164,7 +164,7 @@ export const assertZeroCommands = (commands) => {
164
164
  }
165
165
  };
166
166
  /** Throws when trying to send a message with unresolved Commands. Keyed
167
- * Commands (built with `Command.Interruptible.define`) and Interrupt
167
+ * Commands (built with an interruptible `Command.define`) and Interrupt
168
168
  * Commands are exempt: they model in-flight async work that legitimately
169
169
  * stays pending while later Messages arrive, so a story can dispatch the
170
170
  * Message that interrupts a keyed Command, or keep typing while a
@@ -1,8 +1,10 @@
1
- import { Effect } from 'effect';
1
+ import { Effect, Option, type Schema } from 'effect';
2
2
  import type { CommandDefinition } from '../command/index.js';
3
3
  import type * as Interruptible from '../command/interruptible/index.js';
4
+ import type { CustomElementSpec } from '../customElement/index.js';
4
5
  import type { File } from '../file/index.js';
5
6
  import type { Document, Html, HtmlBuilder, KeyboardModifiers } from '../html/index.js';
7
+ import type { Entry as ManagedResourceEntry } from '../managedResource/index.js';
6
8
  import type { MountDefinition } from '../mount/index.js';
7
9
  import type { VNode } from '../vdom.js';
8
10
  import type { AnyCommand, AnyMount, CommandMatcher, MountMatcher, MountResolver, PendingMount, Resolver } from './internal.js';
@@ -47,11 +49,11 @@ export type SceneSimulation<Model, Message, OutMessage = undefined> = Readonly<{
47
49
  html: VNode;
48
50
  }>;
49
51
  /** A callable step that sets the initial Model. Carries phantom type for compile-time validation. */
50
- type WithStep<Model> = Readonly<{
52
+ type GivenStep<Model> = Readonly<{
51
53
  _phantomModel: Model;
52
54
  }> & (<M, Message, OutMessage = undefined>(simulation: SceneSimulation<M, Message, OutMessage>) => SceneSimulation<M, Message, OutMessage>);
53
- /** A single step in a scene: either a `with` step or a scene simulation transform. */
54
- export type SceneStep<Model, Message, OutMessage> = WithStep<NoInfer<Model>> | ((simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>);
55
+ /** A single step in a scene: either a `given` step or a scene simulation transform. */
56
+ export type SceneStep<Model, Message, OutMessage> = GivenStep<NoInfer<Model>> | ((simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>);
55
57
  /** A typed Command instance carrying the result Message type via its
56
58
  * `effect` field, so passing `FetchWeather({ zipCode })` to `Scene.Command.resolve`
57
59
  * preserves the link between the Command and its declared result Message. */
@@ -62,13 +64,16 @@ type SceneCommandInstance<ResultMessage = unknown> = Readonly<{
62
64
  }>;
63
65
  /** A Command Definition accepted by `Scene.Command.resolve` as a name matcher:
64
66
  * a plain `Command.define` Definition or an interruptible
65
- * `Command.Interruptible.define` Definition. Both carry the
67
+ * interruptible `Command.define` Definition. Both carry the
66
68
  * `CommandDefinitionTypeId` brand and match by name at runtime, so `resolve`
67
69
  * accepts either, the way `expectHas`/`expectExact` already do. */
68
70
  type ResolvableCommandDefinition<Name extends string, ResultMessage> = CommandDefinition<Name, ResultMessage> | Interruptible.DefinitionNoArgs<Name, Effect.Effect<ResultMessage, any, any>> | Interruptible.DefinitionWithArgs<Name, any, any, Effect.Effect<ResultMessage, any, any>> | Interruptible.DefinitionWithArgsNameKeyed<Name, any, Effect.Effect<ResultMessage, any, any>>;
69
71
  /** Sets the initial Model for a scene test. */
70
- export { with_ as with };
71
- declare const with_: <Model>(model: Model) => WithStep<Model>;
72
+ export declare const given: <Model>(model: Model) => GivenStep<Model>;
73
+ /** A ManagedResource entry a scene can drive: the Option-shaped requirements
74
+ * are what the runtime watches, so the steps can check the current Model
75
+ * against them before dispatching a lifecycle Message. */
76
+ type SceneManagedResourceEntry<EntryModel, EntryMessage, Value, OnAcquired extends (...args: any) => EntryMessage = (value: Value) => EntryMessage> = ManagedResourceEntry<EntryModel, EntryMessage, Option.Option<any>, Value, any, OnAcquired>;
72
77
  /** Steps that operate on the pending Commands of a scene simulation.
73
78
  * Destructure as `const { Command } = Scene` for concise call sites. */
74
79
  export declare const Command: {
@@ -107,6 +112,56 @@ export declare const Mount: {
107
112
  * every Mount that fires and then unmounts during a scene. */
108
113
  readonly expectEnded: (...matchers: ReadonlyArray<MountMatcher>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
109
114
  };
115
+ /** Steps that model Messages arriving from a Subscription.
116
+ * Destructure as `const { Subscription } = Scene` for concise call sites. */
117
+ export declare const Subscription: {
118
+ /** Feeds a Message through update as if a Subscription had emitted it,
119
+ * then re-renders. Only for Messages whose real cause is a Subscription;
120
+ * if the Message has a DOM affordance, click it instead. */
121
+ readonly emit: <MessageInput>(message: MessageInput) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
122
+ };
123
+ /** Steps that model the lifecycle Messages of a ManagedResource. The test
124
+ * declares the lifecycle outcome the way `Scene.Command.resolve` declares a
125
+ * Command result, and each step checks the current Model against the
126
+ * entry's `modelToMaybeRequirements` gate first, mirroring the runtime's
127
+ * None to Some and Some to None transitions. The Some to Some re-acquire
128
+ * transition has no step yet. Destructure as
129
+ * `const { ManagedResource } = Scene` for concise call sites. */
130
+ export declare const ManagedResource: {
131
+ /** Declares a successful acquire, feeding the entry's `onAcquired` Message
132
+ * through update. Takes exactly the arguments `onAcquired` declares. The
133
+ * current Model must request the resource. */
134
+ readonly acquire: <EntryModel, EntryMessage, Value, Args extends ReadonlyArray<any>>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value, (...args: Args) => EntryMessage>, ...args: NoInfer<Args>) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
135
+ /** Declares a failed acquire, feeding `onAcquireError(error)` through
136
+ * update. The current Model must request the resource. */
137
+ readonly failAcquire: <EntryModel, EntryMessage, Value>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value>, error: unknown) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
138
+ /** Declares a release, feeding `onReleased()` through update. The current
139
+ * Model must no longer request the resource. */
140
+ readonly release: <EntryModel, EntryMessage, Value>(entry: SceneManagedResourceEntry<EntryModel, EntryMessage, Value>) => <Message, OutMessage = undefined>(simulation: SceneSimulation<EntryModel, Message, OutMessage>) => SceneSimulation<EntryModel, Message, OutMessage>;
141
+ };
142
+ /** Steps that model CustomEvents arriving from a rendered custom element.
143
+ * Destructure as `const { CustomElement } = Scene` for concise call sites. */
144
+ export declare const CustomElement: {
145
+ /** Dispatches a declared CustomEvent through the element's event mapping.
146
+ * The event name and detail are typed by the spec's event Schemas. */
147
+ readonly emit: <Events extends Record<string, Schema.Top>, Name extends keyof Events & string>(spec: CustomElementSpec<string, Record<string, Schema.Top>, Events>, target: string | Locator, eventName: Name, detail: Schema.Schema.Type<Events[Name]>) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
148
+ };
149
+ /** Asserts that the OutMessage is Some with the expected value.
150
+ *
151
+ * The tracked OutMessage is the third element of the most recent update
152
+ * result that had one. An update branch that returns a two-tuple leaves
153
+ * the previous value latched in place, so keep every branch of an
154
+ * OutMessage-returning update on the three-tuple shape, returning
155
+ * `Option.none()` when there is nothing to report. */
156
+ export declare const expectOutMessage: <Expected>(expected: Expected) => <Model, Message, OutMessage>(simulation: SceneSimulation<Model, Message, Option.Option<OutMessage>>) => SceneSimulation<Model, Message, Option.Option<OutMessage>>;
157
+ /** Asserts that the OutMessage is None.
158
+ *
159
+ * The tracked OutMessage is the third element of the most recent update
160
+ * result that had one. An update branch that returns a two-tuple leaves
161
+ * the previous value latched in place, so keep every branch of an
162
+ * OutMessage-returning update on the three-tuple shape, returning
163
+ * `Option.none()` when there is nothing to report. */
164
+ export declare const expectNoOutMessage: () => <Model, Message, OutMessage>(simulation: SceneSimulation<Model, Message, Option.Option<OutMessage>>) => SceneSimulation<Model, Message, Option.Option<OutMessage>>;
110
165
  /** Runs a function for side effects (e.g. assertions) without breaking the step chain. */
111
166
  export declare const tap: <Model, Message, OutMessage = undefined>(f: (simulation: SceneSimulation<Model, Message, OutMessage>) => void) => (simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
112
167
  /** Scopes a sequence of steps to a parent element. Every Locator referenced by
@@ -250,6 +305,23 @@ export declare const expectAll: (locatorAll: LocatorAll) => {
250
305
  toHaveCount: (expected: number) => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
251
306
  toBeEmpty: () => <Model, Message, OutMessage = undefined>(simulation: SceneSimulation<Model, Message, OutMessage>) => SceneSimulation<Model, Message, OutMessage>;
252
307
  };
308
+ /** Adapts a Submodel view that declares `ViewInputs` to the `(model, h)`
309
+ * shape `Scene.scene` takes. `defaults` supplies the full `ViewInputs`
310
+ * once; the returned factory accepts per-test overrides for everything
311
+ * except `toView`, so tests vary value inputs while the renderer stays
312
+ * pinned:
313
+ *
314
+ * ```ts
315
+ * const sceneView = Scene.withViewInputs(view, {
316
+ * value: 5,
317
+ * toView: testToView,
318
+ * })
319
+ *
320
+ * Scene.scene({ update, view: sceneView() }, ...)
321
+ * Scene.scene({ update, view: sceneView({ isDisabled: true }) }, ...)
322
+ * ```
323
+ */
324
+ export declare const withViewInputs: <Model, Message, ViewInputs extends object>(view: (model: Model, viewInputs: ViewInputs, h: HtmlBuilder<Message>) => Html, defaults: NoInfer<ViewInputs>) => (overrides?: Omit<Partial<NoInfer<ViewInputs>>, "toView">) => (model: Model, h: HtmlBuilder<Message>) => Html;
253
325
  /** Executes a scene test. Throws if any Commands remain unresolved. */
254
326
  export declare const scene: {
255
327
  <Model, Message, OutMessage>(config: Readonly<{