@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.
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +15 -0
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs +19 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs.map +7 -0
- package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs +1152 -0
- package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs +599 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-4UFQXPP7.mjs} +13 -3
- package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +42 -46
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
- package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs +758 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs.map +7 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +2 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
- package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +3 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/components/DebugGraph.d.ts +9 -0
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts +4 -2
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +6 -4
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -4
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +5 -8
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts +2 -2
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +62 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +6 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -71
- package/src/DebugPlugin.tsx +19 -34
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +421 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +4 -6
- package/src/capabilities/react-context/index.ts +7 -0
- package/src/capabilities/react-context/react-context.tsx +20 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +411 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +31 -0
- package/src/components/DebugGraph.tsx +15 -0
- package/src/components/DebugObjectPanel.tsx +6 -9
- package/src/components/DebugSettings.tsx +109 -75
- package/src/components/DebugStatus.tsx +2 -2
- package/src/components/DevtoolsOverviewContainer.tsx +2 -2
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +40 -41
- package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +17 -15
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +41 -94
- package/src/components/SpaceGenerator/draw-util.ts +5 -5
- package/src/components/SpaceGenerator/presets.ts +537 -259
- package/src/components/Wireframe.tsx +6 -6
- package/src/components/index.ts +4 -1
- package/src/meta.ts +8 -7
- package/src/translations.ts +9 -5
- package/src/types.ts +9 -1
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs +0 -1238
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs +0 -597
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
- package/dist/lib/browser/chunk-47JOZTT2.mjs +0 -18
- package/dist/lib/browser/chunk-47JOZTT2.mjs.map +0 -7
- package/dist/lib/browser/chunk-KS3YBEL7.mjs.map +0 -7
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs +0 -16
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs +0 -768
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- package/dist/lib/browser/settings-SXQWSIM4.mjs +0 -22
- package/dist/lib/browser/settings-SXQWSIM4.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context.d.ts +0 -8
- package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/index.d.ts +0 -3
- package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -457
- package/src/capabilities/react-context.tsx +0 -16
- package/src/capabilities/react-surface.tsx +0 -397
- package/src/capabilities/settings.ts +0 -19
- package/src/components/DebugApp/DebugApp.tsx +0 -77
- package/src/components/DebugApp/Tree.tsx +0 -103
- 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 {
|
|
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 {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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 {
|
|
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 {
|
|
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
|
|
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.
|
|
26
|
+
onCreateObjects?: (objects: Obj.Unknown[]) => void;
|
|
30
27
|
};
|
|
31
28
|
|
|
32
29
|
export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
|
|
33
|
-
const {
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
34
31
|
const client = useClient();
|
|
35
|
-
const staticTypes = [
|
|
36
|
-
const
|
|
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
|
-
|
|
44
|
-
|
|
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, ...
|
|
49
|
-
}, [client,
|
|
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.
|
|
56
|
+
const staticSchema = await space.db.graph.schemaRegistry.query().run();
|
|
56
57
|
|
|
57
58
|
// Create object map.
|
|
58
|
-
const
|
|
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
|
-
<
|
|
143
|
-
<Toolbar.Root
|
|
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={(
|
|
109
|
+
onChange={(event) => setCount(parseInt(event.target.value))}
|
|
162
110
|
/>
|
|
163
111
|
</Input.Root>
|
|
164
112
|
</Toolbar.Root>
|
|
165
113
|
|
|
166
|
-
<
|
|
167
|
-
<
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
</
|
|
176
|
-
</
|
|
177
|
-
</
|
|
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 {
|
|
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 {
|
|
16
|
+
import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
|
|
17
17
|
|
|
18
18
|
import { faker } from '@dxos/random';
|
|
19
|
-
import {
|
|
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(
|
|
70
|
+
.filter(isTruthy);
|
|
71
71
|
|
|
72
72
|
for (const target of targets) {
|
|
73
73
|
traverse(target);
|