@dxos/plugin-debug 0.8.4-main.c4373fc → 0.8.4-main.d9fc60f731

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 (244) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +373 -0
  3. package/README.md +1 -1
  4. package/dist/lib/neutral/DebugGraph-G4FWS57E.mjs +15 -0
  5. package/dist/lib/neutral/DebugGraph-G4FWS57E.mjs.map +7 -0
  6. package/dist/lib/neutral/DebugObjectPanel-OS65NC4M.mjs +59 -0
  7. package/dist/lib/neutral/DebugObjectPanel-OS65NC4M.mjs.map +7 -0
  8. package/dist/lib/neutral/DebugPlugin.mjs +59 -0
  9. package/dist/lib/neutral/DebugPlugin.mjs.map +7 -0
  10. package/dist/lib/neutral/DebugPlugin.node.mjs +18 -0
  11. package/dist/lib/neutral/DebugPlugin.node.mjs.map +7 -0
  12. package/dist/lib/neutral/DebugPlugin.workerd.mjs +12 -0
  13. package/dist/lib/neutral/DebugPlugin.workerd.mjs.map +7 -0
  14. package/dist/lib/neutral/DebugSettings-RKYNQIKH.mjs +223 -0
  15. package/dist/lib/neutral/DebugSettings-RKYNQIKH.mjs.map +7 -0
  16. package/dist/lib/neutral/DebugSpaceObjectsPanel-BHOCFWDJ.mjs +34 -0
  17. package/dist/lib/neutral/DebugSpaceObjectsPanel-BHOCFWDJ.mjs.map +7 -0
  18. package/dist/lib/neutral/DebugStatus-H2BAHN26.mjs +122 -0
  19. package/dist/lib/neutral/DebugStatus-H2BAHN26.mjs.map +7 -0
  20. package/dist/lib/neutral/DevtoolsOverviewContainer-YX7Z3D2H.mjs +23 -0
  21. package/dist/lib/neutral/DevtoolsOverviewContainer-YX7Z3D2H.mjs.map +7 -0
  22. package/dist/lib/neutral/GithubPanel-QJKDJRVQ.mjs +177 -0
  23. package/dist/lib/neutral/GithubPanel-QJKDJRVQ.mjs.map +7 -0
  24. package/dist/lib/neutral/RegistryPanel-64GIYJHN.mjs +161 -0
  25. package/dist/lib/neutral/RegistryPanel-64GIYJHN.mjs.map +7 -0
  26. package/dist/lib/neutral/SpaceGenerator-Y35G6DRV.mjs +146 -0
  27. package/dist/lib/neutral/SpaceGenerator-Y35G6DRV.mjs.map +7 -0
  28. package/dist/lib/neutral/Wireframe-WD7S2AUU.mjs +52 -0
  29. package/dist/lib/neutral/Wireframe-WD7S2AUU.mjs.map +7 -0
  30. package/dist/lib/neutral/app-graph-builder-XYLTBYKN.mjs +612 -0
  31. package/dist/lib/neutral/app-graph-builder-XYLTBYKN.mjs.map +7 -0
  32. package/dist/lib/neutral/capabilities/index.mjs +15 -0
  33. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  34. package/dist/lib/neutral/chunk-HOV6MV5B.mjs +43 -0
  35. package/dist/lib/neutral/chunk-HOV6MV5B.mjs.map +7 -0
  36. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  37. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  38. package/dist/lib/{browser/chunk-SRV2AIGJ.mjs → neutral/chunk-UAAGABXZ.mjs} +31 -9
  39. package/dist/lib/neutral/chunk-UAAGABXZ.mjs.map +7 -0
  40. package/dist/lib/{browser/SpaceGenerator-54FUIZIH.mjs → neutral/components/index.mjs} +343 -530
  41. package/dist/lib/neutral/components/index.mjs.map +7 -0
  42. package/dist/lib/neutral/containers/index.mjs +25 -0
  43. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  44. package/dist/lib/neutral/index.mjs +18 -0
  45. package/dist/lib/neutral/index.mjs.map +7 -0
  46. package/dist/lib/neutral/meta.json +1 -0
  47. package/dist/lib/neutral/meta.mjs +8 -0
  48. package/dist/lib/neutral/meta.mjs.map +7 -0
  49. package/dist/lib/neutral/plugin.mjs +12 -0
  50. package/dist/lib/neutral/plugin.mjs.map +7 -0
  51. package/dist/lib/neutral/react-context-MUZ3KVLU.mjs +17 -0
  52. package/dist/lib/neutral/react-context-MUZ3KVLU.mjs.map +7 -0
  53. package/dist/lib/neutral/react-surface-3MDMZGCA.mjs +425 -0
  54. package/dist/lib/neutral/react-surface-3MDMZGCA.mjs.map +7 -0
  55. package/dist/lib/neutral/settings-MPM6YUP4.mjs +28 -0
  56. package/dist/lib/neutral/settings-MPM6YUP4.mjs.map +7 -0
  57. package/dist/lib/neutral/translations.mjs +91 -0
  58. package/dist/lib/neutral/translations.mjs.map +7 -0
  59. package/dist/lib/neutral/types/index.mjs +14 -0
  60. package/dist/lib/neutral/types/index.mjs.map +7 -0
  61. package/dist/types/src/DebugPlugin.d.ts +4 -1
  62. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  63. package/dist/types/src/DebugPlugin.node.d.ts +5 -0
  64. package/dist/types/src/DebugPlugin.node.d.ts.map +1 -0
  65. package/dist/types/src/DebugPlugin.test.d.ts +2 -0
  66. package/dist/types/src/DebugPlugin.test.d.ts.map +1 -0
  67. package/dist/types/src/DebugPlugin.workerd.d.ts +5 -0
  68. package/dist/types/src/DebugPlugin.workerd.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  70. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  71. package/dist/types/src/capabilities/index.d.ts +8 -5
  72. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  73. package/dist/types/src/capabilities/react-context.d.ts +4 -2
  74. package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/react-surface.d.ts +7 -2
  76. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  77. package/dist/types/src/capabilities/settings.d.ts +5 -2
  78. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  79. package/dist/types/src/components/DebugSettings/DebugSettings.d.ts +11 -0
  80. package/dist/types/src/components/DebugSettings/DebugSettings.d.ts.map +1 -0
  81. package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts +106 -0
  82. package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/DebugSettings/index.d.ts +2 -0
  84. package/dist/types/src/components/DebugSettings/index.d.ts.map +1 -0
  85. package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
  86. package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
  87. package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
  88. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +4 -5
  89. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  90. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  91. package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
  92. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
  93. package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
  94. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  95. package/dist/types/src/components/index.d.ts +4 -10
  96. package/dist/types/src/components/index.d.ts.map +1 -1
  97. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
  98. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
  99. package/dist/types/src/containers/DebugGraph/index.d.ts +2 -0
  100. package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
  101. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts +6 -0
  102. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
  103. package/dist/types/src/containers/DebugObjectPanel/index.d.ts +2 -0
  104. package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
  105. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +5 -0
  106. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
  107. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +2 -0
  108. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
  109. package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
  110. package/dist/types/src/containers/DebugStatus/index.d.ts +2 -0
  111. package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
  112. package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
  113. package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
  114. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +2 -0
  115. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
  116. package/dist/types/src/containers/GithubPanel/GithubComponent.d.ts +15 -0
  117. package/dist/types/src/containers/GithubPanel/GithubComponent.d.ts.map +1 -0
  118. package/dist/types/src/containers/GithubPanel/GithubComponent.stories.d.ts +106 -0
  119. package/dist/types/src/containers/GithubPanel/GithubComponent.stories.d.ts.map +1 -0
  120. package/dist/types/src/containers/GithubPanel/GithubPanel.d.ts +3 -0
  121. package/dist/types/src/containers/GithubPanel/GithubPanel.d.ts.map +1 -0
  122. package/dist/types/src/containers/GithubPanel/index.d.ts +2 -0
  123. package/dist/types/src/containers/GithubPanel/index.d.ts.map +1 -0
  124. package/dist/types/src/containers/RegistryPanel/RegistryPanel.d.ts +3 -0
  125. package/dist/types/src/containers/RegistryPanel/RegistryPanel.d.ts.map +1 -0
  126. package/dist/types/src/containers/RegistryPanel/index.d.ts +2 -0
  127. package/dist/types/src/containers/RegistryPanel/index.d.ts.map +1 -0
  128. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +11 -0
  129. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
  130. package/dist/types/src/containers/SpaceGenerator/index.d.ts +2 -0
  131. package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
  132. package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
  133. package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
  134. package/dist/types/src/containers/Wireframe/index.d.ts +2 -0
  135. package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
  136. package/dist/types/src/containers/index.d.ts +11 -0
  137. package/dist/types/src/containers/index.d.ts.map +1 -0
  138. package/dist/types/src/index.d.ts +1 -1
  139. package/dist/types/src/index.d.ts.map +1 -1
  140. package/dist/types/src/meta.d.ts +2 -2
  141. package/dist/types/src/meta.d.ts.map +1 -1
  142. package/dist/types/src/plugin.d.ts +4 -0
  143. package/dist/types/src/plugin.d.ts.map +1 -0
  144. package/dist/types/src/translations.d.ts +87 -59
  145. package/dist/types/src/translations.d.ts.map +1 -1
  146. package/dist/types/src/types/Settings.d.ts +8 -0
  147. package/dist/types/src/types/Settings.d.ts.map +1 -0
  148. package/dist/types/src/types/index.d.ts +70 -0
  149. package/dist/types/src/types/index.d.ts.map +1 -0
  150. package/dist/types/tsconfig.tsbuildinfo +1 -1
  151. package/package.json +125 -78
  152. package/src/DebugPlugin.node.ts +18 -0
  153. package/src/DebugPlugin.test.ts +29 -0
  154. package/src/DebugPlugin.tsx +34 -34
  155. package/src/DebugPlugin.workerd.ts +12 -0
  156. package/src/capabilities/app-graph-builder.ts +390 -388
  157. package/src/capabilities/index.ts +5 -5
  158. package/src/capabilities/react-context.tsx +16 -7
  159. package/src/capabilities/react-surface.tsx +386 -339
  160. package/src/capabilities/settings.ts +24 -12
  161. package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
  162. package/src/components/DebugSettings/DebugSettings.tsx +259 -0
  163. package/src/components/DebugSettings/index.ts +5 -0
  164. package/src/components/SchemaTable/index.ts +5 -0
  165. package/src/components/SpaceGenerator/ObjectGenerator.tsx +38 -44
  166. package/src/components/SpaceGenerator/draw-util.ts +8 -8
  167. package/src/components/SpaceGenerator/index.ts +2 -3
  168. package/src/components/SpaceGenerator/presets.ts +245 -151
  169. package/src/components/index.ts +4 -8
  170. package/src/containers/DebugGraph/DebugGraph.tsx +14 -0
  171. package/src/containers/DebugGraph/index.ts +5 -0
  172. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +76 -0
  173. package/src/containers/DebugObjectPanel/index.ts +5 -0
  174. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +47 -0
  175. package/src/containers/DebugSpaceObjectsPanel/index.ts +5 -0
  176. package/src/{components → containers/DebugStatus}/DebugStatus.tsx +42 -19
  177. package/src/containers/DebugStatus/index.ts +5 -0
  178. package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
  179. package/src/containers/DevtoolsOverviewContainer/index.ts +5 -0
  180. package/src/containers/GithubPanel/GithubComponent.stories.tsx +38 -0
  181. package/src/containers/GithubPanel/GithubComponent.tsx +192 -0
  182. package/src/containers/GithubPanel/GithubPanel.tsx +17 -0
  183. package/src/containers/GithubPanel/index.ts +5 -0
  184. package/src/containers/RegistryPanel/RegistryPanel.tsx +150 -0
  185. package/src/containers/RegistryPanel/index.ts +5 -0
  186. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +127 -0
  187. package/src/containers/SpaceGenerator/index.ts +5 -0
  188. package/src/{components → containers/Wireframe}/Wireframe.tsx +7 -12
  189. package/src/containers/Wireframe/index.ts +5 -0
  190. package/src/containers/index.ts +15 -0
  191. package/src/index.ts +1 -1
  192. package/src/meta.ts +29 -6
  193. package/src/plugin.ts +10 -0
  194. package/src/translations.ts +83 -58
  195. package/src/types/Settings.ts +16 -0
  196. package/src/{types.ts → types/index.ts} +21 -11
  197. package/src/vite-env.d.ts +10 -0
  198. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  199. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  200. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  201. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  202. package/dist/lib/browser/SpaceGenerator-54FUIZIH.mjs.map +0 -7
  203. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs +0 -588
  204. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs.map +0 -7
  205. package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
  206. package/dist/lib/browser/chunk-SVCKCXCL.mjs +0 -16
  207. package/dist/lib/browser/chunk-SVCKCXCL.mjs.map +0 -7
  208. package/dist/lib/browser/index.mjs +0 -131
  209. package/dist/lib/browser/index.mjs.map +0 -7
  210. package/dist/lib/browser/meta.json +0 -1
  211. package/dist/lib/browser/react-context-QLZE7VSQ.mjs +0 -16
  212. package/dist/lib/browser/react-context-QLZE7VSQ.mjs.map +0 -7
  213. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs +0 -772
  214. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs.map +0 -7
  215. package/dist/lib/browser/settings-EBVICEEW.mjs +0 -22
  216. package/dist/lib/browser/settings-EBVICEEW.mjs.map +0 -7
  217. package/dist/types/src/components/Container.d.ts +0 -5
  218. package/dist/types/src/components/Container.d.ts.map +0 -1
  219. package/dist/types/src/components/DebugGraph.d.ts +0 -8
  220. package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
  221. package/dist/types/src/components/DebugObjectPanel.d.ts +0 -7
  222. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  223. package/dist/types/src/components/DebugSettings.d.ts +0 -6
  224. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  225. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  226. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  227. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  228. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
  229. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
  230. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
  231. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  232. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  233. package/dist/types/src/types.d.ts +0 -63
  234. package/dist/types/src/types.d.ts.map +0 -1
  235. package/src/components/Container.tsx +0 -15
  236. package/src/components/DebugGraph.tsx +0 -14
  237. package/src/components/DebugObjectPanel.tsx +0 -33
  238. package/src/components/DebugSettings.tsx +0 -159
  239. package/src/components/DevtoolsOverviewContainer.tsx +0 -20
  240. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
  241. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
  242. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  243. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
  244. /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
