foldkit 0.86.0 → 0.88.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 (154) hide show
  1. package/dist/command/index.d.ts +60 -13
  2. package/dist/command/index.d.ts.map +1 -1
  3. package/dist/command/index.js +41 -16
  4. package/dist/command/public.d.ts +1 -1
  5. package/dist/command/public.d.ts.map +1 -1
  6. package/dist/devTools/overlay.d.ts +44 -20
  7. package/dist/devTools/overlay.d.ts.map +1 -1
  8. package/dist/devTools/overlay.js +120 -79
  9. package/dist/devTools/protocol.d.ts +48 -11
  10. package/dist/devTools/protocol.d.ts.map +1 -1
  11. package/dist/devTools/protocol.js +8 -3
  12. package/dist/devTools/serialize.d.ts +8 -2
  13. package/dist/devTools/serialize.d.ts.map +1 -1
  14. package/dist/devTools/serialize.js +11 -2
  15. package/dist/devTools/store.d.ts +8 -4
  16. package/dist/devTools/store.d.ts.map +1 -1
  17. package/dist/devTools/store.js +6 -6
  18. package/dist/devTools/webSocketBridge.d.ts.map +1 -1
  19. package/dist/devTools/webSocketBridge.js +2 -2
  20. package/dist/{task → dom}/dom.d.ts +10 -10
  21. package/dist/dom/dom.d.ts.map +1 -0
  22. package/dist/{task → dom}/dom.js +15 -15
  23. package/dist/{task → dom}/elementMovement.d.ts +1 -1
  24. package/dist/dom/elementMovement.d.ts.map +1 -0
  25. package/dist/{task → dom}/elementMovement.js +3 -3
  26. package/dist/{task → dom}/error.d.ts +0 -8
  27. package/dist/dom/error.d.ts.map +1 -0
  28. package/dist/{task → dom}/error.js +0 -3
  29. package/dist/dom/index.d.ts +8 -0
  30. package/dist/dom/index.d.ts.map +1 -0
  31. package/dist/dom/index.js +6 -0
  32. package/dist/{task → dom}/inert.d.ts +4 -3
  33. package/dist/dom/inert.d.ts.map +1 -0
  34. package/dist/{task → dom}/inert.js +4 -3
  35. package/dist/dom/public.d.ts +3 -0
  36. package/dist/dom/public.d.ts.map +1 -0
  37. package/dist/dom/public.js +1 -0
  38. package/dist/{task → dom}/scrollLock.d.ts +3 -3
  39. package/dist/dom/scrollLock.d.ts.map +1 -0
  40. package/dist/{task → dom}/scrollLock.js +3 -3
  41. package/dist/dom/waitForAnimation.d.ts +17 -0
  42. package/dist/dom/waitForAnimation.d.ts.map +1 -0
  43. package/dist/dom/waitForAnimation.js +23 -0
  44. package/dist/index.d.ts +2 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2 -1
  47. package/dist/render/index.d.ts +2 -0
  48. package/dist/render/index.d.ts.map +1 -0
  49. package/dist/render/index.js +1 -0
  50. package/dist/render/public.d.ts +2 -0
  51. package/dist/render/public.d.ts.map +1 -0
  52. package/dist/render/public.js +1 -0
  53. package/dist/render/render.d.ts +40 -0
  54. package/dist/render/render.d.ts.map +1 -0
  55. package/dist/render/render.js +48 -0
  56. package/dist/runtime/runtime.d.ts.map +1 -1
  57. package/dist/runtime/runtime.js +12 -5
  58. package/dist/test/apps/counter.d.ts +14 -13
  59. package/dist/test/apps/counter.d.ts.map +1 -1
  60. package/dist/test/apps/counter.js +6 -3
  61. package/dist/test/apps/formChild.d.ts +4 -17
  62. package/dist/test/apps/formChild.d.ts.map +1 -1
  63. package/dist/test/apps/formChild.js +4 -6
  64. package/dist/test/apps/login.d.ts +3 -6
  65. package/dist/test/apps/login.d.ts.map +1 -1
  66. package/dist/test/apps/login.js +2 -3
  67. package/dist/test/apps/resumeUpload.d.ts +9 -7
  68. package/dist/test/apps/resumeUpload.d.ts.map +1 -1
  69. package/dist/test/apps/resumeUpload.js +4 -6
  70. package/dist/test/internal.d.ts +58 -13
  71. package/dist/test/internal.d.ts.map +1 -1
  72. package/dist/test/internal.js +121 -39
  73. package/dist/test/scene.d.ts +14 -3
  74. package/dist/test/scene.d.ts.map +1 -1
  75. package/dist/test/scene.js +21 -15
  76. package/dist/test/story.d.ts +15 -5
  77. package/dist/test/story.d.ts.map +1 -1
  78. package/dist/test/story.js +22 -15
  79. package/dist/ui/animation/update.d.ts +7 -5
  80. package/dist/ui/animation/update.d.ts.map +1 -1
  81. package/dist/ui/animation/update.js +8 -9
  82. package/dist/ui/calendar/index.d.ts +7 -8
  83. package/dist/ui/calendar/index.d.ts.map +1 -1
  84. package/dist/ui/calendar/index.js +8 -11
  85. package/dist/ui/calendar/public.d.ts +1 -1
  86. package/dist/ui/calendar/public.d.ts.map +1 -1
  87. package/dist/ui/calendar/public.js +1 -1
  88. package/dist/ui/combobox/multi.d.ts +1 -0
  89. package/dist/ui/combobox/multi.d.ts.map +1 -1
  90. package/dist/ui/combobox/shared.d.ts +32 -17
  91. package/dist/ui/combobox/shared.d.ts.map +1 -1
  92. package/dist/ui/combobox/shared.js +18 -29
  93. package/dist/ui/combobox/single.d.ts +1 -0
  94. package/dist/ui/combobox/single.d.ts.map +1 -1
  95. package/dist/ui/dialog/index.d.ts +10 -5
  96. package/dist/ui/dialog/index.d.ts.map +1 -1
  97. package/dist/ui/dialog/index.js +12 -11
  98. package/dist/ui/disclosure/index.d.ts +5 -3
  99. package/dist/ui/disclosure/index.d.ts.map +1 -1
  100. package/dist/ui/disclosure/index.js +4 -4
  101. package/dist/ui/dragAndDrop/index.d.ts +14 -7
  102. package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
  103. package/dist/ui/dragAndDrop/index.js +20 -9
  104. package/dist/ui/listbox/multi.d.ts +2 -1
  105. package/dist/ui/listbox/multi.d.ts.map +1 -1
  106. package/dist/ui/listbox/shared.d.ts +41 -22
  107. package/dist/ui/listbox/shared.d.ts.map +1 -1
  108. package/dist/ui/listbox/shared.js +22 -35
  109. package/dist/ui/listbox/single.d.ts +2 -1
  110. package/dist/ui/listbox/single.d.ts.map +1 -1
  111. package/dist/ui/menu/index.d.ts +40 -22
  112. package/dist/ui/menu/index.d.ts.map +1 -1
  113. package/dist/ui/menu/index.js +26 -38
  114. package/dist/ui/popover/index.d.ts +26 -16
  115. package/dist/ui/popover/index.d.ts.map +1 -1
  116. package/dist/ui/popover/index.js +15 -22
  117. package/dist/ui/radioGroup/index.d.ts +6 -3
  118. package/dist/ui/radioGroup/index.d.ts.map +1 -1
  119. package/dist/ui/radioGroup/index.js +6 -11
  120. package/dist/ui/tabs/index.d.ts +6 -3
  121. package/dist/ui/tabs/index.d.ts.map +1 -1
  122. package/dist/ui/tabs/index.js +14 -24
  123. package/dist/ui/toast/index.d.ts +4 -0
  124. package/dist/ui/toast/index.d.ts.map +1 -1
  125. package/dist/ui/toast/update.d.ts +11 -3
  126. package/dist/ui/toast/update.d.ts.map +1 -1
  127. package/dist/ui/toast/update.js +8 -5
  128. package/dist/ui/tooltip/index.d.ts +6 -3
  129. package/dist/ui/tooltip/index.d.ts.map +1 -1
  130. package/dist/ui/tooltip/index.js +2 -5
  131. package/dist/ui/virtualList/index.d.ts +7 -3
  132. package/dist/ui/virtualList/index.d.ts.map +1 -1
  133. package/dist/ui/virtualList/index.js +15 -4
  134. package/package.json +9 -5
  135. package/dist/task/dom.d.ts.map +0 -1
  136. package/dist/task/elementMovement.d.ts.map +0 -1
  137. package/dist/task/error.d.ts.map +0 -1
  138. package/dist/task/index.d.ts +0 -10
  139. package/dist/task/index.d.ts.map +0 -1
  140. package/dist/task/index.js +0 -8
  141. package/dist/task/inert.d.ts.map +0 -1
  142. package/dist/task/public.d.ts +0 -2
  143. package/dist/task/public.d.ts.map +0 -1
  144. package/dist/task/public.js +0 -1
  145. package/dist/task/random.d.ts +0 -21
  146. package/dist/task/random.d.ts.map +0 -1
  147. package/dist/task/random.js +0 -20
  148. package/dist/task/scrollLock.d.ts.map +0 -1
  149. package/dist/task/time.d.ts +0 -43
  150. package/dist/task/time.d.ts.map +0 -1
  151. package/dist/task/time.js +0 -53
  152. package/dist/task/timing.d.ts +0 -62
  153. package/dist/task/timing.d.ts.map +0 -1
  154. package/dist/task/timing.js +0 -77
