@dxos/app-framework 0.3.10-main.a21ec31 → 0.3.10-main.dcfebef
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 +166 -19
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +189 -47
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +1 -8
- 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/PluginHost/plugin.d.ts +8 -0
- package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
- package/dist/types/src/plugins/common/index.d.ts +1 -0
- package/dist/types/src/plugins/common/index.d.ts.map +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +7 -5
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/settings.d.ts +8 -0
- package/dist/types/src/plugins/common/settings.d.ts.map +1 -0
- package/dist/types/src/plugins/components/SettingsDialog.d.ts +2 -0
- package/dist/types/src/plugins/components/SettingsDialog.d.ts.map +1 -0
- package/dist/types/src/plugins/components/SettingsValue.d.ts +8 -0
- package/dist/types/src/plugins/components/SettingsValue.d.ts.map +1 -0
- package/dist/types/src/plugins/components/ShortcutsDialog.d.ts +2 -0
- package/dist/types/src/plugins/components/ShortcutsDialog.d.ts.map +1 -0
- package/dist/types/src/plugins/components/index.d.ts +4 -0
- package/dist/types/src/plugins/components/index.d.ts.map +1 -0
- package/dist/types/src/plugins/index.d.ts +1 -0
- package/dist/types/src/plugins/index.d.ts.map +1 -1
- package/package.json +15 -9
- package/src/plugins/PluginHost/PluginContext.tsx +2 -11
- package/src/plugins/PluginHost/PluginHost.tsx +6 -5
- package/src/plugins/PluginHost/plugin.ts +5 -0
- package/src/plugins/common/index.ts +1 -0
- package/src/plugins/common/layout.ts +7 -3
- package/src/plugins/common/settings.ts +16 -0
- package/src/plugins/components/SettingsDialog.tsx +100 -0
- package/src/plugins/components/SettingsValue.tsx +36 -0
- package/src/plugins/components/ShortcutsDialog.tsx +61 -0
- package/src/plugins/components/index.ts +7 -0
- package/src/plugins/index.ts +1 -0
- package/tsconfig.json +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-framework",
|
|
3
|
-
"version": "0.3.10-main.
|
|
3
|
+
"version": "0.3.10-main.dcfebef",
|
|
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,19 +16,25 @@
|
|
|
16
16
|
"@preact/signals-react": "^1.3.6",
|
|
17
17
|
"deepsignal": "1.4.0-shallow.0",
|
|
18
18
|
"zod": "^3.22.4",
|
|
19
|
-
"@dxos/
|
|
20
|
-
"@dxos/
|
|
21
|
-
"@dxos/
|
|
22
|
-
"@dxos/invariant": "0.3.10-main.
|
|
23
|
-
"@dxos/local-storage": "0.3.10-main.
|
|
24
|
-
"@dxos/log": "0.3.10-main.
|
|
19
|
+
"@dxos/app-graph": "0.3.10-main.dcfebef",
|
|
20
|
+
"@dxos/debug": "0.3.10-main.dcfebef",
|
|
21
|
+
"@dxos/async": "0.3.10-main.dcfebef",
|
|
22
|
+
"@dxos/invariant": "0.3.10-main.dcfebef",
|
|
23
|
+
"@dxos/local-storage": "0.3.10-main.dcfebef",
|
|
24
|
+
"@dxos/log": "0.3.10-main.dcfebef",
|
|
25
|
+
"@dxos/keyboard": "0.3.10-main.dcfebef"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/react": "^18.0.21",
|
|
28
|
-
"react": "^18.2.0"
|
|
29
|
+
"react": "^18.2.0",
|
|
30
|
+
"@dxos/react-ui": "0.3.10-main.dcfebef",
|
|
31
|
+
"@dxos/react-ui-theme": "0.3.10-main.dcfebef",
|
|
32
|
+
"@dxos/storybook-utils": "0.3.10-main.dcfebef"
|
|
29
33
|
},
|
|
30
34
|
"peerDependencies": {
|
|
31
|
-
"react": "*"
|
|
35
|
+
"react": "*",
|
|
36
|
+
"@dxos/react-ui": "0.3.10-main.dcfebef",
|
|
37
|
+
"@dxos/react-ui-theme": "0.3.10-main.dcfebef"
|
|
32
38
|
},
|
|
33
39
|
"publishConfig": {
|
|
34
40
|
"access": "public"
|
|
@@ -30,17 +30,9 @@ export type PluginContext = {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Mark plugin as enabled.
|
|
33
|
-
*
|
|
34
33
|
* Requires reload to take effect.
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Mark plugin as disabled.
|
|
40
|
-
*
|
|
41
|
-
* Requires reload to take effect.
|
|
42
|
-
*/
|
|
43
|
-
disablePlugin: (id: string) => void;
|
|
35
|
+
setPlugin: (id: string, enabled: boolean) => void;
|
|
44
36
|
};
|
|
45
37
|
|
|
46
38
|
const PluginContext: Context<PluginContext> = createContext<PluginContext>({
|
|
@@ -48,8 +40,7 @@ const PluginContext: Context<PluginContext> = createContext<PluginContext>({
|
|
|
48
40
|
enabled: [],
|
|
49
41
|
plugins: [],
|
|
50
42
|
available: [],
|
|
51
|
-
|
|
52
|
-
disablePlugin: () => {},
|
|
43
|
+
setPlugin: () => {},
|
|
53
44
|
});
|
|
54
45
|
|
|
55
46
|
/**
|
|
@@ -43,11 +43,12 @@ export const PluginHost = ({
|
|
|
43
43
|
enabled: [...defaults],
|
|
44
44
|
plugins: [],
|
|
45
45
|
available: order.filter(({ id }) => !core.includes(id)),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
setPlugin: (id: string, enabled: boolean) => {
|
|
47
|
+
if (enabled) {
|
|
48
|
+
state.values.enabled = [...state.values.enabled, id];
|
|
49
|
+
} else {
|
|
50
|
+
state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);
|
|
51
|
+
}
|
|
51
52
|
},
|
|
52
53
|
});
|
|
53
54
|
|
|
@@ -13,17 +13,19 @@ import type { Plugin } from '../PluginHost';
|
|
|
13
13
|
/**
|
|
14
14
|
* Basic state provided by a layout plugin.
|
|
15
15
|
*/
|
|
16
|
+
// TODO(burdon): Josiah: why do we use zod here?
|
|
16
17
|
export const Layout = z.object({
|
|
17
18
|
fullscreen: z.boolean(),
|
|
18
19
|
sidebarOpen: z.boolean(),
|
|
19
20
|
complementarySidebarOpen: z.boolean(),
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
// TODO(burdon): Why do we have a single root?
|
|
22
23
|
dialogOpen: z.boolean(),
|
|
24
|
+
dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),
|
|
23
25
|
|
|
24
|
-
popoverAnchorId: z.string().optional(),
|
|
25
|
-
popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),
|
|
26
26
|
popoverOpen: z.boolean(),
|
|
27
|
+
popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),
|
|
28
|
+
popoverAnchorId: z.string().optional(),
|
|
27
29
|
|
|
28
30
|
// TODO(wittjosiah): Array?
|
|
29
31
|
active: z.string().optional().describe('Id of the currently active item.'),
|
|
@@ -62,6 +64,8 @@ export enum LayoutAction {
|
|
|
62
64
|
CLOSE_DIALOG = `${LAYOUT_ACTION}/close-dialog`,
|
|
63
65
|
OPEN_POPOVER = `${LAYOUT_ACTION}/open-popover`,
|
|
64
66
|
CLOSE_POPOVER = `${LAYOUT_ACTION}/close-popover`,
|
|
67
|
+
OPEN_SETTINGS = `${LAYOUT_ACTION}/open-settings`,
|
|
68
|
+
OPEN_SHORTCUTS = `${LAYOUT_ACTION}/open-shortcuts`,
|
|
65
69
|
ACTIVATE = `${LAYOUT_ACTION}/activate`,
|
|
66
70
|
}
|
|
67
71
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Plugin } from '../PluginHost';
|
|
6
|
+
|
|
7
|
+
// TODO(burdon): Plugins should export ts-effect object (see local-storage).
|
|
8
|
+
// TODO(burdon): Auto generate form.
|
|
9
|
+
// TODO(burdon): Set surface's data.type to plugin id (allow custom settings surface).
|
|
10
|
+
|
|
11
|
+
export type SettingsProvides<T> = {
|
|
12
|
+
settings: {
|
|
13
|
+
meta: Plugin['meta'];
|
|
14
|
+
values: T; // TODO(burdon): Read-only?
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Button, DensityProvider, Dialog, List, ListItem, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { ghostHover, ghostSelected, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
9
|
+
|
|
10
|
+
import { type Plugin, usePlugins } from '../PluginHost';
|
|
11
|
+
import { Surface } from '../SurfacePlugin';
|
|
12
|
+
|
|
13
|
+
// TODO(burdon): Move into separate plugin.
|
|
14
|
+
export const SettingsDialogContent = () => {
|
|
15
|
+
const { t } = useTranslation('os');
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Store preview tab.
|
|
18
|
+
const [plugin, setPlugin] = useState<string>('dxos.org/plugin/registry');
|
|
19
|
+
const { plugins, enabled } = usePlugins();
|
|
20
|
+
|
|
21
|
+
const core = [
|
|
22
|
+
'dxos.org/plugin/layout',
|
|
23
|
+
'dxos.org/plugin/client',
|
|
24
|
+
'dxos.org/plugin/space',
|
|
25
|
+
'dxos.org/plugin/registry',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const filteredPlugins = enabled
|
|
29
|
+
.map((id) => plugins.find((plugin) => plugin.meta.id === id))
|
|
30
|
+
.filter((plugin) => (plugin?.provides as any)?.settings)
|
|
31
|
+
.map((plugin) => plugin!.meta)
|
|
32
|
+
.sort(({ name: a }, { name: b }) => a?.localeCompare(b ?? '') ?? 0);
|
|
33
|
+
|
|
34
|
+
// TODO(burdon): Vertical layout if mobile (pattern).
|
|
35
|
+
return (
|
|
36
|
+
<DensityProvider density='fine'>
|
|
37
|
+
<Dialog.Content classNames={['h-[90%] md:max-is-[40rem] overflow-hidden']}>
|
|
38
|
+
<Dialog.Title>{t('settings dialog title', { ns: 'os' })}</Dialog.Title>
|
|
39
|
+
|
|
40
|
+
<div className='flex grow mlb-4 overflow-hidden'>
|
|
41
|
+
<div className={mx('flex flex-col w-[200px] space-y-4 pr-4 border-r overflow-y-auto', groupBorder)}>
|
|
42
|
+
<PluginList
|
|
43
|
+
title='Options'
|
|
44
|
+
plugins={core.map((id) => plugins.find((p) => p.meta.id === id)!.meta)}
|
|
45
|
+
selected={plugin}
|
|
46
|
+
onSelect={(plugin) => setPlugin(plugin)}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<PluginList
|
|
50
|
+
title='Plugins'
|
|
51
|
+
plugins={filteredPlugins}
|
|
52
|
+
selected={plugin}
|
|
53
|
+
onSelect={(plugin) => setPlugin(plugin)}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div className={mx('flex flex-col w-full md:px-4 divide-y overflow-y-auto', groupBorder)}>
|
|
58
|
+
<Surface role='settings' data={{ plugin }} />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<Dialog.Close asChild>
|
|
63
|
+
<Button variant='primary' classNames='mbs-2'>
|
|
64
|
+
{t('done label', { ns: 'os' })}
|
|
65
|
+
</Button>
|
|
66
|
+
</Dialog.Close>
|
|
67
|
+
</Dialog.Content>
|
|
68
|
+
</DensityProvider>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const PluginList = ({
|
|
73
|
+
title,
|
|
74
|
+
plugins,
|
|
75
|
+
selected,
|
|
76
|
+
onSelect,
|
|
77
|
+
}: {
|
|
78
|
+
title: string;
|
|
79
|
+
plugins: Plugin['meta'][];
|
|
80
|
+
selected?: string;
|
|
81
|
+
onSelect: (plugin: string) => void;
|
|
82
|
+
}) => {
|
|
83
|
+
return (
|
|
84
|
+
<div role='none'>
|
|
85
|
+
<h2 className='my-1 px-2 text-sm text-neutral-500'>{title}</h2>
|
|
86
|
+
<List selectable>
|
|
87
|
+
{plugins.map((plugin) => (
|
|
88
|
+
<ListItem.Root
|
|
89
|
+
key={plugin.id}
|
|
90
|
+
onClick={() => onSelect(plugin.id)}
|
|
91
|
+
selected={plugin.id === selected}
|
|
92
|
+
classNames={['px-2 rounded', plugin.id === selected && ghostSelected, ghostHover]}
|
|
93
|
+
>
|
|
94
|
+
<ListItem.Heading classNames={['flex w-full items-center cursor-pointer']}>{plugin.name}</ListItem.Heading>
|
|
95
|
+
</ListItem.Root>
|
|
96
|
+
))}
|
|
97
|
+
</List>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Input } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
type SettingValueProps = {
|
|
10
|
+
label: string;
|
|
11
|
+
description?: JSX.Element;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const SettingsValue = ({ label, description, children }: PropsWithChildren<SettingValueProps>) => {
|
|
15
|
+
return (
|
|
16
|
+
<div role='none' className='flex w-full gap-4 py-1'>
|
|
17
|
+
<Input.Root>
|
|
18
|
+
<div role='none' className='flex flex-col w-full'>
|
|
19
|
+
{/* TODO(burdon): Consistent height for controls (e.g., Select, Textbox, and Checkbox are all different). */}
|
|
20
|
+
<Input.Label classNames='flex min-h-[40px] items-center'>{label}</Input.Label>
|
|
21
|
+
{description && (
|
|
22
|
+
<Input.DescriptionAndValidation classNames='mbs-0.5'>
|
|
23
|
+
<Input.Description>{description}</Input.Description>
|
|
24
|
+
</Input.DescriptionAndValidation>
|
|
25
|
+
)}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div role='none'>
|
|
29
|
+
<div role='none' className='flex min-h-[40px] items-center'>
|
|
30
|
+
{children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</Input.Root>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Label } from '@dxos/app-graph';
|
|
8
|
+
import { Keyboard, keySymbols } from '@dxos/keyboard';
|
|
9
|
+
import { Button, Dialog, DensityProvider, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
11
|
+
|
|
12
|
+
export const ShortcutsDialogContent = () => {
|
|
13
|
+
const { t } = useTranslation('os');
|
|
14
|
+
|
|
15
|
+
const bindings = Keyboard.singleton.getBindings();
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): Factor out.
|
|
18
|
+
// TODO(burdon): How to access all translations across plugins?
|
|
19
|
+
const getLabel = (label: Label) => (Array.isArray(label) ? t(...label) : label);
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<DensityProvider density='fine'>
|
|
23
|
+
<Dialog.Content classNames={['md:max-is-[30rem] overflow-hidden']}>
|
|
24
|
+
<Dialog.Title>{t('shortcuts dialog title', { ns: 'os' })}</Dialog.Title>
|
|
25
|
+
|
|
26
|
+
<table className='table-fixed border-collapse my-4'>
|
|
27
|
+
<tbody>
|
|
28
|
+
{bindings.map((binding, i) => (
|
|
29
|
+
<tr key={i}>
|
|
30
|
+
<td className='p-1 w-[120px]'>
|
|
31
|
+
<div className='flex gap-1'>
|
|
32
|
+
{keySymbols(binding.binding).map((c, i) => (
|
|
33
|
+
<span
|
|
34
|
+
key={i}
|
|
35
|
+
className={mx(
|
|
36
|
+
'inline-flex w-[24px] h-[24px] justify-center items-center text-xs',
|
|
37
|
+
'rounded border border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-850',
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
{c}
|
|
41
|
+
</span>
|
|
42
|
+
))}
|
|
43
|
+
</div>
|
|
44
|
+
</td>
|
|
45
|
+
<td className='p-1'>
|
|
46
|
+
<span className='grow truncate'>{getLabel(binding.data as Label)}</span>
|
|
47
|
+
</td>
|
|
48
|
+
</tr>
|
|
49
|
+
))}
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
<Dialog.Close asChild>
|
|
54
|
+
<Button variant='primary' classNames='mbs-2'>
|
|
55
|
+
{t('close label', { ns: 'os' })}
|
|
56
|
+
</Button>
|
|
57
|
+
</Dialog.Close>
|
|
58
|
+
</Dialog.Content>
|
|
59
|
+
</DensityProvider>
|
|
60
|
+
);
|
|
61
|
+
};
|
package/src/plugins/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -26,12 +26,24 @@
|
|
|
26
26
|
{
|
|
27
27
|
"path": "../../common/invariant"
|
|
28
28
|
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../common/keyboard"
|
|
31
|
+
},
|
|
29
32
|
{
|
|
30
33
|
"path": "../../common/local-storage"
|
|
31
34
|
},
|
|
32
35
|
{
|
|
33
36
|
"path": "../../common/log"
|
|
34
37
|
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../../ui/react-ui"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../../ui/react-ui-theme"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"path": "../../ui/storybook-utils"
|
|
46
|
+
},
|
|
35
47
|
{
|
|
36
48
|
"path": "../app-graph"
|
|
37
49
|
}
|