@dxos/plugin-debug 0.7.5-main.9d2a38b → 0.7.5-main.c41020f

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/{DebugSpace-4JHYA7FG.mjs → DebugSpace-BTMTVZ6C.mjs} +2 -2
  2. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs +1238 -0
  3. package/dist/lib/browser/SpaceGenerator-BPZGOSH4.mjs.map +7 -0
  4. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs +533 -0
  5. package/dist/lib/browser/app-graph-builder-BZFZ6UG6.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-EF3UVAVI.mjs +21 -0
  7. package/dist/lib/browser/chunk-EF3UVAVI.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-UASI2CRI.mjs +72 -0
  9. package/dist/lib/browser/chunk-UASI2CRI.mjs.map +7 -0
  10. package/dist/lib/browser/index.mjs +40 -10
  11. package/dist/lib/browser/index.mjs.map +3 -3
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/react-context-TCD3MNIT.mjs +16 -0
  14. package/dist/lib/browser/react-context-TCD3MNIT.mjs.map +7 -0
  15. package/dist/lib/browser/{react-surface-5GNO6NWP.mjs → react-surface-W6QLG4YJ.mjs} +258 -85
  16. package/dist/lib/browser/react-surface-W6QLG4YJ.mjs.map +7 -0
  17. package/dist/lib/browser/{settings-JCZUA643.mjs → settings-INPXR64L.mjs} +6 -7
  18. package/dist/lib/browser/{settings-JCZUA643.mjs.map → settings-INPXR64L.mjs.map} +3 -3
  19. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  20. package/dist/types/src/capabilities/app-graph-builder.d.ts +110 -110
  21. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/index.d.ts +116 -116
  23. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
  25. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  26. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  27. package/dist/types/src/components/Container.d.ts +2 -2
  28. package/dist/types/src/components/Container.d.ts.map +1 -1
  29. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -2
  30. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  31. package/dist/types/src/components/DebugSettings.d.ts +1 -2
  32. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  33. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts +1 -2
  34. package/dist/types/src/components/DebugSpace/ObjectCreator.d.ts.map +1 -1
  35. package/dist/types/src/components/DebugStatus.d.ts +1 -2
  36. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  37. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  38. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts +1 -2
  39. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +1 -1
  40. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -2
  41. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  42. package/dist/types/src/components/SpaceGenerator/presets.d.ts +22 -0
  43. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -0
  44. package/dist/types/src/components/Wireframe.d.ts +1 -2
  45. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  46. package/dist/types/src/components/index.d.ts +4 -4
  47. package/dist/types/src/components/index.d.ts.map +1 -1
  48. package/dist/types/src/meta.d.ts +1 -0
  49. package/dist/types/src/meta.d.ts.map +1 -1
  50. package/dist/types/src/translations.d.ts +28 -0
  51. package/dist/types/src/translations.d.ts.map +1 -1
  52. package/dist/types/src/types.d.ts +44 -1
  53. package/dist/types/src/types.d.ts.map +1 -1
  54. package/package.json +50 -43
  55. package/src/DebugPlugin.tsx +6 -3
  56. package/src/capabilities/app-graph-builder.ts +297 -89
  57. package/src/capabilities/react-context.tsx +3 -25
  58. package/src/capabilities/react-surface.tsx +202 -33
  59. package/src/capabilities/settings.ts +0 -1
  60. package/src/components/DebugObjectPanel.tsx +17 -5
  61. package/src/components/DebugSettings.tsx +7 -12
  62. package/src/components/DebugStatus.tsx +17 -21
  63. package/src/components/SpaceGenerator/ObjectGenerator.tsx +31 -4
  64. package/src/components/SpaceGenerator/SpaceGenerator.tsx +75 -6
  65. package/src/components/SpaceGenerator/presets.ts +563 -0
  66. package/src/meta.ts +3 -1
  67. package/src/translations.ts +28 -0
  68. package/src/types.ts +52 -1
  69. package/dist/lib/browser/SpaceGenerator-NJCG57CU.mjs +0 -279
  70. package/dist/lib/browser/SpaceGenerator-NJCG57CU.mjs.map +0 -7
  71. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs +0 -177
  72. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs.map +0 -7
  73. package/dist/lib/browser/chunk-I3ON45JK.mjs +0 -18
  74. package/dist/lib/browser/chunk-I3ON45JK.mjs.map +0 -7
  75. package/dist/lib/browser/chunk-P7GHHMDB.mjs +0 -21
  76. package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +0 -7
  77. package/dist/lib/browser/react-context-OZU6J7G3.mjs +0 -37
  78. package/dist/lib/browser/react-context-OZU6J7G3.mjs.map +0 -7
  79. package/dist/lib/browser/react-surface-5GNO6NWP.mjs.map +0 -7
  80. /package/dist/lib/browser/{DebugSpace-4JHYA7FG.mjs.map → DebugSpace-BTMTVZ6C.mjs.map} +0 -0
