@dxos/plugin-debug 0.8.4-main.ae835ea → 0.8.4-main.bc674ce

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 (116) hide show
  1. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +15 -0
  2. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
  3. package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs +19 -0
  4. package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs.map +7 -0
  5. package/dist/lib/browser/{SpaceGenerator-7Q7CX64P.mjs → SpaceGenerator-H33AEFGC.mjs} +226 -233
  6. package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs +598 -0
  8. package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-4UFQXPP7.mjs} +11 -1
  10. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-WZFZ4ESO.mjs → chunk-A5H5GRV6.mjs} +1 -1
  12. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +34 -39
  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-FSWBT3MH.mjs +17 -0
  17. package/dist/lib/browser/react-context-FSWBT3MH.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-2N6CPSHR.mjs +757 -0
  19. package/dist/lib/browser/react-surface-2N6CPSHR.mjs.map +7 -0
  20. package/dist/lib/browser/settings-KA4GN73K.mjs +31 -0
  21. package/dist/lib/browser/settings-KA4GN73K.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +2 -1
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  25. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  27. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/index.d.ts +4 -8
  29. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
  31. package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
  33. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  35. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  37. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  39. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/settings/settings.d.ts +5 -0
  41. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  42. package/dist/types/src/components/DebugGraph.d.ts +5 -4
  43. package/dist/types/src/components/DebugGraph.d.ts.map +1 -1
  44. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
  45. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  46. package/dist/types/src/components/DebugSettings.d.ts +4 -2
  47. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  48. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
  49. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  50. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +2 -2
  51. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  52. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
  54. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  55. package/dist/types/src/components/Wireframe.d.ts +2 -2
  56. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  57. package/dist/types/src/components/index.d.ts +4 -4
  58. package/dist/types/src/components/index.d.ts.map +1 -1
  59. package/dist/types/src/meta.d.ts +2 -2
  60. package/dist/types/src/meta.d.ts.map +1 -1
  61. package/dist/types/src/translations.d.ts +1 -1
  62. package/dist/types/src/types.d.ts +5 -0
  63. package/dist/types/src/types.d.ts.map +1 -1
  64. package/dist/types/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +76 -70
  66. package/src/DebugPlugin.tsx +16 -31
  67. package/src/capabilities/app-graph-builder/app-graph-builder.ts +420 -0
  68. package/src/capabilities/app-graph-builder/index.ts +7 -0
  69. package/src/capabilities/index.ts +4 -6
  70. package/src/capabilities/react-context/index.ts +7 -0
  71. package/src/capabilities/react-context/react-context.tsx +20 -0
  72. package/src/capabilities/react-surface/index.ts +7 -0
  73. package/src/capabilities/react-surface/react-surface.tsx +409 -0
  74. package/src/capabilities/settings/index.ts +7 -0
  75. package/src/capabilities/settings/settings.ts +30 -0
  76. package/src/components/DebugGraph.tsx +4 -3
  77. package/src/components/DebugObjectPanel.tsx +4 -4
  78. package/src/components/DebugSettings.tsx +44 -18
  79. package/src/components/DevtoolsOverviewContainer.tsx +1 -1
  80. package/src/components/SpaceGenerator/ObjectGenerator.tsx +18 -19
  81. package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
  82. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +7 -5
  83. package/src/components/SpaceGenerator/SpaceGenerator.tsx +18 -13
  84. package/src/components/SpaceGenerator/presets.ts +217 -100
  85. package/src/components/Wireframe.tsx +4 -5
  86. package/src/components/index.ts +4 -1
  87. package/src/meta.ts +2 -2
  88. package/src/translations.ts +1 -1
  89. package/src/types.ts +8 -0
  90. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  91. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  92. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  93. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  94. package/dist/lib/browser/SpaceGenerator-7Q7CX64P.mjs.map +0 -7
  95. package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs +0 -588
  96. package/dist/lib/browser/app-graph-builder-RXWTHLEW.mjs.map +0 -7
  97. package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
  98. package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +0 -7
  99. package/dist/lib/browser/react-context-P2YDWEWI.mjs +0 -16
  100. package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +0 -7
  101. package/dist/lib/browser/react-surface-4XGZUT3Z.mjs +0 -772
  102. package/dist/lib/browser/react-surface-4XGZUT3Z.mjs.map +0 -7
  103. package/dist/lib/browser/settings-SQXR3OAH.mjs +0 -22
  104. package/dist/lib/browser/settings-SQXR3OAH.mjs.map +0 -7
  105. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  106. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  107. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  108. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  109. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  110. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  111. package/dist/types/src/capabilities/settings.d.ts +0 -4
  112. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  113. package/src/capabilities/app-graph-builder.ts +0 -431
  114. package/src/capabilities/react-context.tsx +0 -16
  115. package/src/capabilities/react-surface.tsx +0 -399
  116. package/src/capabilities/settings.ts +0 -19
