@dxos/plugin-debug 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055

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 (189) 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-KXVFOGU6.mjs +35 -0
  4. package/dist/lib/browser/DebugObjectPanel-KXVFOGU6.mjs.map +7 -0
  5. package/dist/lib/browser/DebugSettings-DQXOXF6A.mjs +183 -0
  6. package/dist/lib/browser/DebugSettings-DQXOXF6A.mjs.map +7 -0
  7. package/dist/lib/browser/DebugSpaceObjectsPanel-SIK72DXV.mjs +45 -0
  8. package/dist/lib/browser/DebugSpaceObjectsPanel-SIK72DXV.mjs.map +7 -0
  9. package/dist/lib/browser/DebugStatus-FWF3YFBA.mjs +124 -0
  10. package/dist/lib/browser/DebugStatus-FWF3YFBA.mjs.map +7 -0
  11. package/dist/lib/browser/DevtoolsOverviewContainer-TBTTPXVF.mjs +24 -0
  12. package/dist/lib/browser/DevtoolsOverviewContainer-TBTTPXVF.mjs.map +7 -0
  13. package/dist/lib/browser/{SpaceGenerator-46TAISVE.mjs → SpaceGenerator-UUQS6TYY.mjs} +455 -425
  14. package/dist/lib/browser/SpaceGenerator-UUQS6TYY.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-FBLOEOH5.mjs +594 -0
  18. package/dist/lib/browser/app-graph-builder-FBLOEOH5.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-Q37TZWW5.mjs} +12 -2
  20. package/dist/lib/browser/chunk-Q37TZWW5.mjs.map +7 -0
  21. package/dist/lib/browser/{chunk-WZFZ4ESO.mjs → chunk-ZOM2FBHQ.mjs} +2 -2
  22. package/dist/lib/browser/chunk-ZOM2FBHQ.mjs.map +7 -0
  23. package/dist/lib/browser/index.mjs +40 -38
  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-KBHXEMRS.mjs +18 -0
  27. package/dist/lib/browser/react-context-KBHXEMRS.mjs.map +7 -0
  28. package/dist/lib/browser/react-surface-HYT4HKZX.mjs +428 -0
  29. package/dist/lib/browser/react-surface-HYT4HKZX.mjs.map +7 -0
  30. package/dist/lib/browser/settings-XXFUM3QJ.mjs +32 -0
  31. package/dist/lib/browser/settings-XXFUM3QJ.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/index.d.ts +2 -2
  58. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
  59. package/dist/types/src/components/SpaceGenerator/presets.d.ts +1 -4
  60. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  61. package/dist/types/src/components/index.d.ts +2 -10
  62. package/dist/types/src/components/index.d.ts.map +1 -1
  63. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
  64. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
  65. package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
  66. package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
  67. package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +2 -2
  68. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
  69. package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
  70. package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
  71. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts +10 -0
  72. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts.map +1 -0
  73. package/dist/types/src/containers/DebugSettings/index.d.ts +3 -0
  74. package/dist/types/src/containers/DebugSettings/index.d.ts.map +1 -0
  75. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
  76. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
  77. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
  78. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
  79. package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
  80. package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
  81. package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
  82. package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
  83. package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
  84. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
  85. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
  86. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +15 -0
  87. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
  88. package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
  89. package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
  90. package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +1 -1
  91. package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
  92. package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
  93. package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
  94. package/dist/types/src/containers/index.d.ts +10 -0
  95. package/dist/types/src/containers/index.d.ts.map +1 -0
  96. package/dist/types/src/meta.d.ts +2 -2
  97. package/dist/types/src/meta.d.ts.map +1 -1
  98. package/dist/types/src/translations.d.ts +2 -0
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types.d.ts +39 -34
  101. package/dist/types/src/types.d.ts.map +1 -1
  102. package/dist/types/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +75 -70
  104. package/src/DebugPlugin.tsx +27 -31
  105. package/src/capabilities/app-graph-builder/app-graph-builder.ts +419 -0
  106. package/src/capabilities/app-graph-builder/index.ts +7 -0
  107. package/src/capabilities/index.ts +4 -6
  108. package/src/capabilities/react-context/index.ts +7 -0
  109. package/src/capabilities/react-context/react-context.tsx +25 -0
  110. package/src/capabilities/react-surface/index.ts +7 -0
  111. package/src/capabilities/react-surface/react-surface.tsx +414 -0
  112. package/src/capabilities/settings/index.ts +7 -0
  113. package/src/capabilities/settings/settings.ts +31 -0
  114. package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +2 -2
  115. package/src/components/SchemaTable/index.ts +5 -0
  116. package/src/components/SpaceGenerator/ObjectGenerator.tsx +19 -21
  117. package/src/components/SpaceGenerator/index.ts +2 -3
  118. package/src/components/SpaceGenerator/presets.ts +196 -75
  119. package/src/components/index.ts +2 -10
  120. package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
  121. package/src/containers/DebugGraph/index.ts +7 -0
  122. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +47 -0
  123. package/src/containers/DebugObjectPanel/index.ts +7 -0
  124. package/src/{components → containers/DebugSettings}/DebugSettings.tsx +51 -25
  125. package/src/containers/DebugSettings/index.ts +7 -0
  126. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +55 -0
  127. package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
  128. package/src/{components → containers/DebugStatus}/DebugStatus.tsx +40 -16
  129. package/src/containers/DebugStatus/index.ts +7 -0
  130. package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
  131. package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
  132. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +130 -0
  133. package/src/containers/SpaceGenerator/index.ts +7 -0
  134. package/src/{components → containers/Wireframe}/Wireframe.tsx +4 -4
  135. package/src/containers/Wireframe/index.ts +7 -0
  136. package/src/containers/index.ts +14 -0
  137. package/src/meta.ts +3 -3
  138. package/src/translations.ts +2 -0
  139. package/src/types.ts +9 -2
  140. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  141. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  142. package/dist/lib/browser/DevtoolsOverviewContainer-JXVZVPHN.mjs +0 -25
  143. package/dist/lib/browser/DevtoolsOverviewContainer-JXVZVPHN.mjs.map +0 -7
  144. package/dist/lib/browser/SpaceGenerator-46TAISVE.mjs.map +0 -7
  145. package/dist/lib/browser/app-graph-builder-CRH2HJKT.mjs +0 -588
  146. package/dist/lib/browser/app-graph-builder-CRH2HJKT.mjs.map +0 -7
  147. package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
  148. package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +0 -7
  149. package/dist/lib/browser/react-context-P2YDWEWI.mjs +0 -16
  150. package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +0 -7
  151. package/dist/lib/browser/react-surface-2SNVZDEA.mjs +0 -774
  152. package/dist/lib/browser/react-surface-2SNVZDEA.mjs.map +0 -7
  153. package/dist/lib/browser/settings-SQXR3OAH.mjs +0 -22
  154. package/dist/lib/browser/settings-SQXR3OAH.mjs.map +0 -7
  155. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  156. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  157. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  158. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  159. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  160. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  161. package/dist/types/src/capabilities/settings.d.ts +0 -4
  162. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  163. package/dist/types/src/components/Container.d.ts +0 -5
  164. package/dist/types/src/components/Container.d.ts.map +0 -1
  165. package/dist/types/src/components/DebugGraph.d.ts +0 -8
  166. package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
  167. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  168. package/dist/types/src/components/DebugSettings.d.ts +0 -6
  169. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  170. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  171. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  172. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  173. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
  174. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
  175. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
  176. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  177. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  178. package/src/capabilities/app-graph-builder.ts +0 -431
  179. package/src/capabilities/react-context.tsx +0 -16
  180. package/src/capabilities/react-surface.tsx +0 -418
  181. package/src/capabilities/settings.ts +0 -19
  182. package/src/components/Container.tsx +0 -15
  183. package/src/components/DebugGraph.tsx +0 -14
  184. package/src/components/DebugObjectPanel.tsx +0 -33
  185. package/src/components/DevtoolsOverviewContainer.tsx +0 -20
  186. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
  187. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
  188. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  189. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
