@dxos/plugin-debug 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/DebugGraph-6VMEOKEV.mjs +15 -0
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs +19 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs.map +7 -0
- package/dist/lib/browser/{SpaceGenerator-7Q7CX64P.mjs → SpaceGenerator-H33AEFGC.mjs} +226 -233
- package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs +598 -0
- package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-4UFQXPP7.mjs} +11 -1
- package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WZFZ4ESO.mjs → chunk-A5H5GRV6.mjs} +1 -1
- package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +34 -39
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-FSWBT3MH.mjs +17 -0
- package/dist/lib/browser/react-context-FSWBT3MH.mjs.map +7 -0
- package/dist/lib/browser/react-surface-2N6CPSHR.mjs +757 -0
- package/dist/lib/browser/react-surface-2N6CPSHR.mjs.map +7 -0
- package/dist/lib/browser/settings-KA4GN73K.mjs +31 -0
- package/dist/lib/browser/settings-KA4GN73K.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +2 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
- package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +3 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +5 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/components/DebugGraph.d.ts +5 -4
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts +4 -2
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts +2 -2
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -4
- package/dist/types/src/components/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/translations.d.ts +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +76 -70
- package/src/DebugPlugin.tsx +16 -31
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +420 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +4 -6
- package/src/capabilities/react-context/index.ts +7 -0
- package/src/capabilities/react-context/react-context.tsx +20 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +409 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +30 -0
- package/src/components/DebugGraph.tsx +4 -3
- package/src/components/DebugObjectPanel.tsx +4 -4
- package/src/components/DebugSettings.tsx +44 -18
- package/src/components/DevtoolsOverviewContainer.tsx +1 -1
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +18 -19
- package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +7 -5
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +18 -13
- package/src/components/SpaceGenerator/presets.ts +217 -100
- package/src/components/Wireframe.tsx +4 -5
- package/src/components/index.ts +4 -1
- package/src/meta.ts +2 -2
- package/src/translations.ts +1 -1
- package/src/types.ts +8 -0
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-7Q7CX64P.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs +0 -588
- package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs.map +0 -7
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +0 -7
- package/dist/lib/browser/react-context-P2YDWEWI.mjs +0 -16
- package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4XGZUT3Z.mjs +0 -772
- package/dist/lib/browser/react-surface-4XGZUT3Z.mjs.map +0 -7
- package/dist/lib/browser/settings-SQXR3OAH.mjs +0 -22
- package/dist/lib/browser/settings-SQXR3OAH.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context.d.ts +0 -8
- package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -431
- package/src/capabilities/react-context.tsx +0 -16
- package/src/capabilities/react-surface.tsx +0 -399
- package/src/capabilities/settings.ts +0 -19
|
@@ -2,46 +2,47 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
6
7
|
import { addressToA1Notation } from '@dxos/compute';
|
|
7
8
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Filter, Key, type
|
|
9
|
-
import { type
|
|
9
|
+
import { DXN, Filter, Key, type Type } from '@dxos/echo';
|
|
10
|
+
import { type OperationInvoker } from '@dxos/operation';
|
|
10
11
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
12
|
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
13
|
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
13
|
-
import {
|
|
14
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
15
|
import { faker } from '@dxos/random';
|
|
15
16
|
import { type Client } from '@dxos/react-client';
|
|
16
17
|
import { type Space } from '@dxos/react-client/echo';
|
|
17
|
-
import {
|
|
18
|
+
import { View, getTypenameFromQuery } from '@dxos/schema';
|
|
18
19
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
19
20
|
import { range } from '@dxos/util';
|
|
20
21
|
|
|
21
22
|
const generator: ValueGenerator = faker as any;
|
|
22
23
|
|
|
23
|
-
const findViewByTypename = async (views:
|
|
24
|
+
const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
24
25
|
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
export type ObjectGenerator<T
|
|
28
|
+
export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
28
29
|
|
|
29
|
-
export const createGenerator = <
|
|
30
|
+
export const createGenerator = <S extends Type.Obj.Any>(
|
|
30
31
|
client: Client,
|
|
31
|
-
|
|
32
|
-
schema:
|
|
33
|
-
): ObjectGenerator<
|
|
34
|
-
return async (space: Space, n: number): Promise<
|
|
32
|
+
invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
|
|
33
|
+
schema: S,
|
|
34
|
+
): ObjectGenerator<Schema.Schema.Type<S>> => {
|
|
35
|
+
return async (space: Space, n: number): Promise<Schema.Schema.Type<S>[]> => {
|
|
35
36
|
const typename = schema.typename;
|
|
36
37
|
|
|
37
38
|
// Find or create table and view.
|
|
38
|
-
const
|
|
39
|
+
const views = await space.db.query(Filter.type(View.View)).run();
|
|
39
40
|
const view = await findViewByTypename(views, typename);
|
|
40
|
-
const staticSchema = client?.graph.schemaRegistry.
|
|
41
|
+
const staticSchema = client?.graph.schemaRegistry.query({ typename }).runSync()[0];
|
|
41
42
|
if (!view && !staticSchema) {
|
|
42
|
-
await
|
|
43
|
+
await invokePromise(SpaceOperation.AddSchema, { db: space.db, schema, show: false });
|
|
43
44
|
} else if (!view && staticSchema) {
|
|
44
|
-
await
|
|
45
|
+
await invokePromise(SpaceOperation.UseStaticSchema, { db: space.db, typename, show: false });
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
// Create objects.
|
|
@@ -56,7 +57,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
56
57
|
async (space, n, cb) => {
|
|
57
58
|
const objects = range(n).map(() => {
|
|
58
59
|
return space.db.add(
|
|
59
|
-
Markdown.
|
|
60
|
+
Markdown.make({
|
|
60
61
|
name: faker.commerce.productName(),
|
|
61
62
|
content: faker.lorem.sentences(5),
|
|
62
63
|
}),
|
|
@@ -71,9 +72,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
71
72
|
Diagram.Diagram.typename,
|
|
72
73
|
async (space, n, cb) => {
|
|
73
74
|
const objects = range(n).map(() => {
|
|
74
|
-
// TODO(burdon): Generate diagram.
|
|
75
75
|
const obj = space.db.add(Diagram.make({ name: faker.commerce.productName() }));
|
|
76
|
-
|
|
77
76
|
return obj;
|
|
78
77
|
});
|
|
79
78
|
|
|
@@ -19,8 +19,8 @@ export const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTable
|
|
|
19
19
|
<h2 className='p-2'>{label}</h2>
|
|
20
20
|
{types.map((type) => (
|
|
21
21
|
<div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>
|
|
22
|
-
<div className='
|
|
23
|
-
<div className='
|
|
22
|
+
<div className='pli-2 text-sm font-mono text-subdued'>{type.typename}</div>
|
|
23
|
+
<div className='pli-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>
|
|
24
24
|
<IconButton
|
|
25
25
|
variant='ghost'
|
|
26
26
|
icon='ph--plus--regular'
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { OperationPlugin } from '@dxos/app-framework';
|
|
9
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
11
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
12
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
@@ -32,11 +33,12 @@ const meta = {
|
|
|
32
33
|
withPluginManager({
|
|
33
34
|
plugins: [
|
|
34
35
|
ClientPlugin({
|
|
35
|
-
onClientInitialized:
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
onClientInitialized: ({ client }) =>
|
|
37
|
+
Effect.gen(function* () {
|
|
38
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
39
|
+
}),
|
|
38
40
|
}),
|
|
39
|
-
|
|
41
|
+
OperationPlugin(),
|
|
40
42
|
],
|
|
41
43
|
}),
|
|
42
44
|
],
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
8
8
|
import { ComputeGraph } from '@dxos/conductor';
|
|
9
|
-
import { Filter, type
|
|
9
|
+
import { Filter, Obj, type Type } from '@dxos/echo';
|
|
10
10
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
11
|
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
12
|
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
13
13
|
import { useClient } from '@dxos/react-client';
|
|
14
|
-
import { type Space
|
|
14
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
15
15
|
import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
|
|
16
16
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import {
|
|
17
|
+
import { Organization, Person, Task } from '@dxos/types';
|
|
18
18
|
import { jsonKeyReplacer, sortKeys } from '@dxos/util';
|
|
19
19
|
|
|
20
20
|
import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
|
|
@@ -23,43 +23,48 @@ import { SchemaTable } from './SchemaTable';
|
|
|
23
23
|
|
|
24
24
|
export type SpaceGeneratorProps = {
|
|
25
25
|
space: Space;
|
|
26
|
-
onCreateObjects?: (objects: Obj.
|
|
26
|
+
onCreateObjects?: (objects: Obj.Unknown[]) => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
|
|
30
|
-
const {
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
31
31
|
const client = useClient();
|
|
32
32
|
const staticTypes = [Markdown.Document, Diagram.Diagram, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
|
|
33
|
-
const recordTypes = [
|
|
33
|
+
const recordTypes: Type.Obj.Any[] = [Organization.Organization, Person.Person, Task.Task];
|
|
34
34
|
const [count, setCount] = useState(1);
|
|
35
35
|
const [info, setInfo] = useState<any>({});
|
|
36
36
|
const presets = useMemo(() => generator(), []);
|
|
37
37
|
|
|
38
|
+
// Register types.
|
|
39
|
+
useAsyncEffect(async () => {
|
|
40
|
+
await client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
|
|
41
|
+
}, [client]);
|
|
42
|
+
|
|
38
43
|
// Create type generators.
|
|
39
44
|
const typeMap = useMemo(() => {
|
|
40
|
-
client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
|
|
41
45
|
const recordGenerators = new Map<string, ObjectGenerator<any>>(
|
|
42
|
-
recordTypes.map((type) => [type.typename, createGenerator(client,
|
|
46
|
+
recordTypes.map((type) => [type.typename, createGenerator(client, invokePromise, type)]),
|
|
43
47
|
);
|
|
44
48
|
|
|
45
49
|
return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
|
|
46
|
-
}, [client, recordTypes]);
|
|
50
|
+
}, [client, recordTypes, invokePromise]);
|
|
47
51
|
|
|
48
52
|
// Query space to get info.
|
|
49
53
|
const updateInfo = async () => {
|
|
50
54
|
// Create schema map.
|
|
51
55
|
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
52
|
-
const staticSchema = space.db.graph.schemaRegistry.
|
|
56
|
+
const staticSchema = await space.db.graph.schemaRegistry.query().run();
|
|
53
57
|
|
|
54
58
|
// Create object map.
|
|
55
|
-
const
|
|
59
|
+
const objects = await space.db.query(Filter.everything()).run();
|
|
56
60
|
const objectMap = sortKeys(
|
|
57
61
|
objects.reduce<Record<string, number>>((map, obj) => {
|
|
58
|
-
const type = getTypename(obj);
|
|
62
|
+
const type = Obj.getTypename(obj);
|
|
59
63
|
if (type) {
|
|
60
64
|
const count = map[type] ?? 0;
|
|
61
65
|
map[type] = count + 1;
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
return map;
|
|
64
69
|
}, {}),
|
|
65
70
|
);
|