@dxos/plugin-registry 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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/cli/index.mjs +15 -19
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +50 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/cli/index.mjs +15 -18
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +51 -41
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/RegistryPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/commands/disable.d.ts +2 -2
- package/dist/types/src/cli/commands/enable.d.ts +2 -2
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/cli/storage.d.ts +4 -4
- package/dist/types/src/cli/storage.d.ts.map +1 -1
- package/dist/types/src/components/PluginDetail/PluginDetail.d.ts +11 -0
- package/dist/types/src/components/PluginDetail/PluginDetail.d.ts.map +1 -0
- package/dist/types/src/components/PluginDetail/PluginDetail.stories.d.ts +39 -0
- package/dist/types/src/components/PluginDetail/PluginDetail.stories.d.ts.map +1 -0
- package/dist/types/src/components/PluginDetail/index.d.ts +2 -0
- package/dist/types/src/components/PluginDetail/index.d.ts.map +1 -0
- package/dist/types/src/components/PluginList/PluginItem.d.ts.map +1 -0
- package/dist/types/src/components/PluginList/PluginList.d.ts.map +1 -0
- package/dist/types/src/components/PluginList/PluginList.stories.d.ts +38 -0
- package/dist/types/src/components/PluginList/PluginList.stories.d.ts.map +1 -0
- package/dist/types/src/components/PluginList/index.d.ts +2 -0
- package/dist/types/src/components/PluginList/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/LoadPluginDialog/LoadPluginDialog.d.ts +4 -0
- package/dist/types/src/containers/LoadPluginDialog/LoadPluginDialog.d.ts.map +1 -0
- package/dist/types/src/containers/LoadPluginDialog/index.d.ts +2 -0
- package/dist/types/src/containers/LoadPluginDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/PluginArticle/PluginArticle.d.ts +7 -0
- package/dist/types/src/containers/PluginArticle/PluginArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PluginArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PluginArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/PluginRegistry/PluginRegistry.d.ts +10 -0
- package/dist/types/src/containers/PluginRegistry/PluginRegistry.d.ts.map +1 -0
- package/dist/types/src/containers/PluginRegistry/index.d.ts +2 -0
- package/dist/types/src/containers/PluginRegistry/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +6 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +5 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open-plugin-registry.d.ts +5 -0
- package/dist/types/src/operations/open-plugin-registry.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +19 -15
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -31
- package/src/RegistryPlugin.tsx +9 -7
- package/src/capabilities/app-graph-builder.ts +149 -0
- package/src/capabilities/index.ts +9 -3
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +95 -0
- package/src/cli/plugin.ts +4 -3
- package/src/cli/storage.ts +14 -21
- package/src/components/{PluginDetail.stories.tsx → PluginDetail/PluginDetail.stories.tsx} +6 -6
- package/src/components/PluginDetail/PluginDetail.tsx +84 -0
- package/src/components/PluginDetail/index.ts +5 -0
- package/src/components/{PluginItem.tsx → PluginList/PluginItem.tsx} +16 -12
- package/src/components/PluginList/PluginList.stories.tsx +87 -0
- package/src/components/PluginList/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/containers/LoadPluginDialog/LoadPluginDialog.tsx +85 -0
- package/src/containers/LoadPluginDialog/index.ts +5 -0
- package/src/containers/PluginArticle/PluginArticle.tsx +28 -0
- package/src/containers/PluginArticle/index.ts +5 -0
- package/src/containers/PluginRegistry/PluginRegistry.tsx +94 -0
- package/src/containers/PluginRegistry/index.ts +5 -0
- package/src/containers/index.ts +10 -0
- package/src/meta.ts +12 -5
- package/src/operations/index.ts +7 -0
- package/src/operations/open-plugin-registry.ts +21 -0
- package/src/translations.ts +19 -15
- package/dist/lib/browser/app-graph-builder-P3ZGGFAR.mjs +0 -166
- package/dist/lib/browser/app-graph-builder-P3ZGGFAR.mjs.map +0 -7
- package/dist/lib/browser/chunk-VOAOTNGS.mjs +0 -19
- package/dist/lib/browser/chunk-VOAOTNGS.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-P5PKLPRT.mjs +0 -24
- package/dist/lib/browser/operation-resolver-P5PKLPRT.mjs.map +0 -7
- package/dist/lib/browser/react-surface-IIM6T7IA.mjs +0 -337
- package/dist/lib/browser/react-surface-IIM6T7IA.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-56JXLOGZ.mjs +0 -167
- package/dist/lib/node-esm/app-graph-builder-56JXLOGZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SALMIZ2W.mjs +0 -21
- package/dist/lib/node-esm/chunk-SALMIZ2W.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-3ZB5W3T3.mjs +0 -25
- package/dist/lib/node-esm/operation-resolver-3ZB5W3T3.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-F67P7RC3.mjs +0 -338
- package/dist/lib/node-esm/react-surface-F67P7RC3.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/PluginDetail.d.ts +0 -9
- package/dist/types/src/components/PluginDetail.d.ts.map +0 -1
- package/dist/types/src/components/PluginDetail.stories.d.ts +0 -32
- package/dist/types/src/components/PluginDetail.stories.d.ts.map +0 -1
- package/dist/types/src/components/PluginItem.d.ts.map +0 -1
- package/dist/types/src/components/PluginList.d.ts.map +0 -1
- package/dist/types/src/components/PluginList.stories.d.ts +0 -34
- package/dist/types/src/components/PluginList.stories.d.ts.map +0 -1
- package/dist/types/src/components/RegistryContainer.d.ts +0 -8
- package/dist/types/src/components/RegistryContainer.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -136
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -23
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -99
- package/src/components/PluginDetail.tsx +0 -79
- package/src/components/PluginList.stories.tsx +0 -77
- package/src/components/RegistryContainer.tsx +0 -83
- /package/dist/types/src/components/{PluginItem.d.ts → PluginList/PluginItem.d.ts} +0 -0
- /package/dist/types/src/components/{PluginList.d.ts → PluginList/PluginList.d.ts} +0 -0
- /package/src/components/{PluginList.tsx → PluginList/PluginList.tsx} +0 -0
|
@@ -6,11 +6,11 @@ import React, { type MouseEvent, useCallback } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Plugin } from '@dxos/app-framework';
|
|
8
8
|
import { type ChromaticPalette, Icon, IconButton, Input, Link, ListItem, Tag, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
9
|
+
import { mx } from '@dxos/ui-theme';
|
|
10
10
|
import { getStyles } from '@dxos/ui-theme';
|
|
11
11
|
|
|
12
|
-
import { meta } from '
|
|
13
|
-
import { type RegistryTagType } from '
|
|
12
|
+
import { meta } from '#meta';
|
|
13
|
+
import { type RegistryTagType } from '#types';
|
|
14
14
|
|
|
15
15
|
export type PluginItemProps = {
|
|
16
16
|
plugin: Plugin.Plugin;
|
|
@@ -58,11 +58,15 @@ export const PluginItem = ({
|
|
|
58
58
|
labelId={labelId}
|
|
59
59
|
data-testid={`pluginList.${id}`}
|
|
60
60
|
aria-describedby={descriptionId}
|
|
61
|
-
classNames={mx(gridCols, '
|
|
61
|
+
classNames={mx(gridCols, 'h-[14rem] w-full gap-3 pe-2 bg-modal-surface rounded-md overflow-hidden')}
|
|
62
62
|
>
|
|
63
|
-
<div className={mx(gridRows, 'justify-center rounded-l-md', styles.
|
|
64
|
-
<
|
|
65
|
-
|
|
63
|
+
<div className={mx(gridRows, 'justify-center rounded-l-md', styles.surface)}>
|
|
64
|
+
<Icon
|
|
65
|
+
classNames={mx('row-start-2 cursor-pointer', styles.surfaceText)}
|
|
66
|
+
icon={icon}
|
|
67
|
+
size={14}
|
|
68
|
+
onClick={handleClick}
|
|
69
|
+
/>
|
|
66
70
|
</div>
|
|
67
71
|
|
|
68
72
|
<div className={mx(gridRows)}>
|
|
@@ -71,10 +75,10 @@ export const PluginItem = ({
|
|
|
71
75
|
</div>
|
|
72
76
|
|
|
73
77
|
<div>
|
|
74
|
-
<p className={mx(
|
|
78
|
+
<p className={mx('text-description', 'line-clamp-4 min-w-0')}>{description}</p>
|
|
75
79
|
</div>
|
|
76
80
|
|
|
77
|
-
<div className='flex -
|
|
81
|
+
<div className='flex -ms-0.5 overflow-x-auto scrollbar-none'>
|
|
78
82
|
{tags?.map((tag) => (
|
|
79
83
|
<Tag key={tag} palette={tagColors[tag as RegistryTagType]} classNames='text-xs uppercase font-thin'>
|
|
80
84
|
{tag}
|
|
@@ -87,7 +91,7 @@ export const PluginItem = ({
|
|
|
87
91
|
aria-describedby={descriptionId}
|
|
88
92
|
classNames='cursor-pointer'
|
|
89
93
|
icon='ph--gear--regular'
|
|
90
|
-
label={t('settings
|
|
94
|
+
label={t('settings.label')}
|
|
91
95
|
iconOnly
|
|
92
96
|
size={4}
|
|
93
97
|
onClick={handleSettings}
|
|
@@ -95,11 +99,11 @@ export const PluginItem = ({
|
|
|
95
99
|
/>
|
|
96
100
|
|
|
97
101
|
<Link aria-describedby={descriptionId} classNames='text-description cursor-pointer' onClick={handleClick}>
|
|
98
|
-
{t('details
|
|
102
|
+
{t('details.label')}
|
|
99
103
|
</Link>
|
|
100
104
|
|
|
101
105
|
<div className='grow' />
|
|
102
|
-
<div className='
|
|
106
|
+
<div className='pe-1'>
|
|
103
107
|
<Input.Root id={inputId}>
|
|
104
108
|
<Input.Switch classNames='self-center' checked={isEnabled} onClick={handleChange} />
|
|
105
109
|
</Input.Root>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type Plugin, Plugin as PluginNS } from '@dxos/app-framework';
|
|
9
|
+
import { random } from '@dxos/random';
|
|
10
|
+
import { ScrollArea } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { getHashHue } from '@dxos/ui-theme';
|
|
13
|
+
|
|
14
|
+
import { RegistryTagType } from '#types';
|
|
15
|
+
|
|
16
|
+
import { translations } from '../../translations';
|
|
17
|
+
import { PluginList } from './PluginList';
|
|
18
|
+
|
|
19
|
+
random.seed(1);
|
|
20
|
+
|
|
21
|
+
const icons = [
|
|
22
|
+
'ph--bug--regular',
|
|
23
|
+
'ph--compass--regular',
|
|
24
|
+
'ph--kanban--regular',
|
|
25
|
+
'ph--table--regular',
|
|
26
|
+
'ph--gear--regular',
|
|
27
|
+
'ph--github-logo--regular',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const DefaultStory = () => {
|
|
31
|
+
const [plugins] = useState<Plugin.Plugin[]>(
|
|
32
|
+
random.helpers.multiple(
|
|
33
|
+
() =>
|
|
34
|
+
PluginNS.define({
|
|
35
|
+
id: `org.dxos.plugin.plugin-${random.string.uuid()}`,
|
|
36
|
+
name: `${random.commerce.productName()}`,
|
|
37
|
+
description: random.lorem.sentences(Math.ceil(Math.random() * 3)),
|
|
38
|
+
tags: random.helpers.uniqueArray(RegistryTagType.literals as any, Math.floor(Math.random() * 3)),
|
|
39
|
+
icon: random.helpers.arrayElement(icons),
|
|
40
|
+
iconHue: getHashHue(random.string.uuid()),
|
|
41
|
+
homePage: random.datatype.boolean({ probability: 0.5 }) ? random.internet.url() : undefined,
|
|
42
|
+
source: random.internet.url(),
|
|
43
|
+
}).pipe(PluginNS.make)(),
|
|
44
|
+
{ count: 32 },
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
const [enabled, setEnabled] = useState<string[]>([]);
|
|
48
|
+
|
|
49
|
+
const handleChange = (id: string, enabled: boolean) => {
|
|
50
|
+
setEnabled((plugins) => (enabled ? [...plugins, id] : plugins.filter((plugin) => plugin === id)));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ScrollArea.Root orientation='vertical'>
|
|
55
|
+
<ScrollArea.Viewport>
|
|
56
|
+
<PluginList plugins={plugins} enabled={enabled} onChange={handleChange} hasSettings={() => true} />
|
|
57
|
+
</ScrollArea.Viewport>
|
|
58
|
+
</ScrollArea.Root>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const meta = {
|
|
63
|
+
title: 'plugins/plugin-registry/components/PluginList',
|
|
64
|
+
component: PluginList,
|
|
65
|
+
render: DefaultStory,
|
|
66
|
+
parameters: {
|
|
67
|
+
translations,
|
|
68
|
+
},
|
|
69
|
+
} satisfies Meta<typeof PluginList>;
|
|
70
|
+
|
|
71
|
+
export default meta;
|
|
72
|
+
|
|
73
|
+
type Story = StoryObj<typeof meta>;
|
|
74
|
+
|
|
75
|
+
export const Default: Story = {
|
|
76
|
+
decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'bg-deck-surface' })],
|
|
77
|
+
parameters: {
|
|
78
|
+
layout: 'fullscreen',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const FullScreen: Story = {
|
|
83
|
+
decorators: [withTheme(), withLayout({ scroll: true })],
|
|
84
|
+
parameters: {
|
|
85
|
+
layout: 'fullscreen',
|
|
86
|
+
},
|
|
87
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { usePluginManager } from '@dxos/app-framework/ui';
|
|
9
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
10
|
+
import { Button, Dialog, Input, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
|
+
|
|
14
|
+
export const LOAD_PLUGIN_DIALOG = `${meta.id}.LoadPluginDialog`;
|
|
15
|
+
|
|
16
|
+
export const LoadPluginDialog = () => {
|
|
17
|
+
const manager = usePluginManager();
|
|
18
|
+
const { t } = useTranslation(meta.id);
|
|
19
|
+
const [url, setUrl] = useState('');
|
|
20
|
+
const [loading, setLoading] = useState(false);
|
|
21
|
+
const [error, setError] = useState<string | null>(null);
|
|
22
|
+
const closeRef = useRef<HTMLButtonElement | null>(null);
|
|
23
|
+
|
|
24
|
+
const handleLoad = useCallback(() => {
|
|
25
|
+
if (!url.trim()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setLoading(true);
|
|
30
|
+
setError(null);
|
|
31
|
+
|
|
32
|
+
void Effect.gen(function* () {
|
|
33
|
+
yield* manager.add(url.trim());
|
|
34
|
+
closeRef.current?.click();
|
|
35
|
+
}).pipe(
|
|
36
|
+
Effect.catchAll((err) =>
|
|
37
|
+
Effect.sync(() => {
|
|
38
|
+
setError(String(err));
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
Effect.tap(() => Effect.sync(() => setLoading(false))),
|
|
42
|
+
runAndForwardErrors,
|
|
43
|
+
);
|
|
44
|
+
}, [url, manager]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Dialog.Content>
|
|
48
|
+
<Dialog.Header>
|
|
49
|
+
<Dialog.Title>{t('load-by-url-dialog.title')}</Dialog.Title>
|
|
50
|
+
<Dialog.Close asChild>
|
|
51
|
+
<Dialog.CloseIconButton ref={closeRef} />
|
|
52
|
+
</Dialog.Close>
|
|
53
|
+
</Dialog.Header>
|
|
54
|
+
<Dialog.Body>
|
|
55
|
+
{/* TODO(burdon): Form section. */}
|
|
56
|
+
<div className='flex flex-col gap-4'>
|
|
57
|
+
<Input.Root validationValence={error ? 'error' : undefined}>
|
|
58
|
+
<Input.Label>{t('plugin-url.label')}</Input.Label>
|
|
59
|
+
<Input.TextInput
|
|
60
|
+
placeholder='https://example.com/plugin.mjs'
|
|
61
|
+
value={url}
|
|
62
|
+
onChange={(event) => {
|
|
63
|
+
setUrl(event.target.value);
|
|
64
|
+
setError(null);
|
|
65
|
+
}}
|
|
66
|
+
onKeyDown={(event) => {
|
|
67
|
+
if (event.key === 'Enter') {
|
|
68
|
+
handleLoad();
|
|
69
|
+
}
|
|
70
|
+
}}
|
|
71
|
+
disabled={loading}
|
|
72
|
+
autoFocus
|
|
73
|
+
/>
|
|
74
|
+
{error && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}
|
|
75
|
+
</Input.Root>
|
|
76
|
+
<div className='flex justify-end'>
|
|
77
|
+
<Button variant='primary' disabled={!url.trim() || loading} onClick={handleLoad}>
|
|
78
|
+
{loading ? t('loading.label') : t('load-plugin.label')}
|
|
79
|
+
</Button>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</Dialog.Body>
|
|
83
|
+
</Dialog.Content>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { usePluginManager } from '@dxos/app-framework/ui';
|
|
9
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
10
|
+
|
|
11
|
+
import { PluginDetail } from '#components';
|
|
12
|
+
|
|
13
|
+
// TODO(burdon): Convert to ECHO type.
|
|
14
|
+
export type PluginArticleProps = { subject: Plugin.Plugin };
|
|
15
|
+
|
|
16
|
+
export const PluginArticle = ({ subject: plugin }: PluginArticleProps) => {
|
|
17
|
+
const manager = usePluginManager();
|
|
18
|
+
const enabled = manager.getEnabled().includes(plugin.meta.id);
|
|
19
|
+
const handleEnableChange = useCallback(
|
|
20
|
+
(enabled: boolean) =>
|
|
21
|
+
enabled
|
|
22
|
+
? runAndForwardErrors(manager.enable(plugin.meta.id))
|
|
23
|
+
: runAndForwardErrors(manager.disable(plugin.meta.id)),
|
|
24
|
+
[manager, plugin.meta.id],
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return <PluginDetail plugin={plugin} enabled={enabled} onEnabledChange={handleEnableChange} />;
|
|
28
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React, { useCallback, useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
10
|
+
import { useCapabilities, useOperationInvoker, usePluginManager } from '@dxos/app-framework/ui';
|
|
11
|
+
import { AppCapabilities, LayoutOperation, SettingsOperation } from '@dxos/app-toolkit';
|
|
12
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
13
|
+
import { ObservabilityOperation } from '@dxos/plugin-observability/operations';
|
|
14
|
+
import { ScrollArea } from '@dxos/react-ui';
|
|
15
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { PluginList } from '#components';
|
|
18
|
+
import { getPluginPath } from '#meta';
|
|
19
|
+
|
|
20
|
+
const sortByPluginMeta = ({ meta: { name: a = '' } }: Plugin.Plugin, { meta: { name: b = '' } }: Plugin.Plugin) =>
|
|
21
|
+
a.localeCompare(b);
|
|
22
|
+
|
|
23
|
+
export type PluginRegistryProps = {
|
|
24
|
+
id: string;
|
|
25
|
+
plugins: Plugin.Plugin[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const PluginRegistry = composable<HTMLDivElement, PluginRegistryProps>(
|
|
29
|
+
({ id, plugins: pluginsProp, ...props }, forwardedRef) => {
|
|
30
|
+
const manager = usePluginManager();
|
|
31
|
+
const { invoke, invokePromise } = useOperationInvoker();
|
|
32
|
+
const plugins = useMemo(() => pluginsProp.sort(sortByPluginMeta), [pluginsProp]);
|
|
33
|
+
const enabled = useAtomValue(manager.enabled);
|
|
34
|
+
const allSettings = useCapabilities(AppCapabilities.Settings);
|
|
35
|
+
|
|
36
|
+
// TODO(wittjosiah): Factor out to an intent?
|
|
37
|
+
const handleChange = useCallback(
|
|
38
|
+
(id: string, enabled: boolean) =>
|
|
39
|
+
Effect.gen(function* () {
|
|
40
|
+
if (enabled) {
|
|
41
|
+
yield* manager.enable(id);
|
|
42
|
+
} else {
|
|
43
|
+
yield* manager.disable(id);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
yield* invoke(ObservabilityOperation.SendEvent, {
|
|
47
|
+
name: 'plugins.toggle',
|
|
48
|
+
properties: {
|
|
49
|
+
plugin: id,
|
|
50
|
+
enabled,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}).pipe(runAndForwardErrors),
|
|
54
|
+
[invoke, manager],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleClick = useCallback(
|
|
58
|
+
(pluginId: string) =>
|
|
59
|
+
invokePromise(LayoutOperation.Open, {
|
|
60
|
+
subject: [getPluginPath(pluginId)],
|
|
61
|
+
pivotId: id,
|
|
62
|
+
positioning: 'end',
|
|
63
|
+
}),
|
|
64
|
+
[invokePromise, id],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const hasSettings = useCallback(
|
|
68
|
+
(pluginId: string) => allSettings.some((s) => s.prefix === pluginId),
|
|
69
|
+
[allSettings],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const handleSettings = useCallback(
|
|
73
|
+
(pluginId: string) => invokePromise(SettingsOperation.Open, { plugin: pluginId }),
|
|
74
|
+
[invokePromise],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<ScrollArea.Root {...composableProps(props)} orientation='vertical' ref={forwardedRef}>
|
|
79
|
+
<ScrollArea.Viewport>
|
|
80
|
+
<PluginList
|
|
81
|
+
plugins={plugins}
|
|
82
|
+
enabled={enabled}
|
|
83
|
+
onClick={handleClick}
|
|
84
|
+
onChange={handleChange}
|
|
85
|
+
hasSettings={hasSettings}
|
|
86
|
+
onSettings={handleSettings}
|
|
87
|
+
/>
|
|
88
|
+
</ScrollArea.Viewport>
|
|
89
|
+
</ScrollArea.Root>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
PluginRegistry.displayName = 'PluginRegistry';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export { LOAD_PLUGIN_DIALOG } from './LoadPluginDialog/LoadPluginDialog';
|
|
8
|
+
export const LoadPluginDialog: ComponentType<any> = lazy(() => import('./LoadPluginDialog'));
|
|
9
|
+
export const PluginArticle: ComponentType<any> = lazy(() => import('./PluginArticle'));
|
|
10
|
+
export const PluginRegistry: ComponentType<any> = lazy(() => import('./PluginRegistry'));
|
package/src/meta.ts
CHANGED
|
@@ -3,16 +3,23 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { pinnedWorkspaceId } from '@dxos/app-toolkit';
|
|
6
7
|
import { trim } from '@dxos/util';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
// TODO(wittjosiah): This is a hack to prevent the previous deck from being set for pinned items.
|
|
10
|
-
// Ideally this should be worked into the data model in a generic way.
|
|
11
|
-
export const REGISTRY_ID = '!dxos:plugin-registry';
|
|
9
|
+
export const REGISTRY_ID = pinnedWorkspaceId('dxos:plugin-registry');
|
|
12
10
|
export const REGISTRY_KEY = 'plugin-registry';
|
|
13
11
|
|
|
12
|
+
// TODO(wittjosiah): Should this be a special separator or use the standard path separator?
|
|
13
|
+
const CATEGORY_SEPARATOR = '>';
|
|
14
|
+
|
|
15
|
+
/** Build a registry category node ID. */
|
|
16
|
+
export const registryCategoryId = (category: string): string => `${REGISTRY_KEY}${CATEGORY_SEPARATOR}${category}`;
|
|
17
|
+
|
|
18
|
+
/** Qualified graph path to a specific plugin node. */
|
|
19
|
+
export const getPluginPath = (pluginId: string): string => `root/${REGISTRY_ID}/${pluginId}`;
|
|
20
|
+
|
|
14
21
|
export const meta: Plugin.Meta = {
|
|
15
|
-
id: 'dxos.
|
|
22
|
+
id: 'org.dxos.plugin.registry',
|
|
16
23
|
name: 'Plugins',
|
|
17
24
|
description: trim`
|
|
18
25
|
Plugin management system for discovering, installing, and configuring workspace extensions.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { LayoutOperation, SettingsOperation, getSpacePath } from '@dxos/app-toolkit';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { REGISTRY_ID } from '#meta';
|
|
11
|
+
|
|
12
|
+
const handler: Operation.WithHandler<typeof SettingsOperation.OpenPluginRegistry> =
|
|
13
|
+
SettingsOperation.OpenPluginRegistry.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fnUntraced(function* () {
|
|
16
|
+
yield* Operation.invoke(LayoutOperation.SwitchWorkspace, { subject: getSpacePath(REGISTRY_ID) });
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default handler;
|
package/src/translations.ts
CHANGED
|
@@ -4,26 +4,30 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[meta.id]: {
|
|
13
|
-
'plugin
|
|
14
|
-
'details
|
|
15
|
-
'home
|
|
16
|
-
'source
|
|
17
|
-
'plugin
|
|
18
|
-
'all
|
|
19
|
-
'installed
|
|
20
|
-
'recommended
|
|
21
|
-
'labs
|
|
22
|
-
'community
|
|
23
|
-
'load
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
13
|
+
'plugin.name': 'Registry',
|
|
14
|
+
'details.label': 'Details',
|
|
15
|
+
'home-page.label': 'Website',
|
|
16
|
+
'source.label': 'Source',
|
|
17
|
+
'plugin-registry.label': 'Plugin Registry',
|
|
18
|
+
'all-plugins.label': 'All',
|
|
19
|
+
'installed-plugins.label': 'Enabled',
|
|
20
|
+
'recommended-plugins.label': 'Recommended',
|
|
21
|
+
'labs-plugins.label': 'Labs',
|
|
22
|
+
'community-plugins.label': 'Community',
|
|
23
|
+
'load-by-url.label': 'Load from URL',
|
|
24
|
+
'load-by-url-dialog.title': 'Load Plugin from URL',
|
|
25
|
+
'plugin-url.label': 'Plugin URL',
|
|
26
|
+
'load-plugin.label': 'Load Plugin',
|
|
27
|
+
'loading.label': 'Loading...',
|
|
28
|
+
'coming-soon.label': 'Coming soon!',
|
|
29
|
+
'open-plugin-registry.label': 'Open plugin registry',
|
|
30
|
+
'settings.label': 'Settings',
|
|
27
31
|
},
|
|
28
32
|
},
|
|
29
33
|
},
|