@dxos/plugin-debug 0.8.4-main.c4373fc → 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 (188) 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-54FUIZIH.mjs → SpaceGenerator-SWSGJEEL.mjs} +476 -461
  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-SRV2AIGJ.mjs → chunk-4UFQXPP7.mjs} +11 -1
  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 +42 -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/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 +2 -5
  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/{components → containers}/SpaceGenerator/SpaceGenerator.d.ts +2 -2
  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 +2 -2
  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 +3 -1
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types.d.ts +5 -0
  101. package/dist/types/src/types.d.ts.map +1 -1
  102. package/dist/types/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +75 -69
  104. package/src/DebugPlugin.tsx +27 -31
  105. package/src/capabilities/app-graph-builder/app-graph-builder.ts +441 -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 +20 -0
  110. package/src/capabilities/react-surface/index.ts +7 -0
  111. package/src/capabilities/react-surface/react-surface.tsx +428 -0
  112. package/src/capabilities/settings/index.ts +7 -0
  113. package/src/capabilities/settings/settings.ts +31 -0
  114. package/src/components/SchemaTable/index.ts +5 -0
  115. package/src/components/SpaceGenerator/ObjectGenerator.tsx +26 -32
  116. package/src/components/SpaceGenerator/index.ts +2 -3
  117. package/src/components/SpaceGenerator/presets.ts +258 -141
  118. package/src/components/index.ts +2 -10
  119. package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
  120. package/src/containers/DebugGraph/index.ts +7 -0
  121. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +45 -0
  122. package/src/containers/DebugObjectPanel/index.ts +7 -0
  123. package/src/{components → containers/DebugSettings}/DebugSettings.tsx +78 -36
  124. package/src/containers/DebugSettings/index.ts +7 -0
  125. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +60 -0
  126. package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
  127. package/src/containers/DebugStatus/index.ts +7 -0
  128. package/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.tsx +2 -4
  129. package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
  130. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +127 -0
  131. package/src/containers/SpaceGenerator/index.ts +7 -0
  132. package/src/{components → containers/Wireframe}/Wireframe.tsx +6 -7
  133. package/src/containers/Wireframe/index.ts +7 -0
  134. package/src/containers/index.ts +14 -0
  135. package/src/meta.ts +7 -4
  136. package/src/translations.ts +3 -1
  137. package/src/types.ts +8 -0
  138. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  139. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  140. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  141. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  142. package/dist/lib/browser/SpaceGenerator-54FUIZIH.mjs.map +0 -7
  143. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs +0 -588
  144. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs.map +0 -7
  145. package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
  146. package/dist/lib/browser/chunk-SVCKCXCL.mjs +0 -16
  147. package/dist/lib/browser/chunk-SVCKCXCL.mjs.map +0 -7
  148. package/dist/lib/browser/react-context-QLZE7VSQ.mjs +0 -16
  149. package/dist/lib/browser/react-context-QLZE7VSQ.mjs.map +0 -7
  150. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs +0 -772
  151. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs.map +0 -7
  152. package/dist/lib/browser/settings-EBVICEEW.mjs +0 -22
  153. package/dist/lib/browser/settings-EBVICEEW.mjs.map +0 -7
  154. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  155. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  157. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  158. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  159. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  160. package/dist/types/src/capabilities/settings.d.ts +0 -4
  161. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  162. package/dist/types/src/components/Container.d.ts +0 -5
  163. package/dist/types/src/components/Container.d.ts.map +0 -1
  164. package/dist/types/src/components/DebugGraph.d.ts +0 -8
  165. package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
  166. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  167. package/dist/types/src/components/DebugSettings.d.ts +0 -6
  168. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  169. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  170. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  171. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  172. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
  173. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
  174. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  175. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  176. package/src/capabilities/app-graph-builder.ts +0 -431
  177. package/src/capabilities/react-context.tsx +0 -16
  178. package/src/capabilities/react-surface.tsx +0 -399
  179. package/src/capabilities/settings.ts +0 -19
  180. package/src/components/Container.tsx +0 -15
  181. package/src/components/DebugGraph.tsx +0 -14
  182. package/src/components/DebugObjectPanel.tsx +0 -33
  183. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
  184. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
  185. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  186. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
  187. /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
  188. /package/src/{components → containers/DebugStatus}/DebugStatus.tsx +0 -0
