foldkit 0.39.0 → 0.40.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  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 +8 -8
  9. package/dist/fieldValidation/index.d.ts +45 -37
  10. package/dist/fieldValidation/index.d.ts.map +1 -1
  11. package/dist/fieldValidation/public.d.ts +1 -1
  12. package/dist/fieldValidation/public.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/runtime/runtime.d.ts +10 -10
  17. package/dist/runtime/runtime.d.ts.map +1 -1
  18. package/dist/test/index.d.ts +40 -0
  19. package/dist/test/index.d.ts.map +1 -0
  20. package/dist/test/index.js +138 -0
  21. package/dist/test/public.d.ts +3 -0
  22. package/dist/test/public.d.ts.map +1 -0
  23. package/dist/test/public.js +1 -0
  24. package/dist/ui/checkbox/index.d.ts +1 -1
  25. package/dist/ui/checkbox/index.d.ts.map +1 -1
  26. package/dist/ui/combobox/multi.d.ts +1 -1
  27. package/dist/ui/combobox/shared.d.ts +34 -1
  28. package/dist/ui/combobox/shared.d.ts.map +1 -1
  29. package/dist/ui/combobox/shared.js +10 -10
  30. package/dist/ui/combobox/single.d.ts +1 -1
  31. package/dist/ui/dialog/index.d.ts +13 -1
  32. package/dist/ui/dialog/index.d.ts.map +1 -1
  33. package/dist/ui/dialog/index.js +4 -4
  34. package/dist/ui/disclosure/index.d.ts +4 -1
  35. package/dist/ui/disclosure/index.d.ts.map +1 -1
  36. package/dist/ui/disclosure/index.js +1 -1
  37. package/dist/ui/listbox/multi.d.ts +1 -1
  38. package/dist/ui/listbox/shared.d.ts +40 -1
  39. package/dist/ui/listbox/shared.d.ts.map +1 -1
  40. package/dist/ui/listbox/shared.js +12 -12
  41. package/dist/ui/listbox/single.d.ts +1 -1
  42. package/dist/ui/menu/index.d.ts +40 -1
  43. package/dist/ui/menu/index.d.ts.map +1 -1
  44. package/dist/ui/menu/index.js +12 -12
  45. package/dist/ui/popover/index.d.ts +30 -1
  46. package/dist/ui/popover/index.d.ts.map +1 -1
  47. package/dist/ui/popover/index.js +9 -9
  48. package/dist/ui/radioGroup/index.d.ts +4 -1
  49. package/dist/ui/radioGroup/index.d.ts.map +1 -1
  50. package/dist/ui/radioGroup/index.js +1 -1
  51. package/dist/ui/switch/index.d.ts +1 -1
  52. package/dist/ui/switch/index.d.ts.map +1 -1
  53. package/dist/ui/tabs/index.d.ts +4 -1
  54. package/dist/ui/tabs/index.d.ts.map +1 -1
  55. package/dist/ui/tabs/index.js +1 -1
  56. 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
@@ -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 }, []],
@@ -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,C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CAAC,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;AAwQzE,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;AAyiCvE,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCA4ChC,CAAA"}
@@ -174,14 +174,14 @@ const computeDiff = (previous, current) => {
174
174
  };
175
175
  };
176
176
  // 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');
