@dxos/app-framework 0.4.1-main.4f4a61d → 0.4.1-main.618f18c

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.
@@ -1,44 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { type IntentData } from '../IntentPlugin';
3
3
  import type { Plugin } from '../PluginHost';
4
- export declare const Toast: z.ZodObject<{
5
- id: z.ZodString;
6
- title: z.ZodOptional<z.ZodString>;
7
- description: z.ZodOptional<z.ZodString>;
8
- icon: z.ZodOptional<z.ZodAny>;
9
- duration: z.ZodOptional<z.ZodNumber>;
10
- closeLabel: z.ZodOptional<z.ZodString>;
11
- actionLabel: z.ZodOptional<z.ZodString>;
12
- actionAlt: z.ZodOptional<z.ZodString>;
13
- onAction: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
14
- }, "strip", z.ZodTypeAny, {
15
- id: string;
16
- title?: string | undefined;
17
- description?: string | undefined;
18
- icon?: any;
19
- duration?: number | undefined;
20
- closeLabel?: string | undefined;
21
- actionLabel?: string | undefined;
22
- actionAlt?: string | undefined;
23
- onAction?: ((...args: unknown[]) => unknown) | undefined;
24
- }, {
25
- id: string;
26
- title?: string | undefined;
27
- description?: string | undefined;
28
- icon?: any;
29
- duration?: number | undefined;
30
- closeLabel?: string | undefined;
31
- actionLabel?: string | undefined;
32
- actionAlt?: string | undefined;
33
- onAction?: ((...args: unknown[]) => unknown) | undefined;
34
- }>;
35
- export type Toast = z.infer<typeof Toast>;
36
4
  /**
37
5
  * Basic state provided by a layout plugin.
38
- *
39
- * Layout provides the state of global UI landmarks, such as the sidebar, dialog, and popover.
40
- * Generally only one dialog or popover should be open at a time, a layout plugin should manage this.
41
- * For other landmarks, such as toasts, rendering them in the layout prevents them from unmounting when navigating.
42
6
  */
