@dxos/plugin-debug 0.8.3 → 0.8.4-main.1068cf700f

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 (132) hide show
  1. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +15 -0
  2. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
  3. package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs +19 -0
  4. package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs.map +7 -0
  5. package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs +1152 -0
  6. package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs +599 -0
  8. package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-4UFQXPP7.mjs} +13 -3
  10. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
  12. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +42 -46
  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-I3USIAF6.mjs +17 -0
  17. package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-FMVC5GPV.mjs +758 -0
  19. package/dist/lib/browser/react-surface-FMVC5GPV.mjs.map +7 -0
  20. package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
  21. package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +2 -1
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  25. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  27. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/index.d.ts +4 -8
  29. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
  31. package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
  33. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  35. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  37. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  39. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
  41. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  42. package/dist/types/src/components/DebugGraph.d.ts +9 -0
  43. package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
  44. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
  45. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  46. package/dist/types/src/components/DebugSettings.d.ts +4 -2
  47. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  48. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +6 -4
  49. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  50. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
  51. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  52. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -4
  53. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  55. package/dist/types/src/components/SpaceGenerator/presets.d.ts +5 -8
  56. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  57. package/dist/types/src/components/Wireframe.d.ts +2 -2
  58. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  59. package/dist/types/src/components/index.d.ts +4 -3
  60. package/dist/types/src/components/index.d.ts.map +1 -1
  61. package/dist/types/src/meta.d.ts +2 -3
  62. package/dist/types/src/meta.d.ts.map +1 -1
  63. package/dist/types/src/translations.d.ts +62 -60
  64. package/dist/types/src/translations.d.ts.map +1 -1
  65. package/dist/types/src/types.d.ts +6 -1
  66. package/dist/types/src/types.d.ts.map +1 -1
  67. package/dist/types/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +79 -71
  69. package/src/DebugPlugin.tsx +19 -34
  70. package/src/capabilities/app-graph-builder/app-graph-builder.ts +421 -0
  71. package/src/capabilities/app-graph-builder/index.ts +7 -0
  72. package/src/capabilities/index.ts +4 -6
  73. package/src/capabilities/react-context/index.ts +7 -0
  74. package/src/capabilities/react-context/react-context.tsx +20 -0
  75. package/src/capabilities/react-surface/index.ts +7 -0
  76. package/src/capabilities/react-surface/react-surface.tsx +411 -0
  77. package/src/capabilities/settings/index.ts +7 -0
  78. package/src/capabilities/settings/settings.ts +31 -0
  79. package/src/components/DebugGraph.tsx +15 -0
  80. package/src/components/DebugObjectPanel.tsx +6 -9
  81. package/src/components/DebugSettings.tsx +109 -75
  82. package/src/components/DebugStatus.tsx +2 -2
  83. package/src/components/DevtoolsOverviewContainer.tsx +2 -2
  84. package/src/components/SpaceGenerator/ObjectGenerator.tsx +40 -41
  85. package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
  86. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +17 -15
  87. package/src/components/SpaceGenerator/SpaceGenerator.tsx +41 -94
  88. package/src/components/SpaceGenerator/draw-util.ts +5 -5
  89. package/src/components/SpaceGenerator/presets.ts +537 -259
  90. package/src/components/Wireframe.tsx +6 -6
  91. package/src/components/index.ts +4 -1
  92. package/src/meta.ts +8 -7
  93. package/src/translations.ts +9 -5
  94. package/src/types.ts +9 -1
  95. package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
  96. package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
  97. package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs +0 -25
  98. package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs.map +0 -7
  99. package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs +0 -1238
  100. package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
  101. package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs +0 -597
  102. package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
  103. package/dist/lib/browser/chunk-47JOZTT2.mjs +0 -18
  104. package/dist/lib/browser/chunk-47JOZTT2.mjs.map +0 -7
  105. package/dist/lib/browser/chunk-KS3YBEL7.mjs.map +0 -7
  106. package/dist/lib/browser/react-context-ZQRD2WG2.mjs +0 -16
  107. package/dist/lib/browser/react-context-ZQRD2WG2.mjs.map +0 -7
  108. package/dist/lib/browser/react-surface-UI6OK73H.mjs +0 -768
  109. package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
  110. package/dist/lib/browser/settings-SXQWSIM4.mjs +0 -22
  111. package/dist/lib/browser/settings-SXQWSIM4.mjs.map +0 -7
  112. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  113. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  114. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  115. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  116. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  117. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  118. package/dist/types/src/capabilities/settings.d.ts +0 -4
  119. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  120. package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
  121. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
  122. package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
  123. package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
  124. package/dist/types/src/components/DebugApp/index.d.ts +0 -3
  125. package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
  126. package/src/capabilities/app-graph-builder.ts +0 -457
  127. package/src/capabilities/react-context.tsx +0 -16
  128. package/src/capabilities/react-surface.tsx +0 -397
  129. package/src/capabilities/settings.ts +0 -19
  130. package/src/components/DebugApp/DebugApp.tsx +0 -77
  131. package/src/components/DebugApp/Tree.tsx +0 -103
  132. package/src/components/DebugApp/index.ts +0 -7
