@dxos/app-framework 0.6.5 → 0.6.6-staging.23d123d
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/lib/browser/index.mjs +88 -47
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +96 -55
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +4 -0
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
- package/dist/types/src/plugins/common/graph.d.ts +30 -1
- package/dist/types/src/plugins/common/graph.d.ts.map +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +14 -4
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts +163 -44
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/package.json +11 -11
- package/project.json +1 -1
- package/src/plugins/PluginHost/PluginContext.tsx +7 -0
- package/src/plugins/PluginHost/PluginHost.tsx +1 -0
- package/src/plugins/common/graph.ts +39 -1
- package/src/plugins/common/layout.ts +13 -2
- package/src/plugins/common/navigation.ts +111 -73
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { S } from '@dxos/echo-schema';
|
|
2
3
|
import type { IntentData } from '../IntentPlugin';
|
|
3
4
|
import type { Plugin } from '../PluginHost';
|
|
4
5
|
export declare const SLUG_LIST_SEPARATOR = "+";
|
|
@@ -6,26 +7,78 @@ export declare const SLUG_ENTRY_SEPARATOR = "_";
|
|
|
6
7
|
export declare const SLUG_KEY_VALUE_SEPARATOR = "-";
|
|
7
8
|
export declare const SLUG_PATH_SEPARATOR = "~";
|
|
8
9
|
export declare const SLUG_COLLECTION_INDICATOR = "";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
declare const LayoutEntrySchema: S.mutable<S.Struct<{
|
|
11
|
+
id: typeof S.String;
|
|
12
|
+
path: S.optional<typeof S.String>;
|
|
13
|
+
}>>;
|
|
14
|
+
export type LayoutEntry = S.Schema.Type<typeof LayoutEntrySchema>;
|
|
15
|
+
declare const LayoutPartSchema: S.Union<[S.Literal<["sidebar"]>, S.Literal<["main"]>, S.Literal<["solo"]>, S.Literal<["complementary"]>, S.Literal<["fullScreen"]>]>;
|
|
16
|
+
export type LayoutPart = S.Schema.Type<typeof LayoutPartSchema>;
|
|
17
|
+
declare const LayoutPartsSchema: S.SchemaClass<{
|
|
18
|
+
main?: {
|
|
19
|
+
path?: string | undefined;
|
|
20
|
+
id: string;
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
solo?: {
|
|
23
|
+
path?: string | undefined;
|
|
24
|
+
id: string;
|
|
25
|
+
}[] | undefined;
|
|
26
|
+
sidebar?: {
|
|
27
|
+
path?: string | undefined;
|
|
28
|
+
id: string;
|
|
29
|
+
}[] | undefined;
|
|
30
|
+
complementary?: {
|
|
31
|
+
path?: string | undefined;
|
|
32
|
+
id: string;
|
|
33
|
+
}[] | undefined;
|
|
34
|
+
fullScreen?: {
|
|
35
|
+
path?: string | undefined;
|
|
36
|
+
id: string;
|
|
37
|
+
}[] | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
main?: {
|
|
40
|
+
id: string;
|
|
41
|
+
path?: string | undefined;
|
|
42
|
+
}[] | undefined;
|
|
43
|
+
solo?: {
|
|
44
|
+
id: string;
|
|
45
|
+
path?: string | undefined;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
sidebar?: {
|
|
48
|
+
id: string;
|
|
49
|
+
path?: string | undefined;
|
|
50
|
+
}[] | undefined;
|
|
51
|
+
complementary?: {
|
|
52
|
+
id: string;
|
|
53
|
+
path?: string | undefined;
|
|
54
|
+
}[] | undefined;
|
|
55
|
+
fullScreen?: {
|
|
56
|
+
id: string;
|
|
57
|
+
path?: string | undefined;
|
|
58
|
+
}[] | undefined;
|
|
59
|
+
}, never>;
|
|
60
|
+
export type LayoutParts = S.Schema.Type<typeof LayoutPartsSchema>;
|
|
61
|
+
declare const LayoutCoordinateSchema: S.mutable<S.Struct<{
|
|
62
|
+
part: S.Union<[S.Literal<["sidebar"]>, S.Literal<["main"]>, S.Literal<["solo"]>, S.Literal<["complementary"]>, S.Literal<["fullScreen"]>]>;
|
|
63
|
+
entryId: typeof S.String;
|
|
64
|
+
}>>;
|
|
65
|
+
export type LayoutCoordinate = S.Schema.Type<typeof LayoutCoordinateSchema>;
|
|
66
|
+
declare const PartAdjustmentSchema: S.Union<[S.Literal<["increment-start"]>, S.Literal<["increment-end"]>, S.Literal<["solo"]>]>;
|
|
67
|
+
export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
|
|
68
|
+
declare const LayoutAdjustmentSchema: S.mutable<S.Struct<{
|
|
69
|
+
layoutCoordinate: S.mutable<S.Struct<{
|
|
70
|
+
part: S.Union<[S.Literal<["sidebar"]>, S.Literal<["main"]>, S.Literal<["solo"]>, S.Literal<["complementary"]>, S.Literal<["fullScreen"]>]>;
|
|
71
|
+
entryId: typeof S.String;
|
|
72
|
+
}>>;
|
|
73
|
+
type: S.Union<[S.Literal<["increment-start"]>, S.Literal<["increment-end"]>, S.Literal<["solo"]>]>;
|
|
74
|
+
}>>;
|
|
75
|
+
export type LayoutAdjustment = S.Schema.Type<typeof LayoutAdjustmentSchema>;
|
|
76
|
+
/** @deprecated */
|
|
15
77
|
export declare const ActiveParts: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
78
|
+
export type ActiveParts = z.infer<typeof ActiveParts>;
|
|
16
79
|
/**
|
|
17
80
|
* Basic state provided by a navigation plugin.
|
|
18
81
|
*/
|
|
19
|
-
export declare const Location: z.ZodObject<{
|
|
20
|
-
active: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>]>>;
|
|
21
|
-
closed: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
22
|
-
}, "strip", z.ZodTypeAny, {
|
|
23
|
-
active?: string | Record<string, string | string[]> | undefined;
|
|
24
|
-
closed?: string | string[] | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
active?: string | Record<string, string | string[]> | undefined;
|
|
27
|
-
closed?: string | string[] | undefined;
|
|
28
|
-
}>;
|
|
29
82
|
export declare const Attention: z.ZodObject<{
|
|
30
83
|
attended: z.ZodOptional<z.ZodSet<z.ZodString>>;
|
|
31
84
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -33,42 +86,107 @@ export declare const Attention: z.ZodObject<{
|
|
|
33
86
|
}, {
|
|
34
87
|
attended?: Set<string> | undefined;
|
|
35
88
|
}>;
|
|
36
|
-
export type ActiveParts = z.infer<typeof ActiveParts>;
|
|
37
|
-
export type Location = z.infer<typeof Location>;
|
|
38
89
|
export type Attention = z.infer<typeof Attention>;
|
|
39
|
-
export type LayoutPart = 'sidebar' | 'main' | 'complementary';
|
|
40
|
-
export type LayoutCoordinate = {
|
|
41
|
-
part: LayoutPart;
|
|
42
|
-
index: number;
|
|
43
|
-
partSize: number;
|
|
44
|
-
solo?: boolean;
|
|
45
|
-
};
|
|
46
|
-
export type NavigationAdjustmentType = `${'pin' | 'increment'}-${'start' | 'end'}`;
|
|
47
|
-
export type NavigationAdjustment = {
|
|
48
|
-
layoutCoordinate: LayoutCoordinate;
|
|
49
|
-
type: NavigationAdjustmentType;
|
|
50
|
-
};
|
|
51
|
-
export declare const isActiveParts: (active: string | ActiveParts | undefined) => active is Record<string, string | string[]>;
|
|
52
|
-
export declare const isAdjustTransaction: (data: IntentData | undefined) => data is NavigationAdjustment;
|
|
53
|
-
export declare const firstMainId: (active: Location['active']) => string;
|
|
54
|
-
export declare const activeIds: (active: string | ActiveParts | undefined) => Set<string>;
|
|
55
|
-
export declare const isIdActive: (active: string | ActiveParts | undefined, id: string) => boolean;
|
|
56
90
|
/**
|
|
57
91
|
* Provides for a plugin that can manage the app navigation.
|
|
58
92
|
*/
|
|
59
|
-
|
|
60
|
-
location:
|
|
61
|
-
|
|
93
|
+
declare const LocationProvidesSchema: S.mutable<S.Struct<{
|
|
94
|
+
location: S.Struct<{
|
|
95
|
+
active: S.SchemaClass<{
|
|
96
|
+
main?: {
|
|
97
|
+
path?: string | undefined;
|
|
98
|
+
id: string;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
solo?: {
|
|
101
|
+
path?: string | undefined;
|
|
102
|
+
id: string;
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
sidebar?: {
|
|
105
|
+
path?: string | undefined;
|
|
106
|
+
id: string;
|
|
107
|
+
}[] | undefined;
|
|
108
|
+
complementary?: {
|
|
109
|
+
path?: string | undefined;
|
|
110
|
+
id: string;
|
|
111
|
+
}[] | undefined;
|
|
112
|
+
fullScreen?: {
|
|
113
|
+
path?: string | undefined;
|
|
114
|
+
id: string;
|
|
115
|
+
}[] | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
main?: {
|
|
118
|
+
id: string;
|
|
119
|
+
path?: string | undefined;
|
|
120
|
+
}[] | undefined;
|
|
121
|
+
solo?: {
|
|
122
|
+
id: string;
|
|
123
|
+
path?: string | undefined;
|
|
124
|
+
}[] | undefined;
|
|
125
|
+
sidebar?: {
|
|
126
|
+
id: string;
|
|
127
|
+
path?: string | undefined;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
complementary?: {
|
|
130
|
+
id: string;
|
|
131
|
+
path?: string | undefined;
|
|
132
|
+
}[] | undefined;
|
|
133
|
+
fullScreen?: {
|
|
134
|
+
id: string;
|
|
135
|
+
path?: string | undefined;
|
|
136
|
+
}[] | undefined;
|
|
137
|
+
}, never>;
|
|
138
|
+
closed: S.Array$<typeof S.String>;
|
|
139
|
+
}>;
|
|
140
|
+
}>>;
|
|
141
|
+
export type LocationProvides = S.Schema.Type<typeof LocationProvidesSchema>;
|
|
62
142
|
/**
|
|
63
143
|
* Type guard for layout plugins.
|
|
64
144
|
*/
|
|
145
|
+
export declare const isLayoutParts: (value: unknown) => value is {
|
|
146
|
+
main?: {
|
|
147
|
+
path?: string | undefined;
|
|
148
|
+
id: string;
|
|
149
|
+
}[] | undefined;
|
|
150
|
+
solo?: {
|
|
151
|
+
path?: string | undefined;
|
|
152
|
+
id: string;
|
|
153
|
+
}[] | undefined;
|
|
154
|
+
sidebar?: {
|
|
155
|
+
path?: string | undefined;
|
|
156
|
+
id: string;
|
|
157
|
+
}[] | undefined;
|
|
158
|
+
complementary?: {
|
|
159
|
+
path?: string | undefined;
|
|
160
|
+
id: string;
|
|
161
|
+
}[] | undefined;
|
|
162
|
+
fullScreen?: {
|
|
163
|
+
path?: string | undefined;
|
|
164
|
+
id: string;
|
|
165
|
+
}[] | undefined;
|
|
166
|
+
};
|
|
167
|
+
export declare const isLayoutAdjustment: (value: unknown) => value is {
|
|
168
|
+
type: "solo" | "increment-start" | "increment-end";
|
|
169
|
+
layoutCoordinate: {
|
|
170
|
+
part: "main" | "solo" | "sidebar" | "complementary" | "fullScreen";
|
|
171
|
+
entryId: string;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
65
174
|
export declare const parseNavigationPlugin: (plugin: Plugin) => Plugin<LocationProvides> | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Utilities.
|
|
177
|
+
*/
|
|
178
|
+
/** Extracts all unique IDs from the layout parts. */
|
|
179
|
+
export declare const openIds: (layout: LayoutParts) => string[];
|
|
180
|
+
export declare const firstIdInPart: (layout: LayoutParts | undefined, part: LayoutPart) => string | undefined;
|
|
181
|
+
export declare const indexInPart: (layout: LayoutParts | undefined, layoutCoordinate: LayoutCoordinate | undefined) => number | undefined;
|
|
182
|
+
export declare const partLength: (layout: LayoutParts | undefined, part: LayoutPart | undefined) => number;
|
|
66
183
|
export declare enum NavigationAction {
|
|
67
184
|
OPEN = "dxos.org/plugin/navigation/open",
|
|
68
185
|
ADD_TO_ACTIVE = "dxos.org/plugin/navigation/add-to-active",
|
|
69
186
|
SET = "dxos.org/plugin/navigation/set",
|
|
70
187
|
ADJUST = "dxos.org/plugin/navigation/adjust",
|
|
71
|
-
CLOSE = "dxos.org/plugin/navigation/close"
|
|
188
|
+
CLOSE = "dxos.org/plugin/navigation/close",
|
|
189
|
+
EXPOSE = "dxos.org/plugin/navigation/expose"
|
|
72
190
|
}
|
|
73
191
|
/**
|
|
74
192
|
* Expected payload for navigation actions.
|
|
@@ -84,18 +202,18 @@ export declare namespace NavigationAction {
|
|
|
84
202
|
* Payload for adding an item to the active items.
|
|
85
203
|
*/
|
|
86
204
|
type AddToActive = IntentData<{
|
|
205
|
+
part: LayoutPart;
|
|
87
206
|
id: string;
|
|
88
207
|
scrollIntoView?: boolean;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
position: 'add-before' | 'add-after';
|
|
92
|
-
};
|
|
208
|
+
pivotId?: string;
|
|
209
|
+
positioning?: 'start' | 'end';
|
|
93
210
|
}>;
|
|
94
211
|
/**
|
|
95
212
|
* A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
|
|
96
213
|
*/
|
|
97
214
|
type Close = IntentData<{
|
|
98
215
|
activeParts: ActiveParts;
|
|
216
|
+
noToggle?: boolean;
|
|
99
217
|
}>;
|
|
100
218
|
/**
|
|
101
219
|
* The active parts to directly set, to be used when working with URLs or restoring a specific state.
|
|
@@ -106,6 +224,7 @@ export declare namespace NavigationAction {
|
|
|
106
224
|
/**
|
|
107
225
|
* An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
|
|
108
226
|
*/
|
|
109
|
-
type Adjust = IntentData<
|
|
227
|
+
type Adjust = IntentData<LayoutAdjustment>;
|
|
110
228
|
}
|
|
229
|
+
export {};
|
|
111
230
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/navigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/navigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAI5C,QAAA,MAAM,iBAAiB;;;GAAoE,CAAC;AAE5F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAKlE,QAAA,MAAM,gBAAgB,sIAMrB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA0F,CAAC;AAClH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,QA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
|
4
4
|
"description": "A framework for building applications from composible plugins.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"@phosphor-icons/react": "^2.1.5",
|
|
24
24
|
"@preact/signals-core": "^1.6.0",
|
|
25
25
|
"zod": "^3.22.4",
|
|
26
|
-
"@dxos/app-graph": "0.6.
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/invariant": "0.6.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/util": "0.6.
|
|
26
|
+
"@dxos/app-graph": "0.6.6-staging.23d123d",
|
|
27
|
+
"@dxos/async": "0.6.6-staging.23d123d",
|
|
28
|
+
"@dxos/client-protocol": "0.6.6-staging.23d123d",
|
|
29
|
+
"@dxos/debug": "0.6.6-staging.23d123d",
|
|
30
|
+
"@dxos/echo-schema": "0.6.6-staging.23d123d",
|
|
31
|
+
"@dxos/invariant": "0.6.6-staging.23d123d",
|
|
32
|
+
"@dxos/local-storage": "0.6.6-staging.23d123d",
|
|
33
|
+
"@dxos/log": "0.6.6-staging.23d123d",
|
|
34
|
+
"@dxos/util": "0.6.6-staging.23d123d"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "^18.0.21",
|
|
38
38
|
"react": "~18.2.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"react": "
|
|
41
|
+
"react": "~18.2.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
package/project.json
CHANGED
|
@@ -13,6 +13,11 @@ export type PluginContext = {
|
|
|
13
13
|
*/
|
|
14
14
|
ready: boolean;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Core plugins.
|
|
18
|
+
*/
|
|
19
|
+
core: string[];
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* Ids of plugins which are enabled on this device.
|
|
18
23
|
*/
|
|
@@ -26,6 +31,7 @@ export type PluginContext = {
|
|
|
26
31
|
/**
|
|
27
32
|
* All available plugins.
|
|
28
33
|
*/
|
|
34
|
+
// This is metadata rather then just ids because it includes plugins which have not been fully loaded yet.
|
|
29
35
|
available: Plugin['meta'][];
|
|
30
36
|
|
|
31
37
|
/**
|
|
@@ -37,6 +43,7 @@ export type PluginContext = {
|
|
|
37
43
|
|
|
38
44
|
const PluginContext: Context<PluginContext> = createContext<PluginContext>({
|
|
39
45
|
ready: false,
|
|
46
|
+
core: [],
|
|
40
47
|
enabled: [],
|
|
41
48
|
plugins: [],
|
|
42
49
|
available: [],
|
|
@@ -42,6 +42,7 @@ export const PluginHost = ({
|
|
|
42
42
|
}: BootstrapPluginsParams): PluginDefinition<PluginHostProvides> => {
|
|
43
43
|
const state = new LocalStorageStore<PluginContext>(PLUGIN_HOST, {
|
|
44
44
|
ready: false,
|
|
45
|
+
core,
|
|
45
46
|
enabled: [...defaults],
|
|
46
47
|
plugins: [],
|
|
47
48
|
available: order.filter(({ id }) => !core.includes(id)),
|
|
@@ -2,15 +2,41 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type { Graph, GraphBuilder } from '@dxos/app-graph';
|
|
5
|
+
import type { Graph, GraphBuilder, Node } from '@dxos/app-graph';
|
|
6
|
+
import { type MaybePromise } from '@dxos/util';
|
|
6
7
|
|
|
7
8
|
import type { Plugin } from '../PluginHost';
|
|
8
9
|
|
|
10
|
+
// TODO(wittjosiah): Factor out.
|
|
11
|
+
export type SerializedNode = {
|
|
12
|
+
name: string;
|
|
13
|
+
data: string;
|
|
14
|
+
type?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// TODO(wittjosiah): Factor out.
|
|
18
|
+
export type NodeSerializer<T = any> = {
|
|
19
|
+
inputType: string;
|
|
20
|
+
outputType: string;
|
|
21
|
+
disposition?: 'hoist' | 'fallback';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Takes a node and serializes it into a format that can be stored.
|
|
25
|
+
*/
|
|
26
|
+
serialize: (node: Node<T>) => MaybePromise<SerializedNode>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Takes a serialized node and deserializes it into the application.
|
|
30
|
+
*/
|
|
31
|
+
deserialize: (data: SerializedNode, ancestors: unknown[]) => MaybePromise<T>;
|
|
32
|
+
};
|
|
33
|
+
|
|
9
34
|
/**
|
|
10
35
|
* Provides for a plugin that exposes the application graph.
|
|
11
36
|
*/
|
|
12
37
|
export type GraphProvides = {
|
|
13
38
|
graph: Graph;
|
|
39
|
+
explore: GraphBuilder['explore'];
|
|
14
40
|
};
|
|
15
41
|
|
|
16
42
|
export type GraphBuilderProvides = {
|
|
@@ -19,6 +45,12 @@ export type GraphBuilderProvides = {
|
|
|
19
45
|
};
|
|
20
46
|
};
|
|
21
47
|
|
|
48
|
+
export type GraphSerializerProvides = {
|
|
49
|
+
graph: {
|
|
50
|
+
serializer: (plugins: Plugin[]) => NodeSerializer[];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
22
54
|
/**
|
|
23
55
|
* Type guard for graph plugins.
|
|
24
56
|
*/
|
|
@@ -30,3 +62,9 @@ export const parseGraphPlugin = (plugin: Plugin) =>
|
|
|
30
62
|
*/
|
|
31
63
|
export const parseGraphBuilderPlugin = (plugin: Plugin) =>
|
|
32
64
|
(plugin.provides as any).graph?.builder ? (plugin as Plugin<GraphBuilderProvides>) : undefined;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Type guard for graph serializer plugins.
|
|
68
|
+
*/
|
|
69
|
+
export const parseGraphSerializerPlugin = (plugin: Plugin) =>
|
|
70
|
+
(plugin.provides as any).graph?.serializer ? (plugin as Plugin<GraphSerializerProvides>) : undefined;
|
|
@@ -33,12 +33,16 @@ export type Toast = z.infer<typeof Toast>;
|
|
|
33
33
|
* Generally only one dialog or popover should be open at a time, a layout plugin should manage this.
|
|
34
34
|
* For other landmarks, such as toasts, rendering them in the layout prevents them from unmounting when navigating.
|
|
35
35
|
*/
|
|
36
|
+
|
|
37
|
+
const LayoutMode = z.union([z.literal('deck'), z.literal('solo'), z.literal('fullscreen')]);
|
|
38
|
+
export const isLayoutMode = (value: any): value is LayoutMode => LayoutMode.safeParse(value).success;
|
|
39
|
+
export type LayoutMode = z.infer<typeof LayoutMode>;
|
|
40
|
+
|
|
36
41
|
// TODO(wittjosiah): Replace Zod w/ Effect Schema to align with ECHO.
|
|
37
42
|
export const Layout = z.object({
|
|
38
|
-
|
|
43
|
+
layoutMode: z.union([z.literal('deck'), z.literal('solo'), z.literal('fullscreen')]),
|
|
39
44
|
|
|
40
45
|
sidebarOpen: z.boolean(),
|
|
41
|
-
|
|
42
46
|
complementarySidebarOpen: z.boolean(),
|
|
43
47
|
/**
|
|
44
48
|
* @deprecated
|
|
@@ -89,13 +93,20 @@ export const parseLayoutPlugin = (plugin: Plugin) => {
|
|
|
89
93
|
const LAYOUT_ACTION = 'dxos.org/plugin/layout';
|
|
90
94
|
export enum LayoutAction {
|
|
91
95
|
SET_LAYOUT = `${LAYOUT_ACTION}/set-layout`,
|
|
96
|
+
SET_LAYOUT_MODE = `${LAYOUT_ACTION}/set-layout-mode`,
|
|
92
97
|
SCROLL_INTO_VIEW = `${LAYOUT_ACTION}/scroll-into-view`,
|
|
98
|
+
UPDATE_PLANK_SIZE = `${LAYOUT_ACTION}/update-plank-size`,
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
/**
|
|
96
102
|
* Expected payload for layout actions.
|
|
97
103
|
*/
|
|
98
104
|
export namespace LayoutAction {
|
|
105
|
+
export type SetLayoutMode = IntentData<{
|
|
106
|
+
layoutMode?: LayoutMode;
|
|
107
|
+
revert?: boolean;
|
|
108
|
+
}>;
|
|
109
|
+
|
|
99
110
|
export type SetLayout = IntentData<{
|
|
100
111
|
/**
|
|
101
112
|
* Element to set the state of.
|