@@ -2,18 +2,30 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes } from '@dxos/app-framework';
6
- import { live } from '@dxos/live-object';
5
+ import * as Effect from 'effect/Effect';
7
6
 
8
- import { meta } from '../meta';
9
- import { type DebugSettingsProps, DebugSettingsSchema } from '../types';
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { AppCapabilities } from '@dxos/app-toolkit';
9
+ import { createKvsStore } from '@dxos/effect';
10
10
 
11
- export default () => {
12
- const settings = live<DebugSettingsProps>({});
11
+ import { meta } from '#meta';
12
+ import { DebugCapabilities, Settings } from '#types';
13
13
 
14
- return contributes(Capabilities.Settings, {
15
- prefix: meta.id,
16
- schema: DebugSettingsSchema,
17
- value: settings,
18
- });
19
- };
14
+ export default Capability.makeModule(() =>
15
+ Effect.sync(() => {
16
+ const settingsAtom = createKvsStore({
17
+ key: meta.id,
18
+ schema: Settings.Settings,
19
+ defaultValue: () => ({}),
20
+ });
21
+
22
+ return [
23
+ Capability.contributes(DebugCapabilities.Settings, settingsAtom),
24
+ Capability.contributes(AppCapabilities.Settings, {
25
+ prefix: meta.id,
26
+ schema: Settings.Settings,
27
+ atom: settingsAtom,
28
+ }),
29
+ ];
30
+ }),
31
+ );
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+
7
+ import { withClientProvider } from '@dxos/react-client/testing';
8
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
9
+
10
+ import { translations } from '#translations';
11
+
12
+ import { DebugSettings } from './DebugSettings';
13
+
14
+ const meta = {
15
+ title: 'plugins/plugin-debug/components/DebugSettings',
16
+ component: DebugSettings,
17
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withClientProvider({ createIdentity: true })],
18
+ tags: ['settings'],
19
+ parameters: {
20
+ layout: 'fullscreen',
21
+ translations,
22
+ },
23
+ } satisfies Meta<typeof DebugSettings>;
24
+
25
+ export default meta;
26
+
27
+ type Story = StoryObj<typeof meta>;
28
+
29
+ export const Default: Story = {
30
+ args: {
31
+ settings: {
32
+ wireframe: false,
33
+ },
34
+ logStore: { export: async () => '' } as any,
35
+ },
36
+ };
@@ -0,0 +1,259 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
+
7
+ import { AppCapabilities, getPersonalSpace } from '@dxos/app-toolkit';
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
+ import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
10
+ import { log } from '@dxos/log';
11
+ import { type IdbLogStore } from '@dxos/log-store-idb';
12
+ import { useClient } from '@dxos/react-client';
13
+ import { IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
14
+ import { Settings as SettingsForm } from '@dxos/react-ui-form';
15
+ import { TRACE_ALL_KEY } from '@dxos/tracing';
16
+ import { setDeep } from '@dxos/util';
17
+
18
+ import { meta } from '#meta';
19
+ import { type Settings } from '#types';
20
+
21
+ type Toast = {
22
+ title: string;
23
+ description?: string;
24
+ };
25
+
26
+ const StorageAdapters = {
27
+ opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
28
+ idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
29
+ } as const;
30
+
31
+ export type DebugSettingsProps = AppSurface.SettingsArticleProps<
32
+ Settings.Settings,
33
+ {
34
+ logStore: IdbLogStore;
35
+ onUpload?: AppCapabilities.FileUploader;
36
+ }
37
+ >;
38
+
39
+ export const DebugSettings = ({ settings, onSettingsChange, logStore, onUpload }: DebugSettingsProps) => {
40
+ const { t } = useTranslation(meta.id);
41
+ const [toast, setToast] = useState<Toast>();
42
+ const download = useFileDownload();
43
+ const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
44
+ const client = useClient();
45
+
46
+ useEffect(() => {
47
+ void Storage().then((config) => setStorageConfig(config));
48
+ }, []);
49
+
50
+ const handleToast = useCallback(
51
+ (toast: Toast) => {
52
+ setToast(toast);
53
+ const timer = setTimeout(() => setToast(undefined), 5_000);
54
+ return () => clearTimeout(timer);
55
+ },
56
+ [setToast],
57
+ );
58
+
59
+ const handleDownload = useCallback(async () => {
60
+ const data = await client.diagnostics();
61
+ const file = new Blob([JSON.stringify(data, undefined, 2)], {
62
+ type: 'text/plain',
63
+ });
64
+ const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
65
+ download(file, fileName);
66
+
67
+ if (onUpload) {
68
+ const personalSpace = getPersonalSpace(client);
69
+ if (!personalSpace) {
70
+ log.error('no personal space available for upload');
71
+ return;
72
+ }
73
+ const info = await onUpload(personalSpace.db, new File([file], fileName));
74
+ if (!info) {
75
+ log.error('diagnostics failed to upload to IPFS');
76
+ return;
77
+ }
78
+ handleToast({
79
+ title: t('settings.uploaded.message'),
80
+ description: t('settings.uploaded.description'),
81
+ });
82
+
83
+ // TODO(nf): move to IpfsPlugin?
84
+ const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
85
+ void navigator.clipboard.writeText(url);
86
+ handleToast({
87
+ title: t('settings.uploaded.message'),
88
+ description: t('settings.uploaded.description'),
89
+ });
90
+ log.info('diagnostics', { url });
91
+ }
92
+ }, [client, download, handleToast, onUpload, t]);
93
+
94
+ const handleDownloadLogs = useCallback(async () => {
95
+ const ndjson = await logStore.export();
96
+ const file = new Blob([ndjson], { type: 'application/x-ndjson' });
97
+ const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
98
+ download(file, fileName);
99
+ }, [download, logStore]);
100
+
101
+ const handleRepair = useCallback(async () => {
102
+ try {
103
+ const info = await client.repair();
104
+ setStorageConfig(await Storage());
105
+ handleToast({
106
+ title: t('settings.repair-success.message'),
107
+ description: JSON.stringify(info, undefined, 2),
108
+ });
109
+ } catch (err: any) {
110
+ handleToast({
111
+ title: t('settings.repair-failed.message'),
112
+ description: err.message,
113
+ });
114
+ }
115
+ }, [client, handleToast, t]);
116
+
117
+ const handleWireframeChange = useCallback(
118
+ (checked: boolean) => onSettingsChange?.((s) => ({ ...s, wireframe: !!checked })),
119
+ [onSettingsChange],
120
+ );
121
+
122
+ const traceAll = useMemo(
123
+ () => settings.traceAll ?? (typeof localStorage !== 'undefined' && localStorage.getItem(TRACE_ALL_KEY) === 'true'),
124
+ [settings.traceAll],
125
+ );
126
+
127
+ const handleTraceAllChange = useCallback(
128
+ (checked: boolean) => {
129
+ const value = !!checked;
130
+ localStorage.setItem(TRACE_ALL_KEY, String(value));
131
+ onSettingsChange?.((s) => ({ ...s, traceAll: value }));
132
+ },
133
+ [onSettingsChange],
134
+ );
135
+
136
+ const handleOpenTracingPanel = useCallback(() => {
137
+ window.open('about:blank', '_blank');
138
+ }, []);
139
+
140
+ const handleStorageAdapterChange = useCallback(
141
+ (value: string) => {
142
+ if (confirm(t('settings.storage-adapter.changed-alert.message'))) {
143
+ updateConfig(
144
+ storageConfig,
145
+ setStorageConfig,
146
+ ['runtime', 'client', 'storage', 'dataStore'],
147
+ StorageAdapters[value as keyof typeof StorageAdapters],
148
+ );
149
+ }
150
+ },
151
+ [storageConfig, t],
152
+ );
153
+
154
+ return (
155
+ <SettingsForm.Viewport>
156
+ <SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
157
+ <SettingsForm.Item title={t('settings.wireframe.label')} description={t('settings.wireframe.description')}>
158
+ <Input.Switch
159
+ disabled={!onSettingsChange}
160
+ checked={settings.wireframe}
161
+ onCheckedChange={handleWireframeChange}
162
+ />
163
+ </SettingsForm.Item>
164
+ <SettingsForm.Item title={t('settings.trace-all.label')} description={t('settings.trace-all.description')}>
165
+ <Input.Switch disabled={!onSettingsChange} checked={traceAll} onCheckedChange={handleTraceAllChange} />
166
+ </SettingsForm.Item>
167
+ <SettingsForm.Item
168
+ title={t('settings.tracing-panel.label')}
169
+ description={t('settings.tracing-panel.description')}
170
+ >
171
+ <IconButton
172
+ icon='ph--arrow-square-out--regular'
173
+ iconOnly
174
+ label={t('settings.tracing-panel.label')}
175
+ onClick={handleOpenTracingPanel}
176
+ />
177
+ </SettingsForm.Item>
178
+ <SettingsForm.Item
179
+ title={t('settings.download-diagnostics.label')}
180
+ description={t('settings.download-diagnostics.description')}
181
+ >
182
+ <IconButton
183
+ icon='ph--download-simple--regular'
184
+ iconOnly
185
+ label={t('settings.download-diagnostics.label')}
186
+ onClick={handleDownload}
187
+ />
188
+ </SettingsForm.Item>
189
+ <SettingsForm.Item
190
+ title={t('settings.download-logs.label')}
191
+ description={t('settings.download-logs.description')}
192
+ >
193
+ <IconButton
194
+ icon='ph--download-simple--regular'
195
+ iconOnly
196
+ label={t('settings.download-logs.label')}
197
+ onClick={handleDownloadLogs}
198
+ />
199
+ </SettingsForm.Item>
200
+ <SettingsForm.Item title={t('settings.repair.label')} description={t('settings.repair.description')}>
201
+ <IconButton
202
+ icon='ph--first-aid-kit--regular'
203
+ iconOnly
204
+ label={t('settings.repair.label')}
205
+ onClick={handleRepair}
206
+ />
207
+ </SettingsForm.Item>
208
+
209
+ {/* TODO(burdon): Move to layout? */}
210
+ {toast && (
211
+ <Toast.Root>
212
+ <Toast.Title icon='ph--gift--duotone'>
213
+ <span>{toast.title}</span>
214
+ </Toast.Title>
215
+ {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
216
+ </Toast.Root>
217
+ )}
218
+
219
+ <SettingsForm.Item
220
+ title={t('settings.choose-storage-adaptor.label')}
221
+ description={t('settings.choose-storage-adaptor.description')}
222
+ >
223
+ <Select.Root
224
+ disabled={!onSettingsChange}
225
+ value={
226
+ Object.entries(StorageAdapters).find(
227
+ ([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
228
+ )?.[0]
229
+ }
230
+ onValueChange={handleStorageAdapterChange}
231
+ >
232
+ <Select.TriggerButton disabled={!onSettingsChange} placeholder={t('settings.data-store.label')} />
233
+ <Select.Portal>
234
+ <Select.Content>
235
+ <Select.Viewport>
236
+ {Object.keys(StorageAdapters).map((key) => (
237
+ <Select.Option key={key} value={key}>
238
+ {t(`settings.storage-adaptor.${key}.label`)}
239
+ </Select.Option>
240
+ ))}
241
+ </Select.Viewport>
242
+ <Select.Arrow />
243
+ </Select.Content>
244
+ </Select.Portal>
245
+ </Select.Root>
246
+ </SettingsForm.Item>
247
+ </SettingsForm.Section>
248
+ </SettingsForm.Viewport>
249
+ );
250
+ };
251
+
252
+ const updateConfig = (config: ConfigProto, setConfig: (newConfig: ConfigProto) => void, path: string[], value: any) => {
253
+ const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
254
+ setDeep(storageConfigCopy, path, value);
255
+ setConfig(storageConfigCopy);
256
+ queueMicrotask(async () => {
257
+ await SaveConfig(storageConfigCopy);
258
+ });
259
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export { DebugSettings as default } from './DebugSettings';
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './SchemaTable';
@@ -2,47 +2,48 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type PromiseIntentDispatcher, createIntent } from '@dxos/app-framework';
6
- import { addressToA1Notation } from '@dxos/compute';
5
+ import { addressToA1Notation } from '@dxos/compute-hyperformula';
7
6
  import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
8
- import { DXN, Filter, Key, Obj, Ref, Type } from '@dxos/echo';
9
- import { type TypedObject } from '@dxos/echo/internal';
10
- import { Markdown } from '@dxos/plugin-markdown/types';
11
- import { createSheet } from '@dxos/plugin-sheet/types';
12
- import { type CellValue, SheetType } from '@dxos/plugin-sheet/types';
13
- import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
14
- import { SpaceAction } from '@dxos/plugin-space/types';
15
- import { faker } from '@dxos/random';
7
+ import { EID, Filter, Key, Type, View } from '@dxos/echo';
8
+ import { OperationInvoker } from '@dxos/operation';
9
+ import { Markdown } from '@dxos/plugin-markdown';
10
+ import { Sheet } from '@dxos/plugin-sheet';
11
+ import { Sketch } from '@dxos/plugin-sketch';
12
+ import { SpaceOperation } from '@dxos/plugin-space';
13
+ import { random } from '@dxos/random';
16
14
  import { type Client } from '@dxos/react-client';
17
15
  import { type Space } from '@dxos/react-client/echo';
18
- import { DataType, getTypenameFromQuery } from '@dxos/schema';
16
+ import { getTypenameFromQuery } from '@dxos/schema';
19
17
  import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
20
18
  import { range } from '@dxos/util';
21
19
 
22
- const generator: ValueGenerator = faker as any;
20
+ const generator: ValueGenerator = random as any;
23
21
 
24
- const findViewByTypename = async (views: DataType.View[], typename: string) => {
22
+ const findViewByTypename = async (views: View.View[], typename: string) => {
25
23
  return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
26
24
  };
27
25
 
28
- export type ObjectGenerator<T extends Obj.Any> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
26
+ export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
29
27
 
30
- export const createGenerator = <T extends Obj.Any>(
28
+ export const createGenerator = <S extends Type.AnyObj>(
31
29
  client: Client,
32
- dispatch: PromiseIntentDispatcher,
33
- schema: TypedObject<T>,
34
- ): ObjectGenerator<T> => {
35
- return async (space: Space, n: number): Promise<T[]> => {
36
- const typename = schema.typename;
30
+ invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
31
+ schema: S,
32
+ ): ObjectGenerator<Type.InstanceType<S>> => {
33
+ return async (space: Space, n: number): Promise<Type.InstanceType<S>[]> => {
34
+ const typename = Type.getTypename(schema);
37
35
 
38
36
  // Find or create table and view.
39
- const { objects: views } = await space.db.query(Filter.type(DataType.View)).run();
37
+ const views = await space.db.query(Filter.type(View.View)).run();
40
38
  const view = await findViewByTypename(views, typename);
41
- const staticSchema = client?.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
39
+ const staticSchema = client
40
+ ? client.graph.registry
41
+ .list()
42
+ .filter(Type.isType)
43
+ .find((s) => Type.getTypename(s) === typename)
44
+ : undefined;
42
45
  if (!view && !staticSchema) {
43
- await dispatch(createIntent(SpaceAction.AddSchema, { space, schema }));
44
- } else if (!view && staticSchema) {
45
- await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename }));
46
+ await invokePromise(SpaceOperation.AddType, { db: space.db, type: schema, show: false });
46
47
  }
47
48
 
48
49
  // Create objects.
@@ -53,13 +54,13 @@ export const createGenerator = <T extends Obj.Any>(
53
54
 
54
55
  export const staticGenerators = new Map<string, ObjectGenerator<any>>([
55
56
  [
56
- Markdown.Document.typename,
57
+ Type.getTypename(Markdown.Document),
57
58
  async (space, n, cb) => {
58
59
  const objects = range(n).map(() => {
59
60
  return space.db.add(
60
- Markdown.makeDocument({
61
- name: faker.commerce.productName(),
62
- content: faker.lorem.sentences(5),
61
+ Markdown.make({
62
+ name: random.commerce.productName(),
63
+ content: random.lorem.sentences(5),
63
64
  }),
64
65
  );
65
66
  });
@@ -69,17 +70,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
69
70
  },
70
71
  ],
71
72
  [
72
- DiagramType.typename,
73
+ Type.getTypename(Sketch.Sketch),
73
74
  async (space, n, cb) => {
74
75
  const objects = range(n).map(() => {
75
- // TODO(burdon): Generate diagram.
76
- const obj = space.db.add(
77
- Obj.make(DiagramType, {
78
- name: faker.commerce.productName(),
79
- canvas: Ref.make(Obj.make(CanvasType, { content: {} })),
80
- }),
81
- );
82
-
76
+ const obj = space.db.add(Sketch.make({ name: random.commerce.productName() }));
83
77
  return obj;
84
78
  });
85
79
 
@@ -89,10 +83,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
89
83
  ],
90
84
  // TODO(burdon): Create unit tests.
91
85
  [
92
- SheetType.typename,
86
+ Type.getTypename(Sheet.Sheet),
93
87
  async (space, n, cb) => {
94
88
  const objects = range(n).map(() => {
95
- const cells: Record<string, CellValue> = {};
89
+ const cells: Record<string, Sheet.CellValue> = {};
96
90
  const year = new Date().getFullYear();
97
91
  const cols = 4;
98
92
  const rows = 16;
@@ -114,8 +108,8 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
114
108
  // TODO(burdon): Set width.
115
109
  // TODO(burdon): Set formatting for columns.
116
110
  return space.db.add(
117
- createSheet({
118
- name: faker.commerce.productName(),
111
+ Sheet.make({
112
+ name: random.commerce.productName(),
119
113
  cells,
120
114
  }),
121
115
  );
@@ -126,7 +120,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
126
120
  },
127
121
  ],
128
122
  [
129
- ComputeGraph.typename,
123
+ Type.getTypename(ComputeGraph),
130
124
  async (space, n, cb) => {
131
125
  const objects = range(n, () => {
132
126
  const model = ComputeGraphModel.create();
@@ -136,7 +130,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
136
130
  .createNode({
137
131
  id: 'gpt-QUEUE_ID',
138
132
  type: 'constant',
139
- value: new DXN(DXN.kind.QUEUE, ['data', space.id, Key.ObjectId.random()]).toString(),
133
+ value: EID.make({ spaceId: space.id, entityId: Key.EntityId.random() }),
140
134
  })
141
135
  .createNode({ id: 'gpt-APPEND', type: 'append' })
142
136
  .createNode({ id: 'gpt-OUTPUT', type: NODE_OUTPUT })
@@ -15,7 +15,7 @@ import {
15
15
  } from '@antv/layout';
16
16
  import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
17
17
 
18
- import { faker } from '@dxos/random';
18
+ import { random } from '@dxos/random';
19
19
  import { isTruthy, range } from '@dxos/util';
20
20
 
21
21
  // TODO(burdon): Graph layout:
@@ -32,10 +32,10 @@ import { isTruthy, range } from '@dxos/util';
32
32
  // TODO(burdon): Factor out.
33
33
  // TODO(burdon): Map ECHO to Graph.
34
34
  export const generateGraph = (): Graph<PlainObject, PlainObject> => {
35
- const nodes = range(faker.number.int({ min: 8, max: 32 })).map(() => ({
36
- id: faker.string.uuid(),
35
+ const nodes = range(random.number.int({ min: 8, max: 32 })).map(() => ({
36
+ id: random.string.uuid(),
37
37
  data: {
38
- label: faker.lorem
38
+ label: random.lorem
39
39
  .words(2)
40
40
  .split(' ')
41
41
  .map((word) => word.charAt(0).toUpperCase())
@@ -46,7 +46,7 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
46
46
  const unlinked = new Set(nodes.map((node) => node.id));
47
47
  const pop = () => {
48
48
  if (unlinked.size) {
49
- const id = faker.helpers.arrayElement(Array.from(unlinked));
49
+ const id = random.helpers.arrayElement(Array.from(unlinked));
50
50
  unlinked.delete(id);
51
51
  return id;
52
52
  }
@@ -54,12 +54,12 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
54
54
 
55
55
  const edges: Edge<PlainObject>[] = [];
56
56
  const link = (source: string, target: string) => {
57
- edges.push({ id: faker.string.uuid(), source, target, data: {} });
57
+ edges.push({ id: random.string.uuid(), source, target, data: {} });
58
58
  };
59
59
 
60
60
  const branching = 3;
61
61
  const traverse = (source: string) => {
62
- const targets = range(faker.number.int({ min: 1, max: branching }))
62
+ const targets = range(random.number.int({ min: 1, max: branching }))
63
63
  .map(() => {
64
64
  const target = pop();
65
65
  if (target) {
@@ -106,7 +106,7 @@ export const drawGraph = async (
106
106
  preventOverlap: true,
107
107
  };
108
108
 
109
- const layoutType = faker.helpers.arrayElement(['d3force', 'grid', 'radial']);
109
+ const layoutType = random.helpers.arrayElement(['d3force', 'grid', 'radial']);
110
110
  let layout: Layout<any>;
111
111
  switch (layoutType) {
112
112
  case 'd3force': {
@@ -2,6 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { SpaceGenerator } from './SpaceGenerator';
6
-
7
- export default SpaceGenerator;
5
+ export * from './presets';
6
+ export * from './ObjectGenerator';