@dxos/plugin-debug 0.8.1-main.ba2dec9 → 0.8.1-staging.31c3ee1

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 (71) hide show
  1. package/dist/lib/browser/{DebugApp-LQHFFK3Y.mjs → DebugApp-7PFYN52J.mjs} +30 -23
  2. package/dist/lib/browser/{DebugApp-LQHFFK3Y.mjs.map → DebugApp-7PFYN52J.mjs.map} +4 -4
  3. package/dist/lib/browser/{SpaceGenerator-SPEJBGP7.mjs → SpaceGenerator-NBOQZ4JF.mjs} +12 -12
  4. package/dist/lib/browser/SpaceGenerator-NBOQZ4JF.mjs.map +7 -0
  5. package/dist/lib/browser/app-graph-builder-ALFPRSAR.mjs +570 -0
  6. package/dist/lib/browser/app-graph-builder-ALFPRSAR.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-EF3UVAVI.mjs → chunk-RORUXVAC.mjs} +1 -1
  8. package/dist/lib/browser/chunk-RORUXVAC.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-LHJC7LSH.mjs → chunk-TCEHALD4.mjs} +2 -3
  10. package/dist/lib/browser/chunk-TCEHALD4.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +9 -25
  12. package/dist/lib/browser/index.mjs.map +3 -3
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/{react-context-TCD3MNIT.mjs → react-context-ZRLN5KUI.mjs} +2 -2
  15. package/dist/lib/browser/{react-surface-3CAWUFBU.mjs → react-surface-MXXLOQYV.mjs} +133 -47
  16. package/dist/lib/browser/react-surface-MXXLOQYV.mjs.map +7 -0
  17. package/dist/lib/browser/{settings-DLIPIUG7.mjs → settings-AP74NCXH.mjs} +6 -8
  18. package/dist/lib/browser/{settings-DLIPIUG7.mjs.map → settings-AP74NCXH.mjs.map} +3 -3
  19. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  23. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  24. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  25. package/dist/types/src/components/index.d.ts +0 -4
  26. package/dist/types/src/components/index.d.ts.map +1 -1
  27. package/dist/types/src/meta.d.ts +2 -9
  28. package/dist/types/src/meta.d.ts.map +1 -1
  29. package/dist/types/src/translations.d.ts +1 -0
  30. package/dist/types/src/translations.d.ts.map +1 -1
  31. package/dist/types/src/types.d.ts +1 -1
  32. package/dist/types/src/types.d.ts.map +1 -1
  33. package/package.json +49 -48
  34. package/src/DebugPlugin.tsx +1 -14
  35. package/src/capabilities/app-graph-builder.ts +329 -319
  36. package/src/capabilities/react-surface.tsx +97 -44
  37. package/src/capabilities/settings.ts +1 -3
  38. package/src/components/DebugSettings.tsx +0 -3
  39. package/src/components/SpaceGenerator/ObjectGenerator.tsx +1 -1
  40. package/src/components/SpaceGenerator/SchemaTable.tsx +1 -1
  41. package/src/components/SpaceGenerator/SpaceGenerator.tsx +3 -9
  42. package/src/components/index.ts +0 -1
  43. package/src/meta.ts +2 -2
  44. package/src/translations.ts +3 -2
  45. package/src/types.ts +1 -1
  46. package/dist/lib/browser/DebugSpace-5A2QOKAZ.mjs +0 -277
  47. package/dist/lib/browser/DebugSpace-5A2QOKAZ.mjs.map +0 -7
  48. package/dist/lib/browser/SpaceGenerator-SPEJBGP7.mjs.map +0 -7
  49. package/dist/lib/browser/app-graph-builder-MMXPWK2F.mjs +0 -561
  50. package/dist/lib/browser/app-graph-builder-MMXPWK2F.mjs.map +0 -7
  51. package/dist/lib/browser/chunk-EF3UVAVI.mjs.map +0 -7
  52. package/dist/lib/browser/chunk-GSJS3HEM.mjs +0 -15
  53. package/dist/lib/browser/chunk-GSJS3HEM.mjs.map +0 -7
  54. package/dist/lib/browser/chunk-LHJC7LSH.mjs.map +0 -7
  55. package/dist/lib/browser/react-surface-3CAWUFBU.mjs.map +0 -7
  56. package/dist/types/src/components/DebugSpace/DebugSpace.d.ts +0 -8
  57. package/dist/types/src/components/DebugSpace/DebugSpace.d.ts.map +0 -1
  58. package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts +0 -6
  59. package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +0 -1
  60. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts +0 -15
  61. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +0 -1
  62. package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts +0 -6
  63. package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +0 -1
  64. package/dist/types/src/components/DebugSpace/index.d.ts +0 -3
  65. package/dist/types/src/components/DebugSpace/index.d.ts.map +0 -1
  66. package/src/components/DebugSpace/DebugSpace.stories.tsx +0 -46
  67. package/src/components/DebugSpace/DebugSpace.tsx +0 -183
  68. package/src/components/DebugSpace/ObjectCreator.stories.tsx +0 -51
  69. package/src/components/DebugSpace/ObjectCreator.tsx +0 -100
  70. package/src/components/DebugSpace/index.ts +0 -7
  71. /package/dist/lib/browser/{react-context-TCD3MNIT.mjs.map → react-context-ZRLN5KUI.mjs.map} +0 -0