@@ -4,65 +4,67 @@
4
4
 
5
5
  import React, { useCallback, useMemo, useState } from 'react';
6
6
 
7
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
7
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
8
8
  import { ComputeGraph } from '@dxos/conductor';
9
- import { Filter, Obj, Type } from '@dxos/echo';
10
- import { log } from '@dxos/log';
11
- import { DocumentType } from '@dxos/plugin-markdown/types';
12
- import { SheetType } from '@dxos/plugin-sheet/types';
13
- import { DiagramType } from '@dxos/plugin-sketch/types';
14
- import { SpaceAction } from '@dxos/plugin-space/types';
9
+ import { Filter, Obj, type Type } from '@dxos/echo';
10
+ import { Markdown } from '@dxos/plugin-markdown/types';
11
+ import { Sheet } from '@dxos/plugin-sheet/types';
12
+ import { Diagram } from '@dxos/plugin-sketch/types';
15
13
  import { useClient } from '@dxos/react-client';
16
- import { getTypename, type Space } from '@dxos/react-client/echo';
17
- import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
14
+ import { type Space } from '@dxos/react-client/echo';
15
+ import { IconButton, Input, Layout, ScrollArea, Toolbar, useAsyncEffect } from '@dxos/react-ui';
18
16
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
19
- import { initializeTable, TableType } from '@dxos/react-ui-table';
20
- import { DataType } from '@dxos/schema';
17
+ import { Organization, Person, Task } from '@dxos/types';
21
18
  import { jsonKeyReplacer, sortKeys } from '@dxos/util';
22
19
 
23
- import { createGenerator, staticGenerators, type ObjectGenerator } from './ObjectGenerator';
24
- import { SchemaTable } from './SchemaTable';
20
+ import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
25
21
  import { generator } from './presets';
22
+ import { SchemaTable } from './SchemaTable';
26
23
 
27
24
  export type SpaceGeneratorProps = {
28
25
  space: Space;
29
- onCreateObjects?: (objects: Obj.Any[]) => void;
26
+ onCreateObjects?: (objects: Obj.Unknown[]) => void;
30
27
  };
31
28
 
32
29
  export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
33
- const { dispatchPromise: dispatch } = useIntentDispatcher();
30
+ const { invokePromise } = useOperationInvoker();
34
31
  const client = useClient();
35
- const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
36
- const mutableTypes = [DataType.Organization, DataType.Project, DataType.Person, DataType.Message];
32
+ const staticTypes = [Markdown.Document, Diagram.Diagram, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
33
+ const recordTypes: Type.Obj.Any[] = [Organization.Organization, Person.Person, Task.Task];
37
34
  const [count, setCount] = useState(1);
38
35
  const [info, setInfo] = useState<any>({});
39
36
  const presets = useMemo(() => generator(), []);
40
37
 
38
+ // Register types.
39
+ useAsyncEffect(async () => {
40
+ await client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
41
+ }, [client]);
42
+
41
43
  // Create type generators.
42
44
  const typeMap = useMemo(() => {
43
- client.addTypes([...staticTypes, ...presets.schemas]);
44
- const mutableGenerators = new Map<string, ObjectGenerator<any>>(
45
- mutableTypes.map((type) => [type.typename, createGenerator(type as any)]),
45
+ const recordGenerators = new Map<string, ObjectGenerator<any>>(
46
+ recordTypes.map((type) => [type.typename, createGenerator(client, invokePromise, type)]),
46
47
  );
47
48
 
48
- return new Map([...staticGenerators, ...presets.items, ...mutableGenerators]);
49
- }, [client, mutableTypes]);
49
+ return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
50
+ }, [client, recordTypes, invokePromise]);
50
51
 
51
52
  // Query space to get info.
52
53
  const updateInfo = async () => {
53
54
  // Create schema map.
54
55
  const echoSchema = await space.db.schemaRegistry.query().run();
55
- const staticSchema = space.db.graph.schemaRegistry.schemas;
56
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
56
57
 
57
58
  // Create object map.
58
- const { objects } = await space.db.query(Filter.everything()).run();
59
+ const objects = await space.db.query(Filter.everything()).run();
59
60
  const objectMap = sortKeys(
60
61
  objects.reduce<Record<string, number>>((map, obj) => {
61
- const type = getTypename(obj);
62
+ const type = Obj.getTypename(obj);
62
63
  if (type) {
63
64
  const count = map[type] ?? 0;
64
65
  map[type] = count + 1;
65
66
  }
67
+
66
68
  return map;
67
69
  }, {}),
68
70
  );
@@ -90,90 +92,35 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
90
92
  [typeMap, count],
91
93
  );
92
94
 
