@dxos/plugin-registry 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5
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 +219 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +52 -52
- 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 +221 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +53 -52
- 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 +2 -1
- package/dist/types/src/RegistryPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/commands/disable.d.ts +11 -0
- package/dist/types/src/cli/commands/disable.d.ts.map +1 -0
- package/dist/types/src/cli/commands/enable.d.ts +11 -0
- package/dist/types/src/cli/commands/enable.d.ts.map +1 -0
- package/dist/types/src/cli/commands/index.d.ts +3 -0
- package/dist/types/src/cli/commands/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/list.d.ts +7 -0
- package/dist/types/src/cli/commands/list.d.ts.map +1 -0
- package/dist/types/src/cli/commands/util.d.ts +11 -0
- package/dist/types/src/cli/commands/util.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +3 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/cli/storage.d.ts +18 -0
- package/dist/types/src/cli/storage.d.ts.map +1 -0
- 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 +18 -0
- package/dist/types/src/components/PluginList/PluginItem.d.ts.map +1 -0
- package/dist/types/src/components/PluginList/PluginList.d.ts +13 -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/CommunityRegistry/CommunityRegistry.d.ts +8 -0
- package/dist/types/src/containers/CommunityRegistry/CommunityRegistry.d.ts.map +1 -0
- package/dist/types/src/containers/CommunityRegistry/index.d.ts +2 -0
- package/dist/types/src/containers/CommunityRegistry/index.d.ts.map +1 -0
- 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 +14 -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 +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +3 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/use-auto-tags.d.ts +20 -0
- package/dist/types/src/hooks/use-auto-tags.d.ts.map +1 -0
- package/dist/types/src/hooks/use-community-plugins.d.ts +15 -0
- package/dist/types/src/hooks/use-community-plugins.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +7 -4
- 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/src/types.d.ts +3 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -35
- package/src/RegistryPlugin.tsx +12 -26
- package/src/capabilities/app-graph-builder.ts +138 -136
- package/src/capabilities/index.ts +8 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +108 -78
- package/src/cli/commands/disable.ts +47 -0
- package/src/cli/commands/enable.ts +44 -0
- package/src/cli/commands/index.ts +14 -0
- package/src/cli/commands/list.ts +41 -0
- package/src/cli/commands/util.ts +24 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/plugin.ts +17 -0
- package/src/cli/storage.ts +50 -0
- package/src/components/PluginDetail/PluginDetail.stories.tsx +43 -0
- package/src/components/PluginDetail/PluginDetail.tsx +84 -0
- package/src/components/PluginDetail/index.ts +5 -0
- package/src/components/PluginList/PluginItem.tsx +152 -0
- package/src/components/PluginList/PluginList.stories.tsx +87 -0
- package/src/components/PluginList/PluginList.tsx +29 -0
- package/src/components/PluginList/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/containers/CommunityRegistry/CommunityRegistry.tsx +147 -0
- package/src/containers/CommunityRegistry/index.ts +5 -0
- 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 +98 -0
- package/src/containers/PluginRegistry/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-auto-tags.ts +52 -0
- package/src/hooks/use-community-plugins.ts +77 -0
- package/src/meta.ts +19 -9
- package/src/operations/index.ts +7 -0
- package/src/operations/open-plugin-registry.ts +21 -0
- package/src/translations.ts +19 -15
- package/src/types.ts +14 -1
- package/dist/lib/browser/app-graph-builder-LKQBQDUA.mjs +0 -161
- package/dist/lib/browser/app-graph-builder-LKQBQDUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-AEBASNOI.mjs +0 -16
- package/dist/lib/browser/chunk-AEBASNOI.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-W67CIJI3.mjs +0 -23
- package/dist/lib/browser/intent-resolver-W67CIJI3.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SRFVJQKE.mjs +0 -335
- package/dist/lib/browser/react-surface-SRFVJQKE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-N44OGVQA.mjs +0 -162
- package/dist/lib/node-esm/app-graph-builder-N44OGVQA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-R3GXMWPJ.mjs +0 -18
- package/dist/lib/node-esm/chunk-R3GXMWPJ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-M2CBVUVQ.mjs +0 -24
- package/dist/lib/node-esm/intent-resolver-M2CBVUVQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-5XAG2EYX.mjs +0 -336
- package/dist/lib/node-esm/react-surface-5XAG2EYX.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Icon.stories.d.ts +0 -6
- package/dist/types/src/components/Icon.stories.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 -8
- package/dist/types/src/components/PluginDetail.stories.d.ts.map +0 -1
- package/dist/types/src/components/PluginItem.d.ts +0 -13
- package/dist/types/src/components/PluginItem.d.ts.map +0 -1
- package/dist/types/src/components/PluginList.d.ts +0 -8
- package/dist/types/src/components/PluginList.d.ts.map +0 -1
- package/dist/types/src/components/PluginList.stories.d.ts +0 -11
- package/dist/types/src/components/PluginList.stories.d.ts.map +0 -1
- package/dist/types/src/components/RegistryContainer.d.ts +0 -7
- package/dist/types/src/components/RegistryContainer.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -27
- package/src/components/Icon.stories.tsx +0 -107
- package/src/components/PluginDetail.stories.tsx +0 -45
- package/src/components/PluginDetail.tsx +0 -63
- package/src/components/PluginItem.tsx +0 -119
- package/src/components/PluginList.stories.tsx +0 -82
- package/src/components/PluginList.tsx +0 -26
- package/src/components/RegistryContainer.tsx +0 -84
|
@@ -2,89 +2,119 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
8
|
+
import { Capabilities, Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { Surface, usePluginManager } from '@dxos/app-framework/ui';
|
|
10
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
11
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { CommunityRegistry, LOAD_PLUGIN_DIALOG, LoadPluginDialog, PluginArticle, PluginRegistry } from '#containers';
|
|
13
|
+
import { registryCategoryId } from '#meta';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
contributes(Capabilities.ReactSurface, [
|
|
15
|
-
createSurface({
|
|
16
|
-
id: `${REGISTRY_PLUGIN}/all`,
|
|
17
|
-
role: 'article',
|
|
18
|
-
filter: (data): data is any => data.subject === `${REGISTRY_KEY}+all`,
|
|
19
|
-
component: () => {
|
|
20
|
-
const manager = usePluginManager();
|
|
21
|
-
const filtered = useMemo(() => manager.plugins.filter(({ meta }) => !manager.core.includes(meta.id)), []);
|
|
15
|
+
import { useAutoTags, useCommunityPlugins, useRemotePluginIds } from '../hooks';
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
export default Capability.makeModule(() =>
|
|
18
|
+
Effect.succeed(
|
|
19
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: 'official',
|
|
22
|
+
filter: AppSurface.literal(AppSurface.Article, registryCategoryId('official')),
|
|
23
|
+
component: () => {
|
|
24
|
+
const manager = usePluginManager();
|
|
25
|
+
const remoteIds = useRemotePluginIds();
|
|
26
|
+
const { entries } = useCommunityPlugins();
|
|
27
|
+
const extraTagsById = useAutoTags(entries);
|
|
28
|
+
const filtered = useMemo(
|
|
29
|
+
() =>
|
|
30
|
+
manager
|
|
31
|
+
.getPlugins()
|
|
32
|
+
.filter(({ meta }) => !manager.getCore().includes(meta.id))
|
|
33
|
+
.filter(({ meta }) => !remoteIds.has(meta.id)),
|
|
34
|
+
[manager, remoteIds],
|
|
35
|
+
);
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
()
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
37
|
+
return (
|
|
38
|
+
<PluginRegistry id={registryCategoryId('official')} plugins={filtered} extraTagsById={extraTagsById} />
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
Surface.create({
|
|
43
|
+
id: 'installed',
|
|
44
|
+
filter: AppSurface.literal(AppSurface.Article, registryCategoryId('installed')),
|
|
45
|
+
component: () => {
|
|
46
|
+
const manager = usePluginManager();
|
|
47
|
+
const { entries } = useCommunityPlugins();
|
|
48
|
+
const extraTagsById = useAutoTags(entries);
|
|
49
|
+
const filtered = useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
manager
|
|
52
|
+
.getPlugins()
|
|
53
|
+
.filter(({ meta }) => !manager.getCore().includes(meta.id))
|
|
54
|
+
.filter(({ meta }) => manager.getEnabled().includes(meta.id)),
|
|
55
|
+
[manager],
|
|
56
|
+
);
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
return (
|
|
59
|
+
<PluginRegistry id={registryCategoryId('installed')} plugins={filtered} extraTagsById={extraTagsById} />
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
Surface.create({
|
|
64
|
+
id: 'recommended',
|
|
65
|
+
filter: AppSurface.literal(AppSurface.Article, registryCategoryId('recommended')),
|
|
66
|
+
component: () => {
|
|
67
|
+
const manager = usePluginManager();
|
|
68
|
+
const remoteIds = useRemotePluginIds();
|
|
69
|
+
const { entries } = useCommunityPlugins();
|
|
70
|
+
const extraTagsById = useAutoTags(entries);
|
|
71
|
+
const filtered = useMemo(
|
|
72
|
+
() =>
|
|
73
|
+
manager
|
|
74
|
+
.getPlugins()
|
|
75
|
+
.filter(({ meta }) => !manager.getCore().includes(meta.id))
|
|
76
|
+
.filter(({ meta }) => !remoteIds.has(meta.id))
|
|
77
|
+
.filter(({ meta }) => !meta.tags?.includes('labs')),
|
|
78
|
+
[manager, remoteIds],
|
|
79
|
+
);
|
|
67
80
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
return (
|
|
82
|
+
<PluginRegistry id={registryCategoryId('recommended')} plugins={filtered} extraTagsById={extraTagsById} />
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
Surface.create({
|
|
87
|
+
id: 'labs',
|
|
88
|
+
filter: AppSurface.literal(AppSurface.Article, registryCategoryId('labs')),
|
|
89
|
+
component: () => {
|
|
90
|
+
const manager = usePluginManager();
|
|
91
|
+
const { entries } = useCommunityPlugins();
|
|
92
|
+
const extraTagsById = useAutoTags(entries);
|
|
93
|
+
const filtered = useMemo(
|
|
94
|
+
() => manager.getPlugins().filter(({ meta }) => meta.tags?.includes('labs')),
|
|
95
|
+
[manager],
|
|
96
|
+
);
|
|
82
97
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
return <PluginRegistry id={registryCategoryId('labs')} plugins={filtered} extraTagsById={extraTagsById} />;
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
Surface.create({
|
|
102
|
+
id: 'community',
|
|
103
|
+
filter: AppSurface.literal(AppSurface.Article, registryCategoryId('community')),
|
|
104
|
+
component: () => <CommunityRegistry id={registryCategoryId('community')} />,
|
|
105
|
+
}),
|
|
106
|
+
Surface.create({
|
|
107
|
+
id: 'plugin-details',
|
|
108
|
+
filter: AppSurface.subject(AppSurface.Article, Plugin.isPlugin),
|
|
109
|
+
component: ({ data: { subject } }) => {
|
|
110
|
+
return <PluginArticle subject={subject} />;
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
Surface.create({
|
|
114
|
+
id: LOAD_PLUGIN_DIALOG,
|
|
115
|
+
filter: AppSurface.component(AppSurface.Dialog, LOAD_PLUGIN_DIALOG),
|
|
116
|
+
component: () => <LoadPluginDialog />,
|
|
117
|
+
}),
|
|
118
|
+
]),
|
|
119
|
+
),
|
|
120
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Args from '@effect/cli/Args';
|
|
6
|
+
import * as Command from '@effect/cli/Command';
|
|
7
|
+
import * as Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
|
|
10
|
+
import { Plugin } from '@dxos/app-framework';
|
|
11
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
|
|
14
|
+
import { saveEnabledPlugins } from '../storage';
|
|
15
|
+
|
|
16
|
+
export const handler = Effect.fn(function* ({ id }: { id: string }) {
|
|
17
|
+
const { json, profile } = yield* CommandConfig;
|
|
18
|
+
const manager = yield* Plugin.Service;
|
|
19
|
+
|
|
20
|
+
const plugins = manager.getPlugins();
|
|
21
|
+
const plugin = plugins.find((p: Plugin.Plugin) => p.meta.id === id);
|
|
22
|
+
invariant(plugin, `Plugin not found: ${id}`);
|
|
23
|
+
|
|
24
|
+
const core = manager.getCore();
|
|
25
|
+
invariant(!core.includes(id), `Cannot disable core plugin: ${id}`);
|
|
26
|
+
|
|
27
|
+
const disabled = yield* manager.disable(id);
|
|
28
|
+
invariant(disabled, `Failed to disable plugin: ${id}`);
|
|
29
|
+
|
|
30
|
+
// Save enabled plugins to storage
|
|
31
|
+
const enabledPlugins = manager.getEnabled();
|
|
32
|
+
yield* saveEnabledPlugins({ profile, enabled: [...enabledPlugins] });
|
|
33
|
+
|
|
34
|
+
if (json) {
|
|
35
|
+
yield* Console.log(JSON.stringify({ id, enabled: false }, null, 2));
|
|
36
|
+
} else {
|
|
37
|
+
yield* Console.log(`Plugin "${plugin.meta.name ?? id}" disabled.`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const disable = Command.make(
|
|
42
|
+
'disable',
|
|
43
|
+
{
|
|
44
|
+
id: Args.text({ name: 'id' }).pipe(Args.withDescription('The ID of the plugin to disable.')),
|
|
45
|
+
},
|
|
46
|
+
handler,
|
|
47
|
+
).pipe(Command.withDescription('Disable a plugin.'));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Args from '@effect/cli/Args';
|
|
6
|
+
import * as Command from '@effect/cli/Command';
|
|
7
|
+
import * as Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
|
|
10
|
+
import { Plugin } from '@dxos/app-framework';
|
|
11
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
|
|
14
|
+
import { saveEnabledPlugins } from '../storage';
|
|
15
|
+
|
|
16
|
+
export const handler = Effect.fn(function* ({ id }: { id: string }) {
|
|
17
|
+
const { json, profile } = yield* CommandConfig;
|
|
18
|
+
const manager = yield* Plugin.Service;
|
|
19
|
+
|
|
20
|
+
const plugins = manager.getPlugins();
|
|
21
|
+
const plugin = plugins.find((p: Plugin.Plugin) => p.meta.id === id);
|
|
22
|
+
invariant(plugin, `Plugin not found: ${id}`);
|
|
23
|
+
|
|
24
|
+
const enabled = yield* manager.enable(id);
|
|
25
|
+
invariant(enabled, `Failed to enable plugin: ${id}`);
|
|
26
|
+
|
|
27
|
+
// Save enabled plugins to storage
|
|
28
|
+
const enabledPlugins = manager.getEnabled();
|
|
29
|
+
yield* saveEnabledPlugins({ profile, enabled: [...enabledPlugins] });
|
|
30
|
+
|
|
31
|
+
if (json) {
|
|
32
|
+
yield* Console.log(JSON.stringify({ id, enabled: true }, null, 2));
|
|
33
|
+
} else {
|
|
34
|
+
yield* Console.log(`Plugin "${plugin.meta.name ?? id}" enabled.`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const enable = Command.make(
|
|
39
|
+
'enable',
|
|
40
|
+
{
|
|
41
|
+
id: Args.text({ name: 'id' }).pipe(Args.withDescription('The ID of the plugin to enable.')),
|
|
42
|
+
},
|
|
43
|
+
handler,
|
|
44
|
+
).pipe(Command.withDescription('Enable a plugin.'));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { disable } from './disable';
|
|
8
|
+
import { enable } from './enable';
|
|
9
|
+
import { list } from './list';
|
|
10
|
+
|
|
11
|
+
export const plugin: Command.Command<any, any, any, any> = Command.make('plugin').pipe(
|
|
12
|
+
Command.withDescription('Manage plugins.'),
|
|
13
|
+
Command.withSubcommands([enable, disable, list]),
|
|
14
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Console from 'effect/Console';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
|
|
9
|
+
import { Plugin } from '@dxos/app-framework';
|
|
10
|
+
import { CommandConfig, printList } from '@dxos/cli-util';
|
|
11
|
+
|
|
12
|
+
import { type FormattedPlugin, printPlugin } from './util';
|
|
13
|
+
|
|
14
|
+
export const handler = Effect.fn(function* () {
|
|
15
|
+
const { json } = yield* CommandConfig;
|
|
16
|
+
const manager = yield* Plugin.Service;
|
|
17
|
+
|
|
18
|
+
const plugins = manager.getPlugins();
|
|
19
|
+
const enabled = manager.getEnabled();
|
|
20
|
+
const core = manager.getCore();
|
|
21
|
+
|
|
22
|
+
const formattedPlugins: FormattedPlugin[] = plugins.map((plugin: Plugin.Plugin) => {
|
|
23
|
+
const isEnabled = enabled.includes(plugin.meta.id);
|
|
24
|
+
const isCore = core.includes(plugin.meta.id);
|
|
25
|
+
return {
|
|
26
|
+
id: plugin.meta.id,
|
|
27
|
+
name: plugin.meta.name ?? plugin.meta.id,
|
|
28
|
+
enabled: isEnabled,
|
|
29
|
+
core: isCore,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (json) {
|
|
34
|
+
yield* Console.log(JSON.stringify(formattedPlugins, null, 2));
|
|
35
|
+
} else {
|
|
36
|
+
const formatted = formattedPlugins.map(printPlugin);
|
|
37
|
+
yield* Console.log(printList(formatted));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const list = Command.make('list', {}, handler).pipe(Command.withDescription('List all available plugins.'));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { FormBuilder } from '@dxos/cli-util';
|
|
6
|
+
|
|
7
|
+
export type FormattedPlugin = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
core: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Pretty prints a plugin with ANSI colors.
|
|
16
|
+
*/
|
|
17
|
+
export const printPlugin = (plugin: FormattedPlugin) => {
|
|
18
|
+
const status = plugin.core ? 'core' : plugin.enabled ? 'enabled' : 'disabled';
|
|
19
|
+
return FormBuilder.make({ title: plugin.name }).pipe(
|
|
20
|
+
FormBuilder.set('id', plugin.id),
|
|
21
|
+
FormBuilder.set('status', status),
|
|
22
|
+
FormBuilder.build,
|
|
23
|
+
);
|
|
24
|
+
};
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { meta } from '#meta';
|
|
9
|
+
|
|
10
|
+
import { plugin } from './commands';
|
|
11
|
+
|
|
12
|
+
export const RegistryPlugin = Plugin.define(meta).pipe(
|
|
13
|
+
AppPlugin.addCommandModule({
|
|
14
|
+
commands: [plugin],
|
|
15
|
+
}),
|
|
16
|
+
Plugin.make,
|
|
17
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as FileSystem from '@effect/platform/FileSystem';
|
|
6
|
+
import * as Path from '@effect/platform/Path';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
|
+
import * as Yaml from 'yaml';
|
|
10
|
+
|
|
11
|
+
import { DX_CONFIG } from '@dxos/client-protocol';
|
|
12
|
+
|
|
13
|
+
// TODO(wittjosiah): Factor out to app-framework?
|
|
14
|
+
|
|
15
|
+
const PluginsSchema = Schema.Array(Schema.String);
|
|
16
|
+
|
|
17
|
+
/** CLI-only: path to plugins/<profile>.yml (sibling to profile/). */
|
|
18
|
+
const getPluginsConfigPath = (profile: string) => `${DX_CONFIG}/plugins/${profile}.yml`;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Load enabled plugins from plugins/<profile>.yml (sibling to profile/).
|
|
22
|
+
* Returns the list of enabled plugin IDs, or an empty array if the file doesn't exist.
|
|
23
|
+
*/
|
|
24
|
+
export const loadEnabledPlugins = Effect.fn(function* ({ profile }: { profile: string }) {
|
|
25
|
+
const fs = yield* FileSystem.FileSystem;
|
|
26
|
+
const pluginsPath = getPluginsConfigPath(profile);
|
|
27
|
+
|
|
28
|
+
const content = yield* fs
|
|
29
|
+
.readFileString(pluginsPath)
|
|
30
|
+
.pipe(Effect.catchTag('SystemError', () => Effect.succeed('[]')));
|
|
31
|
+
|
|
32
|
+
const raw = Yaml.parse(content);
|
|
33
|
+
const parsed = yield* Schema.decodeUnknown(PluginsSchema)(raw ?? []).pipe(
|
|
34
|
+
Effect.catchAll(() => Effect.succeed([] as string[])),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return parsed;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Save enabled plugins to plugins/<profile>.yml.
|
|
42
|
+
*/
|
|
43
|
+
export const saveEnabledPlugins = Effect.fn(function* ({ profile, enabled }: { profile: string; enabled: string[] }) {
|
|
44
|
+
const fs = yield* FileSystem.FileSystem;
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
const pluginsPath = getPluginsConfigPath(profile);
|
|
47
|
+
yield* fs.makeDirectory(path.dirname(pluginsPath), { recursive: true });
|
|
48
|
+
const encoded = Yaml.stringify(enabled);
|
|
49
|
+
yield* fs.writeFileString(pluginsPath, encoded);
|
|
50
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
|
|
7
|
+
import { Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { random } from '@dxos/random';
|
|
9
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
10
|
+
|
|
11
|
+
import { translations } from '../../translations';
|
|
12
|
+
import { PluginDetail } from './PluginDetail';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'plugins/plugin-registry/components/PluginDetail',
|
|
16
|
+
component: PluginDetail,
|
|
17
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'fullscreen',
|
|
20
|
+
translations,
|
|
21
|
+
},
|
|
22
|
+
} satisfies Meta<typeof PluginDetail>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
|
|
28
|
+
export const Default: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
plugin: Plugin.define({
|
|
31
|
+
id: 'example.com/plugin/test-plugin',
|
|
32
|
+
name: 'Test Plugin',
|
|
33
|
+
description: random.lorem.paragraphs(2),
|
|
34
|
+
icon: 'ph--bug--regular',
|
|
35
|
+
iconHue: 'sky',
|
|
36
|
+
homePage: 'https://example.com',
|
|
37
|
+
source: 'https://github.com/example/test-plugin',
|
|
38
|
+
screenshots: [
|
|
39
|
+
'https://media.gcflearnfree.org/content/55e073de7dd48174331f51b3_01_17_2014/getting_started_interactive2.png',
|
|
40
|
+
],
|
|
41
|
+
}).pipe(Plugin.make)(),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { Icon, Input, Link, ScrollArea, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { composable, composableProps, getStyles, mx } from '@dxos/ui-theme';
|
|
10
|
+
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
|
|
13
|
+
export type PluginDetailProps = {
|
|
14
|
+
plugin: Plugin.Plugin;
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
onEnabledChange?: (enabled: boolean) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const PluginDetail = composable<HTMLDivElement, PluginDetailProps>(
|
|
20
|
+
({ plugin, enabled, onEnabledChange, ...props }, forwardedRef) => {
|
|
21
|
+
const { t } = useTranslation(meta.id);
|
|
22
|
+
const {
|
|
23
|
+
id,
|
|
24
|
+
name,
|
|
25
|
+
description,
|
|
26
|
+
homePage,
|
|
27
|
+
source,
|
|
28
|
+
screenshots,
|
|
29
|
+
icon = 'ph--circle--regular',
|
|
30
|
+
iconHue = 'neutral',
|
|
31
|
+
} = plugin.meta;
|
|
32
|
+
const styles = getStyles(iconHue);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ScrollArea.Root {...composableProps(props)} orientation='vertical' ref={forwardedRef}>
|
|
36
|
+
<ScrollArea.Viewport>
|
|
37
|
+
<div role='none' className='dx-document grid grid-cols-[min-content_1fr] gap-4 p-4'>
|
|
38
|
+
<div role='none'>
|
|
39
|
+
<Icon classNames={mx('p-1 rounded-md', styles.fill, styles.surfaceText)} icon={icon} size={14} />
|
|
40
|
+
</div>
|
|
41
|
+
<div role='none' className='flex flex-col gap-6'>
|
|
42
|
+
<div role='none' className='grid grid-cols-[1fr_min-content] gap-x-3 w-full pt-1'>
|
|
43
|
+
<h2 className='text-xl'>{name}</h2>
|
|
44
|
+
<Input.Root>
|
|
45
|
+
<Input.Switch classNames='self-center' checked={enabled} onCheckedChange={onEnabledChange} />
|
|
46
|
+
</Input.Root>
|
|
47
|
+
<p className='pt-0.5 text-sm text-description'>{id}</p>
|
|
48
|
+
</div>
|
|
49
|
+
<div role='none'>
|
|
50
|
+
<p className='text-description'>{description}</p>
|
|
51
|
+
</div>
|
|
52
|
+
{screenshots && screenshots.length > 0 && (
|
|
53
|
+
<div role='none' className='flex flex-col gap-2'>
|
|
54
|
+
<h2>Preview</h2>
|
|
55
|
+
<img src={screenshots[0]} alt={name} className='aspect-video object-fit' />
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
<div role='none' className='flex flex-col gap-2'>
|
|
59
|
+
<h2>Resources</h2>
|
|
60
|
+
<div className='flex gap-2'>
|
|
61
|
+
{homePage && (
|
|
62
|
+
<Link href={homePage} target='_blank' rel='noreferrer' classNames='text-sm text-description'>
|
|
63
|
+
{t('home-page.label')}
|
|
64
|
+
<Icon icon='ph--arrow-square-out--bold' size={3} classNames='inline-block leading-none mx-1' />
|
|
65
|
+
</Link>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
{source && (
|
|
69
|
+
<Link href={source} target='_blank' rel='noreferrer' classNames='text-sm text-description'>
|
|
70
|
+
{t('source.label')}
|
|
71
|
+
<Icon icon='ph--arrow-square-out--bold' size={3} classNames='inline-block leading-none mx-1' />
|
|
72
|
+
</Link>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</ScrollArea.Viewport>
|
|
79
|
+
</ScrollArea.Root>
|
|
80
|
+
);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
PluginDetail.displayName = 'PluginDetail';
|