177
+ export const JumpTo = Command.define('JumpTo', CompletedJump);
178
+ export const InspectState = Command.define('InspectState', ReceivedInspectedState);
179
+ export const InspectLatest = Command.define('InspectLatest', ReceivedInspectedState);
180
+ export const Resume = Command.define('Resume', CompletedResume);
181
+ export const Clear = Command.define('Clear', CompletedClear);
182
+ export const LockScroll = Command.define('LockScroll', LockedScroll);
183
+ export const UnlockScroll = Command.define('UnlockScroll', UnlockedScroll);
184
+ export const ScrollToTop = Command.define('ScrollToTop', ScrolledToTop);
185
185
  const makeUpdate = (store, shadow, mode) => {
186
186
  const jumpTo = (index) => JumpTo(Effect.gen(function* () {
187
187
  yield* store.jumpTo(index);
@@ -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,MAAM,IAAI,CAAC,EAIZ,MAAM,QAAQ,CAAA;AAIf,0HAA0H;AAC1H,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,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sB,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';
@@ -78,7 +78,7 @@ export type CrashConfig<Model, Message> = Readonly<{
78
78
  }>;
79
79
  type BaseElementConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = Readonly<{
80
80
  Model: Schema.Schema<Model, any, never>;
81
- update: (model: Model, message: Message) => [
81
+ update: (model: Model, message: Message) => readonly [
82
82
  Model,
83
83
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
84
84
  ];
@@ -95,21 +95,21 @@ type BaseElementConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schem
95
95
  export type ElementConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never> = BaseElementConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
96
96
  Flags: Schema.Schema<Flags, any, never>;
97
97
  flags: Effect.Effect<Flags>;
98
- init: (flags: Flags) => [
98
+ init: (flags: Flags) => readonly [
99
99
  Model,
100
100
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
101
101
  ];
102
102
  }>;
103
103
  /** Configuration for `makeElement` without flags. */
104
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: () => [
105
+ init: () => readonly [
106
106
  Model,
107
107
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
108
108
  ];
109
109
  }>;
110
110
  type BaseApplicationConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = Readonly<{
111
111
  Model: Schema.Schema<Model, any, never>;
112
- update: (model: Model, message: Message) => [
112
+ update: (model: Model, message: Message) => readonly [
113
113
  Model,
114
114
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
115
115
  ];
@@ -127,31 +127,31 @@ type BaseApplicationConfig<Model, Message, StreamDepsMap extends Schema.Struct<S
127
127
  export type ApplicationConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags, Resources = never, ManagedResourceServices = never> = BaseApplicationConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
128
128
  Flags: Schema.Schema<Flags, any, never>;
129
129
  flags: Effect.Effect<Flags>;
130
- init: (flags: Flags, url: Url) => [
130
+ init: (flags: Flags, url: Url) => readonly [
131
131
  Model,
132
132
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
133
133
  ];
134
134
  }>;
135
135
  /** Configuration for `makeApplication` without flags. */
136
136
  export type ApplicationConfigWithoutFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Resources = never, ManagedResourceServices = never> = BaseApplicationConfig<Model, Message, StreamDepsMap, Resources, ManagedResourceServices> & Readonly<{
137
- init: (url: Url) => [
137
+ init: (url: Url) => readonly [
138
138
  Model,
139
139
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
140
140
  ];
141
141
  }>;
142
142
  /** The `init` function type for elements, with an optional `flags` parameter when `Flags` is not `void`. */
143
- export type ElementInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? () => [
143
+ export type ElementInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? () => readonly [
144
144
  Model,
145
145
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
146
- ] : (flags: Flags) => [
146
+ ] : (flags: Flags) => readonly [
147
147
  Model,
148
148
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
149
149
  ];
150
150
  /** The `init` function type for applications, receives the current URL and optional flags. */
151
- export type ApplicationInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? (url: Url) => [
151
+ export type ApplicationInit<Model, Message, Flags = void, Resources = never, ManagedResourceServices = never> = Flags extends void ? (url: Url) => readonly [
152
152
  Model,
153
153
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
154
- ] : (flags: Flags, url: Url) => [
154
+ ] : (flags: Flags, url: Url) => readonly [
155
155
  Model,
156
156
  ReadonlyArray<Command<Message, never, Resources | ManagedResourceServices>>
157
157
  ];
@@ -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,OAAO,EAAE,MAAM,YAAY,CAAA;AAGzC,OAAO,EAAE,IAAI,EAAE,MAA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;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,0BAA0B,CAChC,KAAK,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACL,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AAEpB,wBAAgB,eAAe,CAC7B,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,6BAA6B,CACnC,KAAK,EACL,OAAO,EACP,aAAa,EACb,SAAS,EACT,uBAAuB,CACxB,GACA,iBAAiB,CAAA;AA4FpB,kEAAkE;AAClE,eAAO,MAAM,GAAG,GAAI,gBAAgB,iBAAiB,KAAG,IA+BvD,CAAA"}
@@ -0,0 +1,40 @@
1
+ import type { CommandDefinition } from '../command';
2
+ /** A Command in a test simulation, identified by name. */
3
+ export type AnyCommand = Readonly<{
4
+ name: string;
5
+ }>;
6
+ /** An immutable test simulation of a Foldkit program. */
7
+ export type Simulation<Model, Message, OutMessage = undefined> = Readonly<{
8
+ model: Model;
9
+ message: Message | undefined;
10
+ commands: ReadonlyArray<AnyCommand>;
11
+ outMessage: OutMessage;
12
+ }>;
13
+ /** A callable step that sets the initial Model. Carries phantom type for compile-time validation. */
14
+ export type WithStep<Model> = Readonly<{
15
+ _phantomModel: Model;
16
+ }> & (<M, Message, OutMessage = undefined>(simulation: Simulation<M, Message, OutMessage>) => Simulation<M, Message, OutMessage>);
17
+ /** Sets the initial Model for a test story. */
18
+ export { with_ as with };
19
+ declare const with_: <Model>(model: Model) => WithStep<Model>;
20
+ /** Sends a Message through update. Commands stay pending until resolve or resolveAll. */
21
+ export declare const message: <Message>(message_: NoInfer<Message>) => <Model, OutMessage = undefined>(simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>;
22
+ /** Resolves a specific pending Command with the given result Message. */
23
+ export declare const resolve: {
24
+ <Name extends string, ResultMessage>(definition: CommandDefinition<Name, ResultMessage>, resultMessage: ResultMessage): <Model, Message, OutMessage = undefined>(simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>;
25
+ <Name extends string, ResultMessage, ParentMessage>(definition: CommandDefinition<Name, ResultMessage>, resultMessage: ResultMessage, toParentMessage: (message: ResultMessage) => ParentMessage): <Model, Message, OutMessage = undefined>(simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>;
26
+ };
27
+ /** A Command definition paired with the result Message to resolve it with. */
28
+ export type ResolverPair<Name extends string = string, ResultMessage = unknown> = readonly [CommandDefinition<Name, ResultMessage>, ResultMessage];
29
+ /** Resolves all listed Commands with their result Messages. Handles cascading resolution. */
30
+ export declare const resolveAll: (pairs: ReadonlyArray<ResolverPair>) => <Model, Message, OutMessage = undefined>(simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>;
31
+ /** Runs a function for side effects (e.g. assertions) without breaking the pipe chain. */
32
+ export declare const tap: <Model, Message, OutMessage = undefined>(f: (simulation: Simulation<Model, Message, OutMessage>) => void) => (simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>;
33
+ /** A single step in a test story — either a {@link WithStep} or a simulation transform. */
34
+ export type StoryStep<Model, Message, OutMessage> = WithStep<NoInfer<Model>> | ((simulation: Simulation<Model, Message, OutMessage>) => Simulation<Model, Message, OutMessage>);
35
+ /** Executes a test story. Throws if any Commands remain unresolved. */
36
+ export declare const story: {
37
+ <Model, Message, OutMessage>(updateFn: (model: Model, message: Message) => readonly [Model, ReadonlyArray<AnyCommand>, OutMessage], ...steps: ReadonlyArray<StoryStep<Model, Message, OutMessage>>): void;
38
+ <Model, Message>(updateFn: (model: Model, message: Message) => readonly [Model, ReadonlyArray<AnyCommand>], ...steps: ReadonlyArray<StoryStep<Model, Message, undefined>>): void;
39
+ };
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEnD,yDAAyD;AACzD,MAAM,MAAM,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,IAAI,QAAQ,CAAC;IACxE,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IACnC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAC,CAAA;AAEF,qGAAqG;AACrG,MAAM,MAAM,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC;IAAE,aAAa,EAAE,KAAK,CAAA;CAAE,CAAC,GAC9D,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,EAClC,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,KAC3C,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;AAsD1C,+CAA+C;AAC/C,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAA;AACxB,QAAA,MAAM,KAAK,GAAI,KAAK,EAAE,OAAO,KAAK,KAAG,QAAQ,CAAC,KAAK,CAiBlD,CAAA;AAED,yFAAyF;AACzF,eAAO,MAAM,OAAO,GACjB,OAAO,EAAE,UAAU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,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,GAC5D,IAAI,CAAA;CAyCR,CAAA"}
@@ -0,0 +1,138 @@
1
+ import { Array, Predicate, pipe } from 'effect';
2
+ const toInternal = (simulation) =>
3
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
4
+ simulation;
5
+ const resolveByName = (internal, commandName, resolverMessage) => {
6
+ const commandIndex = internal.commands.findIndex(({ name }) => name === commandName);
7
+ if (commandIndex === -1) {
8
+ return undefined;
9
+ }
10
+ const remainingCommands = Array.remove(internal.commands, commandIndex);
11
+ const result = internal.updateFn(internal.model, resolverMessage);
12
+ const nextModel = result[0];
13
+ const newCommands = result[1];
14
+ const outMessage = result.length === 3 ? result[2] : internal.outMessage;
15
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
16
+ return {
17
+ ...internal,
18
+ model: nextModel,
19
+ message: resolverMessage,
20
+ commands: Array.appendAll(remainingCommands, newCommands),
21
+ outMessage,
22
+ };
23
+ };
24
+ /** Sets the initial Model for a test story. */
25
+ export { with_ as with };
26
+ const with_ = (model) => {
27
+ const step = (simulation) => {
28
+ const internal = toInternal(simulation);
29
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
30
+ return { ...internal, model };
31
+ };
32
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
33
+ return Object.assign(step, {
34
+ _phantomModel: undefined,
35
+ });
36
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
37
+ };
38
+ /** Sends a Message through update. Commands stay pending until resolve or resolveAll. */
39
+ export const message = (message_) => (simulation) => {
40
+ const internal = toInternal(simulation);
41
+ if (Array.isNonEmptyReadonlyArray(internal.commands)) {
42
+ const names = pipe(internal.commands, Array.map(({ name }) => ` ${name}`), Array.join('\n'));
43
+ throw new Error(`I found unresolved Commands when you sent a new Message:\n\n${names}\n\n` +
44
+ 'Resolve all Commands before sending the next Message.\n' +
45
+ 'Use Test.resolve(Definition, ResultMessage) for each one,\n' +
46
+ 'or Test.resolveAll([...pairs]) to resolve them all at once.');
47
+ }
48
+ const result = internal.updateFn(internal.model, message_);
49
+ const nextModel = result[0];
50
+ const commands = result[1];
51
+ const outMessage = result.length === 3 ? result[2] : internal.outMessage;
52
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
53
+ return {
54
+ ...internal,
55
+ model: nextModel,
56
+ message: message_,
57
+ commands: Array.appendAll(internal.commands, commands),
58
+ outMessage,
59
+ };
60
+ };
61
+ /** Resolves a specific pending Command with the given result Message. */
62
+ export const resolve = (definition, resultMessage, toParentMessage) => (simulation) => {
63
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
64
+ const internal = toInternal(simulation);
65
+ const messageForUpdate = (Predicate.isUndefined(toParentMessage)
66
+ ? resultMessage
67
+ : toParentMessage(resultMessage));
68
+ const next = resolveByName(internal, definition.name, messageForUpdate);
69
+ if (Predicate.isUndefined(next)) {
70
+ const pending = Array.isNonEmptyReadonlyArray(internal.commands)
71
+ ? pipe(internal.commands, Array.map(({ name }) => ` ${name}`), Array.join('\n'))
72
+ : ' (none)';
73
+ throw new Error(`I tried to resolve "${definition.name}" but it wasn't in the pending Commands.\n\n` +
74
+ `Pending Commands:\n${pending}\n\n` +
75
+ 'Make sure the previous Message produced this Command.');
76
+ }
77
+ return next;
78
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
79
+ };
80
+ /** Resolves all listed Commands with their result Messages. Handles cascading resolution. */
81
+ export const resolveAll = (pairs) => (simulation) => {
82
+ const internal = toInternal(simulation);
83
+ const resolvers = {};
84
+ for (const [definition, resultMessage] of pairs) {
85
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
86
+ resolvers[definition.name] = resultMessage;
87
+ }
88
+ let current = {
89
+ ...internal,
90
+ resolvers: { ...internal.resolvers, ...resolvers },
91
+ };
92
+ const MAX_CASCADE_DEPTH = 100;
93
+ for (let depth = 0; depth < MAX_CASCADE_DEPTH; depth++) {
94
+ const resolvable = current.commands.find(({ name }) => name in current.resolvers);
95
+ if (Predicate.isUndefined(resolvable)) {
96
+ break;
97
+ }
98
+ const next = resolveByName(current, resolvable.name, current.resolvers[resolvable.name]);
99
+ if (Predicate.isUndefined(next)) {
100
+ break;
101
+ }
102
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
103
+ current = next;
104
+ if (depth === MAX_CASCADE_DEPTH - 1) {
105
+ throw new Error('resolveAll hit the maximum cascade depth (100). ' +
106
+ 'This usually means Commands are producing Commands in an infinite cycle.');
107
+ }
108
+ }
109
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
110
+ return current;
111
+ };
112
+ /** Runs a function for side effects (e.g. assertions) without breaking the pipe chain. */
113
+ export const tap = (f) => (simulation) => {
114
+ f(simulation);
115
+ return simulation;
116
+ };
117
+ /** Executes a test story. Throws if any Commands remain unresolved. */
118
+ export const story = (updateFn, ...steps) => {
119
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
120
+ const seed = {
121
+ model: undefined,
122
+ message: undefined,
123
+ commands: [],
124
+ outMessage: undefined,
125
+ updateFn,
126
+ resolvers: {},
127
+ };
128
+ const result = steps.reduce((current, step) => step(current), seed);
129
+ /* eslint-enable @typescript-eslint/consistent-type-assertions */
130
+ const internal = toInternal(result);
131
+ if (Array.isNonEmptyReadonlyArray(internal.commands)) {
132
+ const names = pipe(internal.commands, Array.map(({ name }) => ` ${name}`), Array.join('\n'));
133
+ throw new Error(`I found Commands without resolvers:\n\n${names}\n\n` +
134
+ 'Every Command produced by update needs to be resolved.\n' +
135
+ 'Use Test.resolve(Definition, ResultMessage) for each one,\n' +
136
+ 'or Test.resolveAll([...pairs]) to resolve them all at once.');
137
+ }
138
+ };
@@ -0,0 +1,3 @@
1
+ export type { AnyCommand, ResolverPair, Simulation, StoryStep, WithStep, } from './index';
2
+ export { message, resolve, resolveAll, story, tap, with } from './index';
3
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/test/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA"}