@dxos/plugin-debug 0.7.4 → 0.7.5-labs.a279d8c

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 (80) hide show
  1. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
  2. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
  3. package/dist/lib/browser/{DebugSpace-DHKEAMIC.mjs → DebugSpace-4JHYA7FG.mjs} +7 -6
  4. package/dist/lib/browser/DebugSpace-4JHYA7FG.mjs.map +7 -0
  5. package/dist/lib/browser/{SpaceGenerator-BQ3645OS.mjs → SpaceGenerator-YNT3WDFI.mjs} +226 -20
  6. package/dist/lib/browser/SpaceGenerator-YNT3WDFI.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs +177 -0
  8. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-CAENAAHY.mjs → chunk-I3ON45JK.mjs} +3 -3
  10. package/dist/lib/browser/chunk-I3ON45JK.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-LZEK532R.mjs → chunk-P7GHHMDB.mjs} +1 -11
  12. package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +66 -737
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/react-context-OZU6J7G3.mjs +37 -0
  17. package/dist/lib/browser/react-context-OZU6J7G3.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-ACHNR2UU.mjs +481 -0
  19. package/dist/lib/browser/react-surface-ACHNR2UU.mjs.map +7 -0
  20. package/dist/lib/browser/settings-JCZUA643.mjs +25 -0
  21. package/dist/lib/browser/settings-JCZUA643.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +1 -2
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  25. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +185 -0
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  29. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  31. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/settings.d.ts +4 -0
  33. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  34. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  35. package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  38. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +2 -2
  39. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  40. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  41. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  42. package/dist/types/src/components/Wireframe.d.ts +2 -1
  43. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  44. package/dist/types/src/index.d.ts +1 -2
  45. package/dist/types/src/index.d.ts.map +1 -1
  46. package/dist/types/src/meta.d.ts +1 -2
  47. package/dist/types/src/meta.d.ts.map +1 -1
  48. package/dist/types/src/types.d.ts +0 -6
  49. package/dist/types/src/types.d.ts.map +1 -1
  50. package/dist/types/tsconfig.tsbuildinfo +1 -0
  51. package/package.json +48 -51
  52. package/src/DebugPlugin.tsx +60 -381
  53. package/src/capabilities/app-graph-builder.ts +177 -0
  54. package/src/capabilities/index.ts +10 -0
  55. package/src/capabilities/react-context.tsx +38 -0
  56. package/src/capabilities/react-surface.tsx +138 -0
  57. package/src/capabilities/settings.ts +18 -0
  58. package/src/components/DebugApp/DebugApp.tsx +1 -1
  59. package/src/components/DebugObjectPanel.tsx +17 -5
  60. package/src/components/DebugSettings.tsx +4 -4
  61. package/src/components/DebugSpace/DebugSpace.stories.tsx +4 -3
  62. package/src/components/DebugSpace/DebugSpace.tsx +1 -1
  63. package/src/components/DebugSpace/ObjectCreator.stories.tsx +4 -3
  64. package/src/components/DebugStatus.tsx +3 -9
  65. package/src/components/SpaceGenerator/ObjectGenerator.tsx +126 -18
  66. package/src/components/SpaceGenerator/SpaceGenerator.tsx +6 -4
  67. package/src/components/SpaceGenerator/draw-util.ts +7 -6
  68. package/src/components/Wireframe.tsx +2 -2
  69. package/src/index.ts +1 -4
  70. package/src/meta.ts +1 -1
  71. package/src/types.ts +0 -22
  72. package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
  73. package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
  74. package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
  75. package/dist/lib/browser/chunk-LZEK532R.mjs.map +0 -7
  76. package/dist/lib/browser/meta.mjs +0 -9
  77. package/dist/lib/browser/meta.mjs.map +0 -7
  78. package/dist/types/src/components/DebugSurface.d.ts +0 -9
  79. package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
  80. package/src/components/DebugSurface.tsx +0 -55
@@ -2,17 +2,38 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type AbstractSchema, type BaseObject } from '@dxos/echo-schema';
6
- import { create, type ReactiveObject } from '@dxos/live-object';
7
- import { DocumentType, TextType } from '@dxos/plugin-markdown/types';
8
- import { addressToA1Notation, createSheet } from '@dxos/plugin-sheet';
9
- import { type CellValue } from '@dxos/plugin-sheet/types';
10
- import { SheetType } from '@dxos/plugin-sheet/types';
5
+ import { addressToA1Notation } from '@dxos/compute';
6
+ import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
7
+ import { ObjectId, type BaseObject, type TypedObject } from '@dxos/echo-schema';
8
+ import { type FunctionTrigger, TriggerKind } from '@dxos/functions/types';
9
+ import { invariant } from '@dxos/invariant';
10
+ import { DXN, SpaceId } from '@dxos/keys';
11
+ import { create, makeRef, type ReactiveObject } from '@dxos/live-object';
12
+ import { DocumentType } from '@dxos/plugin-markdown/types';
13
+ import { createSheet } from '@dxos/plugin-sheet/types';
14
+ import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
11
15
  import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
12
16
  import { faker } from '@dxos/random';
13
17
  import { Filter, type Space } from '@dxos/react-client/echo';
18
+ import {
19
+ type ComputeShape,
20
+ createAppend,
21
+ createComputeGraph,
22
+ createConstant,
23
+ createGpt,
24
+ createQueue,
25
+ createText,
26
+ createTrigger,
27
+ } from '@dxos/react-ui-canvas-compute';
28
+ import {
29
+ pointMultiply,
30
+ pointsToRect,
31
+ rectToPoints,
32
+ CanvasBoardType,
33
+ CanvasGraphModel,
34
+ } from '@dxos/react-ui-canvas-editor';
14
35
  import { TableType } from '@dxos/react-ui-table';
15
- import { createView } from '@dxos/schema';
36
+ import { createView, TextType } from '@dxos/schema';
16
37
  import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
17
38
  import { range } from '@dxos/util';
18
39
 
@@ -37,15 +58,13 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
37
58
  DocumentType.typename,
