@dxos/plugin-debug 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae

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.
Files changed (197) hide show
  1. package/dist/lib/browser/DebugGraph-7HXJ2PS2.mjs +16 -0
  2. package/dist/lib/browser/DebugGraph-7HXJ2PS2.mjs.map +7 -0
  3. package/dist/lib/browser/DebugObjectPanel-3TCDNUNW.mjs +33 -0
  4. package/dist/lib/browser/DebugObjectPanel-3TCDNUNW.mjs.map +7 -0
  5. package/dist/lib/browser/DebugSettings-JZMIUDYB.mjs +174 -0
  6. package/dist/lib/browser/DebugSettings-JZMIUDYB.mjs.map +7 -0
  7. package/dist/lib/browser/DebugSpaceObjectsPanel-7NRPLWZ4.mjs +50 -0
  8. package/dist/lib/browser/DebugSpaceObjectsPanel-7NRPLWZ4.mjs.map +7 -0
  9. package/dist/lib/browser/DebugStatus-COQGH37G.mjs +125 -0
  10. package/dist/lib/browser/DebugStatus-COQGH37G.mjs.map +7 -0
  11. package/dist/lib/browser/DevtoolsOverviewContainer-C75NFVER.mjs +20 -0
  12. package/dist/lib/browser/DevtoolsOverviewContainer-C75NFVER.mjs.map +7 -0
  13. package/dist/lib/browser/{SpaceGenerator-AG3XGNMV.mjs → SpaceGenerator-SWSGJEEL.mjs} +573 -382
  14. package/dist/lib/browser/SpaceGenerator-SWSGJEEL.mjs.map +7 -0
  15. package/dist/lib/browser/Wireframe-KAGOKEFW.mjs +53 -0
  16. package/dist/lib/browser/Wireframe-KAGOKEFW.mjs.map +7 -0
  17. package/dist/lib/browser/app-graph-builder-LGUQNXHD.mjs +625 -0
  18. package/dist/lib/browser/app-graph-builder-LGUQNXHD.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-AJA6RYN3.mjs → chunk-4UFQXPP7.mjs} +12 -2
  20. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
  22. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
  23. package/dist/lib/browser/index.mjs +43 -41
  24. package/dist/lib/browser/index.mjs.map +4 -4
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
  27. package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
  28. package/dist/lib/browser/react-surface-BTVNKKVQ.mjs +443 -0
  29. package/dist/lib/browser/react-surface-BTVNKKVQ.mjs.map +7 -0
  30. package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
  31. package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
  32. package/dist/types/src/DebugPlugin.d.ts +7 -1
  33. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  34. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  35. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  37. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/index.d.ts +4 -8
  39. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  40. package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
  41. package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
  42. package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
  43. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
  44. package/dist/types/src/capabilities/react-surface/index.d.ts +5 -0
  45. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  46. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +9 -0
  47. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  48. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  49. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  50. package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
  51. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  52. package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
  53. package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
  54. package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
  55. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
  56. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  57. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  58. package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
  59. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
  60. package/dist/types/src/components/SpaceGenerator/presets.d.ts +4 -4
  61. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  62. package/dist/types/src/components/index.d.ts +2 -9
  63. package/dist/types/src/components/index.d.ts.map +1 -1
  64. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
  65. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
  66. package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
  67. package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
  68. package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +2 -2
  69. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
  70. package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
  71. package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
  72. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts +10 -0
  73. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts.map +1 -0
  74. package/dist/types/src/containers/DebugSettings/index.d.ts +3 -0
  75. package/dist/types/src/containers/DebugSettings/index.d.ts.map +1 -0
  76. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
  77. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
  78. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
  79. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
  80. package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
  81. package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
  82. package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
  83. package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
  84. package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
  85. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
  86. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
  87. package/dist/types/src/{components → containers}/SpaceGenerator/SpaceGenerator.d.ts +2 -2
  88. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
  89. package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
  90. package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
  91. package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
  92. package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
  93. package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
  94. package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
  95. package/dist/types/src/containers/index.d.ts +10 -0
  96. package/dist/types/src/containers/index.d.ts.map +1 -0
  97. package/dist/types/src/meta.d.ts +2 -3
  98. package/dist/types/src/meta.d.ts.map +1 -1
  99. package/dist/types/src/translations.d.ts +5 -1
  100. package/dist/types/src/translations.d.ts.map +1 -1
  101. package/dist/types/src/types.d.ts +6 -1
  102. package/dist/types/src/types.d.ts.map +1 -1
  103. package/dist/types/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +76 -67
  105. package/src/DebugPlugin.tsx +27 -32
  106. package/src/capabilities/app-graph-builder/app-graph-builder.ts +441 -0
  107. package/src/capabilities/app-graph-builder/index.ts +7 -0
  108. package/src/capabilities/index.ts +4 -6
  109. package/src/capabilities/react-context/index.ts +7 -0
  110. package/src/capabilities/react-context/react-context.tsx +20 -0
  111. package/src/capabilities/react-surface/index.ts +7 -0
  112. package/src/capabilities/react-surface/react-surface.tsx +428 -0
  113. package/src/capabilities/settings/index.ts +7 -0
  114. package/src/capabilities/settings/settings.ts +31 -0
  115. package/src/components/SchemaTable/index.ts +5 -0
  116. package/src/components/SpaceGenerator/ObjectGenerator.tsx +32 -38
  117. package/src/components/SpaceGenerator/draw-util.ts +5 -5
  118. package/src/components/SpaceGenerator/index.ts +2 -3
  119. package/src/components/SpaceGenerator/presets.ts +337 -53
  120. package/src/components/index.ts +2 -10
  121. package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
  122. package/src/containers/DebugGraph/index.ts +7 -0
  123. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +45 -0
  124. package/src/containers/DebugObjectPanel/index.ts +7 -0
  125. package/src/containers/DebugSettings/DebugSettings.tsx +201 -0
  126. package/src/containers/DebugSettings/index.ts +7 -0
  127. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +60 -0
  128. package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
  129. package/src/{components → containers/DebugStatus}/DebugStatus.tsx +2 -2
  130. package/src/containers/DebugStatus/index.ts +7 -0
  131. package/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.tsx +2 -4
  132. package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
  133. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +127 -0
  134. package/src/containers/SpaceGenerator/index.ts +7 -0
  135. package/src/{components → containers/Wireframe}/Wireframe.tsx +7 -7
  136. package/src/containers/Wireframe/index.ts +7 -0
  137. package/src/containers/index.ts +14 -0
  138. package/src/meta.ts +8 -7
  139. package/src/translations.ts +5 -1
  140. package/src/types.ts +9 -1
  141. package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs +0 -228
  142. package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs.map +0 -7
  143. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  144. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  145. package/dist/lib/browser/SpaceGenerator-AG3XGNMV.mjs.map +0 -7
  146. package/dist/lib/browser/app-graph-builder-SQXFD2BL.mjs +0 -597
  147. package/dist/lib/browser/app-graph-builder-SQXFD2BL.mjs.map +0 -7
  148. package/dist/lib/browser/chunk-5XPIRNQS.mjs +0 -18
  149. package/dist/lib/browser/chunk-5XPIRNQS.mjs.map +0 -7
  150. package/dist/lib/browser/chunk-AJA6RYN3.mjs.map +0 -7
  151. package/dist/lib/browser/react-context-NVAGLAJD.mjs +0 -16
  152. package/dist/lib/browser/react-context-NVAGLAJD.mjs.map +0 -7
  153. package/dist/lib/browser/react-surface-3GD2OWCA.mjs +0 -768
  154. package/dist/lib/browser/react-surface-3GD2OWCA.mjs.map +0 -7
  155. package/dist/lib/browser/settings-LSSWLM5I.mjs +0 -22
  156. package/dist/lib/browser/settings-LSSWLM5I.mjs.map +0 -7
  157. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  158. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  159. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  160. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  161. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  162. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  163. package/dist/types/src/capabilities/settings.d.ts +0 -4
  164. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  165. package/dist/types/src/components/Container.d.ts +0 -5
  166. package/dist/types/src/components/Container.d.ts.map +0 -1
  167. package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
  168. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
  169. package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
  170. package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
  171. package/dist/types/src/components/DebugApp/index.d.ts +0 -3
  172. package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
  173. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  174. package/dist/types/src/components/DebugSettings.d.ts +0 -6
  175. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  176. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  177. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  178. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  179. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
  180. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -6
  181. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  182. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  183. package/src/capabilities/app-graph-builder.ts +0 -457
  184. package/src/capabilities/react-context.tsx +0 -16
  185. package/src/capabilities/react-surface.tsx +0 -397
  186. package/src/capabilities/settings.ts +0 -19
  187. package/src/components/Container.tsx +0 -15
  188. package/src/components/DebugApp/DebugApp.tsx +0 -84
  189. package/src/components/DebugApp/Tree.tsx +0 -103
  190. package/src/components/DebugApp/index.ts +0 -7
  191. package/src/components/DebugObjectPanel.tsx +0 -35
  192. package/src/components/DebugSettings.tsx +0 -151
  193. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
  194. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
  195. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  196. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
  197. /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
