@dxos/plugin-debug 0.7.1 → 0.7.2-staging.6d26b2a
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/{DebugGlobal-ZTCBF3XR.mjs → DebugApp-HCHR6GKO.mjs} +18 -16
- package/dist/lib/browser/DebugApp-HCHR6GKO.mjs.map +7 -0
- package/dist/lib/browser/DebugSpace-ZLGGNDAR.mjs +276 -0
- package/dist/lib/browser/DebugSpace-ZLGGNDAR.mjs.map +7 -0
- package/dist/lib/browser/chunk-GSJS3HEM.mjs +15 -0
- package/dist/lib/browser/chunk-GSJS3HEM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -11
- 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/Container.d.ts +5 -0
- package/dist/types/src/components/Container.d.ts.map +1 -0
- package/dist/types/src/components/{DebugGlobal.d.ts → DebugApp/DebugApp.d.ts} +2 -3
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +1 -0
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +1 -0
- package/dist/types/src/components/DebugApp/index.d.ts +3 -0
- package/dist/types/src/components/DebugApp/index.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts +2 -2
- package/dist/types/src/components/{DebugSpace.d.ts → DebugSpace/DebugSpace.d.ts} +1 -2
- package/dist/types/src/components/DebugSpace/DebugSpace.d.ts.map +1 -0
- package/dist/types/src/components/{DebugSpace.stories.d.ts → DebugSpace/DebugSpace.stories.d.ts} +1 -1
- package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -0
- package/dist/types/src/components/{ObjectCreator.d.ts → DebugSpace/ObjectCreator.d.ts} +4 -6
- package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +1 -0
- package/dist/types/src/components/{ObjectCreator.stories.d.ts → DebugSpace/ObjectCreator.stories.d.ts} +1 -1
- package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugSpace/index.d.ts +3 -0
- package/dist/types/src/components/DebugSpace/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/package.json +38 -38
- package/src/DebugPlugin.tsx +5 -11
- package/src/components/Container.tsx +15 -0
- package/src/components/{DebugGlobal.tsx → DebugApp/DebugApp.tsx} +9 -11
- package/src/components/{Tree.tsx → DebugApp/Tree.tsx} +1 -1
- package/src/components/DebugApp/index.ts +7 -0
- package/src/components/DebugObjectPanel.tsx +2 -2
- package/src/components/{DebugSpace.stories.tsx → DebugSpace/DebugSpace.stories.tsx} +8 -6
- package/src/components/{DebugSpace.tsx → DebugSpace/DebugSpace.tsx} +70 -82
- package/src/components/{ObjectCreator.stories.tsx → DebugSpace/ObjectCreator.stories.tsx} +14 -11
- package/src/components/DebugSpace/ObjectCreator.tsx +100 -0
- package/src/components/DebugSpace/index.ts +7 -0
- package/src/components/index.ts +1 -1
- package/dist/lib/browser/DebugGlobal-ZTCBF3XR.mjs.map +0 -7
- package/dist/lib/browser/DebugSpace-6TGT3H4I.mjs +0 -411
- package/dist/lib/browser/DebugSpace-6TGT3H4I.mjs.map +0 -7
- package/dist/lib/browser/chunk-H3BJHVRD.mjs +0 -24
- package/dist/lib/browser/chunk-H3BJHVRD.mjs.map +0 -7
- package/dist/types/src/components/DebugGlobal.d.ts.map +0 -1
- package/dist/types/src/components/DebugPanel.d.ts +0 -5
- package/dist/types/src/components/DebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugSpace.d.ts.map +0 -1
- package/dist/types/src/components/DebugSpace.stories.d.ts.map +0 -1
- package/dist/types/src/components/ObjectCreator.d.ts.map +0 -1
- package/dist/types/src/components/ObjectCreator.stories.d.ts.map +0 -1
- package/dist/types/src/components/Tree.d.ts.map +0 -1
- package/dist/types/src/scaffolding/generator.d.ts +0 -11
- package/dist/types/src/scaffolding/generator.d.ts.map +0 -1
- package/dist/types/src/scaffolding/index.d.ts +0 -2
- package/dist/types/src/scaffolding/index.d.ts.map +0 -1
- package/src/components/DebugPanel.tsx +0 -29
- package/src/components/ObjectCreator.tsx +0 -99
- package/src/scaffolding/generator.ts +0 -146
- package/src/scaffolding/index.ts +0 -5
- /package/dist/types/src/components/{Tree.d.ts → DebugApp/Tree.d.ts} +0 -0
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { formatDistance } from 'date-fns';
|
|
6
|
-
import React, { type PropsWithChildren, type ReactNode } from 'react';
|
|
7
|
-
|
|
8
|
-
import { useConfig } from '@dxos/react-client';
|
|
9
|
-
|
|
10
|
-
export const DebugPanel = ({ menu, children }: PropsWithChildren<{ menu: ReactNode }>) => {
|
|
11
|
-
const config = useConfig();
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
<div className='flex shrink-0 p-2 space-x-2'>{menu}</div>
|
|
15
|
-
<div className='flex flex-col grow px-2 overflow-hidden'>
|
|
16
|
-
<div className='flex flex-col grow overflow-auto'>{children}</div>
|
|
17
|
-
{config.values?.runtime?.app?.build?.timestamp && (
|
|
18
|
-
<div className='p-2 text-sm font-mono'>
|
|
19
|
-
{config.values?.runtime?.app?.build?.version}
|
|
20
|
-
{formatDistance(new Date(config.values?.runtime?.app?.build?.timestamp), new Date(), {
|
|
21
|
-
addSuffix: true,
|
|
22
|
-
includeSeconds: true,
|
|
23
|
-
})}
|
|
24
|
-
</div>
|
|
25
|
-
)}
|
|
26
|
-
</div>
|
|
27
|
-
</>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type EchoReactiveObject, type ReactiveObject, type Space } from '@dxos/react-client/echo';
|
|
8
|
-
import { Button } from '@dxos/react-ui';
|
|
9
|
-
import { createColumnBuilder, type TableColumnDef, Table } from '@dxos/react-ui-table/deprecated';
|
|
10
|
-
|
|
11
|
-
import { SchemasNames, createSpaceObjectGenerator } from '../scaffolding';
|
|
12
|
-
|
|
13
|
-
export type CreateObjectsParams = {
|
|
14
|
-
enabled: boolean;
|
|
15
|
-
schema: SchemasNames;
|
|
16
|
-
objectsCount: number;
|
|
17
|
-
mutationsCount: number;
|
|
18
|
-
maxContentLength: number;
|
|
19
|
-
mutationSize: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const CREATE_OBJECTS_IN_ONE_CHUNK = 10;
|
|
23
|
-
|
|
24
|
-
export type ObjectCreatorProps = {
|
|
25
|
-
space: Space;
|
|
26
|
-
onAddObjects?: (objects: ReactiveObject<any>[]) => void;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const ObjectCreator = ({ space, onAddObjects }: ObjectCreatorProps) => {
|
|
30
|
-
const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);
|
|
31
|
-
|
|
32
|
-
const [objectsToCreate, setObjectsToCreate] = useState<CreateObjectsParams[]>([
|
|
33
|
-
{
|
|
34
|
-
enabled: true,
|
|
35
|
-
schema: SchemasNames.document,
|
|
36
|
-
objectsCount: 10,
|
|
37
|
-
mutationsCount: 10,
|
|
38
|
-
mutationSize: 10,
|
|
39
|
-
maxContentLength: 1000,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
enabled: true,
|
|
43
|
-
schema: SchemasNames.diagram,
|
|
44
|
-
objectsCount: 10,
|
|
45
|
-
mutationsCount: 10,
|
|
46
|
-
mutationSize: 10,
|
|
47
|
-
maxContentLength: 1000,
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
const handleCreate = async () => {
|
|
52
|
-
for (const params of objectsToCreate) {
|
|
53
|
-
if (!params.enabled) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
let objectsCreated = 0;
|
|
57
|
-
while (objectsCreated < params.objectsCount) {
|
|
58
|
-
const objects = (await generator.createObjects({
|
|
59
|
-
[params.schema]: Math.min(CREATE_OBJECTS_IN_ONE_CHUNK, params.objectsCount - objectsCreated),
|
|
60
|
-
})) as EchoReactiveObject<any>[];
|
|
61
|
-
|
|
62
|
-
await generator.mutateObjects(objects, {
|
|
63
|
-
count: params.mutationsCount,
|
|
64
|
-
mutationSize: params.mutationSize,
|
|
65
|
-
maxContentLength: params.maxContentLength,
|
|
66
|
-
});
|
|
67
|
-
objectsCreated += objects.length;
|
|
68
|
-
onAddObjects?.(objects);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
await space.db.flush();
|
|
72
|
-
};
|
|
73
|
-
const handleChangeOnRow = (row: CreateObjectsParams, key: string, value: any) => {
|
|
74
|
-
const newObjects = [...objectsToCreate];
|
|
75
|
-
Object.assign(newObjects.find((object) => object.schema === row.schema)!, { [key]: value });
|
|
76
|
-
setObjectsToCreate(newObjects);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const { helper, builder } = createColumnBuilder<CreateObjectsParams>();
|
|
80
|
-
const columns: TableColumnDef<CreateObjectsParams>[] = [
|
|
81
|
-
helper.accessor('enabled', builder.switch({ label: 'Enabled', onUpdate: handleChangeOnRow })),
|
|
82
|
-
helper.accessor('schema', builder.string({ classNames: 'font-mono', label: 'Schema' })),
|
|
83
|
-
helper.accessor('objectsCount', builder.number({ label: 'Objects', onUpdate: handleChangeOnRow })),
|
|
84
|
-
helper.accessor('mutationsCount', builder.number({ label: 'Mutations', onUpdate: handleChangeOnRow })),
|
|
85
|
-
helper.accessor('mutationSize', builder.number({ label: 'Mut. Size', onUpdate: handleChangeOnRow })),
|
|
86
|
-
helper.accessor('maxContentLength', builder.number({ label: 'Length', onUpdate: handleChangeOnRow })),
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<>
|
|
91
|
-
<Table.Root>
|
|
92
|
-
<Table.Viewport>
|
|
93
|
-
<Table.Main<CreateObjectsParams> columns={columns} data={objectsToCreate} />
|
|
94
|
-
</Table.Viewport>
|
|
95
|
-
</Table.Root>
|
|
96
|
-
<Button onClick={handleCreate}>Create</Button>
|
|
97
|
-
</>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
createShapeId,
|
|
7
|
-
defaultBindingUtils,
|
|
8
|
-
defaultShapeUtils,
|
|
9
|
-
defaultTools,
|
|
10
|
-
Editor,
|
|
11
|
-
type TLParentId,
|
|
12
|
-
} from '@tldraw/tldraw';
|
|
13
|
-
|
|
14
|
-
import { sleep } from '@dxos/async';
|
|
15
|
-
import { next as A } from '@dxos/automerge/automerge';
|
|
16
|
-
import {
|
|
17
|
-
SpaceObjectGenerator,
|
|
18
|
-
type TestGeneratorMap,
|
|
19
|
-
type TestMutationsMap,
|
|
20
|
-
type TestSchemaMap,
|
|
21
|
-
} from '@dxos/echo-generator';
|
|
22
|
-
import { create } from '@dxos/echo-schema';
|
|
23
|
-
import { log } from '@dxos/log';
|
|
24
|
-
import { DocumentType, TextType } from '@dxos/plugin-markdown/types';
|
|
25
|
-
import { TLDrawStoreAdapter } from '@dxos/plugin-sketch/sdk';
|
|
26
|
-
import { CanvasType, DiagramType, TLDRAW_SCHEMA } from '@dxos/plugin-sketch/types';
|
|
27
|
-
import { faker } from '@dxos/random';
|
|
28
|
-
import { createDocAccessor, type Space } from '@dxos/react-client/echo';
|
|
29
|
-
|
|
30
|
-
// TODO(burdon): Move to echo-generator.
|
|
31
|
-
|
|
32
|
-
// TODO(wittjosiah): Remove? Just use DXNs.
|
|
33
|
-
export enum SchemasNames {
|
|
34
|
-
document = 'dxos.org/type/Document',
|
|
35
|
-
diagram = 'dxos.org/type/Diagram',
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const SchemasMap: TestSchemaMap<SchemasNames> = {
|
|
39
|
-
[SchemasNames.document]: DocumentType,
|
|
40
|
-
[SchemasNames.diagram]: DiagramType,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const ObjectGenerators: TestGeneratorMap<SchemasNames> = {
|
|
44
|
-
[SchemasNames.document]: () => {
|
|
45
|
-
const name = faker.lorem.sentence({ min: 2, max: 3 });
|
|
46
|
-
return { name, content: create(TextType, { content: '' }), threads: [] };
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
[SchemasNames.diagram]: () => {
|
|
50
|
-
const name = faker.lorem.sentence({ min: 2, max: 3 });
|
|
51
|
-
return {
|
|
52
|
-
name,
|
|
53
|
-
canvas: create(CanvasType, { schema: TLDRAW_SCHEMA, content: {} }),
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const MutationsGenerators: TestMutationsMap<SchemasNames> = {
|
|
59
|
-
[SchemasNames.document]: async (object, params) => {
|
|
60
|
-
const accessor = createDocAccessor<DocumentType>(object.content, ['content']);
|
|
61
|
-
|
|
62
|
-
for (let i = 0; i < params.count; i++) {
|
|
63
|
-
const length = object.content?.content?.length ?? 0;
|
|
64
|
-
accessor.handle.change((doc) => {
|
|
65
|
-
A.splice(
|
|
66
|
-
doc,
|
|
67
|
-
accessor.path.slice(),
|
|
68
|
-
0,
|
|
69
|
-
params.maxContentLength >= length ? 0 : params.mutationSize,
|
|
70
|
-
faker.string.hexadecimal({ length: params.mutationSize - 1 }) + ' ',
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Release the event loop.
|
|
75
|
-
if (i % 100 === 0 || i === params.count - 1) {
|
|
76
|
-
log.info('Mutation:', { mutationIdx: i });
|
|
77
|
-
await sleep(1);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
[SchemasNames.diagram]: async (object, params) => {
|
|
83
|
-
const store = new TLDrawStoreAdapter();
|
|
84
|
-
await store.open(createDocAccessor<CanvasType>(object.canvas, ['content']));
|
|
85
|
-
const app = new Editor({
|
|
86
|
-
store: store.store!,
|
|
87
|
-
shapeUtils: defaultShapeUtils,
|
|
88
|
-
bindingUtils: defaultBindingUtils,
|
|
89
|
-
tools: defaultTools,
|
|
90
|
-
getContainer: () => document.getElementsByTagName('body')[0],
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
//
|
|
94
|
-
// Draw spiral.
|
|
95
|
-
//
|
|
96
|
-
const r = 100;
|
|
97
|
-
const a = 0.05;
|
|
98
|
-
const cx = 200;
|
|
99
|
-
const cy = 200;
|
|
100
|
-
|
|
101
|
-
for (let i = 0; i < params.count; i++) {
|
|
102
|
-
const t = i;
|
|
103
|
-
const t1 = i + 1;
|
|
104
|
-
const x = cx + a * t * r * Math.cos(t);
|
|
105
|
-
const y = cy + a * t * r * Math.sin(t);
|
|
106
|
-
const x1 = cx + a * t1 * r * Math.cos(t1);
|
|
107
|
-
const y1 = cy + a * t1 * r * Math.sin(t1);
|
|
108
|
-
|
|
109
|
-
app.createShape({
|
|
110
|
-
id: createShapeId(),
|
|
111
|
-
isLocked: false,
|
|
112
|
-
meta: {},
|
|
113
|
-
opacity: 1,
|
|
114
|
-
parentId: 'page:page' as TLParentId,
|
|
115
|
-
props: {
|
|
116
|
-
arrowheadEnd: 'none',
|
|
117
|
-
arrowheadStart: 'none',
|
|
118
|
-
bend: 0,
|
|
119
|
-
color: 'black',
|
|
120
|
-
dash: 'draw',
|
|
121
|
-
start: { x, y },
|
|
122
|
-
end: { x: x1, y: y1 },
|
|
123
|
-
fill: 'none',
|
|
124
|
-
font: 'draw',
|
|
125
|
-
labelColor: 'black',
|
|
126
|
-
labelPosition: 0.5,
|
|
127
|
-
scale: 1,
|
|
128
|
-
size: 'm',
|
|
129
|
-
},
|
|
130
|
-
rotation: 0,
|
|
131
|
-
type: 'arrow',
|
|
132
|
-
typeName: 'shape',
|
|
133
|
-
x: 0,
|
|
134
|
-
y: 0,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Release the event loop.
|
|
138
|
-
if (i % 100 === 0) {
|
|
139
|
-
await sleep(1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export const createSpaceObjectGenerator = (space: Space) =>
|
|
146
|
-
new SpaceObjectGenerator(space, SchemasMap, ObjectGenerators, MutationsGenerators);
|
package/src/scaffolding/index.ts
DELETED
|
File without changes
|