38
59
  async (space, n, cb) => {
39
60
  const objects = range(n).map(() => {
40
- const obj = space.db.add(
61
+ return space.db.add(
41
62
  create(DocumentType, {
42
63
  name: faker.commerce.productName(),
43
- content: create(TextType, { content: faker.lorem.sentences(5) }),
64
+ content: makeRef(create(TextType, { content: faker.lorem.sentences(5) })),
44
65
  threads: [],
45
66
  }),
46
67
  );
47
-
48
- return obj;
49
68
  });
50
69
 
51
70
  cb?.(objects);
@@ -60,7 +79,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
60
79
  const obj = space.db.add(
61
80
  create(DiagramType, {
62
81
  name: faker.commerce.productName(),
63
- canvas: create(CanvasType, { content: {} }),
82
+ canvas: makeRef(create(CanvasType, { content: {} })),
64
83
  }),
65
84
  );
66
85
 
@@ -109,30 +128,119 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
109
128
  return objects;
110
129
  },
111
130
  ],
131
+ [
132
+ ComputeGraph.typename,
133
+ async (space, n, cb) => {
134
+ const objects = range(n, () => {
135
+ const model = ComputeGraphModel.create();
136
+ model.builder
137
+ .createNode({ id: 'gpt-INPUT', type: NODE_INPUT })
138
+ .createNode({ id: 'gpt-GPT', type: 'gpt' })
139
+ .createNode({
140
+ id: 'gpt-QUEUE_ID',
141
+ type: 'constant',
142
+ value: new DXN(DXN.kind.QUEUE, ['data', SpaceId.random(), ObjectId.random()]).toString(),
143
+ })
144
+ .createNode({ id: 'gpt-APPEND', type: 'append' })
145
+ .createNode({ id: 'gpt-OUTPUT', type: NODE_OUTPUT })
146
+ .createEdge({ node: 'gpt-INPUT', property: 'prompt' }, { node: 'gpt-GPT', property: 'prompt' })
147
+ .createEdge({ node: 'gpt-GPT', property: 'text' }, { node: 'gpt-OUTPUT', property: 'text' })
148
+ .createEdge({ node: 'gpt-QUEUE_ID', property: DEFAULT_OUTPUT }, { node: 'gpt-APPEND', property: 'id' })
149
+ .createEdge({ node: 'gpt-GPT', property: 'messages' }, { node: 'gpt-APPEND', property: 'items' })
150
+ .createEdge({ node: 'gpt-QUEUE_ID', property: DEFAULT_OUTPUT }, { node: 'gpt-OUTPUT', property: 'queue' });
151
+
152
+ return space.db.add(model.root);
153
+ });
154
+ cb?.(objects);
155
+ return objects;
156
+ },
157
+ ],
158
+ [
159
+ CanvasBoardType.typename,
160
+ async (space, n, cb) => {
161
+ const objects = range(n, () => {
162
+ const canvasModel = CanvasGraphModel.create<ComputeShape>();
163
+
164
+ let functionTrigger: FunctionTrigger | undefined;
165
+ canvasModel.builder.call((builder) => {
166
+ const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
167
+ const triggerShape = createTrigger({ triggerKind: TriggerKind.Webhook, ...position({ x: -18, y: -2 }) });
168
+ const trigger = canvasModel.createNode(triggerShape);
169
+ const text = canvasModel.createNode(createText(position({ x: 19, y: 3, width: 10, height: 10 })));
170
+ const queueId = canvasModel.createNode(
171
+ createConstant({
172
+ value: new DXN(DXN.kind.QUEUE, ['data', SpaceId.random(), ObjectId.random()]).toString(),
173
+ ...position({ x: -18, y: 5, width: 8, height: 6 }),
174
+ }),
175
+ );
176
+ const queue = canvasModel.createNode(createQueue(position({ x: -3, y: 3, width: 14, height: 10 })));
177
+ const append = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
178
+
179
+ builder
180
+ .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'bodyText' })
181
+ .createEdge({ source: gpt.id, target: text.id, output: 'text' })
182
+ .createEdge({ source: queueId.id, target: queue.id })
183
+ .createEdge({ source: queueId.id, target: append.id, input: 'id' })
184
+ .createEdge({ source: gpt.id, target: append.id, output: 'messages', input: 'items' });
185
+
186
+ functionTrigger = triggerShape.functionTrigger!.target!;
187
+ });
188
+
189
+ const computeModel = createComputeGraph(canvasModel);
190
+ const computeGraph = computeModel.root;
191
+
192
+ invariant(functionTrigger);
193
+ functionTrigger.function = DXN.fromLocalObjectId(computeGraph.id).toString();
194
+ functionTrigger.meta ??= {};
195
+ const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT)!;
196
+ functionTrigger.meta.computeNodeId = inputNode.id;
197
+
198
+ return space.db.add(
199
+ create(CanvasBoardType, {
200
+ computeGraph: makeRef(computeGraph),
201
+ layout: canvasModel.graph,
202
+ }),
203
+ );
204
+ });
205
+ cb?.(objects);
206
+ return objects;
207
+ },
208
+ ],
112
209
  ]);
113
210
 
114
- export const createGenerator = <T extends BaseObject>(type: AbstractSchema<T>): ObjectGenerator<T> => {
211
+ const position = (rect: { x: number; y: number; width?: number; height?: number }) => {
212
+ const snap = 32;
213
+ const [center, size] = rectToPoints({ width: 0, height: 0, ...rect });
214
+ const { x, y, width, height } = pointsToRect([pointMultiply(center, snap), pointMultiply(size, snap)]);
215
+ if (width && height) {
216
+ return { center: { x, y }, size: width && height ? { width, height } : undefined };
217
+ } else {
218
+ return { center: { x, y } };
219
+ }
220
+ };
221
+
222
+ export const createGenerator = <T extends BaseObject>(type: TypedObject<T>): ObjectGenerator<T> => {
115
223
  return async (
116
224
  space: Space,
117
225
  n: number,
118
226
  cb?: (objects: ReactiveObject<any>[]) => void,
119
227
  ): Promise<ReactiveObject<T>[]> => {
120
228
  // Find or create mutable schema.
121
- const mutableSchema = await space.db.schemaRegistry.query();
122
229
  const schema =
123
- mutableSchema.find((schema) => schema.typename === type.typename) ?? space.db.schemaRegistry.addSchema(type);
230
+ (await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??
231
+ (await space.db.schemaRegistry.register([type]))[0];
124
232
 
125
233
  // Create objects.
126
- const generate = createAsyncGenerator(generator, schema.schema, { db: space.db });
234
+ const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { db: space.db });
127
235
  const objects = await generate.createObjects(n);
128
236
 
129
237
  // Find or create table and view.
130
238
  const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
131
- const table = tables.find((table) => table.view?.query?.type === type.typename);
239
+ const table = tables.find((table) => table.view?.target?.query?.type === type.typename);
132
240
  if (!table) {
133
241
  const name = type.typename.split('/').pop() ?? type.typename;
134
242
  const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });
135
- const table = space.db.add(create(TableType, { name, view }));
243
+ const table = space.db.add(create(TableType, { name, view: makeRef(view) }));
136
244
  cb?.([table]);
137
245
  }
138
246
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  import React, { useCallback, useMemo, useState } from 'react';
6
6
 
7
+ import { ComputeGraph } from '@dxos/conductor';
7
8
  import { type ReactiveObject } from '@dxos/live-object';
8
9
  import { DocumentType } from '@dxos/plugin-markdown/types';
9
10
  import { SheetType } from '@dxos/plugin-sheet/types';
@@ -11,6 +12,7 @@ import { DiagramType } from '@dxos/plugin-sketch/types';
11
12
  import { useClient } from '@dxos/react-client';
12
13
  import { getTypename, type Space } from '@dxos/react-client/echo';
13
14
  import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
15
+ import { CanvasBoardType } from '@dxos/react-ui-canvas-editor';
14
16
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
15
17
  import { Testing } from '@dxos/schema/testing';
16
18
  import { jsonKeyReplacer, sortKeys } from '@dxos/util';
@@ -25,7 +27,7 @@ export type SpaceGeneratorProps = {
25
27
 
26
28
  export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
27
29
  const client = useClient();
28
- const staticTypes = [DocumentType, DiagramType, SheetType]; // TODO(burdon): Make extensible.
30
+ const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph, CanvasBoardType]; // TODO(burdon): Make extensible.
29
31
  const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType];
