@dxos/plugin-debug 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (93) hide show
  1. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
  2. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
  3. package/dist/lib/browser/{DebugSpace-V3K3PQP6.mjs → DebugSpace-BTMTVZ6C.mjs} +7 -5
  4. package/dist/lib/browser/{DebugSpace-V3K3PQP6.mjs.map → DebugSpace-BTMTVZ6C.mjs.map} +3 -3
  5. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs +1238 -0
  6. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs +533 -0
  8. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-EF3UVAVI.mjs +21 -0
  10. package/dist/lib/browser/chunk-EF3UVAVI.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-UASI2CRI.mjs +72 -0
  12. package/dist/lib/browser/chunk-UASI2CRI.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +97 -713
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/react-context-TCD3MNIT.mjs +16 -0
  17. package/dist/lib/browser/react-context-TCD3MNIT.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-W6QLG4YJ.mjs +641 -0
  19. package/dist/lib/browser/react-surface-W6QLG4YJ.mjs.map +7 -0
  20. package/dist/lib/browser/settings-INPXR64L.mjs +24 -0
  21. package/dist/lib/browser/settings-INPXR64L.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +1 -2
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  25. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +185 -0
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  29. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  31. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/settings.d.ts +4 -0
  33. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  34. package/dist/types/src/components/Container.d.ts +2 -2
  35. package/dist/types/src/components/Container.d.ts.map +1 -1
  36. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -2
  37. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  38. package/dist/types/src/components/DebugSettings.d.ts +1 -2
  39. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  40. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts +1 -2
  41. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +1 -1
  42. package/dist/types/src/components/DebugStatus.d.ts +1 -2
  43. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  44. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  45. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts +1 -2
  46. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +1 -1
  47. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -2
  48. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  49. package/dist/types/src/components/SpaceGenerator/presets.d.ts +22 -0
  50. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
  51. package/dist/types/src/components/Wireframe.d.ts +1 -2
  52. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  53. package/dist/types/src/components/index.d.ts +4 -4
  54. package/dist/types/src/components/index.d.ts.map +1 -1
  55. package/dist/types/src/index.d.ts +1 -2
  56. package/dist/types/src/index.d.ts.map +1 -1
  57. package/dist/types/src/meta.d.ts +2 -2
  58. package/dist/types/src/meta.d.ts.map +1 -1
  59. package/dist/types/src/translations.d.ts +28 -0
  60. package/dist/types/src/translations.d.ts.map +1 -1
  61. package/dist/types/src/types.d.ts +44 -4
  62. package/dist/types/src/types.d.ts.map +1 -1
  63. package/dist/types/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +51 -52
  65. package/src/DebugPlugin.tsx +61 -345
  66. package/src/capabilities/app-graph-builder.ts +385 -0
  67. package/src/capabilities/index.ts +10 -0
  68. package/src/capabilities/react-context.tsx +16 -0
  69. package/src/capabilities/react-surface.tsx +307 -0
  70. package/src/capabilities/settings.ts +17 -0
  71. package/src/components/DebugApp/DebugApp.tsx +1 -1
  72. package/src/components/DebugObjectPanel.tsx +17 -5
  73. package/src/components/DebugSettings.tsx +11 -16
  74. package/src/components/DebugSpace/DebugSpace.tsx +1 -1
  75. package/src/components/DebugStatus.tsx +17 -27
  76. package/src/components/SpaceGenerator/ObjectGenerator.tsx +34 -7
  77. package/src/components/SpaceGenerator/SpaceGenerator.tsx +76 -7
  78. package/src/components/SpaceGenerator/presets.ts +563 -0
  79. package/src/index.ts +1 -4
  80. package/src/meta.ts +4 -2
  81. package/src/translations.ts +28 -0
  82. package/src/types.ts +51 -13
  83. package/dist/lib/browser/SpaceGenerator-Y2NXBQVR.mjs +0 -277
  84. package/dist/lib/browser/SpaceGenerator-Y2NXBQVR.mjs.map +0 -7
  85. package/dist/lib/browser/chunk-6CGQHKET.mjs +0 -21
  86. package/dist/lib/browser/chunk-6CGQHKET.mjs.map +0 -7
  87. package/dist/lib/browser/chunk-CAENAAHY.mjs +0 -18
  88. package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
  89. package/dist/lib/browser/meta.mjs +0 -9
  90. package/dist/lib/browser/meta.mjs.map +0 -7
  91. package/dist/types/src/components/DebugSurface.d.ts +0 -9
  92. package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
  93. package/src/components/DebugSurface.tsx +0 -55
