@dxos/plugin-debug 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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 +19 -118
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +81 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +3 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/DebugPlugin.node.d.ts +5 -0
- package/dist/types/src/DebugPlugin.node.d.ts.map +1 -0
- package/dist/types/src/DebugPlugin.test.d.ts +2 -0
- package/dist/types/src/DebugPlugin.test.d.ts.map +1 -0
- 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 +11 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/{react-context/react-context.d.ts → react-context.d.ts} +1 -1
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +9 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +7 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- 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 +97 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/index.d.ts +2 -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 +2 -2
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.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.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 +2 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts +6 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts +2 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +5 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +2 -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 +2 -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 +2 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +11 -0
- package/dist/types/src/{components → containers}/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/containers/SpaceGenerator/index.d.ts +2 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/index.d.ts +2 -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/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +78 -59
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +8 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +69 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +89 -70
- package/src/DebugPlugin.node.ts +18 -0
- package/src/DebugPlugin.test.ts +29 -0
- package/src/DebugPlugin.tsx +20 -11
- package/src/capabilities/app-graph-builder.ts +405 -0
- package/src/capabilities/index.ts +6 -4
- package/src/capabilities/react-context.tsx +25 -0
- package/src/capabilities/react-surface.tsx +439 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +7 -6
- package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
- package/src/components/DebugSettings/DebugSettings.tsx +262 -0
- package/src/components/DebugSettings/index.ts +5 -0
- package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +2 -2
- package/src/components/SchemaTable/index.ts +5 -0
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +14 -15
- package/src/components/SpaceGenerator/draw-util.ts +8 -8
- package/src/components/SpaceGenerator/index.ts +2 -3
- package/src/components/SpaceGenerator/presets.ts +53 -73
- package/src/components/index.ts +4 -11
- package/src/{components → containers/DebugGraph}/DebugGraph.tsx +3 -4
- package/src/containers/DebugGraph/index.ts +5 -0
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +76 -0
- package/src/containers/DebugObjectPanel/index.ts +5 -0
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +47 -0
- package/src/containers/DebugSpaceObjectsPanel/index.ts +5 -0
- package/src/{components → containers/DebugStatus}/DebugStatus.tsx +41 -19
- package/src/containers/DebugStatus/index.ts +5 -0
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
- package/src/containers/DevtoolsOverviewContainer/index.ts +5 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +126 -0
- package/src/containers/SpaceGenerator/index.ts +5 -0
- package/src/{components → containers/Wireframe}/Wireframe.tsx +3 -7
- package/src/containers/Wireframe/index.ts +5 -0
- package/src/containers/index.ts +13 -0
- package/src/index.ts +7 -1
- package/src/meta.ts +1 -1
- package/src/translations.ts +75 -58
- package/src/types/Settings.ts +16 -0
- package/src/{types.ts → types/index.ts} +15 -14
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +0 -15
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs +0 -19
- package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs +0 -1152
- package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs +0 -598
- package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs.map +0 -7
- package/dist/lib/browser/chunk-4UFQXPP7.mjs +0 -78
- package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-A5H5GRV6.mjs +0 -20
- package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +0 -7
- package/dist/lib/browser/react-context-FSWBT3MH.mjs +0 -17
- package/dist/lib/browser/react-context-FSWBT3MH.mjs.map +0 -7
- package/dist/lib/browser/react-surface-2N6CPSHR.mjs +0 -757
- package/dist/lib/browser/react-surface-2N6CPSHR.mjs.map +0 -7
- package/dist/lib/browser/settings-KA4GN73K.mjs +0 -31
- package/dist/lib/browser/settings-KA4GN73K.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/react-context/index.d.ts +0 -7
- package/dist/types/src/capabilities/react-context/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context/react-context.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/capabilities/settings/index.d.ts +0 -3
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +0 -5
- package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
- 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 -9
- package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts +0 -7
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugSettings.d.ts +0 -8
- 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.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 -68
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -420
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/react-context/index.ts +0 -7
- package/src/capabilities/react-context/react-context.tsx +0 -20
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -409
- package/src/capabilities/settings/index.ts +0 -7
- package/src/components/Container.tsx +0 -15
- package/src/components/DebugObjectPanel.tsx +0 -33
- package/src/components/DebugSettings.tsx +0 -185
- package/src/components/DevtoolsOverviewContainer.tsx +0 -20
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -54
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -127
- /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/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { AppCapabilities, getPersonalSpace } from '@dxos/app-toolkit';
|
|
8
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
|
+
import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import { type IdbLogStore } from '@dxos/log-store-idb';
|
|
12
|
+
import { useClient } from '@dxos/react-client';
|
|
13
|
+
import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import { Settings as SettingsForm } from '@dxos/react-ui-form';
|
|
15
|
+
import { TRACE_ALL_KEY } from '@dxos/tracing';
|
|
16
|
+
import { setDeep } from '@dxos/util';
|
|
17
|
+
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { type Settings } from '#types';
|
|
20
|
+
|
|
21
|
+
type Toast = {
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const StorageAdapters = {
|
|
27
|
+
opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
|
|
28
|
+
idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export type DebugSettingsProps = AppSurface.SettingsArticleProps<
|
|
32
|
+
Settings.Settings,
|
|
33
|
+
{
|
|
34
|
+
logStore: IdbLogStore;
|
|
35
|
+
onUpload?: AppCapabilities.FileUploader;
|
|
36
|
+
}
|
|
37
|
+
>;
|
|
38
|
+
|
|
39
|
+
export const DebugSettings = ({ settings, onSettingsChange, logStore, onUpload }: DebugSettingsProps) => {
|
|
40
|
+
const { t } = useTranslation(meta.id);
|
|
41
|
+
const [toast, setToast] = useState<Toast>();
|
|
42
|
+
const download = useFileDownload();
|
|
43
|
+
const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
|
|
44
|
+
const client = useClient();
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
void Storage().then((config) => setStorageConfig(config));
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
const handleToast = useCallback(
|
|
51
|
+
(toast: Toast) => {
|
|
52
|
+
setToast(toast);
|
|
53
|
+
const timer = setTimeout(() => setToast(undefined), 5_000);
|
|
54
|
+
return () => clearTimeout(timer);
|
|
55
|
+
},
|
|
56
|
+
[setToast],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const handleDownload = useCallback(async () => {
|
|
60
|
+
const data = await client.diagnostics();
|
|
61
|
+
const file = new Blob([JSON.stringify(data, undefined, 2)], {
|
|
62
|
+
type: 'text/plain',
|
|
63
|
+
});
|
|
64
|
+
const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
|
|
65
|
+
download(file, fileName);
|
|
66
|
+
|
|
67
|
+
if (onUpload) {
|
|
68
|
+
const personalSpace = getPersonalSpace(client);
|
|
69
|
+
if (!personalSpace) {
|
|
70
|
+
log.error('no personal space available for upload');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const info = await onUpload(personalSpace.db, new File([file], fileName));
|
|
74
|
+
if (!info) {
|
|
75
|
+
log.error('diagnostics failed to upload to IPFS');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
handleToast({
|
|
79
|
+
title: t('settings.uploaded.message'),
|
|
80
|
+
description: t('settings.uploaded.description'),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// TODO(nf): move to IpfsPlugin?
|
|
84
|
+
const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
|
|
85
|
+
void navigator.clipboard.writeText(url);
|
|
86
|
+
handleToast({
|
|
87
|
+
title: t('settings.uploaded.message'),
|
|
88
|
+
description: t('settings.uploaded.description'),
|
|
89
|
+
});
|
|
90
|
+
log.info('diagnostics', { url });
|
|
91
|
+
}
|
|
92
|
+
}, [client, download, handleToast, onUpload, t]);
|
|
93
|
+
|
|
94
|
+
const handleDownloadLogs = useCallback(async () => {
|
|
95
|
+
const ndjson = await logStore.export();
|
|
96
|
+
const file = new Blob([ndjson], { type: 'application/x-ndjson' });
|
|
97
|
+
const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
|
|
98
|
+
download(file, fileName);
|
|
99
|
+
}, [download, logStore]);
|
|
100
|
+
|
|
101
|
+
const handleRepair = useCallback(async () => {
|
|
102
|
+
try {
|
|
103
|
+
const info = await client.repair();
|
|
104
|
+
setStorageConfig(await Storage());
|
|
105
|
+
handleToast({
|
|
106
|
+
title: t('settings.repair-success.message'),
|
|
107
|
+
description: JSON.stringify(info, undefined, 2),
|
|
108
|
+
});
|
|
109
|
+
} catch (err: any) {
|
|
110
|
+
handleToast({
|
|
111
|
+
title: t('settings.repair-failed.message'),
|
|
112
|
+
description: err.message,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, [client, handleToast, t]);
|
|
116
|
+
|
|
117
|
+
const handleWireframeChange = useCallback(
|
|
118
|
+
(checked: boolean) => onSettingsChange?.((s) => ({ ...s, wireframe: !!checked })),
|
|
119
|
+
[onSettingsChange],
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const traceAll = useMemo(
|
|
123
|
+
() => settings.traceAll ?? (typeof localStorage !== 'undefined' && localStorage.getItem(TRACE_ALL_KEY) === 'true'),
|
|
124
|
+
[settings.traceAll],
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const handleTraceAllChange = useCallback(
|
|
128
|
+
(checked: boolean) => {
|
|
129
|
+
const value = !!checked;
|
|
130
|
+
localStorage.setItem(TRACE_ALL_KEY, String(value));
|
|
131
|
+
onSettingsChange?.((s) => ({ ...s, traceAll: value }));
|
|
132
|
+
},
|
|
133
|
+
[onSettingsChange],
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
const handleOpenTracingPanel = useCallback(() => {
|
|
137
|
+
window.open('about:blank', '_blank');
|
|
138
|
+
}, []);
|
|
139
|
+
|
|
140
|
+
const handleStorageAdapterChange = useCallback(
|
|
141
|
+
(value: string) => {
|
|
142
|
+
if (confirm(t('settings.storage-adapter.changed-alert.message'))) {
|
|
143
|
+
updateConfig(
|
|
144
|
+
storageConfig,
|
|
145
|
+
setStorageConfig,
|
|
146
|
+
['runtime', 'client', 'storage', 'dataStore'],
|
|
147
|
+
StorageAdapters[value as keyof typeof StorageAdapters],
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
[storageConfig, t],
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<SettingsForm.Viewport>
|
|
156
|
+
<SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
|
|
157
|
+
<SettingsForm.Item title={t('settings.wireframe.label')} description={t('settings.wireframe.description')}>
|
|
158
|
+
<Input.Switch
|
|
159
|
+
disabled={!onSettingsChange}
|
|
160
|
+
checked={settings.wireframe}
|
|
161
|
+
onCheckedChange={handleWireframeChange}
|
|
162
|
+
/>
|
|
163
|
+
</SettingsForm.Item>
|
|
164
|
+
<SettingsForm.Item title={t('settings.trace-all.label')} description={t('settings.trace-all.description')}>
|
|
165
|
+
<Input.Switch disabled={!onSettingsChange} checked={traceAll} onCheckedChange={handleTraceAllChange} />
|
|
166
|
+
</SettingsForm.Item>
|
|
167
|
+
<SettingsForm.Item
|
|
168
|
+
title={t('settings.tracing-panel.label')}
|
|
169
|
+
description={t('settings.tracing-panel.description')}
|
|
170
|
+
>
|
|
171
|
+
<IconButton
|
|
172
|
+
icon='ph--arrow-square-out--regular'
|
|
173
|
+
iconOnly
|
|
174
|
+
label={t('settings.tracing-panel.label')}
|
|
175
|
+
onClick={handleOpenTracingPanel}
|
|
176
|
+
/>
|
|
177
|
+
</SettingsForm.Item>
|
|
178
|
+
<SettingsForm.Item
|
|
179
|
+
title={t('settings.download-diagnostics.label')}
|
|
180
|
+
description={t('settings.download-diagnostics.description')}
|
|
181
|
+
>
|
|
182
|
+
<IconButton
|
|
183
|
+
icon='ph--download-simple--regular'
|
|
184
|
+
iconOnly
|
|
185
|
+
label={t('settings.download-diagnostics.label')}
|
|
186
|
+
onClick={handleDownload}
|
|
187
|
+
/>
|
|
188
|
+
</SettingsForm.Item>
|
|
189
|
+
<SettingsForm.Item
|
|
190
|
+
title={t('settings.download-logs.label')}
|
|
191
|
+
description={t('settings.download-logs.description')}
|
|
192
|
+
>
|
|
193
|
+
<IconButton
|
|
194
|
+
icon='ph--download-simple--regular'
|
|
195
|
+
iconOnly
|
|
196
|
+
label={t('settings.download-logs.label')}
|
|
197
|
+
onClick={handleDownloadLogs}
|
|
198
|
+
/>
|
|
199
|
+
</SettingsForm.Item>
|
|
200
|
+
<SettingsForm.Item title={t('settings.repair.label')} description={t('settings.repair.description')}>
|
|
201
|
+
<IconButton
|
|
202
|
+
icon='ph--first-aid-kit--regular'
|
|
203
|
+
iconOnly
|
|
204
|
+
label={t('settings.repair.label')}
|
|
205
|
+
onClick={handleRepair}
|
|
206
|
+
/>
|
|
207
|
+
</SettingsForm.Item>
|
|
208
|
+
|
|
209
|
+
{/* TODO(burdon): Move to layout? */}
|
|
210
|
+
{toast && (
|
|
211
|
+
<Toast.Root>
|
|
212
|
+
<Toast.Body>
|
|
213
|
+
<Toast.Title>
|
|
214
|
+
<Icon icon='ph--gift--duotone' classNames='inline mr-1' />
|
|
215
|
+
<span>{toast.title}</span>
|
|
216
|
+
</Toast.Title>
|
|
217
|
+
{toast.description && <Toast.Description>{toast.description}</Toast.Description>}
|
|
218
|
+
</Toast.Body>
|
|
219
|
+
</Toast.Root>
|
|
220
|
+
)}
|
|
221
|
+
|
|
222
|
+
<SettingsForm.Item
|
|
223
|
+
title={t('settings.choose-storage-adaptor.label')}
|
|
224
|
+
description={t('settings.choose-storage-adaptor.description')}
|
|
225
|
+
>
|
|
226
|
+
<Select.Root
|
|
227
|
+
disabled={!onSettingsChange}
|
|
228
|
+
value={
|
|
229
|
+
Object.entries(StorageAdapters).find(
|
|
230
|
+
([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
|
|
231
|
+
)?.[0]
|
|
232
|
+
}
|
|
233
|
+
onValueChange={handleStorageAdapterChange}
|
|
234
|
+
>
|
|
235
|
+
<Select.TriggerButton disabled={!onSettingsChange} placeholder={t('settings.data-store.label')} />
|
|
236
|
+
<Select.Portal>
|
|
237
|
+
<Select.Content>
|
|
238
|
+
<Select.Viewport>
|
|
239
|
+
{Object.keys(StorageAdapters).map((key) => (
|
|
240
|
+
<Select.Option key={key} value={key}>
|
|
241
|
+
{t(`settings.storage-adaptor.${key}.label`)}
|
|
242
|
+
</Select.Option>
|
|
243
|
+
))}
|
|
244
|
+
</Select.Viewport>
|
|
245
|
+
<Select.Arrow />
|
|
246
|
+
</Select.Content>
|
|
247
|
+
</Select.Portal>
|
|
248
|
+
</Select.Root>
|
|
249
|
+
</SettingsForm.Item>
|
|
250
|
+
</SettingsForm.Section>
|
|
251
|
+
</SettingsForm.Viewport>
|
|
252
|
+
);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const updateConfig = (config: ConfigProto, setConfig: (newConfig: ConfigProto) => void, path: string[], value: any) => {
|
|
256
|
+
const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
|
|
257
|
+
setDeep(storageConfigCopy, path, value);
|
|
258
|
+
setConfig(storageConfigCopy);
|
|
259
|
+
queueMicrotask(async () => {
|
|
260
|
+
await SaveConfig(storageConfigCopy);
|
|
261
|
+
});
|
|
262
|
+
};
|
|
@@ -19,8 +19,8 @@ export const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTable
|
|
|
19
19
|
<h2 className='p-2'>{label}</h2>
|
|
20
20
|
{types.map((type) => (
|
|
21
21
|
<div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>
|
|
22
|
-
<div className='
|
|
23
|
-
<div className='
|
|
22
|
+
<div className='px-2 text-sm font-mono text-subdued'>{type.typename}</div>
|
|
23
|
+
<div className='px-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>
|
|
24
24
|
<IconButton
|
|
25
25
|
variant='ghost'
|
|
26
26
|
icon='ph--plus--regular'
|
|
@@ -4,22 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { addressToA1Notation } from '@dxos/compute';
|
|
7
|
+
import { addressToA1Notation } from '@dxos/compute-hyperformula';
|
|
8
8
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
9
9
|
import { DXN, Filter, Key, type Type } from '@dxos/echo';
|
|
10
|
-
import {
|
|
10
|
+
import { View } from '@dxos/echo';
|
|
11
|
+
import { OperationInvoker } from '@dxos/operation';
|
|
11
12
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
12
13
|
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
13
|
-
import {
|
|
14
|
-
import { SpaceOperation } from '@dxos/plugin-space/
|
|
15
|
-
import {
|
|
14
|
+
import { Sketch } from '@dxos/plugin-sketch/types';
|
|
15
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
16
|
+
import { random } from '@dxos/random';
|
|
16
17
|
import { type Client } from '@dxos/react-client';
|
|
17
18
|
import { type Space } from '@dxos/react-client/echo';
|
|
18
|
-
import {
|
|
19
|
+
import { getTypenameFromQuery } from '@dxos/schema';
|
|
19
20
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
20
21
|
import { range } from '@dxos/util';
|
|
21
22
|
|
|
22
|
-
const generator: ValueGenerator =
|
|
23
|
+
const generator: ValueGenerator = random as any;
|
|
23
24
|
|
|
24
25
|
const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
25
26
|
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
@@ -27,7 +28,7 @@ const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
|
27
28
|
|
|
28
29
|
export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
29
30
|
|
|
30
|
-
export const createGenerator = <S extends Type.
|
|
31
|
+
export const createGenerator = <S extends Type.AnyObj>(
|
|
31
32
|
client: Client,
|
|
32
33
|
invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
|
|
33
34
|
schema: S,
|
|
@@ -41,8 +42,6 @@ export const createGenerator = <S extends Type.Obj.Any>(
|
|
|
41
42
|
const staticSchema = client?.graph.schemaRegistry.query({ typename }).runSync()[0];
|
|
42
43
|
if (!view && !staticSchema) {
|
|
43
44
|
await invokePromise(SpaceOperation.AddSchema, { db: space.db, schema, show: false });
|
|
44
|
-
} else if (!view && staticSchema) {
|
|
45
|
-
await invokePromise(SpaceOperation.UseStaticSchema, { db: space.db, typename, show: false });
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
// Create objects.
|
|
@@ -58,8 +57,8 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
58
57
|
const objects = range(n).map(() => {
|
|
59
58
|
return space.db.add(
|
|
60
59
|
Markdown.make({
|
|
61
|
-
name:
|
|
62
|
-
content:
|
|
60
|
+
name: random.commerce.productName(),
|
|
61
|
+
content: random.lorem.sentences(5),
|
|
63
62
|
}),
|
|
64
63
|
);
|
|
65
64
|
});
|
|
@@ -69,10 +68,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
69
68
|
},
|
|
70
69
|
],
|
|
71
70
|
[
|
|
72
|
-
|
|
71
|
+
Sketch.Sketch.typename,
|
|
73
72
|
async (space, n, cb) => {
|
|
74
73
|
const objects = range(n).map(() => {
|
|
75
|
-
const obj = space.db.add(
|
|
74
|
+
const obj = space.db.add(Sketch.make({ name: random.commerce.productName() }));
|
|
76
75
|
return obj;
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -108,7 +107,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
108
107
|
// TODO(burdon): Set formatting for columns.
|
|
109
108
|
return space.db.add(
|
|
110
109
|
Sheet.make({
|
|
111
|
-
name:
|
|
110
|
+
name: random.commerce.productName(),
|
|
112
111
|
cells,
|
|
113
112
|
}),
|
|
114
113
|
);
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '@antv/layout';
|
|
16
16
|
import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { random } from '@dxos/random';
|
|
19
19
|
import { isTruthy, range } from '@dxos/util';
|
|
20
20
|
|
|
21
21
|
// TODO(burdon): Graph layout:
|
|
@@ -32,10 +32,10 @@ import { isTruthy, range } from '@dxos/util';
|
|
|
32
32
|
// TODO(burdon): Factor out.
|
|
33
33
|
// TODO(burdon): Map ECHO to Graph.
|
|
34
34
|
export const generateGraph = (): Graph<PlainObject, PlainObject> => {
|
|
35
|
-
const nodes = range(
|
|
36
|
-
id:
|
|
35
|
+
const nodes = range(random.number.int({ min: 8, max: 32 })).map(() => ({
|
|
36
|
+
id: random.string.uuid(),
|
|
37
37
|
data: {
|
|
38
|
-
label:
|
|
38
|
+
label: random.lorem
|
|
39
39
|
.words(2)
|
|
40
40
|
.split(' ')
|
|
41
41
|
.map((word) => word.charAt(0).toUpperCase())
|
|
@@ -46,7 +46,7 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
|
|
|
46
46
|
const unlinked = new Set(nodes.map((node) => node.id));
|
|
47
47
|
const pop = () => {
|
|
48
48
|
if (unlinked.size) {
|
|
49
|
-
const id =
|
|
49
|
+
const id = random.helpers.arrayElement(Array.from(unlinked));
|
|
50
50
|
unlinked.delete(id);
|
|
51
51
|
return id;
|
|
52
52
|
}
|
|
@@ -54,12 +54,12 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
|
|
|
54
54
|
|
|
55
55
|
const edges: Edge<PlainObject>[] = [];
|
|
56
56
|
const link = (source: string, target: string) => {
|
|
57
|
-
edges.push({ id:
|
|
57
|
+
edges.push({ id: random.string.uuid(), source, target, data: {} });
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
const branching = 3;
|
|
61
61
|
const traverse = (source: string) => {
|
|
62
|
-
const targets = range(
|
|
62
|
+
const targets = range(random.number.int({ min: 1, max: branching }))
|
|
63
63
|
.map(() => {
|
|
64
64
|
const target = pop();
|
|
65
65
|
if (target) {
|
|
@@ -106,7 +106,7 @@ export const drawGraph = async (
|
|
|
106
106
|
preventOverlap: true,
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
const layoutType =
|
|
109
|
+
const layoutType = random.helpers.arrayElement(['d3force', 'grid', 'radial']);
|
|
110
110
|
let layout: Layout<any>;
|
|
111
111
|
switch (layoutType) {
|
|
112
112
|
case 'd3force': {
|