30
32
  const [count, setCount] = useState(1);
31
33
  const [info, setInfo] = useState<any>({});
@@ -43,7 +45,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
43
45
  // Query space to get info.
44
46
  const updateInfo = async () => {
45
47
  // Create schema map.
46
- const mutableSchema = await space.db.schemaRegistry.query();
48
+ const echoSchema = await space.db.schemaRegistry.query().run();
47
49
  const staticSchema = space.db.graph.schemaRegistry.schemas;
48
50
 
49
51
  // Create object map.
@@ -62,7 +64,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
62
64
  setInfo({
63
65
  schema: {
64
66
  static: staticSchema.length,
65
- mutable: mutableSchema.length,
67
+ mutable: echoSchema.length,
66
68
  },
67
69
  objects: objectMap,
68
70
  });
@@ -86,7 +88,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
86
88
  <div role='none' className='flex flex-col divide-y divide-separator'>
87
89
  <Toolbar.Root classNames='p-1'>
88
90
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
89
- <Toolbar.Expander />
91
+ <Toolbar.Separator variant='gap' />
90
92
  <div className='flex'>
91
93
  <Input.Root>
92
94
  <Input.TextInput
@@ -86,20 +86,21 @@ export const drawGraph = async (
86
86
  editor: Editor,
87
87
  graph: Graph<PlainObject, PlainObject>,
88
88
  ): Promise<SerializedStore<TLRecord>> => {
89
- const grid = 40;
89
+ const gridSize = 40;
90
90
  const nodeSize = 80;
91
91
 
92
- const snap = (n: number) => Math.round(n / grid) * grid;
92
+ const snap = (n: number) => Math.round(n / gridSize) * gridSize;
93
93
 
94
+ // TODO(burdon): Util.
94
95
  type Intersection<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest]
95
96
  ? First & Intersection<Rest>
96
97
  : unknown;
97
98
 
98
99
  const defaultOptions: Intersection<[D3ForceLayoutOptions, GridLayoutOptions, RadialLayoutOptions]> = {
99
100
  center: [0, 0],
100
- width: grid * 20,
101
- height: grid * 20,
102
- linkDistance: grid * 2,
101
+ width: gridSize * 20,
102
+ height: gridSize * 20,
103
+ linkDistance: gridSize * 2,
103
104
  nodeSize,
104
105
  nodeSpacing: nodeSize,
105
106
  preventOverlap: true,
@@ -129,7 +130,7 @@ export const drawGraph = async (
129
130
  layout = new RadialLayout({
130
131
  ...defaultOptions,
131
132
  focusNode: graph.getAllNodes()[0],
132
- unitRadius: grid * 2,
133
+ unitRadius: gridSize * 2,
133
134
  });
134
135
  }
135
136
  }
@@ -5,7 +5,7 @@
5
5
  import React from 'react';
6
6
  import { useResizeDetector } from 'react-resize-detector';
7
7
 
8
- import { fullyQualifiedId } from '@dxos/react-client/echo';
8
+ import { fullyQualifiedId, type ReactiveEchoObject } from '@dxos/react-client/echo';
9
9
  import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import { useAttendableAttributes } from '@dxos/react-ui-attention';
11
11
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
@@ -14,7 +14,7 @@ import { mx } from '@dxos/react-ui-theme';
14
14
  // TODO(burdon): Create generic container with wireframe mode.
15
15
  export type WireframeProps = ThemedClassName<{
16
16
  label?: string;
17
- object?: any;
17
+ object: ReactiveEchoObject<any>;
18
18
  }>;
19
19
 
20
20
  // TODO(burdon): Make focusable and attendable with input.
package/src/index.ts CHANGED
@@ -2,8 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { DebugPlugin } from './DebugPlugin';
6
-
7
5
  export * from './DebugPlugin';
8
-
9
- export default DebugPlugin;
6
+ export * from './meta';
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 default {
9
+ export const meta = {
10
10
  id: DEBUG_PLUGIN,
11
11
  name: 'Debug',
12
12
  description: 'DXOS debugging tools.',
package/src/types.ts CHANGED
@@ -4,23 +4,8 @@
4
4
 
5
5
  import { type Context, createContext } from 'react';
6
6
 
7
- import type {
8
- GraphBuilderProvides,
9
- IntentResolverProvides,
10
- SettingsProvides,
11
- SurfaceProvides,
12
- TranslationsProvides,
13
- } from '@dxos/app-framework';
14
7
  import type { TimerCallback, TimerOptions } from '@dxos/async';
15
8
  import { S } from '@dxos/echo-schema';
16
- import { type PanelProvides } from '@dxos/plugin-deck/types';
17
-
18
- import { DEBUG_PLUGIN } from './meta';
19
-
20
- const DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;
21
- export enum DebugAction {
22
- OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,
23
- }
24
9
 
25
10
  export type DebugContextType = {
26
11
  running: boolean;
@@ -43,10 +28,3 @@ export const DebugSettingsSchema = S.mutable(
43
28
  );
44
29
 
45
30
  export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
46
-
47
- export type DebugPluginProvides = SurfaceProvides &
48
- IntentResolverProvides &
49
- GraphBuilderProvides &
50
- SettingsProvides<DebugSettingsProps> &
51
- TranslationsProvides &
52
- PanelProvides;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/DebugSpace/DebugSpace.tsx", "../../../src/components/DebugSpace/ObjectCreator.tsx", "../../../src/components/DebugSpace/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC, useContext, useMemo, useState } from 'react';\n\nimport { createSpaceObjectGenerator } from '@dxos/echo-generator';\nimport { type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { Invitation } from '@dxos/protocols/proto/dxos/client/services';\nimport { faker } from '@dxos/random';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, type Space, useSpaceInvitation } from '@dxos/react-client/echo';\nimport { InvitationEncoder } from '@dxos/react-client/invitations';\nimport { useAsyncEffect } from '@dxos/react-hooks';\nimport { Icon, IconButton, Input, type IconProps, type TextInputProps, Toolbar, useFileDownload } from '@dxos/react-ui';\nimport { safeParseInt } from '@dxos/util';\n\nimport { ObjectCreator } from './ObjectCreator';\nimport { DebugContext } from '../../types';\nimport { Container } from '../Container';\n\nconst DEFAULT_COUNT = 100;\nconst DEFAULT_PERIOD = 500;\nconst DEFAULT_JITTER = 50;\n\nconst useRefresh = (): [any, () => void] => {\n const [update, setUpdate] = useState({});\n return [update, () => setUpdate({})];\n};\n\nconst CustomInput = ({ icon, ...props }: Pick<IconProps, 'icon'> & TextInputProps) => {\n return (\n <div role='none' className='relative'>\n <Input.Root>\n <Input.TextInput classNames='w-[100px] text-right pie-[22px]' size={5} {...props} />\n </Input.Root>\n <Icon icon={icon} size={3} classNames='absolute inline-end-1 block-start-1 mt-[6px]' />\n </div>\n );\n};\n\nexport const DebugSpace: FC<{\n space: Space;\n onAddObjects?: (objects: ReactiveObject<any>[]) => void;\n}> = ({ space, onAddObjects }) => {\n const { connect } = useSpaceInvitation(space?.key);\n const client = useClient();\n const [data, setData] = useState<any>({});\n\n const [update, handleUpdate] = useRefresh();\n useAsyncEffect(\n async (isMounted) => {\n const data = await client.diagnostics({ truncate: true });\n if (isMounted()) {\n setData(\n data?.diagnostics?.spaces?.find(({ key }: any) => {\n return space.key.toHex().startsWith(key);\n }),\n );\n }\n },\n [space, update],\n );\n\n const download = useFileDownload();\n const handleDownload = async () => {\n download(\n new Blob([JSON.stringify(data, undefined, 2)], { type: 'text/plain' }),\n `${new Date().toISOString().replace(/\\W/g, '-')}.json`,\n );\n };\n\n const [mutationCount, setMutationCount] = useState(String(DEFAULT_COUNT));\n const [mutationInterval, setMutationInterval] = useState(String(DEFAULT_PERIOD));\n const [mutationJitter, setMutationJitter] = useState(String(DEFAULT_JITTER));\n\n const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);\n\n // TODO(burdon): Note: this is shared across all spaces!\n const { running, start, stop } = useContext(DebugContext);\n const handleToggleRunning = () => {\n if (running) {\n stop();\n handleUpdate();\n } else {\n start(\n async () => {\n const { objects } = await space.db.query(Filter.schema(DocumentType)).run();\n if (objects.length) {\n const object = faker.helpers.arrayElement(objects);\n await generator.mutateObject(object, { count: 10, mutationSize: 10, maxContentLength: 1000 });\n }\n },\n {\n count: safeParseInt(mutationCount) ?? 0,\n interval: safeParseInt(mutationInterval) ?? 0,\n jitter: safeParseInt(mutationJitter) ?? 0,\n },\n );\n }\n };\n\n const handleCreateInvitation = () => {\n const invitation = space.share({\n type: Invitation.Type.INTERACTIVE,\n authMethod: Invitation.AuthMethod.NONE,\n multiUse: true,\n });\n\n // TODO(burdon): Refactor.\n // TODO(burdon): Unsubscribe?\n connect(invitation);\n const code = InvitationEncoder.encode(invitation.get());\n new URL(window.origin).searchParams.set('spaceInvitationCode', code);\n const url = `${window.origin}?spaceInvitationCode=${code}`;\n void navigator.clipboard.writeText(url);\n };\n\n const handleCreateEpoch = async () => {\n await space.internal.createEpoch();\n handleUpdate();\n };\n\n return (\n <Container\n toolbar={\n <Toolbar.Root classNames='p-1'>\n <CustomInput\n icon='ph--flag--regular'\n autoComplete='off'\n placeholder='Count'\n value={mutationCount}\n onChange={({ target: { value } }) => setMutationCount(value)}\n />\n <CustomInput\n icon='ph--timer--regular'\n autoComplete='off'\n placeholder='Interval'\n value={mutationInterval}\n onChange={({ target: { value } }) => setMutationInterval(value)}\n />\n <CustomInput\n icon='ph--plus-minus--regular'\n autoComplete='off'\n placeholder='Jitter'\n value={mutationJitter}\n onChange={({ target: { value } }) => setMutationJitter(value)}\n />\n\n <IconButton\n icon={running ? 'ph--pause-circle--regular' : 'ph--play-circle--regular'}\n iconOnly\n label='Start/stop'\n size={5}\n onClick={handleToggleRunning}\n />\n <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' size={5} onClick={handleUpdate} />\n <IconButton icon='ph--download-simple--regular' iconOnly label='Download' size={5} onClick={handleDownload} />\n\n <Toolbar.Expander />\n <IconButton\n icon='ph--flag-pennant--regular'\n iconOnly\n label='Create epoch'\n size={5}\n onClick={handleCreateEpoch}\n />\n <IconButton\n icon='ph--user-circle-plus--regular'\n iconOnly\n iconClassNames='text-blue-500'\n label='Create Invitation'\n size={5}\n onClick={handleCreateInvitation}\n />\n </Toolbar.Root>\n }\n >\n <ObjectCreator space={space} onAddObjects={onAddObjects} />\n </Container>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useMemo, useState } from 'react';\n\nimport { type MutationsProviderParams, TestSchemaType, createSpaceObjectGenerator } from '@dxos/echo-generator';\nimport { type ReactiveEchoObject, type ReactiveObject, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Toolbar } from '@dxos/react-ui';\nimport { createColumnBuilder, type TableColumnDef, Table } from '@dxos/react-ui-table/deprecated';\n\nconst BATCH_SIZE = 10;\n\nexport type CreateObjectsParams = {\n schema: string;\n enabled: boolean;\n objects: number;\n mutations: Pick<MutationsProviderParams, 'count' | 'mutationSize' | 'maxContentLength'>;\n};\n\nexport type ObjectCreatorProps = {\n space: Space;\n onAddObjects?: (objects: ReactiveObject<any>[]) => void;\n};\n\nexport const ObjectCreator = ({ space, onAddObjects }: ObjectCreatorProps) => {\n const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);\n\n const [objects, setObjects] = useState<CreateObjectsParams[]>(\n Object.values(TestSchemaType).map((schema) => ({\n schema,\n enabled: true,\n objects: 10,\n mutations: {\n count: 10,\n mutationSize: 10,\n maxContentLength: 1000,\n },\n })),\n );\n\n const handleCreate = async () => {\n for (const params of objects) {\n if (!params.enabled) {\n continue;\n }\n\n let objectsCreated = 0;\n while (objectsCreated < params.objects) {\n const objects = (await generator.createObjects({\n [params.schema]: Math.min(BATCH_SIZE, params.objects - objectsCreated),\n })) as ReactiveEchoObject<any>[];\n\n await generator.mutateObjects(objects, params.mutations);\n objectsCreated += objects.length;\n onAddObjects?.(objects);\n }\n }\n\n await space.db.flush();\n };\n\n const handleUpdate = (row: CreateObjectsParams, key: string, value: any) => {\n const newObjects = [...objects];\n Object.assign(newObjects.find((object) => object.schema === row.schema)!, { [key]: value });\n setObjects(newObjects);\n };\n\n const { helper, builder } = createColumnBuilder<CreateObjectsParams>();\n const columns: TableColumnDef<CreateObjectsParams>[] = [\n helper.accessor('enabled', builder.switch({ label: 'Live', onUpdate: handleUpdate })),\n helper.accessor('schema', builder.string({ label: 'Schema', classNames: 'font-mono' })),\n helper.accessor('objects', builder.number({ label: 'Objects', onUpdate: handleUpdate })),\n helper.accessor((obj) => obj.mutations.count, {\n id: 'mutations',\n ...builder.number({ label: 'Mutations', onUpdate: handleUpdate }),\n }),\n helper.accessor((obj) => obj.mutations.mutationSize, {\n id: 'mutationSize',\n ...builder.number({ label: 'Mut. Size', onUpdate: handleUpdate }),\n }),\n helper.accessor((obj) => obj.mutations.maxContentLength, {\n id: 'mutationMaxContentLength',\n ...builder.number({ label: 'Length', onUpdate: handleUpdate }),\n }),\n ];\n\n return (\n <>\n <Table.Root>\n <Table.Viewport>\n <Table.Main<CreateObjectsParams> columns={columns} data={objects} />\n </Table.Viewport>\n </Table.Root>\n <Toolbar.Root classNames='p-1'>\n <IconButton icon='ph--plus--regular' label='Create' onClick={handleCreate} />\n </Toolbar.Root>\n </>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DebugSpace } from './DebugSpace';\n\nexport default DebugSpace;\n"],
5
- "mappings": ";;;;;;;;;AAIA,OAAOA,UAAkBC,YAAYC,WAAAA,UAASC,YAAAA,iBAAgB;AAE9D,SAASC,8BAAAA,mCAAkC;AAE3C,SAASC,oBAAoB;AAC7B,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,iBAAiB;AAC1B,SAASC,QAAoBC,0BAA0B;AACvD,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,MAAMC,cAAAA,aAAYC,OAA4CC,WAAAA,UAASC,uBAAuB;AACvG,SAASC,oBAAoB;;;ACZ7B,OAAOC,SAASC,SAASC,gBAAgB;AAEzC,SAAuCC,gBAAgBC,kCAAkC;AAEzF,SAASC,YAAYC,eAAe;AACpC,SAASC,qBAA0CC,aAAa;AAEhE,IAAMC,aAAa;AAcZ,IAAMC,gBAAgB,CAAC,EAAEC,OAAOC,aAAY,MAAsB;AACvE,QAAMC,YAAYC,QAAQ,MAAMC,2BAA2BJ,KAAAA,GAAQ;IAACA;GAAM;AAE1E,QAAM,CAACK,SAASC,UAAAA,IAAcC,SAC5BC,OAAOC,OAAOC,cAAAA,EAAgBC,IAAI,CAACC,YAAY;IAC7CA;IACAC,SAAS;IACTR,SAAS;IACTS,WAAW;MACTC,OAAO;MACPC,cAAc;MACdC,kBAAkB;IACpB;EACF,EAAA,CAAA;AAGF,QAAMC,eAAe,YAAA;AACnB,eAAWC,UAAUd,SAAS;AAC5B,UAAI,CAACc,OAAON,SAA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,EAAEF,MAAK,EAAE,MAAO5D,kBAAkB4D,KAAAA;QAGzD,gBAAA1G,OAAA,cAAC6G,aAAAA;MACC/G,MAAMoD,UAAU,8BAA8B;MAC9C4D,UAAAA;MACAC,OAAM;MACNvG,MAAM;MACNwG,SAASzD;QAEX,gBAAAvD,OAAA,cAAC6G,aAAAA;MAAW/G,MAAK;MAA+BgH,UAAAA;MAASC,OAAM;MAAUvG,MAAM;MAAGwG,SAAS5F;QAC3F,gBAAApB,OAAA,cAAC6G,aAAAA;MAAW/G,MAAK;MAA+BgH,UAAAA;MAASC,OAAM;MAAWvG,MAAM;MAAGwG,SAASjF;QAE5F,gBAAA/B,OAAA,cAACuG,SAAQU,UAAQ,IAAA,GACjB,gBAAAjH,OAAA,cAAC6G,aAAAA;MACC/G,MAAK;MACLgH,UAAAA;MACAC,OAAM;MACNvG,MAAM;MACNwG,SAASd;QAEX,gBAAAlG,OAAA,cAAC6G,aAAAA;MACC/G,MAAK;MACLgH,UAAAA;MACAI,gBAAe;MACfH,OAAM;MACNvG,MAAM;MACNwG,SAASrC;;KAKf,gBAAA3E,OAAA,cAACmH,eAAAA;IAAcxG;IAAcC;;AAGnC;;;AEhLA,IAAA,qBAAewG;",
6
- "names": ["React", "useContext", "useMemo", "useState", "createSpaceObjectGenerator", "DocumentType", "Invitation", "faker", "useClient", "Filter", "useSpaceInvitation", "InvitationEncoder", "useAsyncEffect", "Icon", "IconButton", "Input", "Toolbar", "useFileDownload", "safeParseInt", "React", "useMemo", "useState", "TestSchemaType", "createSpaceObjectGenerator", "IconButton", "Toolbar", "createColumnBuilder", "Table", "BATCH_SIZE", "ObjectCreator", "space", "onAddObjects", "generator", "useMemo", "createSpaceObjectGenerator", "objects", "setObjects", "useState", "Object", "values", "TestSchemaType", "map", "schema", "enabled", "mutations", "count", "mutationSize", "maxContentLength", "handleCreate", "params", "objectsCreated", "createObjects", "Math", "min", "mutateObjects", "length", "db", "flush", "handleUpdate", "row", "key", "value", "newObjects", "assign", "find", "object", "helper", "builder", "createColumnBuilder", "columns", "accessor", "switch", "label", "onUpdate", "string", "classNames", "number", "obj", "id", "Table", "Root", "Viewport", "Main", "data", "Toolbar", "IconButton", "icon", "onClick", "DEFAULT_COUNT", "DEFAULT_PERIOD", "DEFAULT_JITTER", "useRefresh", "update", "setUpdate", "useState", "CustomInput", "icon", "props", "React", "div", "role", "className", "Input", "Root", "TextInput", "classNames", "size", "Icon", "DebugSpace", "space", "onAddObjects", "connect", "useSpaceInvitation", "key", "client", "useClient", "data", "setData", "handleUpdate", "useAsyncEffect", "isMounted", "diagnostics", "truncate", "spaces", "find", "toHex", "startsWith", "download", "useFileDownload", "handleDownload", "Blob", "JSON", "stringify", "undefined", "type", "Date", "toISOString", "replace", "mutationCount", "setMutationCount", "String", "mutationInterval", "setMutationInterval", "mutationJitter", "setMutationJitter", "generator", "useMemo", "createSpaceObjectGenerator", "running", "start", "stop", "useContext", "DebugContext", "handleToggleRunning", "objects", "db", "query", "Filter", "schema", "DocumentType", "run", "length", "object", "faker", "helpers", "arrayElement", "mutateObject", "count", "mutationSize", "maxContentLength", "safeParseInt", "interval", "jitter", "handleCreateInvitation", "invitation", "share", "Invitation", "Type", "INTERACTIVE", "authMethod", "AuthMethod", "NONE", "multiUse", "code", "InvitationEncoder", "encode", "get", "URL", "window", "origin", "searchParams", "set", "url", "navigator", "clipboard", "writeText", "handleCreateEpoch", "internal", "createEpoch", "Container", "toolbar", "Toolbar", "autoComplete", "placeholder", "value", "onChange", "target", "IconButton", "iconOnly", "label", "onClick", "Expander", "iconClassNames", "ObjectCreator", "DebugSpace"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/SpaceGenerator/SpaceGenerator.tsx", "../../../src/components/SpaceGenerator/ObjectGenerator.tsx", "../../../src/components/SpaceGenerator/SchemaTable.tsx", "../../../src/components/SpaceGenerator/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { SheetType } from '@dxos/plugin-sheet/types';\nimport { DiagramType } from '@dxos/plugin-sketch/types';\nimport { useClient } from '@dxos/react-client';\nimport { getTypename, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { Testing } from '@dxos/schema/testing';\nimport { jsonKeyReplacer, sortKeys } from '@dxos/util';\n\nimport { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';\nimport { SchemaTable } from './SchemaTable';\n\nexport type SpaceGeneratorProps = {\n space: Space;\n onCreateObjects?: (objects: ReactiveObject<any>[]) => void;\n};\n\nexport const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {\n const client = useClient();\n const staticTypes = [DocumentType, DiagramType, SheetType]; // TODO(burdon): Make extensible.\n const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType];\n const [count, setCount] = useState(1);\n const [info, setInfo] = useState<any>({});\n\n // Create type generators.\n const typeMap = useMemo(() => {\n client.addTypes(staticTypes);\n const mutableGenerators = new Map<string, ObjectGenerator<any>>(\n mutableTypes.map((type) => [type.typename, createGenerator(type)]),\n );\n\n return new Map([...staticGenerators, ...mutableGenerators]);\n }, [client, mutableTypes]);\n\n // Query space to get info.\n const updateInfo = async () => {\n // Create schema map.\n const mutableSchema = await space.db.schemaRegistry.query();\n const staticSchema = space.db.graph.schemaRegistry.schemas;\n\n // Create object map.\n const { objects } = await space.db.query().run();\n const objectMap = sortKeys(\n objects.reduce<Record<string, number>>((map, obj) => {\n const type = getTypename(obj);\n if (type) {\n const count = map[type] ?? 0;\n map[type] = count + 1;\n }\n return map;\n }, {}),\n );\n\n setInfo({\n schema: {\n static: staticSchema.length,\n mutable: mutableSchema.length,\n },\n objects: objectMap,\n });\n };\n\n useAsyncEffect(updateInfo, [space]);\n\n const handleCreateData = useCallback(\n async (typename: string) => {\n const constructor = typeMap.get(typename);\n if (constructor) {\n // TODO(burdon): Input to specify number of objects.\n await constructor(space, count, onCreateObjects);\n await updateInfo();\n }\n },\n [typeMap, count],\n );\n\n return (\n <div role='none' className='flex flex-col divide-y divide-separator'>\n <Toolbar.Root classNames='p-1'>\n <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />\n <Toolbar.Expander />\n <div className='flex'>\n <Input.Root>\n <Input.TextInput\n type='number'\n min={1}\n max={100}\n placeholder={'Count'}\n classNames='w-[80px]'\n value={count}\n onChange={(ev) => setCount(parseInt(ev.target.value))}\n />\n </Input.Root>\n </div>\n </Toolbar.Root>\n\n <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />\n <SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />\n\n <SyntaxHighlighter classNames='flex text-xs' language='json'>\n {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}\n </SyntaxHighlighter>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type AbstractSchema, type BaseObject } from '@dxos/echo-schema';\nimport { create, type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType, TextType } from '@dxos/plugin-markdown/types';\nimport { addressToA1Notation, createSheet } from '@dxos/plugin-sheet';\nimport { type CellValue } from '@dxos/plugin-sheet/types';\nimport { SheetType } from '@dxos/plugin-sheet/types';\nimport { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';\nimport { faker } from '@dxos/random';\nimport { Filter, type Space } from '@dxos/react-client/echo';\nimport { TableType } from '@dxos/react-ui-table';\nimport { createView } from '@dxos/schema';\nimport { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';\nimport { range } from '@dxos/util';\n\nconst generator: ValueGenerator = faker as any;\n\n// TODO(burdon): Add objects to collections.\n// TODO(burdon): Create docs.\n// TODO(burdon): Create sketches.\n// TODO(burdon): Create sheets.\n// TODO(burdon): Create comments.\n// TODO(burdon): Reuse in testbench-app.\n// TODO(burdon): Mutator running in background (factor out): from echo-generator.\n\nexport type ObjectGenerator<T extends BaseObject> = (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n) => Promise<ReactiveObject<T>[]>;\n\nexport const staticGenerators = new Map<string, ObjectGenerator<any>>([\n [\n DocumentType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const obj = space.db.add(\n create(DocumentType, {\n name: faker.commerce.productName(),\n content: create(TextType, { content: faker.lorem.sentences(5) }),\n threads: [],\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n [\n DiagramType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n // TODO(burdon): Generate diagram.\n const obj = space.db.add(\n create(DiagramType, {\n name: faker.commerce.productName(),\n canvas: create(CanvasType, { content: {} }),\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n // TODO(burdon): Create unit tests.\n [\n SheetType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const cells: Record<string, CellValue> = {};\n const year = new Date().getFullYear();\n const cols = 4;\n const rows = 16;\n for (let col = 1; col <= cols; col++) {\n for (let row = 1; row <= rows; row++) {\n const cell = addressToA1Notation({ col, row });\n if (row === 1) {\n cells[cell] = { value: `${year} Q${col}` };\n } else if (row === rows) {\n const from = addressToA1Notation({ col, row: 2 });\n const to = addressToA1Notation({ col, row: rows - 1 });\n cells[cell] = { value: `=SUM(${from}:${to})` };\n } else if (row > 2 && row < rows - 1) {\n cells[cell] = { value: Math.floor(Math.random() * 10_000) };\n }\n }\n }\n\n // TODO(burdon): Set width.\n // TODO(burdon): Set formatting for columns.\n return space.db.add(\n createSheet({\n name: faker.commerce.productName(),\n cells,\n }),\n );\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n]);\n\nexport const createGenerator = <T extends BaseObject>(type: AbstractSchema<T>): ObjectGenerator<T> => {\n return async (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n ): Promise<ReactiveObject<T>[]> => {\n // Find or create mutable schema.\n const mutableSchema = await space.db.schemaRegistry.query();\n const schema =\n mutableSchema.find((schema) => schema.typename === type.typename) ?? space.db.schemaRegistry.addSchema(type);\n\n // Create objects.\n const generate = createAsyncGenerator(generator, schema.schema, { db: space.db });\n const objects = await generate.createObjects(n);\n\n // Find or create table and view.\n const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();\n const table = tables.find((table) => table.view?.query?.type === type.typename);\n if (!table) {\n const name = type.typename.split('/').pop() ?? type.typename;\n const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });\n const table = space.db.add(create(TableType, { name, view }));\n cb?.([table]);\n }\n\n return objects;\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { IconButton } from '@dxos/react-ui';\n\nexport type SchemaTableProps = {\n types: any[];\n objects?: Record<string, number | undefined>;\n label: string;\n onClick: (typename: string) => void;\n};\n\nexport const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTableProps) => {\n return (\n <div className='grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden'>\n <div className='grid grid-cols-subgrid col-span-3'>\n <div className='px-2 text-sm text-primary-500'>{label}</div>\n <div className='px-2 text-xs text-subdued text-right'>count</div>\n </div>\n {types.map((type) => (\n <div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>\n <div className='px-2 text-sm font-mono text-green-500'>{type.typename}</div>\n <div className='px-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>\n <IconButton\n variant='ghost'\n icon='ph--plus--regular'\n iconOnly\n label='Create data'\n onClick={() => onClick(type.typename)}\n />\n </div>\n ))}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SpaceGenerator } from './SpaceGenerator';\n\nexport default SpaceGenerator;\n"],
5
- "m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A;IAAkBnB,YAAW;IAAeoB,UAAS;KACnDC,KAAKC,UAAU;IAAEhF;IAAO,GAAGgB;EAAK,GAAGiE,gBAAgB;IAAEC,UAAU;EAAK,CAAA,GAAI,CAAA,CAAA,CAAA;AAIjF;;;AG1GA,IAAA,yBAAeC;",
6
- "names": ["React", "useCallback", "useMemo", "useState", "DocumentType", "SheetType", "DiagramType", "useClient", "getTypename", "IconButton", "Input", "Toolbar", "useAsyncEffect", "SyntaxHighlighter", "Testing", "jsonKeyReplacer", "sortKeys", "create", "DocumentType", "TextType", "addressToA1Notation", "createSheet", "SheetType", "CanvasType", "DiagramType", "faker", "Filter", "TableType", "createView", "createAsyncGenerator", "range", "generator", "faker", "staticGenerators", "Map", "DocumentType", "typename", "space", "n", "cb", "objects", "range", "map", "obj", "db", "add", "create", "name", "commerce", "productName", "content", "TextType", "lorem", "sentences", "threads", "DiagramType", "canvas", "CanvasType", "SheetType", "cells", "year", "Date", "getFullYear", "cols", "rows", "col", "row", "cell", "addressToA1Notation", "value", "from", "to", "Math", "floor", "random", "createSheet", "createGenerator", "type", "mutableSchema", "schemaRegistry", "query", "schema", "find", "addSchema", "generate", "createAsyncGenerator", "createObjects", "tables", "Filter", "TableType", "run", "table", "view", "split", "pop", "createView", "jsonSchema", "React", "IconButton", "SchemaTable", "types", "objects", "label", "onClick", "div", "className", "map", "type", "key", "typename", "IconButton", "variant", "icon", "iconOnly", "SpaceGenerator", "space", "onCreateObjects", "client", "useClient", "staticTypes", "DocumentType", "DiagramType", "SheetType", "mutableTypes", "Testing", "OrgType", "ProjectType", "ContactType", "count", "setCount", "useState", "info", "setInfo", "typeMap", "useMemo", "addTypes", "mutableGenerators", "Map", "map", "type", "typename", "createGenerator", "staticGenerators", "updateInfo", "mutableSchema", "db", "schemaRegistry", "query", "staticSchema", "graph", "schemas", "objects", "run", "objectMap", "sortKeys", "reduce", "obj", "getTypename", "schema", "static", "length", "mutable", "useAsyncEffect", "handleCreateData", "useCallback", "constructor", "get", "React", "div", "role", "className", "Toolbar", "Root", "classNames", "IconButton", "icon", "iconOnly", "label", "onClick", "Expander", "Input", "TextInput", "min", "max", "placeholder", "value", "onChange", "ev", "parseInt", "target", "SchemaTable", "types", "SyntaxHighlighter", "language", "JSON", "stringify", "jsonKeyReplacer", "truncate", "SpaceGenerator"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const DEBUG_PLUGIN = 'dxos.org/plugin/debug';\n\nexport default {\n id: DEBUG_PLUGIN,\n name: 'Debug',\n description: 'DXOS debugging tools.',\n icon: 'ph--bug--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
6
- "names": ["DEBUG_PLUGIN", "id", "name", "description", "icon", "source", "tags"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport type { TimerCallback, TimerOptions } from '@dxos/async';\nimport { S } from '@dxos/echo-schema';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\n\nimport { DEBUG_PLUGIN } from './meta';\n\nconst DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;\nexport enum DebugAction {\n OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,\n}\n\nexport type DebugContextType = {\n running: boolean;\n start: (cb: TimerCallback, options: TimerOptions) => void;\n stop: () => void;\n};\n\nexport const DebugContext: Context<DebugContextType> = createContext<DebugContextType>({\n running: false,\n start: () => {},\n stop: () => {},\n});\n\nexport const DebugSettingsSchema = S.mutable(\n S.Struct({\n devtools: S.optional(S.Boolean),\n debug: S.optional(S.Boolean),\n wireframe: S.optional(S.Boolean),\n }),\n);\n\nexport interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}\n\nexport type DebugPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n SettingsProvides<DebugSettingsProps> &\n TranslationsProvides &\n PanelProvides;\n"],
5
- "mappings": ";;;;;AAIA,SAAuBA,qBAAqB;AAU5C,SAASC,SAAS;AAKlB,IAAMC,eAAe,GAAGC,YAAAA;;UACZC,cAAAA;+CACM,GAAGF,YAAAA,gBAA4B,IAAA;GADrCE,gBAAAA,cAAAA,CAAAA,EAAAA;AAUL,IAAMC,eAA0CC,cAAgC;EACrFC,SAAS;EACTC,OAAO,MAAA;EAAO;EACdC,MAAM,MAAA;EAAO;AACf,CAAA;AAEO,IAAMC,sBAAsBC,EAAEC,QACnCD,EAAEE,OAAO;EACPC,UAAUH,EAAEI,SAASJ,EAAEK,OAAO;EAC9BC,OAAON,EAAEI,SAASJ,EAAEK,OAAO;EAC3BE,WAAWP,EAAEI,SAASJ,EAAEK,OAAO;AACjC,CAAA,CAAA;",
6
- "names": ["createContext", "S", "DEBUG_ACTION", "DEBUG_PLUGIN", "DebugAction", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
7
- }
@@ -1,9 +0,0 @@
1
- import {
2
- DEBUG_PLUGIN,
3
- meta_default
4
- } from "./chunk-CAENAAHY.mjs";
5
- export {
6
- DEBUG_PLUGIN,
7
- meta_default as default
8
- };
9
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { type ThemedClassName } from '@dxos/react-ui';
3
- export type SurfaceDebugProps = ThemedClassName<{}>;
4
- /**
5
- * Show surface info.
6
- * NOTE: Remove from @dxos/app-framework if removing this.
7
- */
8
- export declare const DebugSurface: ({ classNames }: SurfaceDebugProps) => React.JSX.Element;
9
- //# sourceMappingURL=DebugSurface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DebugSurface.d.ts","sourceRoot":"","sources":["../../../../src/components/DebugSurface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKpE,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,sBAoC7D,CAAC"}
@@ -1,55 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { useMemo, useState } from 'react';
6
-
7
- import { type DebugInfo, useSurfaceRoot } from '@dxos/app-framework';
8
- import { Button, Icon, type ThemedClassName } from '@dxos/react-ui';
9
- import { mx } from '@dxos/react-ui-theme';
10
-
11
- // TODO(burdon): Move to debug panel.
12
-
13
- export type SurfaceDebugProps = ThemedClassName<{}>;
14
-
15
- /**
16
- * Show surface info.
17
- * NOTE: Remove from @dxos/app-framework if removing this.
18
- */
19
- export const DebugSurface = ({ classNames }: SurfaceDebugProps) => {
20
- const context = useSurfaceRoot();
21
- const [surfaces, setSurfaces] = useState<DebugInfo[]>([]);
22
- const renderMap = useMemo(() => new Map<string, { last: number; delta: number }>(), []);
23
- const handleRefresh = () => {
24
- if (context.debugInfo) {
25
- setSurfaces(
26
- Array.from(context.debugInfo.values())
27
- .sort(({ created: a }, { created: b }) => a - b)
28
- .map((surface) => {
29
- const state = renderMap.get(surface.id) ?? { last: 0, delta: 0 };
30
- renderMap.set(surface.id, { last: surface.renderCount, delta: surface.renderCount - state.last });
31
- return surface;
32
- }),
33
- );
34
- }
35
- };
36
-
37
- return (
38
- <div className={mx('flex flex-col border border-separator overflow-hidden bg-modalSurface', classNames)}>
39
- <div className='flex flex-col h-full w-full p-2'>
40
- {surfaces.map(({ id, name, renderCount }) => (
41
- <div key={id} className='grid grid-cols-[1fr_3rem_3rem] items-center text-xs font-mono whitespace-nowrap'>
42
- <span className='px-1 truncate'>{name}</span>
43
- <span className='px-1 text-right'>{renderCount}</span>
44
- <span className='px-1 text-right'>{renderMap.get(id)?.delta}</span>
45
- </div>
46
- ))}
47
- </div>
48
- <div className='flex justify-center text-sm items-center'>
49
- <Button onClick={handleRefresh}>
50
- <Icon icon='ph--arrow-clockwise--regular' size={4} />
51
- </Button>
52
- </div>
53
- </div>
54
- );
55
- };