@@ -2,14 +2,17 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { pipe } from 'effect';
5
6
  import React, { useCallback } from 'react';
6
7
 
7
8
  import {
8
9
  Capabilities,
10
+ chain,
9
11
  contributes,
10
12
  createIntent,
11
13
  createSurface,
12
14
  LayoutAction,
15
+ useCapability,
13
16
  type PluginsContext,
14
17
  } from '@dxos/app-framework';
15
18
  import {
@@ -31,16 +34,18 @@ import {
31
34
  StoragePanel,
32
35
  SwarmPanel,
33
36
  TracingPanel,
34
- DashboardPanel,
35
37
  EdgeDashboardPanel,
36
- SearchPanel,
37
38
  AutomergePanel,
38
39
  WorkflowPanel,
39
40
  QueuesPanel,
40
41
  InvocationTracePanel,
42
+ TestingPanel,
41
43
  } from '@dxos/devtools';
42
44
  import { SettingsStore } from '@dxos/local-storage';
45
+ import { log } from '@dxos/log';
46
+ import { ClientCapabilities } from '@dxos/plugin-client';
43
47
  import { Graph } from '@dxos/plugin-graph';
48
+ import { ScriptAction } from '@dxos/plugin-script/types';
44
49
  import { SpaceAction, CollectionType } from '@dxos/plugin-space/types';
45
50
  import {
46
51
  SpaceState,
@@ -49,17 +54,10 @@ import {
49
54
  type ReactiveEchoObject,
50
55
  type ReactiveObject,
51
56
  type Space,
57
+ parseId,
52
58
  } from '@dxos/react-client/echo';
53
59
 
54
- import {
55
- DebugApp,
56
- DebugObjectPanel,
57
- DebugSettings,
58
- DebugSpace,
59
- DebugStatus,
60
- SpaceGenerator,
61
- Wireframe,
62
- } from '../components';
60
+ import { DebugApp, DebugObjectPanel, DebugSettings, DebugStatus, SpaceGenerator, Wireframe } from '../components';
63
61
  import { DEBUG_PLUGIN } from '../meta';
64
62
  import { type DebugSettingsProps, Devtools } from '../types';
65
63
 
@@ -75,10 +73,19 @@ type GraphDebug = {
75
73
  const isSpaceDebug = (data: any): data is SpaceDebug => data?.type === `${DEBUG_PLUGIN}/space` && isSpace(data.space);
76
74
  const isGraphDebug = (data: any): data is GraphDebug => data?.graph instanceof Graph;
77
75
 
76
+ // TODO(wittjosiah): Factor out?
77
+ const useCurrentSpace = () => {
78
+ const layout = useCapability(Capabilities.Layout);
79
+ const client = useCapability(ClientCapabilities.Client);
80
+ const { spaceId } = parseId(layout.workspace);
81
+ const space = spaceId ? client.spaces.get(spaceId) : undefined;
82
+ return space;
83
+ };
84
+
78
85
  export default (context: PluginsContext) =>
79
86
  contributes(Capabilities.ReactSurface, [
80
87
  createSurface({
81
- id: `${DEBUG_PLUGIN}/settings`,
88
+ id: `${DEBUG_PLUGIN}/plugin-settings`,
82
89
  role: 'article',
83
90
  filter: (data): data is { subject: SettingsStore<DebugSettingsProps> } =>
84
91
  data.subject instanceof SettingsStore && data.subject.prefix === DEBUG_PLUGIN,
@@ -110,12 +117,7 @@ export default (context: PluginsContext) =>
110
117
  [data.subject.space],
111
118
  );
112
119
 
113
- const deprecated = false;
114
- return deprecated ? (
115
- <DebugSpace space={data.subject.space} onAddObjects={handleCreateObject} />
116
- ) : (
117
- <SpaceGenerator space={data.subject.space} onCreateObjects={handleCreateObject} />
118
- );
120
+ return <SpaceGenerator space={data.subject.space} onCreateObjects={handleCreateObject} />;
119
121
  },
120
122
  }),
121
123
  createSurface({
@@ -139,10 +141,11 @@ export default (context: PluginsContext) =>
139
141
  ),
140
142
  }),
141
143
  createSurface({
142
- id: `${DEBUG_PLUGIN}/complementary`,
143
- role: 'complementary--debug',
144
- filter: (data): data is { subject: ReactiveEchoObject<any> } => isEchoObject(data.subject),
145
- component: ({ data }) => <DebugObjectPanel object={data.subject} />,
144
+ id: `${DEBUG_PLUGIN}/object-debug`,
145
+ role: 'article',
146
+ filter: (data): data is { companionTo: ReactiveEchoObject<any> } =>
147
+ data.subject === 'debug' && isEchoObject(data.companionTo),
148
+ component: ({ data }) => <DebugObjectPanel object={data.companionTo} />,
146
149
  }),
147
150
  createSurface({
148
151
  id: `${DEBUG_PLUGIN}/status`,
@@ -158,7 +161,7 @@ export default (context: PluginsContext) =>
158
161
  id: `${DEBUG_PLUGIN}/client/config`,
159
162
  role: 'article',
160
163
  filter: (data): data is any => data.subject === Devtools.Client.Config,
161
- component: () => <ConfigPanel />,
164
+ component: () => <ConfigPanel vaultSelector={false} />,
162
165
  }),
163
166
  createSurface({
164
167
  id: `${DEBUG_PLUGIN}/client/storage`,
@@ -206,7 +209,10 @@ export default (context: PluginsContext) =>
206
209
  id: `${DEBUG_PLUGIN}/halo/credentials`,
207
210
  role: 'article',
208
211
  filter: (data): data is any => data.subject === Devtools.Halo.Credentials,
209
- component: () => <CredentialsPanel />,
212
+ component: () => {
213
+ const space = useCurrentSpace();
214
+ return <CredentialsPanel space={space} />;
215
+ },
210
216
  }),
211
217
  createSurface({
212
218
  id: `${DEBUG_PLUGIN}/echo/spaces`,
@@ -226,31 +232,41 @@ export default (context: PluginsContext) =>
226
232
  role: 'article',
227
233
  filter: (data): data is any => data.subject === Devtools.Echo.Space,
228
234
  component: () => {
235
+ const space = useCurrentSpace();
229
236
  const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
230
237
  const handleSelect = useCallback(
231
238
  () => dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [Devtools.Echo.Feeds] })),
232
239
  [dispatch],
233
240
  );
234
- return <SpaceInfoPanel onSelectFeed={handleSelect} onSelectPipeline={handleSelect} />;
241
+ return <SpaceInfoPanel space={space} onSelectFeed={handleSelect} onSelectPipeline={handleSelect} />;
235
242
  },
236
243
  }),
