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