93
- // TODO(wittjosiah): Remove. Replace with proper echo import.
94
- const handleLoadTables = useCallback(async () => {
95
- const input = document.createElement('input');
96
- input.type = 'file';
97
- input.accept = '.json';
98
-
99
- input.onchange = async (e) => {
100
- const file = (e.target as HTMLInputElement).files?.[0];
101
- if (!file) {
102
- return;
103
- }
104
-
105
- try {
106
- const content = await file.text();
107
- const data = JSON.parse(content);
108
- const schemas = await space.db.schemaRegistry.register(data.schemas.map(Type.toEffectSchema));
109
- // TODO(wittjosiah): If the schema is already registered this should skip.
110
- await Promise.all(
111
- schemas.map(async (schema) => {
112
- const parts = schema.typename.split('/');
113
- const name = parts[parts.length - 1];
114
- const table = Obj.make(TableType, { name, threads: [] });
115
- await initializeTable({ client, space, table, typename: schema.typename });
116
- await dispatch(createIntent(SpaceAction.AddObject, { target: space, object: table }));
117
- return table;
118
- }),
119
- );
120
- // TODO(wittjosiah): This should query the space for schemas.
121
- await Promise.all(
122
- data.objects.map(async ({ id, '@type': typename, ...fields }: any) => {
123
- const schema = schemas.find((s) => `dxn:type:${s.typename}:${s.version}` === typename);
124
- if (!schema) {
125
- log.warn('Missing schema for object', { id, typename });
126
- return;
127
- }
128
- const object = Obj.make(schema, fields);
129
- space.db.add(object);
130
- return object;
131
- }),
132
- );
133
- } catch (err) {
134
- log.catch(err);
135
- }
136
- };
137
-
138
- input.click();
139
- }, []);
140
-
141
95
  return (
142
- <div role='none' className='flex flex-col grow overflow-hidden'>
143
- <Toolbar.Root classNames='border-be border-subduedSeparator'>
96
+ <Layout.Main toolbar>
97
+ <Toolbar.Root>
144
98
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
145
- <IconButton
146
- icon='ph--file-arrow-up--regular'
147
- iconOnly
148
- label='Load tables from JSON'
149
- onClick={handleLoadTables}
150
- />
151
99
  <Toolbar.Separator variant='gap' />
152
100
  <Input.Root>
153
101
  <Input.TextInput
154
102
  type='number'
103
+ placeholder='Count'
104
+ classNames='is-[4rem] text-right'
155
105
  min={1}
156
106
  max={100}
157
- placeholder={'Count'}
158
- classNames='!w-[4rem] !text-right'
159
107
  size={8}
160
108
  value={count}
161
- onChange={(ev) => setCount(parseInt(ev.target.value))}
109
+ onChange={(event) => setCount(parseInt(event.target.value))}
162
110
  />
163
111
  </Input.Root>
164
112
  </Toolbar.Root>
165
113
 
166
- <div className='flex flex-col overflow-y-auto divide-y divide-separator'>
167
- <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
168
- <SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />
169
- <SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
170
-
171
- <div>
172
- <SyntaxHighlighter classNames='flex text-xs' language='json'>
114
+ <ScrollArea.Root thin orientation='vertical'>
115
+ <ScrollArea.Viewport classNames='gap-4 divide-y divide-subduedSeparator'>
116
+ <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
117
+ <SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
118
+ <SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
119
+ <SyntaxHighlighter language='json' classNames='text-xs'>
173
120
  {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
174
121
  </SyntaxHighlighter>
175
- </div>
176
- </div>
177
- </div>
122
+ </ScrollArea.Viewport>
123
+ </ScrollArea.Root>
124
+ </Layout.Main>
178
125
  );
179
126
  };
@@ -3,20 +3,20 @@
3
3
  //
4
4
 
5
5
  // TODO(burdon): workerize-loader dep.
6
- import { Graph, type Edge, type PlainObject } from '@antv/graphlib';
6
+ import { type Edge, Graph, type PlainObject } from '@antv/graphlib';
7
7
  import {
8
- type Layout,
9
8
  D3ForceLayout,
10
9
  type D3ForceLayoutOptions,
11
10
  GridLayout,
12
11
  type GridLayoutOptions,
12
+ type Layout,
13
13
  RadialLayout,
14
14
  type RadialLayoutOptions,
15
15
  } from '@antv/layout';
16
- import { createBindingId, createShapeId, type Editor, type SerializedStore, type TLRecord } from '@tldraw/tldraw';
16
+ import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
17
17
 
18
18
  import { faker } from '@dxos/random';
19
- import { isNotFalsy, range } from '@dxos/util';
19
+ import { isTruthy, range } from '@dxos/util';
20
20
 
21
21
  // TODO(burdon): Graph layout:
22
22
  // - https://www.npmjs.com/package/@antv/layout (uses d3)
@@ -67,7 +67,7 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
67
67
  }
68
68
  return target;
69
69
  })
70
- .filter(isNotFalsy);
70
+ .filter(isTruthy);
71
71
 
72
72
  for (const target of targets) {
73
73
  traverse(target);