@dxos/plugin-debug 0.7.4 → 0.7.5-labs.401163d
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/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
- package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
- package/dist/lib/browser/{DebugSpace-DHKEAMIC.mjs → DebugSpace-4JHYA7FG.mjs} +7 -6
- package/dist/lib/browser/DebugSpace-4JHYA7FG.mjs.map +7 -0
- package/dist/lib/browser/SpaceGenerator-KYSK77VG.mjs +1100 -0
- package/dist/lib/browser/SpaceGenerator-KYSK77VG.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs +181 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs.map +7 -0
- package/dist/lib/browser/chunk-EF3UVAVI.mjs +21 -0
- package/dist/lib/browser/chunk-EF3UVAVI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LZEK532R.mjs → chunk-P7GHHMDB.mjs} +1 -11
- package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -737
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs +484 -0
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs.map +7 -0
- package/dist/lib/browser/settings-OIMSBZUC.mjs +25 -0
- package/dist/lib/browser/settings-OIMSBZUC.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +1 -2
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +180 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.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 +21 -0
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
- package/dist/types/src/components/Wireframe.d.ts +2 -1
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +0 -6
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +49 -51
- package/src/DebugPlugin.tsx +55 -381
- package/src/capabilities/app-graph-builder.ts +175 -0
- package/src/capabilities/index.ts +9 -0
- package/src/capabilities/react-surface.tsx +130 -0
- package/src/capabilities/settings.ts +18 -0
- package/src/components/DebugApp/DebugApp.tsx +1 -1
- package/src/components/DebugObjectPanel.tsx +17 -5
- package/src/components/DebugSettings.tsx +11 -13
- package/src/components/DebugSpace/DebugSpace.stories.tsx +4 -3
- package/src/components/DebugSpace/DebugSpace.tsx +1 -1
- package/src/components/DebugSpace/ObjectCreator.stories.tsx +4 -3
- package/src/components/DebugStatus.tsx +17 -27
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +45 -18
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +11 -8
- package/src/components/SpaceGenerator/draw-util.ts +7 -6
- package/src/components/SpaceGenerator/presets.ts +493 -0
- package/src/components/Wireframe.tsx +2 -2
- package/src/index.ts +1 -4
- package/src/meta.ts +4 -2
- package/src/types.ts +0 -22
- package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs +0 -273
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
- package/dist/lib/browser/chunk-CAENAAHY.mjs +0 -18
- package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZEK532R.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/types/src/components/DebugSurface.d.ts +0 -9
- package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
- package/src/components/DebugSurface.tsx +0 -55
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { type
|
|
10
|
-
import {
|
|
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 { DXN, SpaceId } from '@dxos/keys';
|
|
9
|
+
import { create, makeRef, type ReactiveObject } from '@dxos/live-object';
|
|
10
|
+
import { DocumentType } from '@dxos/plugin-markdown/types';
|
|
11
|
+
import { createSheet } from '@dxos/plugin-sheet/types';
|
|
12
|
+
import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
|
|
11
13
|
import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
|
|
12
14
|
import { faker } from '@dxos/random';
|
|
13
15
|
import { Filter, type Space } from '@dxos/react-client/echo';
|
|
14
16
|
import { TableType } from '@dxos/react-ui-table';
|
|
15
|
-
import { createView } from '@dxos/schema';
|
|
17
|
+
import { createView, TextType } from '@dxos/schema';
|
|
16
18
|
import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
|
|
17
19
|
import { range } from '@dxos/util';
|
|
18
20
|
|
|
@@ -37,15 +39,13 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
37
39
|
DocumentType.typename,
|
|
38
40
|
async (space, n, cb) => {
|
|
39
41
|
const objects = range(n).map(() => {
|
|
40
|
-
|
|
42
|
+
return space.db.add(
|
|
41
43
|
create(DocumentType, {
|
|
42
44
|
name: faker.commerce.productName(),
|
|
43
|
-
content: create(TextType, { content: faker.lorem.sentences(5) }),
|
|
45
|
+
content: makeRef(create(TextType, { content: faker.lorem.sentences(5) })),
|
|
44
46
|
threads: [],
|
|
45
47
|
}),
|
|
46
48
|
);
|
|
47
|
-
|
|
48
|
-
return obj;
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
cb?.(objects);
|
|
@@ -60,7 +60,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
60
60
|
const obj = space.db.add(
|
|
61
61
|
create(DiagramType, {
|
|
62
62
|
name: faker.commerce.productName(),
|
|
63
|
-
canvas: create(CanvasType, { content: {} }),
|
|
63
|
+
canvas: makeRef(create(CanvasType, { content: {} })),
|
|
64
64
|
}),
|
|
65
65
|
);
|
|
66
66
|
|
|
@@ -109,30 +109,57 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
109
109
|
return objects;
|
|
110
110
|
},
|
|
111
111
|
],
|
|
112
|
+
[
|
|
113
|
+
ComputeGraph.typename,
|
|
114
|
+
async (space, n, cb) => {
|
|
115
|
+
const objects = range(n, () => {
|
|
116
|
+
const model = ComputeGraphModel.create();
|
|
117
|
+
model.builder
|
|
118
|
+
.createNode({ id: 'gpt-INPUT', type: NODE_INPUT })
|
|
119
|
+
.createNode({ id: 'gpt-GPT', type: 'gpt' })
|
|
120
|
+
.createNode({
|
|
121
|
+
id: 'gpt-QUEUE_ID',
|
|
122
|
+
type: 'constant',
|
|
123
|
+
value: new DXN(DXN.kind.QUEUE, ['data', SpaceId.random(), ObjectId.random()]).toString(),
|
|
124
|
+
})
|
|
125
|
+
.createNode({ id: 'gpt-APPEND', type: 'append' })
|
|
126
|
+
.createNode({ id: 'gpt-OUTPUT', type: NODE_OUTPUT })
|
|
127
|
+
.createEdge({ node: 'gpt-INPUT', property: 'prompt' }, { node: 'gpt-GPT', property: 'prompt' })
|
|
128
|
+
.createEdge({ node: 'gpt-GPT', property: 'text' }, { node: 'gpt-OUTPUT', property: 'text' })
|
|
129
|
+
.createEdge({ node: 'gpt-QUEUE_ID', property: DEFAULT_OUTPUT }, { node: 'gpt-APPEND', property: 'id' })
|
|
130
|
+
.createEdge({ node: 'gpt-GPT', property: 'messages' }, { node: 'gpt-APPEND', property: 'items' })
|
|
131
|
+
.createEdge({ node: 'gpt-QUEUE_ID', property: DEFAULT_OUTPUT }, { node: 'gpt-OUTPUT', property: 'queue' });
|
|
132
|
+
|
|
133
|
+
return space.db.add(model.root);
|
|
134
|
+
});
|
|
135
|
+
cb?.(objects);
|
|
136
|
+
return objects;
|
|
137
|
+
},
|
|
138
|
+
],
|
|
112
139
|
]);
|
|
113
140
|
|
|
114
|
-
export const createGenerator = <T extends BaseObject>(type:
|
|
141
|
+
export const createGenerator = <T extends BaseObject>(type: TypedObject<T>): ObjectGenerator<T> => {
|
|
115
142
|
return async (
|
|
116
143
|
space: Space,
|
|
117
144
|
n: number,
|
|
118
145
|
cb?: (objects: ReactiveObject<any>[]) => void,
|
|
119
146
|
): Promise<ReactiveObject<T>[]> => {
|
|
120
147
|
// Find or create mutable schema.
|
|
121
|
-
const mutableSchema = await space.db.schemaRegistry.query();
|
|
122
148
|
const schema =
|
|
123
|
-
|
|
149
|
+
(await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??
|
|
150
|
+
(await space.db.schemaRegistry.register([type]))[0];
|
|
124
151
|
|
|
125
152
|
// Create objects.
|
|
126
|
-
const generate = createAsyncGenerator(generator, schema.
|
|
153
|
+
const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { db: space.db });
|
|
127
154
|
const objects = await generate.createObjects(n);
|
|
128
155
|
|
|
129
156
|
// Find or create table and view.
|
|
130
157
|
const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
|
|
131
|
-
const table = tables.find((table) => table.view?.query?.type === type.typename);
|
|
158
|
+
const table = tables.find((table) => table.view?.target?.query?.type === type.typename);
|
|
132
159
|
if (!table) {
|
|
133
160
|
const name = type.typename.split('/').pop() ?? type.typename;
|
|
134
161
|
const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });
|
|
135
|
-
const table = space.db.add(create(TableType, { name, view }));
|
|
162
|
+
const table = space.db.add(create(TableType, { name, view: makeRef(view) }));
|
|
136
163
|
cb?.([table]);
|
|
137
164
|
}
|
|
138
165
|
|
|
@@ -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';
|
|
@@ -17,6 +18,7 @@ import { jsonKeyReplacer, sortKeys } from '@dxos/util';
|
|
|
17
18
|
|
|
18
19
|
import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
|
|
19
20
|
import { SchemaTable } from './SchemaTable';
|
|
21
|
+
import { presets } from './presets';
|
|
20
22
|
|
|
21
23
|
export type SpaceGeneratorProps = {
|
|
22
24
|
space: Space;
|
|
@@ -25,25 +27,25 @@ 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.
|
|
29
|
-
const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType];
|
|
30
|
+
const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
|
|
31
|
+
const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType, Testing.EmailType];
|
|
30
32
|
const [count, setCount] = useState(1);
|
|
31
33
|
const [info, setInfo] = useState<any>({});
|
|
32
34
|
|
|
33
35
|
// Create type generators.
|
|
34
36
|
const typeMap = useMemo(() => {
|
|
35
|
-
client.addTypes(staticTypes);
|
|
37
|
+
client.addTypes([...staticTypes, ...presets.schemas]);
|
|
36
38
|
const mutableGenerators = new Map<string, ObjectGenerator<any>>(
|
|
37
|
-
mutableTypes.map((type) => [type.typename, createGenerator(type)]),
|
|
39
|
+
mutableTypes.map((type) => [type.typename, createGenerator(type as any)]),
|
|
38
40
|
);
|
|
39
41
|
|
|
40
|
-
return new Map([...staticGenerators, ...mutableGenerators]);
|
|
42
|
+
return new Map([...staticGenerators, ...presets.items, ...mutableGenerators]);
|
|
41
43
|
}, [client, mutableTypes]);
|
|
42
44
|
|
|
43
45
|
// Query space to get info.
|
|
44
46
|
const updateInfo = async () => {
|
|
45
47
|
// Create schema map.
|
|
46
|
-
const
|
|
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:
|
|
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.
|
|
91
|
+
<Toolbar.Separator variant='gap' />
|
|
90
92
|
<div className='flex'>
|
|
91
93
|
<Input.Root>
|
|
92
94
|
<Input.TextInput
|
|
@@ -104,6 +106,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
104
106
|
|
|
105
107
|
<SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
|
|
106
108
|
<SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />
|
|
109
|
+
<SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
|
|
107
110
|
|
|
108
111
|
<SyntaxHighlighter classNames='flex text-xs' language='json'>
|
|
109
112
|
{JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
|
|
@@ -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
|
|
89
|
+
const gridSize = 40;
|
|
90
90
|
const nodeSize = 80;
|
|
91
91
|
|
|
92
|
-
const snap = (n: number) => Math.round(n /
|
|
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:
|
|
101
|
-
height:
|
|
102
|
-
linkDistance:
|
|
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:
|
|
133
|
+
unitRadius: gridSize * 2,
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
}
|