43
7
  export declare const Layout: z.ZodObject<{
44
8
  fullscreen: z.ZodBoolean;
@@ -49,77 +13,30 @@ export declare const Layout: z.ZodObject<{
49
13
  popoverOpen: z.ZodBoolean;
50
14
  popoverContent: z.ZodOptional<z.ZodAny>;
51
15
  popoverAnchorId: z.ZodOptional<z.ZodString>;
52
- toasts: z.ZodArray<z.ZodObject<{
53
- id: z.ZodString;
54
- title: z.ZodOptional<z.ZodString>;
55
- description: z.ZodOptional<z.ZodString>;
56
- icon: z.ZodOptional<z.ZodAny>;
57
- duration: z.ZodOptional<z.ZodNumber>;
58
- closeLabel: z.ZodOptional<z.ZodString>;
59
- actionLabel: z.ZodOptional<z.ZodString>;
60
- actionAlt: z.ZodOptional<z.ZodString>;
61
- onAction: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
62
- }, "strip", z.ZodTypeAny, {
63
- id: string;
64
- title?: string | undefined;
65
- description?: string | undefined;
66
- icon?: any;
67
- duration?: number | undefined;
68
- closeLabel?: string | undefined;
69
- actionLabel?: string | undefined;
70
- actionAlt?: string | undefined;
71
- onAction?: ((...args: unknown[]) => unknown) | undefined;
72
- }, {
73
- id: string;
74
- title?: string | undefined;
75
- description?: string | undefined;
76
- icon?: any;
77
- duration?: number | undefined;
78
- closeLabel?: string | undefined;
79
- actionLabel?: string | undefined;
80
- actionAlt?: string | undefined;
81
- onAction?: ((...args: unknown[]) => unknown) | undefined;
82
- }>, "many">;
16
+ active: z.ZodOptional<z.ZodString>;
17
+ previous: z.ZodOptional<z.ZodString>;
83
18
  }, "strip", z.ZodTypeAny, {
84
19
  fullscreen: boolean;
85
20
  sidebarOpen: boolean;
86
21
  complementarySidebarOpen: boolean;
87
22
  dialogOpen: boolean;
88
23
  popoverOpen: boolean;
89
- toasts: {
90
- id: string;
91
- title?: string | undefined;
92
- description?: string | undefined;
93
- icon?: any;
94
- duration?: number | undefined;
95
- closeLabel?: string | undefined;
96
- actionLabel?: string | undefined;
97
- actionAlt?: string | undefined;
98
- onAction?: ((...args: unknown[]) => unknown) | undefined;
99
- }[];
100
24
  dialogContent?: any;
101
25
  popoverContent?: any;
102
26
  popoverAnchorId?: string | undefined;
27
+ active?: string | undefined;
28
+ previous?: string | undefined;
103
29
  }, {
104
30
  fullscreen: boolean;
105
31
  sidebarOpen: boolean;
106
32
  complementarySidebarOpen: boolean;
107
33
  dialogOpen: boolean;
108
34
  popoverOpen: boolean;
109
- toasts: {
110
- id: string;
111
- title?: string | undefined;
112
- description?: string | undefined;
113
- icon?: any;
114
- duration?: number | undefined;
115
- closeLabel?: string | undefined;
116
- actionLabel?: string | undefined;
117
- actionAlt?: string | undefined;
118
- onAction?: ((...args: unknown[]) => unknown) | undefined;
119
- }[];
120
35
  dialogContent?: any;
121
36
  popoverContent?: any;
122
37
  popoverAnchorId?: string | undefined;
38
+ active?: string | undefined;
39
+ previous?: string | undefined;
123
40
  }>;
124
41
  export type Layout = z.infer<typeof Layout>;
125
42
  /**
@@ -133,38 +50,42 @@ export type LayoutProvides = {
133
50
  */
134
51
  export declare const parseLayoutPlugin: (plugin: Plugin) => Plugin<LayoutProvides> | undefined;
135
52
  export declare enum LayoutAction {
136
- SET_LAYOUT = "dxos.org/plugin/layout/set-layout",
137
- /** @deprecated */
53
+ TOGGLE_FULLSCREEN = "dxos.org/plugin/layout/toggle-fullscreen",
54
+ TOGGLE_SIDEBAR = "dxos.org/plugin/layout/toggle-sidebar",
55
+ TOGGLE_COMPLEMENTARY_SIDEBAR = "dxos.org/plugin/layout/toggle-complementary-sidebar",
56
+ OPEN_DIALOG = "dxos.org/plugin/layout/open-dialog",
57
+ CLOSE_DIALOG = "dxos.org/plugin/layout/close-dialog",
58
+ OPEN_POPOVER = "dxos.org/plugin/layout/open-popover",
59
+ CLOSE_POPOVER = "dxos.org/plugin/layout/close-popover",
60
+ ACTIVATE = "dxos.org/plugin/layout/activate",
138
61
  FOCUS = "dxos.org/plugin/layout/focus"
139
62
  }
140
63
  /**
141
64
  * Expected payload for layout actions.
142
65
  */
143
66
  export declare namespace LayoutAction {
144
- type SetLayout = IntentData<{
145
- /**
146
- * Element to set the state of.
147
- */
148
- element: 'fullscreen' | 'sidebar' | 'complementary' | 'dialog' | 'popover' | 'toast';
149
- /**
150
- * Whether the element is on or off.
151
- *
152
- * If omitted, the element's state will be toggled or set based on other provided data.
153
- * For example, if `component` is provided, the state will be set to `true`.
154
- */
67
+ type ToggleFullscreen = IntentData<{
155
68
  state?: boolean;
156
- /**
157
- * Component to render in the dialog or popover.
158
- */
159
- component?: string;
160
- /**
161
- * Data to be passed to the dialog or popover Surface.
162
- */
163
- subject?: any;
164
- /**
165
- * Anchor ID for the popover.
166
- */
167
- anchorId?: string;
69
+ }>;
70
+ type ToggleSidebar = IntentData<{
71
+ state?: boolean;
72
+ }>;
73
+ type ToggleComplementarySidebar = IntentData<{
74
+ state?: boolean;
75
+ }>;
76
+ type OpenDialog = IntentData<{
77
+ component: string;
78
+ subject: any;
79
+ }>;
80
+ type CloseDialog = IntentData<{}>;
81
+ type OpenPopover = IntentData<{
82
+ anchorId: string;
83
+ component: string;
84
+ subject: any;
85
+ }>;
86
+ type ClosePopover = IntentData<{}>;
87
+ type Activate = IntentData<{
88
+ id: string;
168
89
  }>;
169
90
  }
170
91
  //# sourceMappingURL=layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/layout.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWhB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;AAE1C;;;;;;GAMG;AAEH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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0.4.1-main.618f18c",
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",
@@ -16,13 +16,13 @@
16
16
  "@preact/signals-react": "^1.3.6",
17
17
  "deepsignal": "1.4.0-shallow.0",
18
18
  "zod": "^3.22.4",
19
- "@dxos/debug": "0.4.1-main.4f4a61d",
20
- "@dxos/invariant": "0.4.1-main.4f4a61d",
21
- "@dxos/app-graph": "0.4.1-main.4f4a61d",
22
- "@dxos/local-storage": "0.4.1-main.4f4a61d",
23
- "@dxos/log": "0.4.1-main.4f4a61d",
24
- "@dxos/async": "0.4.1-main.4f4a61d",
25
- "@dxos/util": "0.4.1-main.4f4a61d"
19
+ "@dxos/app-graph": "0.4.1-main.618f18c",
20
+ "@dxos/async": "0.4.1-main.618f18c",
21
+ "@dxos/debug": "0.4.1-main.618f18c",
22
+ "@dxos/invariant": "0.4.1-main.618f18c",
23
+ "@dxos/local-storage": "0.4.1-main.618f18c",
24
+ "@dxos/util": "0.4.1-main.618f18c",
25
+ "@dxos/log": "0.4.1-main.618f18c"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/react": "^18.0.21",
@@ -5,6 +5,5 @@
5
5
  export * from './graph';
6
6
  export * from './layout';
7
7
  export * from './metadata';
8
- export * from './navigation';
9
8
  export * from './settings';
10
9
  export * from './translations';
@@ -11,34 +11,16 @@ import type { Plugin } from '../PluginHost';
11
11
  // Provides
12
12
  //
13
13
 
14
- export const Toast = z.object({
15
- id: z.string(),
16
- title: z.string().optional(),
17
- description: z.string().optional(),
18
- // TODO(wittjosiah): `icon` should be string to be parsed by an `Icon` component.
19
- icon: z.any().optional(),
20
- duration: z.number().optional(),
21
- closeLabel: z.string().optional(),
22
- actionLabel: z.string().optional(),
23
- actionAlt: z.string().optional(),
24
- onAction: z.function().optional(),
25
- });
26
-
27
- export type Toast = z.infer<typeof Toast>;
28
-
29
14
  /**
30
15
  * Basic state provided by a layout plugin.
31
- *
32
- * Layout provides the state of global UI landmarks, such as the sidebar, dialog, and popover.
33
- * Generally only one dialog or popover should be open at a time, a layout plugin should manage this.
34
- * For other landmarks, such as toasts, rendering them in the layout prevents them from unmounting when navigating.
35
16
  */
36
- // TODO(wittjosiah): Replace Zod w/ Effect Schema to align with ECHO.
17
+ // TODO(burdon): Josiah: why do we use zod here?
37
18
  export const Layout = z.object({
38
19
  fullscreen: z.boolean(),
39
20
  sidebarOpen: z.boolean(),
40
21
  complementarySidebarOpen: z.boolean(),
41
22
 
23
+ // TODO(burdon): Why do we have a single root?
42
24
  dialogOpen: z.boolean(),
43
25
  dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),
44
26
 
@@ -46,7 +28,10 @@ export const Layout = z.object({
46
28
  popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),
47
29
  popoverAnchorId: z.string().optional(),
48
30
 
49
- toasts: z.array(Toast),
31
+ // TODO(wittjosiah): Array?
32
+ active: z.string().optional().describe('Id of the currently active item.'),
33
+ // TODO(wittjosiah): History?
34
+ previous: z.string().optional(),
50
35
  });
51
36
 
52
37
  export type Layout = z.infer<typeof Layout>;
@@ -71,12 +56,16 @@ export const parseLayoutPlugin = (plugin: Plugin) => {
71
56
  //
72
57
 
73
58
  const LAYOUT_ACTION = 'dxos.org/plugin/layout';
59
+ // TODO(wittjosiah): Consider consolidating some action types (e.g. toggle).
74
60
  export enum LayoutAction {
75
- SET_LAYOUT = `${LAYOUT_ACTION}/set-layout`,
76
-
77
- /** @deprecated */
78
- // TODO(wittjosiah): At minimum this should be renamed, "focus" means something very specific on a web page.
79
- // Consider removing this action entirely, it's maybe not generic enough to live here.
61
+ TOGGLE_FULLSCREEN = `${LAYOUT_ACTION}/toggle-fullscreen`,
62
+ TOGGLE_SIDEBAR = `${LAYOUT_ACTION}/toggle-sidebar`,
63
+ TOGGLE_COMPLEMENTARY_SIDEBAR = `${LAYOUT_ACTION}/toggle-complementary-sidebar`,
64
+ OPEN_DIALOG = `${LAYOUT_ACTION}/open-dialog`,
65
+ CLOSE_DIALOG = `${LAYOUT_ACTION}/close-dialog`,
66
+ OPEN_POPOVER = `${LAYOUT_ACTION}/open-popover`,
67
+ CLOSE_POPOVER = `${LAYOUT_ACTION}/close-popover`,
68
+ ACTIVATE = `${LAYOUT_ACTION}/activate`,
80
69
  FOCUS = `${LAYOUT_ACTION}/focus`,
81
70
  }
82
71
 
@@ -84,33 +73,34 @@ export enum LayoutAction {
84
73
  * Expected payload for layout actions.
85
74
  */
86
75
  export namespace LayoutAction {
87
- export type SetLayout = IntentData<{
88
- /**
89
- * Element to set the state of.
90
- */
91
- element: 'fullscreen' | 'sidebar' | 'complementary' | 'dialog' | 'popover' | 'toast';
92
-
93
- /**
94
- * Whether the element is on or off.
95
- *
96
- * If omitted, the element's state will be toggled or set based on other provided data.
97
- * For example, if `component` is provided, the state will be set to `true`.
98
- */
76
+ export type ToggleFullscreen = IntentData<{
99
77
  state?: boolean;
78
+ }>;
79
+
80
+ export type ToggleSidebar = IntentData<{
81
+ state?: boolean;
82
+ }>;
100
83
 
101
- /**
102
- * Component to render in the dialog or popover.
103
- */
104
- component?: string;
84
+ export type ToggleComplementarySidebar = IntentData<{
85
+ state?: boolean;
86
+ }>;
87
+
88
+ export type OpenDialog = IntentData<{
89
+ component: string;
90
+ subject: any;
91
+ }>;
92
+
93
+ export type CloseDialog = IntentData<{}>;
94
+
95
+ export type OpenPopover = IntentData<{
96
+ anchorId: string;
97
+ component: string;
98
+ subject: any;
99
+ }>;
105
100
 
106
- /**
107
- * Data to be passed to the dialog or popover Surface.
108
- */
109
- subject?: any;
101
+ export type ClosePopover = IntentData<{}>;
110
102
 
111
- /**
112
- * Anchor ID for the popover.
113
- */
114
- anchorId?: string;
103
+ export type Activate = IntentData<{
104
+ id: string;
115
105
  }>;
116
106
  }
@@ -1,47 +0,0 @@
1
- import { z } from 'zod';
2
- import type { IntentData } from '../IntentPlugin';
3
- import type { Plugin } from '../PluginHost';
4
- /**
5
- * Basic state provided by a navigation plugin.
6
- */
7
- export declare const Location: z.ZodObject<{
8
- active: z.ZodOptional<z.ZodString>;
9
- previous: z.ZodOptional<z.ZodString>;
10
- }, "strip", z.ZodTypeAny, {
11
- active?: string | undefined;
12
- previous?: string | undefined;
13
- }, {
14
- active?: string | undefined;
15
- previous?: string | undefined;
16
- }>;
17
- export type Location = z.infer<typeof Location>;
18
- /**
19
- * Provides for a plugin that can manage the app navigation.
20
- */
21
- export type LocationProvides = {
22
- location: Readonly<Location>;
23
- };
24
- /**
25
- * Type guard for layout plugins.
26
- */
27
- export declare const parseNavigationPlugin: (plugin: Plugin) => Plugin<LocationProvides> | undefined;
28
- export declare enum NavigationAction {
29
- ACTIVATE = "dxos.org/plugin/navigation/activate"
30
- }
31
- /**
32
- * Expected payload for navigation actions.
33
- */
34
- export declare namespace NavigationAction {
35
- type Activate = IntentData<{
36
- /**
37
- * Id to set as active.
38
- */
39
- id: string;
40
- /**
41
- * Location of the active item.
42
- * Defaults to 'main'.
43
- */
44
- key?: string;
45
- }>;
46
- }
47
- //# sourceMappingURL=navigation.d.ts.map
@@ -1 +0,0 @@
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;AAM5C;;GAEG;AAGH,eAAO,MAAM,QAAQ;;;;;;;;;EAInB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,WAAY,MAAM,yCAGnD,CAAC;AAOF,oBAAY,gBAAgB;IAC1B,QAAQ,wCAAkC;CAC3C;AAED;;GAEG;AACH,yBAAiB,gBAAgB,CAAC;IAChC,KAAY,QAAQ,GAAG,UAAU,CAAC;QAChC;;WAEG;QACH,EAAE,EAAE,MAAM,CAAC;QAEX;;;WAGG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ"}
@@ -1,67 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { z } from 'zod';
6
-
7
- import type { IntentData } from '../IntentPlugin';
8
- import type { Plugin } from '../PluginHost';
9
-
10
- //
11
- // Provides
12
- //
13
-
14
- /**
15
- * Basic state provided by a navigation plugin.
16
- */
17
- // TODO(wittjosiah): Replace Zod w/ Effect Schema to align with ECHO.
18
- // TODO(wittjosiah): We should align this more with `window.location` along the lines of what React Router does.
19
- export const Location = z.object({
20
- active: z.string().optional().describe('Id of the currently active item.'),
21
- // TODO(wittjosiah): History?
22
- previous: z.string().optional(),
23
- });
24
-
25
- export type Location = z.infer<typeof Location>;
26
-
27
- /**
28
- * Provides for a plugin that can manage the app navigation.
29
- */
30
- export type LocationProvides = {
31
- location: Readonly<Location>;
32
- };
33
-
34
- /**
35
- * Type guard for layout plugins.
36
- */
37
- export const parseNavigationPlugin = (plugin: Plugin) => {
38
- const { success } = Location.safeParse((plugin.provides as any).location);
39
- return success ? (plugin as Plugin<LocationProvides>) : undefined;
40
- };
41
-
42
- //
43
- // Intents
44
- //
45
-
46
- const NAVIGATION_ACTION = 'dxos.org/plugin/navigation';
47
- export enum NavigationAction {
48
- ACTIVATE = `${NAVIGATION_ACTION}/activate`,
49
- }
50
-
51
- /**
52
- * Expected payload for navigation actions.
53
- */
54
- export namespace NavigationAction {
55
- export type Activate = IntentData<{
56
- /**
57
- * Id to set as active.
58
- */
59
- id: string;
60
-
61
- /**
62
- * Location of the active item.
63
- * Defaults to 'main'.
64
- */
65
- key?: string;
66
- }>;
67
- }