237
244
  createSurface({
238
245
  id: `${DEBUG_PLUGIN}/echo/feeds`,
239
246
  role: 'article',
240
247
  filter: (data): data is any => data.subject === Devtools.Echo.Feeds,
241
- component: () => <FeedsPanel />,
248
+ component: () => {
249
+ const space = useCurrentSpace();
250
+ return <FeedsPanel space={space} />;
251
+ },
242
252
  }),
243
253
  createSurface({
244
254
  id: `${DEBUG_PLUGIN}/echo/objects`,
245
255
  role: 'article',
246
256
  filter: (data): data is any => data.subject === Devtools.Echo.Objects,
247
- component: () => <ObjectsPanel />,
257
+ component: () => {
258
+ const space = useCurrentSpace();
259
+ return <ObjectsPanel space={space} />;
260
+ },
248
261
  }),
249
262
  createSurface({
250
263
  id: `${DEBUG_PLUGIN}/echo/automerge`,
251
264
  role: 'article',
252
265
  filter: (data): data is any => data.subject === Devtools.Echo.Automerge,
253
- component: () => <AutomergePanel />,
266
+ component: () => {
267
+ const space = useCurrentSpace();
268
+ return <AutomergePanel space={space} />;
269
+ },
254
270
  }),
255
271
  createSurface({
256
272
  id: `${DEBUG_PLUGIN}/echo/queues`,
@@ -262,7 +278,10 @@ export default (context: PluginsContext) =>
262
278
  id: `${DEBUG_PLUGIN}/echo/members`,
263
279
  role: 'article',
264
280
  filter: (data): data is any => data.subject === Devtools.Echo.Members,
265
- component: () => <MembersPanel />,
281
+ component: () => {
282
+ const space = useCurrentSpace();
283
+ return <MembersPanel space={space} />;
284
+ },
266
285
  }),