@@ -4,17 +4,17 @@
4
4
 
5
5
  import React, { useEffect, useState } from 'react';
6
6
 
7
- import { Capabilities } from '@dxos/app-framework';
8
- import { useCapabilities } from '@dxos/app-framework/react';
7
+ import { useCapabilities } from '@dxos/app-framework/ui';
8
+ import { AppCapabilities, getPersonalSpace } from '@dxos/app-toolkit';
9
9
  import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
10
- import { log } from '@dxos/log';
10
+ import { type LogBuffer, log } from '@dxos/log';
11
11
  import { useClient } from '@dxos/react-client';
12
12
  import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
13
- import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
13
+ import { Settings } from '@dxos/react-ui-form';
14
14
  import { setDeep } from '@dxos/util';
15
15
 
16
- import { meta } from '../meta';
17
- import { type DebugSettingsProps } from '../types';
16
+ import { meta } from '../../meta';
17
+ import { type DebugSettingsProps } from '../../types';
18
18
 
19
19
  type Toast = {
20
20
  title: string;
@@ -26,14 +26,20 @@ const StorageAdapters = {
26
26
  idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
27
27
  } as const;
28
28
 
29
- export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) => {
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) => {
30
36
  const { t } = useTranslation(meta.id);
31
37
  const [toast, setToast] = useState<Toast>();
32
38
  const client = useClient();
33
39
  const download = useFileDownload();
34
40
  // TODO(mykola): Get updates from other places that change Config.
35
41
  const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
36
- const [upload] = useCapabilities(Capabilities.FileUploader);
42
+ const [upload] = useCapabilities(AppCapabilities.FileUploader);
37
43
 
38
44
  useEffect(() => {
39
45
  void Storage().then((config) => setStorageConfig(config));
@@ -54,7 +60,12 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
54
60
  download(file, fileName);
55
61
 
56
62
  if (upload) {
57
- const info = await upload(client.spaces.default, new File([file], fileName));
63
+ const personalSpace = getPersonalSpace(client);
64
+ if (!personalSpace) {
65
+ log.error('no personal space available for upload');
66
+ return;
67
+ }
68
+ const info = await upload(personalSpace.db, new File([file], fileName));
58
69
  if (!info) {
59
70
  log.error('diagnostics failed to upload to IPFS');
60
71
  return;
@@ -75,6 +86,13 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
75
86
  }
76
87
  };
77
88
 
89
+ const handleDownloadLogs = () => {
90
+ const ndjson = logBuffer.serialize();
91
+ const file = new Blob([ndjson], { type: 'application/x-ndjson' });
92
+ const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
93
+ download(file, fileName);
94
+ };
95
+
78
96
  const handleRepair = async () => {
79
97
  try {
80
98
  const info = await client.repair();
@@ -92,38 +110,46 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
92
110
  };
93
111
 
94
112
  return (
95
- <ControlPage>
96
- <ControlSection title={t('settings title', { ns: meta.id })}>
97
- <ControlGroup>
98
- <ControlItemInput title={t('settings wireframe')}>
113
+ <Settings.Root>
114
+ <Settings.Section title={t('settings title', { ns: meta.id })}>
115
+ <Settings.Group>
116
+ <Settings.ItemInput title={t('settings wireframe')}>
99
117
  <Input.Switch
100
118
  checked={settings.wireframe}
101
- onCheckedChange={(checked) => (settings.wireframe = !!checked)}
119
+ onCheckedChange={(checked) => onSettingsChange((s) => ({ ...s, wireframe: !!checked }))}
102
120
  />
103
- </ControlItemInput>
104
- <ControlItemInput title={t('settings download diagnostics')}>
121
+ </Settings.ItemInput>
122
+ <Settings.ItemInput title={t('settings download diagnostics')}>
105
123
  <IconButton
106
124
  icon='ph--download-simple--regular'
107
125
  iconOnly
108
126
  label={t('settings download diagnostics')}
109
127
  onClick={handleDownload}
110
128
  />
111
- </ControlItemInput>
112
- <ControlItemInput title={t('settings repair')}>
129
+ </Settings.ItemInput>
130
+ <Settings.ItemInput title={t('settings download logs')}>
131
+ <IconButton
132
+ icon='ph--download-simple--regular'
133
+ iconOnly
134
+ label={t('settings download logs')}
135
+ onClick={handleDownloadLogs}
136
+ />
137
+ </Settings.ItemInput>
138
+ <Settings.ItemInput title={t('settings repair')}>
113
139
  <IconButton
114
140
  icon='ph--first-aid-kit--regular'
115
141
  iconOnly
116
142
  label={t('settings repair')}
117
143
  onClick={handleRepair}
118
144
  />
119
- </ControlItemInput>
145
+ </Settings.ItemInput>
120
146
 
121
147
  {/* TODO(burdon): Move to layout? */}
122
148
  {toast && (
123
149
  <Toast.Root>
124
150
  <Toast.Body>
125
151
  <Toast.Title>
126
- <Icon icon='ph--gift--duotone' size={5} classNames='inline mr-1' />
152
+ <Icon icon='ph--gift--duotone' classNames='inline mr-1' />
127
153
  <span>{toast.title}</span>
128
154
  </Toast.Title>
129
155
  {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
@@ -131,7 +157,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
131
157
  </Toast.Root>
132
158
  )}
133
159
 
134
- <ControlItemInput title={t('settings choose storage adaptor')}>
160
+ <Settings.ItemInput title={t('settings choose storage adaptor')}>
135
161
  <Select.Root
136
162
  value={
137
163
  Object.entries(StorageAdapters).find(
@@ -163,10 +189,10 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
163
189
  </Select.Content>
164
190
  </Select.Portal>
165
191
  </Select.Root>
166
- </ControlItemInput>
167
- </ControlGroup>
168
- </ControlSection>
169
- </ControlPage>
192
+ </Settings.ItemInput>
193
+ </Settings.Group>
194
+ </Settings.Section>
195
+ </Settings.Root>
170
196
  );
171
197
  };
172
198
 
@@ -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,55 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useState } from 'react';
6
+
7
+ import { ObjectsTree } from '@dxos/devtools';
8
+ import { type Database, Filter, Query } from '@dxos/echo';
9
+ import type { ObjectId } from '@dxos/keys';
10
+ import { useActiveSpace } from '@dxos/plugin-space';
11
+ import { useQuery } from '@dxos/react-client/echo';
12
+ import { Clipboard, Grid, Input, Panel, ScrollArea, Toolbar } from '@dxos/react-ui';
13
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
14
+
15
+ export const DebugSpaceObjectsPanel = () => {
16
+ const space = useActiveSpace();
17
+ if (!space) {
18
+ return null;
19
+ }
20
+
21
+ return <DebugSpaceObjectsPanelMain database={space.db} />;
22
+ };
23
+
24
+ const DebugSpaceObjectsPanelMain = ({ database }: { database: Database.Database }) => {
25
+ const [selectedId, setSelectedId] = useState<ObjectId | null>(null);
26
+
27
+ const [selectedObject] = useQuery(
28
+ database,
29
+ selectedId ? Query.select(Filter.id(selectedId)) : Query.select(Filter.nothing()),
30
+ );
31
+
32
+ return (
33
+ <Clipboard.Provider>
34
+ <Panel.Root>
35
+ <Panel.Toolbar asChild>
36
+ <Toolbar.Root>
37
+ <Input.Root>
38
+ <Input.TextInput disabled placeholder='Search...' />
39
+ </Input.Root>
40
+ </Toolbar.Root>
41
+ </Panel.Toolbar>
42
+ <Panel.Content asChild>
43
+ <Grid rows={2} classNames='divide-y divide-separator'>
44
+ <ScrollArea.Root>
45
+ <ScrollArea.Viewport>
46
+ <ObjectsTree db={database} onSelect={(entity) => setSelectedId(entity.id)} />
47
+ </ScrollArea.Viewport>
48
+ </ScrollArea.Root>
49
+ {selectedObject && <Json classNames='p-1' data={selectedObject} />}
50
+ </Grid>
51
+ </Panel.Content>
52
+ </Panel.Root>
53
+ </Clipboard.Provider>
54
+ );
55
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { DebugSpaceObjectsPanel } from './DebugSpaceObjectsPanel';
6
+
7
+ export default DebugSpaceObjectsPanel;
@@ -9,7 +9,7 @@ import { useActiveSpace } from '@dxos/plugin-space';
9
9
  import { StatusBar } from '@dxos/plugin-status-bar';
10
10
  import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
11
11
  import { useNetworkStatus } from '@dxos/react-client/mesh';
12
- import { Icon } from '@dxos/react-ui';
12
+ import { IconButton } from '@dxos/react-ui';
13
13
 
14
14
  const styles = {
15
15
  success: 'text-sky-300 dark:text-green-700',
@@ -89,14 +89,20 @@ const ErrorIndicator = () => {
89
89
 
90
90
  if (errorRef.current) {
91
91
  return (
92
- <StatusBar.Button title={errorRef.current.message} onClick={handleReset}>
93
- <Icon icon='ph--warning-circle--duotone' size={4} classNames={styles.error} />
94
- </StatusBar.Button>
92
+ <StatusBar.Item>
93
+ <IconButton
94
+ icon='ph--warning-circle--duotone'
95
+ iconOnly
96
+ label={errorRef.current.message}
97
+ classNames={styles.error}
98
+ onClick={handleReset}
99
+ />
100
+ </StatusBar.Item>
95
101
  );
96
102
  } else {
97
103
  return (
98
- <StatusBar.Item title='No errors.'>
99
- <Icon icon='ph--check--regular' size={4} />
104
+ <StatusBar.Item>
105
+ <IconButton variant='ghost' icon='ph--check--regular' iconOnly label='No errors.' />
100
106
  </StatusBar.Item>
101
107
  );
102
108
  }
@@ -114,14 +120,20 @@ const SwarmIndicator = () => {
114
120
 
115
121
  if (state === 0) {
116
122
  return (
117
- <StatusBar.Item title='Connected to swarm.'>
118
- <Icon icon='ph--lightning--regular' size={4} />
123
+ <StatusBar.Item>
124
+ <IconButton variant='ghost' icon='ph--lightning--regular' iconOnly label='Connected to swarm.' />
119
125
  </StatusBar.Item>
120
126
  );
121
127
  } else {
122
128
  return (
123
- <StatusBar.Item title='Disconnected from swarm.'>
124
- <Icon icon='ph--lightning-slash--regular' size={4} classNames={styles.warning} />
129
+ <StatusBar.Item>
130
+ <IconButton
131
+ variant='ghost'
132
+ icon='ph--lightning-slash--regular'
133
+ iconOnly
134
+ label='Disconnected from swarm.'
135
+ classNames={styles.warning}
136
+ />
125
137
  </StatusBar.Item>
126
138
  );
127
139
  }
@@ -156,21 +168,33 @@ const SavingIndicator = () => {
156
168
  switch (state) {
157
169
  case 2:
158
170
  return (
159
- <StatusBar.Item title='Edit not saved.'>
160
- <Icon icon='ph--circle--duotone' size={4} classNames={styles.warning} />
171
+ <StatusBar.Item>
172
+ <IconButton
173
+ variant='ghost'
174
+ icon='ph--circle--duotone'
175
+ iconOnly
176
+ label='Edit not saved.'
177
+ classNames={styles.warning}
178
+ />
161
179
  </StatusBar.Item>
162
180
  );
163
181
  case 1:
164
182
  return (
165
- <StatusBar.Item title='Saving...'>
166
- <Icon icon='ph--circle--duotone' size={4} classNames={styles.success} />
183
+ <StatusBar.Item>
184
+ <IconButton
185
+ variant='ghost'
186
+ icon='ph--circle--duotone'
187
+ iconOnly
188
+ label='Saving...'
189
+ classNames={styles.success}
190
+ />
167
191
  </StatusBar.Item>
168
192
  );
169
193
  case 0:
170
194
  default:
171
195
  return (
172
- <StatusBar.Item title='Modified indicator.'>
173
- <Icon icon='ph--circle--duotone' size={4} />
196
+ <StatusBar.Item>
197
+ <IconButton variant='ghost' icon='ph--circle--duotone' iconOnly label='Modified indicator.' />
174
198
  </StatusBar.Item>
175
199
  );
176
200
  }
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { DebugStatus } from './DebugStatus';
6
+
7
+ export default DebugStatus;
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Surface } from '@dxos/app-framework/ui';
8
+ import { StatsPanel, useStats } from '@dxos/devtools';
9
+
10
+ export const DevtoolsOverviewContainer = () => {
11
+ const [stats, refreshStats] = useStats();
12
+ const surfaceProfilerStats = Surface.useProfilerStats();
13
+ const clearSurfaceProfiler = Surface.useProfilerClear();
14
+
15
+ return (
16
+ <StatsPanel
17
+ stats={stats}
18
+ surfaceProfilerStats={surfaceProfilerStats}
19
+ onRefresh={refreshStats}
20
+ onClearSurfaceProfiler={clearSurfaceProfiler}
21
+ >
22
+ <Surface.Surface role='devtools-overview' />
23
+ </StatsPanel>
24
+ );
25
+ };
@@ -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,130 @@
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 { Sketch } 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 { composable, composableProps } from '@dxos/ui-theme';
19
+ import { jsonKeyReplacer, sortKeys } from '@dxos/util';
20
+
21
+ import { type ObjectGenerator, SchemaTable, createGenerator, generator, staticGenerators } from '../../components';
22
+
23
+ export type SpaceGeneratorProps = {
24
+ space: Space;
25
+ onCreateObjects?: (objects: Obj.Unknown[]) => void;
26
+ };
27
+
28
+ export const SpaceGenerator = composable<HTMLDivElement, SpaceGeneratorProps>(
29
+ ({ space, onCreateObjects, children, ...props }, forwardedRef) => {
30
+ const { invokePromise } = useOperationInvoker();
31
+ const client = useClient();
32
+ const staticTypes = [Markdown.Document, Sketch.Sketch, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
33
+ const recordTypes: Type.AnyObj[] = [Organization.Organization, Person.Person, Task.Task];
34
+ const [count, setCount] = useState(1);
35
+ const [info, setInfo] = useState<any>({});
36
+ const presets = useMemo(() => generator(), []);
37
+
38
+ // Register types.
39
+ useAsyncEffect(async () => {
40
+ await client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
41
+ }, [client]);
42
+
43
+ // Create type generators.
44
+ const typeMap = useMemo(() => {
45
+ const recordGenerators = new Map<string, ObjectGenerator<any>>(
46
+ recordTypes.map((type) => [type.typename, createGenerator(client, invokePromise, type)]),
47
+ );
48
+
49
+ return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
50
+ }, [client, recordTypes, invokePromise]);
51
+
52
+ // Query space to get info.
53
+ const updateInfo = async () => {
54
+ // Create schema map.
55
+ const echoSchema = await space.db.schemaRegistry.query().run();
56
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
57
+
58
+ // Create object map.
59
+ const objects = await space.db.query(Filter.everything()).run();
60
+ const objectMap = sortKeys(
61
+ objects.reduce<Record<string, number>>((map, obj) => {
62
+ const type = Obj.getTypename(obj);
63
+ if (type) {
64
+ const count = map[type] ?? 0;
65
+ map[type] = count + 1;
66
+ }
67
+
68
+ return map;
69
+ }, {}),
70
+ );
71
+
72
+ setInfo({
73
+ schema: {
74
+ static: staticSchema.length,
75
+ mutable: echoSchema.length,
76
+ },
77
+ objects: objectMap,
78
+ });
79
+ };
80
+
81
+ useAsyncEffect(updateInfo, [space]);
82
+
83
+ const handleCreateData = useCallback(
84
+ async (typename: string) => {
85
+ const constructor = typeMap.get(typename);
86
+ if (constructor) {
87
+ // TODO(burdon): Input to specify number of objects.
88
+ await constructor(space, count, onCreateObjects);
89
+ await updateInfo();
90
+ }
91
+ },
92
+ [typeMap, count],
93
+ );
94
+
95
+ return (
96
+ <Panel.Root {...composableProps(props)} ref={forwardedRef}>
97
+ <Panel.Toolbar asChild>
98
+ <Toolbar.Root>
99
+ <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
100
+ <Toolbar.Separator />
101
+ <Input.Root>
102
+ <Input.TextInput
103
+ type='number'
104
+ placeholder='Count'
105
+ classNames='w-[4rem] text-right'
106
+ min={1}
107
+ max={100}
108
+ size={8}
109
+ value={count}
110
+ onChange={(event) => setCount(parseInt(event.target.value))}
111
+ />
112
+ </Input.Root>
113
+ </Toolbar.Root>
114
+ </Panel.Toolbar>
115
+ <Panel.Content asChild>
116
+ <ScrollArea.Root thin orientation='vertical'>
117
+ <ScrollArea.Viewport classNames='gap-4 divide-y divide-subdued-separator'>
118
+ <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
119
+ <SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
120
+ <SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
121
+ <SyntaxHighlighter language='json' classNames='text-xs'>
122
+ {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
123
+ </SyntaxHighlighter>
124
+ </ScrollArea.Viewport>
125
+ </ScrollArea.Root>
126
+ </Panel.Content>
127
+ </Panel.Root>
128
+ );
129
+ },
130
+ );
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { SpaceGenerator } from './SpaceGenerator';
6
+
7
+ export default SpaceGenerator;
@@ -9,12 +9,12 @@ import { Obj } from '@dxos/echo';
9
9
  import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import { useAttentionAttributes } from '@dxos/react-ui-attention';
11
11
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
12
- import { mx } from '@dxos/react-ui-theme';
12
+ import { mx } from '@dxos/ui-theme';
13
13
 
14
14
  // TODO(burdon): Create generic container with wireframe mode.
15
15
  export type WireframeProps = ThemedClassName<{
16
+ object: Obj.Unknown;
16
17
  label?: string;
17
- object: Obj.Any;
18
18
  }>;
19
19
 
20
20
  // TODO(burdon): Make focusable and attendable with input.
@@ -23,14 +23,14 @@ export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
23
23
  const { width, height, ref } = useResizeDetector();
24
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='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,11 +2,11 @@
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
6
  import { trim } from '@dxos/util';
7
7
 
8
- export const meta: PluginMeta = {
9
- id: 'dxos.org/plugin/debug',
8
+ export const meta: Plugin.Meta = {
9
+ id: 'org.dxos.plugin.debug',
10
10
  name: 'Debug',
11
11
  description: trim`
12
12
  Comprehensive developer toolkit for troubleshooting applications, generating test data, and exploring automation capabilities.
@@ -17,6 +17,7 @@ export const translations = [
17
17
  'open devtools label': 'Open DevTools',
18
18
  'devtools label': 'DevTools',
19
19
  'devtools overview label': 'Stats',
20
+ 'space objects label': 'Database',
20
21
  'debug label': 'Debug',
21
22
  'debug app graph label': 'App Graph',
22
23
  'settings show debug panel': 'Show Debug panel.',
@@ -24,6 +25,7 @@ export const translations = [
24
25
  'settings wireframe': 'Show wireframes.',
25
26
  'settings repair': 'Run repair tool.',
26
27
  'settings download diagnostics': 'Download diagnostics.',
28
+ 'settings download logs': 'Download log buffer.',
27
29
  'settings uploaded': 'Uploaded to IPFS',
28
30
  'settings uploaded to clipboard': 'URL copied to clipboard.',
29
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 { type Atom } from '@effect-atom/atom-react';
5
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,9 +31,12 @@ 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
- // TODO(wittjosiah): Cannot use slashes in ids until we have a router which decouples ids from url paths.
32
- export const id = 'dxos.org.plugin.debug.devtools';
39
+ export const id = `${meta.id}.devtools`;
33
40
 
34
41
  export namespace Client {
35
42
  export const id = `${Devtools.id}.client`;
@@ -1,20 +0,0 @@
1
- // src/components/DebugGraph.tsx
2
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
3
- import React from "react";
4
- import { Tree } from "@dxos/devtools";
5
- var DebugGraph = ({ graph, root }) => {
6
- var _effect = _useSignals();
7
- try {
8
- return /* @__PURE__ */ React.createElement(Tree, {
9
- data: graph.toJSON(root)
10
- });
11
- } finally {
12
- _effect.f();
13
- }
14
- };
15
- var DebugGraph_default = DebugGraph;
16
- export {
17
- DebugGraph,
18
- DebugGraph_default as default
19
- };
20
- //# sourceMappingURL=DebugGraph-EDOH6R2G.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/DebugGraph.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC } from 'react';\n\nimport { Tree } from '@dxos/devtools';\nimport { type Graph } from '@dxos/plugin-graph';\n\nexport const DebugGraph: FC<{ graph: Graph; root: string }> = ({ graph, root }) => {\n return <Tree data={graph.toJSON(root)} />;\n};\n\nexport default DebugGraph;\n"],
5
- "mappings": ";;AAIA,OAAOA,WAAwB;AAE/B,SAASC,YAAY;AAGd,IAAMC,aAAiD,CAAC,EAAEC,OAAOC,KAAI,MAAE;;;AAC5E,WAAO,sBAAA,cAACC,MAAAA;MAAKC,MAAMH,MAAMI,OAAOH,IAAAA;;;;;AAClC;AAEA,IAAA,qBAAeF;",
6
- "names": ["React", "Tree", "DebugGraph", "graph", "root", "Tree", "data", "toJSON"]
7
- }