@dxos/plugin-debug 0.7.4 → 0.7.5-labs.a279d8c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
  2. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
  3. package/dist/lib/browser/{DebugSpace-DHKEAMIC.mjs → DebugSpace-4JHYA7FG.mjs} +7 -6
  4. package/dist/lib/browser/DebugSpace-4JHYA7FG.mjs.map +7 -0
  5. package/dist/lib/browser/{SpaceGenerator-BQ3645OS.mjs → SpaceGenerator-YNT3WDFI.mjs} +226 -20
  6. package/dist/lib/browser/SpaceGenerator-YNT3WDFI.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs +177 -0
  8. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-CAENAAHY.mjs → chunk-I3ON45JK.mjs} +3 -3
  10. package/dist/lib/browser/chunk-I3ON45JK.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-LZEK532R.mjs → chunk-P7GHHMDB.mjs} +1 -11
  12. package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +66 -737
  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-OZU6J7G3.mjs +37 -0
  17. package/dist/lib/browser/react-context-OZU6J7G3.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-ACHNR2UU.mjs +481 -0
  19. package/dist/lib/browser/react-surface-ACHNR2UU.mjs.map +7 -0
  20. package/dist/lib/browser/settings-JCZUA643.mjs +25 -0
  21. package/dist/lib/browser/settings-JCZUA643.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +1 -2
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  25. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +185 -0
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  29. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  31. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/settings.d.ts +4 -0
  33. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  34. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  35. package/dist/types/src/components/DebugSpace/DebugSpace.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/DebugSpace/ObjectCreator.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  38. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +2 -2
  39. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  40. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  41. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  42. package/dist/types/src/components/Wireframe.d.ts +2 -1
  43. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  44. package/dist/types/src/index.d.ts +1 -2
  45. package/dist/types/src/index.d.ts.map +1 -1
  46. package/dist/types/src/meta.d.ts +1 -2
  47. package/dist/types/src/meta.d.ts.map +1 -1
  48. package/dist/types/src/types.d.ts +0 -6
  49. package/dist/types/src/types.d.ts.map +1 -1
  50. package/dist/types/tsconfig.tsbuildinfo +1 -0
  51. package/package.json +48 -51
  52. package/src/DebugPlugin.tsx +60 -381
  53. package/src/capabilities/app-graph-builder.ts +177 -0
  54. package/src/capabilities/index.ts +10 -0
  55. package/src/capabilities/react-context.tsx +38 -0
  56. package/src/capabilities/react-surface.tsx +138 -0
  57. package/src/capabilities/settings.ts +18 -0
  58. package/src/components/DebugApp/DebugApp.tsx +1 -1
  59. package/src/components/DebugObjectPanel.tsx +17 -5
  60. package/src/components/DebugSettings.tsx +4 -4
  61. package/src/components/DebugSpace/DebugSpace.stories.tsx +4 -3
  62. package/src/components/DebugSpace/DebugSpace.tsx +1 -1
  63. package/src/components/DebugSpace/ObjectCreator.stories.tsx +4 -3
  64. package/src/components/DebugStatus.tsx +3 -9
  65. package/src/components/SpaceGenerator/ObjectGenerator.tsx +126 -18
  66. package/src/components/SpaceGenerator/SpaceGenerator.tsx +6 -4
  67. package/src/components/SpaceGenerator/draw-util.ts +7 -6
  68. package/src/components/Wireframe.tsx +2 -2
  69. package/src/index.ts +1 -4
  70. package/src/meta.ts +1 -1
  71. package/src/types.ts +0 -22
  72. package/dist/lib/browser/DebugSpace-DHKEAMIC.mjs.map +0 -7
  73. package/dist/lib/browser/SpaceGenerator-BQ3645OS.mjs.map +0 -7
  74. package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
  75. package/dist/lib/browser/chunk-LZEK532R.mjs.map +0 -7
  76. package/dist/lib/browser/meta.mjs +0 -9
  77. package/dist/lib/browser/meta.mjs.map +0 -7
  78. package/dist/types/src/components/DebugSurface.d.ts +0 -9
  79. package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
  80. package/src/components/DebugSurface.tsx +0 -55