package/src/index.ts CHANGED
@@ -2,8 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { DebugPlugin } from './DebugPlugin';
6
-
7
5
  export * from './DebugPlugin';
8
-
9
- export default DebugPlugin;
6
+ export * from './meta';
package/src/meta.ts CHANGED
@@ -6,11 +6,13 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
8
8
 
9
- export default {
9
+ export const meta = {
10
10
  id: DEBUG_PLUGIN,
11
11
  name: 'Debug',
12
- description: 'DXOS debugging tools.',
12
+ description:
13
+ 'The debug plugin is useful for troubleshooting inside of Composer. You can also use the Debug plugin to create test data inside of sheets or tables or explore pre-built automations. Non-technical users will likely not spend much time here, but this plugin is invaluable for developers and technical users.',
13
14
  icon: 'ph--bug--regular',
14
15
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
15
16
  tags: ['experimental'],
17
+ screenshots: ['https://dxos.network/plugin-details-debug-dark.png'],
16
18
  } satisfies PluginMeta;
@@ -31,6 +31,34 @@ export default [
31
31
  'Warning: Swapping the storage adapter will make your data unavailable.',
32
32
  'settings space fragmentation': 'Enable AM space fragmentation',
33
33
  'open debug panel label': 'Show Debug',
34
+ 'client label': 'Client',
35
+ 'config label': 'Config',
36
+ 'storage label': 'Storage',
37
+ 'logs label': 'Logs',
38
+ 'diagnostics label': 'Diagnostics',
39
+ 'tracing label': 'Tracing',
40
+ 'halo label': 'HALO',
41
+ 'identity label': 'Identity',
42
+ 'devices label': 'Devices',
43
+ 'keyring label': 'Keyring',
44
+ 'credentials label': 'Credentials',
45
+ 'echo label': 'ECHO',
46
+ 'spaces label': 'Spaces',
47
+ 'space label': 'Space',
48
+ 'feeds label': 'Feeds',
49
+ 'objects label': 'Objects',
50
+ 'automerge label': 'Automerge',
51
+ 'members label': 'Members',
52
+ 'metadata label': 'Metadata',
53
+ 'mesh label': 'Mesh',
54
+ 'signal label': 'Signal',
55
+ 'swarm label': 'Swarm',
56
+ 'network label': 'Network',
57
+ 'agent label': 'Agent',
58
+ 'dashboard label': 'Dashboard',
59
+ 'search label': 'Search',
60
+ 'edge label': 'Edge',
61
+ 'workflows label': 'Workflows',
34
62
  },
35
63
  },
36
64
  },
package/src/types.ts CHANGED
@@ -4,15 +4,8 @@
4
4
 
5
5
  import { type Context, createContext } from 'react';
6
6
 
7
- import type {
8
- GraphBuilderProvides,
9
- SettingsProvides,
10
- SurfaceProvides,
11
- TranslationsProvides,
12
- } from '@dxos/app-framework';
13
7
  import type { TimerCallback, TimerOptions } from '@dxos/async';
14
8
  import { S } from '@dxos/echo-schema';
15
- import { type PanelProvides } from '@dxos/plugin-deck/types';
16
9
 