@@ -0,0 +1,45 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useState } from 'react';
6
+
7
+ import { ObjectsTree } from '@dxos/devtools';
8
+ import { Filter, Obj, Query } from '@dxos/echo';
9
+ import type { ObjectId } from '@dxos/keys';
10
+ import { useQuery } from '@dxos/react-client/echo';
11
+ import { Clipboard, Grid, Panel, ScrollArea } from '@dxos/react-ui';
12
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
13
+
14
+ export type DebugObjectPanelProps = {
15
+ object: Obj.Unknown;
16
+ };
17
+
18
+ export const DebugObjectPanel = ({ object }: DebugObjectPanelProps) => {
19
+ const db = Obj.getDatabase(object);
20
+
21
+ const [selectedId, setSelectedId] = useState<ObjectId | null>(null);
22
+ const [selectedObject] = useQuery(
23
+ db,
24
+ Query.select(Filter.id(selectedId ?? object.id)).options({ deleted: 'include' }),
25
+ );
26
+
27
+ return (
28
+ <Clipboard.Provider>
29
+ <Panel.Root>
30
+ <Panel.Content asChild>
31
+ <Grid rows={db ? 2 : 1} classNames='divide-y divide-separator'>
32
+ {db && (
33
+ <ScrollArea.Root>
34
+ <ScrollArea.Viewport>
35
+ <ObjectsTree db={db} root={object} onSelect={(entity) => setSelectedId(entity.id)} />
36
+ </ScrollArea.Viewport>
37
+ </ScrollArea.Root>
38
+ )}
39
+ <Json data={selectedObject} />
40
+ </Grid>
41
+ </Panel.Content>
42
+ </Panel.Root>
43
+ </Clipboard.Provider>
44
+ );
45
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { DebugObjectPanel } from './DebugObjectPanel';
6
+
7
+ export default DebugObjectPanel;
@@ -4,16 +4,17 @@
4
4
 
5
5
  import React, { useEffect, useState } from 'react';
6
6
 
7
- import { Capabilities, useCapabilities } from '@dxos/app-framework';
7
+ import { useCapabilities } from '@dxos/app-framework/ui';
8
+ import { AppCapabilities } from '@dxos/app-toolkit';
8
9
  import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
9
- import { log } from '@dxos/log';
10
+ import { type LogBuffer, log } from '@dxos/log';
10
11
  import { useClient } from '@dxos/react-client';
11
- import { Button, Icon, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
12
- import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
12
+ import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
13
+ import { Settings } from '@dxos/react-ui-form';
13
14
  import { setDeep } from '@dxos/util';
14
15
 
15
- import { meta } from '../meta';
16
- import { type DebugSettingsProps } from '../types';
16
+ import { meta } from '../../meta';
17
+ import { type DebugSettingsProps } from '../../types';
17
18
 
18
19
  type Toast = {
19
20
  title: string;
@@ -25,14 +26,20 @@ const StorageAdapters = {
25
26
  idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
26
27
  } as const;
27
28
 
28
- 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) => {
29
36
  const { t } = useTranslation(meta.id);
30
37
  const [toast, setToast] = useState<Toast>();
31
38
  const client = useClient();
32
39
  const download = useFileDownload();
33
40
  // TODO(mykola): Get updates from other places that change Config.
34
41
  const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
35
- const [upload] = useCapabilities(Capabilities.FileUploader);
42
+ const [upload] = useCapabilities(AppCapabilities.FileUploader);
36
43
 
37
44
  useEffect(() => {
38
45
  void Storage().then((config) => setStorageConfig(config));
@@ -46,56 +53,91 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
46
53
 
47
54
  const handleDownload = async () => {
48
55
  const data = await client.diagnostics();
49
- const file = new Blob([JSON.stringify(data, undefined, 2)], { type: 'text/plain' });
56
+ const file = new Blob([JSON.stringify(data, undefined, 2)], {
57
+ type: 'text/plain',
58
+ });
50
59
  const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
51
60
  download(file, fileName);
52
61
 
53
62
  if (upload) {
54
- const info = await upload(new File([file], fileName), client.spaces.default);
63
+ const info = await upload(client.spaces.default.db, new File([file], fileName));
55
64
  if (!info) {
56
65
  log.error('diagnostics failed to upload to IPFS');
57
66
  return;
58
67
  }
59
- handleToast({ title: t('settings uploaded'), description: t('settings uploaded to clipboard') });
68
+ handleToast({
69
+ title: t('settings uploaded'),
70
+ description: t('settings uploaded to clipboard'),
71
+ });
60
72
 
61
73
  // TODO(nf): move to IpfsPlugin?
62
74
  const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
63
75
  void navigator.clipboard.writeText(url);
64
- handleToast({ title: t('settings uploaded'), description: t('settings uploaded to clipboard') });
76
+ handleToast({
77
+ title: t('settings uploaded'),
78
+ description: t('settings uploaded to clipboard'),
79
+ });
65
80
  log.info('diagnostics', { url });
66
81
  }
67
82
  };
68
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
+
69
91
  const handleRepair = async () => {
70
92
  try {
71
93
  const info = await client.repair();
72
94
  setStorageConfig(await Storage());
73
- handleToast({ title: t('settings repair success'), description: JSON.stringify(info, undefined, 2) });
95
+ handleToast({
96
+ title: t('settings repair success'),
97
+ description: JSON.stringify(info, undefined, 2),
98
+ });
74
99
  } catch (err: any) {
75
- handleToast({ title: t('settings repair failed'), description: err.message });
100
+ handleToast({
101
+ title: t('settings repair failed'),
102
+ description: err.message,
103
+ });
76
104
  }
77
105
  };
78
106
 
79
107
  return (
80
- <ControlPage>
81
- <ControlSection title={t('settings title', { ns: meta.id })}>
82
- <ControlGroup>
83
- <ControlItemInput title={t('settings wireframe')}>
108
+ <Settings.Root>
109
+ <Settings.Section title={t('settings title', { ns: meta.id })}>
110
+ <Settings.Group>
111
+ <Settings.ItemInput title={t('settings wireframe')}>
84
112
  <Input.Switch
85
113
  checked={settings.wireframe}
86
- onCheckedChange={(checked) => (settings.wireframe = !!checked)}
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}
87
139
  />
88
- </ControlItemInput>
89
- <ControlItemInput title={t('settings download diagnostics')}>
90
- <Button onClick={handleDownload}>
91
- <Icon icon='ph--download-simple--regular' size={5} />
92
- </Button>
93
- </ControlItemInput>
94
- <ControlItemInput title={t('settings repair')}>
95
- <Button onClick={handleRepair}>
96
- <Icon icon='ph--first-aid-kit--regular' size={5} />
97
- </Button>
98
- </ControlItemInput>
140
+ </Settings.ItemInput>
99
141
 
100
142
  {/* TODO(burdon): Move to layout? */}
101
143
  {toast && (
@@ -110,11 +152,11 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
110
152
  </Toast.Root>
111
153
  )}
112
154
 
113
- <ControlItemInput title={t('settings choose storage adaptor')}>
155
+ <Settings.ItemInput title={t('settings choose storage adaptor')}>
114
156
  <Select.Root
115
157
  value={
116
158
  Object.entries(StorageAdapters).find(
117
- ([name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
159
+ ([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
118
160
  )?.[0]
119
161
  }
120
162
  onValueChange={(value) => {
@@ -142,10 +184,10 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
142
184
  </Select.Content>
143
185
  </Select.Portal>
144
186
  </Select.Root>
145
- </ControlItemInput>
146
- </ControlGroup>
147
- </ControlSection>
148
- </ControlPage>
187
+ </Settings.ItemInput>
188
+ </Settings.Group>
189
+ </Settings.Section>
190
+ </Settings.Root>
149
191
  );
150
192
  };
151
193
 
@@ -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;
@@ -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,33 +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();
25
24
 
26
25
  return (
27
- <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}>
28
27
  <div className='absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono'>
29
28
  <div className='flex justify-between'>
30
29
  <div>{label}</div>
31
30
  <div>{`[${width}x${height}]`}</div>
32
31
  </div>
33
32
  {object && (
34
- <SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded'>
33
+ <SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded-sm'>
35
34
  {JSON.stringify(object, undefined, 2)}
36
35
  </SyntaxHighlighter>
37
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,13 +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 meta: PluginMeta = {
8
+ export const meta: Plugin.Meta = {
8
9
  id: 'dxos.org/plugin/debug',
9
10
  name: 'Debug',
10
- description:
11
- '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
+ `,
12
15
  icon: 'ph--bug--regular',
13
16
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
14
17
  screenshots: ['https://dxos.network/plugin-details-debug-dark.png'],
@@ -16,7 +16,8 @@ export const translations = [
16
16
  'mutation period': 'Mutation period',
17
17
  'open devtools label': 'Open DevTools',
18
18
  'devtools label': 'DevTools',
19
- 'devtools overview label': 'DevTools Stats',
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,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';
@@ -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
- }