@@ -0,0 +1,757 @@
1
+ import {
2
+ DebugCapabilities,
3
+ Devtools
4
+ } from "./chunk-4UFQXPP7.mjs";
5
+ import {
6
+ meta
7
+ } from "./chunk-A5H5GRV6.mjs";
8
+
9
+ // src/capabilities/react-surface/react-surface.tsx
10
+ import * as Effect from "effect/Effect";
11
+ import React5, { useCallback } from "react";
12
+ import { Capability, Common as Common2 } from "@dxos/app-framework";
13
+ import { useCapability, useLayout, useOperationInvoker, useSettingsState } from "@dxos/app-framework/react";
14
+ import { AutomergePanel, ConfigPanel, CredentialsPanel, DeviceListPanel, DiagnosticsPanel, EdgeDashboardPanel, FeedsPanel, IdentityPanel, InvocationTraceContainer, KeyringPanel, LoggingPanel, MembersPanel, MetadataPanel, NetworkPanel, ObjectsPanel, QueuesPanel, SchemaPanel, SignalPanel, SpaceInfoPanel, SpaceListPanel, StoragePanel, SwarmPanel, TestingPanel, TracingPanel, WorkflowPanel } from "@dxos/devtools";
15
+ import { Obj as Obj2 } from "@dxos/echo";
16
+ import { log as log2 } from "@dxos/log";
17
+ import { ClientCapabilities } from "@dxos/plugin-client";
18
+ import { ScriptOperation } from "@dxos/plugin-script/types";
19
+ import { SpaceOperation } from "@dxos/plugin-space/types";
20
+ import { SpaceState, isSpace, parseId } from "@dxos/react-client/echo";
21
+ import { Layout as Layout2 } from "@dxos/react-ui-mosaic";
22
+ import { Collection } from "@dxos/schema";
23
+
24
+ // src/components/index.ts
25
+ import { lazy } from "react";
26
+
27
+ // src/components/DebugObjectPanel.tsx
28
+ import React from "react";
29
+ import { Clipboard, Input, Toolbar } from "@dxos/react-ui";
30
+ import { Layout } from "@dxos/react-ui-mosaic";
31
+ import { Json } from "@dxos/react-ui-syntax-highlighter";
32
+ var DebugObjectPanel = ({ object }) => {
33
+ const dxn = `dxn:echo:@:${object.id}`;
34
+ return /* @__PURE__ */ React.createElement(Clipboard.Provider, null, /* @__PURE__ */ React.createElement(Layout.Main, {
35
+ toolbar: true
36
+ }, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
37
+ disabled: true,
38
+ value: dxn
39
+ }), /* @__PURE__ */ React.createElement(Clipboard.IconButton, {
40
+ value: dxn
41
+ }))), /* @__PURE__ */ React.createElement(Json, {
42
+ data: object
43
+ })));
44
+ };
45
+
46
+ // src/components/DebugSettings.tsx
47
+ import React2, { useEffect, useState } from "react";
48
+ import { Common } from "@dxos/app-framework";
49
+ import { useCapabilities } from "@dxos/app-framework/react";
50
+ import { SaveConfig, Storage, defs } from "@dxos/config";
51
+ import { log } from "@dxos/log";
52
+ import { useClient } from "@dxos/react-client";
53
+ import { Icon, IconButton, Input as Input2, Select, Toast, useFileDownload, useTranslation } from "@dxos/react-ui";
54
+ import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from "@dxos/react-ui-form";
55
+ import { setDeep } from "@dxos/util";
56
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/DebugSettings.tsx";
57
+ var StorageAdapters = {
58
+ opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
59
+ idb: defs.Runtime.Client.Storage.StorageDriver.IDB
60
+ };
61
+ var DebugSettings = ({ settings, onSettingsChange }) => {
62
+ const { t } = useTranslation(meta.id);
63
+ const [toast, setToast] = useState();
64
+ const client = useClient();
65
+ const download = useFileDownload();
66
+ const [storageConfig, setStorageConfig] = useState({});
67
+ const [upload] = useCapabilities(Common.Capability.FileUploader);
68
+ useEffect(() => {
69
+ void Storage().then((config) => setStorageConfig(config));
70
+ }, []);
71
+ const handleToast = (toast2) => {
72
+ setToast(toast2);
73
+ const t2 = setTimeout(() => setToast(void 0), 5e3);
74
+ return () => clearTimeout(t2);
75
+ };
76
+ const handleDownload = async () => {
77
+ const data = await client.diagnostics();
78
+ const file = new Blob([
79
+ JSON.stringify(data, void 0, 2)
80
+ ], {
81
+ type: "text/plain"
82
+ });
83
+ const fileName = `composer-${(/* @__PURE__ */ new Date()).toISOString().replace(/\W/g, "-")}.json`;
84
+ download(file, fileName);
85
+ if (upload) {
86
+ const info = await upload(client.spaces.default.db, new File([
87
+ file
88
+ ], fileName));
89
+ if (!info) {
90
+ log.error("diagnostics failed to upload to IPFS", void 0, {
91
+ F: __dxlog_file,
92
+ L: 64,
93
+ S: void 0,
94
+ C: (f, a) => f(...a)
95
+ });
96
+ return;
97
+ }
98
+ handleToast({
99
+ title: t("settings uploaded"),
100
+ description: t("settings uploaded to clipboard")
101
+ });
102
+ const url = client.config.values.runtime.services.ipfs.gateway + "/" + info.cid;
103
+ void navigator.clipboard.writeText(url);
104
+ handleToast({
105
+ title: t("settings uploaded"),
106
+ description: t("settings uploaded to clipboard")
107
+ });
108
+ log.info("diagnostics", {
109
+ url
110
+ }, {
111
+ F: __dxlog_file,
112
+ L: 79,
113
+ S: void 0,
114
+ C: (f, a) => f(...a)
115
+ });
116
+ }
117
+ };
118
+ const handleRepair = async () => {
119
+ try {
120
+ const info = await client.repair();
121
+ setStorageConfig(await Storage());
122
+ handleToast({
123
+ title: t("settings repair success"),
124
+ description: JSON.stringify(info, void 0, 2)
125
+ });
126
+ } catch (err) {
127
+ handleToast({
128
+ title: t("settings repair failed"),
129
+ description: err.message
130
+ });
131
+ }
132
+ };
133
+ return /* @__PURE__ */ React2.createElement(ControlPage, null, /* @__PURE__ */ React2.createElement(ControlSection, {
134
+ title: t("settings title", {
135
+ ns: meta.id
136
+ })
137
+ }, /* @__PURE__ */ React2.createElement(ControlGroup, null, /* @__PURE__ */ React2.createElement(ControlItemInput, {
138
+ title: t("settings wireframe")
139
+ }, /* @__PURE__ */ React2.createElement(Input2.Switch, {
140
+ checked: settings.wireframe,
141
+ onCheckedChange: (checked) => onSettingsChange((s) => ({
142
+ ...s,
143
+ wireframe: !!checked
144
+ }))
145
+ })), /* @__PURE__ */ React2.createElement(ControlItemInput, {
146
+ title: t("settings download diagnostics")
147
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
148
+ icon: "ph--download-simple--regular",
149
+ iconOnly: true,
150
+ label: t("settings download diagnostics"),
151
+ onClick: handleDownload
152
+ })), /* @__PURE__ */ React2.createElement(ControlItemInput, {
153
+ title: t("settings repair")
154
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
155
+ icon: "ph--first-aid-kit--regular",
156
+ iconOnly: true,
157
+ label: t("settings repair"),
158
+ onClick: handleRepair
159
+ })), toast && /* @__PURE__ */ React2.createElement(Toast.Root, null, /* @__PURE__ */ React2.createElement(Toast.Body, null, /* @__PURE__ */ React2.createElement(Toast.Title, null, /* @__PURE__ */ React2.createElement(Icon, {
160
+ icon: "ph--gift--duotone",
161
+ size: 5,
162
+ classNames: "inline mr-1"
163
+ }), /* @__PURE__ */ React2.createElement("span", null, toast.title)), toast.description && /* @__PURE__ */ React2.createElement(Toast.Description, null, toast.description))), /* @__PURE__ */ React2.createElement(ControlItemInput, {
164
+ title: t("settings choose storage adaptor")
165
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
166
+ value: Object.entries(StorageAdapters).find(([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore)?.[0],
167
+ onValueChange: (value) => {
168
+ if (confirm(t("settings storage adapter changed alert"))) {
169
+ updateConfig(storageConfig, setStorageConfig, [
170
+ "runtime",
171
+ "client",
172
+ "storage",
173
+ "dataStore"
174
+ ], StorageAdapters[value]);
175
+ }
176
+ }
177
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
178
+ placeholder: t("settings data store label")
179
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, Object.keys(StorageAdapters).map((key) => /* @__PURE__ */ React2.createElement(Select.Option, {
180
+ key,
181
+ value: key
182
+ }, t(`settings storage adaptor ${key} label`)))), /* @__PURE__ */ React2.createElement(Select.Arrow, null))))))));
183
+ };
184
+ var updateConfig = (config, setConfig, path, value) => {
185
+ const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
186
+ setDeep(storageConfigCopy, path, value);
187
+ setConfig(storageConfigCopy);
188
+ queueMicrotask(async () => {
189
+ await SaveConfig(storageConfigCopy);
190
+ });
191
+ };
192
+
193
+ // src/components/DebugStatus.tsx
194
+ import React3, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
195
+ import { TimeoutError } from "@dxos/async";
196
+ import { useActiveSpace } from "@dxos/plugin-space";
197
+ import { StatusBar } from "@dxos/plugin-status-bar";
198
+ import { ConnectionState } from "@dxos/protocols/proto/dxos/client/services";
199
+ import { useNetworkStatus } from "@dxos/react-client/mesh";
200
+ import { Icon as Icon2 } from "@dxos/react-ui";
201
+ var styles = {
202
+ success: "text-sky-300 dark:text-green-700",
203
+ warning: "text-orange-300 dark:text-orange-600",
204
+ error: "text-red-300 dark:text-red-600"
205
+ };
206
+ var ErrorIndicator = () => {
207
+ const [, forceUpdate] = useState2({});
208
+ const errorRef = useRef(null);
209
+ useEffect2(() => {
210
+ const errorListener = (event) => {
211
+ const error = event.error ?? event.reason;
212
+ if (errorRef.current !== error) {
213
+ errorRef.current = error;
214
+ forceUpdate({});
215
+ }
216
+ };
217
+ window.addEventListener("error", errorListener);
218
+ window.addEventListener("unhandledrejection", errorListener);
219
+ return () => {
220
+ window.removeEventListener("error", errorListener);
221
+ window.removeEventListener("unhandledrejection", errorListener);
222
+ };
223
+ }, []);
224
+ const handleReset = () => {
225
+ errorRef.current = null;
226
+ forceUpdate({});
227
+ };
228
+ if (errorRef.current) {
229
+ return /* @__PURE__ */ React3.createElement(StatusBar.Button, {
230
+ title: errorRef.current.message,
231
+ onClick: handleReset
232
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
233
+ icon: "ph--warning-circle--duotone",
234
+ size: 4,
235
+ classNames: styles.error
236
+ }));
237
+ } else {
238
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
239
+ title: "No errors."
240
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
241
+ icon: "ph--check--regular",
242
+ size: 4
243
+ }));
244
+ }
245
+ };
246
+ var SwarmIndicator = () => {
247
+ const [state, setState] = useState2(0);
248
+ const { swarm } = useNetworkStatus();
249
+ useEffect2(() => {
250
+ setState(swarm === ConnectionState.ONLINE ? 0 : 1);
251
+ }, [
252
+ swarm
253
+ ]);
254
+ if (state === 0) {
255
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
256
+ title: "Connected to swarm."
257
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
258
+ icon: "ph--lightning--regular",
259
+ size: 4
260
+ }));
261
+ } else {
262
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
263
+ title: "Disconnected from swarm."
264
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
265
+ icon: "ph--lightning-slash--regular",
266
+ size: 4,
267
+ classNames: styles.warning
268
+ }));
269
+ }
270
+ };
271
+ var SavingIndicator = () => {
272
+ const [state, _setState] = useState2(0);
273
+ const _space = useActiveSpace();
274
+ switch (state) {
275
+ case 2:
276
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
277
+ title: "Edit not saved."
278
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
279
+ icon: "ph--circle--duotone",
280
+ size: 4,
281
+ classNames: styles.warning
282
+ }));
283
+ case 1:
284
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
285
+ title: "Saving..."
286
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
287
+ icon: "ph--circle--duotone",
288
+ size: 4,
289
+ classNames: styles.success
290
+ }));
291
+ case 0:
292
+ default:
293
+ return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
294
+ title: "Modified indicator."
295
+ }, /* @__PURE__ */ React3.createElement(Icon2, {
296
+ icon: "ph--circle--duotone",
297
+ size: 4
298
+ }));
299
+ }
300
+ };
301
+ var indicators = [
302
+ SavingIndicator,
303
+ SwarmIndicator,
304
+ ErrorIndicator
305
+ ];
306
+ var DebugStatus = () => {
307
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, indicators.map((Indicator) => /* @__PURE__ */ React3.createElement(Indicator, {
308
+ key: Indicator.name
309
+ })));
310
+ };
311
+
312
+ // src/components/Wireframe.tsx
313
+ import React4 from "react";
314
+ import { useResizeDetector } from "react-resize-detector";
315
+ import { Obj } from "@dxos/echo";
316
+ import { useAttentionAttributes } from "@dxos/react-ui-attention";
317
+ import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
318
+ import { mx } from "@dxos/ui-theme";
319
+ var Wireframe = ({ classNames, label, object }) => {
320
+ const attentionAttrs = useAttentionAttributes(Obj.getDXN(object).toString());
321
+ const { width, height, ref } = useResizeDetector();
322
+ return /* @__PURE__ */ React4.createElement("div", {
323
+ ref,
324
+ className: mx("relative grow min-bs-96", classNames),
325
+ ...attentionAttrs
326
+ }, /* @__PURE__ */ React4.createElement("div", {
327
+ className: "absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono"
328
+ }, /* @__PURE__ */ React4.createElement("div", {
329
+ className: "flex justify-between"
330
+ }, /* @__PURE__ */ React4.createElement("div", null, label), /* @__PURE__ */ React4.createElement("div", null, `[${width}x${height}]`)), object && /* @__PURE__ */ React4.createElement(SyntaxHighlighter, {
331
+ language: "json",
332
+ classNames: "text-xs opacity-75 rounded"
333
+ }, JSON.stringify(object, void 0, 2))), /* @__PURE__ */ React4.createElement("svg", {
334
+ width,
335
+ height,
336
+ className: "bg-transparent *:text-subdued"
337
+ }, /* @__PURE__ */ React4.createElement("rect", {
338
+ x: 0,
339
+ y: 0,
340
+ width,
341
+ height,
342
+ strokeWidth: 1,
343
+ fill: "none"
344
+ }), /* @__PURE__ */ React4.createElement("line", {
345
+ x1: 0,
346
+ y1: 0,
347
+ x2: width,
348
+ y2: height,
349
+ strokeWidth: 1
350
+ }), /* @__PURE__ */ React4.createElement("line", {
351
+ x1: 0,
352
+ y1: height,
353
+ x2: width,
354
+ y2: 0,
355
+ strokeWidth: 1
356
+ })));
357
+ };
358
+
359
+ // src/components/index.ts
360
+ var DebugGraph = lazy(() => import("./DebugGraph-6VMEOKEV.mjs"));
361
+ var DevtoolsOverviewContainer = lazy(() => import("./DevtoolsOverviewContainer-77PKFLYV.mjs"));
362
+ var SpaceGenerator = lazy(() => import("./SpaceGenerator-H33AEFGC.mjs"));
363
+
364
+ // src/capabilities/react-surface/react-surface.tsx
365
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/capabilities/react-surface/react-surface.tsx";
366
+ var isSpaceDebug = (data) => data?.type === `${meta.id}/space` && isSpace(data.space);
367
+ var isGraphDebug = (data) => {
368
+ const graph = data?.graph;
369
+ return graph != null && typeof graph === "object" && typeof graph.json === "function" && typeof data?.root === "string";
370
+ };
371
+ var useCurrentSpace = () => {
372
+ const layout = useLayout();
373
+ const client = useCapability(ClientCapabilities.Client);
374
+ const { spaceId } = parseId(layout.workspace);
375
+ const space = spaceId ? client.spaces.get(spaceId) : void 0;
376
+ return space;
377
+ };
378
+ var react_surface_default = Capability.makeModule(Effect.fnUntraced(function* () {
379
+ const capabilities = yield* Capability.Service;
380
+ const registry = capabilities.get(Common2.Capability.AtomRegistry);
381
+ const settingsAtom = capabilities.get(DebugCapabilities.Settings);
382
+ return Capability.contributes(Common2.Capability.ReactSurface, [
383
+ Common2.createSurface({
384
+ id: `${meta.id}/plugin-settings`,
385
+ role: "article",
386
+ filter: (data) => Common2.Capability.isSettings(data.subject) && data.subject.prefix === meta.id,
387
+ component: ({ data: { subject } }) => {
388
+ const { settings, updateSettings } = useSettingsState(subject.atom);
389
+ return /* @__PURE__ */ React5.createElement(DebugSettings, {
390
+ settings,
391
+ onSettingsChange: updateSettings
392
+ });
393
+ }
394
+ }),
395
+ Common2.createSurface({
396
+ id: `${meta.id}/space`,
397
+ role: "article",
398
+ filter: (data) => isSpaceDebug(data.subject),
399
+ component: ({ role, data }) => {
400
+ const { invokePromise } = useOperationInvoker();
401
+ const handleCreateObject = useCallback((objects) => {
402
+ if (!isSpace(data.subject.space)) {
403
+ return;
404
+ }
405
+ const collection = data.subject.space.state.get() === SpaceState.SPACE_READY && data.subject.space.properties[Collection.Collection.typename]?.target;
406
+ if (!Obj2.instanceOf(Collection.Collection, collection)) {
407
+ return;
408
+ }
409
+ objects.forEach((object) => {
410
+ void invokePromise(SpaceOperation.AddObject, {
411
+ target: collection,
412
+ object
413
+ });
414
+ });
415
+ }, [
416
+ data.subject.space,
417
+ invokePromise
418
+ ]);
419
+ return /* @__PURE__ */ React5.createElement(Layout2.Main, {
420
+ role
421
+ }, /* @__PURE__ */ React5.createElement(SpaceGenerator, {
422
+ space: data.subject.space,
423
+ onCreateObjects: handleCreateObject
424
+ }));
425
+ }
426
+ }),
427
+ Common2.createSurface({
428
+ id: `${meta.id}/app-graph`,
429
+ role: "article",
430
+ filter: (data) => isGraphDebug(data.subject),
431
+ component: ({ data }) => /* @__PURE__ */ React5.createElement(DebugGraph, {
432
+ graph: data.subject.graph,
433
+ root: data.subject.root
434
+ })
435
+ }),
436
+ Common2.createSurface({
437
+ id: `${meta.id}/wireframe`,
438
+ role: [
439
+ "article",
440
+ "section"
441
+ ],
442
+ position: "hoist",
443
+ filter: (data) => {
444
+ const settings = registry.get(settingsAtom);
445
+ return Obj2.isObject(data.subject) && !!settings.wireframe;
446
+ },
447
+ component: ({ data, role }) => /* @__PURE__ */ React5.createElement(Wireframe, {
448
+ label: `${role}:${name}`,
449
+ object: data.subject,
450
+ classNames: "row-span-2 overflow-hidden"
451
+ })
452
+ }),
453
+ Common2.createSurface({
454
+ id: `${meta.id}/object-debug`,
455
+ role: "article",
456
+ filter: (data) => data.subject === "debug" && Obj2.isObject(data.companionTo),
457
+ component: ({ data }) => /* @__PURE__ */ React5.createElement(DebugObjectPanel, {
458
+ object: data.companionTo
459
+ })
460
+ }),
461
+ Common2.createSurface({
462
+ id: `${meta.id}/devtools-overview`,
463
+ role: "deck-companion--devtools",
464
+ component: () => /* @__PURE__ */ React5.createElement(DevtoolsOverviewContainer, null)
465
+ }),
466
+ Common2.createSurface({
467
+ id: `${meta.id}/status`,
468
+ role: "status",
469
+ component: () => /* @__PURE__ */ React5.createElement(DebugStatus, null)
470
+ }),
471
+ //
472
+ // Devtools
473
+ //
474
+ Common2.createSurface({
475
+ id: `${meta.id}/client/config`,
476
+ role: "article",
477
+ filter: (data) => data.subject === Devtools.Client.Config,
478
+ component: () => /* @__PURE__ */ React5.createElement(ConfigPanel, {
479
+ vaultSelector: false
480
+ })
481
+ }),
482
+ Common2.createSurface({
483
+ id: `${meta.id}/client/storage`,
484
+ role: "article",
485
+ filter: (data) => data.subject === Devtools.Client.Storage,
486
+ component: () => /* @__PURE__ */ React5.createElement(StoragePanel, null)
487
+ }),
488
+ Common2.createSurface({
489
+ id: `${meta.id}/client/logs`,
490
+ role: "article",
491
+ filter: (data) => data.subject === Devtools.Client.Logs,
492
+ component: () => /* @__PURE__ */ React5.createElement(LoggingPanel, null)
493
+ }),
494
+ Common2.createSurface({
495
+ id: `${meta.id}/client/diagnostics`,
496
+ role: "article",
497
+ filter: (data) => data.subject === Devtools.Client.Diagnostics,
498
+ component: () => /* @__PURE__ */ React5.createElement(DiagnosticsPanel, null)
499
+ }),
500
+ Common2.createSurface({
501
+ id: `${meta.id}/client/tracing`,
502
+ role: "article",
503
+ filter: (data) => data.subject === Devtools.Client.Tracing,
504
+ component: () => /* @__PURE__ */ React5.createElement(TracingPanel, null)
505
+ }),
506
+ Common2.createSurface({
507
+ id: `${meta.id}/halo/identity`,
508
+ role: "article",
509
+ filter: (data) => data.subject === Devtools.Halo.Identity,
510
+ component: () => /* @__PURE__ */ React5.createElement(IdentityPanel, null)
511
+ }),
512
+ Common2.createSurface({
513
+ id: `${meta.id}/halo/devices`,
514
+ role: "article",
515
+ filter: (data) => data.subject === Devtools.Halo.Devices,
516
+ component: () => /* @__PURE__ */ React5.createElement(DeviceListPanel, null)
517
+ }),
518
+ Common2.createSurface({
519
+ id: `${meta.id}/halo/keyring`,
520
+ role: "article",
521
+ filter: (data) => data.subject === Devtools.Halo.Keyring,
522
+ component: () => /* @__PURE__ */ React5.createElement(KeyringPanel, null)
523
+ }),
524
+ Common2.createSurface({
525
+ id: `${meta.id}/halo/credentials`,
526
+ role: "article",
527
+ filter: (data) => data.subject === Devtools.Halo.Credentials,
528
+ component: () => {
529
+ const space = useCurrentSpace();
530
+ return /* @__PURE__ */ React5.createElement(CredentialsPanel, {
531
+ space
532
+ });
533
+ }
534
+ }),
535
+ Common2.createSurface({
536
+ id: `${meta.id}/echo/spaces`,
537
+ role: "article",
538
+ filter: (data) => data.subject === Devtools.Echo.Spaces,
539
+ component: () => {
540
+ const { invokePromise } = useOperationInvoker();
541
+ const handleSelect = useCallback(() => invokePromise(Common2.LayoutOperation.Open, {
542
+ subject: [
543
+ Devtools.Echo.Space
544
+ ]
545
+ }), [
546
+ invokePromise
547
+ ]);
548
+ return /* @__PURE__ */ React5.createElement(SpaceListPanel, {
549
+ onSelect: handleSelect
550
+ });
551
+ }
552
+ }),
553
+ Common2.createSurface({
554
+ id: `${meta.id}/echo/space`,
555
+ role: "article",
556
+ filter: (data) => data.subject === Devtools.Echo.Space,
557
+ component: () => {
558
+ const space = useCurrentSpace();
559
+ const { invokePromise } = useOperationInvoker();
560
+ const handleSelect = useCallback(() => invokePromise(Common2.LayoutOperation.Open, {
561
+ subject: [
562
+ Devtools.Echo.Feeds
563
+ ]
564
+ }), [
565
+ invokePromise
566
+ ]);
567
+ return /* @__PURE__ */ React5.createElement(SpaceInfoPanel, {
568
+ space,
569
+ onSelectFeed: handleSelect,
570
+ onSelectPipeline: handleSelect
571
+ });
572
+ }
573
+ }),
574
+ Common2.createSurface({
575
+ id: `${meta.id}/echo/feeds`,
576
+ role: "article",
577
+ filter: (data) => data.subject === Devtools.Echo.Feeds,
578
+ component: () => {
579
+ const space = useCurrentSpace();
580
+ return /* @__PURE__ */ React5.createElement(FeedsPanel, {
581
+ space
582
+ });
583
+ }
584
+ }),
585
+ Common2.createSurface({
586
+ id: `${meta.id}/echo/objects`,
587
+ role: "article",
588
+ filter: (data) => data.subject === Devtools.Echo.Objects,
589
+ component: () => {
590
+ const space = useCurrentSpace();
591
+ return /* @__PURE__ */ React5.createElement(ObjectsPanel, {
592
+ space
593
+ });
594
+ }
595
+ }),
596
+ Common2.createSurface({
597
+ id: `${meta.id}/echo/schema`,
598
+ role: "article",
599
+ filter: (data) => data.subject === Devtools.Echo.Schema,
600
+ component: () => {
601
+ const space = useCurrentSpace();
602
+ return /* @__PURE__ */ React5.createElement(SchemaPanel, {
603
+ space
604
+ });
605
+ }
606
+ }),
607
+ Common2.createSurface({
608
+ id: `${meta.id}/echo/automerge`,
609
+ role: "article",
610
+ filter: (data) => data.subject === Devtools.Echo.Automerge,
611
+ component: () => {
612
+ const space = useCurrentSpace();
613
+ return /* @__PURE__ */ React5.createElement(AutomergePanel, {
614
+ space
615
+ });
616
+ }
617
+ }),
618
+ Common2.createSurface({
619
+ id: `${meta.id}/echo/queues`,
620
+ role: "article",
621
+ filter: (data) => data.subject === Devtools.Echo.Queues,
622
+ component: () => /* @__PURE__ */ React5.createElement(QueuesPanel, null)
623
+ }),
624
+ Common2.createSurface({
625
+ id: `${meta.id}/echo/members`,
626
+ role: "article",
627
+ filter: (data) => data.subject === Devtools.Echo.Members,
628
+ component: () => {
629
+ const space = useCurrentSpace();
630
+ return /* @__PURE__ */ React5.createElement(MembersPanel, {
631
+ space
632
+ });
633
+ }
634
+ }),
635
+ Common2.createSurface({
636
+ id: `${meta.id}/echo/metadata`,
637
+ role: "article",
638
+ filter: (data) => data.subject === Devtools.Echo.Metadata,
639
+ component: () => /* @__PURE__ */ React5.createElement(MetadataPanel, null)
640
+ }),
641
+ Common2.createSurface({
642
+ id: `${meta.id}/mesh/signal`,
643
+ role: "article",
644
+ filter: (data) => data.subject === Devtools.Mesh.Signal,
645
+ component: () => /* @__PURE__ */ React5.createElement(SignalPanel, null)
646
+ }),
647
+ Common2.createSurface({
648
+ id: `${meta.id}/mesh/swarm`,
649
+ role: "article",
650
+ filter: (data) => data.subject === Devtools.Mesh.Swarm,
651
+ component: () => /* @__PURE__ */ React5.createElement(SwarmPanel, null)
652
+ }),
653
+ Common2.createSurface({
654
+ id: `${meta.id}/mesh/network`,
655
+ role: "article",
656
+ filter: (data) => data.subject === Devtools.Mesh.Network,
657
+ component: () => {
658
+ const space = useCurrentSpace();
659
+ return /* @__PURE__ */ React5.createElement(NetworkPanel, {
660
+ space
661
+ });
662
+ }
663
+ }),
664
+ // TODO(wittjosiah): Remove?
665
+ // createSurface({
666
+ // id: `${meta.id}/agent/dashboard`,
667
+ // role: 'article',
668
+ // filter: (data): data is any => data.subject === Devtools.Agent.Dashboard,
669
+ // component: () => <DashboardPanel />,
670
+ // }),
671
+ Common2.createSurface({
672
+ id: `${meta.id}/edge/dashboard`,
673
+ role: "article",
674
+ filter: (data) => data.subject === Devtools.Edge.Dashboard,
675
+ component: () => /* @__PURE__ */ React5.createElement(EdgeDashboardPanel, null)
676
+ }),
677
+ Common2.createSurface({
678
+ id: `${meta.id}/edge/workflows`,
679
+ role: "article",
680
+ filter: (data) => data.subject === Devtools.Edge.Workflows,
681
+ component: () => {
682
+ const space = useCurrentSpace();
683
+ return /* @__PURE__ */ React5.createElement(WorkflowPanel, {
684
+ space
685
+ });
686
+ }
687
+ }),
688
+ Common2.createSurface({
689
+ id: `${meta.id}/edge/traces`,
690
+ role: "article",
691
+ filter: (data) => data.subject === Devtools.Edge.Traces,
692
+ component: () => {
693
+ const space = useCurrentSpace();
694
+ const queueDxn = space?.properties.invocationTraceQueue?.dxn;
695
+ return /* @__PURE__ */ React5.createElement(InvocationTraceContainer, {
696
+ db: space?.db,
697
+ queueDxn,
698
+ detailAxis: "block"
699
+ });
700
+ }
701
+ }),
702
+ Common2.createSurface({
703
+ id: `${meta.id}/edge/testing`,
704
+ role: "article",
705
+ filter: (data) => data.subject === Devtools.Edge.Testing,
706
+ component: () => {
707
+ const { invokePromise } = useOperationInvoker();
708
+ const onSpaceCreate = useCallback(async (space) => {
709
+ await space.waitUntilReady();
710
+ await invokePromise(SpaceOperation.Migrate, {
711
+ space
712
+ });
713
+ await space.db.flush();
714
+ }, [
715
+ invokePromise
716
+ ]);
717
+ const onScriptPluginOpen = useCallback(async (space) => {
718
+ await space.waitUntilReady();
719
+ const createResult = await invokePromise(ScriptOperation.CreateScript, {
720
+ db: space.db
721
+ });
722
+ if (createResult.data?.object) {
723
+ await invokePromise(SpaceOperation.AddObject, {
724
+ target: space.db,
725
+ object: createResult.data.object
726
+ });
727
+ }
728
+ log2.info("script created", {
729
+ result: createResult
730
+ }, {
731
+ F: __dxlog_file2,
732
+ L: 395,
733
+ S: this,
734
+ C: (f, a) => f(...a)
735
+ });
736
+ if (createResult.data?.object?.id) {
737
+ await invokePromise(Common2.LayoutOperation.Open, {
738
+ subject: [
739
+ `${space.id}:${createResult.data.object.id}`
740
+ ]
741
+ });
742
+ }
743
+ }, [
744
+ invokePromise
745
+ ]);
746
+ return /* @__PURE__ */ React5.createElement(TestingPanel, {
747
+ onSpaceCreate,
748
+ onScriptPluginOpen
749
+ });
750
+ }
751
+ })
752
+ ]);
753
+ }));
754
+ export {
755
+ react_surface_default as default
756
+ };
757
+ //# sourceMappingURL=react-surface-2N6CPSHR.mjs.map