267
286
  createSurface({
268
287
  id: `${DEBUG_PLUGIN}/echo/metadata`,
@@ -286,20 +305,18 @@ export default (context: PluginsContext) =>
286
305
  id: `${DEBUG_PLUGIN}/mesh/network`,
287
306
  role: 'article',
288
307
  filter: (data): data is any => data.subject === Devtools.Mesh.Network,
289
- component: () => <NetworkPanel />,
290
- }),
291
- createSurface({
292
- id: `${DEBUG_PLUGIN}/agent/dashboard`,
293
- role: 'article',
294
- filter: (data): data is any => data.subject === Devtools.Agent.Dashboard,
295
- component: () => <DashboardPanel />,
296
- }),
297
- createSurface({
298
- id: `${DEBUG_PLUGIN}/agent/search`,
299
- role: 'article',
300
- filter: (data): data is any => data.subject === Devtools.Agent.Search,
301
- component: () => <SearchPanel />,
308
+ component: () => {
309
+ const space = useCurrentSpace();
310
+ return <NetworkPanel space={space} />;
311
+ },
302
312
  }),
313
+ // TODO(wittjosiah): Remove?
314
+ // createSurface({
315
+ // id: `${DEBUG_PLUGIN}/agent/dashboard`,
316
+ // role: 'article',
317
+ // filter: (data): data is any => data.subject === Devtools.Agent.Dashboard,
318
+ // component: () => <DashboardPanel />,
319
+ // }),
303
320
  createSurface({
304
321
  id: `${DEBUG_PLUGIN}/edge/dashboard`,
305
322
  role: 'article',
@@ -310,12 +327,48 @@ export default (context: PluginsContext) =>
310
327
  id: `${DEBUG_PLUGIN}/edge/workflows`,
311
328
  role: 'article',
312
329
  filter: (data): data is any => data.subject === Devtools.Edge.Workflows,
313
- component: () => <WorkflowPanel />,
330
+ component: () => {
331
+ const space = useCurrentSpace();
332
+ return <WorkflowPanel space={space} />;
333
+ },
314
334
  }),
315
335
  createSurface({
316
336
  id: `${DEBUG_PLUGIN}/edge/traces`,
317
337
  role: 'article',
318
338
  filter: (data): data is any => data.subject === Devtools.Edge.Traces,
319
- component: () => <InvocationTracePanel />,
339
+ component: () => {
340
+ const space = useCurrentSpace();
341
+ return <InvocationTracePanel space={space} />;
342
+ },
343
+ }),
344
+ createSurface({
345
+ id: `${DEBUG_PLUGIN}/edge/testing`,
346
+ role: 'article',
347
+ filter: (data): data is any => data.subject === Devtools.Edge.Testing,
348
+ component: () => {
349
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
350
+ const onSpaceCreate = useCallback(
351
+ async (space: Space) => {
352
+ await space.waitUntilReady();
353
+ await dispatch(createIntent(SpaceAction.Migrate, { space }));
354
+ await space.db.flush();
355
+ },
356
+ [dispatch],
357
+ );
358
+ const onScriptPluginOpen = useCallback(
359
+ async (space: Space) => {
360
+ await space.waitUntilReady();
361
+ const result = await dispatch(
362
+ pipe(createIntent(ScriptAction.Create, { space }), chain(SpaceAction.AddObject, { target: space })),
363
+ );
364
+ log.info('script created', { result });
365
+ await dispatch(
366
+ createIntent(LayoutAction.Open, { part: 'main', subject: [`${space.id}:${result.data?.object.id}`] }),
367
+ );
368
+ },
369
+ [dispatch],
370
+ );
371
+ return <TestingPanel onSpaceCreate={onSpaceCreate} onScriptPluginOpen={onScriptPluginOpen} />;
372
+ },
320
373
  }),