@@ -1,394 +1,18 @@
1
- import {
2
- DebugAction,
3
- DebugContext,
4
- DebugSettingsSchema
5
- } from "./chunk-LZEK532R.mjs";
6
1
  import {
7
2
  DEBUG_PLUGIN,
8
- meta_default
9
- } from "./chunk-CAENAAHY.mjs";
3
+ meta
4
+ } from "./chunk-I3ON45JK.mjs";
10
5
 
11
6
  // packages/plugins/plugin-debug/src/DebugPlugin.tsx
12
- import React5, { useEffect as useEffect3, useState as useState3 } from "react";
13
- import { definePlugin, parseGraphPlugin as parseGraphPlugin2, parseIntentPlugin, parseMetadataResolverPlugin, parseSettingsPlugin, resolvePlugin } from "@dxos/app-framework";
14
- import { Timer } from "@dxos/async";
15
- import { Devtools } from "@dxos/devtools";
16
- import { invariant } from "@dxos/invariant";
17
- import { parseClientPlugin } from "@dxos/plugin-client";
18
- import { createExtension, Graph, toSignal } from "@dxos/plugin-graph";
19
- import { memoizeQuery, SpaceAction } from "@dxos/plugin-space";
20
- import { CollectionType } from "@dxos/plugin-space/types";
21
- import { create, getTypename, isEchoObject, isSpace, parseId, SpaceState } from "@dxos/react-client/echo";
22
- import { Main } from "@dxos/react-ui";
23
- import { baseSurface, bottombarBlockPaddingEnd, fixedInsetFlexLayout, topbarBlockPaddingStart } from "@dxos/react-ui-theme";
24
-
25
- // packages/plugins/plugin-debug/src/components/index.ts
26
- import { lazy } from "react";
7
+ import { Capabilities, contributes, defineModule, definePlugin, Events } from "@dxos/app-framework";
8
+ import { DeckCapabilities } from "@dxos/plugin-deck";
27
9
 
