@dxos/plugin-debug 0.8.3 → 0.8.4-main.c1de068
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-WSEJPCKY.mjs → DebugApp-ZDL4CPY5.mjs} +28 -25
- package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs.map +7 -0
- package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs → DevtoolsOverviewContainer-EPD6EWT5.mjs} +2 -2
- package/dist/lib/browser/{SpaceGenerator-VB6IB2LL.mjs → SpaceGenerator-AG3XGNMV.mjs} +186 -441
- package/dist/lib/browser/SpaceGenerator-AG3XGNMV.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-SQXFD2BL.mjs} +4 -4
- package/dist/lib/browser/{chunk-47JOZTT2.mjs → chunk-5XPIRNQS.mjs} +2 -2
- package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-AJA6RYN3.mjs} +2 -2
- package/dist/lib/browser/index.mjs +12 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-context-ZQRD2WG2.mjs → react-context-NVAGLAJD.mjs} +3 -3
- package/dist/lib/browser/{react-surface-UI6OK73H.mjs → react-surface-3GD2OWCA.mjs} +18 -18
- package/dist/lib/browser/react-surface-3GD2OWCA.mjs.map +7 -0
- package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-LSSWLM5I.mjs} +4 -4
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +3 -1
- 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 +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +1 -4
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +60 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -58
- package/src/DebugPlugin.tsx +1 -1
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/DebugApp/DebugApp.tsx +19 -12
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +25 -19
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +1 -1
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +9 -66
- package/src/components/SpaceGenerator/presets.ts +216 -214
- package/src/translations.ts +6 -4
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- /package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs.map → DevtoolsOverviewContainer-EPD6EWT5.mjs.map} +0 -0
- /package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs.map → app-graph-builder-SQXFD2BL.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-47JOZTT2.mjs.map → chunk-5XPIRNQS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-KS3YBEL7.mjs.map → chunk-AJA6RYN3.mjs.map} +0 -0
- /package/dist/lib/browser/{react-context-ZQRD2WG2.mjs.map → react-context-NVAGLAJD.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-SXQWSIM4.mjs.map → settings-LSSWLM5I.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-debug",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.c1de068",
|
|
4
4
|
"description": "DXOS Surface plugin for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@antv/graphlib": "^2.0.4",
|
|
27
27
|
"@antv/layout": "^1.2.13",
|
|
28
|
-
"@automerge/automerge": "3.0.0
|
|
28
|
+
"@automerge/automerge": "3.0.0",
|
|
29
29
|
"@preact-signals/safe-react": "^0.9.0",
|
|
30
30
|
"@preact/signals-core": "^1.9.0",
|
|
31
31
|
"@tldraw/tldraw": "^3.0.0",
|
|
@@ -33,75 +33,73 @@
|
|
|
33
33
|
"react-json-tree": "^0.18.0",
|
|
34
34
|
"react-resize-detector": "^11.0.1",
|
|
35
35
|
"workerize-loader": "^2.0.2",
|
|
36
|
-
"@dxos/app-framework": "0.8.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/echo": "0.8.
|
|
45
|
-
"@dxos/echo-generator": "0.8.
|
|
46
|
-
"@dxos/echo-pipeline": "0.8.
|
|
47
|
-
"@dxos/echo-schema": "0.8.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/live-object": "0.8.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/plugin-deck": "0.8.
|
|
56
|
-
"@dxos/plugin-graph": "0.8.
|
|
57
|
-
"@dxos/plugin-markdown": "0.8.
|
|
58
|
-
"@dxos/plugin-meeting": "0.8.
|
|
59
|
-
"@dxos/plugin-
|
|
60
|
-
"@dxos/plugin-
|
|
61
|
-
"@dxos/plugin-
|
|
62
|
-
"@dxos/plugin-
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/plugin-theme": "0.8.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/react-
|
|
69
|
-
"@dxos/react-
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/react-ui-
|
|
76
|
-
"@dxos/react-ui-
|
|
77
|
-
"@dxos/schema": "0.8.
|
|
78
|
-
"@dxos/util": "0.8.
|
|
79
|
-
"@dxos/
|
|
36
|
+
"@dxos/app-framework": "0.8.4-main.c1de068",
|
|
37
|
+
"@dxos/compute": "0.8.4-main.c1de068",
|
|
38
|
+
"@dxos/client-services": "0.8.4-main.c1de068",
|
|
39
|
+
"@dxos/conductor": "0.8.4-main.c1de068",
|
|
40
|
+
"@dxos/async": "0.8.4-main.c1de068",
|
|
41
|
+
"@dxos/context": "0.8.4-main.c1de068",
|
|
42
|
+
"@dxos/devtools": "0.8.4-main.c1de068",
|
|
43
|
+
"@dxos/config": "0.8.4-main.c1de068",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.c1de068",
|
|
45
|
+
"@dxos/echo-generator": "0.8.4-main.c1de068",
|
|
46
|
+
"@dxos/echo-pipeline": "0.8.4-main.c1de068",
|
|
47
|
+
"@dxos/echo-schema": "0.8.4-main.c1de068",
|
|
48
|
+
"@dxos/invariant": "0.8.4-main.c1de068",
|
|
49
|
+
"@dxos/keys": "0.8.4-main.c1de068",
|
|
50
|
+
"@dxos/functions": "0.8.4-main.c1de068",
|
|
51
|
+
"@dxos/live-object": "0.8.4-main.c1de068",
|
|
52
|
+
"@dxos/local-storage": "0.8.4-main.c1de068",
|
|
53
|
+
"@dxos/plugin-client": "0.8.4-main.c1de068",
|
|
54
|
+
"@dxos/log": "0.8.4-main.c1de068",
|
|
55
|
+
"@dxos/plugin-deck": "0.8.4-main.c1de068",
|
|
56
|
+
"@dxos/plugin-graph": "0.8.4-main.c1de068",
|
|
57
|
+
"@dxos/plugin-markdown": "0.8.4-main.c1de068",
|
|
58
|
+
"@dxos/plugin-meeting": "0.8.4-main.c1de068",
|
|
59
|
+
"@dxos/plugin-script": "0.8.4-main.c1de068",
|
|
60
|
+
"@dxos/plugin-sheet": "0.8.4-main.c1de068",
|
|
61
|
+
"@dxos/plugin-sketch": "0.8.4-main.c1de068",
|
|
62
|
+
"@dxos/plugin-status-bar": "0.8.4-main.c1de068",
|
|
63
|
+
"@dxos/plugin-space": "0.8.4-main.c1de068",
|
|
64
|
+
"@dxos/plugin-table": "0.8.4-main.c1de068",
|
|
65
|
+
"@dxos/plugin-theme": "0.8.4-main.c1de068",
|
|
66
|
+
"@dxos/protocols": "0.8.4-main.c1de068",
|
|
67
|
+
"@dxos/random": "0.8.4-main.c1de068",
|
|
68
|
+
"@dxos/react-client": "0.8.4-main.c1de068",
|
|
69
|
+
"@dxos/react-hooks": "0.8.4-main.c1de068",
|
|
70
|
+
"@dxos/react-ui-attention": "0.8.4-main.c1de068",
|
|
71
|
+
"@dxos/react-ui-canvas-compute": "0.8.4-main.c1de068",
|
|
72
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.c1de068",
|
|
73
|
+
"@dxos/react-ui-form": "0.8.4-main.c1de068",
|
|
74
|
+
"@dxos/react-ui-kanban": "0.8.4-main.c1de068",
|
|
75
|
+
"@dxos/react-ui-stack": "0.8.4-main.c1de068",
|
|
76
|
+
"@dxos/react-ui-table": "0.8.4-main.c1de068",
|
|
77
|
+
"@dxos/schema": "0.8.4-main.c1de068",
|
|
78
|
+
"@dxos/util": "0.8.4-main.c1de068",
|
|
79
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.c1de068"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@effect-rx/rx-react": "
|
|
83
|
-
"@effect/platform": "0.
|
|
84
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
82
|
+
"@effect-rx/rx-react": "0.38.0",
|
|
83
|
+
"@effect/platform": "0.89.0",
|
|
85
84
|
"@types/react": "~18.2.0",
|
|
86
85
|
"@types/react-dom": "~18.2.0",
|
|
87
|
-
"effect": "3.
|
|
86
|
+
"effect": "3.17.0",
|
|
88
87
|
"react": "~18.2.0",
|
|
89
88
|
"react-dom": "~18.2.0",
|
|
90
89
|
"vite": "5.4.7",
|
|
91
|
-
"@dxos/react-ui": "0.8.
|
|
92
|
-
"@dxos/react-ui-theme": "0.8.
|
|
93
|
-
"@dxos/storybook-utils": "0.8.
|
|
90
|
+
"@dxos/react-ui": "0.8.4-main.c1de068",
|
|
91
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068",
|
|
92
|
+
"@dxos/storybook-utils": "0.8.4-main.c1de068"
|
|
94
93
|
},
|
|
95
94
|
"peerDependencies": {
|
|
96
95
|
"@effect-rx/rx-react": "^0.34.1",
|
|
97
|
-
"@effect/platform": "0.80.12",
|
|
98
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
96
|
+
"@effect/platform": "^0.80.12",
|
|
99
97
|
"effect": "^3.13.3",
|
|
100
98
|
"react": "~18.2.0",
|
|
101
99
|
"react-dom": "~18.2.0",
|
|
102
|
-
"@dxos/
|
|
103
|
-
"@dxos/react-ui": "0.8.
|
|
104
|
-
"@dxos/
|
|
100
|
+
"@dxos/random": "0.8.4-main.c1de068",
|
|
101
|
+
"@dxos/react-ui-theme": "0.8.4-main.c1de068",
|
|
102
|
+
"@dxos/react-ui": "0.8.4-main.c1de068"
|
|
105
103
|
},
|
|
106
104
|
"publishConfig": {
|
|
107
105
|
"access": "public"
|
package/src/DebugPlugin.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { type Client } from '@dxos/react-client';
|
|
|
7
7
|
|
|
8
8
|
import { AppGraphBuilder, DebugSettings, ReactContext, ReactSurface } from './capabilities';
|
|
9
9
|
import { meta } from './meta';
|
|
10
|
-
import translations from './translations';
|
|
10
|
+
import { translations } from './translations';
|
|
11
11
|
|
|
12
12
|
// TODO(wittjosiah): Rename to DevtoolsPlugin?
|
|
13
13
|
export const DebugPlugin = () => {
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
TracingPanel,
|
|
44
44
|
WorkflowPanel,
|
|
45
45
|
} from '@dxos/devtools';
|
|
46
|
-
import { Obj
|
|
46
|
+
import { Obj } from '@dxos/echo';
|
|
47
47
|
import { SettingsStore } from '@dxos/local-storage';
|
|
48
48
|
import { log } from '@dxos/log';
|
|
49
49
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
@@ -111,7 +111,7 @@ export default (context: PluginContext) =>
|
|
|
111
111
|
|
|
112
112
|
const collection =
|
|
113
113
|
data.subject.space.state.get() === SpaceState.SPACE_READY &&
|
|
114
|
-
data.subject.space.properties[
|
|
114
|
+
data.subject.space.properties[DataType.Collection.typename]?.target;
|
|
115
115
|
if (!Obj.instanceOf(DataType.Collection, collection)) {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Gauge, Graph as GraphIcon, Gear, Toolbox, Warning } from '@phosphor-icons/react';
|
|
6
5
|
import React, { type FC, useEffect, useState } from 'react';
|
|
7
6
|
|
|
8
7
|
import { type Graph } from '@dxos/plugin-graph';
|
|
9
8
|
import { useClient, useConfig } from '@dxos/react-client';
|
|
10
|
-
import {
|
|
11
|
-
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
9
|
+
import { ToggleGroup, ToggleGroupItem, Toolbar, Icon, IconButton } from '@dxos/react-ui';
|
|
12
10
|
|
|
13
11
|
import { Json, Tree } from './Tree';
|
|
14
12
|
import { Container } from '../Container';
|
|
@@ -49,23 +47,32 @@ export const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {
|
|
|
49
47
|
<Toolbar.Root classNames='p-1'>
|
|
50
48
|
<ToggleGroup type='single' value={view}>
|
|
51
49
|
<ToggleGroupItem value={'graph'} onClick={() => setView('graph')} title={'Plugin graph'}>
|
|
52
|
-
<
|
|
50
|
+
<Icon icon='ph--graph--regular' size={5} />
|
|
53
51
|
</ToggleGroupItem>
|
|
54
52
|
<ToggleGroupItem value={'diagnostics'} onClick={() => setView('diagnostics')} title={'Diagnostics'}>
|
|
55
|
-
<
|
|
53
|
+
<Icon icon='ph--gauge--regular' size={5} />
|
|
56
54
|
</ToggleGroupItem>
|
|
57
55
|
<ToggleGroupItem value={'config'} onClick={() => setView('config')} title={'Config'}>
|
|
58
|
-
<
|
|
56
|
+
<Icon icon='ph--gear--regular' size={5} />
|
|
59
57
|
</ToggleGroupItem>
|
|
60
58
|
</ToggleGroup>
|
|
61
59
|
|
|
62
60
|
<Toolbar.Separator variant='gap' />
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
<IconButton
|
|
62
|
+
icon='ph--warning--regular'
|
|
63
|
+
iconOnly
|
|
64
|
+
size={5}
|
|
65
|
+
classNames='text-red-700'
|
|
66
|
+
onClick={(event) => handleResetClient(event.shiftKey)}
|
|
67
|
+
label='Reset client'
|
|
68
|
+
/>
|
|
69
|
+
<IconButton
|
|
70
|
+
icon='ph--toolbox--duotone'
|
|
71
|
+
iconOnly
|
|
72
|
+
size={5}
|
|
73
|
+
onClick={handleOpenDevtools}
|
|
74
|
+
label='Open Devtools'
|
|
75
|
+
/>
|
|
69
76
|
</Toolbar.Root>
|
|
70
77
|
}
|
|
71
78
|
>
|
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
5
6
|
import { addressToA1Notation } from '@dxos/compute';
|
|
6
7
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
7
|
-
import { DXN, Filter, Key, Obj, Ref } from '@dxos/echo';
|
|
8
|
+
import { DXN, Filter, Key, Obj, Ref, Type } from '@dxos/echo';
|
|
8
9
|
import { type TypedObject } from '@dxos/echo-schema';
|
|
9
10
|
import { DocumentType } from '@dxos/plugin-markdown/types';
|
|
10
11
|
import { createSheet } from '@dxos/plugin-sheet/types';
|
|
11
12
|
import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
|
|
12
13
|
import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
|
|
14
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
15
|
import { faker } from '@dxos/random';
|
|
16
|
+
import { type Client } from '@dxos/react-client';
|
|
14
17
|
import { type Space } from '@dxos/react-client/echo';
|
|
15
|
-
import {
|
|
16
|
-
import { createView, DataType } from '@dxos/schema';
|
|
18
|
+
import { DataType } from '@dxos/schema';
|
|
17
19
|
import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
|
|
18
20
|
import { range } from '@dxos/util';
|
|
19
21
|
|
|
@@ -21,27 +23,31 @@ const generator: ValueGenerator = faker as any;
|
|
|
21
23
|
|
|
22
24
|
export type ObjectGenerator<T extends Obj.Any> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
const schema =
|
|
28
|
-
(await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??
|
|
29
|
-
(await space.db.schemaRegistry.register([type]))[0];
|
|
26
|
+
const findViewByTypename = async (views: DataType.View[], typename: string) => {
|
|
27
|
+
return views.find((view) => view.query.typename === typename);
|
|
28
|
+
};
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
export const createGenerator = <T extends Obj.Any>(
|
|
31
|
+
client: Client,
|
|
32
|
+
dispatch: PromiseIntentDispatcher,
|
|
33
|
+
schema: TypedObject<T>,
|
|
34
|
+
): ObjectGenerator<T> => {
|
|
35
|
+
return async (space: Space, n: number, cb?: (objects: T[]) => void): Promise<T[]> => {
|
|
36
|
+
const typename = schema.typename;
|
|
34
37
|
|
|
35
38
|
// Find or create table and view.
|
|
36
|
-
const { objects:
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const { objects: views } = await space.db.query(Filter.type(DataType.View)).run();
|
|
40
|
+
const view = await findViewByTypename(views, typename);
|
|
41
|
+
const staticSchema = client?.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
42
|
+
if (!view && !staticSchema) {
|
|
43
|
+
await dispatch(createIntent(SpaceAction.AddSchema, { space, schema }));
|
|
44
|
+
} else if (!view && staticSchema) {
|
|
45
|
+
await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename }));
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
// Create objects.
|
|
49
|
+
const generate = createAsyncGenerator(generator, schema, { db: space.db });
|
|
50
|
+
return generate.createObjects(n);
|
|
45
51
|
};
|
|
46
52
|
};
|
|
47
53
|
|
|
@@ -4,19 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { ComputeGraph } from '@dxos/conductor';
|
|
9
|
-
import { Filter, Obj
|
|
10
|
-
import { log } from '@dxos/log';
|
|
9
|
+
import { Filter, type Obj } from '@dxos/echo';
|
|
11
10
|
import { DocumentType } from '@dxos/plugin-markdown/types';
|
|
12
11
|
import { SheetType } from '@dxos/plugin-sheet/types';
|
|
13
12
|
import { DiagramType } from '@dxos/plugin-sketch/types';
|
|
14
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
15
13
|
import { useClient } from '@dxos/react-client';
|
|
16
14
|
import { getTypename, type Space } from '@dxos/react-client/echo';
|
|
17
15
|
import { IconButton, Input, 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
17
|
import { DataType } from '@dxos/schema';
|
|
21
18
|
import { jsonKeyReplacer, sortKeys } from '@dxos/util';
|
|
22
19
|
|
|
@@ -33,20 +30,20 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
33
30
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
34
31
|
const client = useClient();
|
|
35
32
|
const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
|
|
36
|
-
const
|
|
33
|
+
const recordTypes = [DataType.Organization, DataType.Project, DataType.Person, DataType.Message];
|
|
37
34
|
const [count, setCount] = useState(1);
|
|
38
35
|
const [info, setInfo] = useState<any>({});
|
|
39
36
|
const presets = useMemo(() => generator(), []);
|
|
40
37
|
|
|
41
38
|
// Create type generators.
|
|
42
39
|
const typeMap = useMemo(() => {
|
|
43
|
-
client.addTypes([...staticTypes, ...presets.schemas]);
|
|
44
|
-
const
|
|
45
|
-
|
|
40
|
+
client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
|
|
41
|
+
const recordGenerators = new Map<string, ObjectGenerator<any>>(
|
|
42
|
+
recordTypes.map((type) => [type.typename, createGenerator(client, dispatch, type as any)]),
|
|
46
43
|
);
|
|
47
44
|
|
|
48
|
-
return new Map([...staticGenerators, ...presets.items, ...
|
|
49
|
-
}, [client,
|
|
45
|
+
return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
|
|
46
|
+
}, [client, recordTypes]);
|
|
50
47
|
|
|
51
48
|
// Query space to get info.
|
|
52
49
|
const updateInfo = async () => {
|
|
@@ -90,64 +87,10 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
90
87
|
[typeMap, count],
|
|
91
88
|
);
|
|
92
89
|
|
|
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
90
|
return (
|
|
142
91
|
<div role='none' className='flex flex-col grow overflow-hidden'>
|
|
143
92
|
<Toolbar.Root classNames='border-be border-subduedSeparator'>
|
|
144
93
|
<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
94
|
<Toolbar.Separator variant='gap' />
|
|
152
95
|
<Input.Root>
|
|
153
96
|
<Input.TextInput
|
|
@@ -165,7 +108,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
165
108
|
|
|
166
109
|
<div className='flex flex-col overflow-y-auto divide-y divide-separator'>
|
|
167
110
|
<SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
|
|
168
|
-
<SchemaTable types={
|
|
111
|
+
<SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
|
|
169
112
|
<SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
|
|
170
113
|
|
|
171
114
|
<div>
|