321
374
  ]);
@@ -9,9 +9,7 @@ import { DEBUG_PLUGIN } from '../meta';
9
9
  import { type DebugSettingsProps, DebugSettingsSchema } from '../types';
10
10
 
11
11
  export default () => {
12
- const settings = create<DebugSettingsProps>({
13
- debug: true,
14
- });
12
+ const settings = create<DebugSettingsProps>({});
15
13
 
16
14
  return contributes(Capabilities.Settings, { schema: DebugSettingsSchema, prefix: DEBUG_PLUGIN, value: settings });
17
15
  };
@@ -78,9 +78,6 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
78
78
 
79
79
  return (
80
80
  <DeprecatedFormContainer>
81
- <DeprecatedFormInput label={t('settings show debug panel')}>
82
- <Input.Switch checked={settings.debug} onCheckedChange={(checked) => (settings.debug = !!checked)} />
83
- </DeprecatedFormInput>
84
81
  <DeprecatedFormInput label={t('settings wireframe')}>
85
82
  <Input.Switch checked={settings.wireframe} onCheckedChange={(checked) => (settings.wireframe = !!checked)} />
86
83
  </DeprecatedFormInput>
@@ -150,7 +150,7 @@ export const createGenerator = <T extends BaseObject>(type: TypedObject<T>): Obj
150
150
  (await space.db.schemaRegistry.register([type]))[0];
151
151
 
152
152
  // Create objects.
153
- const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { db: space.db });
153
+ const generate = createAsyncGenerator(generator, schema.snapshot, { db: space.db });
154
154
  const objects = await generate.createObjects(n);
155
155
 
156
156
  // Find or create table and view.
@@ -15,7 +15,7 @@ export type SchemaTableProps = {
15
15
 
16
16
  export const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTableProps) => {
17
17
  return (
18
- <div className='grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden'>
18
+ <div className='grid grid-cols-[1fr_80px_40px] gap-1 overflow-none'>
19
19
  <div className='grid grid-cols-subgrid col-span-3'>
20
20
  <div className='px-2 text-sm text-primary-500'>{label}</div>
21
21
  <div className='px-2 text-xs text-subdued text-right'>count</div>
@@ -34,13 +34,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
34
34
  const { dispatchPromise: dispatch } = useIntentDispatcher();
35
35
  const client = useClient();
36
36
  const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
37
- const mutableTypes = [
38
- Testing.OrgType,
39
- Testing.ProjectType,
40
- Testing.ContactType,
41
- Testing.EmailType,
42
- Testing.MessageType,
43
- ];
37
+ const mutableTypes = [Testing.Org, Testing.Project, Testing.Contact, Testing.Message];
44
38
  const [count, setCount] = useState(1);
45
39
  const [info, setInfo] = useState<any>({});
46
40
 
@@ -118,7 +112,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
118
112
  const parts = schema.typename.split('/');
119
113
  const name = parts[parts.length - 1];
120
114
  const table = create(TableType, { name, threads: [] });
121
- await initializeTable({ space, table, initialSchema: schema.typename });
115
+ await initializeTable({ client, space, table, typename: schema.typename });
122
116
  await dispatch(createIntent(SpaceAction.AddObject, { target: space, object: table }));
123
117
  return table;
124
118
  }),
@@ -145,7 +139,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
145
139
  }, []);
146
140
 
147
141
  return (
148
- <div role='none' className='flex flex-col divide-y divide-separator'>
142
+ <div role='none' className='flex flex-col divide-y divide-separator overflow-y-auto'>
149
143
  <Toolbar.Root classNames='p-1'>
150
144
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
151
145
  <IconButton
@@ -5,7 +5,6 @@
5
5
  import { lazy } from 'react';
6
6
 
7
7
  export const DebugApp = lazy(() => import('./DebugApp'));
8
- export const DebugSpace = lazy(() => import('./DebugSpace'));
9
8
  export const SpaceGenerator = lazy(() => import('./SpaceGenerator'));
10
9
 
11
10
  export * from './DebugObjectPanel';
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
8
8
 
9
- export const meta = {
9
+ export const meta: PluginMeta = {
10
10
  id: DEBUG_PLUGIN,
11
11
  name: 'Debug',
12
12
  description:
@@ -15,4 +15,4 @@ export const meta = {
15
15
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
16
16
  tags: ['experimental'],
17
17
  screenshots: ['https://dxos.network/plugin-details-debug-dark.png'],
18
- } satisfies PluginMeta;
18
+ };
@@ -51,16 +51,17 @@ export default [
51
51
  'queues label': 'Queues',
52
52
  'members label': 'Members',
53
53
  'metadata label': 'Metadata',
54
- 'mesh label': 'Mesh',
54
+ 'mesh label': 'MESH',
55
55
  'signal label': 'Signal',
56
56
  'swarm label': 'Swarm',
57
57
  'network label': 'Network',
58
58
  'agent label': 'Agent',
59
59
  'dashboard label': 'Dashboard',
60
60
  'search label': 'Search',
61
- 'edge label': 'Edge',
61
+ 'edge label': 'EDGE',
62
62
  'workflows label': 'Workflows',
63
63
  'traces label': 'Traces',
64
+ 'testing label': 'Testing',
64
65
  },
65
66
  },
66
67
  },