28
- // packages/plugins/plugin-debug/src/components/DebugObjectPanel.tsx
29
- import React from "react";
30
- import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
31
- var DebugObjectPanel = ({ object }) => {
32
- return /* @__PURE__ */ React.createElement("div", {
33
- className: "flex flex-col"
34
- }, /* @__PURE__ */ React.createElement(SyntaxHighlighter, {
35
- classNames: "flex text-xs",
36
- language: "json"
37
- }, JSON.stringify(object, null, 2)));
38
- };
39
-
40
- // packages/plugins/plugin-debug/src/components/DebugSettings.tsx
41
- import { Gift, DownloadSimple, FirstAidKit } from "@phosphor-icons/react";
42
- import React2, { useEffect, useState } from "react";
43
- import { parseFileManagerPlugin, useResolvePlugin } from "@dxos/app-framework";
44
- import { defs, SaveConfig, Storage } from "@dxos/config";
45
- import { log } from "@dxos/log";
46
- import { useClient } from "@dxos/react-client";
47
- import { useTranslation, Button, Toast, Input, useFileDownload, Select } from "@dxos/react-ui";
48
- import { DeprecatedFormInput } from "@dxos/react-ui-form";
49
- import { getSize, mx } from "@dxos/react-ui-theme";
50
- import { setDeep } from "@dxos/util";
51
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/DebugSettings.tsx";
52
- var StorageAdapters = {
53
- opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
54
- idb: defs.Runtime.Client.Storage.StorageDriver.IDB
55
- };
56
- var DebugSettings = ({ settings }) => {
57
- const { t } = useTranslation(DEBUG_PLUGIN);
58
- const [toast, setToast] = useState();
59
- const client = useClient();
60
- const download = useFileDownload();
61
- const [storageConfig, setStorageConfig] = useState({});
62
- const fileManagerPlugin = useResolvePlugin(parseFileManagerPlugin);
63
- useEffect(() => {
64
- void Storage().then((config) => setStorageConfig(config));
65
- }, []);
66
- const handleToast = (toast2) => {
67
- setToast(toast2);
68
- const t2 = setTimeout(() => setToast(void 0), 5e3);
69
- return () => clearTimeout(t2);
70
- };
71
- const handleDownload = async () => {
72
- const data = await client.diagnostics();
73
- const file = new Blob([
74
- JSON.stringify(data, void 0, 2)
75
- ], {
76
- type: "text/plain"
77
- });
78
- const fileName = `composer-${(/* @__PURE__ */ new Date()).toISOString().replace(/\W/g, "-")}.json`;
79
- download(file, fileName);
80
- if (fileManagerPlugin?.provides.file.upload) {
81
- const info = await fileManagerPlugin.provides.file.upload(new File([
82
- file
83
- ], fileName), client.spaces.default);
84
- if (!info) {
85
- log.error("diagnostics failed to upload to IPFS", void 0, {
86
- F: __dxlog_file,
87
- L: 58,
88
- S: void 0,
89
- C: (f, a) => f(...a)
90
- });
91
- return;
92
- }
93
- handleToast({
94
- title: t("settings uploaded"),
95
- description: t("settings uploaded to clipboard")
96
- });
97
- const url = client.config.values.runtime.services.ipfs.gateway + "/" + info.cid;
98
- void navigator.clipboard.writeText(url);
99
- handleToast({
100
- title: t("settings uploaded"),
101
- description: t("settings uploaded to clipboard")
102
- });
103
- log.info("diagnostics", {
104
- url
105
- }, {
106
- F: __dxlog_file,
107
- L: 67,
108
- S: void 0,
109
- C: (f, a) => f(...a)
110
- });
111
- }
112
- };
113
- const handleRepair = async () => {
114
- try {
115
- const info = await client.repair();
116
- setStorageConfig(await Storage());
117
- handleToast({
118
- title: t("settings repair success"),
119
- description: JSON.stringify(info, void 0, 2)
120
- });
121
- } catch (err) {
122
- handleToast({
123
- title: t("settings repair failed"),
124
- description: err.message
125
- });
126
- }
127
- };
128
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
129
- label: t("settings show debug panel")
130
- }, /* @__PURE__ */ React2.createElement(Input.Switch, {
131
- checked: settings.debug,
132
- onCheckedChange: (checked) => settings.debug = !!checked
133
- })), /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
134
- label: t("settings show devtools panel")
135
- }, /* @__PURE__ */ React2.createElement(Input.Switch, {
136
- checked: settings.devtools,
137
- onCheckedChange: (checked) => settings.devtools = !!checked
138
- })), /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
139
- label: t("settings wireframe")
140
- }, /* @__PURE__ */ React2.createElement(Input.Switch, {
141
- checked: settings.wireframe,
142
- onCheckedChange: (checked) => settings.wireframe = !!checked
143
- })), /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
144
- label: t("settings download diagnostics")
145
- }, /* @__PURE__ */ React2.createElement(Button, {
146
- onClick: handleDownload
147
- }, /* @__PURE__ */ React2.createElement(DownloadSimple, {
148
- className: getSize(5)
149
- }))), /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
150
- label: t("settings repair")
151
- }, /* @__PURE__ */ React2.createElement(Button, {
152
- onClick: handleRepair
153
- }, /* @__PURE__ */ React2.createElement(FirstAidKit, {
154
- className: getSize(5)
155
- }))), toast && /* @__PURE__ */ React2.createElement(Toast.Root, null, /* @__PURE__ */ React2.createElement(Toast.Body, null, /* @__PURE__ */ React2.createElement(Toast.Title, null, /* @__PURE__ */ React2.createElement(Gift, {
156
- className: mx(getSize(5), "inline mr-1"),
157
- weight: "duotone"
158
- }), /* @__PURE__ */ React2.createElement("span", null, toast.title)), toast.description && /* @__PURE__ */ React2.createElement(Toast.Description, null, toast.description))), /* @__PURE__ */ React2.createElement(DeprecatedFormInput, {
159
- label: t("settings choose storage adaptor")
160
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
161
- value: Object.entries(StorageAdapters).find(([name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore)?.[0],
162
- onValueChange: (value) => {
163
- if (confirm(t("settings storage adapter changed alert"))) {
164
- updateConfig(storageConfig, setStorageConfig, [
165
- "runtime",
166
- "client",
167
- "storage",
168
- "dataStore"
169
- ], StorageAdapters[value]);
170
- }
171
- }
172
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
173
- placeholder: t("settings data store label")
174
- }), /* @__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, {
175
- key,
176
- value: key
177
- }, t(`settings storage adaptor ${key} label`)))))))));
178
- };
179
- var updateConfig = (config, setConfig, path, value) => {
180
- const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
181
- setDeep(storageConfigCopy, path, value);
182
- setConfig(storageConfigCopy);
183
- queueMicrotask(async () => {
184
- await SaveConfig(storageConfigCopy);
185
- });
186
- };
187
-
188
- // packages/plugins/plugin-debug/src/components/DebugStatus.tsx
189
- import React3, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
190
- import { firstIdInPart, parseGraphPlugin, parseNavigationPlugin, useResolvePlugin as useResolvePlugin2 } from "@dxos/app-framework";
191
- import { TimeoutError } from "@dxos/async";
192
- import { StatsPanel, useStats } from "@dxos/devtools";
193
- import { log as log2 } from "@dxos/log";
194
- import { getActiveSpace } from "@dxos/plugin-space";
195
- import { StatusBar } from "@dxos/plugin-status-bar";
196
- import { ConnectionState } from "@dxos/protocols/proto/dxos/client/services";
197
- import { useNetworkStatus } from "@dxos/react-client/mesh";
198
- import { Icon } from "@dxos/react-ui";
199
- import { mx as mx2 } from "@dxos/react-ui-theme";
200
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/DebugStatus.tsx";
201
- var styles = {
202
- success: "text-sky-300 dark:text-green-700",
203
- warning: "text-orange-300 dark:text-orange-600",
204
- error: "text-red-300 dark:text-red-600"
205
- };
206
- var ErrorIndicator = () => {
207
- const [, forceUpdate] = useState2({});
208
- const errorRef = useRef();
209
- useEffect2(() => {
210
- const errorListener = (event) => {
211
- const error = event.error ?? event.reason;
212
- if (errorRef.current !== error) {
213
- log2.error("onError", {
214
- event
215
- }, {
216
- F: __dxlog_file2,
217
- L: 73,
218
- S: void 0,
219
- C: (f, a) => f(...a)
220
- });
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(Icon, {
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(Icon, {
249
- icon: "ph--check--regular",
250
- size: 4
251
- }));
252
- }
253
- };
254
- var SwarmIndicator = () => {
255
- const [state, setState] = useState2(0);
256
- const { swarm } = useNetworkStatus();
257
- useEffect2(() => {
258
- setState(swarm === ConnectionState.ONLINE ? 0 : 1);
259
- }, [
260
- swarm
261
- ]);
262
- if (state === 0) {
263
- return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
264
- title: "Connected to swarm."
265
- }, /* @__PURE__ */ React3.createElement(Icon, {
266
- icon: "ph--lightning--regular",
267
- size: 4
268
- }));
269
- } else {
270
- return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
271
- title: "Disconnected from swarm."
272
- }, /* @__PURE__ */ React3.createElement(Icon, {
273
- icon: "ph--lightning-slash--regular",
274
- size: 4,
275
- classNames: styles.warning
276
- }));
277
- }
278
- };
279
- var SavingIndicator = () => {
280
- const [state, _setState] = useState2(0);
281
- const navigationPlugin = useResolvePlugin2(parseNavigationPlugin);
282
- const graphPlugin = useResolvePlugin2(parseGraphPlugin);
283
- const location2 = navigationPlugin?.provides.location;
284
- const graph = graphPlugin?.provides.graph;
285
- const _space = location2 && graph ? getActiveSpace(graph, firstIdInPart(location2.active, "main")) : void 0;
286
- switch (state) {
287
- case 2:
288
- return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
289
- title: "Edit not saved."
290
- }, /* @__PURE__ */ React3.createElement(Icon, {
291
- icon: "ph--circle--duotone",
292
- size: 4,
293
- classNames: styles.warning
294
- }));
295
- case 1:
296
- return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
297
- title: "Saving..."
298
- }, /* @__PURE__ */ React3.createElement(Icon, {
299
- icon: "ph--circle--duotone",
300
- size: 4,
301
- classNames: styles.success
302
- }));
303
- case 0:
304
- default:
305
- return /* @__PURE__ */ React3.createElement(StatusBar.Item, {
306
- title: "Modified indicator."
307
- }, /* @__PURE__ */ React3.createElement(Icon, {
308
- icon: "ph--circle--duotone",
309
- size: 4
310
- }));
311
- }
312
- };
313
- var PerformanceIndicator = () => {
314
- const [visible, setVisible] = useState2(false);
315
- const [stats, refreshStats] = useStats();
316
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(StatusBar.Button, {
317
- onClick: () => setVisible((visible2) => !visible2),
318
- title: "Performance panels"
319
- }, /* @__PURE__ */ React3.createElement(Icon, {
320
- icon: "ph--chart-bar--regular",
321
- size: 4
322
- })), visible && /* @__PURE__ */ React3.createElement("div", {
323
- className: mx2("z-20 absolute bottom-[--statusbar-size] right-4 w-[450px]", "overflow-x-hidden overflow-y-auto scrollbar-thin", "border-x border-y border-separator")
324
- }, /* @__PURE__ */ React3.createElement(StatsPanel, {
325
- stats,
326
- onRefresh: refreshStats
327
- })));
328
- };
329
- var indicators = [
330
- SavingIndicator,
331
- SwarmIndicator,
332
- PerformanceIndicator,
333
- ErrorIndicator
334
- ];
335
- var DebugStatus = () => {
336
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, indicators.map((Indicator) => /* @__PURE__ */ React3.createElement(Indicator, {
337
- key: Indicator.name
338
- })));
339
- };
340
-
341
- // packages/plugins/plugin-debug/src/components/Wireframe.tsx
342
- import React4 from "react";
343
- import { useResizeDetector } from "react-resize-detector";
344
- import { fullyQualifiedId } from "@dxos/react-client/echo";
345
- import { useAttendableAttributes } from "@dxos/react-ui-attention";
346
- import { SyntaxHighlighter as SyntaxHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
347
- import { mx as mx3 } from "@dxos/react-ui-theme";
348
- var Wireframe = ({ classNames, label, object }) => {
349
- const attendableAttrs = useAttendableAttributes(fullyQualifiedId(object));
350
- const { width, height, ref } = useResizeDetector();
351
- return /* @__PURE__ */ React4.createElement("div", {
352
- ref,
353
- className: mx3("relative grow min-bs-96", classNames),
354
- ...attendableAttrs
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
- };
387
-
388
- // packages/plugins/plugin-debug/src/components/index.ts
389
- var DebugApp = lazy(() => import("./DebugApp-HCHR6GKO.mjs"));
390
- var DebugSpace = lazy(() => import("./DebugSpace-DHKEAMIC.mjs"));
391
- var SpaceGenerator = lazy(() => import("./SpaceGenerator-BQ3645OS.mjs"));
10
+ // packages/plugins/plugin-debug/src/capabilities/index.ts
11
+ import { lazy } from "@dxos/app-framework";
12
+ var AppGraphBuilder = lazy(() => import("./app-graph-builder-FXELWOFS.mjs"));
13
+ var ReactContext = lazy(() => import("./react-context-OZU6J7G3.mjs"));
14
+ var ReactSurface = lazy(() => import("./react-surface-ACHNR2UU.mjs"));
15
+ var DebugSettings = lazy(() => import("./settings-JCZUA643.mjs"));
392
16
 
393
17
  // packages/plugins/plugin-debug/src/translations.ts
394
18
  var translations_default = [
@@ -423,361 +47,66 @@ var translations_default = [
423
47
  ];
424
48
 
425
49
  // packages/plugins/plugin-debug/src/DebugPlugin.tsx
426
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/DebugPlugin.tsx";
427
- var DebugPlugin = definePlugin((context) => {
428
- const settings = create({
429
- debug: true,
430
- devtools: true
431
- });
432
- return {
433
- meta: meta_default,
434
- ready: async (plugins) => {
435
- context.init(plugins);
436
- context.resolvePlugin(parseSettingsPlugin).provides.settingsStore.createStore({
437
- schema: DebugSettingsSchema,
438
- prefix: DEBUG_PLUGIN,
439
- value: settings
440
- });
441
- const composer = window.composer;
442
- composer.changeStorageVersionInMetadata = async (version) => {
443
- const { changeStorageVersionInMetadata } = await import("@dxos/echo-pipeline/testing");
444
- const { createStorageObjects } = await import("@dxos/client-services");
445
- const client = window.dxos.client;
446
- const config = client.config;
447
- await client.destroy();
448
- const { storage } = createStorageObjects(config.values?.runtime?.client?.storage ?? {});
449
- await changeStorageVersionInMetadata(storage, version);
450
- location.pathname = "/";
451
- };
452
- },
453
- unload: async () => {
454
- context.dispose();
455
- },
456
- provides: {
457
- settings,
458
- translations: translations_default,
459
- complementary: {
460
- panels: [
50
+ var DebugPlugin = () => {
51
+ setupDevtools();
52
+ return definePlugin(meta, [
53
+ defineModule({
54
+ id: `${meta.id}/module/settings`,
55
+ activatesOn: Events.SetupSettings,
56
+ activate: DebugSettings
57
+ }),
58
+ defineModule({
59
+ id: `${meta.id}/module/translations`,
60
+ activatesOn: Events.SetupTranslations,
61
+ activate: () => contributes(Capabilities.Translations, translations_default)
62
+ }),
63
+ defineModule({
64
+ id: `${meta.id}/module/complementary-panel`,
65
+ activatesOn: Events.Startup,
66
+ activate: () => contributes(DeckCapabilities.ComplementaryPanel, {
67
+ id: "debug",
68
+ label: [
69
+ "debug label",
461
70
  {
462
- id: "debug",
463
- label: [
464
- "open debug panel label",
465
- {
466
- ns: DEBUG_PLUGIN
467
- }
468
- ],
469
- icon: "ph--bug--regular"
470
- }
471
- ]
472
- },
473
- context: ({ children }) => {
474
- const [timer, setTimer] = useState3();
475
- useEffect3(() => timer?.state.on((value) => !value && setTimer(void 0)), [
476
- timer
477
- ]);
478
- useEffect3(() => {
479
- timer?.stop();
480
- }, []);
481
- return /* @__PURE__ */ React5.createElement(DebugContext.Provider, {
482
- value: {
483
- running: !!timer,
484
- start: (cb, options) => {
485
- timer?.stop();
486
- setTimer(new Timer(cb).start(options));
487
- },
488
- stop: () => timer?.stop()
489
- }
490
- }, children);
491
- },
492
- graph: {
493
- builder: (plugins) => {
494
- const clientPlugin = resolvePlugin(plugins, parseClientPlugin);
495
- const metadataPlugin = resolvePlugin(plugins, parseMetadataResolverPlugin);
496
- const graphPlugin = resolvePlugin(plugins, parseGraphPlugin2);
497
- const resolve = metadataPlugin?.provides.metadata.resolver;
498
- const client = clientPlugin?.provides.client;
499
- invariant(resolve, void 0, {
500
- F: __dxlog_file3,
501
- L: 128,
502
- S: void 0,
503
- A: [
504
- "resolve",
505
- ""
506
- ]
507
- });
508
- invariant(client, void 0, {
509
- F: __dxlog_file3,
510
- L: 129,
511
- S: void 0,
512
- A: [
513
- "client",
514
- ""
515
- ]
516
- });
517
- return [
518
- // Devtools node.
519
- createExtension({
520
- id: "dxos.org/plugin/debug/devtools",
521
- filter: (node) => !!settings.devtools && node.id === "root",
522
- connector: () => [
523
- {
524
- // TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
525
- id: "dxos.org.plugin.debug.devtools",
526
- data: "devtools",
527
- type: "dxos.org/plugin/debug/devtools",
528
- properties: {
529
- label: [
530
- "devtools label",
531
- {
532
- ns: DEBUG_PLUGIN
533
- }
534
- ],
535
- icon: "ph--hammer--regular"
536
- }
537
- }
538
- ]
539
- }),
540
- // Debug node.
541
- createExtension({
542
- id: "dxos.org/plugin/debug/debug",
543
- filter: (node) => !!settings.debug && node.id === "root",
544
- connector: () => [
545
- {
546
- id: "dxos.org/plugin/debug/debug",
547
- type: "dxos.org/plugin/debug/debug",
548
- data: {
549
- graph: graphPlugin?.provides.graph
550
- },
551
- properties: {
552
- label: [
553
- "debug label",
554
- {
555
- ns: DEBUG_PLUGIN
556
- }
557
- ],
558
- icon: "ph--bug--regular"
559
- }
560
- }
561
- ]
562
- }),
563
- // Space debug nodes.
564
- createExtension({
565
- id: "dxos.org/plugin/debug/spaces",
566
- filter: (node) => !!settings.debug && isSpace(node.data),
567
- connector: ({ node }) => {
568
- const space = node.data;
569
- const state = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
570
- if (state !== SpaceState.SPACE_READY) {
571
- return;
572
- }
573
- const collection = space.properties[CollectionType.typename];
574
- if (!collection) {
575
- return;
576
- }
577
- return [
578
- {
579
- id: `${space.id}-debug`,
580
- type: "dxos.org/plugin/debug/space",
581
- data: {
582
- space,
583
- type: "dxos.org/plugin/debug/space"
584
- },
585
- properties: {
586
- label: [
587
- "debug label",
588
- {
589
- ns: DEBUG_PLUGIN
590
- }
591
- ],
592
- icon: "ph--bug--regular"
593
- }
594
- }
595
- ];
596
- }
597
- }),
598
- // Create nodes for debug sidebar.
599
- createExtension({
600
- id: `${DEBUG_PLUGIN}/debug-for-subject`,
601
- resolver: ({ id }) => {
602
- if (!id.endsWith("~debug")) {
603
- return;
604
- }
605
- const type = "orphan-settings-for-subject";
606
- const icon = "ph--bug--regular";
607
- const [subjectId] = id.split("~");
608
- const { spaceId, objectId } = parseId(subjectId);
609
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
610
- const space = spaces?.find((space2) => space2.state.get() === SpaceState.SPACE_READY && space2.id === spaceId);
611
- if (!objectId) {
612
- const label2 = space ? space.properties.name || [
613
- "unnamed space label",
614
- {
615
- ns: DEBUG_PLUGIN
616
- }
617
- ] : [
618
- "unnamed object settings label",
619
- {
620
- ns: DEBUG_PLUGIN
621
- }
622
- ];
623
- return {
624
- id,
625
- type,
626
- data: null,
627
- properties: {
628
- icon,
629
- label: label2,
630
- showResolvedThreads: false,
631
- object: null,
632
- space
633
- }
634
- };
635
- }
636
- const [object] = memoizeQuery(space, {
637
- id: objectId
638
- });
639
- if (!object || !subjectId) {
640
- return;
641
- }
642
- const meta = resolve(getTypename(object) ?? "");
643
- const label = meta.label?.(object) || object.name || meta.placeholder || [
644
- "unnamed object settings label",
645
- {
646
- ns: DEBUG_PLUGIN
647
- }
648
- ];
649
- return {
650
- id,
651
- type,
652
- data: null,
653
- properties: {
654
- icon,
655
- label,
656
- object
657
- }
658
- };
659
- }
660
- })
661
- ];
662
- }
663
- },
664
- intent: {
665
- resolver: async (intent, plugins) => {
666
- switch (intent.action) {
667
- case DebugAction.OPEN_DEVTOOLS: {
668
- const clientPlugin = context.getPlugin("dxos.org/plugin/client");
669
- const client = clientPlugin.provides.client;
670
- const vaultUrl = client.config.values?.runtime?.client?.remoteSource ?? "https://halo.dxos.org";
671
- let devtoolsUrl = "http://localhost:5174";
672
- try {
673
- await fetch(devtoolsUrl);
674
- } catch {
675
- const isDev = window.location.href.includes(".dev.") || window.location.href.includes("localhost");
676
- devtoolsUrl = `https://devtools${isDev ? ".dev." : "."}dxos.org`;
677
- }
678
- window.open(`${devtoolsUrl}?target=${vaultUrl}`, "_blank");
679
- return {
680
- data: true
681
- };
682
- }
71
+ ns: DEBUG_PLUGIN
683
72
  }
684
- }
685
- },
686
- surface: {
687
- component: ({ name, data, role }) => {
688
- switch (role) {
689
- case "settings":
690
- return data.plugin === meta_default.id ? /* @__PURE__ */ React5.createElement(DebugSettings, {
691
- settings
692
- }) : null;
693
- case "status":
694
- return /* @__PURE__ */ React5.createElement(DebugStatus, null);
695
- case "complementary--debug":
696
- return isEchoObject(data.subject) ? /* @__PURE__ */ React5.createElement(DebugObjectPanel, {
697
- object: data.subject
698
- }) : null;
699
- }
700
- const primary = data.active ?? data.object;
701
- let component = null;
702
- if (role === "main" || role === "article") {
703
- if (primary === "devtools" && settings.devtools) {
704
- component = /* @__PURE__ */ React5.createElement(Devtools, null);
705
- } else if (!primary || typeof primary !== "object" || !settings.debug) {
706
- component = null;
707
- } else if ("type" in primary && primary.type === "dxos.org/plugin/debug/space" && "space" in primary && isSpace(primary.space)) {
708
- const handleCreateObject = (objects) => {
709
- if (!isSpace(primary.space)) {
710
- return;
711
- }
712
- const collection = primary.space.state.get() === SpaceState.SPACE_READY && primary.space.properties[CollectionType.typename];
713
- if (!(collection instanceof CollectionType)) {
714
- return;
715
- }
716
- void context.resolvePlugin(parseIntentPlugin).provides.intent.dispatch(objects.map((object) => ({
717
- action: SpaceAction.ADD_OBJECT,
718
- data: {
719
- target: collection,
720
- object
721
- }
722
- })));
723
- };
724
- const deprecated = false;
725
- component = deprecated ? /* @__PURE__ */ React5.createElement(DebugSpace, {
726
- space: primary.space,
727
- onAddObjects: handleCreateObject
728
- }) : /* @__PURE__ */ React5.createElement(SpaceGenerator, {
729
- space: primary.space,
730
- onCreateObjects: handleCreateObject
731
- });
732
- } else if ("graph" in primary && primary.graph instanceof Graph) {
733
- component = /* @__PURE__ */ React5.createElement(DebugApp, {
734
- graph: primary.graph
735
- });
736
- }
737
- }
738
- if (!component) {
739
- if (settings.wireframe) {
740
- if (role === "main" || role === "article" || role === "section") {
741
- const primary2 = data.active ?? data.object;
742
- const isCollection = primary2 instanceof CollectionType;
743
- if (!isCollection) {
744
- return {
745
- node: /* @__PURE__ */ React5.createElement(Wireframe, {
746
- label: `${role}:${name}`,
747
- object: primary2,
748
- classNames: "row-span-2 overflow-hidden"
749
- }),
750
- disposition: "hoist"
751
- };
752
- }
753
- }
754
- }
755
- return null;
756
- }
757
- switch (role) {
758
- case "article":
759
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, component);
760
- case "main":
761
- return /* @__PURE__ */ React5.createElement(Main.Content, {
762
- classNames: [
763
- baseSurface,
764
- fixedInsetFlexLayout,
765
- topbarBlockPaddingStart,
766
- bottombarBlockPaddingEnd
767
- ]
768
- }, component);
769
- }
770
- return null;
771
- }
772
- }
773
- }
73
+ ],
74
+ icon: "ph--bug--regular"
75
+ })
76
+ }),
77
+ defineModule({
78
+ id: `${meta.id}/module/react-context`,
79
+ activatesOn: Events.Startup,
80
+ activate: ReactContext
81
+ }),
82
+ defineModule({
83
+ id: `${meta.id}/module/react-surface`,
84
+ activatesOn: Events.Startup,
85
+ activate: ReactSurface
86
+ }),
87
+ defineModule({
88
+ id: `${meta.id}/module/app-graph-builder`,
89
+ activatesOn: Events.SetupAppGraph,
90
+ activate: AppGraphBuilder
91
+ })
92
+ ]);
93
+ };
94
+ var setupDevtools = () => {
95
+ globalThis.composer ??= {};
96
+ globalThis.composer.changeStorageVersionInMetadata = async (version) => {
97
+ const { changeStorageVersionInMetadata } = await import("@dxos/echo-pipeline/testing");
98
+ const { createStorageObjects } = await import("@dxos/client-services");
99
+ const client = window.dxos.client;
100
+ const config = client.config;
101
+ await client.destroy();
102
+ const { storage } = createStorageObjects(config.values?.runtime?.client?.storage ?? {});
103
+ await changeStorageVersionInMetadata(storage, version);
104
+ location.pathname = "/";
774
105
  };
775
- });
776
-
777
- // packages/plugins/plugin-debug/src/index.ts
778
- var src_default = DebugPlugin;
106
+ };
779
107
  export {
108
+ DEBUG_PLUGIN,
780
109
  DebugPlugin,
781
- src_default as default
110
+ meta
782
111
  };
783
112
  //# sourceMappingURL=index.mjs.map