@dxos/plugin-debug 0.7.4 → 0.7.5-labs.a279d8c
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-BQ3645OS.mjs → SpaceGenerator-YNT3WDFI.mjs} +226 -20
- package/dist/lib/browser/SpaceGenerator-YNT3WDFI.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs +177 -0
- package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CAENAAHY.mjs → chunk-I3ON45JK.mjs} +3 -3
- package/dist/lib/browser/chunk-I3ON45JK.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 +66 -737
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-OZU6J7G3.mjs +37 -0
- package/dist/lib/browser/react-context-OZU6J7G3.mjs.map +7 -0
- package/dist/lib/browser/react-surface-ACHNR2UU.mjs +481 -0
- package/dist/lib/browser/react-surface-ACHNR2UU.mjs.map +7 -0
- package/dist/lib/browser/settings-JCZUA643.mjs +25 -0
- package/dist/lib/browser/settings-JCZUA643.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 +185 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +8 -0
- package/dist/types/src/capabilities/react-context.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/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/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 +1 -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 +48 -51
- package/src/DebugPlugin.tsx +60 -381
- package/src/capabilities/app-graph-builder.ts +177 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/react-context.tsx +38 -0
- package/src/capabilities/react-surface.tsx +138 -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 +4 -4
- 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 +3 -9
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +126 -18
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +6 -4
- package/src/components/SpaceGenerator/draw-util.ts +7 -6
- package/src/components/Wireframe.tsx +2 -2
- package/src/index.ts +1 -4
- package/src/meta.ts +1 -1
- package/src/types.ts +0 -22
- package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-debug",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-labs.a279d8c",
|
|
4
4
|
"description": "DXOS Surface plugin for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -11,19 +11,11 @@
|
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/types/src/index.d.ts",
|
|
13
13
|
"browser": "./dist/lib/browser/index.mjs"
|
|
14
|
-
},
|
|
15
|
-
"./meta": {
|
|
16
|
-
"types": "./dist/types/src/meta.d.ts",
|
|
17
|
-
"browser": "./dist/lib/browser/meta.mjs"
|
|
18
14
|
}
|
|
19
15
|
},
|
|
20
16
|
"types": "dist/types/src/index.d.ts",
|
|
21
17
|
"typesVersions": {
|
|
22
|
-
"*": {
|
|
23
|
-
"meta": [
|
|
24
|
-
"dist/types/src/meta.d.ts"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
18
|
+
"*": {}
|
|
27
19
|
},
|
|
28
20
|
"files": [
|
|
29
21
|
"dist",
|
|
@@ -35,45 +27,50 @@
|
|
|
35
27
|
"@preact/signals-core": "^1.6.0",
|
|
36
28
|
"@tldraw/tldraw": "^3.0.0",
|
|
37
29
|
"date-fns": "^3.3.1",
|
|
38
|
-
"effect": "^3.
|
|
30
|
+
"effect": "^3.12.3",
|
|
39
31
|
"lodash.get": "^4.4.2",
|
|
40
32
|
"react-json-tree": "^0.18.0",
|
|
41
33
|
"react-resize-detector": "^11.0.1",
|
|
42
34
|
"workerize-loader": "^2.0.2",
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/config": "0.7.
|
|
48
|
-
"@dxos/client-services": "0.7.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/echo-
|
|
52
|
-
"@dxos/keys": "0.7.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/plugin-
|
|
61
|
-
"@dxos/plugin-
|
|
62
|
-
"@dxos/plugin-
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/plugin-
|
|
65
|
-
"@dxos/plugin-
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/react-
|
|
73
|
-
"@dxos/react-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
35
|
+
"@dxos/async": "0.7.5-labs.a279d8c",
|
|
36
|
+
"@dxos/automerge": "0.7.5-labs.a279d8c",
|
|
37
|
+
"@dxos/compute": "0.7.5-labs.a279d8c",
|
|
38
|
+
"@dxos/conductor": "0.7.5-labs.a279d8c",
|
|
39
|
+
"@dxos/config": "0.7.5-labs.a279d8c",
|
|
40
|
+
"@dxos/client-services": "0.7.5-labs.a279d8c",
|
|
41
|
+
"@dxos/devtools": "0.7.5-labs.a279d8c",
|
|
42
|
+
"@dxos/echo-generator": "0.7.5-labs.a279d8c",
|
|
43
|
+
"@dxos/echo-pipeline": "0.7.5-labs.a279d8c",
|
|
44
|
+
"@dxos/keys": "0.7.5-labs.a279d8c",
|
|
45
|
+
"@dxos/invariant": "0.7.5-labs.a279d8c",
|
|
46
|
+
"@dxos/echo-schema": "0.7.5-labs.a279d8c",
|
|
47
|
+
"@dxos/functions": "0.7.5-labs.a279d8c",
|
|
48
|
+
"@dxos/live-object": "0.7.5-labs.a279d8c",
|
|
49
|
+
"@dxos/local-storage": "0.7.5-labs.a279d8c",
|
|
50
|
+
"@dxos/app-framework": "0.7.5-labs.a279d8c",
|
|
51
|
+
"@dxos/log": "0.7.5-labs.a279d8c",
|
|
52
|
+
"@dxos/plugin-deck": "0.7.5-labs.a279d8c",
|
|
53
|
+
"@dxos/plugin-graph": "0.7.5-labs.a279d8c",
|
|
54
|
+
"@dxos/plugin-markdown": "0.7.5-labs.a279d8c",
|
|
55
|
+
"@dxos/plugin-client": "0.7.5-labs.a279d8c",
|
|
56
|
+
"@dxos/plugin-sheet": "0.7.5-labs.a279d8c",
|
|
57
|
+
"@dxos/plugin-sketch": "0.7.5-labs.a279d8c",
|
|
58
|
+
"@dxos/plugin-space": "0.7.5-labs.a279d8c",
|
|
59
|
+
"@dxos/plugin-theme": "0.7.5-labs.a279d8c",
|
|
60
|
+
"@dxos/plugin-status-bar": "0.7.5-labs.a279d8c",
|
|
61
|
+
"@dxos/random": "0.7.5-labs.a279d8c",
|
|
62
|
+
"@dxos/plugin-table": "0.7.5-labs.a279d8c",
|
|
63
|
+
"@dxos/protocols": "0.7.5-labs.a279d8c",
|
|
64
|
+
"@dxos/react-client": "0.7.5-labs.a279d8c",
|
|
65
|
+
"@dxos/react-hooks": "0.7.5-labs.a279d8c",
|
|
66
|
+
"@dxos/react-ui-attention": "0.7.5-labs.a279d8c",
|
|
67
|
+
"@dxos/react-ui-canvas-compute": "0.7.5-labs.a279d8c",
|
|
68
|
+
"@dxos/react-ui-canvas-editor": "0.7.5-labs.a279d8c",
|
|
69
|
+
"@dxos/react-ui-form": "0.7.5-labs.a279d8c",
|
|
70
|
+
"@dxos/react-ui-table": "0.7.5-labs.a279d8c",
|
|
71
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.5-labs.a279d8c",
|
|
72
|
+
"@dxos/schema": "0.7.5-labs.a279d8c",
|
|
73
|
+
"@dxos/util": "0.7.5-labs.a279d8c"
|
|
77
74
|
},
|
|
78
75
|
"devDependencies": {
|
|
79
76
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -83,17 +80,17 @@
|
|
|
83
80
|
"react": "~18.2.0",
|
|
84
81
|
"react-dom": "~18.2.0",
|
|
85
82
|
"vite": "5.4.7",
|
|
86
|
-
"@dxos/react-ui-theme": "0.7.
|
|
87
|
-
"@dxos/react-ui": "0.7.
|
|
88
|
-
"@dxos/storybook-utils": "0.7.
|
|
83
|
+
"@dxos/react-ui-theme": "0.7.5-labs.a279d8c",
|
|
84
|
+
"@dxos/react-ui": "0.7.5-labs.a279d8c",
|
|
85
|
+
"@dxos/storybook-utils": "0.7.5-labs.a279d8c"
|
|
89
86
|
},
|
|
90
87
|
"peerDependencies": {
|
|
91
88
|
"@phosphor-icons/react": "^2.1.5",
|
|
92
89
|
"react": "~18.2.0",
|
|
93
90
|
"react-dom": "~18.2.0",
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/react-ui": "0.7.
|
|
91
|
+
"@dxos/random": "0.7.5-labs.a279d8c",
|
|
92
|
+
"@dxos/react-ui": "0.7.5-labs.a279d8c",
|
|
93
|
+
"@dxos/react-ui-theme": "0.7.5-labs.a279d8c"
|
|
97
94
|
},
|
|
98
95
|
"publishConfig": {
|
|
99
96
|
"access": "public"
|
package/src/DebugPlugin.tsx
CHANGED
|
@@ -2,389 +2,68 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
definePlugin,
|
|
9
|
-
parseGraphPlugin,
|
|
10
|
-
parseIntentPlugin,
|
|
11
|
-
parseMetadataResolverPlugin,
|
|
12
|
-
parseSettingsPlugin,
|
|
13
|
-
resolvePlugin,
|
|
14
|
-
} from '@dxos/app-framework';
|
|
15
|
-
import { Timer } from '@dxos/async';
|
|
16
|
-
import { Devtools } from '@dxos/devtools';
|
|
17
|
-
import { invariant } from '@dxos/invariant';
|
|
18
|
-
import { type ClientPluginProvides, parseClientPlugin } from '@dxos/plugin-client';
|
|
19
|
-
import { createExtension, Graph, type Node, toSignal } from '@dxos/plugin-graph';
|
|
20
|
-
import { memoizeQuery, SpaceAction } from '@dxos/plugin-space';
|
|
21
|
-
import { CollectionType } from '@dxos/plugin-space/types';
|
|
5
|
+
import { Capabilities, contributes, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
6
|
+
import { DeckCapabilities } from '@dxos/plugin-deck';
|
|
22
7
|
import { type Client } from '@dxos/react-client';
|
|
23
|
-
import {
|
|
24
|
-
create,
|
|
25
|
-
getTypename,
|
|
26
|
-
isEchoObject,
|
|
27
|
-
isSpace,
|
|
28
|
-
parseId,
|
|
29
|
-
type ReactiveObject,
|
|
30
|
-
type Space,
|
|
31
|
-
SpaceState,
|
|
32
|
-
} from '@dxos/react-client/echo';
|
|
33
|
-
import { Main } from '@dxos/react-ui';
|
|
34
|
-
import {
|
|
35
|
-
baseSurface,
|
|
36
|
-
bottombarBlockPaddingEnd,
|
|
37
|
-
fixedInsetFlexLayout,
|
|
38
|
-
topbarBlockPaddingStart,
|
|
39
|
-
} from '@dxos/react-ui-theme';
|
|
40
8
|
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
DebugObjectPanel,
|
|
44
|
-
DebugSettings,
|
|
45
|
-
DebugSpace,
|
|
46
|
-
DebugStatus,
|
|
47
|
-
SpaceGenerator,
|
|
48
|
-
Wireframe,
|
|
49
|
-
} from './components';
|
|
50
|
-
import meta, { DEBUG_PLUGIN } from './meta';
|
|
9
|
+
import { AppGraphBuilder, DebugSettings, ReactContext, ReactSurface } from './capabilities';
|
|
10
|
+
import { DEBUG_PLUGIN, meta } from './meta';
|
|
51
11
|
import translations from './translations';
|
|
52
|
-
import {
|
|
53
|
-
DebugAction,
|
|
54
|
-
DebugContext,
|
|
55
|
-
type DebugPluginProvides,
|
|
56
|
-
type DebugSettingsProps,
|
|
57
|
-
DebugSettingsSchema,
|
|
58
|
-
} from './types';
|
|
59
|
-
|
|
60
|
-
export const DebugPlugin = definePlugin<DebugPluginProvides>((context) => {
|
|
61
|
-
const settings = create<DebugSettingsProps>({
|
|
62
|
-
debug: true,
|
|
63
|
-
devtools: true,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
meta,
|
|
68
|
-
ready: async (plugins) => {
|
|
69
|
-
context.init(plugins);
|
|
70
|
-
context.resolvePlugin(parseSettingsPlugin).provides.settingsStore.createStore({
|
|
71
|
-
schema: DebugSettingsSchema,
|
|
72
|
-
prefix: DEBUG_PLUGIN,
|
|
73
|
-
value: settings,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// TODO(burdon): Remove hacky dependency on global variable.
|
|
77
|
-
// Used to test how composer handles breaking protocol changes.
|
|
78
|
-
const composer = (window as any).composer;
|
|
79
|
-
composer.changeStorageVersionInMetadata = async (version: number) => {
|
|
80
|
-
const { changeStorageVersionInMetadata } = await import('@dxos/echo-pipeline/testing');
|
|
81
|
-
const { createStorageObjects } = await import('@dxos/client-services');
|
|
82
|
-
const client: Client = (window as any).dxos.client;
|
|
83
|
-
const config = client.config;
|
|
84
|
-
await client.destroy();
|
|
85
|
-
const { storage } = createStorageObjects(config.values?.runtime?.client?.storage ?? {});
|
|
86
|
-
await changeStorageVersionInMetadata(storage, version);
|
|
87
|
-
location.pathname = '/';
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
unload: async () => {
|
|
91
|
-
context.dispose();
|
|
92
|
-
},
|
|
93
|
-
provides: {
|
|
94
|
-
settings,
|
|
95
|
-
translations,
|
|
96
|
-
complementary: {
|
|
97
|
-
panels: [{ id: 'debug', label: ['open debug panel label', { ns: DEBUG_PLUGIN }], icon: 'ph--bug--regular' }],
|
|
98
|
-
},
|
|
99
|
-
context: ({ children }) => {
|
|
100
|
-
const [timer, setTimer] = useState<Timer>();
|
|
101
|
-
useEffect(() => timer?.state.on((value) => !value && setTimer(undefined)), [timer]);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
timer?.stop();
|
|
104
|
-
}, []);
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<DebugContext.Provider
|
|
108
|
-
value={{
|
|
109
|
-
running: !!timer,
|
|
110
|
-
start: (cb, options) => {
|
|
111
|
-
timer?.stop();
|
|
112
|
-
setTimer(new Timer(cb).start(options));
|
|
113
|
-
},
|
|
114
|
-
stop: () => timer?.stop(),
|
|
115
|
-
}}
|
|
116
|
-
>
|
|
117
|
-
{children}
|
|
118
|
-
</DebugContext.Provider>
|
|
119
|
-
);
|
|
120
|
-
},
|
|
121
|
-
graph: {
|
|
122
|
-
builder: (plugins) => {
|
|
123
|
-
const clientPlugin = resolvePlugin(plugins, parseClientPlugin);
|
|
124
|
-
const metadataPlugin = resolvePlugin(plugins, parseMetadataResolverPlugin);
|
|
125
|
-
const graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
|
|
126
|
-
const resolve = metadataPlugin?.provides.metadata.resolver;
|
|
127
|
-
const client = clientPlugin?.provides.client;
|
|
128
|
-
invariant(resolve);
|
|
129
|
-
invariant(client);
|
|
130
|
-
|
|
131
|
-
return [
|
|
132
|
-
// Devtools node.
|
|
133
|
-
createExtension({
|
|
134
|
-
id: 'dxos.org/plugin/debug/devtools',
|
|
135
|
-
filter: (node): node is Node<null> => !!settings.devtools && node.id === 'root',
|
|
136
|
-
connector: () => [
|
|
137
|
-
{
|
|
138
|
-
// TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
|
|
139
|
-
id: 'dxos.org.plugin.debug.devtools',
|
|
140
|
-
data: 'devtools',
|
|
141
|
-
type: 'dxos.org/plugin/debug/devtools',
|
|
142
|
-
properties: {
|
|
143
|
-
label: ['devtools label', { ns: DEBUG_PLUGIN }],
|
|
144
|
-
icon: 'ph--hammer--regular',
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
}),
|
|
149
|
-
|
|
150
|
-
// Debug node.
|
|
151
|
-
createExtension({
|
|
152
|
-
id: 'dxos.org/plugin/debug/debug',
|
|
153
|
-
filter: (node): node is Node<null> => !!settings.debug && node.id === 'root',
|
|
154
|
-
connector: () => [
|
|
155
|
-
{
|
|
156
|
-
id: 'dxos.org/plugin/debug/debug',
|
|
157
|
-
type: 'dxos.org/plugin/debug/debug',
|
|
158
|
-
data: { graph: graphPlugin?.provides.graph },
|
|
159
|
-
properties: {
|
|
160
|
-
label: ['debug label', { ns: DEBUG_PLUGIN }],
|
|
161
|
-
icon: 'ph--bug--regular',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
}),
|
|
166
|
-
|
|
167
|
-
// Space debug nodes.
|
|
168
|
-
createExtension({
|
|
169
|
-
id: 'dxos.org/plugin/debug/spaces',
|
|
170
|
-
filter: (node): node is Node<Space> => !!settings.debug && isSpace(node.data),
|
|
171
|
-
connector: ({ node }) => {
|
|
172
|
-
const space = node.data;
|
|
173
|
-
const state = toSignal(
|
|
174
|
-
(onChange) => space.state.subscribe(() => onChange()).unsubscribe,
|
|
175
|
-
() => space.state.get(),
|
|
176
|
-
space.id,
|
|
177
|
-
);
|
|
178
|
-
if (state !== SpaceState.SPACE_READY) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Not adding the debug node until the root collection is available aligns the behaviour of this
|
|
183
|
-
// extension with that of the space plugin adding objects. This ensures that the debug node is added at
|
|
184
|
-
// the same time as objects and prevents order from changing as the nodes are added.
|
|
185
|
-
const collection = space.properties[CollectionType.typename] as CollectionType | undefined;
|
|
186
|
-
if (!collection) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return [
|
|
191
|
-
{
|
|
192
|
-
id: `${space.id}-debug`, // TODO(burdon): Change to slashes consistently.
|
|
193
|
-
type: 'dxos.org/plugin/debug/space',
|
|
194
|
-
data: { space, type: 'dxos.org/plugin/debug/space' },
|
|
195
|
-
properties: {
|
|
196
|
-
label: ['debug label', { ns: DEBUG_PLUGIN }],
|
|
197
|
-
icon: 'ph--bug--regular',
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
];
|
|
201
|
-
},
|
|
202
|
-
}),
|
|
203
|
-
|
|
204
|
-
// Create nodes for debug sidebar.
|
|
205
|
-
createExtension({
|
|
206
|
-
id: `${DEBUG_PLUGIN}/debug-for-subject`,
|
|
207
|
-
resolver: ({ id }) => {
|
|
208
|
-
// TODO(Zan): Find util (or make one).
|
|
209
|
-
if (!id.endsWith('~debug')) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const type = 'orphan-settings-for-subject';
|
|
214
|
-
const icon = 'ph--bug--regular';
|
|
215
|
-
|
|
216
|
-
const [subjectId] = id.split('~');
|
|
217
|
-
const { spaceId, objectId } = parseId(subjectId);
|
|
218
|
-
const spaces = toSignal(
|
|
219
|
-
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
220
|
-
() => client.spaces.get(),
|
|
221
|
-
);
|
|
222
|
-
const space = spaces?.find(
|
|
223
|
-
(space) => space.state.get() === SpaceState.SPACE_READY && space.id === spaceId,
|
|
224
|
-
);
|
|
225
|
-
if (!objectId) {
|
|
226
|
-
// TODO(burdon): Ref SPACE_PLUGIN ns.
|
|
227
|
-
const label = space
|
|
228
|
-
? space.properties.name || ['unnamed space label', { ns: DEBUG_PLUGIN }]
|
|
229
|
-
: ['unnamed object settings label', { ns: DEBUG_PLUGIN }];
|
|
230
|
-
|
|
231
|
-
// TODO(wittjosiah): Support comments for arbitrary subjects.
|
|
232
|
-
// This is to ensure that the comments panel is not stuck on an old object.
|
|
233
|
-
return {
|
|
234
|
-
id,
|
|
235
|
-
type,
|
|
236
|
-
data: null,
|
|
237
|
-
properties: {
|
|
238
|
-
icon,
|
|
239
|
-
label,
|
|
240
|
-
showResolvedThreads: false,
|
|
241
|
-
object: null,
|
|
242
|
-
space,
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const [object] = memoizeQuery(space, { id: objectId });
|
|
248
|
-
if (!object || !subjectId) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const meta = resolve(getTypename(object) ?? '');
|
|
253
|
-
const label = meta.label?.(object) ||
|
|
254
|
-
object.name ||
|
|
255
|
-
meta.placeholder || ['unnamed object settings label', { ns: DEBUG_PLUGIN }];
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
id,
|
|
259
|
-
type,
|
|
260
|
-
data: null,
|
|
261
|
-
properties: {
|
|
262
|
-
icon,
|
|
263
|
-
label,
|
|
264
|
-
object,
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
}),
|
|
269
|
-
];
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
intent: {
|
|
273
|
-
resolver: async (intent, plugins) => {
|
|
274
|
-
switch (intent.action) {
|
|
275
|
-
case DebugAction.OPEN_DEVTOOLS: {
|
|
276
|
-
const clientPlugin = context.getPlugin<ClientPluginProvides>('dxos.org/plugin/client');
|
|
277
|
-
const client = clientPlugin.provides.client;
|
|
278
|
-
const vaultUrl = client.config.values?.runtime?.client?.remoteSource ?? 'https://halo.dxos.org';
|
|
279
|
-
|
|
280
|
-
// Check if we're serving devtools locally on the usual port.
|
|
281
|
-
let devtoolsUrl = 'http://localhost:5174';
|
|
282
|
-
try {
|
|
283
|
-
// TODO(burdon): Test header to see if this is actually devtools.
|
|
284
|
-
await fetch(devtoolsUrl);
|
|
285
|
-
} catch {
|
|
286
|
-
// Match devtools to running app.
|
|
287
|
-
const isDev = window.location.href.includes('.dev.') || window.location.href.includes('localhost');
|
|
288
|
-
devtoolsUrl = `https://devtools${isDev ? '.dev.' : '.'}dxos.org`;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
window.open(`${devtoolsUrl}?target=${vaultUrl}`, '_blank');
|
|
292
|
-
return { data: true };
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
surface: {
|
|
298
|
-
component: ({ name, data, role }) => {
|
|
299
|
-
switch (role) {
|
|
300
|
-
case 'settings':
|
|
301
|
-
return data.plugin === meta.id ? <DebugSettings settings={settings} /> : null;
|
|
302
|
-
case 'status':
|
|
303
|
-
return <DebugStatus />;
|
|
304
|
-
case 'complementary--debug':
|
|
305
|
-
return isEchoObject(data.subject) ? <DebugObjectPanel object={data.subject} /> : null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const primary = data.active ?? data.object;
|
|
309
|
-
let component: ReactNode = null;
|
|
310
|
-
if (role === 'main' || role === 'article') {
|
|
311
|
-
if (primary === 'devtools' && settings.devtools) {
|
|
312
|
-
component = <Devtools />;
|
|
313
|
-
} else if (!primary || typeof primary !== 'object' || !settings.debug) {
|
|
314
|
-
component = null;
|
|
315
|
-
} else if (
|
|
316
|
-
'type' in primary &&
|
|
317
|
-
primary.type === 'dxos.org/plugin/debug/space' &&
|
|
318
|
-
'space' in primary &&
|
|
319
|
-
isSpace(primary.space)
|
|
320
|
-
) {
|
|
321
|
-
const handleCreateObject = (objects: ReactiveObject<any>[]) => {
|
|
322
|
-
if (!isSpace(primary.space)) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const collection =
|
|
327
|
-
primary.space.state.get() === SpaceState.SPACE_READY &&
|
|
328
|
-
primary.space.properties[CollectionType.typename];
|
|
329
|
-
if (!(collection instanceof CollectionType)) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
void context.resolvePlugin(parseIntentPlugin).provides.intent.dispatch(
|
|
334
|
-
objects.map((object) => ({
|
|
335
|
-
action: SpaceAction.ADD_OBJECT,
|
|
336
|
-
data: { target: collection, object },
|
|
337
|
-
})),
|
|
338
|
-
);
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const deprecated = false;
|
|
342
|
-
component = deprecated ? (
|
|
343
|
-
<DebugSpace space={primary.space} onAddObjects={handleCreateObject} />
|
|
344
|
-
) : (
|
|
345
|
-
<SpaceGenerator space={primary.space} onCreateObjects={handleCreateObject} />
|
|
346
|
-
);
|
|
347
|
-
} else if ('graph' in primary && primary.graph instanceof Graph) {
|
|
348
|
-
component = <DebugApp graph={primary.graph} />;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
if (!component) {
|
|
353
|
-
if (settings.wireframe) {
|
|
354
|
-
if (role === 'main' || role === 'article' || role === 'section') {
|
|
355
|
-
const primary = data.active ?? data.object;
|
|
356
|
-
const isCollection = primary instanceof CollectionType;
|
|
357
|
-
// TODO(burdon): Move into Container abstraction.
|
|
358
|
-
if (!isCollection) {
|
|
359
|
-
return {
|
|
360
|
-
node: (
|
|
361
|
-
<Wireframe label={`${role}:${name}`} object={primary} classNames='row-span-2 overflow-hidden' />
|
|
362
|
-
),
|
|
363
|
-
disposition: 'hoist',
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
switch (role) {
|
|
373
|
-
case 'article':
|
|
374
|
-
return <>{component}</>;
|
|
375
|
-
case 'main':
|
|
376
|
-
return (
|
|
377
|
-
<Main.Content
|
|
378
|
-
classNames={[baseSurface, fixedInsetFlexLayout, topbarBlockPaddingStart, bottombarBlockPaddingEnd]}
|
|
379
|
-
>
|
|
380
|
-
{component}
|
|
381
|
-
</Main.Content>
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
12
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
13
|
+
export const DebugPlugin = () => {
|
|
14
|
+
setupDevtools();
|
|
15
|
+
|
|
16
|
+
return definePlugin(meta, [
|
|
17
|
+
defineModule({
|
|
18
|
+
id: `${meta.id}/module/settings`,
|
|
19
|
+
activatesOn: Events.SetupSettings,
|
|
20
|
+
activate: DebugSettings,
|
|
21
|
+
}),
|
|
22
|
+
defineModule({
|
|
23
|
+
id: `${meta.id}/module/translations`,
|
|
24
|
+
activatesOn: Events.SetupTranslations,
|
|
25
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
26
|
+
}),
|
|
27
|
+
defineModule({
|
|
28
|
+
id: `${meta.id}/module/complementary-panel`,
|
|
29
|
+
activatesOn: Events.Startup,
|
|
30
|
+
activate: () =>
|
|
31
|
+
contributes(DeckCapabilities.ComplementaryPanel, {
|
|
32
|
+
id: 'debug',
|
|
33
|
+
label: ['debug label', { ns: DEBUG_PLUGIN }],
|
|
34
|
+
icon: 'ph--bug--regular',
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
defineModule({
|
|
38
|
+
id: `${meta.id}/module/react-context`,
|
|
39
|
+
activatesOn: Events.Startup,
|
|
40
|
+
activate: ReactContext,
|
|
41
|
+
}),
|
|
42
|
+
defineModule({
|
|
43
|
+
id: `${meta.id}/module/react-surface`,
|
|
44
|
+
activatesOn: Events.Startup,
|
|
45
|
+
activate: ReactSurface,
|
|
46
|
+
}),
|
|
47
|
+
defineModule({
|
|
48
|
+
id: `${meta.id}/module/app-graph-builder`,
|
|
49
|
+
activatesOn: Events.SetupAppGraph,
|
|
50
|
+
activate: AppGraphBuilder,
|
|
51
|
+
}),
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const setupDevtools = () => {
|
|
56
|
+
(globalThis as any).composer ??= {};
|
|
57
|
+
|
|
58
|
+
// Used to test how composer handles breaking protocol changes.
|
|
59
|
+
(globalThis as any).composer.changeStorageVersionInMetadata = async (version: number) => {
|
|
60
|
+
const { changeStorageVersionInMetadata } = await import('@dxos/echo-pipeline/testing');
|
|
61
|
+
const { createStorageObjects } = await import('@dxos/client-services');
|
|
62
|
+
const client: Client = (window as any).dxos.client;
|
|
63
|
+
const config = client.config;
|
|
64
|
+
await client.destroy();
|
|
65
|
+
const { storage } = createStorageObjects(config.values?.runtime?.client?.storage ?? {});
|
|
66
|
+
await changeStorageVersionInMetadata(storage, version);
|
|
67
|
+
location.pathname = '/';
|
|
389
68
|
};
|
|
390
|
-
}
|
|
69
|
+
};
|