package/src/types.ts CHANGED
@@ -21,7 +21,6 @@ export const DebugContext: Context<DebugContextType> = createContext<DebugContex
21
21
 
22
22
  export const DebugSettingsSchema = S.mutable(
23
23
  S.Struct({
24
- debug: S.optional(S.Boolean),
25
24
  wireframe: S.optional(S.Boolean),
26
25
  }),
27
26
  );
@@ -79,5 +78,6 @@ export namespace Devtools {
79
78
  export const Dashboard = `${Devtools.Edge.id}.dashboard`;
80
79
  export const Workflows = `${Devtools.Edge.id}.workflows`;
81
80
  export const Traces = `${Devtools.Edge.id}.traces`;
81
+ export const Testing = `${Devtools.Edge.id}.testing`;
82
82
  }
83
83
  }
@@ -1,277 +0,0 @@
1
- import {
2
- Container
3
- } from "./chunk-GSJS3HEM.mjs";
4
- import {
5
- DebugContext
6
- } from "./chunk-LHJC7LSH.mjs";
7
-
8
- // packages/plugins/plugin-debug/src/components/DebugSpace/DebugSpace.tsx
9
- import React2, { useContext, useMemo as useMemo2, useState as useState2 } from "react";
10
- import { createSpaceObjectGenerator as createSpaceObjectGenerator2 } from "@dxos/echo-generator";
11
- import { DocumentType } from "@dxos/plugin-markdown/types";
12
- import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
13
- import { faker } from "@dxos/random";
14
- import { useClient } from "@dxos/react-client";
15
- import { Filter, useSpaceInvitation } from "@dxos/react-client/echo";
16
- import { InvitationEncoder } from "@dxos/react-client/invitations";
17
- import { useAsyncEffect } from "@dxos/react-hooks";
18
- import { Icon, IconButton as IconButton2, Input, Toolbar as Toolbar2, useFileDownload } from "@dxos/react-ui";
19
- import { safeParseInt } from "@dxos/util";
20
-
21
- // packages/plugins/plugin-debug/src/components/DebugSpace/ObjectCreator.tsx
22
- import React, { useMemo, useState } from "react";
23
- import { TestSchemaType, createSpaceObjectGenerator } from "@dxos/echo-generator";
24
- import { IconButton, Toolbar } from "@dxos/react-ui";
25
- import { createColumnBuilder, Table } from "@dxos/react-ui-table/deprecated";
26
- var BATCH_SIZE = 10;
27
- var ObjectCreator = ({ space, onAddObjects }) => {
28
- const generator = useMemo(() => createSpaceObjectGenerator(space), [
29
- space
30
- ]);
31
- const [objects, setObjects] = useState(Object.values(TestSchemaType).map((schema) => ({
32
- schema,
33
- enabled: true,
34
- objects: 10,
35
- mutations: {
36
- count: 10,
37
- mutationSize: 10,
38
- maxContentLength: 1e3
39
- }
40
- })));
41
- const handleCreate = async () => {
42
- for (const params of objects) {
43
- if (!params.enabled) {
44
- continue;
45
- }
46
- let objectsCreated = 0;
47
- while (objectsCreated < params.objects) {
48
- const objects2 = await generator.createObjects({
49
- [params.schema]: Math.min(BATCH_SIZE, params.objects - objectsCreated)
50
- });
51
- await generator.mutateObjects(objects2, params.mutations);
52
- objectsCreated += objects2.length;
53
- onAddObjects?.(objects2);
54
- }
55
- }
56
- await space.db.flush();
57
- };
58
- const handleUpdate = (row, key, value) => {
59
- const newObjects = [
60
- ...objects
61
- ];
62
- Object.assign(newObjects.find((object) => object.schema === row.schema), {
63
- [key]: value
64
- });
65
- setObjects(newObjects);
66
- };
67
- const { helper, builder } = createColumnBuilder();
68
- const columns = [
69
- helper.accessor("enabled", builder.switch({
70
- label: "Live",
71
- onUpdate: handleUpdate
72
- })),
73
- helper.accessor("schema", builder.string({
74
- label: "Schema",
75
- classNames: "font-mono"
76
- })),
77
- helper.accessor("objects", builder.number({
78
- label: "Objects",
79
- onUpdate: handleUpdate
80
- })),
81
- helper.accessor((obj) => obj.mutations.count, {
82
- id: "mutations",
83
- ...builder.number({
84
- label: "Mutations",
85
- onUpdate: handleUpdate
86
- })
87
- }),
88
- helper.accessor((obj) => obj.mutations.mutationSize, {
89
- id: "mutationSize",
90
- ...builder.number({
91
- label: "Mut. Size",
92
- onUpdate: handleUpdate
93
- })
94
- }),
95
- helper.accessor((obj) => obj.mutations.maxContentLength, {
96
- id: "mutationMaxContentLength",
97
- ...builder.number({
98
- label: "Length",
99
- onUpdate: handleUpdate
100
- })
101
- })
102
- ];
103
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Table.Root, null, /* @__PURE__ */ React.createElement(Table.Viewport, null, /* @__PURE__ */ React.createElement(Table.Main, {
104
- columns,
105
- data: objects
106
- }))), /* @__PURE__ */ React.createElement(Toolbar.Root, {
107
- classNames: "p-1"
108
- }, /* @__PURE__ */ React.createElement(IconButton, {
109
- icon: "ph--plus--regular",
110
- label: "Create",
111
- onClick: handleCreate
112
- })));
113
- };
114
-
115
- // packages/plugins/plugin-debug/src/components/DebugSpace/DebugSpace.tsx
116
- var DEFAULT_COUNT = 100;
117
- var DEFAULT_PERIOD = 500;
118
- var DEFAULT_JITTER = 50;
119
- var useRefresh = () => {
120
- const [update, setUpdate] = useState2({});
121
- return [
122
- update,
123
- () => setUpdate({})
124
- ];
125
- };
126
- var CustomInput = ({ icon, ...props }) => {
127
- return /* @__PURE__ */ React2.createElement("div", {
128
- role: "none",
129
- className: "relative"
130
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
131
- classNames: "w-[100px] text-right pie-[22px]",
132
- size: 5,
133
- ...props
134
- })), /* @__PURE__ */ React2.createElement(Icon, {
135
- icon,
136
- size: 3,
137
- classNames: "absolute inline-end-1 block-start-1 mt-[6px]"
138
- }));
139
- };
140
- var DebugSpace = ({ space, onAddObjects }) => {
141
- const { connect } = useSpaceInvitation(space?.key);
142
- const client = useClient();
143
- const [data, setData] = useState2({});
144
- const [update, handleUpdate] = useRefresh();
145
- useAsyncEffect(async (isMounted) => {
146
- const data2 = await client.diagnostics({
147
- truncate: true
148
- });
149
- if (isMounted()) {
150
- setData(data2?.diagnostics?.spaces?.find(({ key }) => {
151
- return space.key.toHex().startsWith(key);
152
- }));
153
- }
154
- }, [
155
- space,
156
- update
157
- ]);
158
- const download = useFileDownload();
159
- const handleDownload = async () => {
160
- download(new Blob([
161
- JSON.stringify(data, void 0, 2)
162
- ], {
163
- type: "text/plain"
164
- }), `${(/* @__PURE__ */ new Date()).toISOString().replace(/\W/g, "-")}.json`);
165
- };
166
- const [mutationCount, setMutationCount] = useState2(String(DEFAULT_COUNT));
167
- const [mutationInterval, setMutationInterval] = useState2(String(DEFAULT_PERIOD));
168
- const [mutationJitter, setMutationJitter] = useState2(String(DEFAULT_JITTER));
169
- const generator = useMemo2(() => createSpaceObjectGenerator2(space), [
170
- space
171
- ]);
172
- const { running, start, stop } = useContext(DebugContext);
173
- const handleToggleRunning = () => {
174
- if (running) {
175
- stop();
176
- handleUpdate();
177
- } else {
178
- start(async () => {
179
- const { objects } = await space.db.query(Filter.schema(DocumentType)).run();
180
- if (objects.length) {
181
- const object = faker.helpers.arrayElement(objects);
182
- await generator.mutateObject(object, {
183
- count: 10,
184
- mutationSize: 10,
185
- maxContentLength: 1e3
186
- });
187
- }
188
- }, {
189
- count: safeParseInt(mutationCount) ?? 0,
190
- interval: safeParseInt(mutationInterval) ?? 0,
191
- jitter: safeParseInt(mutationJitter) ?? 0
192
- });
193
- }
194
- };
195
- const handleCreateInvitation = () => {
196
- const invitation = space.share({
197
- type: Invitation.Type.INTERACTIVE,
198
- authMethod: Invitation.AuthMethod.NONE,
199
- multiUse: true
200
- });
201
- connect(invitation);
202
- const code = InvitationEncoder.encode(invitation.get());
203
- new URL(window.origin).searchParams.set("spaceInvitationCode", code);
204
- const url = `${window.origin}?spaceInvitationCode=${code}`;
205
- void navigator.clipboard.writeText(url);
206
- };
207
- const handleCreateEpoch = async () => {
208
- await space.internal.createEpoch();
209
- handleUpdate();
210
- };
211
- return /* @__PURE__ */ React2.createElement(Container, {
212
- toolbar: /* @__PURE__ */ React2.createElement(Toolbar2.Root, {
213
- classNames: "p-1"
214
- }, /* @__PURE__ */ React2.createElement(CustomInput, {
215
- icon: "ph--flag--regular",
216
- autoComplete: "off",
217
- placeholder: "Count",
218
- value: mutationCount,
219
- onChange: ({ target: { value } }) => setMutationCount(value)
220
- }), /* @__PURE__ */ React2.createElement(CustomInput, {
221
- icon: "ph--timer--regular",
222
- autoComplete: "off",
223
- placeholder: "Interval",
224
- value: mutationInterval,
225
- onChange: ({ target: { value } }) => setMutationInterval(value)
226
- }), /* @__PURE__ */ React2.createElement(CustomInput, {
227
- icon: "ph--plus-minus--regular",
228
- autoComplete: "off",
229
- placeholder: "Jitter",
230
- value: mutationJitter,
231
- onChange: ({ target: { value } }) => setMutationJitter(value)
232
- }), /* @__PURE__ */ React2.createElement(IconButton2, {
233
- icon: running ? "ph--pause-circle--regular" : "ph--play-circle--regular",
234
- iconOnly: true,
235
- label: "Start/stop",
236
- size: 5,
237
- onClick: handleToggleRunning
238
- }), /* @__PURE__ */ React2.createElement(IconButton2, {
239
- icon: "ph--arrow-clockwise--regular",
240
- iconOnly: true,
241
- label: "Refresh",
242
- size: 5,
243
- onClick: handleUpdate
244
- }), /* @__PURE__ */ React2.createElement(IconButton2, {
245
- icon: "ph--download-simple--regular",
246
- iconOnly: true,
247
- label: "Download",
248
- size: 5,
249
- onClick: handleDownload
250
- }), /* @__PURE__ */ React2.createElement(Toolbar2.Separator, {
251
- variant: "gap"
252
- }), /* @__PURE__ */ React2.createElement(IconButton2, {
253
- icon: "ph--flag-pennant--regular",
254
- iconOnly: true,
255
- label: "Create epoch",
256
- size: 5,
257
- onClick: handleCreateEpoch
258
- }), /* @__PURE__ */ React2.createElement(IconButton2, {
259
- icon: "ph--user-circle-plus--regular",
260
- iconOnly: true,
261
- iconClassNames: "text-blue-500",
262
- label: "Create Invitation",
263
- size: 5,
264
- onClick: handleCreateInvitation
265
- }))
266
- }, /* @__PURE__ */ React2.createElement(ObjectCreator, {
267
- space,
268
- onAddObjects
269
- }));
270
- };
271
-
272
- // packages/plugins/plugin-debug/src/components/DebugSpace/index.ts
273
- var DebugSpace_default = DebugSpace;
274
- export {
275
- DebugSpace_default as default
276
- };
277
- //# sourceMappingURL=DebugSpace-5A2QOKAZ.mjs.map