package/src/meta.ts CHANGED
@@ -9,8 +9,10 @@ export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
9
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
@@ -21,10 +21,61 @@ export const DebugContext: Context<DebugContextType> = createContext<DebugContex
21
21
 
22
22
  export const DebugSettingsSchema = S.mutable(
23
23
  S.Struct({
24
- devtools: S.optional(S.Boolean),
25
24
  debug: S.optional(S.Boolean),
26
25
  wireframe: S.optional(S.Boolean),
27
26
  }),
28
27
  );
29
28
 
30
29
  export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
30
+
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,279 +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 } from "@dxos/plugin-markdown/types";
17
- import { createSheet } from "@dxos/plugin-sheet/types";
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, TextType } 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.Separator, {
242
- variant: "gap"
243
- }), /* @__PURE__ */ React2.createElement("div", {
244
- className: "flex"
245
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
246
- type: "number",
247
- min: 1,
248
- max: 100,
249
- placeholder: "Count",
250
- classNames: "w-[80px]",
251
- value: count,
252
- onChange: (ev) => setCount(parseInt(ev.target.value))
253
- })))), /* @__PURE__ */ React2.createElement(SchemaTable, {
254
- types: staticTypes,
255
- objects: info.objects,
256
- label: "Static Types",
257
- onClick: handleCreateData
258
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
259
- types: mutableTypes,
260
- objects: info.objects,
261
- label: "Mutable Types",
262
- onClick: handleCreateData
263
- }), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
264
- classNames: "flex text-xs",
265
- language: "json"
266
- }, JSON.stringify({
267
- space,
268
- ...info
269
- }, jsonKeyReplacer({
270
- truncate: true
271
- }), 2)));
272
- };
273
-
274
- // packages/plugins/plugin-debug/src/components/SpaceGenerator/index.ts
275
- var SpaceGenerator_default = SpaceGenerator;
276
- export {
277
- SpaceGenerator_default as default
278
- };
279
- //# sourceMappingURL=SpaceGenerator-NJCG57CU.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.Separator variant='gap' />\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 } from '@dxos/plugin-markdown/types';\nimport { createSheet } from '@dxos/plugin-sheet/types';\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, TextType } 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,oBAAoB;AAC7B,SAASC,mBAAmB;AAC5B,SAASC,iBAAiC;AAC1C,SAASC,YAAYC,mBAAmB;AACxC,SAASC,aAAa;AACtB,SAASC,cAA0B;AACnC,SAASC,iBAAiB;AAC1B,SAASC,YAAYC,gBAAgB;AACrC,SAASC,4BAAiD;A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;GAAM;AAGlB,SACE,gBAAAuC,OAAA,cAACC,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACzB,gBAAAH,OAAA,cAACI,QAAQC,MAAI;IAACC,YAAW;KACvB,gBAAAN,OAAA,cAACO,aAAAA;IAAWC,MAAK;IAA+BC,UAAAA;IAASC,OAAM;IAAUC,SAASnC;MAClF,gBAAAwB,OAAA,cAACI,QAAQQ,WAAS;IAACC,SAAQ;MAC3B,gBAAAb,OAAA,cAACC,OAAAA;IAAIE,WAAU;KACb,gBAAAH,OAAA,cAACc,MAAMT,MAAI,MACT,gBAAAL,OAAA,cAACc,MAAMC,WAAS;IACd3C,MAAK;IACL4C,KAAK;IACLC,KAAK;IACLC,aAAa;IACbZ,YAAW;IACXa,OAAO1D;IACP2D,UAAU,CAACC,OAAO3D,SAAS4D,SAASD,GAAGE,OAAOJ,KAAK,CAAA;SAM3D,gBAAAnB,OAAA,cAACwB,aAAAA;IAAYC,OAAOzE;IAAaiC,SAASrB,KAAKqB;IAASyB,OAAM;IAAeC,SAASf;MACtF,gBAAAI,OAAA,cAACwB,aAAAA;IAAYC,OAAOrE;IAAc6B,SAASrB,KAAKqB;IAASyB,OAAM;IAAgBC,SAASf;MAExF,gBAAAI,OAAA,cAAC0B,mBAAAA;IAAkBpB,YAAW;IAAeqB,UAAS;KACnDC,KAAKC,UAAU;IAAEjF;IAAO,GAAGgB;EAAK,GAAGkE,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", "createSheet", "SheetType", "CanvasType", "DiagramType", "faker", "Filter", "TableType", "createView", "TextType", "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", "Separator", "variant", "Input", "TextInput", "min", "max", "placeholder", "value", "onChange", "ev", "parseInt", "target", "SchemaTable", "types", "SyntaxHighlighter", "language", "JSON", "stringify", "jsonKeyReplacer", "truncate", "SpaceGenerator"]
7
- }
@@ -1,177 +0,0 @@
1
- import {
2
- DEBUG_PLUGIN
3
- } from "./chunk-I3ON45JK.mjs";
4
-
5
- // packages/plugins/plugin-debug/src/capabilities/app-graph-builder.ts
6
- import { contributes, Capabilities } from "@dxos/app-framework";
7
- import { ClientCapabilities } from "@dxos/plugin-client";
8
- import { createExtension, toSignal } from "@dxos/plugin-graph";
9
- import { memoizeQuery } from "@dxos/plugin-space";
10
- import { CollectionType } from "@dxos/plugin-space/types";
11
- import { getTypename, parseId, SpaceState } from "@dxos/react-client/echo";
12
- import { isSpace } from "@dxos/react-client/echo";
13
- var app_graph_builder_default = (context) => {
14
- const resolve = (typename) => context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
15
- return contributes(Capabilities.AppGraphBuilder, [
16
- // Devtools node.
17
- createExtension({
18
- id: "dxos.org/plugin/debug/devtools",
19
- filter: (node) => {
20
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
21
- return !!settings?.devtools && node.id === "root";
22
- },
23
- connector: () => [
24
- {
25
- // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
26
- id: "dxos.org.plugin.debug.devtools",
27
- data: "devtools",
28
- type: "dxos.org/plugin/debug/devtools",
29
- properties: {
30
- label: [
31
- "devtools label",
32
- {
33
- ns: DEBUG_PLUGIN
34
- }
35
- ],
36
- icon: "ph--hammer--regular"
37
- }
38
- }
39
- ]
40
- }),
41
- // Debug node.
42
- createExtension({
43
- id: "dxos.org/plugin/debug/debug",
44
- filter: (node) => {
45
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
46
- return !!settings?.debug && node.id === "root";
47
- },
48
- connector: () => {
49
- const graph = context.requestCapability(Capabilities.AppGraph);
50
- return [
51
- {
52
- id: "dxos.org/plugin/debug/debug",
53
- type: "dxos.org/plugin/debug/debug",
54
- data: {
55
- graph
56
- },
57
- properties: {
58
- label: [
59
- "debug label",
60
- {
61
- ns: DEBUG_PLUGIN
62
- }
63
- ],
64
- icon: "ph--bug--regular"
65
- }
66
- }
67
- ];
68
- }
69
- }),
70
- // Space debug nodes.
71
- createExtension({
72
- id: "dxos.org/plugin/debug/spaces",
73
- filter: (node) => {
74
- const settings = context.requestCapabilities(Capabilities.SettingsStore)[0]?.getStore(DEBUG_PLUGIN)?.value;
75
- return !!settings?.debug && isSpace(node.data);
76
- },
77
- connector: ({ node }) => {
78
- const space = node.data;
79
- const state = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
80
- if (state !== SpaceState.SPACE_READY) {
81
- return;
82
- }
83
- const collection = space.properties[CollectionType.typename]?.target;
84
- if (!collection) {
85
- return;
86
- }
87
- return [
88
- {
89
- id: `${space.id}-debug`,
90
- type: "dxos.org/plugin/debug/space",
91
- data: {
92
- space,
93
- type: "dxos.org/plugin/debug/space"
94
- },
95
- properties: {
96
- label: [
97
- "debug label",
98
- {
99
- ns: DEBUG_PLUGIN
100
- }
101
- ],
102
- icon: "ph--bug--regular"
103
- }
104
- }
105
- ];
106
- }
107
- }),
108
- // Create nodes for debug sidebar.
109
- createExtension({
110
- id: `${DEBUG_PLUGIN}/debug-for-subject`,
111
- resolver: ({ id }) => {
112
- if (!id.endsWith("~debug")) {
113
- return;
114
- }
115
- const type = "orphan-settings-for-subject";
116
- const icon = "ph--bug--regular";
117
- const client = context.requestCapability(ClientCapabilities.Client);
118
- const [subjectId] = id.split("~");
119
- const { spaceId, objectId } = parseId(subjectId);
120
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
121
- const space = spaces?.find((space2) => space2.state.get() === SpaceState.SPACE_READY && space2.id === spaceId);
122
- if (!objectId) {
123
- const label2 = space ? space.properties.name || [
124
- "unnamed space label",
125
- {
126
- ns: DEBUG_PLUGIN
127
- }
128
- ] : [
129
- "unnamed object settings label",
130
- {
131
- ns: DEBUG_PLUGIN
132
- }
133
- ];
134
- return {
135
- id,
136
- type,
137
- data: null,
138
- properties: {
139
- icon,
140
- label: label2,
141
- showResolvedThreads: false,
142
- object: null,
143
- space
144
- }
145
- };
146
- }
147
- const [object] = memoizeQuery(space, {
148
- id: objectId
149
- });
150
- if (!object || !subjectId) {
151
- return;
152
- }
153
- const meta = resolve(getTypename(object) ?? "");
154
- const label = meta.label?.(object) || object.name || meta.placeholder || [
155
- "unnamed object settings label",
156
- {
157
- ns: DEBUG_PLUGIN
158
- }
159
- ];
160
- return {
161
- id,
162
- type,
163
- data: null,
164
- properties: {
165
- icon,
166
- label,
167
- object
168
- }
169
- };
170
- }
171
- })
172
- ]);
173
- };
174
- export {
175
- app_graph_builder_default as default
176
- };
177
- //# sourceMappingURL=app-graph-builder-FXELWOFS.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { contributes, Capabilities, type PluginsContext } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { createExtension, toSignal, type Node } from '@dxos/plugin-graph';\nimport { memoizeQuery } from '@dxos/plugin-space';\nimport { CollectionType } from '@dxos/plugin-space/types';\nimport { getTypename, parseId, SpaceState } from '@dxos/react-client/echo';\nimport { isSpace, type Space } from '@dxos/react-client/echo';\n\nimport { DEBUG_PLUGIN } from '../meta';\nimport { type DebugSettingsProps } from '../types';\n\nexport default (context: PluginsContext) => {\n const resolve = (typename: string) =>\n context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};\n\n return contributes(Capabilities.AppGraphBuilder, [\n // Devtools node.\n createExtension({\n id: 'dxos.org/plugin/debug/devtools',\n filter: (node): node is Node<null> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.devtools && node.id === 'root';\n },\n connector: () => [\n {\n // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?\n id: 'dxos.org.plugin.debug.devtools',\n data: 'devtools',\n type: 'dxos.org/plugin/debug/devtools',\n properties: {\n label: ['devtools label', { ns: DEBUG_PLUGIN }],\n icon: 'ph--hammer--regular',\n },\n },\n ],\n }),\n\n // Debug node.\n createExtension({\n id: 'dxos.org/plugin/debug/debug',\n filter: (node): node is Node<null> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.debug && node.id === 'root';\n },\n connector: () => {\n const graph = context.requestCapability(Capabilities.AppGraph);\n\n return [\n {\n id: 'dxos.org/plugin/debug/debug',\n type: 'dxos.org/plugin/debug/debug',\n data: { graph },\n properties: {\n label: ['debug label', { ns: DEBUG_PLUGIN }],\n icon: 'ph--bug--regular',\n },\n },\n ];\n },\n }),\n\n // Space debug nodes.\n createExtension({\n id: 'dxos.org/plugin/debug/spaces',\n filter: (node): node is Node<Space> => {\n const settings = context\n .requestCapabilities(Capabilities.SettingsStore)[0]\n ?.getStore<DebugSettingsProps>(DEBUG_PLUGIN)?.value;\n return !!settings?.debug && isSpace(node.data);\n },\n connector: ({ node }) => {\n const space = node.data;\n const state = toSignal(\n (onChange) => space.state.subscribe(() => onChange()).unsubscribe,\n () => space.state.get(),\n space.id,\n );\n if (state !== SpaceState.SPACE_READY) {\n return;\n }\n\n // Not adding the debug node until the root collection is available aligns the behaviour of this\n // extension with that of the space plugin adding objects. This ensures that the debug node is added at\n // the same time as objects and prevents order from changing as the nodes are added.\n const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;\n if (!collection) {\n return;\n }\n\n return [\n {\n id: `${space.id}-debug`, // TODO(burdon): Change to slashes consistently.\n type: 'dxos.org/plugin/debug/space',\n data: { space, type: 'dxos.org/plugin/debug/space' },\n properties: {\n label: ['debug label', { ns: DEBUG_PLUGIN }],\n icon: 'ph--bug--regular',\n },\n },\n ];\n },\n }),\n\n // Create nodes for debug sidebar.\n createExtension({\n id: `${DEBUG_PLUGIN}/debug-for-subject`,\n resolver: ({ id }) => {\n // TODO(Zan): Find util (or make one).\n if (!id.endsWith('~debug')) {\n return;\n }\n\n const type = 'orphan-settings-for-subject';\n const icon = 'ph--bug--regular';\n\n const client = context.requestCapability(ClientCapabilities.Client);\n const [subjectId] = id.split('~');\n const { spaceId, objectId } = parseId(subjectId);\n const spaces = toSignal(\n (onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,\n () => client.spaces.get(),\n );\n const space = spaces?.find((space) => space.state.get() === SpaceState.SPACE_READY && space.id === spaceId);\n if (!objectId) {\n // TODO(burdon): Ref SPACE_PLUGIN ns.\n const label = space\n ? space.properties.name || ['unnamed space label', { ns: DEBUG_PLUGIN }]\n : ['unnamed object settings label', { ns: DEBUG_PLUGIN }];\n\n // TODO(wittjosiah): Support comments for arbitrary subjects.\n // This is to ensure that the comments panel is not stuck on an old object.\n return {\n id,\n type,\n data: null,\n properties: {\n icon,\n label,\n showResolvedThreads: false,\n object: null,\n space,\n },\n };\n }\n\n const [object] = memoizeQuery(space, { id: objectId });\n if (!object || !subjectId) {\n return;\n }\n\n const meta = resolve(getTypename(object) ?? '');\n const label = meta.label?.(object) ||\n object.name ||\n meta.placeholder || ['unnamed object settings label', { ns: DEBUG_PLUGIN }];\n\n return {\n id,\n type,\n data: null,\n properties: {\n icon,\n label,\n object,\n },\n };\n },\n }),\n ]);\n};\n"],
5
- "mappings": ";;;;;AAIA,SAASA,aAAaC,oBAAyC;AAC/D,SAASC,0BAA0B;AACnC,SAASC,iBAAiBC,gBAA2B;AACrD,SAASC,oBAAoB;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,aAAaC,SAASC,kBAAkB;AACjD,SAASC,eAA2B;AAKpC,IAAA,4BAAe,CAACC,YAAAA;AACd,QAAMC,UAAU,CAACC,aACfF,QAAQG,oBAAoBC,aAAaC,QAAQ,EAAEC,KAAK,CAAC,EAAEC,GAAE,MAAOA,OAAOL,QAAAA,GAAWM,YAAY,CAAC;AAErG,SAAOC,YAAYL,aAAaM,iBAAiB;;IAE/CC,gBAAgB;MACdJ,IAAI;MACJK,QAAQ,CAACC,SAAAA;AACP,cAAMC,WAAWd,QACdG,oBAAoBC,aAAaW,aAAa,EAAE,CAAA,GAC/CC,S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AACzB;QACF;AAEA,cAAMU,OAAO1D,QAAQ2D,YAAYH,MAAAA,KAAW,EAAA;AAC5C,cAAMjC,QAAQmC,KAAKnC,QAAQiC,MAAAA,KACzBA,OAAOF,QACPI,KAAKE,eAAe;UAAC;UAAiC;YAAEpC,IAAIR;UAAa;;AAE3E,eAAO;UACLV;UACAe;UACAD,MAAM;UACNE,YAAY;YACVG;YACAF;YACAiC;UACF;QACF;MACF;IACF,CAAA;GACD;AACH;",
6
- "names": ["contributes", "Capabilities", "ClientCapabilities", "createExtension", "toSignal", "memoizeQuery", "CollectionType", "getTypename", "parseId", "SpaceState", "isSpace", "context", "resolve", "typename", "requestCapabilities", "Capabilities", "Metadata", "find", "id", "metadata", "contributes", "AppGraphBuilder", "createExtension", "filter", "node", "settings", "SettingsStore", "getStore", "DEBUG_PLUGIN", "value", "devtools", "connector", "data", "type", "properties", "label", "ns", "icon", "debug", "graph", "requestCapability", "AppGraph", "isSpace", "space", "state", "toSignal", "onChange", "subscribe", "unsubscribe", "get", "SpaceState", "SPACE_READY", "collection", "CollectionType", "target", "resolver", "endsWith", "client", "ClientCapabilities", "Client", "subjectId", "split", "spaceId", "objectId", "parseId", "spaces", "name", "showResolvedThreads", "object", "memoizeQuery", "meta", "getTypename", "placeholder"]
7
- }
@@ -1,18 +0,0 @@
1
- // packages/plugins/plugin-debug/src/meta.ts
2
- var DEBUG_PLUGIN = "dxos.org/plugin/debug";
3
- var meta = {
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
17
- };
18
- //# sourceMappingURL=chunk-I3ON45JK.mjs.map