@@ -0,0 +1,201 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useEffect, useState } from 'react';
6
+
7
+ import { useCapabilities } from '@dxos/app-framework/ui';
8
+ import { AppCapabilities } from '@dxos/app-toolkit';
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 } from '@dxos/react-ui-form';
14
+ import { setDeep } from '@dxos/util';
15
+
16
+ import { meta } from '../../meta';
17
+ import { type DebugSettingsProps } 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 DebugSettingsComponentProps = {
30
+ settings: DebugSettingsProps;
31
+ onSettingsChange: (fn: (current: DebugSettingsProps) => DebugSettingsProps) => void;
32
+ logBuffer: LogBuffer;
33
+ };
34
+
35
+ export const DebugSettings = ({ settings, onSettingsChange, logBuffer }: DebugSettingsComponentProps) => {
36
+ const { t } = useTranslation(meta.id);
37
+ const [toast, setToast] = useState<Toast>();
38
+ const client = useClient();
39
+ const download = useFileDownload();
40
+ // TODO(mykola): Get updates from other places that change Config.
41
+ const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
42
+ const [upload] = useCapabilities(AppCapabilities.FileUploader);
43
+
44
+ useEffect(() => {
45
+ void Storage().then((config) => setStorageConfig(config));
46
+ }, []);
47
+
48
+ const handleToast = (toast: Toast) => {
49
+ setToast(toast);
50
+ const t = setTimeout(() => setToast(undefined), 5_000);
51
+ return () => clearTimeout(t);
52
+ };
53
+
54
+ const handleDownload = async () => {
55
+ const data = await client.diagnostics();
56
+ const file = new Blob([JSON.stringify(data, undefined, 2)], {
57
+ type: 'text/plain',
58
+ });
59
+ const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
60
+ download(file, fileName);
61
+
62
+ if (upload) {
63
+ const info = await upload(client.spaces.default.db, new File([file], fileName));
64
+ if (!info) {
65
+ log.error('diagnostics failed to upload to IPFS');
66
+ return;
67
+ }
68
+ handleToast({
69
+ title: t('settings uploaded'),
70
+ description: t('settings uploaded to clipboard'),
71
+ });
72
+
73
+ // TODO(nf): move to IpfsPlugin?
74
+ const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
75
+ void navigator.clipboard.writeText(url);
76
+ handleToast({
77
+ title: t('settings uploaded'),
78
+ description: t('settings uploaded to clipboard'),
79
+ });
80
+ log.info('diagnostics', { url });
81
+ }
82
+ };
83
+
84
+ const handleDownloadLogs = () => {
85
+ const ndjson = logBuffer.serialize();
86
+ const file = new Blob([ndjson], { type: 'application/x-ndjson' });
87
+ const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
88
+ download(file, fileName);
89
+ };
90
+
91
+ const handleRepair = async () => {
92
+ try {
93
+ const info = await client.repair();
94
+ setStorageConfig(await Storage());
95
+ handleToast({
96
+ title: t('settings repair success'),
97
+ description: JSON.stringify(info, undefined, 2),
98
+ });
99
+ } catch (err: any) {
100
+ handleToast({
101
+ title: t('settings repair failed'),
102
+ description: err.message,
103
+ });
104
+ }
105
+ };
106
+
107
+ return (
108
+ <Settings.Root>
109
+ <Settings.Section title={t('settings title', { ns: meta.id })}>
110
+ <Settings.Group>
111
+ <Settings.ItemInput title={t('settings wireframe')}>
112
+ <Input.Switch
113
+ checked={settings.wireframe}
114
+ onCheckedChange={(checked) => onSettingsChange((s) => ({ ...s, wireframe: !!checked }))}
115
+ />
116
+ </Settings.ItemInput>
117
+ <Settings.ItemInput title={t('settings download diagnostics')}>
118
+ <IconButton
119
+ icon='ph--download-simple--regular'
120
+ iconOnly
121
+ label={t('settings download diagnostics')}
122
+ onClick={handleDownload}
123
+ />
124
+ </Settings.ItemInput>
125
+ <Settings.ItemInput title={t('settings download logs')}>
126
+ <IconButton
127
+ icon='ph--download-simple--regular'
128
+ iconOnly
129
+ label={t('settings download logs')}
130
+ onClick={handleDownloadLogs}
131
+ />
132
+ </Settings.ItemInput>
133
+ <Settings.ItemInput title={t('settings repair')}>
134
+ <IconButton
135
+ icon='ph--first-aid-kit--regular'
136
+ iconOnly
137
+ label={t('settings repair')}
138
+ onClick={handleRepair}
139
+ />
140
+ </Settings.ItemInput>
141
+
142
+ {/* TODO(burdon): Move to layout? */}
143
+ {toast && (
144
+ <Toast.Root>
145
+ <Toast.Body>
146
+ <Toast.Title>
147
+ <Icon icon='ph--gift--duotone' size={5} classNames='inline mr-1' />
148
+ <span>{toast.title}</span>
149
+ </Toast.Title>
150
+ {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
151
+ </Toast.Body>
152
+ </Toast.Root>
153
+ )}
154
+
155
+ <Settings.ItemInput title={t('settings choose storage adaptor')}>
156
+ <Select.Root
157
+ value={
158
+ Object.entries(StorageAdapters).find(
159
+ ([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
160
+ )?.[0]
161
+ }
162
+ onValueChange={(value) => {
163
+ if (confirm(t('settings storage adapter changed alert'))) {
164
+ updateConfig(
165
+ storageConfig,
166
+ setStorageConfig,
167
+ ['runtime', 'client', 'storage', 'dataStore'],
168
+ StorageAdapters[value as keyof typeof StorageAdapters],
169
+ );
170
+ }
171
+ }}
172
+ >
173
+ <Select.TriggerButton placeholder={t('settings data store label')} />
174
+ <Select.Portal>
175
+ <Select.Content>
176
+ <Select.Viewport>
177
+ {Object.keys(StorageAdapters).map((key) => (
178
+ <Select.Option key={key} value={key}>
179
+ {t(`settings storage adaptor ${key} label`)}
180
+ </Select.Option>
181
+ ))}
182
+ </Select.Viewport>
183
+ <Select.Arrow />
184
+ </Select.Content>
185
+ </Select.Portal>
186
+ </Select.Root>
187
+ </Settings.ItemInput>
188
+ </Settings.Group>
189
+ </Settings.Section>
190
+ </Settings.Root>
191
+ );
192
+ };
193
+
194
+ const updateConfig = (config: ConfigProto, setConfig: (newConfig: ConfigProto) => void, path: string[], value: any) => {
195
+ const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
196
+ setDeep(storageConfigCopy, path, value);
197
+ setConfig(storageConfigCopy);
198
+ queueMicrotask(async () => {
199
+ await SaveConfig(storageConfigCopy);
200
+ });
201
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { DebugSettings } from './DebugSettings';
6
+
7
+ export default DebugSettings;
@@ -0,0 +1,60 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useState } from 'react';
6
+
7
+ import { useCapability } from '@dxos/app-framework/ui';
8
+ import { useLayout } from '@dxos/app-toolkit/ui';
9
+ import { ObjectsTree } from '@dxos/devtools';
10
+ import { type Database, Filter, Query } from '@dxos/echo';
11
+ import type { ObjectId } from '@dxos/keys';
12
+ import { ClientCapabilities } from '@dxos/plugin-client';
13
+ import { parseId, useQuery } from '@dxos/react-client/echo';
14
+ import { Clipboard, Grid, Input, Panel, ScrollArea, Toolbar } from '@dxos/react-ui';
15
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
16
+
17
+ export const DebugSpaceObjectsPanel = () => {
18
+ const layout = useLayout();
19
+ const client = useCapability(ClientCapabilities.Client);
20
+ const { spaceId } = parseId(layout.workspace);
21
+ const space = spaceId ? client.spaces.get(spaceId) : undefined;
22
+ if (!space) {
23
+ return null;
24
+ }
25
+
26
+ return <DebugSpaceObjectsPanelMain database={space.db} />;
27
+ };
28
+
29
+ const DebugSpaceObjectsPanelMain = ({ database }: { database: Database.Database }) => {
30
+ const [selectedId, setSelectedId] = useState<ObjectId | null>(null);
31
+
32
+ const [selectedObject] = useQuery(
33
+ database,
34
+ selectedId ? Query.select(Filter.id(selectedId)) : Query.select(Filter.nothing()),
35
+ );
36
+
37
+ return (
38
+ <Clipboard.Provider>
39
+ <Panel.Root>
40
+ <Panel.Toolbar asChild>
41
+ <Toolbar.Root>
42
+ <Input.Root>
43
+ <Input.TextInput disabled placeholder='Search...' />
44
+ </Input.Root>
45
+ </Toolbar.Root>
46
+ </Panel.Toolbar>
47
+ <Panel.Content asChild>
48
+ <Grid rows={2} classNames='divide-y divide-separator'>
49
+ <ScrollArea.Root>
50
+ <ScrollArea.Viewport>
51
+ <ObjectsTree db={database} onSelect={(entity) => setSelectedId(entity.id)} />
52
+ </ScrollArea.Viewport>
53
+ </ScrollArea.Root>
54
+ {selectedObject && <Json classNames='p-1' data={selectedObject} />}
55
+ </Grid>
56
+ </Panel.Content>
57
+ </Panel.Root>
58
+ </Clipboard.Provider>
59
+ );
60
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { DebugSpaceObjectsPanel } from './DebugSpaceObjectsPanel';
6
+
7
+ export default DebugSpaceObjectsPanel;
@@ -59,7 +59,7 @@ const _timer = (cb: (err?: Error) => void, options?: { min?: number; max?: numbe
59
59
  // TODO(burdon): Integrate with Sentry?
60
60
  const ErrorIndicator = () => {
61
61
  const [, forceUpdate] = useState({});
62
- const errorRef = useRef<Error>();
62
+ const errorRef = useRef<Error>(null);
63
63
  useEffect(() => {
64
64
  const errorListener = (event: any) => {
65
65
  const error: Error = event.error ?? event.reason;
@@ -83,7 +83,7 @@ const ErrorIndicator = () => {
83
83
  }, []);
84
84
 
85
85
  const handleReset = () => {
86
- errorRef.current = undefined;
86
+ errorRef.current = null;
87
87
  forceUpdate({});
88
88
  };
89
89
 
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { DebugStatus } from './DebugStatus';
6
+
7
+ export default DebugStatus;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Surface } from '@dxos/app-framework';
7
+ import { Surface } from '@dxos/app-framework/ui';
8
8
  import { StatsPanel, useStats } from '@dxos/devtools';
9
9
 
10
10
  export const DevtoolsOverviewContainer = () => {
@@ -12,9 +12,7 @@ export const DevtoolsOverviewContainer = () => {
12
12
 
13
13
  return (
14
14
  <StatsPanel stats={stats} onRefresh={refreshStats}>
15
- <Surface role='devtools-overview' />
15
+ <Surface.Surface role='devtools-overview' />
16
16
  </StatsPanel>
17
17
  );
18
18
  };
19
-
20
- export default DevtoolsOverviewContainer;
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { DevtoolsOverviewContainer } from './DevtoolsOverviewContainer';
6
+
7
+ export default DevtoolsOverviewContainer;
@@ -0,0 +1,127 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo, useState } from 'react';
6
+
7
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
8
+ import { ComputeGraph } from '@dxos/conductor';
9
+ import { Filter, Obj, type Type } from '@dxos/echo';
10
+ import { Markdown } from '@dxos/plugin-markdown/types';
11
+ import { Sheet } from '@dxos/plugin-sheet/types';
12
+ import { Diagram } from '@dxos/plugin-sketch/types';
13
+ import { useClient } from '@dxos/react-client';
14
+ import { type Space } from '@dxos/react-client/echo';
15
+ import { IconButton, Input, Panel, ScrollArea, Toolbar, useAsyncEffect } from '@dxos/react-ui';
16
+ import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
17
+ import { Organization, Person, Task } from '@dxos/types';
18
+ import { jsonKeyReplacer, sortKeys } from '@dxos/util';
19
+
20
+ import { type ObjectGenerator, SchemaTable, createGenerator, generator, staticGenerators } from '../../components';
21
+
22
+ export type SpaceGeneratorProps = {
23
+ space: Space;
24
+ onCreateObjects?: (objects: Obj.Unknown[]) => void;
25
+ };
26
+
27
+ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
28
+ const { invokePromise } = useOperationInvoker();
29
+ const client = useClient();
30
+ const staticTypes = [Markdown.Document, Diagram.Diagram, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
31
+ const recordTypes: Type.AnyObj[] = [Organization.Organization, Person.Person, Task.Task];
32
+ const [count, setCount] = useState(1);
33
+ const [info, setInfo] = useState<any>({});
34
+ const presets = useMemo(() => generator(), []);
35
+
36
+ // Register types.
37
+ useAsyncEffect(async () => {
38
+ await client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
39
+ }, [client]);
40
+
41
+ // Create type generators.
42
+ const typeMap = useMemo(() => {
43
+ const recordGenerators = new Map<string, ObjectGenerator<any>>(
44
+ recordTypes.map((type) => [type.typename, createGenerator(client, invokePromise, type)]),
45
+ );
46
+
47
+ return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
48
+ }, [client, recordTypes, invokePromise]);
49
+
50
+ // Query space to get info.
51
+ const updateInfo = async () => {
52
+ // Create schema map.
53
+ const echoSchema = await space.db.schemaRegistry.query().run();
54
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
55
+
56
+ // Create object map.
57
+ const objects = await space.db.query(Filter.everything()).run();
58
+ const objectMap = sortKeys(
59
+ objects.reduce<Record<string, number>>((map, obj) => {
60
+ const type = Obj.getTypename(obj);
61
+ if (type) {
62
+ const count = map[type] ?? 0;
63
+ map[type] = count + 1;
64
+ }
65
+
66
+ return map;
67
+ }, {}),
68
+ );
69
+
70
+ setInfo({
71
+ schema: {
72
+ static: staticSchema.length,
73
+ mutable: echoSchema.length,
74
+ },
75
+ objects: objectMap,
76
+ });
77
+ };
78
+
79
+ useAsyncEffect(updateInfo, [space]);
80
+
81
+ const handleCreateData = useCallback(
82
+ async (typename: string) => {
83
+ const constructor = typeMap.get(typename);
84
+ if (constructor) {
85
+ // TODO(burdon): Input to specify number of objects.
86
+ await constructor(space, count, onCreateObjects);
87
+ await updateInfo();
88
+ }
89
+ },
90
+ [typeMap, count],
91
+ );
92
+
93
+ return (
94
+ <Panel.Root>
95
+ <Panel.Toolbar asChild>
96
+ <Toolbar.Root>
97
+ <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
98
+ <Toolbar.Separator />
99
+ <Input.Root>
100
+ <Input.TextInput
101
+ type='number'
102
+ placeholder='Count'
103
+ classNames='w-[4rem] text-right'
104
+ min={1}
105
+ max={100}
106
+ size={8}
107
+ value={count}
108
+ onChange={(event) => setCount(parseInt(event.target.value))}
109
+ />
110
+ </Input.Root>
111
+ </Toolbar.Root>
112
+ </Panel.Toolbar>
113
+ <Panel.Content asChild>
114
+ <ScrollArea.Root thin orientation='vertical'>
115
+ <ScrollArea.Viewport classNames='gap-4 divide-y divide-subdued-separator'>
116
+ <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
117
+ <SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
118
+ <SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
119
+ <SyntaxHighlighter language='json' classNames='text-xs'>
120
+ {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
121
+ </SyntaxHighlighter>
122
+ </ScrollArea.Viewport>
123
+ </ScrollArea.Root>
124
+ </Panel.Content>
125
+ </Panel.Root>
126
+ );
127
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { SpaceGenerator } from './SpaceGenerator';
6
+
7
+ export default SpaceGenerator;
@@ -5,32 +5,32 @@
5
5
  import React from 'react';
6
6
  import { useResizeDetector } from 'react-resize-detector';
7
7
 
8
- import { type Obj } from '@dxos/echo';
9
- import { fullyQualifiedId } from '@dxos/react-client/echo';
8
+ import { Obj } from '@dxos/echo';
10
9
  import { type ThemedClassName } from '@dxos/react-ui';
11
10
  import { useAttentionAttributes } from '@dxos/react-ui-attention';
12
11
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
13
- import { mx } from '@dxos/react-ui-theme';
12
+ import { mx } from '@dxos/ui-theme';
14
13
 
15
14
  // TODO(burdon): Create generic container with wireframe mode.
16
15
  export type WireframeProps = ThemedClassName<{
16
+ object: Obj.Unknown;
17
17
  label?: string;
18
- object: Obj.Any;
19
18
  }>;
20
19
 
21
20
  // TODO(burdon): Make focusable and attendable with input.
22
21
  export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
23
- const attentionAttrs = useAttentionAttributes(fullyQualifiedId(object));
22
+ const attentionAttrs = useAttentionAttributes(Obj.getDXN(object).toString());
24
23
  const { width, height, ref } = useResizeDetector();
24
+
25
25
  return (
26
- <div ref={ref} className={mx('relative grow min-bs-96', classNames)} {...attentionAttrs}>
26
+ <div ref={ref} className={mx('relative grow min-h-96', classNames)} {...attentionAttrs}>
27
27
  <div className='absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono'>
28
28
  <div className='flex justify-between'>
29
29
  <div>{label}</div>
30
30
  <div>{`[${width}x${height}]`}</div>
31
31
  </div>
32
32
  {object && (
33
- <SyntaxHighlighter language='json' classNames='flex w-full text-xs opacity-75 rounded'>
33
+ <SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded-sm'>
34
34
  {JSON.stringify(object, undefined, 2)}
35
35
  </SyntaxHighlighter>
36
36
  )}
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Wireframe } from './Wireframe';
6
+
7
+ export default Wireframe;
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type ComponentType, lazy } from 'react';
6
+
7
+ export const DebugGraph: ComponentType<any> = lazy(() => import('./DebugGraph'));
8
+ export const DebugObjectPanel: ComponentType<any> = lazy(() => import('./DebugObjectPanel'));
9
+ export const DebugSettings: ComponentType<any> = lazy(() => import('./DebugSettings'));
10
+ export const DebugStatus: ComponentType<any> = lazy(() => import('./DebugStatus'));
11
+ export const DevtoolsOverviewContainer: ComponentType<any> = lazy(() => import('./DevtoolsOverviewContainer'));
12
+ export const SpaceGenerator: ComponentType<any> = lazy(() => import('./SpaceGenerator'));
13
+ export const Wireframe: ComponentType<any> = lazy(() => import('./Wireframe'));
14
+ export const DebugSpaceObjectsPanel: ComponentType<any> = lazy(() => import('./DebugSpaceObjectsPanel'));
package/src/meta.ts CHANGED
@@ -2,15 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
8
-
9
- export const meta: PluginMeta = {
10
- id: DEBUG_PLUGIN,
8
+ export const meta: Plugin.Meta = {
9
+ id: 'dxos.org/plugin/debug',
11
10
  name: 'Debug',
12
- description:
13
- 'The debug plugin is useful for troubleshooting inside of Composer. You can also use the Debug plugin to create test data inside of sheets or tables or explore pre-built automations. Non-technical users will likely not spend much time here, but this plugin is invaluable for developers and technical users.',
11
+ description: trim`
12
+ Comprehensive developer toolkit for troubleshooting applications, generating test data, and exploring automation capabilities.
13
+ Inspect objects, monitor events, and debug plugin behavior in real-time.
14
+ `,
14
15
  icon: 'ph--bug--regular',
15
16
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
16
17
  screenshots: ['https://dxos.network/plugin-details-debug-dark.png'],
@@ -11,17 +11,21 @@ export const translations = [
11
11
  'en-US': {
12
12
  [meta.id]: {
13
13
  'plugin name': 'Debug',
14
+ 'settings title': 'Debug settings',
14
15
  'mutation count': 'Number of mutations',
15
16
  'mutation period': 'Mutation period',
16
17
  'open devtools label': 'Open DevTools',
17
18
  'devtools label': 'DevTools',
18
- 'devtools overview label': 'DevTools Stats',
19
+ 'devtools overview label': 'Stats',
20
+ 'space objects label': 'Database',
19
21
  'debug label': 'Debug',
22
+ 'debug app graph label': 'App Graph',
20
23
  'settings show debug panel': 'Show Debug panel.',
21
24
  'settings show devtools panel': 'Show DevTools panel.',
22
25
  'settings wireframe': 'Show wireframes.',
23
26
  'settings repair': 'Run repair tool.',
24
27
  'settings download diagnostics': 'Download diagnostics.',
28
+ 'settings download logs': 'Download log buffer.',
25
29
  'settings uploaded': 'Uploaded to IPFS',
26
30
  'settings uploaded to clipboard': 'URL copied to clipboard.',
27
31
  'settings repair success': 'Repair succeeded',
package/src/types.ts CHANGED
@@ -2,11 +2,15 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import { type Atom } from '@effect-atom/atom-react';
6
+ import * as Schema from 'effect/Schema';
6
7
  import { type Context, createContext } from 'react';
7
8
 
9
+ import { Capability } from '@dxos/app-framework';
8
10
  import type { TimerCallback, TimerOptions } from '@dxos/async';
9
11
 
12
+ import { meta } from './meta';
13
+
10
14
  export type DebugContextType = {
11
15
  running: boolean;
12
16
  start: (cb: TimerCallback, options: TimerOptions) => void;
@@ -27,6 +31,10 @@ export const DebugSettingsSchema = Schema.mutable(
27
31
 
28
32
  export interface DebugSettingsProps extends Schema.Schema.Type<typeof DebugSettingsSchema> {}
29
33
 
34
+ export namespace DebugCapabilities {
35
+ export const Settings = Capability.make<Atom.Writable<DebugSettingsProps>>(`${meta.id}/capability/settings`);
36
+ }
37
+
30
38
  export namespace Devtools {
31
39
  // TODO(wittjosiah): Cannot use slashes in ids until we have a router which decouples ids from url paths.
32
40
  export const id = 'dxos.org.plugin.debug.devtools';