@dxos/plugin-debug 0.7.4 → 0.7.5-main.9cb18ac
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/{DebugSpace-DHKEAMIC.mjs → DebugSpace-V3K3PQP6.mjs} +2 -3
- package/dist/lib/browser/{DebugSpace-DHKEAMIC.mjs.map → DebugSpace-V3K3PQP6.mjs.map} +1 -1
- package/dist/lib/browser/{SpaceGenerator-BQ3645OS.mjs → SpaceGenerator-Y2NXBQVR.mjs} +18 -14
- package/dist/lib/browser/SpaceGenerator-Y2NXBQVR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LZEK532R.mjs → chunk-6CGQHKET.mjs} +1 -11
- package/dist/lib/browser/chunk-6CGQHKET.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +86 -111
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/DebugPlugin.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/SpaceGenerator/ObjectGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.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/types.d.ts +2 -5
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +43 -42
- package/src/DebugPlugin.tsx +92 -126
- package/src/components/DebugSpace/DebugSpace.stories.tsx +4 -3
- package/src/components/DebugSpace/ObjectCreator.stories.tsx +4 -3
- package/src/components/DebugSurface.tsx +2 -2
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +13 -13
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +2 -2
- package/src/components/SpaceGenerator/draw-util.ts +7 -6
- package/src/components/Wireframe.tsx +2 -2
- package/src/types.ts +0 -9
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZEK532R.mjs.map +0 -7
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-main.9cb18ac",
|
|
4
4
|
"description": "DXOS Surface plugin for testing.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -35,45 +35,46 @@
|
|
|
35
35
|
"@preact/signals-core": "^1.6.0",
|
|
36
36
|
"@tldraw/tldraw": "^3.0.0",
|
|
37
37
|
"date-fns": "^3.3.1",
|
|
38
|
-
"effect": "^3.
|
|
38
|
+
"effect": "^3.12.1",
|
|
39
39
|
"lodash.get": "^4.4.2",
|
|
40
40
|
"react-json-tree": "^0.18.0",
|
|
41
41
|
"react-resize-detector": "^11.0.1",
|
|
42
42
|
"workerize-loader": "^2.0.2",
|
|
43
|
-
"@dxos/app-framework": "0.7.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/echo-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/local-storage": "0.7.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/plugin-
|
|
59
|
-
"@dxos/plugin-
|
|
60
|
-
"@dxos/plugin-
|
|
61
|
-
"@dxos/plugin-
|
|
62
|
-
"@dxos/plugin-
|
|
63
|
-
"@dxos/plugin-space": "0.7.
|
|
64
|
-
"@dxos/plugin-
|
|
65
|
-
"@dxos/plugin-
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/random": "0.7.
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-
|
|
71
|
-
"@dxos/react-hooks": "0.7.
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/react-ui-
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
43
|
+
"@dxos/app-framework": "0.7.5-main.9cb18ac",
|
|
44
|
+
"@dxos/automerge": "0.7.5-main.9cb18ac",
|
|
45
|
+
"@dxos/async": "0.7.5-main.9cb18ac",
|
|
46
|
+
"@dxos/client-services": "0.7.5-main.9cb18ac",
|
|
47
|
+
"@dxos/compute": "0.7.5-main.9cb18ac",
|
|
48
|
+
"@dxos/config": "0.7.5-main.9cb18ac",
|
|
49
|
+
"@dxos/devtools": "0.7.5-main.9cb18ac",
|
|
50
|
+
"@dxos/echo-generator": "0.7.5-main.9cb18ac",
|
|
51
|
+
"@dxos/echo-pipeline": "0.7.5-main.9cb18ac",
|
|
52
|
+
"@dxos/echo-schema": "0.7.5-main.9cb18ac",
|
|
53
|
+
"@dxos/invariant": "0.7.5-main.9cb18ac",
|
|
54
|
+
"@dxos/keys": "0.7.5-main.9cb18ac",
|
|
55
|
+
"@dxos/live-object": "0.7.5-main.9cb18ac",
|
|
56
|
+
"@dxos/local-storage": "0.7.5-main.9cb18ac",
|
|
57
|
+
"@dxos/log": "0.7.5-main.9cb18ac",
|
|
58
|
+
"@dxos/plugin-deck": "0.7.5-main.9cb18ac",
|
|
59
|
+
"@dxos/plugin-markdown": "0.7.5-main.9cb18ac",
|
|
60
|
+
"@dxos/plugin-client": "0.7.5-main.9cb18ac",
|
|
61
|
+
"@dxos/plugin-graph": "0.7.5-main.9cb18ac",
|
|
62
|
+
"@dxos/plugin-sketch": "0.7.5-main.9cb18ac",
|
|
63
|
+
"@dxos/plugin-space": "0.7.5-main.9cb18ac",
|
|
64
|
+
"@dxos/plugin-sheet": "0.7.5-main.9cb18ac",
|
|
65
|
+
"@dxos/plugin-status-bar": "0.7.5-main.9cb18ac",
|
|
66
|
+
"@dxos/plugin-theme": "0.7.5-main.9cb18ac",
|
|
67
|
+
"@dxos/random": "0.7.5-main.9cb18ac",
|
|
68
|
+
"@dxos/plugin-table": "0.7.5-main.9cb18ac",
|
|
69
|
+
"@dxos/protocols": "0.7.5-main.9cb18ac",
|
|
70
|
+
"@dxos/react-client": "0.7.5-main.9cb18ac",
|
|
71
|
+
"@dxos/react-hooks": "0.7.5-main.9cb18ac",
|
|
72
|
+
"@dxos/react-ui-attention": "0.7.5-main.9cb18ac",
|
|
73
|
+
"@dxos/react-ui-form": "0.7.5-main.9cb18ac",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.7.5-main.9cb18ac",
|
|
75
|
+
"@dxos/react-ui-table": "0.7.5-main.9cb18ac",
|
|
76
|
+
"@dxos/schema": "0.7.5-main.9cb18ac",
|
|
77
|
+
"@dxos/util": "0.7.5-main.9cb18ac"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
80
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -83,17 +84,17 @@
|
|
|
83
84
|
"react": "~18.2.0",
|
|
84
85
|
"react-dom": "~18.2.0",
|
|
85
86
|
"vite": "5.4.7",
|
|
86
|
-
"@dxos/react-ui
|
|
87
|
-
"@dxos/react-ui": "0.7.
|
|
88
|
-
"@dxos/storybook-utils": "0.7.
|
|
87
|
+
"@dxos/react-ui": "0.7.5-main.9cb18ac",
|
|
88
|
+
"@dxos/react-ui-theme": "0.7.5-main.9cb18ac",
|
|
89
|
+
"@dxos/storybook-utils": "0.7.5-main.9cb18ac"
|
|
89
90
|
},
|
|
90
91
|
"peerDependencies": {
|
|
91
92
|
"@phosphor-icons/react": "^2.1.5",
|
|
92
93
|
"react": "~18.2.0",
|
|
93
94
|
"react-dom": "~18.2.0",
|
|
94
|
-
"@dxos/
|
|
95
|
-
"@dxos/
|
|
96
|
-
"@dxos/react-ui": "0.7.
|
|
95
|
+
"@dxos/random": "0.7.5-main.9cb18ac",
|
|
96
|
+
"@dxos/react-ui-theme": "0.7.5-main.9cb18ac",
|
|
97
|
+
"@dxos/react-ui": "0.7.5-main.9cb18ac"
|
|
97
98
|
},
|
|
98
99
|
"publishConfig": {
|
|
99
100
|
"access": "public"
|
package/src/DebugPlugin.tsx
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
createIntent,
|
|
9
|
+
createSurface,
|
|
8
10
|
definePlugin,
|
|
9
11
|
parseGraphPlugin,
|
|
10
12
|
parseIntentPlugin,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
import { Timer } from '@dxos/async';
|
|
16
18
|
import { Devtools } from '@dxos/devtools';
|
|
17
19
|
import { invariant } from '@dxos/invariant';
|
|
18
|
-
import {
|
|
20
|
+
import { parseClientPlugin } from '@dxos/plugin-client/types';
|
|
19
21
|
import { createExtension, Graph, type Node, toSignal } from '@dxos/plugin-graph';
|
|
20
22
|
import { memoizeQuery, SpaceAction } from '@dxos/plugin-space';
|
|
21
23
|
import { CollectionType } from '@dxos/plugin-space/types';
|
|
@@ -26,17 +28,11 @@ import {
|
|
|
26
28
|
isEchoObject,
|
|
27
29
|
isSpace,
|
|
28
30
|
parseId,
|
|
31
|
+
type ReactiveEchoObject,
|
|
29
32
|
type ReactiveObject,
|
|
30
33
|
type Space,
|
|
31
34
|
SpaceState,
|
|
32
35
|
} 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
36
|
|
|
41
37
|
import {
|
|
42
38
|
DebugApp,
|
|
@@ -49,13 +45,19 @@ import {
|
|
|
49
45
|
} from './components';
|
|
50
46
|
import meta, { DEBUG_PLUGIN } from './meta';
|
|
51
47
|
import translations from './translations';
|
|
52
|
-
import {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
import { DebugContext, type DebugPluginProvides, type DebugSettingsProps, DebugSettingsSchema } from './types';
|
|
49
|
+
|
|
50
|
+
type SpaceDebug = {
|
|
51
|
+
type: string;
|
|
52
|
+
space: Space;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type GraphDebug = {
|
|
56
|
+
graph: Graph;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const isSpaceDebug = (data: any): data is SpaceDebug => data.type === `${DEBUG_PLUGIN}/space` && isSpace(data.space);
|
|
60
|
+
const isGraphDebug = (data: any): data is GraphDebug => data.graph instanceof Graph;
|
|
59
61
|
|
|
60
62
|
export const DebugPlugin = definePlugin<DebugPluginProvides>((context) => {
|
|
61
63
|
const settings = create<DebugSettingsProps>({
|
|
@@ -65,7 +67,7 @@ export const DebugPlugin = definePlugin<DebugPluginProvides>((context) => {
|
|
|
65
67
|
|
|
66
68
|
return {
|
|
67
69
|
meta,
|
|
68
|
-
ready: async (plugins) => {
|
|
70
|
+
ready: async ({ plugins }) => {
|
|
69
71
|
context.init(plugins);
|
|
70
72
|
context.resolvePlugin(parseSettingsPlugin).provides.settingsStore.createStore({
|
|
71
73
|
schema: DebugSettingsSchema,
|
|
@@ -182,7 +184,7 @@ export const DebugPlugin = definePlugin<DebugPluginProvides>((context) => {
|
|
|
182
184
|
// Not adding the debug node until the root collection is available aligns the behaviour of this
|
|
183
185
|
// extension with that of the space plugin adding objects. This ensures that the debug node is added at
|
|
184
186
|
// 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;
|
|
187
|
+
const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;
|
|
186
188
|
if (!collection) {
|
|
187
189
|
return;
|
|
188
190
|
}
|
|
@@ -269,121 +271,85 @@ export const DebugPlugin = definePlugin<DebugPluginProvides>((context) => {
|
|
|
269
271
|
];
|
|
270
272
|
},
|
|
271
273
|
},
|
|
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
274
|
surface: {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
)
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
275
|
+
definitions: () => [
|
|
276
|
+
createSurface({
|
|
277
|
+
id: `${DEBUG_PLUGIN}/settings`,
|
|
278
|
+
role: 'settings',
|
|
279
|
+
filter: (data): data is any => data.subject === DEBUG_PLUGIN,
|
|
280
|
+
component: () => <DebugSettings settings={settings} />,
|
|
281
|
+
}),
|
|
282
|
+
createSurface({
|
|
283
|
+
id: `${DEBUG_PLUGIN}/status`,
|
|
284
|
+
role: 'status',
|
|
285
|
+
component: () => <DebugStatus />,
|
|
286
|
+
}),
|
|
287
|
+
createSurface({
|
|
288
|
+
id: `${DEBUG_PLUGIN}/complementary`,
|
|
289
|
+
role: 'complementary--debug',
|
|
290
|
+
filter: (data): data is { subject: ReactiveEchoObject<any> } => isEchoObject(data.subject),
|
|
291
|
+
component: ({ data }) => <DebugObjectPanel object={data.subject} />,
|
|
292
|
+
}),
|
|
293
|
+
createSurface({
|
|
294
|
+
id: `${DEBUG_PLUGIN}/devtools`,
|
|
295
|
+
role: 'article',
|
|
296
|
+
filter: (data): data is any => data.subject === 'devtools' && !!settings.devtools,
|
|
297
|
+
component: () => <Devtools />,
|
|
298
|
+
}),
|
|
299
|
+
createSurface({
|
|
300
|
+
id: `${DEBUG_PLUGIN}/space`,
|
|
301
|
+
role: 'article',
|
|
302
|
+
filter: (data): data is { subject: SpaceDebug } => isSpaceDebug(data.subject),
|
|
303
|
+
component: ({ data }) => {
|
|
304
|
+
const handleCreateObject = useCallback(
|
|
305
|
+
(objects: ReactiveObject<any>[]) => {
|
|
306
|
+
if (!isSpace(data.subject.space)) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
325
309
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
310
|
+
const collection =
|
|
311
|
+
data.subject.space.state.get() === SpaceState.SPACE_READY &&
|
|
312
|
+
data.subject.space.properties[CollectionType.typename]?.target;
|
|
313
|
+
if (!(collection instanceof CollectionType)) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
332
316
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
317
|
+
objects.forEach((object) => {
|
|
318
|
+
void context
|
|
319
|
+
.resolvePlugin(parseIntentPlugin)
|
|
320
|
+
.provides.intent.dispatchPromise(
|
|
321
|
+
createIntent(SpaceAction.AddObject, { target: collection, object }),
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
[data.subject.space],
|
|
326
|
+
);
|
|
340
327
|
|
|
341
328
|
const deprecated = false;
|
|
342
|
-
|
|
343
|
-
<DebugSpace space={
|
|
329
|
+
return deprecated ? (
|
|
330
|
+
<DebugSpace space={data.subject.space} onAddObjects={handleCreateObject} />
|
|
344
331
|
) : (
|
|
345
|
-
<SpaceGenerator space={
|
|
332
|
+
<SpaceGenerator space={data.subject.space} onCreateObjects={handleCreateObject} />
|
|
346
333
|
);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
385
|
-
return null;
|
|
386
|
-
},
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
createSurface({
|
|
337
|
+
id: `${DEBUG_PLUGIN}/graph`,
|
|
338
|
+
role: 'article',
|
|
339
|
+
filter: (data): data is { subject: GraphDebug } => isGraphDebug(data.subject),
|
|
340
|
+
component: ({ data }) => <DebugApp graph={data.subject.graph} />,
|
|
341
|
+
}),
|
|
342
|
+
createSurface({
|
|
343
|
+
id: `${DEBUG_PLUGIN}/wireframe`,
|
|
344
|
+
role: ['article', 'section'],
|
|
345
|
+
disposition: 'hoist',
|
|
346
|
+
filter: (data): data is { subject: ReactiveEchoObject<any> } =>
|
|
347
|
+
isEchoObject(data.subject) && !!settings.wireframe,
|
|
348
|
+
component: ({ data, role }) => (
|
|
349
|
+
<Wireframe label={`${role}:${name}`} object={data.subject} classNames='row-span-2 overflow-hidden' />
|
|
350
|
+
),
|
|
351
|
+
}),
|
|
352
|
+
],
|
|
387
353
|
},
|
|
388
354
|
},
|
|
389
355
|
};
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -37,9 +37,9 @@ export const DebugSurface = ({ classNames }: SurfaceDebugProps) => {
|
|
|
37
37
|
return (
|
|
38
38
|
<div className={mx('flex flex-col border border-separator overflow-hidden bg-modalSurface', classNames)}>
|
|
39
39
|
<div className='flex flex-col h-full w-full p-2'>
|
|
40
|
-
{surfaces.map(({ id,
|
|
40
|
+
{surfaces.map(({ id, role, renderCount }) => (
|
|
41
41
|
<div key={id} className='grid grid-cols-[1fr_3rem_3rem] items-center text-xs font-mono whitespace-nowrap'>
|
|
42
|
-
<span className='px-1 truncate'>{
|
|
42
|
+
<span className='px-1 truncate'>{role}</span>
|
|
43
43
|
<span className='px-1 text-right'>{renderCount}</span>
|
|
44
44
|
<span className='px-1 text-right'>{renderMap.get(id)?.delta}</span>
|
|
45
45
|
</div>
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { addressToA1Notation } from '@dxos/compute';
|
|
6
|
+
import { type BaseObject, type TypedObject } from '@dxos/echo-schema';
|
|
7
|
+
import { create, makeRef, type ReactiveObject } from '@dxos/live-object';
|
|
7
8
|
import { DocumentType, TextType } from '@dxos/plugin-markdown/types';
|
|
8
|
-
import {
|
|
9
|
-
import { type CellValue } from '@dxos/plugin-sheet/types';
|
|
10
|
-
import { SheetType } from '@dxos/plugin-sheet/types';
|
|
9
|
+
import { createSheet } from '@dxos/plugin-sheet';
|
|
10
|
+
import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
|
|
11
11
|
import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
13
|
import { Filter, type Space } from '@dxos/react-client/echo';
|
|
@@ -40,7 +40,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
40
40
|
const obj = space.db.add(
|
|
41
41
|
create(DocumentType, {
|
|
42
42
|
name: faker.commerce.productName(),
|
|
43
|
-
content: create(TextType, { content: faker.lorem.sentences(5) }),
|
|
43
|
+
content: makeRef(create(TextType, { content: faker.lorem.sentences(5) })),
|
|
44
44
|
threads: [],
|
|
45
45
|
}),
|
|
46
46
|
);
|
|
@@ -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
|
|
|
@@ -111,28 +111,28 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
111
111
|
],
|
|
112
112
|
]);
|
|
113
113
|
|
|
114
|
-
export const createGenerator = <T extends BaseObject>(type:
|
|
114
|
+
export const createGenerator = <T extends BaseObject>(type: TypedObject<T>): ObjectGenerator<T> => {
|
|
115
115
|
return async (
|
|
116
116
|
space: Space,
|
|
117
117
|
n: number,
|
|
118
118
|
cb?: (objects: ReactiveObject<any>[]) => void,
|
|
119
119
|
): Promise<ReactiveObject<T>[]> => {
|
|
120
120
|
// Find or create mutable schema.
|
|
121
|
-
const mutableSchema = await space.db.schemaRegistry.query();
|
|
122
121
|
const schema =
|
|
123
|
-
|
|
122
|
+
(await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??
|
|
123
|
+
(await space.db.schemaRegistry.register([type]))[0];
|
|
124
124
|
|
|
125
125
|
// Create objects.
|
|
126
|
-
const generate = createAsyncGenerator(generator, schema.
|
|
126
|
+
const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { db: space.db });
|
|
127
127
|
const objects = await generate.createObjects(n);
|
|
128
128
|
|
|
129
129
|
// Find or create table and view.
|
|
130
130
|
const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
|
|
131
|
-
const table = tables.find((table) => table.view?.query?.type === type.typename);
|
|
131
|
+
const table = tables.find((table) => table.view?.target?.query?.type === type.typename);
|
|
132
132
|
if (!table) {
|
|
133
133
|
const name = type.typename.split('/').pop() ?? type.typename;
|
|
134
134
|
const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });
|
|
135
|
-
const table = space.db.add(create(TableType, { name, view }));
|
|
135
|
+
const table = space.db.add(create(TableType, { name, view: makeRef(view) }));
|
|
136
136
|
cb?.([table]);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -43,7 +43,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
43
43
|
// Query space to get info.
|
|
44
44
|
const updateInfo = async () => {
|
|
45
45
|
// Create schema map.
|
|
46
|
-
const
|
|
46
|
+
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
47
47
|
const staticSchema = space.db.graph.schemaRegistry.schemas;
|
|
48
48
|
|
|
49
49
|
// Create object map.
|
|
@@ -62,7 +62,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
62
62
|
setInfo({
|
|
63
63
|
schema: {
|
|
64
64
|
static: staticSchema.length,
|
|
65
|
-
mutable:
|
|
65
|
+
mutable: echoSchema.length,
|
|
66
66
|
},
|
|
67
67
|
objects: objectMap,
|
|
68
68
|
});
|
|
@@ -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
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useResizeDetector } from 'react-resize-detector';
|
|
7
7
|
|
|
8
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
8
|
+
import { fullyQualifiedId, type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
9
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { useAttendableAttributes } from '@dxos/react-ui-attention';
|
|
11
11
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
@@ -14,7 +14,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
14
14
|
// TODO(burdon): Create generic container with wireframe mode.
|
|
15
15
|
export type WireframeProps = ThemedClassName<{
|
|
16
16
|
label?: string;
|
|
17
|
-
object
|
|
17
|
+
object: ReactiveEchoObject<any>;
|
|
18
18
|
}>;
|
|
19
19
|
|
|
20
20
|
// TODO(burdon): Make focusable and attendable with input.
|
package/src/types.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { type Context, createContext } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
8
|
GraphBuilderProvides,
|
|
9
|
-
IntentResolverProvides,
|
|
10
9
|
SettingsProvides,
|
|
11
10
|
SurfaceProvides,
|
|
12
11
|
TranslationsProvides,
|
|
@@ -15,13 +14,6 @@ import type { TimerCallback, TimerOptions } from '@dxos/async';
|
|
|
15
14
|
import { S } from '@dxos/echo-schema';
|
|
16
15
|
import { type PanelProvides } from '@dxos/plugin-deck/types';
|
|
17
16
|
|
|
18
|
-
import { DEBUG_PLUGIN } from './meta';
|
|
19
|
-
|
|
20
|
-
const DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;
|
|
21
|
-
export enum DebugAction {
|
|
22
|
-
OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
export type DebugContextType = {
|
|
26
18
|
running: boolean;
|
|
27
19
|
start: (cb: TimerCallback, options: TimerOptions) => void;
|
|
@@ -45,7 +37,6 @@ export const DebugSettingsSchema = S.mutable(
|
|
|
45
37
|
export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
|
|
46
38
|
|
|
47
39
|
export type DebugPluginProvides = SurfaceProvides &
|
|
48
|
-
IntentResolverProvides &
|
|
49
40
|
GraphBuilderProvides &
|
|
50
41
|
SettingsProvides<DebugSettingsProps> &
|
|
51
42
|
TranslationsProvides &
|