@dxos/plugin-debug 0.8.3 → 0.8.4-main.f9ba587

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