17
10
  export type DebugContextType = {
18
11
  running: boolean;
@@ -28,7 +21,6 @@ export const DebugContext: Context<DebugContextType> = createContext<DebugContex
28
21
 
29
22
  export const DebugSettingsSchema = S.mutable(
30
23
  S.Struct({
31
- devtools: S.optional(S.Boolean),
32
24
  debug: S.optional(S.Boolean),
33
25
  wireframe: S.optional(S.Boolean),
34
26
  }),
@@ -36,8 +28,54 @@ export const DebugSettingsSchema = S.mutable(
36
28
 
37
29
  export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
38
30
 
39
- export type DebugPluginProvides = SurfaceProvides &
40
- GraphBuilderProvides &
41
- SettingsProvides<DebugSettingsProps> &
42
- TranslationsProvides &
43
- PanelProvides;
31
+ export namespace Devtools {
32
+ // TODO(wittjosiah): Cannot use slashes in ids until we have a router which decouples ids from url paths.
33
+ export const id = 'dxos.org.plugin.debug.devtools';
34
+
35
+ export namespace Client {
36
+ export const id = `${Devtools.id}.client`;
37
+ export const Config = `${Devtools.Client.id}.config`;
38
+ export const Storage = `${Devtools.Client.id}.storage`;
39
+ export const Logs = `${Devtools.Client.id}.logs`;
40
+ export const Diagnostics = `${Devtools.Client.id}.diagnostics`;
41
+ export const Tracing = `${Devtools.Client.id}.tracing`;
42
+ }
43
+
44
+ export namespace Halo {
45
+ export const id = `${Devtools.id}.halo`;
46
+ export const Identity = `${Devtools.Halo.id}.identity`;
47
+ export const Devices = `${Devtools.Halo.id}.devices`;
48
+ export const Keyring = `${Devtools.Halo.id}.keyring`;
49
+ export const Credentials = `${Devtools.Halo.id}.credentials`;
50
+ }
51
+
52
+ export namespace Echo {
53
+ export const id = `${Devtools.id}.echo`;
54
+ export const Spaces = `${Devtools.Echo.id}.spaces`;
55
+ export const Space = `${Devtools.Echo.id}.space`;
56
+ export const Feeds = `${Devtools.Echo.id}.feeds`;
57
+ export const Objects = `${Devtools.Echo.id}.objects`;
58
+ export const Automerge = `${Devtools.Echo.id}.automerge`;
59
+ export const Members = `${Devtools.Echo.id}.members`;
60
+ export const Metadata = `${Devtools.Echo.id}.metadata`;
61
+ }
62
+
63
+ export namespace Mesh {
64
+ export const id = `${Devtools.id}.mesh`;
65
+ export const Signal = `${Devtools.Mesh.id}.signal`;
66
+ export const Swarm = `${Devtools.Mesh.id}.swarm`;
67
+ export const Network = `${Devtools.Mesh.id}.network`;
68
+ }
69
+
70
+ export namespace Agent {
71
+ export const id = `${Devtools.id}.agent`;
72
+ export const Dashboard = `${Devtools.Agent.id}.dashboard`;
73
+ export const Search = `${Devtools.Agent.id}.search`;
74
+ }
75
+
76
+ export namespace Edge {
77
+ export const id = `${Devtools.id}.edge`;
78
+ export const Dashboard = `${Devtools.Edge.id}.dashboard`;
79
+ export const Workflows = `${Devtools.Edge.id}.workflows`;
80
+ }
81
+ }
@@ -1,277 +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 { addressToA1Notation } from "@dxos/compute";
15
- import { create, makeRef } from "@dxos/live-object";
16
- import { DocumentType, TextType } from "@dxos/plugin-markdown/types";
17
- import { createSheet } from "@dxos/plugin-sheet";
18
- import { SheetType } from "@dxos/plugin-sheet/types";
19
- import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
20
- import { faker } from "@dxos/random";
21
- import { Filter } from "@dxos/react-client/echo";
22
- import { TableType } from "@dxos/react-ui-table";
23
- import { createView } from "@dxos/schema";
24
- import { createAsyncGenerator } from "@dxos/schema/testing";
25
- import { range } from "@dxos/util";
26
- var generator = faker;
27
- var staticGenerators = /* @__PURE__ */ new Map([
28
- [
29
- DocumentType.typename,
30
- async (space, n, cb) => {
31
- const objects = range(n).map(() => {
32
- const obj = space.db.add(create(DocumentType, {
33
- name: faker.commerce.productName(),
34
- content: makeRef(create(TextType, {
35
- content: faker.lorem.sentences(5)
36
- })),
37
- threads: []
38
- }));
39
- return obj;
40
- });
41
- cb?.(objects);
42
- return objects;
43
- }
44
- ],
45
- [
46
- DiagramType.typename,
47
- async (space, n, cb) => {
48
- const objects = range(n).map(() => {
49
- const obj = space.db.add(create(DiagramType, {
50
- name: faker.commerce.productName(),
51
- canvas: makeRef(create(CanvasType, {
52
- content: {}
53
- }))
54
- }));
55
- return obj;
56
- });
57
- cb?.(objects);
58
- return objects;
59
- }
60
- ],
61
- // TODO(burdon): Create unit tests.
62
- [
63
- SheetType.typename,
64
- async (space, n, cb) => {
65
- const objects = range(n).map(() => {
66
- const cells = {};
67
- const year = (/* @__PURE__ */ new Date()).getFullYear();
68
- const cols = 4;
69
- const rows = 16;
70
- for (let col = 1; col <= cols; col++) {
71
- for (let row = 1; row <= rows; row++) {
72
- const cell = addressToA1Notation({
73
- col,
74
- row
75
- });
76
- if (row === 1) {
77
- cells[cell] = {
78
- value: `${year} Q${col}`
79
- };
80
- } else if (row === rows) {
81
- const from = addressToA1Notation({
82
- col,
83
- row: 2
84
- });
85
- const to = addressToA1Notation({
86
- col,
87
- row: rows - 1
88
- });
89
- cells[cell] = {
90
- value: `=SUM(${from}:${to})`
91
- };
92
- } else if (row > 2 && row < rows - 1) {
93
- cells[cell] = {
94
- value: Math.floor(Math.random() * 1e4)
95
- };
96
- }
97
- }
98
- }
99
- return space.db.add(createSheet({
100
- name: faker.commerce.productName(),
101
- cells
102
- }));
103
- });
104
- cb?.(objects);
105
- return objects;
106
- }
107
- ]
108
- ]);
109
- var createGenerator = (type) => {
110
- return async (space, n, cb) => {
111
- const schema = await space.db.schemaRegistry.query({
112
- typename: type.typename
113
- }).firstOrUndefined() ?? (await space.db.schemaRegistry.register([
114
- type
115
- ]))[0];
116
- const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), {
117
- db: space.db
118
- });
119
- const objects = await generate.createObjects(n);
120
- const { objects: tables } = await space.db.query(Filter.schema(TableType)).run();
121
- const table = tables.find((table2) => table2.view?.target?.query?.type === type.typename);
122
- if (!table) {
123
- const name = type.typename.split("/").pop() ?? type.typename;
124
- const view = createView({
125
- name,
126
- typename: type.typename,
127
- jsonSchema: schema.jsonSchema
128
- });
129
- const table2 = space.db.add(create(TableType, {
130
- name,
131
- view: makeRef(view)
132
- }));
133
- cb?.([
134
- table2
135
- ]);
136
- }
137
- return objects;
138
- };
139
- };
140
-
141
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/SchemaTable.tsx
142
- import React from "react";
143
- import { IconButton } from "@dxos/react-ui";
144
- var SchemaTable = ({ types, objects = {}, label, onClick }) => {
145
- return /* @__PURE__ */ React.createElement("div", {
146
- className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-hidden"
147
- }, /* @__PURE__ */ React.createElement("div", {
148
- className: "grid grid-cols-subgrid col-span-3"
149
- }, /* @__PURE__ */ React.createElement("div", {
150
- className: "px-2 text-sm text-primary-500"
151
- }, label), /* @__PURE__ */ React.createElement("div", {
152
- className: "px-2 text-xs text-subdued text-right"
153
- }, "count")), types.map((type) => /* @__PURE__ */ React.createElement("div", {
154
- key: type.typename,
155
- className: "grid grid-cols-subgrid col-span-3 items-center"
156
- }, /* @__PURE__ */ React.createElement("div", {
157
- className: "px-2 text-sm font-mono text-green-500"
158
- }, type.typename), /* @__PURE__ */ React.createElement("div", {
159
- className: "px-2 text-right font-mono"
160
- }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
161
- variant: "ghost",
162
- icon: "ph--plus--regular",
163
- iconOnly: true,
164
- label: "Create data",
165
- onClick: () => onClick(type.typename)
166
- }))));
167
- };
168
-
169
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
170
- var SpaceGenerator = ({ space, onCreateObjects }) => {
171
- const client = useClient();
172
- const staticTypes = [
173
- DocumentType2,
174
- DiagramType2,
175
- SheetType2
176
- ];
177
- const mutableTypes = [
178
- Testing.OrgType,
179
- Testing.ProjectType,
180
- Testing.ContactType
181
- ];
182
- const [count, setCount] = useState(1);
183
- const [info, setInfo] = useState({});
184
- const typeMap = useMemo(() => {
185
- client.addTypes(staticTypes);
186
- const mutableGenerators = new Map(mutableTypes.map((type) => [
187
- type.typename,
188
- createGenerator(type)
189
- ]));
190
- return new Map([
191
- ...staticGenerators,
192
- ...mutableGenerators
193
- ]);
194
- }, [
195
- client,
196
- mutableTypes
197
- ]);
198
- const updateInfo = async () => {
199
- const echoSchema = await space.db.schemaRegistry.query().run();
200
- const staticSchema = space.db.graph.schemaRegistry.schemas;
201
- const { objects } = await space.db.query().run();
202
- const objectMap = sortKeys(objects.reduce((map, obj) => {
203
- const type = getTypename(obj);
204
- if (type) {
205
- const count2 = map[type] ?? 0;
206
- map[type] = count2 + 1;
207
- }
208
- return map;
209
- }, {}));
210
- setInfo({
211
- schema: {
212
- static: staticSchema.length,
213
- mutable: echoSchema.length
214
- },
215
- objects: objectMap
216
- });
217
- };
218
- useAsyncEffect(updateInfo, [
219
- space
220
- ]);
221
- const handleCreateData = useCallback(async (typename) => {
222
- const constructor = typeMap.get(typename);
223
- if (constructor) {
224
- await constructor(space, count, onCreateObjects);
225
- await updateInfo();
226
- }
227
- }, [
228
- typeMap,
229
- count
230
- ]);
231
- return /* @__PURE__ */ React2.createElement("div", {
232
- role: "none",
233
- className: "flex flex-col divide-y divide-separator"
234
- }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
235
- classNames: "p-1"
236
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
237
- icon: "ph--arrow-clockwise--regular",
238
- iconOnly: true,
239
- label: "Refresh",
240
- onClick: updateInfo
241
- }), /* @__PURE__ */ React2.createElement(Toolbar.Expander, null), /* @__PURE__ */ React2.createElement("div", {
242
- className: "flex"
243
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
244
- type: "number",
245
- min: 1,
246
- max: 100,
247
- placeholder: "Count",
248
- classNames: "w-[80px]",
249
- value: count,
250
- onChange: (ev) => setCount(parseInt(ev.target.value))
251
- })))), /* @__PURE__ */ React2.createElement(SchemaTable, {
252
- types: staticTypes,
253
- objects: info.objects,
254
- label: "Static Types",
255
- onClick: handleCreateData
256
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
257
- types: mutableTypes,
258
- objects: info.objects,
259
- label: "Mutable Types",
260
- onClick: handleCreateData
261
- }), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
262
- classNames: "flex text-xs",
263
- language: "json"
264
- }, JSON.stringify({
265
- space,
266
- ...info
267
- }, jsonKeyReplacer({
268
- truncate: true
269
- }), 2)));
270
- };
271
-
272
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/index.ts
273
- var SpaceGenerator_default = SpaceGenerator;
274
- export {
275
- SpaceGenerator_default as default
276
- };
277
- //# sourceMappingURL=SpaceGenerator-Y2NXBQVR.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 echoSchema = await space.db.schemaRegistry.query().run();\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: echoSchema.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 { addressToA1Notation } from '@dxos/compute';\nimport { type BaseObject, type TypedObject } from '@dxos/echo-schema';\nimport { create, makeRef, type ReactiveObject } from '@dxos/live-object';\nimport { DocumentType, TextType } from '@dxos/plugin-markdown/types';\nimport { createSheet } from '@dxos/plugin-sheet';\nimport { SheetType, type CellValue } 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: makeRef(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: makeRef(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: TypedObject<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 schema =\n (await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??\n (await space.db.schemaRegistry.register([type]))[0];\n\n // Create objects.\n const generate = createAsyncGenerator(generator, schema.getSchemaSnapshot(), { 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?.target?.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: makeRef(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,aAAAA,kBAAiB;AAC1B,SAASC,eAAAA,oBAAmB;AAC5B,SAASC,iBAAiB;AAC1B,SAASC,mBAA+B;AACxC,SAASC,cAAAA,aAAYC,OAAOC,SAASC,sBAAsB;AAC3D,SAASC,yBAAyB;AAClC,SAASC,eAAe;AACxB,SAASC,iBAAiBC,gBAAgB;;;ACX1C,SAASC,2BAA2B;AAEpC,SAASC,QAAQC,eAAoC;AACrD,SAASC,cAAcC,gBAAgB;AACvC,SAASC,mBAAmB;AAC5B,SAASC,iBAAiC;AAC1C,SAASC,YAAYC,mBAAmB;AACxC,SAASC,aAAa;AACtB,SAASC,cAA0B;AACnC,SAASC,iBAAiB;AAC1B,SAASC,kBAAkB;AAC3B,SAASC,4BAAiD;AAC1D,SAASC,aAAa;AAEtB,IAAMC,YAA4BC;AAgB3B,IAAMC,mBAAmB,oBAAIC,IAAkC;EACpE;IACEC,aAAaC;IACb,OAAOC,OAAOC,GAAGC,OAAAA;AACf,YAAMC,UAAUC,MAAMH,CAAAA,EAAGI,IAAI,MAAA;AAC3B,cAAMC,MAAMN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,SAASnC;MAClF,gBAAAwB,OAAA,cAACI,QAAQQ,UAAQ,IAAA,GACjB,gBAAAZ,OAAA,cAACC,OAAAA;IAAIE,WAAU;KACb,gBAAAH,OAAA,cAACa,MAAMR,MAAI,MACT,gBAAAL,OAAA,cAACa,MAAMC,WAAS;IACd1C,MAAK;IACL2C,KAAK;IACLC,KAAK;IACLC,aAAa;IACbX,YAAW;IACXY,OAAOzD;IACP0D,UAAU,CAACC,OAAO1D,SAAS2D,SAASD,GAAGE,OAAOJ,KAAK,CAAA;SAM3D,gBAAAlB,OAAA,cAACuB,aAAAA;IAAYC,OAAOxE;IAAaiC,SAASrB,KAAKqB;IAASyB,OAAM;IAAeC,SAASf;MACtF,gBAAAI,OAAA,cAACuB,aAAAA;IAAYC,OAAOpE;IAAc6B,SAASrB,KAAKqB;IAASyB,OAAM;IAAgBC,SAASf;MAExF,gBAAAI,OAAA,cAACyB,mBAAAA;IAAkBnB,YAAW;IAAeoB,UAAS;KACnDC,KAAKC,UAAU;IAAEhF;IAAO,GAAGgB;EAAK,GAAGiE,gBAAgB;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", "addressToA1Notation", "create", "makeRef", "DocumentType", "TextType", "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", "makeRef", "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", "schema", "schemaRegistry", "query", "firstOrUndefined", "register", "generate", "createAsyncGenerator", "getSchemaSnapshot", "createObjects", "tables", "Filter", "TableType", "run", "table", "find", "view", "target", "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", "echoSchema", "db", "schemaRegistry", "query", "run", "staticSchema", "graph", "schemas", "objects", "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,21 +0,0 @@
1
- // packages/plugins/plugin-debug/src/types.ts
2
- import { createContext } from "react";
3
- import { S } from "@dxos/echo-schema";
4
- var DebugContext = createContext({
5
- running: false,
6
- start: () => {
7
- },
8
- stop: () => {
9
- }
10
- });
11
- var DebugSettingsSchema = S.mutable(S.Struct({
12
- devtools: S.optional(S.Boolean),
13
- debug: S.optional(S.Boolean),
14
- wireframe: S.optional(S.Boolean)
15
- }));
16
-
17
- export {
18
- DebugContext,
19
- DebugSettingsSchema
20
- };
21
- //# sourceMappingURL=chunk-6CGQHKET.mjs.map
@@ -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 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\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 GraphBuilderProvides &\n SettingsProvides<DebugSettingsProps> &\n TranslationsProvides &\n PanelProvides;\n"],
5
- "mappings": ";AAIA,SAAuBA,qBAAqB;AAS5C,SAASC,SAAS;AASX,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", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
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,9 +0,0 @@
1
- import {
2
- DEBUG_PLUGIN,
3
- meta_default
4
- } from "./chunk-CAENAAHY.mjs";
5
- export {
6
- DEBUG_PLUGIN,
7
- meta_default as default
8
- };
9
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
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, role, 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'>{role}</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
- };