@@ -3,41 +3,88 @@ import { Effect, Schema } from 'effect';
3
3
  export declare const CommandDefinitionTypeId: unique symbol;
4
4
  /** Type-level brand for CommandDefinition values. */
5
5
  export type CommandDefinitionTypeId = typeof CommandDefinitionTypeId;
6
- /** A named Effect that produces a message. */
6
+ /** A named Effect that produces a message, optionally carrying the args used to construct it. */
7
7
  export type Command<T, E = never, R = never> = [T] extends [Schema.Top] ? Readonly<{
8
8
  name: string;
9
+ args?: Record<string, unknown>;
9
10
  effect: Effect.Effect<Schema.Schema.Type<T>, E, R>;
10
11
  }> : Readonly<{
11
12
  name: string;
13
+ args?: Record<string, unknown>;
12
14
  effect: Effect.Effect<T, E, R>;
13
15
  }>;
14
- /** A Command identity created with `Command.define`. Call with an Effect to create a Command. */
15
- export interface CommandDefinition<Name extends string, ResultMessage = any> {
16
+ /** A Command definition for a Command with no declared args. Call as `Definition()` to produce a Command instance. */
17
+ export interface CommandDefinitionNoArgs<Name extends string, Eff extends Effect.Effect<any, any, any>> {
16
18
  readonly [CommandDefinitionTypeId]: CommandDefinitionTypeId;
17
19
  readonly name: Name;
18
- <CommandEffect extends Effect.Effect<ResultMessage, any, any>>(effect: CommandEffect): Readonly<{
20
+ (): Readonly<{
19
21
  name: Name;
20
- effect: CommandEffect;
22
+ effect: Eff;
21
23
  }>;
22
24
  }
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.Top>>(name: Name, ...results: Results): CommandDefinition<Name, Schema.Schema.Type<Results[number]>>;
26
- };
27
- /** Transforms the Effect inside a Command while preserving its name. */
25
+ /** A Command definition for a Command with declared args. Call as `Definition(args)` to produce a Command instance. */
26
+ export interface CommandDefinitionWithArgs<Name extends string, Fields extends Schema.Struct.Fields, Eff extends Effect.Effect<any, any, any>> {
27
+ readonly [CommandDefinitionTypeId]: CommandDefinitionTypeId;
28
+ readonly name: Name;
29
+ (args: Schema.Schema.Type<Schema.Struct<Fields>>): Readonly<{
30
+ name: Name;
31
+ args: Schema.Schema.Type<Schema.Struct<Fields>>;
32
+ effect: Eff;
33
+ }>;
34
+ }
35
+ /** A Command definition created with `Command.define`. Union over the no-args and with-args shapes; consumers that only need name/identity can accept this. */
36
+ export type CommandDefinition<Name extends string = string, ResultMessage = any> = CommandDefinitionNoArgs<Name, Effect.Effect<ResultMessage, any, any>> | CommandDefinitionWithArgs<Name, any, Effect.Effect<ResultMessage, any, any>>;
37
+ /**
38
+ * Defines a Command. Two forms, distinguished by whether the second argument
39
+ * is a Schema (a result message) or a record of Schemas (the args declaration).
40
+ *
41
+ * The Effect (or effect builder) is bound at definition time. The returned
42
+ * Definition is callable: with no args for a Command that doesn't declare any,
43
+ * or with the declared args record otherwise.
44
+ *
45
+ * @example No args
46
+ * ```ts
47
+ * const LockScroll = Command.define('LockScroll', CompletedLockScroll)(
48
+ * Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())),
49
+ * )
50
+ * // Call site:
51
+ * LockScroll()
52
+ * ```
53
+ *
54
+ * @example With args
55
+ * ```ts
56
+ * const FetchWeather = Command.define(
57
+ * 'FetchWeather',
58
+ * { zipCode: S.String },
59
+ * SucceededFetchWeather,
60
+ * FailedFetchWeather,
61
+ * )(({ zipCode }) =>
62
+ * Effect.gen(function* () { ... }),
63
+ * )
64
+ * // Call site:
65
+ * FetchWeather({ zipCode: '90210' })
66
+ * ```
67
+ */
68
+ export declare function define<const Name extends string, Results extends ReadonlyArray<Schema.Top>>(name: Name, ...results: Results): <Eff extends Effect.Effect<Schema.Schema.Type<Results[number]>, any, any>>(effect: Eff) => CommandDefinitionNoArgs<Name, Eff>;
69
+ export declare function define<const Name extends string, Fields extends Schema.Struct.Fields, Results extends ReadonlyArray<Schema.Top>>(name: Name, args: Fields, ...results: Results): <Eff extends Effect.Effect<Schema.Schema.Type<Results[number]>, any, any>>(effectBuilder: (args: Schema.Schema.Type<Schema.Struct<Fields>>) => Eff) => CommandDefinitionWithArgs<Name, Fields, Eff>;
70
+ /** Transforms the Effect inside a Command while preserving its name and args. */
28
71
  export declare const mapEffect: {
29
- <A, E, R, B>(f: (effect: Effect.Effect<A, E, R>) => Effect.Effect<B, E, R>): (command: Readonly<{
72
+ <A, E1, R1, B, E2, R2>(f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): (command: Readonly<{
30
73
  name: string;
31
- effect: Effect.Effect<A, E, R>;
74
+ args?: Record<string, unknown>;
75
+ effect: Effect.Effect<A, E1, R1>;
32
76
  }>) => Readonly<{
33
77
  name: string;
34
- effect: Effect.Effect<B, E, R>;
78
+ args?: Record<string, unknown>;
79
+ effect: Effect.Effect<B, E2, R2>;
35
80
  }>;
36
81
  <A, E1, R1, B, E2, R2>(command: Readonly<{
37
82
  name: string;
83
+ args?: Record<string, unknown>;
38
84
  effect: Effect.Effect<A, E1, R1>;
39
85
  }>, f: (effect: Effect.Effect<A, E1, R1>) => Effect.Effect<B, E2, R2>): Readonly<{
40
86
  name: string;
87
+ args?: Record<string, unknown>;
41
88
  effect: Effect.Effect<B, E2, R2>;
42
89
  }>;
43
90
  };
@@ -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,GAAG,CAAC,GACnE,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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AE,CAAC,CAAA;KACjC,CAAC,EACF,CAAC,EAAE,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;QACV,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;KACjC,CAAC,CAAA;CAQyD,CAAA"}
@@ -1,23 +1,48 @@
1
+ import { Schema } from 'effect';
1
2
  /** Type-level brand for CommandDefinition values. */
2
3
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
3
4
  export const CommandDefinitionTypeId = Symbol.for('foldkit/CommandDefinition');
4
- /** Defines a named Command identity with the Messages it returns. */
5
- export const define = (name, ..._results) => {
6
- const create = (effect) => ({
7
- name,
8
- effect,
9
- });
10
- Object.defineProperty(create, 'name', { value: name, configurable: true });
11
- Object.defineProperty(create, CommandDefinitionTypeId, {
12
- value: CommandDefinitionTypeId,
13
- });
14
- /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
15
- return create;
16
- };
17
- /** Transforms the Effect inside a Command while preserving its name. */
5
+ export function define(name, ...rest) {
6
+ const [maybeArgs] = rest;
7
+ const isArgsRecord = maybeArgs !== undefined &&
8
+ typeof maybeArgs === 'object' &&
9
+ maybeArgs !== null &&
10
+ !Schema.isSchema(maybeArgs);
11
+ if (isArgsRecord) {
12
+ return (effectBuilder) => {
13
+ const definition = (args) => ({
14
+ name,
15
+ args,
16
+ effect: effectBuilder(args),
17
+ });
18
+ Object.defineProperty(definition, 'name', {
19
+ value: name,
20
+ configurable: true,
21
+ });
22
+ Object.defineProperty(definition, CommandDefinitionTypeId, {
23
+ value: CommandDefinitionTypeId,
24
+ });
25
+ /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
26
+ return definition;
27
+ };
28
+ }
29
+ return (effect) => {
30
+ const definition = () => ({ name, effect });
31
+ Object.defineProperty(definition, 'name', {
32
+ value: name,
33
+ configurable: true,
34
+ });
35
+ Object.defineProperty(definition, CommandDefinitionTypeId, {
36
+ value: CommandDefinitionTypeId,
37
+ });
38
+ /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
39
+ return definition;
40
+ };
41
+ }
42
+ /** Transforms the Effect inside a Command while preserving its name and args. */
18
43
  export const mapEffect = ((...args) => args.length === 1
19
44
  ? (command) => ({
20
- name: command.name,
45
+ ...command,
21
46
  effect: args[0](command.effect),
22
47
  })
23
- : { name: args[0].name, effect: args[1](args[0].effect) });
48
+ : { ...args[0], effect: args[1](args[0].effect) });
@@ -1,3 +1,3 @@
1
- export type { Command, CommandDefinition } from './index.js';
1
+ export type { Command, CommandDefinition, CommandDefinitionNoArgs, CommandDefinitionWithArgs, } from './index.js';
2
2
  export { CommandDefinitionTypeId, define, mapEffect } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/command/public.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/command/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
@@ -1,38 +1,62 @@
1
- import { Effect, HashSet, Option } from 'effect';
1
+ import { Context, Effect, HashSet, Option, Schema as S, SubscriptionRef } from 'effect';
2
2
  import * as Command from '../command/index.js';
3
3
  import type { DevToolsMode, DevToolsPosition } from '../runtime/runtime.js';
4
- import { type DevToolsStore } from './store.js';
5
- export declare const JumpTo: Command.CommandDefinition<"JumpTo", {
4
+ import { type CommandRecord, type DevToolsStore, type StoreState } from './store.js';
5
+ declare const StoreService_base: Context.ServiceClass<StoreService, "foldkit/DevToolsStore", Readonly<{
6
+ recordInit: (model: unknown, commands: ReadonlyArray<CommandRecord>, mountStartNames?: ReadonlyArray<string>) => Effect.Effect<void>;
7
+ recordMessage: (message: Readonly<{
8
+ _tag: string;
9
+ }>, modelBeforeUpdate: unknown, modelAfterUpdate: unknown, commands: ReadonlyArray<CommandRecord>, isModelChanged: boolean) => Effect.Effect<void>;
10
+ attachRenderedMounts: (mountStartNames: ReadonlyArray<string>, mountEndNames: ReadonlyArray<string>) => Effect.Effect<void>;
11
+ getModelAtIndex: (index: number) => Effect.Effect<unknown>;
12
+ getMessageAtIndex: (index: number) => Effect.Effect<Option.Option<unknown>>;
13
+ getDiffAtIndex: (index: number) => Effect.Effect<import("./store.js").DiffResult>;
14
+ jumpTo: (index: number) => Effect.Effect<void>;
15
+ resume: Effect.Effect<void>;
16
+ clear: Effect.Effect<void>;
17
+ stateRef: SubscriptionRef.SubscriptionRef<StoreState>;
18
+ }>>;
19
+ declare class StoreService extends StoreService_base {
20
+ }
21
+ declare const ShadowRootService_base: Context.ServiceClass<ShadowRootService, "foldkit/DevToolsShadowRoot", ShadowRoot>;
22
+ declare class ShadowRootService extends ShadowRootService_base {
23
+ }
24
+ export declare const LockScroll: Command.CommandDefinitionNoArgs<"LockScroll", Effect.Effect<{
25
+ readonly _tag: "LockedScroll";
26
+ }, never, never>>;
27
+ export declare const UnlockScroll: Command.CommandDefinitionNoArgs<"UnlockScroll", Effect.Effect<{
28
+ readonly _tag: "UnlockedScroll";
29
+ }, never, never>>;
30
+ export declare const JumpTo: Command.CommandDefinitionWithArgs<"JumpTo", {
31
+ index: S.Number;
32
+ }, Effect.Effect<{
6
33
  readonly _tag: "CompletedJump";
7
- }>;
8
- export declare const InspectState: Command.CommandDefinition<"InspectState", {
34
+ }, never, StoreService>>;
35
+ export declare const InspectState: Command.CommandDefinitionWithArgs<"InspectState", {
36
+ index: S.Number;
37
+ }, Effect.Effect<{
9
38
  readonly _tag: "ReceivedInspectedState";
10
39
  readonly model: unknown;
11
40
  readonly changedPaths: HashSet.HashSet<string>;
12
41
  readonly affectedPaths: HashSet.HashSet<string>;
13
42
  readonly maybeMessage: Option.Option<unknown>;
14
- }>;
15
- export declare const InspectLatest: Command.CommandDefinition<"InspectLatest", {
43
+ }, never, StoreService>>;
44
+ export declare const InspectLatest: Command.CommandDefinitionNoArgs<"InspectLatest", Effect.Effect<{
16
45
  readonly _tag: "ReceivedInspectedState";
17
46
  readonly model: unknown;
18
47
  readonly changedPaths: HashSet.HashSet<string>;
19
48
  readonly affectedPaths: HashSet.HashSet<string>;
20
49
  readonly maybeMessage: Option.Option<unknown>;
21
- }>;
22
- export declare const Resume: Command.CommandDefinition<"Resume", {
50
+ }, never, StoreService>>;
51
+ export declare const Resume: Command.CommandDefinitionNoArgs<"Resume", Effect.Effect<{
23
52
  readonly _tag: "CompletedResume";
24
- }>;
25
- export declare const Clear: Command.CommandDefinition<"Clear", {
53
+ }, never, StoreService>>;
54
+ export declare const Clear: Command.CommandDefinitionNoArgs<"Clear", Effect.Effect<{
26
55
  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", {
56
+ }, never, StoreService>>;
57
+ export declare const ScrollToTop: Command.CommandDefinitionNoArgs<"ScrollToTop", Effect.Effect<{
35
58
  readonly _tag: "ScrolledToTop";
36
- }>;
59
+ }, never, ShadowRootService>>;
37
60
  export declare const createOverlay: (store: DevToolsStore, position: DevToolsPosition, mode: DevToolsMode, maybeBanner: Option.Option<string>) => Effect.Effect<void, never, never>;
61
+ export {};
38
62
  //# 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,EAGN,OAAO,EAGP,MAAM,EAUP,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAW9C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAQ3E,OAAO,EAAE,KAAK,aAAa,EAA+B,MAAM,YAAY,CAAA;AAqO5E,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;AAs9CvE,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCAoDhC,CAAA"}
1
+ {"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../src/devTools/overlay.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,MAAM,EAGN,OAAO,EAGP,MAAM,EAKN,MAAM,IAAI,CAAC,EAGX,eAAe,EAEhB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAY9C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAO3E,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,UAAU,EAChB,MAAM,YAAY,CAAA;;wFAoYT,CAAF;;;;;;;;;;;;;AAnJR,cAAM,YAAa,SAAQ,iBAE1B;CAAG;;AAEJ,cAAM,iBAAkB,SAAQ,sBAGC;CAAG;AAEpC,eAAO,MAAM,UAAU;;iBAGsB,CAAA;AAE7C,eAAO,MAAM,YAAY;;iBAGwB,CAAA;AAWjD,eAAO,MAAM,MAAM;;;;wBAUlB,CAAA;AAED,eAAO,MAAM,YAAY;;;;;;;;wBAIqB,CAAA;AAE9C,eAAO,MAAM,aAAa;;;;;;wBAYzB,CAAA;AAED,eAAO,MAAM,MAAM;;wBASlB,CAAA;AAED,eAAO,MAAM,KAAK;;wBASjB,CAAA;AAED,eAAO,MAAM,WAAW;;6BAYvB,CAAA;AAw9CD,eAAO,MAAM,aAAa,GACxB,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,MAAM,YAAY,EAClB,aAAa,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,sCAoDhC,CAAA"}
@@ -1,25 +1,29 @@
1
1
  import { clsx } from 'clsx';
2
- import { Array as Array_, Effect, Equal, Function, HashSet, Match as M, Number as Number_, Option, Order, Predicate, Queue, Record, Schema as S, Stream, String as String_, SubscriptionRef, pipe, } from 'effect';
2
+ import { Array as Array_, Context, Effect, Equal, Function, HashSet, Match as M, Number as Number_, Option, Order, Predicate, Queue, Record, Schema as S, Stream, String as String_, SubscriptionRef, pipe, } from 'effect';
3
3
  import * as Command from '../command/index.js';
4
+ import { lockScroll, unlockScroll } from '../dom/scrollLock.js';
4
5
  import { OptionExt } from '../effectExtensions/index.js';
5
6
  import { createKeyedLazy, createLazy, html, } from '../html/index.js';
6
7
  import { m } from '../message/index.js';
7
8
  import { makeProgram } from '../runtime/runtime.js';
8
9
  import { makeSubscriptions } from '../runtime/subscription.js';
9
10
  import { evo } from '../struct/index.js';
10
- import { lockScroll, unlockScroll } from '../task/scrollLock.js';
11
11
  import * as Listbox from '../ui/listbox/public.js';
12
12
  import * as Tabs from '../ui/tabs/public.js';
13
13
  import { overlayStyles } from './overlay-styles.js';
14
14
  import { toInspectableValue } from './serialize.js';
15
- import { INIT_INDEX } from './store.js';
15
+ import { INIT_INDEX, } from './store.js';
16
16
  import { GOT_MESSAGE_PATTERN, extractSubmodelInfo, isTagged, } from './submodelPath.js';
17
17
  // MODEL
18
+ const DisplayCommand = S.Struct({
19
+ name: S.String,
20
+ args: S.Option(S.Record(S.String, S.Unknown)),
21
+ });
18
22
  const DisplayEntry = S.Struct({
19
23
  tag: S.String,
20
24
  submodelPath: S.Array(S.String),
21
25
  maybeLeafTag: S.Option(S.String),
22
- commandNames: S.Array(S.String),
26
+ commands: S.Array(DisplayCommand),
23
27
  mountStartNames: S.Array(S.String),
24
28
  mountEndNames: S.Array(S.String),
25
29
  timestamp: S.Number,
@@ -49,7 +53,7 @@ const Model = S.Struct({
49
53
  isOpen: S.Boolean,
50
54
  isMobile: S.Boolean,
51
55
  entries: S.Array(DisplayEntry),
52
- initCommandNames: S.Array(S.String),
56
+ initCommands: S.Array(DisplayCommand),
53
57
  initMountStartNames: S.Array(S.String),
54
58
  startIndex: S.Number,
55
59
  isPaused: S.Boolean,
@@ -69,7 +73,7 @@ const Model = S.Struct({
69
73
  const Flags = S.Struct({
70
74
  isMobile: S.Boolean,
71
75
  entries: S.Array(DisplayEntry),
72
- initCommandNames: S.Array(S.String),
76
+ initCommands: S.Array(DisplayCommand),
73
77
  initMountStartNames: S.Array(S.String),
74
78
  startIndex: S.Number,
75
79
  isPaused: S.Boolean,
@@ -102,7 +106,7 @@ const GotInspectorTabsMessage = m('GotInspectorTabsMessage', {
102
106
  });
103
107
  const ReceivedStoreUpdate = m('ReceivedStoreUpdate', {
104
108
  entries: S.Array(DisplayEntry),
105
- initCommandNames: S.Array(S.String),
109
+ initCommands: S.Array(DisplayCommand),
106
110
  initMountStartNames: S.Array(S.String),
107
111
  startIndex: S.Number,
108
112
  isPaused: S.Boolean,
@@ -146,13 +150,17 @@ const NO_MOUNTS = [];
146
150
  const formatTimeDelta = (deltaMs) => M.value(deltaMs).pipe(M.when(0, () => '0ms'), M.when(Number_.isLessThan(MILLIS_PER_SECOND), ms => `+${Math.round(ms)}ms`), M.orElse(ms => `+${(ms / MILLIS_PER_SECOND).toFixed(1)}s`));
147
151
  const MESSAGE_LIST_SELECTOR = '.message-list';
148
152
  const computeSubmodelTags = (entries) => pipe(entries, Array_.flatMap(({ submodelPath }) => submodelPath), Array_.dedupe, Array_.sort(Order.String));
153
+ const toDisplayCommand = (command) => ({
154
+ name: command.name,
155
+ args: Option.fromNullishOr(command.args),
156
+ });
149
157
  const toDisplayEntries = ({ entries }) => Array_.map(entries, entry => {
150
158
  const { submodelPath, maybeLeafTag } = extractSubmodelInfo(entry.tag, entry.message);
151
159
  return {
152
160
  tag: entry.tag,
153
161
  submodelPath,
154
162
  maybeLeafTag,
155
- commandNames: entry.commandNames,
163
+ commands: Array_.map(entry.commands, toDisplayCommand),
156
164
  mountStartNames: entry.mountStartNames,
157
165
  mountEndNames: entry.mountEndNames,
158
166
  timestamp: entry.timestamp,
@@ -161,7 +169,7 @@ const toDisplayEntries = ({ entries }) => Array_.map(entries, entry => {
161
169
  });
162
170
  const toDisplayState = (state) => ({
163
171
  entries: toDisplayEntries(state),
164
- initCommandNames: state.initCommandNames,
172
+ initCommands: Array_.map(state.initCommands, toDisplayCommand),
165
173
  initMountStartNames: state.initMountStartNames,
166
174
  startIndex: state.startIndex,
167
175
  isPaused: state.isPaused,
@@ -179,50 +187,60 @@ const objectPreview = (value) => pipe(value, Record.keys, Array_.filter(key => k
179
187
  }));
180
188
  const collapsedPreview = (value) => M.value(value).pipe(M.when(Array.isArray, array => `(${array.length})`), M.when(Predicate.isObject, objectPreview), M.orElse(() => ''));
181
189
  // UPDATE
182
- export const JumpTo = Command.define('JumpTo', CompletedJump);
183
- export const InspectState = Command.define('InspectState', ReceivedInspectedState);
184
- export const InspectLatest = Command.define('InspectLatest', ReceivedInspectedState);
185
- export const Resume = Command.define('Resume', CompletedResume);
186
- export const Clear = Command.define('Clear', CompletedClear);
187
- export const LockScroll = Command.define('LockScroll', LockedScroll);
188
- export const UnlockScroll = Command.define('UnlockScroll', UnlockedScroll);
189
- export const ScrollToTop = Command.define('ScrollToTop', ScrolledToTop);
190
+ class StoreService extends Context.Service()('foldkit/DevToolsStore') {
191
+ }
192
+ class ShadowRootService extends Context.Service()('foldkit/DevToolsShadowRoot') {
193
+ }
194
+ export const LockScroll = Command.define('LockScroll', LockedScroll)(lockScroll.pipe(Effect.as(LockedScroll())));
195
+ export const UnlockScroll = Command.define('UnlockScroll', UnlockedScroll)(unlockScroll.pipe(Effect.as(UnlockedScroll())));
196
+ const buildInspectionEffect = (index) => Effect.gen(function* () {
197
+ const store = yield* StoreService;
198
+ const model = yield* store.getModelAtIndex(index);
199
+ const maybeMessage = yield* store.getMessageAtIndex(index);
200
+ const diff = yield* store.getDiffAtIndex(index);
201
+ return ReceivedInspectedState({ model, maybeMessage, ...diff });
202
+ });
203
+ export const JumpTo = Command.define('JumpTo', { index: S.Number }, CompletedJump)(({ index }) => Effect.gen(function* () {
204
+ const store = yield* StoreService;
205
+ yield* store.jumpTo(index);
206
+ return CompletedJump();
207
+ }));
208
+ export const InspectState = Command.define('InspectState', { index: S.Number }, ReceivedInspectedState)(({ index }) => buildInspectionEffect(index));
209
+ export const InspectLatest = Command.define('InspectLatest', ReceivedInspectedState)(Effect.gen(function* () {
210
+ const store = yield* StoreService;
211
+ const state = yield* SubscriptionRef.get(store.stateRef);
212
+ const latestIndex = Array_.isReadonlyArrayEmpty(state.entries)
213
+ ? INIT_INDEX
214
+ : state.startIndex + state.entries.length - 1;
215
+ return yield* buildInspectionEffect(latestIndex);
216
+ }));
217
+ export const Resume = Command.define('Resume', CompletedResume)(Effect.gen(function* () {
218
+ const store = yield* StoreService;
219
+ yield* store.resume;
220
+ return CompletedResume();
221
+ }));
222
+ export const Clear = Command.define('Clear', CompletedClear)(Effect.gen(function* () {
223
+ const store = yield* StoreService;
224
+ yield* store.clear;
225
+ return CompletedClear();
226
+ }));
227
+ export const ScrollToTop = Command.define('ScrollToTop', ScrolledToTop)(Effect.gen(function* () {
228
+ const shadow = yield* ShadowRootService;
229
+ const messageList = shadow.querySelector(MESSAGE_LIST_SELECTOR);
230
+ if (messageList instanceof HTMLElement) {
231
+ messageList.scrollTop = 0;
232
+ }
233
+ return ScrolledToTop();
234
+ }));
190
235
  const makeUpdate = (store, shadow, mode) => {
191
- const jumpTo = (index) => JumpTo(Effect.gen(function* () {
192
- yield* store.jumpTo(index);
193
- return CompletedJump();
194
- }));
195
- const inspectState = (index) => InspectState(Effect.gen(function* () {
196
- const model = yield* store.getModelAtIndex(index);
197
- const maybeMessage = yield* store.getMessageAtIndex(index);
198
- const diff = yield* store.getDiffAtIndex(index);
199
- return ReceivedInspectedState({ model, maybeMessage, ...diff });
200
- }));
201
- const inspectLatest = InspectLatest(Effect.gen(function* () {
202
- const state = yield* SubscriptionRef.get(store.stateRef);
203
- const latestIndex = Array_.isReadonlyArrayEmpty(state.entries)
204
- ? INIT_INDEX
205
- : state.startIndex + state.entries.length - 1;
206
- return yield* inspectState(latestIndex).effect;
207
- }));
208
- const resume = Resume(Effect.gen(function* () {
209
- yield* store.resume;
210
- return CompletedResume();
211
- }));
212
- const clear = Clear(Effect.gen(function* () {
213
- yield* store.clear;
214
- return CompletedClear();
215
- }));
216
- const toggleScrollLock = (shouldLock) => shouldLock
217
- ? LockScroll(lockScroll.pipe(Effect.as(LockedScroll())))
218
- : UnlockScroll(unlockScroll.pipe(Effect.as(UnlockedScroll())));
219
- const scrollToTop = ScrollToTop(Effect.sync(() => {
220
- const messageList = shadow.querySelector(MESSAGE_LIST_SELECTOR);
221
- if (messageList instanceof HTMLElement) {
222
- messageList.scrollTop = 0;
223
- }
224
- return ScrolledToTop();
225
- }));
236
+ const provideContext = (effect) => effect.pipe(Effect.provideService(StoreService, store), Effect.provideService(ShadowRootService, shadow));
237
+ const inspectLatest = Command.mapEffect(InspectLatest(), provideContext);
238
+ const resume = Command.mapEffect(Resume(), provideContext);
239
+ const clear = Command.mapEffect(Clear(), provideContext);
240
+ const scrollToTop = Command.mapEffect(ScrollToTop(), provideContext);
241
+ const jumpTo = (index) => Command.mapEffect(JumpTo({ index }), provideContext);
242
+ const inspectState = (index) => Command.mapEffect(InspectState({ index }), provideContext);
243
+ const toggleScrollLock = (shouldLock) => shouldLock ? LockScroll() : UnlockScroll();
226
244
  return (model, message) => M.value(message).pipe(M.withReturnType(), M.tags({
227
245
  ClickedToggle: () => {
228
246
  const nextIsOpen = !model.isOpen;
@@ -308,7 +326,7 @@ const makeUpdate = (store, shadow, mode) => {
308
326
  }),
309
327
  [],
310
328
  ],
311
- ReceivedStoreUpdate: ({ entries, initCommandNames, initMountStartNames, startIndex, isPaused, pausedAtIndex, }) => {
329
+ ReceivedStoreUpdate: ({ entries, initCommands, initMountStartNames, startIndex, isPaused, pausedAtIndex, }) => {
312
330
  const shouldFollowLatest = M.value(mode).pipe(M.when('TimeTravel', () => !isPaused), M.when('Inspect', () => model.isFollowingLatest), M.exhaustive);
313
331
  const latestIndex = Array_.match(entries, {
314
332
  onEmpty: () => INIT_INDEX,
@@ -319,7 +337,7 @@ const makeUpdate = (store, shadow, mode) => {
319
337
  return [
320
338
  evo(model, {
321
339
  entries: () => entries,
322
- initCommandNames: () => initCommandNames,
340
+ initCommands: () => initCommands,
323
341
  initMountStartNames: () => initMountStartNames,
324
342
  startIndex: () => startIndex,
325
343
  isPaused: () => isPaused,
@@ -425,8 +443,8 @@ const makeView = (position, mode, maybeBanner) => {
425
443
  const diffDotView = span([Class('diff-dot')], []);
426
444
  const inlineDiffDotView = span([Class('diff-dot-inline')], []);
427
445
  const flattenTree = ({ value, treePath, depth, key, ...shared }) => {
428
- const { expandedPaths, changedPaths, affectedPaths, accumulator, indentRootChildren, } = shared;
429
- const isRoot = treePath === 'root';
446
+ const { rootPath, expandedPaths, changedPaths, affectedPaths, accumulator, indentRootChildren, } = shared;
447
+ const isRoot = treePath === rootPath;
430
448
  const nodeIsExpandable = isExpandable(value);
431
449
  const isExpanded = nodeIsExpandable && (isRoot || HashSet.has(expandedPaths, treePath));
432
450
  const tag = isTagged(value) ? value._tag : '';
@@ -439,6 +457,7 @@ const makeView = (position, mode, maybeBanner) => {
439
457
  isExpanded,
440
458
  isChanged: HashSet.has(changedPaths, treePath),
441
459
  isAffected: HashSet.has(affectedPaths, treePath),
460
+ isRoot,
442
461
  tag,
443
462
  });
444
463
  if (!isExpanded) {
@@ -464,7 +483,7 @@ const makeView = (position, mode, maybeBanner) => {
464
483
  })));
465
484
  }
466
485
  };
467
- const flatNodeView = (value, treePath, depth, key, nodeIsExpandable, isExpanded, isChanged, isAffected, tag) => {
486
+ const flatNodeView = (value, treePath, depth, key, nodeIsExpandable, isExpanded, isChanged, isAffected, isRoot, tag) => {
468
487
  const indent = Style({ paddingLeft: `${depth * TREE_INDENT_PX}px` });
469
488
  const hasDiffDot = isChanged || isAffected;
470
489
  if (!nodeIsExpandable) {
@@ -480,7 +499,6 @@ const makeView = (position, mode, maybeBanner) => {
480
499
  leafValueView(value),
481
500
  ]);
482
501
  }
483
- const isRoot = treePath === 'root';
484
502
  const preview = isExpanded
485
503
  ? Array.isArray(value)
486
504
  ? `(${value.length})`
@@ -502,11 +520,24 @@ const makeView = (position, mode, maybeBanner) => {
502
520
  span([Class('json-preview')], [preview]),
503
521
  ]);
504
522
  };
523
+ const renderFlatNode = (node) => lazyTreeNode(node.treePath, flatNodeView, [
524
+ node.value,
525
+ node.treePath,
526
+ node.depth,
527
+ node.key,
528
+ node.isExpandable,
529
+ node.isExpanded,
530
+ node.isChanged,
531
+ node.isAffected,
532
+ node.isRoot,
533
+ node.tag,
534
+ ]);
505
535
  const treeView = (value, rootPath, expandedPaths, changedPaths, affectedPaths, maybeRootLabel, indentRootChildren) => {
506
536
  const nodes = [];
507
537
  flattenTree({
508
538
  value: toInspectableValue(value),
509
539
  treePath: rootPath,
540
+ rootPath,
510
541
  expandedPaths,
511
542
  changedPaths,
512
543
  affectedPaths,
@@ -517,17 +548,7 @@ const makeView = (position, mode, maybeBanner) => {
517
548
  });
518
549
  return div([
519
550
  Class('inspector-tree flex-1 overflow-auto min-h-0 min-w-0 overscroll-none'),
520
- ], nodes.map(node => lazyTreeNode(node.treePath, flatNodeView, [
521
- node.value,
522
- node.treePath,
523
- node.depth,
524
- node.key,
525
- node.isExpandable,
526
- node.isExpanded,
527
- node.isChanged,
528
- node.isAffected,
529
- node.tag,
530
- ])));
551
+ ], nodes.map(renderFlatNode));
531
552
  };
532
553
  const inspectedTimestamp = (model) => {
533
554
  const lastIndex = Array_.isReadonlyArrayEmpty(model.entries)
@@ -601,26 +622,45 @@ const makeView = (position, mode, maybeBanner) => {
601
622
  },
602
623
  });
603
624
  const selectedHistoryIndex = (model) => M.value(mode).pipe(M.when('TimeTravel', () => model.isPaused ? model.pausedAtIndex : INIT_INDEX), M.when('Inspect', () => model.selectedIndex), M.exhaustive);
604
- const selectedCommandNames = (model) => {
625
+ const selectedCommands = (model) => {
605
626
  const selectedIndex = selectedHistoryIndex(model);
606
627
  if (selectedIndex === INIT_INDEX) {
607
- return model.initCommandNames;
628
+ return model.initCommands;
608
629
  }
609
630
  else {
610
- return pipe(model.entries, Array_.get(selectedIndex - model.startIndex), Option.map(entry => entry.commandNames), Option.getOrElse(() => NO_COMMANDS));
631
+ return pipe(model.entries, Array_.get(selectedIndex - model.startIndex), Option.map(entry => entry.commands), Option.getOrElse(() => NO_COMMANDS));
611
632
  }
612
633
  };
613
- const commandsTabContent = (commandNames) => Array_.match(commandNames, {
634
+ const flattenCommand = (command, index, expandedPaths) => {
635
+ const taggedValue = Option.match(command.args, {
636
+ onNone: () => ({ _tag: command.name }),
637
+ onSome: argsValue => ({ ...argsValue, _tag: command.name }),
638
+ });
639
+ const rootPath = `command-${index}`;
640
+ const nodes = [];
641
+ flattenTree({
642
+ value: toInspectableValue(taggedValue),
643
+ treePath: rootPath,
644
+ rootPath,
645
+ expandedPaths,
646
+ changedPaths: HashSet.empty(),
647
+ affectedPaths: HashSet.empty(),
648
+ depth: 0,
649
+ key: '',
650
+ accumulator: nodes,
651
+ indentRootChildren: false,
652
+ });
653
+ return nodes;
654
+ };
655
+ const commandsTabContent = (commands, expandedPaths) => Array_.match(commands, {
614
656
  onEmpty: () => div([
615
657
  Class('flex-1 flex items-center justify-center text-dt-muted text-2xs font-mono min-w-0'),
616
658
  ], ['No Commands returned']),
617
- onNonEmpty: names => div([
659
+ onNonEmpty: commandList => div([
618
660
  Class('flex flex-col flex-1 min-h-0 min-w-0 overflow-auto overscroll-none'),
619
- ], Array_.map(names, (name, index) => div([
620
- Class('flex items-center px-2 py-1 text-base font-mono text-dt border-b gap-1.5'),
621
- ], [
661
+ ], Array_.map(commandList, (command, index) => div([Class('flex items-start px-2 py-1 border-b gap-1.5')], [
622
662
  span([Class(indexClass)], [String(index + 1)]),
623
- span([Class('json-tag')], [name]),
663
+ div([Class('flex flex-col flex-1 min-w-0')], Array_.map(flattenCommand(command, index, expandedPaths), renderFlatNode)),
624
664
  ]))),
625
665
  });
626
666
  const selectedMountActivity = (model) => {
@@ -679,7 +719,8 @@ const makeView = (position, mode, maybeBanner) => {
679
719
  model.expandedPaths,
680
720
  inspectedTimestamp(model),
681
721
  ])), M.when('Commands', () => lazyTabContent('Commands', commandsTabContent, [
682
- selectedCommandNames(model),
722
+ selectedCommands(model),
723
+ model.expandedPaths,
683
724
  ])), M.when('Mounts', () => {
684
725
  const { starts, ends } = selectedMountActivity(model);
685
726
  return lazyTabContent('Mounts', mountsTabContent, [starts, ends]);