@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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, Capabilities, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
7
|
+
import { createExtension, toSignal, type Node } from '@dxos/plugin-graph';
|
|
8
|
+
import { memoizeQuery } from '@dxos/plugin-space';
|
|
9
|
+
import { CollectionType } from '@dxos/plugin-space/types';
|
|
10
|
+
import { getTypename, parseId, SpaceState } from '@dxos/react-client/echo';
|
|
11
|
+
import { isSpace, type Space } from '@dxos/react-client/echo';
|
|
12
|
+
|
|
13
|
+
import { DEBUG_PLUGIN } from '../meta';
|
|
14
|
+
import { type DebugSettingsProps } from '../types';
|
|
15
|
+
|
|
16
|
+
export default (context: PluginsContext) => {
|
|
17
|
+
const resolve = (typename: string) =>
|
|
18
|
+
context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
|
|
19
|
+
|
|
20
|
+
return contributes(Capabilities.AppGraphBuilder, [
|
|
21
|
+
// Devtools node.
|
|
22
|
+
createExtension({
|
|
23
|
+
id: 'dxos.org/plugin/debug/devtools',
|
|
24
|
+
filter: (node): node is Node<null> => {
|
|
25
|
+
const settings = context
|
|
26
|
+
.requestCapabilities(Capabilities.SettingsStore)[0]
|
|
27
|
+
?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;
|
|
28
|
+
return !!settings?.devtools && node.id === 'root';
|
|
29
|
+
},
|
|
30
|
+
connector: () => [
|
|
31
|
+
{
|
|
32
|
+
// TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
|
|
33
|
+
id: 'dxos.org.plugin.debug.devtools',
|
|
34
|
+
data: 'devtools',
|
|
35
|
+
type: 'dxos.org/plugin/debug/devtools',
|
|
36
|
+
properties: {
|
|
37
|
+
label: ['devtools label', { ns: DEBUG_PLUGIN }],
|
|
38
|
+
disposition: 'navigation',
|
|
39
|
+
icon: 'ph--hammer--regular',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
|
|
45
|
+
// Debug node.
|
|
46
|
+
createExtension({
|
|
47
|
+
id: 'dxos.org/plugin/debug/debug',
|
|
48
|
+
filter: (node): node is Node<null> => {
|
|
49
|
+
const settings = context
|
|
50
|
+
.requestCapabilities(Capabilities.SettingsStore)[0]
|
|
51
|
+
?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;
|
|
52
|
+
return !!settings?.debug && node.id === 'root';
|
|
53
|
+
},
|
|
54
|
+
connector: () => {
|
|
55
|
+
const [graph] = context.requestCapabilities(Capabilities.AppGraph);
|
|
56
|
+
if (!graph) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
id: 'dxos.org/plugin/debug/debug',
|
|
63
|
+
type: 'dxos.org/plugin/debug/debug',
|
|
64
|
+
data: { graph },
|
|
65
|
+
properties: {
|
|
66
|
+
label: ['debug label', { ns: DEBUG_PLUGIN }],
|
|
67
|
+
disposition: 'navigation',
|
|
68
|
+
icon: 'ph--bug--regular',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
|
|
75
|
+
// Space debug nodes.
|
|
76
|
+
createExtension({
|
|
77
|
+
id: 'dxos.org/plugin/debug/spaces',
|
|
78
|
+
filter: (node): node is Node<Space> => {
|
|
79
|
+
const settings = context
|
|
80
|
+
.requestCapabilities(Capabilities.SettingsStore)[0]
|
|
81
|
+
?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;
|
|
82
|
+
return !!settings?.debug && isSpace(node.data);
|
|
83
|
+
},
|
|
84
|
+
connector: ({ node }) => {
|
|
85
|
+
const space = node.data;
|
|
86
|
+
const state = toSignal(
|
|
87
|
+
(onChange) => space.state.subscribe(() => onChange()).unsubscribe,
|
|
88
|
+
() => space.state.get(),
|
|
89
|
+
space.id,
|
|
90
|
+
);
|
|
91
|
+
if (state !== SpaceState.SPACE_READY) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Not adding the debug node until the root collection is available aligns the behaviour of this
|
|
96
|
+
// extension with that of the space plugin adding objects. This ensures that the debug node is added at
|
|
97
|
+
// the same time as objects and prevents order from changing as the nodes are added.
|
|
98
|
+
const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;
|
|
99
|
+
if (!collection) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
id: `${space.id}-debug`, // TODO(burdon): Change to slashes consistently.
|
|
106
|
+
type: 'dxos.org/plugin/debug/space',
|
|
107
|
+
data: { space, type: 'dxos.org/plugin/debug/space' },
|
|
108
|
+
properties: {
|
|
109
|
+
label: ['debug label', { ns: DEBUG_PLUGIN }],
|
|
110
|
+
icon: 'ph--bug--regular',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
|
|
117
|
+
// Create nodes for debug sidebar.
|
|
118
|
+
createExtension({
|
|
119
|
+
id: `${DEBUG_PLUGIN}/debug-for-subject`,
|
|
120
|
+
resolver: ({ id }) => {
|
|
121
|
+
if (!id.endsWith('~debug')) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const type = 'orphan-settings-for-subject';
|
|
126
|
+
const icon = 'ph--bug--regular';
|
|
127
|
+
|
|
128
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
129
|
+
const [subjectId] = id.split('~');
|
|
130
|
+
const { spaceId, objectId } = parseId(subjectId);
|
|
131
|
+
const spaces = toSignal(
|
|
132
|
+
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
133
|
+
() => client.spaces.get(),
|
|
134
|
+
);
|
|
135
|
+
const space = spaces?.find((space) => space.state.get() === SpaceState.SPACE_READY && space.id === spaceId);
|
|
136
|
+
if (!objectId) {
|
|
137
|
+
// TODO(burdon): Ref SPACE_PLUGIN ns.
|
|
138
|
+
const label = space
|
|
139
|
+
? space.properties.name || ['unnamed space label', { ns: DEBUG_PLUGIN }]
|
|
140
|
+
: ['unnamed object settings label', { ns: DEBUG_PLUGIN }];
|
|
141
|
+
|
|
142
|
+
// TODO(wittjosiah): Support comments for arbitrary subjects.
|
|
143
|
+
// This is to ensure that the comments panel is not stuck on an old object.
|
|
144
|
+
return {
|
|
145
|
+
id,
|
|
146
|
+
type,
|
|
147
|
+
data: null,
|
|
148
|
+
properties: { icon, label, object: null, space },
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const [object] = memoizeQuery(space, { id: objectId });
|
|
153
|
+
if (!object || !subjectId) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const meta = resolve(getTypename(object) ?? '');
|
|
158
|
+
const label = meta.label?.(object) ||
|
|
159
|
+
object.name ||
|
|
160
|
+
meta.placeholder || ['unnamed object settings label', { ns: DEBUG_PLUGIN }];
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
id,
|
|
164
|
+
type,
|
|
165
|
+
data: null,
|
|
166
|
+
properties: {
|
|
167
|
+
icon,
|
|
168
|
+
label,
|
|
169
|
+
object,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
]);
|
|
175
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
8
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
9
|
+
export const DebugSettings = lazy(() => import('./settings'));
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createIntent, createSurface, type PluginsContext } from '@dxos/app-framework';
|
|
8
|
+
import { Devtools } from '@dxos/devtools';
|
|
9
|
+
import { SettingsStore } from '@dxos/local-storage';
|
|
10
|
+
import { Graph } from '@dxos/plugin-graph';
|
|
11
|
+
import { SpaceAction, CollectionType } from '@dxos/plugin-space/types';
|
|
12
|
+
import {
|
|
13
|
+
SpaceState,
|
|
14
|
+
isSpace,
|
|
15
|
+
isEchoObject,
|
|
16
|
+
type ReactiveEchoObject,
|
|
17
|
+
type ReactiveObject,
|
|
18
|
+
type Space,
|
|
19
|
+
} from '@dxos/react-client/echo';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
DebugApp,
|
|
23
|
+
DebugObjectPanel,
|
|
24
|
+
DebugSettings,
|
|
25
|
+
DebugSpace,
|
|
26
|
+
DebugStatus,
|
|
27
|
+
SpaceGenerator,
|
|
28
|
+
Wireframe,
|
|
29
|
+
} from '../components';
|
|
30
|
+
import { DEBUG_PLUGIN } from '../meta';
|
|
31
|
+
import { type DebugSettingsProps } from '../types';
|
|
32
|
+
|
|
33
|
+
type SpaceDebug = {
|
|
34
|
+
type: string;
|
|
35
|
+
space: Space;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
type GraphDebug = {
|
|
39
|
+
graph: Graph;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isSpaceDebug = (data: any): data is SpaceDebug => data.type === `${DEBUG_PLUGIN}/space` && isSpace(data.space);
|
|
43
|
+
const isGraphDebug = (data: any): data is GraphDebug => data.graph instanceof Graph;
|
|
44
|
+
|
|
45
|
+
export default (context: PluginsContext) =>
|
|
46
|
+
contributes(Capabilities.ReactSurface, [
|
|
47
|
+
createSurface({
|
|
48
|
+
id: `${DEBUG_PLUGIN}/settings`,
|
|
49
|
+
role: 'article',
|
|
50
|
+
filter: (data): data is { subject: SettingsStore<DebugSettingsProps> } =>
|
|
51
|
+
data.subject instanceof SettingsStore && data.subject.prefix === DEBUG_PLUGIN,
|
|
52
|
+
component: ({ data: { subject } }) => <DebugSettings settings={subject.value} />,
|
|
53
|
+
}),
|
|
54
|
+
createSurface({
|
|
55
|
+
id: `${DEBUG_PLUGIN}/status`,
|
|
56
|
+
role: 'status',
|
|
57
|
+
component: () => <DebugStatus />,
|
|
58
|
+
}),
|
|
59
|
+
createSurface({
|
|
60
|
+
id: `${DEBUG_PLUGIN}/complementary`,
|
|
61
|
+
role: 'complementary--debug',
|
|
62
|
+
filter: (data): data is { subject: ReactiveEchoObject<any> } => isEchoObject(data.subject),
|
|
63
|
+
component: ({ data }) => <DebugObjectPanel object={data.subject} />,
|
|
64
|
+
}),
|
|
65
|
+
createSurface({
|
|
66
|
+
id: `${DEBUG_PLUGIN}/devtools`,
|
|
67
|
+
role: 'article',
|
|
68
|
+
filter: (data): data is any => {
|
|
69
|
+
const settings = context
|
|
70
|
+
.requestCapability(Capabilities.SettingsStore)
|
|
71
|
+
.getStore<DebugSettingsProps>(DEBUG_PLUGIN)!.value;
|
|
72
|
+
return data.subject === 'devtools' && !!settings.devtools;
|
|
73
|
+
},
|
|
74
|
+
component: () => <Devtools />,
|
|
75
|
+
}),
|
|
76
|
+
createSurface({
|
|
77
|
+
id: `${DEBUG_PLUGIN}/space`,
|
|
78
|
+
role: 'article',
|
|
79
|
+
filter: (data): data is { subject: SpaceDebug } => isSpaceDebug(data.subject),
|
|
80
|
+
component: ({ data }) => {
|
|
81
|
+
const handleCreateObject = useCallback(
|
|
82
|
+
(objects: ReactiveObject<any>[]) => {
|
|
83
|
+
if (!isSpace(data.subject.space)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const collection =
|
|
88
|
+
data.subject.space.state.get() === SpaceState.SPACE_READY &&
|
|
89
|
+
data.subject.space.properties[CollectionType.typename]?.target;
|
|
90
|
+
if (!(collection instanceof CollectionType)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
95
|
+
objects.forEach((object) => {
|
|
96
|
+
void dispatch(createIntent(SpaceAction.AddObject, { target: collection, object }));
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
[data.subject.space],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const deprecated = false;
|
|
103
|
+
return deprecated ? (
|
|
104
|
+
<DebugSpace space={data.subject.space} onAddObjects={handleCreateObject} />
|
|
105
|
+
) : (
|
|
106
|
+
<SpaceGenerator space={data.subject.space} onCreateObjects={handleCreateObject} />
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
createSurface({
|
|
111
|
+
id: `${DEBUG_PLUGIN}/graph`,
|
|
112
|
+
role: 'article',
|
|
113
|
+
filter: (data): data is { subject: GraphDebug } => isGraphDebug(data.subject),
|
|
114
|
+
component: ({ data }) => <DebugApp graph={data.subject.graph} />,
|
|
115
|
+
}),
|
|
116
|
+
createSurface({
|
|
117
|
+
id: `${DEBUG_PLUGIN}/wireframe`,
|
|
118
|
+
role: ['article', 'section'],
|
|
119
|
+
position: 'hoist',
|
|
120
|
+
filter: (data): data is { subject: ReactiveEchoObject<any> } => {
|
|
121
|
+
const settings = context
|
|
122
|
+
.requestCapability(Capabilities.SettingsStore)
|
|
123
|
+
.getStore<DebugSettingsProps>(DEBUG_PLUGIN)!.value;
|
|
124
|
+
return isEchoObject(data.subject) && !!settings.wireframe;
|
|
125
|
+
},
|
|
126
|
+
component: ({ data, role }) => (
|
|
127
|
+
<Wireframe label={`${role}:${name}`} object={data.subject} classNames='row-span-2 overflow-hidden' />
|
|
128
|
+
),
|
|
129
|
+
}),
|
|
130
|
+
]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
6
|
+
import { create } from '@dxos/react-client/echo';
|
|
7
|
+
|
|
8
|
+
import { DEBUG_PLUGIN } from '../meta';
|
|
9
|
+
import { type DebugSettingsProps, DebugSettingsSchema } from '../types';
|
|
10
|
+
|
|
11
|
+
export default () => {
|
|
12
|
+
const settings = create<DebugSettingsProps>({
|
|
13
|
+
debug: true,
|
|
14
|
+
devtools: true,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return contributes(Capabilities.Settings, { schema: DebugSettingsSchema, prefix: DEBUG_PLUGIN, value: settings });
|
|
18
|
+
};
|
|
@@ -59,7 +59,7 @@ export const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {
|
|
|
59
59
|
</ToggleGroupItem>
|
|
60
60
|
</ToggleGroup>
|
|
61
61
|
|
|
62
|
-
<Toolbar.
|
|
62
|
+
<Toolbar.Separator variant='gap' />
|
|
63
63
|
<Button onClick={(event) => handleResetClient(event.shiftKey)} title='Reset client'>
|
|
64
64
|
<Warning className={mx(getSize(5), 'text-red-700')} />
|
|
65
65
|
</Button>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ReactiveEchoObject } from '@dxos/client/echo';
|
|
8
|
+
import { Clipboard, Input } from '@dxos/react-ui';
|
|
8
9
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
9
10
|
|
|
10
11
|
export type DebugObjectPanelProps = {
|
|
@@ -13,11 +14,22 @@ export type DebugObjectPanelProps = {
|
|
|
13
14
|
|
|
14
15
|
// TODO(burdon): Get schema and traverse references.
|
|
15
16
|
export const DebugObjectPanel = ({ object }: DebugObjectPanelProps) => {
|
|
17
|
+
const dxn = `dxn:echo:@:${object.id}`;
|
|
16
18
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
<Clipboard.Provider>
|
|
20
|
+
<div className='flex flex-col'>
|
|
21
|
+
<Input.Root>
|
|
22
|
+
<div role='none' className='flex flex-col gap-1'>
|
|
23
|
+
<div role='none' className='flex gap-1'>
|
|
24
|
+
<Input.TextInput disabled value={dxn} />
|
|
25
|
+
<Clipboard.IconButton value={dxn} />
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</Input.Root>
|
|
29
|
+
<SyntaxHighlighter classNames='flex text-xs' language='json'>
|
|
30
|
+
{JSON.stringify(object, null, 2)}
|
|
31
|
+
</SyntaxHighlighter>
|
|
32
|
+
</div>
|
|
33
|
+
</Clipboard.Provider>
|
|
22
34
|
);
|
|
23
35
|
};
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Gift, DownloadSimple, FirstAidKit } from '@phosphor-icons/react';
|
|
6
5
|
import React, { useEffect, useState } from 'react';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
9
8
|
import { type ConfigProto, defs, SaveConfig, Storage } from '@dxos/config';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
11
10
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { useTranslation, Button, Toast, Input, useFileDownload, Select } from '@dxos/react-ui';
|
|
13
|
-
import { DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
14
|
-
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
11
|
+
import { useTranslation, Button, Toast, Input, useFileDownload, Select, Icon } from '@dxos/react-ui';
|
|
12
|
+
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
15
13
|
import { setDeep } from '@dxos/util';
|
|
16
14
|
|
|
17
15
|
import { DEBUG_PLUGIN } from '../meta';
|
|
@@ -34,7 +32,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
34
32
|
const download = useFileDownload();
|
|
35
33
|
// TODO(mykola): Get updates from other places that change Config.
|
|
36
34
|
const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
|
|
37
|
-
const
|
|
35
|
+
const [upload] = useCapabilities(Capabilities.FileUploader);
|
|
38
36
|
|
|
39
37
|
useEffect(() => {
|
|
40
38
|
void Storage().then((config) => setStorageConfig(config));
|
|
@@ -52,8 +50,8 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
52
50
|
const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
|
|
53
51
|
download(file, fileName);
|
|
54
52
|
|
|
55
|
-
if (
|
|
56
|
-
const info = await
|
|
53
|
+
if (upload) {
|
|
54
|
+
const info = await upload(new File([file], fileName), client.spaces.default);
|
|
57
55
|
if (!info) {
|
|
58
56
|
log.error('diagnostics failed to upload to IPFS');
|
|
59
57
|
return;
|
|
@@ -79,7 +77,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
79
77
|
};
|
|
80
78
|
|
|
81
79
|
return (
|
|
82
|
-
|
|
80
|
+
<DeprecatedFormContainer>
|
|
83
81
|
<DeprecatedFormInput label={t('settings show debug panel')}>
|
|
84
82
|
<Input.Switch checked={settings.debug} onCheckedChange={(checked) => (settings.debug = !!checked)} />
|
|
85
83
|
</DeprecatedFormInput>
|
|
@@ -91,12 +89,12 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
91
89
|
</DeprecatedFormInput>
|
|
92
90
|
<DeprecatedFormInput label={t('settings download diagnostics')}>
|
|
93
91
|
<Button onClick={handleDownload}>
|
|
94
|
-
<
|
|
92
|
+
<Icon icon='ph--download-simple--regular' size={5} />
|
|
95
93
|
</Button>
|
|
96
94
|
</DeprecatedFormInput>
|
|
97
95
|
<DeprecatedFormInput label={t('settings repair')}>
|
|
98
96
|
<Button onClick={handleRepair}>
|
|
99
|
-
<
|
|
97
|
+
<Icon icon='ph--first-aid-kit--regular' size={5} />
|
|
100
98
|
</Button>
|
|
101
99
|
</DeprecatedFormInput>
|
|
102
100
|
|
|
@@ -105,7 +103,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
105
103
|
<Toast.Root>
|
|
106
104
|
<Toast.Body>
|
|
107
105
|
<Toast.Title>
|
|
108
|
-
<
|
|
106
|
+
<Icon icon='ph--gift--duotone' size={5} classNames='inline mr-1' />
|
|
109
107
|
<span>{toast.title}</span>
|
|
110
108
|
</Toast.Title>
|
|
111
109
|
{toast.description && <Toast.Description>{toast.description}</Toast.Description>}
|
|
@@ -145,7 +143,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
145
143
|
</Select.Portal>
|
|
146
144
|
</Select.Root>
|
|
147
145
|
</DeprecatedFormInput>
|
|
148
|
-
|
|
146
|
+
</DeprecatedFormContainer>
|
|
149
147
|
);
|
|
150
148
|
};
|
|
151
149
|
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import { createSpaceObjectGenerator } from '@dxos/echo-generator';
|
|
11
11
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
+
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
13
14
|
import { render, withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
15
|
|
|
15
16
|
import { DebugSpace } from './DebugSpace';
|
|
16
17
|
|
|
17
18
|
const DefaultStory = () => {
|
|
18
19
|
const [space] = useSpaces();
|
|
19
|
-
|
|
20
|
+
useAsyncEffect(async () => {
|
|
20
21
|
if (space) {
|
|
21
22
|
const generator = createSpaceObjectGenerator(space);
|
|
22
|
-
generator.addSchemas();
|
|
23
|
+
await generator.addSchemas();
|
|
23
24
|
}
|
|
24
25
|
}, [space]);
|
|
25
26
|
|
|
@@ -158,7 +158,7 @@ export const DebugSpace: FC<{
|
|
|
158
158
|
<IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' size={5} onClick={handleUpdate} />
|
|
159
159
|
<IconButton icon='ph--download-simple--regular' iconOnly label='Download' size={5} onClick={handleDownload} />
|
|
160
160
|
|
|
161
|
-
<Toolbar.
|
|
161
|
+
<Toolbar.Separator variant='gap' />
|
|
162
162
|
<IconButton
|
|
163
163
|
icon='ph--flag-pennant--regular'
|
|
164
164
|
iconOnly
|
|
@@ -5,22 +5,23 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import { createSpaceObjectGenerator } from '@dxos/echo-generator';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
+
import { useAsyncEffect } from '@dxos/react-hooks';
|
|
14
15
|
import { render, withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
16
|
|
|
16
17
|
import { ObjectCreator, type ObjectCreatorProps } from './ObjectCreator';
|
|
17
18
|
|
|
18
19
|
const DefaultStory = () => {
|
|
19
20
|
const [space] = useSpaces();
|
|
20
|
-
|
|
21
|
+
useAsyncEffect(async () => {
|
|
21
22
|
if (space) {
|
|
22
23
|
const generator = createSpaceObjectGenerator(space);
|
|
23
|
-
generator.addSchemas();
|
|
24
|
+
await generator.addSchemas();
|
|
24
25
|
}
|
|
25
26
|
}, [space]);
|
|
26
27
|
|
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useAppGraph, useLayout } from '@dxos/app-framework';
|
|
8
8
|
import { TimeoutError } from '@dxos/async';
|
|
9
9
|
import { StatsPanel, useStats } from '@dxos/devtools';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
10
|
import { getActiveSpace } from '@dxos/plugin-space';
|
|
12
11
|
import { StatusBar } from '@dxos/plugin-status-bar';
|
|
13
12
|
import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
|
|
14
13
|
import { useNetworkStatus } from '@dxos/react-client/mesh';
|
|
15
|
-
import { Icon } from '@dxos/react-ui';
|
|
16
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
14
|
+
import { Icon, Popover } from '@dxos/react-ui';
|
|
17
15
|
|
|
18
16
|
const styles = {
|
|
19
17
|
success: 'text-sky-300 dark:text-green-700',
|
|
@@ -67,10 +65,7 @@ const ErrorIndicator = () => {
|
|
|
67
65
|
useEffect(() => {
|
|
68
66
|
const errorListener = (event: any) => {
|
|
69
67
|
const error: Error = event.error ?? event.reason;
|
|
70
|
-
// event.preventDefault();
|
|
71
68
|
if (errorRef.current !== error) {
|
|
72
|
-
// eslint-disable-next-line no-console
|
|
73
|
-
log.error('onError', { event });
|
|
74
69
|
errorRef.current = error;
|
|
75
70
|
forceUpdate({});
|
|
76
71
|
}
|
|
@@ -140,11 +135,9 @@ const SwarmIndicator = () => {
|
|
|
140
135
|
// TODO(burdon): Merge with SaveStatus.
|
|
141
136
|
const SavingIndicator = () => {
|
|
142
137
|
const [state, _setState] = useState(0);
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const graph = graphPlugin?.provides.graph;
|
|
147
|
-
const _space = location && graph ? getActiveSpace(graph, firstIdInPart(location.active, 'main')) : undefined;
|
|
138
|
+
const layout = useLayout();
|
|
139
|
+
const { graph } = useAppGraph();
|
|
140
|
+
const _space = graph ? getActiveSpace(graph, layout.active[0]) : undefined;
|
|
148
141
|
// TODO(dmaretskyi): Fix this when we have save status for automerge.
|
|
149
142
|
// useEffect(() => {
|
|
150
143
|
// if (!space) {
|
|
@@ -192,22 +185,19 @@ const PerformanceIndicator = () => {
|
|
|
192
185
|
const [stats, refreshStats] = useStats();
|
|
193
186
|
|
|
194
187
|
return (
|
|
195
|
-
|
|
196
|
-
<
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
'overflow-x-hidden overflow-y-auto scrollbar-thin',
|
|
204
|
-
'border-x border-y border-separator',
|
|
205
|
-
)}
|
|
206
|
-
>
|
|
188
|
+
<Popover.Root open={visible} onOpenChange={setVisible}>
|
|
189
|
+
<Popover.Trigger asChild>
|
|
190
|
+
<StatusBar.Button onClick={() => setVisible((visible) => !visible)} title='Performance panels'>
|
|
191
|
+
<Icon icon='ph--chart-bar--regular' size={4} />
|
|
192
|
+
</StatusBar.Button>
|
|
193
|
+
</Popover.Trigger>
|
|
194
|
+
<Popover.Portal>
|
|
195
|
+
<Popover.Content classNames='max-is-[min(var(--radix-popover-content-available-width),300px)] max-bs-[--radix-popover-content-available-height]'>
|
|
207
196
|
<StatsPanel stats={stats} onRefresh={refreshStats} />
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
197
|
+
<Popover.Arrow />
|
|
198
|
+
</Popover.Content>
|
|
199
|
+
</Popover.Portal>
|
|
200
|
+
</Popover.Root>
|
|
211
201
|
);
|
|
212
202
|
};
|
|
213
203
|
|