@dxos/plugin-debug 0.8.3 → 0.8.4-main.1068cf700f

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