@dxos/plugin-debug 0.7.4 → 0.7.5-labs.401163d
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-KYSK77VG.mjs +1100 -0
- package/dist/lib/browser/SpaceGenerator-KYSK77VG.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs +181 -0
- package/dist/lib/browser/app-graph-builder-DCMGZAT3.mjs.map +7 -0
- package/dist/lib/browser/chunk-EF3UVAVI.mjs +21 -0
- package/dist/lib/browser/chunk-EF3UVAVI.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 +60 -737
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs +484 -0
- package/dist/lib/browser/react-surface-6GVTLM4O.mjs.map +7 -0
- package/dist/lib/browser/settings-OIMSBZUC.mjs +25 -0
- package/dist/lib/browser/settings-OIMSBZUC.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 +180 -0
- package/dist/types/src/capabilities/index.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/DebugSettings.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/SpaceGenerator/presets.d.ts +21 -0
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
- 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 +2 -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 +49 -51
- package/src/DebugPlugin.tsx +55 -381
- package/src/capabilities/app-graph-builder.ts +175 -0
- package/src/capabilities/index.ts +9 -0
- package/src/capabilities/react-surface.tsx +130 -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 +11 -13
- 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 +17 -27
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +45 -18
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +11 -8
- package/src/components/SpaceGenerator/draw-util.ts +7 -6
- package/src/components/SpaceGenerator/presets.ts +493 -0
- package/src/components/Wireframe.tsx +2 -2
- package/src/index.ts +1 -4
- package/src/meta.ts +4 -2
- package/src/types.ts +0 -22
- package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs +0 -273
- package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
- package/dist/lib/browser/chunk-CAENAAHY.mjs +0 -18
- 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
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
2
|
-
import React2, { useCallback, useMemo, useState } from "react";
|
|
3
|
-
import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
|
|
4
|
-
import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
|
|
5
|
-
import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
|
|
6
|
-
import { useClient } from "@dxos/react-client";
|
|
7
|
-
import { getTypename } from "@dxos/react-client/echo";
|
|
8
|
-
import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
9
|
-
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
10
|
-
import { Testing } from "@dxos/schema/testing";
|
|
11
|
-
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
12
|
-
|
|
13
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
14
|
-
import { create } from "@dxos/live-object";
|
|
15
|
-
import { DocumentType, TextType } from "@dxos/plugin-markdown/types";
|
|
16
|
-
import { addressToA1Notation, createSheet } from "@dxos/plugin-sheet";
|
|
17
|
-
import { SheetType } from "@dxos/plugin-sheet/types";
|
|
18
|
-
import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
|
|
19
|
-
import { faker } from "@dxos/random";
|
|
20
|
-
import { Filter } from "@dxos/react-client/echo";
|
|
21
|
-
import { TableType } from "@dxos/react-ui-table";
|
|
22
|
-
import { createView } from "@dxos/schema";
|
|
23
|
-
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
24
|
-
import { range } from "@dxos/util";
|
|
25
|
-
var generator = faker;
|
|
26
|
-
var staticGenerators = /* @__PURE__ */ new Map([
|
|
27
|
-
[
|
|
28
|
-
DocumentType.typename,
|
|
29
|
-
async (space, n, cb) => {
|
|
30
|
-
const objects = range(n).map(() => {
|
|
31
|
-
const obj = space.db.add(create(DocumentType, {
|
|
32
|
-
name: faker.commerce.productName(),
|
|
33
|
-
content: create(TextType, {
|
|
34
|
-
content: faker.lorem.sentences(5)
|
|
35
|
-
}),
|
|
36
|
-
threads: []
|
|
37
|
-
}));
|
|
38
|
-
return obj;
|
|
39
|
-
});
|
|
40
|
-
cb?.(objects);
|
|
41
|
-
return objects;
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
[
|
|
45
|
-
DiagramType.typename,
|
|
46
|
-
async (space, n, cb) => {
|
|
47
|
-
const objects = range(n).map(() => {
|
|
48
|
-
const obj = space.db.add(create(DiagramType, {
|
|
49
|
-
name: faker.commerce.productName(),
|
|
50
|
-
canvas: create(CanvasType, {
|
|
51
|
-
content: {}
|
|
52
|
-
})
|
|
53
|
-
}));
|
|
54
|
-
return obj;
|
|
55
|
-
});
|
|
56
|
-
cb?.(objects);
|
|
57
|
-
return objects;
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
// TODO(burdon): Create unit tests.
|
|
61
|
-
[
|
|
62
|
-
SheetType.typename,
|
|
63
|
-
async (space, n, cb) => {
|
|
64
|
-
const objects = range(n).map(() => {
|
|
65
|
-
const cells = {};
|
|
66
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
67
|
-
const cols = 4;
|
|
68
|
-
const rows = 16;
|
|
69
|
-
for (let col = 1; col <= cols; col++) {
|
|
70
|
-
for (let row = 1; row <= rows; row++) {
|
|
71
|
-
const cell = addressToA1Notation({
|
|
72
|
-
col,
|
|
73
|
-
row
|
|
74
|
-
});
|
|
75
|
-
if (row === 1) {
|
|
76
|
-
cells[cell] = {
|
|
77
|
-
value: `${year} Q${col}`
|
|
78
|
-
};
|
|
79
|
-
} else if (row === rows) {
|
|
80
|
-
const from = addressToA1Notation({
|
|
81
|
-
col,
|
|
82
|
-
row: 2
|
|
83
|
-
});
|
|
84
|
-
const to = addressToA1Notation({
|
|
85
|
-
col,
|
|
86
|
-
row: rows - 1
|
|
87
|
-
});
|
|
88
|
-
cells[cell] = {
|
|
89
|
-
value: `=SUM(${from}:${to})`
|
|
90
|
-
};
|
|
91
|
-
} else if (row > 2 && row < rows - 1) {
|
|
92
|
-
cells[cell] = {
|
|
93
|
-
value: Math.floor(Math.random() * 1e4)
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return space.db.add(createSheet({
|
|
99
|
-
name: faker.commerce.productName(),
|
|
100
|
-
cells
|
|
101
|
-
}));
|
|
102
|
-
});
|
|
103
|
-
cb?.(objects);
|
|
104
|
-
return objects;
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
]);
|
|
108
|
-
var createGenerator = (type) => {
|
|
109
|
-
return async (space, n, cb) => {
|
|
110
|
-
const mutableSchema = await space.db.schemaRegistry.query();
|
|
111
|
-
const schema = mutableSchema.find((schema2) => schema2.typename === type.typename) ?? space.db.schemaRegistry.addSchema(type);
|
|
112
|
-
const generate = createAsyncGenerator(generator, schema.schema, {
|
|
113
|
-
db: space.db
|
|
114
|
-
});
|
|
115
|
-
const objects = await generate.createObjects(n);
|
|
116
|
-
const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
|
|
117
|
-
const table = tables.find((table2) => table2.view?.query?.type === type.typename);
|
|
118
|
-
if (!table) {
|
|
119
|
-
const name = type.typename.split("/").pop() ?? type.typename;
|
|
120
|
-
const view = createView({
|
|
121
|
-
name,
|
|
122
|
-
typename: type.typename,
|
|
123
|
-
jsonSchema: schema.jsonSchema
|
|
124
|
-
});
|
|
125
|
-
const table2 = space.db.add(create(TableType, {
|
|
126
|
-
name,
|
|
127
|
-
view
|
|
128
|
-
}));
|
|
129
|
-
cb?.([
|
|
130
|
-
table2
|
|
131
|
-
]);
|
|
132
|
-
}
|
|
133
|
-
return objects;
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SchemaTable.tsx
|
|
138
|
-
import React from "react";
|
|
139
|
-
import { IconButton } from "@dxos/react-ui";
|
|
140
|
-
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
141
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
142
|
-
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden"
|
|
143
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
144
|
-
className: "grid grid-cols-subgrid col-span-3"
|
|
145
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
146
|
-
className: "px-2 text-sm text-primary-500"
|
|
147
|
-
}, label), /* @__PURE__ */ React.createElement("div", {
|
|
148
|
-
className: "px-2 text-xs text-subdued text-right"
|
|
149
|
-
}, "count")), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
150
|
-
key: type.typename,
|
|
151
|
-
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
152
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
153
|
-
className: "px-2 text-sm font-mono text-green-500"
|
|
154
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
155
|
-
className: "px-2 text-right font-mono"
|
|
156
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
157
|
-
variant: "ghost",
|
|
158
|
-
icon: "ph--plus--regular",
|
|
159
|
-
iconOnly: true,
|
|
160
|
-
label: "Create data",
|
|
161
|
-
onClick: () => onClick(type.typename)
|
|
162
|
-
}))));
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
166
|
-
var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
167
|
-
const client = useClient();
|
|
168
|
-
const staticTypes = [
|
|
169
|
-
DocumentType2,
|
|
170
|
-
DiagramType2,
|
|
171
|
-
SheetType2
|
|
172
|
-
];
|
|
173
|
-
const mutableTypes = [
|
|
174
|
-
Testing.OrgType,
|
|
175
|
-
Testing.ProjectType,
|
|
176
|
-
Testing.ContactType
|
|
177
|
-
];
|
|
178
|
-
const [count, setCount] = useState(1);
|
|
179
|
-
const [info, setInfo] = useState({});
|
|
180
|
-
const typeMap = useMemo(() => {
|
|
181
|
-
client.addTypes(staticTypes);
|
|
182
|
-
const mutableGenerators = new Map(mutableTypes.map((type) => [
|
|
183
|
-
type.typename,
|
|
184
|
-
createGenerator(type)
|
|
185
|
-
]));
|
|
186
|
-
return new Map([
|
|
187
|
-
...staticGenerators,
|
|
188
|
-
...mutableGenerators
|
|
189
|
-
]);
|
|
190
|
-
}, [
|
|
191
|
-
client,
|
|
192
|
-
mutableTypes
|
|
193
|
-
]);
|
|
194
|
-
const updateInfo = async () => {
|
|
195
|
-
const mutableSchema = await space.db.schemaRegistry.query();
|
|
196
|
-
const staticSchema = space.db.graph.schemaRegistry.schemas;
|
|
197
|
-
const { objects } = await space.db.query().run();
|
|
198
|
-
const objectMap = sortKeys(objects.reduce((map, obj) => {
|
|
199
|
-
const type = getTypename(obj);
|
|
200
|
-
if (type) {
|
|
201
|
-
const count2 = map[type] ?? 0;
|
|
202
|
-
map[type] = count2 + 1;
|
|
203
|
-
}
|
|
204
|
-
return map;
|
|
205
|
-
}, {}));
|
|
206
|
-
setInfo({
|
|
207
|
-
schema: {
|
|
208
|
-
static: staticSchema.length,
|
|
209
|
-
mutable: mutableSchema.length
|
|
210
|
-
},
|
|
211
|
-
objects: objectMap
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
useAsyncEffect(updateInfo, [
|
|
215
|
-
space
|
|
216
|
-
]);
|
|
217
|
-
const handleCreateData = useCallback(async (typename) => {
|
|
218
|
-
const constructor = typeMap.get(typename);
|
|
219
|
-
if (constructor) {
|
|
220
|
-
await constructor(space, count, onCreateObjects);
|
|
221
|
-
await updateInfo();
|
|
222
|
-
}
|
|
223
|
-
}, [
|
|
224
|
-
typeMap,
|
|
225
|
-
count
|
|
226
|
-
]);
|
|
227
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
228
|
-
role: "none",
|
|
229
|
-
className: "flex flex-col divide-y divide-separator"
|
|
230
|
-
}, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
|
|
231
|
-
classNames: "p-1"
|
|
232
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
233
|
-
icon: "ph--arrow-clockwise--regular",
|
|
234
|
-
iconOnly: true,
|
|
235
|
-
label: "Refresh",
|
|
236
|
-
onClick: updateInfo
|
|
237
|
-
}), /* @__PURE__ */ React2.createElement(Toolbar.Expander, null), /* @__PURE__ */ React2.createElement("div", {
|
|
238
|
-
className: "flex"
|
|
239
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
240
|
-
type: "number",
|
|
241
|
-
min: 1,
|
|
242
|
-
max: 100,
|
|
243
|
-
placeholder: "Count",
|
|
244
|
-
classNames: "w-[80px]",
|
|
245
|
-
value: count,
|
|
246
|
-
onChange: (ev) => setCount(parseInt(ev.target.value))
|
|
247
|
-
})))), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
248
|
-
types: staticTypes,
|
|
249
|
-
objects: info.objects,
|
|
250
|
-
label: "Static Types",
|
|
251
|
-
onClick: handleCreateData
|
|
252
|
-
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
253
|
-
types: mutableTypes,
|
|
254
|
-
objects: info.objects,
|
|
255
|
-
label: "Mutable Types",
|
|
256
|
-
onClick: handleCreateData
|
|
257
|
-
}), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
258
|
-
classNames: "flex text-xs",
|
|
259
|
-
language: "json"
|
|
260
|
-
}, JSON.stringify({
|
|
261
|
-
space,
|
|
262
|
-
...info
|
|
263
|
-
}, jsonKeyReplacer({
|
|
264
|
-
truncate: true
|
|
265
|
-
}), 2)));
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/index.ts
|
|
269
|
-
var SpaceGenerator_default = SpaceGenerator;
|
|
270
|
-
export {
|
|
271
|
-
SpaceGenerator_default as default
|
|
272
|
-
};
|
|
273
|
-
//# sourceMappingURL=SpaceGenerator-BQ3645OS.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/SpaceGenerator/SpaceGenerator.tsx", "../../../src/components/SpaceGenerator/ObjectGenerator.tsx", "../../../src/components/SpaceGenerator/SchemaTable.tsx", "../../../src/components/SpaceGenerator/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType } from '@dxos/plugin-markdown/types';\nimport { SheetType } from '@dxos/plugin-sheet/types';\nimport { DiagramType } from '@dxos/plugin-sketch/types';\nimport { useClient } from '@dxos/react-client';\nimport { getTypename, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';\nimport { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';\nimport { Testing } from '@dxos/schema/testing';\nimport { jsonKeyReplacer, sortKeys } from '@dxos/util';\n\nimport { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';\nimport { SchemaTable } from './SchemaTable';\n\nexport type SpaceGeneratorProps = {\n space: Space;\n onCreateObjects?: (objects: ReactiveObject<any>[]) => void;\n};\n\nexport const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {\n const client = useClient();\n const staticTypes = [DocumentType, DiagramType, SheetType]; // TODO(burdon): Make extensible.\n const mutableTypes = [Testing.OrgType, Testing.ProjectType, Testing.ContactType];\n const [count, setCount] = useState(1);\n const [info, setInfo] = useState<any>({});\n\n // Create type generators.\n const typeMap = useMemo(() => {\n client.addTypes(staticTypes);\n const mutableGenerators = new Map<string, ObjectGenerator<any>>(\n mutableTypes.map((type) => [type.typename, createGenerator(type)]),\n );\n\n return new Map([...staticGenerators, ...mutableGenerators]);\n }, [client, mutableTypes]);\n\n // Query space to get info.\n const updateInfo = async () => {\n // Create schema map.\n const mutableSchema = await space.db.schemaRegistry.query();\n const staticSchema = space.db.graph.schemaRegistry.schemas;\n\n // Create object map.\n const { objects } = await space.db.query().run();\n const objectMap = sortKeys(\n objects.reduce<Record<string, number>>((map, obj) => {\n const type = getTypename(obj);\n if (type) {\n const count = map[type] ?? 0;\n map[type] = count + 1;\n }\n return map;\n }, {}),\n );\n\n setInfo({\n schema: {\n static: staticSchema.length,\n mutable: mutableSchema.length,\n },\n objects: objectMap,\n });\n };\n\n useAsyncEffect(updateInfo, [space]);\n\n const handleCreateData = useCallback(\n async (typename: string) => {\n const constructor = typeMap.get(typename);\n if (constructor) {\n // TODO(burdon): Input to specify number of objects.\n await constructor(space, count, onCreateObjects);\n await updateInfo();\n }\n },\n [typeMap, count],\n );\n\n return (\n <div role='none' className='flex flex-col divide-y divide-separator'>\n <Toolbar.Root classNames='p-1'>\n <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />\n <Toolbar.Expander />\n <div className='flex'>\n <Input.Root>\n <Input.TextInput\n type='number'\n min={1}\n max={100}\n placeholder={'Count'}\n classNames='w-[80px]'\n value={count}\n onChange={(ev) => setCount(parseInt(ev.target.value))}\n />\n </Input.Root>\n </div>\n </Toolbar.Root>\n\n <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />\n <SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />\n\n <SyntaxHighlighter classNames='flex text-xs' language='json'>\n {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}\n </SyntaxHighlighter>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type AbstractSchema, type BaseObject } from '@dxos/echo-schema';\nimport { create, type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType, TextType } from '@dxos/plugin-markdown/types';\nimport { addressToA1Notation, createSheet } from '@dxos/plugin-sheet';\nimport { type CellValue } from '@dxos/plugin-sheet/types';\nimport { SheetType } from '@dxos/plugin-sheet/types';\nimport { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';\nimport { faker } from '@dxos/random';\nimport { Filter, type Space } from '@dxos/react-client/echo';\nimport { TableType } from '@dxos/react-ui-table';\nimport { createView } from '@dxos/schema';\nimport { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';\nimport { range } from '@dxos/util';\n\nconst generator: ValueGenerator = faker as any;\n\n// TODO(burdon): Add objects to collections.\n// TODO(burdon): Create docs.\n// TODO(burdon): Create sketches.\n// TODO(burdon): Create sheets.\n// TODO(burdon): Create comments.\n// TODO(burdon): Reuse in testbench-app.\n// TODO(burdon): Mutator running in background (factor out): from echo-generator.\n\nexport type ObjectGenerator<T extends BaseObject> = (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n) => Promise<ReactiveObject<T>[]>;\n\nexport const staticGenerators = new Map<string, ObjectGenerator<any>>([\n [\n DocumentType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const obj = space.db.add(\n create(DocumentType, {\n name: faker.commerce.productName(),\n content: create(TextType, { content: faker.lorem.sentences(5) }),\n threads: [],\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n [\n DiagramType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n // TODO(burdon): Generate diagram.\n const obj = space.db.add(\n create(DiagramType, {\n name: faker.commerce.productName(),\n canvas: create(CanvasType, { content: {} }),\n }),\n );\n\n return obj;\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n // TODO(burdon): Create unit tests.\n [\n SheetType.typename,\n async (space, n, cb) => {\n const objects = range(n).map(() => {\n const cells: Record<string, CellValue> = {};\n const year = new Date().getFullYear();\n const cols = 4;\n const rows = 16;\n for (let col = 1; col <= cols; col++) {\n for (let row = 1; row <= rows; row++) {\n const cell = addressToA1Notation({ col, row });\n if (row === 1) {\n cells[cell] = { value: `${year} Q${col}` };\n } else if (row === rows) {\n const from = addressToA1Notation({ col, row: 2 });\n const to = addressToA1Notation({ col, row: rows - 1 });\n cells[cell] = { value: `=SUM(${from}:${to})` };\n } else if (row > 2 && row < rows - 1) {\n cells[cell] = { value: Math.floor(Math.random() * 10_000) };\n }\n }\n }\n\n // TODO(burdon): Set width.\n // TODO(burdon): Set formatting for columns.\n return space.db.add(\n createSheet({\n name: faker.commerce.productName(),\n cells,\n }),\n );\n });\n\n cb?.(objects);\n return objects;\n },\n ],\n]);\n\nexport const createGenerator = <T extends BaseObject>(type: AbstractSchema<T>): ObjectGenerator<T> => {\n return async (\n space: Space,\n n: number,\n cb?: (objects: ReactiveObject<any>[]) => void,\n ): Promise<ReactiveObject<T>[]> => {\n // Find or create mutable schema.\n const mutableSchema = await space.db.schemaRegistry.query();\n const schema =\n mutableSchema.find((schema) => schema.typename === type.typename) ?? space.db.schemaRegistry.addSchema(type);\n\n // Create objects.\n const generate = createAsyncGenerator(generator, schema.schema, { db: space.db });\n const objects = await generate.createObjects(n);\n\n // Find or create table and view.\n const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();\n const table = tables.find((table) => table.view?.query?.type === type.typename);\n if (!table) {\n const name = type.typename.split('/').pop() ?? type.typename;\n const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });\n const table = space.db.add(create(TableType, { name, view }));\n cb?.([table]);\n }\n\n return objects;\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { IconButton } from '@dxos/react-ui';\n\nexport type SchemaTableProps = {\n types: any[];\n objects?: Record<string, number | undefined>;\n label: string;\n onClick: (typename: string) => void;\n};\n\nexport const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTableProps) => {\n return (\n <div className='grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden'>\n <div className='grid grid-cols-subgrid col-span-3'>\n <div className='px-2 text-sm text-primary-500'>{label}</div>\n <div className='px-2 text-xs text-subdued text-right'>count</div>\n </div>\n {types.map((type) => (\n <div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>\n <div className='px-2 text-sm font-mono text-green-500'>{type.typename}</div>\n <div className='px-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>\n <IconButton\n variant='ghost'\n icon='ph--plus--regular'\n iconOnly\n label='Create data'\n onClick={() => onClick(type.typename)}\n />\n </div>\n ))}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SpaceGenerator } from './SpaceGenerator';\n\nexport default SpaceGenerator;\n"],
|
|
5
|
-
"mappings": ";AAIA,OAAOA,UAASC,aAAaC,SAASC,gBAAgB;AAGtD,SAASC,gBAAAA,qBAAoB;AAC7B,SAASC,a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BAAgB;IAAEC,UAAU;EAAK,CAAA,GAAI,CAAA,CAAA,CAAA;AAIjF;;;AG1GA,IAAA,yBAAeC;",
|
|
6
|
-
"names": ["React", "useCallback", "useMemo", "useState", "DocumentType", "SheetType", "DiagramType", "useClient", "getTypename", "IconButton", "Input", "Toolbar", "useAsyncEffect", "SyntaxHighlighter", "Testing", "jsonKeyReplacer", "sortKeys", "create", "DocumentType", "TextType", "addressToA1Notation", "createSheet", "SheetType", "CanvasType", "DiagramType", "faker", "Filter", "TableType", "createView", "createAsyncGenerator", "range", "generator", "faker", "staticGenerators", "Map", "DocumentType", "typename", "space", "n", "cb", "objects", "range", "map", "obj", "db", "add", "create", "name", "commerce", "productName", "content", "TextType", "lorem", "sentences", "threads", "DiagramType", "canvas", "CanvasType", "SheetType", "cells", "year", "Date", "getFullYear", "cols", "rows", "col", "row", "cell", "addressToA1Notation", "value", "from", "to", "Math", "floor", "random", "createSheet", "createGenerator", "type", "mutableSchema", "schemaRegistry", "query", "schema", "find", "addSchema", "generate", "createAsyncGenerator", "createObjects", "tables", "Filter", "TableType", "run", "table", "view", "split", "pop", "createView", "jsonSchema", "React", "IconButton", "SchemaTable", "types", "objects", "label", "onClick", "div", "className", "map", "type", "key", "typename", "IconButton", "variant", "icon", "iconOnly", "SpaceGenerator", "space", "onCreateObjects", "client", "useClient", "staticTypes", "DocumentType", "DiagramType", "SheetType", "mutableTypes", "Testing", "OrgType", "ProjectType", "ContactType", "count", "setCount", "useState", "info", "setInfo", "typeMap", "useMemo", "addTypes", "mutableGenerators", "Map", "map", "type", "typename", "createGenerator", "staticGenerators", "updateInfo", "mutableSchema", "db", "schemaRegistry", "query", "staticSchema", "graph", "schemas", "objects", "run", "objectMap", "sortKeys", "reduce", "obj", "getTypename", "schema", "static", "length", "mutable", "useAsyncEffect", "handleCreateData", "useCallback", "constructor", "get", "React", "div", "role", "className", "Toolbar", "Root", "classNames", "IconButton", "icon", "iconOnly", "label", "onClick", "Expander", "Input", "TextInput", "min", "max", "placeholder", "value", "onChange", "ev", "parseInt", "target", "SchemaTable", "types", "SyntaxHighlighter", "language", "JSON", "stringify", "jsonKeyReplacer", "truncate", "SpaceGenerator"]
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// packages/plugins/plugin-debug/src/meta.ts
|
|
2
|
-
var DEBUG_PLUGIN = "dxos.org/plugin/debug";
|
|
3
|
-
var meta_default = {
|
|
4
|
-
id: DEBUG_PLUGIN,
|
|
5
|
-
name: "Debug",
|
|
6
|
-
description: "DXOS debugging tools.",
|
|
7
|
-
icon: "ph--bug--regular",
|
|
8
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug",
|
|
9
|
-
tags: [
|
|
10
|
-
"experimental"
|
|
11
|
-
]
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
DEBUG_PLUGIN,
|
|
16
|
-
meta_default
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-CAENAAHY.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const DEBUG_PLUGIN = 'dxos.org/plugin/debug';\n\nexport default {\n id: DEBUG_PLUGIN,\n name: 'Debug',\n description: 'DXOS debugging tools.',\n icon: 'ph--bug--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
|
|
6
|
-
"names": ["DEBUG_PLUGIN", "id", "name", "description", "icon", "source", "tags"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport type { TimerCallback, TimerOptions } from '@dxos/async';\nimport { S } from '@dxos/echo-schema';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\n\nimport { DEBUG_PLUGIN } from './meta';\n\nconst DEBUG_ACTION = `${DEBUG_PLUGIN}/action`;\nexport enum DebugAction {\n OPEN_DEVTOOLS = `${DEBUG_ACTION}/open-devtools`,\n}\n\nexport type DebugContextType = {\n running: boolean;\n start: (cb: TimerCallback, options: TimerOptions) => void;\n stop: () => void;\n};\n\nexport const DebugContext: Context<DebugContextType> = createContext<DebugContextType>({\n running: false,\n start: () => {},\n stop: () => {},\n});\n\nexport const DebugSettingsSchema = S.mutable(\n S.Struct({\n devtools: S.optional(S.Boolean),\n debug: S.optional(S.Boolean),\n wireframe: S.optional(S.Boolean),\n }),\n);\n\nexport interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}\n\nexport type DebugPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n SettingsProvides<DebugSettingsProps> &\n TranslationsProvides &\n PanelProvides;\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAAuBA,qBAAqB;AAU5C,SAASC,SAAS;AAKlB,IAAMC,eAAe,GAAGC,YAAAA;;UACZC,cAAAA;+CACM,GAAGF,YAAAA,gBAA4B,IAAA;GADrCE,gBAAAA,cAAAA,CAAAA,EAAAA;AAUL,IAAMC,eAA0CC,cAAgC;EACrFC,SAAS;EACTC,OAAO,MAAA;EAAO;EACdC,MAAM,MAAA;EAAO;AACf,CAAA;AAEO,IAAMC,sBAAsBC,EAAEC,QACnCD,EAAEE,OAAO;EACPC,UAAUH,EAAEI,SAASJ,EAAEK,OAAO;EAC9BC,OAAON,EAAEI,SAASJ,EAAEK,OAAO;EAC3BE,WAAWP,EAAEI,SAASJ,EAAEK,OAAO;AACjC,CAAA,CAAA;",
|
|
6
|
-
"names": ["createContext", "S", "DEBUG_ACTION", "DEBUG_PLUGIN", "DebugAction", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
3
|
-
export type SurfaceDebugProps = ThemedClassName<{}>;
|
|
4
|
-
/**
|
|
5
|
-
* Show surface info.
|
|
6
|
-
* NOTE: Remove from @dxos/app-framework if removing this.
|
|
7
|
-
*/
|
|
8
|
-
export declare const DebugSurface: ({ classNames }: SurfaceDebugProps) => React.JSX.Element;
|
|
9
|
-
//# sourceMappingURL=DebugSurface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DebugSurface.d.ts","sourceRoot":"","sources":["../../../../src/components/DebugSurface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKpE,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,sBAoC7D,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type DebugInfo, useSurfaceRoot } from '@dxos/app-framework';
|
|
8
|
-
import { Button, Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
10
|
-
|
|
11
|
-
// TODO(burdon): Move to debug panel.
|
|
12
|
-
|
|
13
|
-
export type SurfaceDebugProps = ThemedClassName<{}>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Show surface info.
|
|
17
|
-
* NOTE: Remove from @dxos/app-framework if removing this.
|
|
18
|
-
*/
|
|
19
|
-
export const DebugSurface = ({ classNames }: SurfaceDebugProps) => {
|
|
20
|
-
const context = useSurfaceRoot();
|
|
21
|
-
const [surfaces, setSurfaces] = useState<DebugInfo[]>([]);
|
|
22
|
-
const renderMap = useMemo(() => new Map<string, { last: number; delta: number }>(), []);
|
|
23
|
-
const handleRefresh = () => {
|
|
24
|
-
if (context.debugInfo) {
|
|
25
|
-
setSurfaces(
|
|
26
|
-
Array.from(context.debugInfo.values())
|
|
27
|
-
.sort(({ created: a }, { created: b }) => a - b)
|
|
28
|
-
.map((surface) => {
|
|
29
|
-
const state = renderMap.get(surface.id) ?? { last: 0, delta: 0 };
|
|
30
|
-
renderMap.set(surface.id, { last: surface.renderCount, delta: surface.renderCount - state.last });
|
|
31
|
-
return surface;
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className={mx('flex flex-col border border-separator overflow-hidden bg-modalSurface', classNames)}>
|
|
39
|
-
<div className='flex flex-col h-full w-full p-2'>
|
|
40
|
-
{surfaces.map(({ id, name, renderCount }) => (
|
|
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'>{name}</span>
|
|
43
|
-
<span className='px-1 text-right'>{renderCount}</span>
|
|
44
|
-
<span className='px-1 text-right'>{renderMap.get(id)?.delta}</span>
|
|
45
|
-
</div>
|
|
46
|
-
))}
|
|
47
|
-
</div>
|
|
48
|
-
<div className='flex justify-center text-sm items-center'>
|
|
49
|
-
<Button onClick={handleRefresh}>
|
|
50
|
-
<Icon icon='ph--arrow-clockwise--regular' size={4} />
|
|
51
|
-
</Button>
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
};
|