@dxos/plugin-debug 0.6.8-main.046e6cf
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.
- package/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/DebugGlobal-H37KGFEG.mjs +179 -0
- package/dist/lib/browser/DebugGlobal-H37KGFEG.mjs.map +7 -0
- package/dist/lib/browser/DebugSpace-ZZ2JLU6F.mjs +407 -0
- package/dist/lib/browser/DebugSpace-ZZ2JLU6F.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsMain-DTAWVF22.mjs +16 -0
- package/dist/lib/browser/DevtoolsMain-DTAWVF22.mjs.map +7 -0
- package/dist/lib/browser/chunk-ED5L5YYI.mjs +27 -0
- package/dist/lib/browser/chunk-ED5L5YYI.mjs.map +7 -0
- package/dist/lib/browser/chunk-RYK3J66D.mjs +24 -0
- package/dist/lib/browser/chunk-RYK3J66D.mjs.map +7 -0
- package/dist/lib/browser/chunk-WEGYHXMB.mjs +21 -0
- package/dist/lib/browser/chunk-WEGYHXMB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +658 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +9 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +5 -0
- package/dist/types/src/DebugPlugin.d.ts.map +1 -0
- package/dist/types/src/components/DebugGlobal.d.ts +7 -0
- package/dist/types/src/components/DebugGlobal.d.ts.map +1 -0
- package/dist/types/src/components/DebugPanel.d.ts +5 -0
- package/dist/types/src/components/DebugPanel.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings.d.ts +6 -0
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -0
- package/dist/types/src/components/DebugSpace.d.ts +9 -0
- package/dist/types/src/components/DebugSpace.d.ts.map +1 -0
- package/dist/types/src/components/DebugSpace.stories.d.ts +16 -0
- package/dist/types/src/components/DebugSpace.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugStatus.d.ts +3 -0
- package/dist/types/src/components/DebugStatus.d.ts.map +1 -0
- package/dist/types/src/components/DevtoolsMain.d.ts +4 -0
- package/dist/types/src/components/DevtoolsMain.d.ts.map +1 -0
- package/dist/types/src/components/ObjectCreator.d.ts +17 -0
- package/dist/types/src/components/ObjectCreator.d.ts.map +1 -0
- package/dist/types/src/components/ObjectCreator.stories.d.ts +17 -0
- package/dist/types/src/components/ObjectCreator.stories.d.ts.map +1 -0
- package/dist/types/src/components/Tree.d.ts +20 -0
- package/dist/types/src/components/Tree.d.ts.map +1 -0
- package/dist/types/src/components/Wireframe.d.ts +7 -0
- package/dist/types/src/components/Wireframe.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +13 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +15 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/scaffolding/generator.d.ts +11 -0
- package/dist/types/src/scaffolding/generator.d.ts.map +1 -0
- package/dist/types/src/scaffolding/index.d.ts +2 -0
- package/dist/types/src/scaffolding/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +29 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +19 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/types.test.d.ts +2 -0
- package/dist/types/src/types.test.d.ts.map +1 -0
- package/package.json +92 -0
- package/src/DebugPlugin.tsx +270 -0
- package/src/components/DebugGlobal.tsx +80 -0
- package/src/components/DebugPanel.tsx +34 -0
- package/src/components/DebugSettings.tsx +159 -0
- package/src/components/DebugSpace.stories.tsx +40 -0
- package/src/components/DebugSpace.tsx +195 -0
- package/src/components/DebugStatus.tsx +221 -0
- package/src/components/DevtoolsMain.tsx +16 -0
- package/src/components/ObjectCreator.stories.tsx +44 -0
- package/src/components/ObjectCreator.tsx +100 -0
- package/src/components/Tree.tsx +113 -0
- package/src/components/Wireframe.tsx +35 -0
- package/src/components/index.ts +14 -0
- package/src/index.ts +9 -0
- package/src/meta.tsx +19 -0
- package/src/scaffolding/generator.ts +143 -0
- package/src/scaffolding/index.ts +5 -0
- package/src/translations.ts +36 -0
- package/src/types.test.ts +13 -0
- package/src/types.ts +45 -0
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DebugAction,
|
|
3
|
+
DebugContext
|
|
4
|
+
} from "./chunk-RYK3J66D.mjs";
|
|
5
|
+
import {
|
|
6
|
+
DEBUG_PLUGIN,
|
|
7
|
+
meta_default
|
|
8
|
+
} from "./chunk-WEGYHXMB.mjs";
|
|
9
|
+
|
|
10
|
+
// packages/plugins/experimental/plugin-debug/src/DebugPlugin.tsx
|
|
11
|
+
import { Bug, Hammer } from "@phosphor-icons/react";
|
|
12
|
+
import React5, { useEffect as useEffect3, useState as useState3 } from "react";
|
|
13
|
+
import { getPlugin, parseGraphPlugin as parseGraphPlugin2, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
|
|
14
|
+
import { Timer } from "@dxos/async";
|
|
15
|
+
import { LocalStorageStore } from "@dxos/local-storage";
|
|
16
|
+
import { createExtension, Graph } from "@dxos/plugin-graph";
|
|
17
|
+
import { SpaceAction } from "@dxos/plugin-space";
|
|
18
|
+
import { CollectionType } from "@dxos/plugin-space/types";
|
|
19
|
+
import { SpaceState, isSpace } from "@dxos/react-client/echo";
|
|
20
|
+
import { Main } from "@dxos/react-ui";
|
|
21
|
+
import { baseSurface, topbarBlockPaddingStart, fixedInsetFlexLayout, bottombarBlockPaddingEnd } from "@dxos/react-ui-theme";
|
|
22
|
+
|
|
23
|
+
// packages/plugins/experimental/plugin-debug/src/components/index.ts
|
|
24
|
+
import React4 from "react";
|
|
25
|
+
|
|
26
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugSettings.tsx
|
|
27
|
+
import { Gift, DownloadSimple, FirstAidKit } from "@phosphor-icons/react";
|
|
28
|
+
import React, { useEffect, useState } from "react";
|
|
29
|
+
import { parseFileManagerPlugin, useResolvePlugin } from "@dxos/app-framework";
|
|
30
|
+
import { defs, SaveConfig, Storage } from "@dxos/config";
|
|
31
|
+
import { log } from "@dxos/log";
|
|
32
|
+
import { SettingsValue } from "@dxos/plugin-settings";
|
|
33
|
+
import { useClient } from "@dxos/react-client";
|
|
34
|
+
import { useTranslation, Button, Toast, Input, useFileDownload, Select } from "@dxos/react-ui";
|
|
35
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
36
|
+
import { setDeep } from "@dxos/util";
|
|
37
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-debug/src/components/DebugSettings.tsx";
|
|
38
|
+
var StorageAdapters = {
|
|
39
|
+
opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
|
|
40
|
+
idb: defs.Runtime.Client.Storage.StorageDriver.IDB
|
|
41
|
+
};
|
|
42
|
+
var DebugSettings = ({ settings }) => {
|
|
43
|
+
const { t } = useTranslation(DEBUG_PLUGIN);
|
|
44
|
+
const [toast, setToast] = useState();
|
|
45
|
+
const client = useClient();
|
|
46
|
+
const download = useFileDownload();
|
|
47
|
+
const [storageConfig, setStorageConfig] = useState({});
|
|
48
|
+
const fileManagerPlugin = useResolvePlugin(parseFileManagerPlugin);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
void Storage().then((config) => setStorageConfig(config));
|
|
51
|
+
}, []);
|
|
52
|
+
const handleToast = (toast2) => {
|
|
53
|
+
setToast(toast2);
|
|
54
|
+
const t2 = setTimeout(() => setToast(void 0), 5e3);
|
|
55
|
+
return () => clearTimeout(t2);
|
|
56
|
+
};
|
|
57
|
+
const handleDownload = async () => {
|
|
58
|
+
const data = await client.diagnostics();
|
|
59
|
+
const file = new Blob([
|
|
60
|
+
JSON.stringify(data, void 0, 2)
|
|
61
|
+
], {
|
|
62
|
+
type: "text/plain"
|
|
63
|
+
});
|
|
64
|
+
const fileName = `composer-${(/* @__PURE__ */ new Date()).toISOString().replace(/\W/g, "-")}.json`;
|
|
65
|
+
download(file, fileName);
|
|
66
|
+
if (fileManagerPlugin?.provides.file.upload) {
|
|
67
|
+
const info = await fileManagerPlugin.provides.file.upload(new File([
|
|
68
|
+
file
|
|
69
|
+
], fileName), client.spaces.default);
|
|
70
|
+
if (!info) {
|
|
71
|
+
log.error("diagnostics failed to upload to IPFS", void 0, {
|
|
72
|
+
F: __dxlog_file,
|
|
73
|
+
L: 58,
|
|
74
|
+
S: void 0,
|
|
75
|
+
C: (f, a) => f(...a)
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
handleToast({
|
|
80
|
+
title: t("settings uploaded"),
|
|
81
|
+
description: t("settings uploaded to clipboard")
|
|
82
|
+
});
|
|
83
|
+
const url = client.config.values.runtime.services.ipfs.gateway + "/" + info.cid;
|
|
84
|
+
void navigator.clipboard.writeText(url);
|
|
85
|
+
handleToast({
|
|
86
|
+
title: t("settings uploaded"),
|
|
87
|
+
description: t("settings uploaded to clipboard")
|
|
88
|
+
});
|
|
89
|
+
log.info("diagnostics", {
|
|
90
|
+
url
|
|
91
|
+
}, {
|
|
92
|
+
F: __dxlog_file,
|
|
93
|
+
L: 67,
|
|
94
|
+
S: void 0,
|
|
95
|
+
C: (f, a) => f(...a)
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const handleRepair = async () => {
|
|
100
|
+
try {
|
|
101
|
+
const info = await client.repair();
|
|
102
|
+
setStorageConfig(await Storage());
|
|
103
|
+
handleToast({
|
|
104
|
+
title: t("settings repair success"),
|
|
105
|
+
description: JSON.stringify(info, void 0, 2)
|
|
106
|
+
});
|
|
107
|
+
} catch (err) {
|
|
108
|
+
handleToast({
|
|
109
|
+
title: t("settings repair failed"),
|
|
110
|
+
description: err.message
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
115
|
+
label: t("settings show debug panel")
|
|
116
|
+
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
117
|
+
checked: settings.debug,
|
|
118
|
+
onCheckedChange: (checked) => settings.debug = !!checked
|
|
119
|
+
})), /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
120
|
+
label: t("settings show devtools panel")
|
|
121
|
+
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
122
|
+
checked: settings.devtools,
|
|
123
|
+
onCheckedChange: (checked) => settings.devtools = !!checked
|
|
124
|
+
})), /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
125
|
+
label: t("settings wireframe")
|
|
126
|
+
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
127
|
+
checked: settings.wireframe,
|
|
128
|
+
onCheckedChange: (checked) => settings.wireframe = !!checked
|
|
129
|
+
})), /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
130
|
+
label: t("settings download diagnostics")
|
|
131
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
132
|
+
onClick: handleDownload
|
|
133
|
+
}, /* @__PURE__ */ React.createElement(DownloadSimple, {
|
|
134
|
+
className: getSize(5)
|
|
135
|
+
}))), /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
136
|
+
label: t("settings repair")
|
|
137
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
138
|
+
onClick: handleRepair
|
|
139
|
+
}, /* @__PURE__ */ React.createElement(FirstAidKit, {
|
|
140
|
+
className: getSize(5)
|
|
141
|
+
}))), toast && /* @__PURE__ */ React.createElement(Toast.Root, null, /* @__PURE__ */ React.createElement(Toast.Body, null, /* @__PURE__ */ React.createElement(Toast.Title, null, /* @__PURE__ */ React.createElement(Gift, {
|
|
142
|
+
className: mx(getSize(5), "inline mr-1"),
|
|
143
|
+
weight: "duotone"
|
|
144
|
+
}), /* @__PURE__ */ React.createElement("span", null, toast.title)), toast.description && /* @__PURE__ */ React.createElement(Toast.Description, null, toast.description))), /* @__PURE__ */ React.createElement(SettingsValue, {
|
|
145
|
+
label: t("settings choose storage adaptor")
|
|
146
|
+
}, /* @__PURE__ */ React.createElement(Select.Root, {
|
|
147
|
+
value: Object.entries(StorageAdapters).find(([name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore)?.[0],
|
|
148
|
+
onValueChange: (value) => {
|
|
149
|
+
if (confirm(t("settings storage adapter changed alert"))) {
|
|
150
|
+
updateConfig(storageConfig, setStorageConfig, [
|
|
151
|
+
"runtime",
|
|
152
|
+
"client",
|
|
153
|
+
"storage",
|
|
154
|
+
"dataStore"
|
|
155
|
+
], StorageAdapters[value]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
159
|
+
placeholder: t("settings data store label")
|
|
160
|
+
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, Object.keys(StorageAdapters).map((key) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
161
|
+
key,
|
|
162
|
+
value: key
|
|
163
|
+
}, t(`settings storage adaptor ${key} label`)))))))));
|
|
164
|
+
};
|
|
165
|
+
var updateConfig = (config, setConfig, path, value) => {
|
|
166
|
+
const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
|
|
167
|
+
setDeep(storageConfigCopy, path, value);
|
|
168
|
+
setConfig(storageConfigCopy);
|
|
169
|
+
queueMicrotask(async () => {
|
|
170
|
+
await SaveConfig(storageConfigCopy);
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugStatus.tsx
|
|
175
|
+
import { ChartBar, Circle, Lightning, LightningSlash } from "@phosphor-icons/react";
|
|
176
|
+
import React2, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
177
|
+
import { firstIdInPart, parseGraphPlugin, parseNavigationPlugin, useResolvePlugin as useResolvePlugin2 } from "@dxos/app-framework";
|
|
178
|
+
import { TimeoutError } from "@dxos/async";
|
|
179
|
+
import { StatsPanel, useStats } from "@dxos/devtools";
|
|
180
|
+
import { log as log2 } from "@dxos/log";
|
|
181
|
+
import { getActiveSpace } from "@dxos/plugin-space";
|
|
182
|
+
import { StatusBar } from "@dxos/plugin-status-bar";
|
|
183
|
+
import { ConnectionState } from "@dxos/protocols/proto/dxos/client/services";
|
|
184
|
+
import { useNetworkStatus } from "@dxos/react-client/mesh";
|
|
185
|
+
import { getSize as getSize2, mx as mx2 } from "@dxos/react-ui-theme";
|
|
186
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-debug/src/components/DebugStatus.tsx";
|
|
187
|
+
var styles = {
|
|
188
|
+
success: "text-sky-300 dark:text-green-700",
|
|
189
|
+
warning: "text-orange-300 dark:text-orange-600",
|
|
190
|
+
error: "text-red-300 dark:text-red-600"
|
|
191
|
+
};
|
|
192
|
+
var ErrorIndicator = () => {
|
|
193
|
+
const [, forceUpdate] = useState2({});
|
|
194
|
+
const errorRef = useRef();
|
|
195
|
+
useEffect2(() => {
|
|
196
|
+
const errorListener = (event) => {
|
|
197
|
+
const error = event.error ?? event.reason;
|
|
198
|
+
if (errorRef.current !== error) {
|
|
199
|
+
log2.error("onError", {
|
|
200
|
+
event
|
|
201
|
+
}, {
|
|
202
|
+
F: __dxlog_file2,
|
|
203
|
+
L: 73,
|
|
204
|
+
S: void 0,
|
|
205
|
+
C: (f, a) => f(...a)
|
|
206
|
+
});
|
|
207
|
+
errorRef.current = error;
|
|
208
|
+
forceUpdate({});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
window.addEventListener("error", errorListener);
|
|
212
|
+
window.addEventListener("unhandledrejection", errorListener);
|
|
213
|
+
return () => {
|
|
214
|
+
window.removeEventListener("error", errorListener);
|
|
215
|
+
window.removeEventListener("unhandledrejection", errorListener);
|
|
216
|
+
};
|
|
217
|
+
}, []);
|
|
218
|
+
const handleReset = () => {
|
|
219
|
+
errorRef.current = void 0;
|
|
220
|
+
forceUpdate({});
|
|
221
|
+
};
|
|
222
|
+
if (errorRef.current) {
|
|
223
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Button, {
|
|
224
|
+
title: errorRef.current.message,
|
|
225
|
+
onClick: handleReset
|
|
226
|
+
}, /* @__PURE__ */ React2.createElement(Circle, {
|
|
227
|
+
weight: "fill",
|
|
228
|
+
className: mx2(styles.error, getSize2(3))
|
|
229
|
+
}));
|
|
230
|
+
} else {
|
|
231
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
232
|
+
title: "No errors."
|
|
233
|
+
}, /* @__PURE__ */ React2.createElement(Circle, {
|
|
234
|
+
weight: "fill",
|
|
235
|
+
className: getSize2(3)
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
var SwarmIndicator = () => {
|
|
240
|
+
const [state, setState] = useState2(0);
|
|
241
|
+
const { swarm } = useNetworkStatus();
|
|
242
|
+
useEffect2(() => {
|
|
243
|
+
setState(swarm === ConnectionState.ONLINE ? 0 : 1);
|
|
244
|
+
}, [
|
|
245
|
+
swarm
|
|
246
|
+
]);
|
|
247
|
+
if (state === 0) {
|
|
248
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
249
|
+
title: "Connected to swarm."
|
|
250
|
+
}, /* @__PURE__ */ React2.createElement(Lightning, {
|
|
251
|
+
className: getSize2(4)
|
|
252
|
+
}));
|
|
253
|
+
} else {
|
|
254
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
255
|
+
title: "Disconnected from swarm."
|
|
256
|
+
}, /* @__PURE__ */ React2.createElement(LightningSlash, {
|
|
257
|
+
className: mx2(styles.warning, getSize2(4))
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var SavingIndicator = () => {
|
|
262
|
+
const [state, _setState] = useState2(0);
|
|
263
|
+
const navigationPlugin = useResolvePlugin2(parseNavigationPlugin);
|
|
264
|
+
const graphPlugin = useResolvePlugin2(parseGraphPlugin);
|
|
265
|
+
const location2 = navigationPlugin?.provides.location;
|
|
266
|
+
const graph = graphPlugin?.provides.graph;
|
|
267
|
+
const _space = location2 && graph ? getActiveSpace(graph, firstIdInPart(location2.active, "main")) : void 0;
|
|
268
|
+
switch (state) {
|
|
269
|
+
case 2:
|
|
270
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
271
|
+
title: "Edit not saved."
|
|
272
|
+
}, /* @__PURE__ */ React2.createElement(Circle, {
|
|
273
|
+
weight: "fill",
|
|
274
|
+
className: mx2(styles.warning, getSize2(3))
|
|
275
|
+
}));
|
|
276
|
+
case 1:
|
|
277
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
278
|
+
title: "Saving..."
|
|
279
|
+
}, /* @__PURE__ */ React2.createElement(Circle, {
|
|
280
|
+
weight: "fill",
|
|
281
|
+
className: mx2(styles.success, getSize2(3))
|
|
282
|
+
}));
|
|
283
|
+
case 0:
|
|
284
|
+
default:
|
|
285
|
+
return /* @__PURE__ */ React2.createElement(StatusBar.Item, {
|
|
286
|
+
title: "Modified indicator."
|
|
287
|
+
}, /* @__PURE__ */ React2.createElement(Circle, {
|
|
288
|
+
weight: "fill",
|
|
289
|
+
className: getSize2(3)
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
var PerformanceIndicator = () => {
|
|
294
|
+
const [visible, setVisible] = useState2(false);
|
|
295
|
+
const [stats, refreshStats] = useStats();
|
|
296
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(StatusBar.Button, {
|
|
297
|
+
onClick: () => setVisible((visible2) => !visible2),
|
|
298
|
+
title: "Performance panels"
|
|
299
|
+
}, /* @__PURE__ */ React2.createElement(ChartBar, null)), /* @__PURE__ */ React2.createElement("div", {
|
|
300
|
+
className: mx2("z-20 absolute transition-[right] bottom-[24px] w-[450px]", "border-l border-y border-neutral-300 dark:border-neutral-700", visible ? "right-0" : "right-[-450px]")
|
|
301
|
+
}, /* @__PURE__ */ React2.createElement(StatsPanel, {
|
|
302
|
+
stats,
|
|
303
|
+
onRefresh: refreshStats
|
|
304
|
+
})));
|
|
305
|
+
};
|
|
306
|
+
var indicators = [
|
|
307
|
+
PerformanceIndicator,
|
|
308
|
+
SavingIndicator,
|
|
309
|
+
ErrorIndicator,
|
|
310
|
+
SwarmIndicator
|
|
311
|
+
];
|
|
312
|
+
var DebugStatus = () => {
|
|
313
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, indicators.map((Indicator) => /* @__PURE__ */ React2.createElement(Indicator, {
|
|
314
|
+
key: Indicator.name
|
|
315
|
+
})));
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
// packages/plugins/experimental/plugin-debug/src/components/Wireframe.tsx
|
|
319
|
+
import React3 from "react";
|
|
320
|
+
import { useResizeDetector } from "react-resize-detector";
|
|
321
|
+
import { createAttendableAttributes } from "@dxos/react-ui-attention";
|
|
322
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
323
|
+
var Wireframe = ({ label, data, className }) => {
|
|
324
|
+
const attendableAttrs = createAttendableAttributes(data);
|
|
325
|
+
const { width, height, ref } = useResizeDetector();
|
|
326
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
327
|
+
ref,
|
|
328
|
+
className: mx3("relative grow", className),
|
|
329
|
+
...attendableAttrs
|
|
330
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
331
|
+
className: "absolute inset-2 flex flex-col overflow-hidden font-mono"
|
|
332
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
333
|
+
className: "flex justify-between"
|
|
334
|
+
}, /* @__PURE__ */ React3.createElement("div", null, label), /* @__PURE__ */ React3.createElement("div", null, `[${width}x${height}]`)), /* @__PURE__ */ React3.createElement("div", {
|
|
335
|
+
className: "flex grow overflow-auto"
|
|
336
|
+
}, data && /* @__PURE__ */ React3.createElement("pre", {
|
|
337
|
+
className: "text-neutral-500 text-sm whitespace-pre-line"
|
|
338
|
+
}, JSON.stringify(data, void 0, 1)))), /* @__PURE__ */ React3.createElement("svg", {
|
|
339
|
+
width,
|
|
340
|
+
height,
|
|
341
|
+
className: "bg-transparent [&>*]:stroke-neutral-500"
|
|
342
|
+
}, /* @__PURE__ */ React3.createElement("rect", {
|
|
343
|
+
x: 0,
|
|
344
|
+
y: 0,
|
|
345
|
+
width,
|
|
346
|
+
height,
|
|
347
|
+
strokeWidth: 1,
|
|
348
|
+
fill: "none"
|
|
349
|
+
}), /* @__PURE__ */ React3.createElement("line", {
|
|
350
|
+
x1: 0,
|
|
351
|
+
y1: 0,
|
|
352
|
+
x2: width,
|
|
353
|
+
y2: height,
|
|
354
|
+
strokeWidth: 1
|
|
355
|
+
}), /* @__PURE__ */ React3.createElement("line", {
|
|
356
|
+
x1: 0,
|
|
357
|
+
y1: height,
|
|
358
|
+
x2: width,
|
|
359
|
+
y2: 0,
|
|
360
|
+
strokeWidth: 1
|
|
361
|
+
})));
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// packages/plugins/experimental/plugin-debug/src/components/index.ts
|
|
365
|
+
var DebugGlobal = React4.lazy(() => import("./DebugGlobal-H37KGFEG.mjs"));
|
|
366
|
+
var DebugSpace = React4.lazy(() => import("./DebugSpace-ZZ2JLU6F.mjs"));
|
|
367
|
+
var DevtoolsMain = React4.lazy(() => import("./DevtoolsMain-DTAWVF22.mjs"));
|
|
368
|
+
|
|
369
|
+
// packages/plugins/experimental/plugin-debug/src/translations.ts
|
|
370
|
+
var translations_default = [
|
|
371
|
+
{
|
|
372
|
+
"en-US": {
|
|
373
|
+
[DEBUG_PLUGIN]: {
|
|
374
|
+
"plugin name": "Debug",
|
|
375
|
+
"mutation count": "Number of mutations",
|
|
376
|
+
"mutation period": "Mutation period",
|
|
377
|
+
"open devtools label": "Open DevTools",
|
|
378
|
+
"devtools label": "DevTools",
|
|
379
|
+
"debug label": "Debug",
|
|
380
|
+
"settings show debug panel": "Show Debug panel.",
|
|
381
|
+
"settings show devtools panel": "Show DevTools panel.",
|
|
382
|
+
"settings wireframe": "Show wireframes.",
|
|
383
|
+
"settings repair": "Run repair tool.",
|
|
384
|
+
"settings download diagnostics": "Download diagnostics.",
|
|
385
|
+
"settings uploaded": "Uploaded to IPFS",
|
|
386
|
+
"settings uploaded to clipboard": "URL copied to clipboard.",
|
|
387
|
+
"settings repair success": "Repair succeeded",
|
|
388
|
+
"settings repair failed": "Repair failed",
|
|
389
|
+
"settings choose storage adaptor": "Storage adaptor (worker reload required).",
|
|
390
|
+
"settings storage adaptor idb label": "IndexedDB",
|
|
391
|
+
"settings storage adaptor opfs label": "OPFS",
|
|
392
|
+
"settings data store label": "Data Store",
|
|
393
|
+
"settings storage adapter changed alert": "Warning: Swapping the storage adapter will make your data unavailable.",
|
|
394
|
+
"settings space fragmentation": "Enable AM space fragmentation"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
];
|
|
399
|
+
|
|
400
|
+
// packages/plugins/experimental/plugin-debug/src/DebugPlugin.tsx
|
|
401
|
+
var SETTINGS_KEY = DEBUG_PLUGIN + "/settings";
|
|
402
|
+
var DebugPlugin = () => {
|
|
403
|
+
const settings = new LocalStorageStore(DEBUG_PLUGIN, {
|
|
404
|
+
debug: true,
|
|
405
|
+
devtools: true
|
|
406
|
+
});
|
|
407
|
+
let intentPlugin;
|
|
408
|
+
return {
|
|
409
|
+
meta: meta_default,
|
|
410
|
+
ready: async (plugins) => {
|
|
411
|
+
intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
412
|
+
settings.prop({
|
|
413
|
+
key: "debug",
|
|
414
|
+
type: LocalStorageStore.bool({
|
|
415
|
+
allowUndefined: true
|
|
416
|
+
})
|
|
417
|
+
}).prop({
|
|
418
|
+
key: "devtools",
|
|
419
|
+
type: LocalStorageStore.bool({
|
|
420
|
+
allowUndefined: true
|
|
421
|
+
})
|
|
422
|
+
}).prop({
|
|
423
|
+
key: "wireframe",
|
|
424
|
+
type: LocalStorageStore.bool({
|
|
425
|
+
allowUndefined: true
|
|
426
|
+
})
|
|
427
|
+
});
|
|
428
|
+
const composer = window.composer;
|
|
429
|
+
composer.changeStorageVersionInMetadata = async (version) => {
|
|
430
|
+
const { changeStorageVersionInMetadata } = await import("@dxos/echo-pipeline/testing");
|
|
431
|
+
const { createStorageObjects } = await import("@dxos/client-services");
|
|
432
|
+
const client = window.dxos.client;
|
|
433
|
+
const config = client.config;
|
|
434
|
+
await client.destroy();
|
|
435
|
+
const { storage } = createStorageObjects(config.values?.runtime?.client?.storage ?? {});
|
|
436
|
+
await changeStorageVersionInMetadata(storage, version);
|
|
437
|
+
location.pathname = "/";
|
|
438
|
+
};
|
|
439
|
+
},
|
|
440
|
+
unload: async () => {
|
|
441
|
+
settings.close();
|
|
442
|
+
},
|
|
443
|
+
provides: {
|
|
444
|
+
settings: settings.values,
|
|
445
|
+
translations: translations_default,
|
|
446
|
+
context: ({ children }) => {
|
|
447
|
+
const [timer, setTimer] = useState3();
|
|
448
|
+
useEffect3(() => timer?.state.on((value) => !value && setTimer(void 0)), [
|
|
449
|
+
timer
|
|
450
|
+
]);
|
|
451
|
+
useEffect3(() => {
|
|
452
|
+
timer?.stop();
|
|
453
|
+
}, []);
|
|
454
|
+
return /* @__PURE__ */ React5.createElement(DebugContext.Provider, {
|
|
455
|
+
value: {
|
|
456
|
+
running: !!timer,
|
|
457
|
+
start: (cb, options) => {
|
|
458
|
+
timer?.stop();
|
|
459
|
+
setTimer(new Timer(cb).start(options));
|
|
460
|
+
},
|
|
461
|
+
stop: () => timer?.stop()
|
|
462
|
+
}
|
|
463
|
+
}, children);
|
|
464
|
+
},
|
|
465
|
+
graph: {
|
|
466
|
+
builder: (plugins) => {
|
|
467
|
+
const graphPlugin = resolvePlugin(plugins, parseGraphPlugin2);
|
|
468
|
+
return [
|
|
469
|
+
// Devtools node.
|
|
470
|
+
createExtension({
|
|
471
|
+
id: "dxos.org/plugin/debug/devtools",
|
|
472
|
+
filter: (node) => !!settings.values.devtools && node.id === "root",
|
|
473
|
+
connector: () => [
|
|
474
|
+
{
|
|
475
|
+
// TODO(zan): Removed `/` because it breaks deck layout reload. Fix?
|
|
476
|
+
id: "dxos.org.plugin.debug.devtools",
|
|
477
|
+
data: "devtools",
|
|
478
|
+
type: "dxos.org/plugin/debug/devtools",
|
|
479
|
+
properties: {
|
|
480
|
+
label: [
|
|
481
|
+
"devtools label",
|
|
482
|
+
{
|
|
483
|
+
ns: DEBUG_PLUGIN
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
icon: (props) => /* @__PURE__ */ React5.createElement(Hammer, props),
|
|
487
|
+
iconSymbol: "ph--hammer--regular"
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
]
|
|
491
|
+
}),
|
|
492
|
+
// Debug node.
|
|
493
|
+
createExtension({
|
|
494
|
+
id: "dxos.org/plugin/debug/debug",
|
|
495
|
+
filter: (node) => !!settings.values.debug && node.id === "root",
|
|
496
|
+
connector: () => [
|
|
497
|
+
{
|
|
498
|
+
id: "dxos.org/plugin/debug/debug",
|
|
499
|
+
type: "dxos.org/plugin/debug/debug",
|
|
500
|
+
data: {
|
|
501
|
+
graph: graphPlugin?.provides.graph
|
|
502
|
+
},
|
|
503
|
+
properties: {
|
|
504
|
+
label: [
|
|
505
|
+
"debug label",
|
|
506
|
+
{
|
|
507
|
+
ns: DEBUG_PLUGIN
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
icon: (props) => /* @__PURE__ */ React5.createElement(Bug, props),
|
|
511
|
+
iconSymbol: "ph--bug--regular"
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
]
|
|
515
|
+
}),
|
|
516
|
+
// Space debug nodes.
|
|
517
|
+
createExtension({
|
|
518
|
+
id: "dxos.org/plugin/debug/spaces",
|
|
519
|
+
filter: (node) => !!settings.values.debug && isSpace(node.data),
|
|
520
|
+
connector: ({ node }) => {
|
|
521
|
+
const space = node.data;
|
|
522
|
+
return [
|
|
523
|
+
{
|
|
524
|
+
id: `${space.id}-debug`,
|
|
525
|
+
type: "dxos.org/plugin/debug/space",
|
|
526
|
+
data: {
|
|
527
|
+
space
|
|
528
|
+
},
|
|
529
|
+
properties: {
|
|
530
|
+
label: [
|
|
531
|
+
"debug label",
|
|
532
|
+
{
|
|
533
|
+
ns: DEBUG_PLUGIN
|
|
534
|
+
}
|
|
535
|
+
],
|
|
536
|
+
icon: (props) => /* @__PURE__ */ React5.createElement(Bug, props),
|
|
537
|
+
iconSymbol: "ph--bug--regular"
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
];
|
|
541
|
+
}
|
|
542
|
+
})
|
|
543
|
+
];
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
intent: {
|
|
547
|
+
resolver: async (intent, plugins) => {
|
|
548
|
+
switch (intent.action) {
|
|
549
|
+
case DebugAction.OPEN_DEVTOOLS: {
|
|
550
|
+
const clientPlugin = getPlugin(plugins, "dxos.org/plugin/client");
|
|
551
|
+
const client = clientPlugin.provides.client;
|
|
552
|
+
const vaultUrl = client.config.values?.runtime?.client?.remoteSource ?? "https://halo.dxos.org";
|
|
553
|
+
let devtoolsUrl = "http://localhost:5174";
|
|
554
|
+
try {
|
|
555
|
+
await fetch(devtoolsUrl);
|
|
556
|
+
} catch {
|
|
557
|
+
const isDev = window.location.href.includes(".dev.") || window.location.href.includes("localhost");
|
|
558
|
+
devtoolsUrl = `https://devtools${isDev ? ".dev." : "."}dxos.org`;
|
|
559
|
+
}
|
|
560
|
+
window.open(`${devtoolsUrl}?target=${vaultUrl}`, "_blank");
|
|
561
|
+
return {
|
|
562
|
+
data: true
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
surface: {
|
|
569
|
+
component: ({ name, data, role }) => {
|
|
570
|
+
switch (role) {
|
|
571
|
+
case "settings":
|
|
572
|
+
return data.plugin === meta_default.id ? /* @__PURE__ */ React5.createElement(DebugSettings, {
|
|
573
|
+
settings: settings.values
|
|
574
|
+
}) : null;
|
|
575
|
+
case "status":
|
|
576
|
+
return /* @__PURE__ */ React5.createElement(DebugStatus, null);
|
|
577
|
+
}
|
|
578
|
+
const primary = data.active ?? data.object;
|
|
579
|
+
let component;
|
|
580
|
+
if (role === "main" || role === "article") {
|
|
581
|
+
if (primary === "devtools" && settings.values.devtools) {
|
|
582
|
+
component = /* @__PURE__ */ React5.createElement(DevtoolsMain, null);
|
|
583
|
+
} else if (!primary || typeof primary !== "object" || !settings.values.debug) {
|
|
584
|
+
component = null;
|
|
585
|
+
} else if ("space" in primary && isSpace(primary.space)) {
|
|
586
|
+
component = /* @__PURE__ */ React5.createElement(DebugSpace, {
|
|
587
|
+
space: primary.space,
|
|
588
|
+
onAddObjects: (objects) => {
|
|
589
|
+
if (!isSpace(primary.space)) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const collection = primary.space.state.get() === SpaceState.SPACE_READY && primary.space.properties[CollectionType.typename];
|
|
593
|
+
if (!(collection instanceof CollectionType)) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
void intentPlugin?.provides.intent.dispatch(objects.map((object) => ({
|
|
597
|
+
action: SpaceAction.ADD_OBJECT,
|
|
598
|
+
data: {
|
|
599
|
+
target: collection,
|
|
600
|
+
object
|
|
601
|
+
}
|
|
602
|
+
})));
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
} else if ("graph" in primary && primary.graph instanceof Graph) {
|
|
606
|
+
component = /* @__PURE__ */ React5.createElement(DebugGlobal, {
|
|
607
|
+
graph: primary.graph
|
|
608
|
+
});
|
|
609
|
+
} else {
|
|
610
|
+
component = null;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (!component) {
|
|
614
|
+
if (settings.values.wireframe) {
|
|
615
|
+
if (role === "main" || role === "article" || role === "section") {
|
|
616
|
+
const primary2 = data.active ?? data.object;
|
|
617
|
+
if (!(primary2 instanceof CollectionType)) {
|
|
618
|
+
return /* @__PURE__ */ React5.createElement(Wireframe, {
|
|
619
|
+
label: role,
|
|
620
|
+
data,
|
|
621
|
+
className: "row-span-2 overflow-hidden"
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
switch (role) {
|
|
629
|
+
case "article":
|
|
630
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
631
|
+
role: "none",
|
|
632
|
+
className: "row-span-2 rounded-t-md overflow-x-auto"
|
|
633
|
+
}, component);
|
|
634
|
+
case "main":
|
|
635
|
+
return /* @__PURE__ */ React5.createElement(Main.Content, {
|
|
636
|
+
classNames: [
|
|
637
|
+
baseSurface,
|
|
638
|
+
fixedInsetFlexLayout,
|
|
639
|
+
topbarBlockPaddingStart,
|
|
640
|
+
bottombarBlockPaddingEnd
|
|
641
|
+
]
|
|
642
|
+
}, component);
|
|
643
|
+
}
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// packages/plugins/experimental/plugin-debug/src/index.ts
|
|
652
|
+
var src_default = DebugPlugin;
|
|
653
|
+
export {
|
|
654
|
+
DebugPlugin,
|
|
655
|
+
SETTINGS_KEY,
|
|
656
|
+
src_default as default
|
|
657
|
+
};
|
|
658
|
+
//# sourceMappingURL=index.mjs.map
|