@dxos/plugin-debug 0.7.1 → 0.7.2-main.f1adc9f

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.
Files changed (80) hide show
  1. package/dist/lib/browser/{DebugGlobal-ZTCBF3XR.mjs → DebugApp-HCHR6GKO.mjs} +18 -16
  2. package/dist/lib/browser/DebugApp-HCHR6GKO.mjs.map +7 -0
  3. package/dist/lib/browser/DebugSpace-HK2GQYIB.mjs +276 -0
  4. package/dist/lib/browser/DebugSpace-HK2GQYIB.mjs.map +7 -0
  5. package/dist/lib/browser/SpaceGenerator-TIBUROQA.mjs +155 -0
  6. package/dist/lib/browser/SpaceGenerator-TIBUROQA.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-GSJS3HEM.mjs +15 -0
  8. package/dist/lib/browser/chunk-GSJS3HEM.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +39 -41
  10. package/dist/lib/browser/index.mjs.map +3 -3
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  13. package/dist/types/src/components/Container.d.ts +5 -0
  14. package/dist/types/src/components/Container.d.ts.map +1 -0
  15. package/dist/types/src/components/{DebugGlobal.d.ts → DebugApp/DebugApp.d.ts} +2 -3
  16. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +1 -0
  17. package/dist/types/src/components/DebugApp/Tree.d.ts.map +1 -0
  18. package/dist/types/src/components/DebugApp/index.d.ts +3 -0
  19. package/dist/types/src/components/DebugApp/index.d.ts.map +1 -0
  20. package/dist/types/src/components/DebugObjectPanel.d.ts +2 -2
  21. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  22. package/dist/types/src/components/{DebugSpace.d.ts → DebugSpace/DebugSpace.d.ts} +1 -2
  23. package/dist/types/src/components/DebugSpace/DebugSpace.d.ts.map +1 -0
  24. package/dist/types/src/components/{DebugSpace.stories.d.ts → DebugSpace/DebugSpace.stories.d.ts} +1 -1
  25. package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -0
  26. package/dist/types/src/components/{ObjectCreator.d.ts → DebugSpace/ObjectCreator.d.ts} +4 -6
  27. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +1 -0
  28. package/dist/types/src/components/{ObjectCreator.stories.d.ts → DebugSpace/ObjectCreator.stories.d.ts} +1 -1
  29. package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -0
  30. package/dist/types/src/components/DebugSpace/index.d.ts +3 -0
  31. package/dist/types/src/components/DebugSpace/index.d.ts.map +1 -0
  32. package/dist/types/src/components/{SurfaceDebug.d.ts → DebugSurface.d.ts} +2 -2
  33. package/dist/types/src/components/{SurfaceDebug.d.ts.map → DebugSurface.d.ts.map} +1 -1
  34. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +9 -0
  35. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
  36. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +6 -0
  37. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -0
  38. package/dist/types/src/components/SpaceGenerator/index.d.ts +3 -0
  39. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -0
  40. package/dist/types/src/components/index.d.ts +2 -1
  41. package/dist/types/src/components/index.d.ts.map +1 -1
  42. package/package.json +41 -38
  43. package/src/DebugPlugin.tsx +61 -48
  44. package/src/components/Container.tsx +15 -0
  45. package/src/components/{DebugGlobal.tsx → DebugApp/DebugApp.tsx} +9 -11
  46. package/src/components/{Tree.tsx → DebugApp/Tree.tsx} +1 -1
  47. package/src/components/DebugApp/index.ts +7 -0
  48. package/src/components/DebugObjectPanel.tsx +4 -3
  49. package/src/components/{DebugSpace.stories.tsx → DebugSpace/DebugSpace.stories.tsx} +8 -6
  50. package/src/components/{DebugSpace.tsx → DebugSpace/DebugSpace.tsx} +70 -82
  51. package/src/components/{ObjectCreator.stories.tsx → DebugSpace/ObjectCreator.stories.tsx} +14 -11
  52. package/src/components/DebugSpace/ObjectCreator.tsx +100 -0
  53. package/src/components/DebugSpace/index.ts +7 -0
  54. package/src/components/{SurfaceDebug.tsx → DebugSurface.tsx} +1 -1
  55. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +37 -0
  56. package/src/components/SpaceGenerator/SpaceGenerator.tsx +169 -0
  57. package/src/components/SpaceGenerator/index.ts +7 -0
  58. package/src/components/index.ts +2 -1
  59. package/dist/lib/browser/DebugGlobal-ZTCBF3XR.mjs.map +0 -7
  60. package/dist/lib/browser/DebugSpace-6TGT3H4I.mjs +0 -411
  61. package/dist/lib/browser/DebugSpace-6TGT3H4I.mjs.map +0 -7
  62. package/dist/lib/browser/chunk-H3BJHVRD.mjs +0 -24
  63. package/dist/lib/browser/chunk-H3BJHVRD.mjs.map +0 -7
  64. package/dist/types/src/components/DebugGlobal.d.ts.map +0 -1
  65. package/dist/types/src/components/DebugPanel.d.ts +0 -5
  66. package/dist/types/src/components/DebugPanel.d.ts.map +0 -1
  67. package/dist/types/src/components/DebugSpace.d.ts.map +0 -1
  68. package/dist/types/src/components/DebugSpace.stories.d.ts.map +0 -1
  69. package/dist/types/src/components/ObjectCreator.d.ts.map +0 -1
  70. package/dist/types/src/components/ObjectCreator.stories.d.ts.map +0 -1
  71. package/dist/types/src/components/Tree.d.ts.map +0 -1
  72. package/dist/types/src/scaffolding/generator.d.ts +0 -11
  73. package/dist/types/src/scaffolding/generator.d.ts.map +0 -1
  74. package/dist/types/src/scaffolding/index.d.ts +0 -2
  75. package/dist/types/src/scaffolding/index.d.ts.map +0 -1
  76. package/src/components/DebugPanel.tsx +0 -29
  77. package/src/components/ObjectCreator.tsx +0 -99
  78. package/src/scaffolding/generator.ts +0 -146
  79. package/src/scaffolding/index.ts +0 -5
  80. /package/dist/types/src/components/{Tree.d.ts → DebugApp/Tree.d.ts} +0 -0
@@ -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);
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './generator';