foldkit 0.87.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.
- package/dist/command/index.d.ts +60 -13
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +41 -16
- package/dist/command/public.d.ts +1 -1
- package/dist/command/public.d.ts.map +1 -1
- package/dist/devTools/overlay.d.ts +44 -20
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/overlay.js +119 -78
- package/dist/devTools/protocol.d.ts +48 -11
- package/dist/devTools/protocol.d.ts.map +1 -1
- package/dist/devTools/protocol.js +8 -3
- package/dist/devTools/serialize.d.ts +8 -2
- package/dist/devTools/serialize.d.ts.map +1 -1
- package/dist/devTools/serialize.js +11 -2
- package/dist/devTools/store.d.ts +8 -4
- package/dist/devTools/store.d.ts.map +1 -1
- package/dist/devTools/store.js +6 -6
- package/dist/devTools/webSocketBridge.d.ts.map +1 -1
- package/dist/devTools/webSocketBridge.js +2 -2
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +12 -5
- package/dist/test/apps/counter.d.ts +14 -13
- package/dist/test/apps/counter.d.ts.map +1 -1
- package/dist/test/apps/counter.js +6 -3
- package/dist/test/apps/formChild.d.ts +4 -17
- package/dist/test/apps/formChild.d.ts.map +1 -1
- package/dist/test/apps/formChild.js +4 -6
- package/dist/test/apps/login.d.ts +3 -6
- package/dist/test/apps/login.d.ts.map +1 -1
- package/dist/test/apps/login.js +2 -3
- package/dist/test/apps/resumeUpload.d.ts +9 -7
- package/dist/test/apps/resumeUpload.d.ts.map +1 -1
- package/dist/test/apps/resumeUpload.js +4 -6
- package/dist/test/internal.d.ts +58 -13
- package/dist/test/internal.d.ts.map +1 -1
- package/dist/test/internal.js +121 -39
- package/dist/test/scene.d.ts +14 -3
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +21 -15
- package/dist/test/story.d.ts +15 -5
- package/dist/test/story.d.ts.map +1 -1
- package/dist/test/story.js +22 -15
- package/dist/ui/animation/update.d.ts +7 -5
- package/dist/ui/animation/update.d.ts.map +1 -1
- package/dist/ui/animation/update.js +6 -8
- package/dist/ui/calendar/index.d.ts +7 -8
- package/dist/ui/calendar/index.d.ts.map +1 -1
- package/dist/ui/calendar/index.js +7 -10
- package/dist/ui/calendar/public.d.ts +1 -1
- package/dist/ui/calendar/public.d.ts.map +1 -1
- package/dist/ui/calendar/public.js +1 -1
- package/dist/ui/combobox/multi.d.ts +1 -0
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/shared.d.ts +32 -17
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +17 -28
- package/dist/ui/combobox/single.d.ts +1 -0
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/dialog/index.d.ts +10 -5
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +11 -10
- package/dist/ui/disclosure/index.d.ts +5 -3
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +3 -3
- package/dist/ui/dragAndDrop/index.d.ts +14 -7
- package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/index.js +19 -8
- package/dist/ui/listbox/multi.d.ts +1 -0
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/shared.d.ts +40 -21
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +21 -34
- package/dist/ui/listbox/single.d.ts +1 -0
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/menu/index.d.ts +40 -22
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +25 -37
- package/dist/ui/popover/index.d.ts +26 -16
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +14 -21
- package/dist/ui/radioGroup/index.d.ts +6 -3
- package/dist/ui/radioGroup/index.d.ts.map +1 -1
- package/dist/ui/radioGroup/index.js +5 -10
- package/dist/ui/tabs/index.d.ts +6 -3
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +13 -23
- package/dist/ui/toast/index.d.ts +4 -0
- package/dist/ui/toast/index.d.ts.map +1 -1
- package/dist/ui/toast/update.d.ts +11 -3
- package/dist/ui/toast/update.d.ts.map +1 -1
- package/dist/ui/toast/update.js +8 -4
- package/dist/ui/tooltip/index.d.ts +6 -3
- package/dist/ui/tooltip/index.d.ts.map +1 -1
- package/dist/ui/tooltip/index.js +2 -4
- package/dist/ui/virtualList/index.d.ts +7 -3
- package/dist/ui/virtualList/index.d.ts.map +1 -1
- package/dist/ui/virtualList/index.js +15 -4
- package/package.json +1 -1
package/dist/command/index.d.ts
CHANGED
|
@@ -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
|
|
15
|
-
export interface
|
|
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
|
-
|
|
20
|
+
(): Readonly<{
|
|
19
21
|
name: Name;
|
|
20
|
-
effect:
|
|
22
|
+
effect: Eff;
|
|
21
23
|
}>;
|
|
22
24
|
}
|
|
23
|
-
/**
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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,
|
|
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
|
-
|
|
74
|
+
args?: Record<string, unknown>;
|
|
75
|
+
effect: Effect.Effect<A, E1, R1>;
|
|
32
76
|
}>) => Readonly<{
|
|
33
77
|
name: string;
|
|
34
|
-
|
|
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,
|
|
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,iGAAiG;AACjG,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,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,C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AAM,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"}
|
package/dist/command/index.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
|
|
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
|
-
|
|
45
|
+
...command,
|
|
21
46
|
effect: args[0](command.effect),
|
|
22
47
|
})
|
|
23
|
-
: {
|
|
48
|
+
: { ...args[0], effect: args[1](args[0].effect) });
|
package/dist/command/public.d.ts
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
53
|
+
}, never, StoreService>>;
|
|
54
|
+
export declare const Clear: Command.CommandDefinitionNoArgs<"Clear", Effect.Effect<{
|
|
26
55
|
readonly _tag: "CompletedClear";
|
|
27
|
-
}
|
|
28
|
-
export declare const
|
|
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,
|
|
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"}
|
package/dist/devTools/overlay.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
4
|
import { lockScroll, unlockScroll } from '../dom/scrollLock.js';
|
|
5
5
|
import { OptionExt } from '../effectExtensions/index.js';
|
|
@@ -12,14 +12,18 @@ 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
export const
|
|
187
|
-
export const
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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,
|
|
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
|
-
|
|
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 ===
|
|
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(
|
|
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
|
|
625
|
+
const selectedCommands = (model) => {
|
|
605
626
|
const selectedIndex = selectedHistoryIndex(model);
|
|
606
627
|
if (selectedIndex === INIT_INDEX) {
|
|
607
|
-
return model.
|
|
628
|
+
return model.initCommands;
|
|
608
629
|
}
|
|
609
630
|
else {
|
|
610
|
-
return pipe(model.entries, Array_.get(selectedIndex - model.startIndex), Option.map(entry => entry.
|
|
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
|
|
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:
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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]);
|