@dxos/plugin-debug 0.8.4-main.ae835ea → 0.8.4-main.bcb3aa67d6
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 +101 -100
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/DebugPlugin.d.ts +7 -1
- package/dist/types/src/DebugPlugin.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 +12 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +4 -2
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +7 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +8 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts +11 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts +79 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/index.d.ts +3 -0
- package/dist/types/src/components/DebugSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
- package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -10
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +2 -2
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
- package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +15 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
- package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +9 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +60 -58
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +6 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +67 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -70
- package/src/DebugPlugin.tsx +31 -33
- package/src/capabilities/app-graph-builder.ts +363 -388
- package/src/capabilities/index.ts +5 -5
- package/src/capabilities/react-context.tsx +16 -7
- package/src/capabilities/react-surface.tsx +360 -337
- package/src/capabilities/settings.ts +24 -12
- package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
- package/src/components/DebugSettings/DebugSettings.tsx +228 -0
- package/src/components/DebugSettings/index.ts +7 -0
- package/src/components/SchemaTable/index.ts +5 -0
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +21 -23
- package/src/components/SpaceGenerator/index.ts +2 -3
- package/src/components/SpaceGenerator/presets.ts +243 -121
- package/src/components/index.ts +4 -8
- package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
- package/src/containers/DebugGraph/index.ts +7 -0
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +47 -0
- package/src/containers/DebugObjectPanel/index.ts +7 -0
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +55 -0
- package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
- package/src/{components → containers/DebugStatus}/DebugStatus.tsx +41 -17
- package/src/containers/DebugStatus/index.ts +7 -0
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
- package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +130 -0
- package/src/containers/SpaceGenerator/index.ts +7 -0
- package/src/{components → containers/Wireframe}/Wireframe.tsx +6 -7
- package/src/containers/Wireframe/index.ts +7 -0
- package/src/containers/index.ts +13 -0
- package/src/meta.ts +3 -3
- package/src/translations.ts +66 -58
- package/src/types/Settings.ts +15 -0
- package/src/{types.ts → types/index.ts} +12 -10
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-7Q7CX64P.mjs +0 -1159
- package/dist/lib/browser/SpaceGenerator-7Q7CX64P.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs +0 -588
- package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs.map +0 -7
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs +0 -68
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs +0 -20
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +0 -7
- package/dist/lib/browser/react-context-P2YDWEWI.mjs +0 -16
- package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4XGZUT3Z.mjs +0 -772
- package/dist/lib/browser/react-surface-4XGZUT3Z.mjs.map +0 -7
- package/dist/lib/browser/settings-SQXR3OAH.mjs +0 -22
- package/dist/lib/browser/settings-SQXR3OAH.mjs.map +0 -7
- package/dist/types/src/components/Container.d.ts +0 -5
- package/dist/types/src/components/Container.d.ts.map +0 -1
- package/dist/types/src/components/DebugGraph.d.ts +0 -8
- package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugSettings.d.ts +0 -6
- package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
- package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
- package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
- package/dist/types/src/components/Wireframe.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -63
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/Container.tsx +0 -15
- package/src/components/DebugGraph.tsx +0 -14
- package/src/components/DebugObjectPanel.tsx +0 -33
- package/src/components/DebugSettings.tsx +0 -159
- package/src/components/DevtoolsOverviewContainer.tsx +0 -20
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
- /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
- /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
- /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
|
@@ -2,18 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { live } from '@dxos/live-object';
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
9
|
+
import { createKvsStore } from '@dxos/effect';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
import { DebugCapabilities, Settings } from '#types';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
export default Capability.makeModule(() =>
|
|
15
|
+
Effect.sync(() => {
|
|
16
|
+
const settingsAtom = createKvsStore({
|
|
17
|
+
key: meta.id,
|
|
18
|
+
schema: Settings.Settings,
|
|
19
|
+
defaultValue: () => ({}),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return [
|
|
23
|
+
Capability.contributes(DebugCapabilities.Settings, settingsAtom),
|
|
24
|
+
Capability.contributes(AppCapabilities.Settings, {
|
|
25
|
+
prefix: meta.id,
|
|
26
|
+
schema: Settings.Settings,
|
|
27
|
+
atom: settingsAtom,
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
|
|
7
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
8
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
9
|
+
|
|
10
|
+
import { translations } from '../../translations';
|
|
11
|
+
|
|
12
|
+
import { DebugSettings } from './DebugSettings';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'plugins/plugin-debug/components/DebugSettings',
|
|
16
|
+
component: DebugSettings,
|
|
17
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withClientProvider({ createIdentity: true })],
|
|
18
|
+
tags: ['settings'],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: 'fullscreen',
|
|
21
|
+
translations,
|
|
22
|
+
},
|
|
23
|
+
} satisfies Meta<typeof DebugSettings>;
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
settings: {
|
|
32
|
+
wireframe: false,
|
|
33
|
+
},
|
|
34
|
+
logBuffer: { serialize: () => '' } as any,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { AppCapabilities, getPersonalSpace } from '@dxos/app-toolkit';
|
|
8
|
+
import { type SettingsSurfaceProps } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
|
|
10
|
+
import { type LogBuffer, log } from '@dxos/log';
|
|
11
|
+
import { useClient } from '@dxos/react-client';
|
|
12
|
+
import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { Settings as SettingsForm } from '@dxos/react-ui-form';
|
|
14
|
+
import { setDeep } from '@dxos/util';
|
|
15
|
+
|
|
16
|
+
import { meta } from '#meta';
|
|
17
|
+
import { type Settings } from '#types';
|
|
18
|
+
|
|
19
|
+
type Toast = {
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const StorageAdapters = {
|
|
25
|
+
opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
|
|
26
|
+
idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
export type DebugSettingsProps = SettingsSurfaceProps<
|
|
30
|
+
Settings.Settings,
|
|
31
|
+
{
|
|
32
|
+
logBuffer: LogBuffer;
|
|
33
|
+
onUpload?: AppCapabilities.FileUploader;
|
|
34
|
+
}
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export const DebugSettings = ({ settings, onSettingsChange, logBuffer, onUpload }: DebugSettingsProps) => {
|
|
38
|
+
const { t } = useTranslation(meta.id);
|
|
39
|
+
const [toast, setToast] = useState<Toast>();
|
|
40
|
+
const download = useFileDownload();
|
|
41
|
+
const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
|
|
42
|
+
const client = useClient();
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
void Storage().then((config) => setStorageConfig(config));
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
const handleToast = useCallback(
|
|
49
|
+
(toast: Toast) => {
|
|
50
|
+
setToast(toast);
|
|
51
|
+
const timer = setTimeout(() => setToast(undefined), 5_000);
|
|
52
|
+
return () => clearTimeout(timer);
|
|
53
|
+
},
|
|
54
|
+
[setToast],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const handleDownload = useCallback(async () => {
|
|
58
|
+
const data = await client.diagnostics();
|
|
59
|
+
const file = new Blob([JSON.stringify(data, undefined, 2)], {
|
|
60
|
+
type: 'text/plain',
|
|
61
|
+
});
|
|
62
|
+
const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
|
|
63
|
+
download(file, fileName);
|
|
64
|
+
|
|
65
|
+
if (onUpload) {
|
|
66
|
+
const personalSpace = getPersonalSpace(client);
|
|
67
|
+
if (!personalSpace) {
|
|
68
|
+
log.error('no personal space available for upload');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const info = await onUpload(personalSpace.db, new File([file], fileName));
|
|
72
|
+
if (!info) {
|
|
73
|
+
log.error('diagnostics failed to upload to IPFS');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
handleToast({
|
|
77
|
+
title: t('settings.uploaded.message'),
|
|
78
|
+
description: t('settings.uploaded.description'),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// TODO(nf): move to IpfsPlugin?
|
|
82
|
+
const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
|
|
83
|
+
void navigator.clipboard.writeText(url);
|
|
84
|
+
handleToast({
|
|
85
|
+
title: t('settings.uploaded.message'),
|
|
86
|
+
description: t('settings.uploaded.description'),
|
|
87
|
+
});
|
|
88
|
+
log.info('diagnostics', { url });
|
|
89
|
+
}
|
|
90
|
+
}, [client, download, handleToast, onUpload, t]);
|
|
91
|
+
|
|
92
|
+
const handleDownloadLogs = useCallback(() => {
|
|
93
|
+
const ndjson = logBuffer.serialize();
|
|
94
|
+
const file = new Blob([ndjson], { type: 'application/x-ndjson' });
|
|
95
|
+
const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
|
|
96
|
+
download(file, fileName);
|
|
97
|
+
}, [download, logBuffer]);
|
|
98
|
+
|
|
99
|
+
const handleRepair = useCallback(async () => {
|
|
100
|
+
try {
|
|
101
|
+
const info = await client.repair();
|
|
102
|
+
setStorageConfig(await Storage());
|
|
103
|
+
handleToast({
|
|
104
|
+
title: t('settings.repair-success.message'),
|
|
105
|
+
description: JSON.stringify(info, undefined, 2),
|
|
106
|
+
});
|
|
107
|
+
} catch (err: any) {
|
|
108
|
+
handleToast({
|
|
109
|
+
title: t('settings.repair-failed.message'),
|
|
110
|
+
description: err.message,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}, [client, handleToast, t]);
|
|
114
|
+
|
|
115
|
+
const handleWireframeChange = useCallback(
|
|
116
|
+
(checked: boolean) => onSettingsChange?.((s) => ({ ...s, wireframe: !!checked })),
|
|
117
|
+
[onSettingsChange],
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const handleStorageAdapterChange = useCallback(
|
|
121
|
+
(value: string) => {
|
|
122
|
+
if (confirm(t('settings.storage-adapter.changed-alert.message'))) {
|
|
123
|
+
updateConfig(
|
|
124
|
+
storageConfig,
|
|
125
|
+
setStorageConfig,
|
|
126
|
+
['runtime', 'client', 'storage', 'dataStore'],
|
|
127
|
+
StorageAdapters[value as keyof typeof StorageAdapters],
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
[storageConfig, t],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<SettingsForm.Viewport>
|
|
136
|
+
<SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
|
|
137
|
+
<SettingsForm.Item title={t('settings.wireframe.label')} description={t('settings.wireframe.description')}>
|
|
138
|
+
<Input.Switch
|
|
139
|
+
disabled={!onSettingsChange}
|
|
140
|
+
checked={settings.wireframe}
|
|
141
|
+
onCheckedChange={handleWireframeChange}
|
|
142
|
+
/>
|
|
143
|
+
</SettingsForm.Item>
|
|
144
|
+
<SettingsForm.Item
|
|
145
|
+
title={t('settings.download-diagnostics.label')}
|
|
146
|
+
description={t('settings.download-diagnostics.description')}
|
|
147
|
+
>
|
|
148
|
+
<IconButton
|
|
149
|
+
icon='ph--download-simple--regular'
|
|
150
|
+
iconOnly
|
|
151
|
+
label={t('settings.download-diagnostics.label')}
|
|
152
|
+
onClick={handleDownload}
|
|
153
|
+
/>
|
|
154
|
+
</SettingsForm.Item>
|
|
155
|
+
<SettingsForm.Item
|
|
156
|
+
title={t('settings.download-logs.label')}
|
|
157
|
+
description={t('settings.download-logs.description')}
|
|
158
|
+
>
|
|
159
|
+
<IconButton
|
|
160
|
+
icon='ph--download-simple--regular'
|
|
161
|
+
iconOnly
|
|
162
|
+
label={t('settings.download-logs.label')}
|
|
163
|
+
onClick={handleDownloadLogs}
|
|
164
|
+
/>
|
|
165
|
+
</SettingsForm.Item>
|
|
166
|
+
<SettingsForm.Item title={t('settings.repair.label')} description={t('settings.repair.description')}>
|
|
167
|
+
<IconButton
|
|
168
|
+
icon='ph--first-aid-kit--regular'
|
|
169
|
+
iconOnly
|
|
170
|
+
label={t('settings.repair.label')}
|
|
171
|
+
onClick={handleRepair}
|
|
172
|
+
/>
|
|
173
|
+
</SettingsForm.Item>
|
|
174
|
+
|
|
175
|
+
{/* TODO(burdon): Move to layout? */}
|
|
176
|
+
{toast && (
|
|
177
|
+
<Toast.Root>
|
|
178
|
+
<Toast.Body>
|
|
179
|
+
<Toast.Title>
|
|
180
|
+
<Icon icon='ph--gift--duotone' classNames='inline mr-1' />
|
|
181
|
+
<span>{toast.title}</span>
|
|
182
|
+
</Toast.Title>
|
|
183
|
+
{toast.description && <Toast.Description>{toast.description}</Toast.Description>}
|
|
184
|
+
</Toast.Body>
|
|
185
|
+
</Toast.Root>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
<SettingsForm.Item
|
|
189
|
+
title={t('settings.choose-storage-adaptor.label')}
|
|
190
|
+
description={t('settings.choose-storage-adaptor.description')}
|
|
191
|
+
>
|
|
192
|
+
<Select.Root
|
|
193
|
+
disabled={!onSettingsChange}
|
|
194
|
+
value={
|
|
195
|
+
Object.entries(StorageAdapters).find(
|
|
196
|
+
([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
|
|
197
|
+
)?.[0]
|
|
198
|
+
}
|
|
199
|
+
onValueChange={handleStorageAdapterChange}
|
|
200
|
+
>
|
|
201
|
+
<Select.TriggerButton disabled={!onSettingsChange} placeholder={t('settings.data-store.label')} />
|
|
202
|
+
<Select.Portal>
|
|
203
|
+
<Select.Content>
|
|
204
|
+
<Select.Viewport>
|
|
205
|
+
{Object.keys(StorageAdapters).map((key) => (
|
|
206
|
+
<Select.Option key={key} value={key}>
|
|
207
|
+
{t(`settings.storage-adaptor.${key}.label`)}
|
|
208
|
+
</Select.Option>
|
|
209
|
+
))}
|
|
210
|
+
</Select.Viewport>
|
|
211
|
+
<Select.Arrow />
|
|
212
|
+
</Select.Content>
|
|
213
|
+
</Select.Portal>
|
|
214
|
+
</Select.Root>
|
|
215
|
+
</SettingsForm.Item>
|
|
216
|
+
</SettingsForm.Section>
|
|
217
|
+
</SettingsForm.Viewport>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const updateConfig = (config: ConfigProto, setConfig: (newConfig: ConfigProto) => void, path: string[], value: any) => {
|
|
222
|
+
const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
|
|
223
|
+
setDeep(storageConfigCopy, path, value);
|
|
224
|
+
setConfig(storageConfigCopy);
|
|
225
|
+
queueMicrotask(async () => {
|
|
226
|
+
await SaveConfig(storageConfigCopy);
|
|
227
|
+
});
|
|
228
|
+
};
|
|
@@ -2,46 +2,46 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
6
7
|
import { addressToA1Notation } from '@dxos/compute';
|
|
7
8
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Filter, Key, type
|
|
9
|
-
import {
|
|
9
|
+
import { DXN, Filter, Key, type Type } from '@dxos/echo';
|
|
10
|
+
import { View } from '@dxos/echo';
|
|
11
|
+
import { type OperationInvoker } from '@dxos/operation';
|
|
10
12
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
13
|
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
+
import { Sketch } from '@dxos/plugin-sketch/types';
|
|
15
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
14
16
|
import { faker } from '@dxos/random';
|
|
15
17
|
import { type Client } from '@dxos/react-client';
|
|
16
18
|
import { type Space } from '@dxos/react-client/echo';
|
|
17
|
-
import {
|
|
19
|
+
import { getTypenameFromQuery } from '@dxos/schema';
|
|
18
20
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
19
21
|
import { range } from '@dxos/util';
|
|
20
22
|
|
|
21
23
|
const generator: ValueGenerator = faker as any;
|
|
22
24
|
|
|
23
|
-
const findViewByTypename = async (views:
|
|
25
|
+
const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
24
26
|
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
export type ObjectGenerator<T
|
|
29
|
+
export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
28
30
|
|
|
29
|
-
export const createGenerator = <
|
|
31
|
+
export const createGenerator = <S extends Type.AnyObj>(
|
|
30
32
|
client: Client,
|
|
31
|
-
|
|
32
|
-
schema:
|
|
33
|
-
): ObjectGenerator<
|
|
34
|
-
return async (space: Space, n: number): Promise<
|
|
33
|
+
invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
|
|
34
|
+
schema: S,
|
|
35
|
+
): ObjectGenerator<Schema.Schema.Type<S>> => {
|
|
36
|
+
return async (space: Space, n: number): Promise<Schema.Schema.Type<S>[]> => {
|
|
35
37
|
const typename = schema.typename;
|
|
36
38
|
|
|
37
39
|
// Find or create table and view.
|
|
38
|
-
const
|
|
40
|
+
const views = await space.db.query(Filter.type(View.View)).run();
|
|
39
41
|
const view = await findViewByTypename(views, typename);
|
|
40
|
-
const staticSchema = client?.graph.schemaRegistry.
|
|
42
|
+
const staticSchema = client?.graph.schemaRegistry.query({ typename }).runSync()[0];
|
|
41
43
|
if (!view && !staticSchema) {
|
|
42
|
-
await
|
|
43
|
-
} else if (!view && staticSchema) {
|
|
44
|
-
await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename, show: false }));
|
|
44
|
+
await invokePromise(SpaceOperation.AddSchema, { db: space.db, schema, show: false });
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// Create objects.
|
|
@@ -56,7 +56,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
56
56
|
async (space, n, cb) => {
|
|
57
57
|
const objects = range(n).map(() => {
|
|
58
58
|
return space.db.add(
|
|
59
|
-
Markdown.
|
|
59
|
+
Markdown.make({
|
|
60
60
|
name: faker.commerce.productName(),
|
|
61
61
|
content: faker.lorem.sentences(5),
|
|
62
62
|
}),
|
|
@@ -68,12 +68,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
68
68
|
},
|
|
69
69
|
],
|
|
70
70
|
[
|
|
71
|
-
|
|
71
|
+
Sketch.Sketch.typename,
|
|
72
72
|
async (space, n, cb) => {
|
|
73
73
|
const objects = range(n).map(() => {
|
|
74
|
-
|
|
75
|
-
const obj = space.db.add(Diagram.make({ name: faker.commerce.productName() }));
|
|
76
|
-
|
|
74
|
+
const obj = space.db.add(Sketch.make({ name: faker.commerce.productName() }));
|
|
77
75
|
return obj;
|
|
78
76
|
});
|
|
79
77
|
|