@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
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
Copyright (c) 2022 DXOS
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @dxos/plugin-kanban
|
|
2
|
+
|
|
3
|
+
Surface plugin for kanban entities.
|
|
4
|
+
|
|
5
|
+
## DXOS Resources
|
|
6
|
+
|
|
7
|
+
- [Website](https://dxos.org)
|
|
8
|
+
- [Developer Documentation](https://docs.dxos.org)
|
|
9
|
+
- Talk to us on [Discord](https://dxos.org/discord)
|
|
10
|
+
|
|
11
|
+
## Contributions
|
|
12
|
+
|
|
13
|
+
Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
|
|
14
|
+
|
|
15
|
+
License: [MIT](./LICENSE) Copyright 2023 © DXOS
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DebugPanel
|
|
3
|
+
} from "./chunk-ED5L5YYI.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugGlobal.tsx
|
|
6
|
+
import { Gauge, Graph as GraphIcon, Gear, Toolbox, Warning } from "@phosphor-icons/react";
|
|
7
|
+
import React2, { useEffect, useState as useState2 } from "react";
|
|
8
|
+
import { useClient, useConfig } from "@dxos/react-client";
|
|
9
|
+
import { Button, ToggleGroup, ToggleGroupItem, useThemeContext } from "@dxos/react-ui";
|
|
10
|
+
import { getSize, mx as mx2 } from "@dxos/react-ui-theme";
|
|
11
|
+
|
|
12
|
+
// packages/plugins/experimental/plugin-debug/src/components/Tree.tsx
|
|
13
|
+
import React, { useState } from "react";
|
|
14
|
+
import SyntaxHighlighter from "react-syntax-highlighter";
|
|
15
|
+
import styleDark from "react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark";
|
|
16
|
+
import styleLight from "react-syntax-highlighter/dist/esm/styles/hljs/a11y-light";
|
|
17
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
18
|
+
import { arrayToBuffer } from "@dxos/util";
|
|
19
|
+
var replacer = (key, value) => {
|
|
20
|
+
if (typeof value === "object") {
|
|
21
|
+
if (value instanceof Uint8Array) {
|
|
22
|
+
return arrayToBuffer(value).toString("hex");
|
|
23
|
+
}
|
|
24
|
+
if (value?.type === "Buffer") {
|
|
25
|
+
return Buffer.from(value.data).toString("hex");
|
|
26
|
+
}
|
|
27
|
+
if (key === "downloaded") {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
var Json = ({ data, theme }) => {
|
|
34
|
+
const style = theme === "dark" ? styleDark : styleLight;
|
|
35
|
+
return /* @__PURE__ */ React.createElement(SyntaxHighlighter, {
|
|
36
|
+
language: "json",
|
|
37
|
+
style,
|
|
38
|
+
className: "w-full"
|
|
39
|
+
}, JSON.stringify(data, replacer, 2));
|
|
40
|
+
};
|
|
41
|
+
var Tree = ({ data }) => {
|
|
42
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
43
|
+
className: "flex overflow-auto ml-2 border-l-2 border-blue-500"
|
|
44
|
+
}, /* @__PURE__ */ React.createElement(Node, {
|
|
45
|
+
data,
|
|
46
|
+
root: true
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
var Node = ({ data, root }) => {
|
|
50
|
+
if (typeof data !== "object" || data === void 0 || data === null) {
|
|
51
|
+
return /* @__PURE__ */ React.createElement(Scalar, {
|
|
52
|
+
value: data
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(data)) {
|
|
56
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
57
|
+
className: "flex flex-col space-y-2"
|
|
58
|
+
}, data.map((value, index) => /* @__PURE__ */ React.createElement(KeyValue, {
|
|
59
|
+
key: index,
|
|
60
|
+
label: String(index),
|
|
61
|
+
data: value,
|
|
62
|
+
className: "bg-teal-50"
|
|
63
|
+
})));
|
|
64
|
+
}
|
|
65
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
66
|
+
className: "flex flex-col space-y-2"
|
|
67
|
+
}, Object.entries(data).map(([key, value]) => /* @__PURE__ */ React.createElement(KeyValue, {
|
|
68
|
+
key,
|
|
69
|
+
label: key,
|
|
70
|
+
data: value,
|
|
71
|
+
className: "bg-blue-50"
|
|
72
|
+
})));
|
|
73
|
+
};
|
|
74
|
+
var KeyValue = ({ label, data, className }) => {
|
|
75
|
+
const [open, setOpen] = useState(true);
|
|
76
|
+
if (data === void 0) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
80
|
+
className: "flex"
|
|
81
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
82
|
+
className: mx("border-blue-200 text-sm select-none cursor-pointer", className),
|
|
83
|
+
onClick: () => setOpen((open2) => !open2)
|
|
84
|
+
}, label), open && /* @__PURE__ */ React.createElement(Node, {
|
|
85
|
+
data
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
var Scalar = ({ value }) => {
|
|
89
|
+
return /* @__PURE__ */ React.createElement(Box, {
|
|
90
|
+
className: "bg-green-50 border-green-200 rounded-r text-sm font-thin"
|
|
91
|
+
}, value === void 0 && "undefined" || value === null && "null" || typeof value === "string" && value || JSON.stringify(value));
|
|
92
|
+
};
|
|
93
|
+
var Box = ({ children, className, ...props }) => {
|
|
94
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
95
|
+
className: mx("flex px-2 border border-l-0 font-mono truncate", className),
|
|
96
|
+
...props
|
|
97
|
+
}, children);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugGlobal.tsx
|
|
101
|
+
var DebugGlobal = ({ graph }) => {
|
|
102
|
+
const { themeMode } = useThemeContext();
|
|
103
|
+
const [view, setView] = useState2("graph");
|
|
104
|
+
const [data, setData] = useState2({});
|
|
105
|
+
const client = useClient();
|
|
106
|
+
const config = useConfig();
|
|
107
|
+
const handleRefresh = async () => {
|
|
108
|
+
const data2 = await client.diagnostics({
|
|
109
|
+
truncate: true
|
|
110
|
+
});
|
|
111
|
+
setData(data2);
|
|
112
|
+
};
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
void handleRefresh();
|
|
115
|
+
}, []);
|
|
116
|
+
const handleResetClient = async (force = false) => {
|
|
117
|
+
if (!force && !window.confirm("Reset storage?")) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
await client.reset();
|
|
121
|
+
window.location.href = window.location.origin;
|
|
122
|
+
};
|
|
123
|
+
const handleOpenDevtools = () => {
|
|
124
|
+
const vaultUrl = config.values?.runtime?.client?.remoteSource;
|
|
125
|
+
if (vaultUrl) {
|
|
126
|
+
window.open(`https://devtools.dev.dxos.org/?target=${vaultUrl}`);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return /* @__PURE__ */ React2.createElement(DebugPanel, {
|
|
130
|
+
menu: /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ToggleGroup, {
|
|
131
|
+
type: "single",
|
|
132
|
+
value: view
|
|
133
|
+
}, /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
134
|
+
value: "graph",
|
|
135
|
+
onClick: () => setView("graph"),
|
|
136
|
+
title: "Plugin graph"
|
|
137
|
+
}, /* @__PURE__ */ React2.createElement(GraphIcon, {
|
|
138
|
+
className: getSize(5)
|
|
139
|
+
})), /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
140
|
+
value: "diagnostics",
|
|
141
|
+
onClick: () => setView("diagnostics"),
|
|
142
|
+
title: "Diagnostics"
|
|
143
|
+
}, /* @__PURE__ */ React2.createElement(Gauge, {
|
|
144
|
+
className: getSize(5)
|
|
145
|
+
})), /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
146
|
+
value: "config",
|
|
147
|
+
onClick: () => setView("config"),
|
|
148
|
+
title: "Config"
|
|
149
|
+
}, /* @__PURE__ */ React2.createElement(Gear, {
|
|
150
|
+
className: getSize(5)
|
|
151
|
+
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
152
|
+
className: "grow"
|
|
153
|
+
}), /* @__PURE__ */ React2.createElement(Button, {
|
|
154
|
+
onClick: (event) => handleResetClient(event.shiftKey),
|
|
155
|
+
title: "Reset client"
|
|
156
|
+
}, /* @__PURE__ */ React2.createElement(Warning, {
|
|
157
|
+
className: mx2(getSize(5), "text-red-700")
|
|
158
|
+
})), /* @__PURE__ */ React2.createElement(Button, {
|
|
159
|
+
onClick: handleOpenDevtools,
|
|
160
|
+
title: "Open Devtools"
|
|
161
|
+
}, /* @__PURE__ */ React2.createElement(Toolbox, {
|
|
162
|
+
weight: "duotone",
|
|
163
|
+
className: mx2(getSize(5), "text-700")
|
|
164
|
+
})))
|
|
165
|
+
}, view === "graph" && /* @__PURE__ */ React2.createElement(Tree, {
|
|
166
|
+
data: graph.toJSON()
|
|
167
|
+
}), view === "config" && /* @__PURE__ */ React2.createElement(Json, {
|
|
168
|
+
theme: themeMode,
|
|
169
|
+
data: data.diagnostics?.config
|
|
170
|
+
}), view === "diagnostics" && /* @__PURE__ */ React2.createElement(Json, {
|
|
171
|
+
theme: themeMode,
|
|
172
|
+
data
|
|
173
|
+
}));
|
|
174
|
+
};
|
|
175
|
+
var DebugGlobal_default = DebugGlobal;
|
|
176
|
+
export {
|
|
177
|
+
DebugGlobal_default as default
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=DebugGlobal-H37KGFEG.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/DebugGlobal.tsx", "../../../src/components/Tree.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Gauge, Graph as GraphIcon, Gear, Toolbox, Warning } from '@phosphor-icons/react';\nimport React, { type FC, useEffect, useState } from 'react';\n\nimport { type Graph } from '@dxos/plugin-graph';\nimport { useClient, useConfig } from '@dxos/react-client';\nimport { Button, ToggleGroup, ToggleGroupItem, useThemeContext } from '@dxos/react-ui';\nimport { getSize, mx } from '@dxos/react-ui-theme';\n\nimport { DebugPanel } from './DebugPanel';\nimport { Json, Tree } from './Tree';\n\nconst DebugGlobal: FC<{ graph: Graph }> = ({ graph }) => {\n const { themeMode } = useThemeContext();\n const [view, setView] = useState<'config' | 'diagnostics' | 'graph'>('graph');\n const [data, setData] = useState<any>({});\n const client = useClient();\n const config = useConfig();\n const handleRefresh = async () => {\n const data = await client.diagnostics({ truncate: true });\n setData(data);\n };\n useEffect(() => {\n void handleRefresh();\n }, []);\n\n const handleResetClient = async (force = false) => {\n if (!force && !window.confirm('Reset storage?')) {\n return;\n }\n\n // TODO(burdon): Throws exception.\n await client.reset();\n window.location.href = window.location.origin;\n };\n\n const handleOpenDevtools = () => {\n const vaultUrl = config.values?.runtime?.client?.remoteSource;\n if (vaultUrl) {\n window.open(`https://devtools.dev.dxos.org/?target=${vaultUrl}`);\n }\n };\n\n return (\n <DebugPanel\n menu={\n <>\n <ToggleGroup type='single' value={view}>\n <ToggleGroupItem value={'graph'} onClick={() => setView('graph')} title={'Plugin graph'}>\n <GraphIcon className={getSize(5)} />\n </ToggleGroupItem>\n <ToggleGroupItem value={'diagnostics'} onClick={() => setView('diagnostics')} title={'Diagnostics'}>\n <Gauge className={getSize(5)} />\n </ToggleGroupItem>\n <ToggleGroupItem value={'config'} onClick={() => setView('config')} title={'Config'}>\n <Gear className={getSize(5)} />\n </ToggleGroupItem>\n </ToggleGroup>\n\n <div className='grow' />\n <Button onClick={(event) => handleResetClient(event.shiftKey)} title='Reset client'>\n <Warning className={mx(getSize(5), 'text-red-700')} />\n </Button>\n <Button onClick={handleOpenDevtools} title='Open Devtools'>\n <Toolbox weight='duotone' className={mx(getSize(5), 'text-700')} />\n </Button>\n </>\n }\n >\n {view === 'graph' && <Tree data={graph.toJSON()} />}\n {view === 'config' && <Json theme={themeMode} data={data.diagnostics?.config} />}\n {view === 'diagnostics' && <Json theme={themeMode} data={data} />}\n </DebugPanel>\n );\n};\n\nexport default DebugGlobal;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { type FC, type HTMLAttributes, useState } from 'react';\nimport SyntaxHighlighter from 'react-syntax-highlighter';\n// eslint-disable-next-line no-restricted-imports\nimport styleDark from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-dark';\n// eslint-disable-next-line no-restricted-imports\nimport styleLight from 'react-syntax-highlighter/dist/esm/styles/hljs/a11y-light';\n\nimport { type ThemeMode } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\nimport { arrayToBuffer } from '@dxos/util';\n\n// TODO(burdon): Copied form devtools.\n\nexport const replacer = (key: any, value: any) => {\n if (typeof value === 'object') {\n if (value instanceof Uint8Array) {\n return arrayToBuffer(value).toString('hex');\n }\n\n if (value?.type === 'Buffer') {\n return Buffer.from(value.data).toString('hex');\n }\n\n if (key === 'downloaded') {\n return undefined;\n }\n }\n\n return value;\n};\n\nexport const Json: FC<{ data?: object; theme: ThemeMode }> = ({ data, theme }) => {\n const style = theme === 'dark' ? styleDark : styleLight;\n return (\n <SyntaxHighlighter language='json' style={style} className='w-full'>\n {JSON.stringify(data, replacer, 2)}\n </SyntaxHighlighter>\n );\n};\n\nexport const Tree: FC<{ data?: object }> = ({ data }) => {\n return (\n <div className='flex overflow-auto ml-2 border-l-2 border-blue-500'>\n <Node data={data} root />\n </div>\n );\n};\n\nexport const Node: FC<{ data?: any; root?: boolean }> = ({ data, root }) => {\n if (typeof data !== 'object' || data === undefined || data === null) {\n return <Scalar value={data} />;\n }\n\n if (Array.isArray(data)) {\n return (\n <div className='flex flex-col space-y-2'>\n {data.map((value, index) => (\n <KeyValue key={index} label={String(index)} data={value} className='bg-teal-50' />\n ))}\n </div>\n );\n }\n\n return (\n <div className='flex flex-col space-y-2'>\n {Object.entries(data).map(([key, value]) => (\n <KeyValue key={key} label={key} data={value} className='bg-blue-50' />\n ))}\n </div>\n );\n};\n\nexport const KeyValue: FC<{ label: string; data?: any; className?: string }> = ({ label, data, className }) => {\n const [open, setOpen] = useState(true);\n if (data === undefined) {\n return null;\n }\n\n return (\n <div className='flex'>\n <Box\n className={mx('border-blue-200 text-sm select-none cursor-pointer', className)}\n onClick={() => setOpen((open) => !open)}\n >\n {label}\n </Box>\n {open && <Node data={data} />}\n </div>\n );\n};\n\nconst Scalar: FC<{ value: any }> = ({ value }) => {\n return (\n <Box className='bg-green-50 border-green-200 rounded-r text-sm font-thin'>\n {(value === undefined && 'undefined') ||\n (value === null && 'null') ||\n (typeof value === 'string' && value) ||\n JSON.stringify(value)}\n </Box>\n );\n};\n\nconst Box: FC<HTMLAttributes<HTMLDivElement>> = ({ children, className, ...props }) => {\n return (\n <div className={mx('flex px-2 border border-l-0 font-mono truncate', className)} {...props}>\n {children}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,OAAOC,SAASC,WAAWC,MAAMC,SAASC,eAAe;AAClE,OAAOC,UAAkBC,WAAWC,YAAAA,iBAAgB;AAGpD,SAASC,WAAWC,iBAAiB;AACrC,SAASC,QAAQC,aAAaC,iBAAiBC,uBAAuB;AACtE,SAASC,SAASC,MAAAA,WAAU;;;ACN5B,OAAOC,SAAuCC,gBAAgB;AAC9D,OAAOC,uBAAuB;AAE9B,OAAOC,eAAe;AAEtB,OAAOC,gBAAgB;AAGvB,SAASC,UAAU;AACnB,SAASC,qBAAqB;AAIvB,IAAMC,WAAW,CAACC,KAAUC,UAAAA;AACjC,MAAI,OAAOA,UAAU,UAAU;AAC7B,QAAIA,iBAAiBC,YAAY;AAC/B,aAAOC,cAAcF,KAAAA,EAAOG,SAAS,KAAA;IACvC;AAEA,QAAIH,OAAOI,SAAS,UAAU;AAC5B,aAAOC,OAAOC,KAAKN,MAAMO,IAAI,EAAEJ,SAAS,KAAA;IAC1C;AAEA,QAAIJ,QAAQ,cAAc;AACxB,aAAOS;IACT;EACF;AAEA,SAAOR;AACT;AAEO,IAAMS,OAAgD,CAAC,EAAEF,MAAMG,MAAK,MAAE;AAC3E,QAAMC,QAAQD,UAAU,SAASE,YAAYC;AAC7C,SACE,sBAAA,cAACC,mBAAAA;IAAkBC,UAAS;IAAOJ;IAAcK,W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gauge", "Graph", "GraphIcon", "Gear", "Toolbox", "Warning", "React", "useEffect", "useState", "useClient", "useConfig", "Button", "ToggleGroup", "ToggleGroupItem", "useThemeContext", "getSize", "mx", "React", "useState", "SyntaxHighlighter", "styleDark", "styleLight", "mx", "arrayToBuffer", "replacer", "key", "value", "Uint8Array", "arrayToBuffer", "toString", "type", "Buffer", "from", "data", "undefined", "Json", "theme", "style", "styleDark", "styleLight", "SyntaxHighlighter", "language", "className", "JSON", "stringify", "Tree", "div", "Node", "root", "Scalar", "Array", "isArray", "map", "index", "KeyValue", "label", "String", "Object", "entries", "open", "setOpen", "useState", "Box", "mx", "onClick", "children", "props", "DebugGlobal", "graph", "themeMode", "useThemeContext", "view", "setView", "useState", "data", "setData", "client", "useClient", "config", "useConfig", "handleRefresh", "diagnostics", "truncate", "useEffect", "handleResetClient", "force", "window", "confirm", "reset", "location", "href", "origin", "handleOpenDevtools", "vaultUrl", "values", "runtime", "remoteSource", "open", "React", "DebugPanel", "menu", "ToggleGroup", "type", "value", "ToggleGroupItem", "onClick", "title", "GraphIcon", "className", "getSize", "Gauge", "Gear", "div", "Button", "event", "shiftKey", "Warning", "mx", "Toolbox", "weight", "Tree", "toJSON", "Json", "theme"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DebugContext
|
|
3
|
+
} from "./chunk-RYK3J66D.mjs";
|
|
4
|
+
import "./chunk-WEGYHXMB.mjs";
|
|
5
|
+
import {
|
|
6
|
+
DebugPanel
|
|
7
|
+
} from "./chunk-ED5L5YYI.mjs";
|
|
8
|
+
|
|
9
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugSpace.tsx
|
|
10
|
+
import { ArrowClockwise, DownloadSimple, Flag, FlagPennant, HandPalm, Play, PlusMinus, Timer, UserCirclePlus } from "@phosphor-icons/react";
|
|
11
|
+
import React2, { useContext, useMemo as useMemo2, useState as useState2 } from "react";
|
|
12
|
+
import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
|
|
13
|
+
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
14
|
+
import { faker as faker2 } from "@dxos/random";
|
|
15
|
+
import { useAsyncEffect } from "@dxos/react-async";
|
|
16
|
+
import { useClient } from "@dxos/react-client";
|
|
17
|
+
import { Filter, useSpaceInvitation } from "@dxos/react-client/echo";
|
|
18
|
+
import { InvitationEncoder } from "@dxos/react-client/invitations";
|
|
19
|
+
import { Button as Button2, Input, useFileDownload } from "@dxos/react-ui";
|
|
20
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
21
|
+
import { safeParseInt } from "@dxos/util";
|
|
22
|
+
|
|
23
|
+
// packages/plugins/experimental/plugin-debug/src/components/ObjectCreator.tsx
|
|
24
|
+
import React, { useMemo, useState } from "react";
|
|
25
|
+
import { Button, DensityProvider } from "@dxos/react-ui";
|
|
26
|
+
import { createColumnBuilder, Table } from "@dxos/react-ui-table";
|
|
27
|
+
|
|
28
|
+
// packages/plugins/experimental/plugin-debug/src/scaffolding/generator.ts
|
|
29
|
+
import { createShapeId, defaultBindingUtils, defaultShapeUtils, defaultTools, Editor } from "@tldraw/tldraw";
|
|
30
|
+
import { sleep } from "@dxos/async";
|
|
31
|
+
import { next as A } from "@dxos/automerge/automerge";
|
|
32
|
+
import { SpaceObjectGenerator } from "@dxos/echo-generator";
|
|
33
|
+
import { create } from "@dxos/echo-schema";
|
|
34
|
+
import { log } from "@dxos/log";
|
|
35
|
+
import { DocumentType, TextType } from "@dxos/plugin-markdown/types";
|
|
36
|
+
import { TLDrawStoreAdapter } from "@dxos/plugin-sketch";
|
|
37
|
+
import { CanvasType, DiagramType, TLDRAW_SCHEMA } from "@dxos/plugin-sketch/types";
|
|
38
|
+
import { faker } from "@dxos/random";
|
|
39
|
+
import { createDocAccessor } from "@dxos/react-client/echo";
|
|
40
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-debug/src/scaffolding/generator.ts";
|
|
41
|
+
var SchemasNames;
|
|
42
|
+
(function(SchemasNames2) {
|
|
43
|
+
SchemasNames2["document"] = "dxos.org/type/Document";
|
|
44
|
+
SchemasNames2["diagram"] = "dxos.org/type/Diagram";
|
|
45
|
+
})(SchemasNames || (SchemasNames = {}));
|
|
46
|
+
var SchemasMap = {
|
|
47
|
+
["dxos.org/type/Document"]: DocumentType,
|
|
48
|
+
["dxos.org/type/Diagram"]: DiagramType
|
|
49
|
+
};
|
|
50
|
+
var ObjectGenerators = {
|
|
51
|
+
["dxos.org/type/Document"]: () => {
|
|
52
|
+
const name = faker.lorem.sentence();
|
|
53
|
+
return {
|
|
54
|
+
name,
|
|
55
|
+
content: create(TextType, {
|
|
56
|
+
content: ""
|
|
57
|
+
}),
|
|
58
|
+
threads: []
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
["dxos.org/type/Diagram"]: () => {
|
|
62
|
+
const name = faker.lorem.sentence();
|
|
63
|
+
return {
|
|
64
|
+
name,
|
|
65
|
+
canvas: create(CanvasType, {
|
|
66
|
+
schema: TLDRAW_SCHEMA,
|
|
67
|
+
content: {}
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var MutationsGenerators = {
|
|
73
|
+
["dxos.org/type/Document"]: async (object, params) => {
|
|
74
|
+
const accessor = createDocAccessor(object.content, [
|
|
75
|
+
"content"
|
|
76
|
+
]);
|
|
77
|
+
for (let i = 0; i < params.count; i++) {
|
|
78
|
+
const length = object.content?.content?.length ?? 0;
|
|
79
|
+
accessor.handle.change((doc) => {
|
|
80
|
+
A.splice(doc, accessor.path.slice(), 0, params.maxContentLength >= length ? 0 : params.mutationSize, faker.string.hexadecimal({
|
|
81
|
+
length: params.mutationSize - 1
|
|
82
|
+
}) + " ");
|
|
83
|
+
});
|
|
84
|
+
if (i % 100 === 0 || i === params.count - 1) {
|
|
85
|
+
log.info("Mutation:", {
|
|
86
|
+
mutationIdx: i
|
|
87
|
+
}, {
|
|
88
|
+
F: __dxlog_file,
|
|
89
|
+
L: 73,
|
|
90
|
+
S: void 0,
|
|
91
|
+
C: (f, a) => f(...a)
|
|
92
|
+
});
|
|
93
|
+
await sleep(1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
["dxos.org/type/Diagram"]: async (object, params) => {
|
|
98
|
+
const store = new TLDrawStoreAdapter();
|
|
99
|
+
await store.open(createDocAccessor(object.canvas, [
|
|
100
|
+
"content"
|
|
101
|
+
]));
|
|
102
|
+
const app = new Editor({
|
|
103
|
+
store: store.store,
|
|
104
|
+
shapeUtils: defaultShapeUtils,
|
|
105
|
+
bindingUtils: defaultBindingUtils,
|
|
106
|
+
tools: defaultTools,
|
|
107
|
+
getContainer: () => document.getElementsByTagName("body")[0]
|
|
108
|
+
});
|
|
109
|
+
const r = 100;
|
|
110
|
+
const a = 0.05;
|
|
111
|
+
const cx = 200;
|
|
112
|
+
const cy = 200;
|
|
113
|
+
for (let i = 0; i < params.count; i++) {
|
|
114
|
+
const t = i;
|
|
115
|
+
const t1 = i + 1;
|
|
116
|
+
const x = cx + a * t * r * Math.cos(t);
|
|
117
|
+
const y = cy + a * t * r * Math.sin(t);
|
|
118
|
+
const x1 = cx + a * t1 * r * Math.cos(t1);
|
|
119
|
+
const y1 = cy + a * t1 * r * Math.sin(t1);
|
|
120
|
+
app.createShape({
|
|
121
|
+
id: createShapeId(),
|
|
122
|
+
isLocked: false,
|
|
123
|
+
meta: {},
|
|
124
|
+
opacity: 1,
|
|
125
|
+
parentId: "page:page",
|
|
126
|
+
props: {
|
|
127
|
+
arrowheadEnd: "none",
|
|
128
|
+
arrowheadStart: "none",
|
|
129
|
+
bend: 0,
|
|
130
|
+
color: "black",
|
|
131
|
+
dash: "draw",
|
|
132
|
+
start: {
|
|
133
|
+
x,
|
|
134
|
+
y
|
|
135
|
+
},
|
|
136
|
+
end: {
|
|
137
|
+
x: x1,
|
|
138
|
+
y: y1
|
|
139
|
+
},
|
|
140
|
+
fill: "none",
|
|
141
|
+
font: "draw",
|
|
142
|
+
labelColor: "black",
|
|
143
|
+
labelPosition: 0.5,
|
|
144
|
+
scale: 1,
|
|
145
|
+
size: "m"
|
|
146
|
+
},
|
|
147
|
+
rotation: 0,
|
|
148
|
+
type: "arrow",
|
|
149
|
+
typeName: "shape",
|
|
150
|
+
x: 0,
|
|
151
|
+
y: 0
|
|
152
|
+
});
|
|
153
|
+
if (i % 100 === 0) {
|
|
154
|
+
await sleep(1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var createSpaceObjectGenerator = (space) => new SpaceObjectGenerator(space, SchemasMap, ObjectGenerators, MutationsGenerators);
|
|
160
|
+
|
|
161
|
+
// packages/plugins/experimental/plugin-debug/src/components/ObjectCreator.tsx
|
|
162
|
+
var CREATE_OBJECTS_IN_ONE_CHUNK = 10;
|
|
163
|
+
var ObjectCreator = ({ space, onAddObjects }) => {
|
|
164
|
+
const generator = useMemo(() => createSpaceObjectGenerator(space), [
|
|
165
|
+
space
|
|
166
|
+
]);
|
|
167
|
+
const [objectsToCreate, setObjectsToCreate] = useState([
|
|
168
|
+
{
|
|
169
|
+
enabled: true,
|
|
170
|
+
schema: SchemasNames.document,
|
|
171
|
+
objectsCount: 10,
|
|
172
|
+
mutationsCount: 10,
|
|
173
|
+
mutationSize: 10,
|
|
174
|
+
maxContentLength: 1e3
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
enabled: true,
|
|
178
|
+
schema: SchemasNames.diagram,
|
|
179
|
+
objectsCount: 10,
|
|
180
|
+
mutationsCount: 10,
|
|
181
|
+
mutationSize: 10,
|
|
182
|
+
maxContentLength: 1e3
|
|
183
|
+
}
|
|
184
|
+
]);
|
|
185
|
+
const handleCreate = async () => {
|
|
186
|
+
for (const params of objectsToCreate) {
|
|
187
|
+
if (!params.enabled) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
let objectsCreated = 0;
|
|
191
|
+
while (objectsCreated < params.objectsCount) {
|
|
192
|
+
const objects = await generator.createObjects({
|
|
193
|
+
[params.schema]: Math.min(CREATE_OBJECTS_IN_ONE_CHUNK, params.objectsCount - objectsCreated)
|
|
194
|
+
});
|
|
195
|
+
await generator.mutateObjects(objects, {
|
|
196
|
+
count: params.mutationsCount,
|
|
197
|
+
mutationSize: params.mutationSize,
|
|
198
|
+
maxContentLength: params.maxContentLength
|
|
199
|
+
});
|
|
200
|
+
objectsCreated += objects.length;
|
|
201
|
+
onAddObjects?.(objects);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
await space.db.flush();
|
|
205
|
+
};
|
|
206
|
+
const handleChangeOnRow = (row, key, value) => {
|
|
207
|
+
const newObjects = [
|
|
208
|
+
...objectsToCreate
|
|
209
|
+
];
|
|
210
|
+
Object.assign(newObjects.find((object) => object.schema === row.schema), {
|
|
211
|
+
[key]: value
|
|
212
|
+
});
|
|
213
|
+
setObjectsToCreate(newObjects);
|
|
214
|
+
};
|
|
215
|
+
const { helper, builder } = createColumnBuilder();
|
|
216
|
+
const columns = [
|
|
217
|
+
helper.accessor("enabled", builder.switch({
|
|
218
|
+
label: "Enabled",
|
|
219
|
+
onUpdate: handleChangeOnRow
|
|
220
|
+
})),
|
|
221
|
+
helper.accessor("schema", builder.string({
|
|
222
|
+
classNames: "font-mono",
|
|
223
|
+
label: "Schema"
|
|
224
|
+
})),
|
|
225
|
+
helper.accessor("objectsCount", builder.number({
|
|
226
|
+
label: "Objects",
|
|
227
|
+
onUpdate: handleChangeOnRow
|
|
228
|
+
})),
|
|
229
|
+
helper.accessor("mutationsCount", builder.number({
|
|
230
|
+
label: "Mutations",
|
|
231
|
+
onUpdate: handleChangeOnRow
|
|
232
|
+
})),
|
|
233
|
+
helper.accessor("mutationSize", builder.number({
|
|
234
|
+
label: "Mut. Size",
|
|
235
|
+
onUpdate: handleChangeOnRow
|
|
236
|
+
})),
|
|
237
|
+
helper.accessor("maxContentLength", builder.number({
|
|
238
|
+
label: "Length",
|
|
239
|
+
onUpdate: handleChangeOnRow
|
|
240
|
+
}))
|
|
241
|
+
];
|
|
242
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DensityProvider, {
|
|
243
|
+
density: "fine"
|
|
244
|
+
}, /* @__PURE__ */ React.createElement(Table.Root, null, /* @__PURE__ */ React.createElement(Table.Viewport, null, /* @__PURE__ */ React.createElement(Table.Main, {
|
|
245
|
+
columns,
|
|
246
|
+
data: objectsToCreate
|
|
247
|
+
})))), /* @__PURE__ */ React.createElement(Button, {
|
|
248
|
+
onClick: handleCreate
|
|
249
|
+
}, "Create"));
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// packages/plugins/experimental/plugin-debug/src/components/DebugSpace.tsx
|
|
253
|
+
var DEFAULT_COUNT = 100;
|
|
254
|
+
var DEFAULT_PERIOD = 500;
|
|
255
|
+
var DEFAULT_JITTER = 50;
|
|
256
|
+
var useRefresh = () => {
|
|
257
|
+
const [update, setUpdate] = useState2({});
|
|
258
|
+
return [
|
|
259
|
+
update,
|
|
260
|
+
() => setUpdate({})
|
|
261
|
+
];
|
|
262
|
+
};
|
|
263
|
+
var DebugSpace = ({ space, onAddObjects }) => {
|
|
264
|
+
const { connect } = useSpaceInvitation(space?.key);
|
|
265
|
+
const client = useClient();
|
|
266
|
+
const [data, setData] = useState2({});
|
|
267
|
+
const [update, handleUpdate] = useRefresh();
|
|
268
|
+
useAsyncEffect(async (isMounted) => {
|
|
269
|
+
const data2 = await client.diagnostics({
|
|
270
|
+
truncate: true
|
|
271
|
+
});
|
|
272
|
+
if (isMounted()) {
|
|
273
|
+
setData(data2?.diagnostics?.spaces?.find(({ key }) => {
|
|
274
|
+
return space.key.toHex().startsWith(key);
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
}, [
|
|
278
|
+
space,
|
|
279
|
+
update
|
|
280
|
+
]);
|
|
281
|
+
const download = useFileDownload();
|
|
282
|
+
const handleCopy = async () => {
|
|
283
|
+
download(new Blob([
|
|
284
|
+
JSON.stringify(data, void 0, 2)
|
|
285
|
+
], {
|
|
286
|
+
type: "text/plain"
|
|
287
|
+
}), `${(/* @__PURE__ */ new Date()).toISOString().replace(/\W/g, "-")}.json`);
|
|
288
|
+
};
|
|
289
|
+
const [mutationCount, setMutationCount] = useState2(String(DEFAULT_COUNT));
|
|
290
|
+
const [mutationInterval, setMutationInterval] = useState2(String(DEFAULT_PERIOD));
|
|
291
|
+
const [mutationJitter, setMutationJitter] = useState2(String(DEFAULT_JITTER));
|
|
292
|
+
const generator = useMemo2(() => createSpaceObjectGenerator(space), [
|
|
293
|
+
space
|
|
294
|
+
]);
|
|
295
|
+
const { running, start, stop } = useContext(DebugContext);
|
|
296
|
+
const handleToggleRunning = () => {
|
|
297
|
+
if (running) {
|
|
298
|
+
stop();
|
|
299
|
+
handleUpdate();
|
|
300
|
+
} else {
|
|
301
|
+
start(async () => {
|
|
302
|
+
const { objects } = await space.db.query(Filter.schema(DocumentType2)).run();
|
|
303
|
+
if (objects.length) {
|
|
304
|
+
const object = faker2.helpers.arrayElement(objects);
|
|
305
|
+
await generator.mutateObject(object, {
|
|
306
|
+
count: 10,
|
|
307
|
+
mutationSize: 10,
|
|
308
|
+
maxContentLength: 1e3
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}, {
|
|
312
|
+
count: safeParseInt(mutationCount) ?? 0,
|
|
313
|
+
interval: safeParseInt(mutationInterval) ?? 0,
|
|
314
|
+
jitter: safeParseInt(mutationJitter) ?? 0
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
const handleCreateInvitation = () => {
|
|
319
|
+
const invitation = space.share({
|
|
320
|
+
type: Invitation.Type.INTERACTIVE,
|
|
321
|
+
authMethod: Invitation.AuthMethod.NONE,
|
|
322
|
+
multiUse: true
|
|
323
|
+
});
|
|
324
|
+
connect(invitation);
|
|
325
|
+
const code = InvitationEncoder.encode(invitation.get());
|
|
326
|
+
new URL(window.origin).searchParams.set("spaceInvitationCode", code);
|
|
327
|
+
const url = `${window.origin}?spaceInvitationCode=${code}`;
|
|
328
|
+
void navigator.clipboard.writeText(url);
|
|
329
|
+
};
|
|
330
|
+
const handleCreateEpoch = async () => {
|
|
331
|
+
await space.internal.createEpoch();
|
|
332
|
+
handleUpdate();
|
|
333
|
+
};
|
|
334
|
+
return /* @__PURE__ */ React2.createElement(DebugPanel, {
|
|
335
|
+
menu: /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", {
|
|
336
|
+
className: "relative",
|
|
337
|
+
title: "mutation count"
|
|
338
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
339
|
+
autoComplete: "off",
|
|
340
|
+
size: 5,
|
|
341
|
+
classNames: "w-[100px] text-right pie-[22px]",
|
|
342
|
+
placeholder: "Count",
|
|
343
|
+
value: mutationCount,
|
|
344
|
+
onChange: ({ target: { value } }) => setMutationCount(value)
|
|
345
|
+
})), /* @__PURE__ */ React2.createElement(Flag, {
|
|
346
|
+
className: mx("absolute inline-end-1 block-start-1 mt-[6px]", getSize(3))
|
|
347
|
+
})), /* @__PURE__ */ React2.createElement("div", {
|
|
348
|
+
className: "relative",
|
|
349
|
+
title: "mutation period"
|
|
350
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
351
|
+
autoComplete: "off",
|
|
352
|
+
size: 5,
|
|
353
|
+
classNames: "w-[100px] text-right pie-[22px]",
|
|
354
|
+
placeholder: "Interval",
|
|
355
|
+
value: mutationInterval,
|
|
356
|
+
onChange: ({ target: { value } }) => setMutationInterval(value)
|
|
357
|
+
})), /* @__PURE__ */ React2.createElement(Timer, {
|
|
358
|
+
className: mx("absolute inline-end-1 block-start-1 mt-[6px]", getSize(3))
|
|
359
|
+
})), /* @__PURE__ */ React2.createElement("div", {
|
|
360
|
+
className: "relative",
|
|
361
|
+
title: "mutation jitter"
|
|
362
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
363
|
+
autoComplete: "off",
|
|
364
|
+
size: 5,
|
|
365
|
+
classNames: "w-[100px] text-right pie-[22px]",
|
|
366
|
+
placeholder: "Jitter",
|
|
367
|
+
value: mutationJitter,
|
|
368
|
+
onChange: ({ target: { value } }) => setMutationJitter(value)
|
|
369
|
+
})), /* @__PURE__ */ React2.createElement(PlusMinus, {
|
|
370
|
+
className: mx("absolute inline-end-1 block-start-1 mt-[6px]", getSize(3))
|
|
371
|
+
})), /* @__PURE__ */ React2.createElement(Button2, {
|
|
372
|
+
onClick: handleToggleRunning
|
|
373
|
+
}, running ? /* @__PURE__ */ React2.createElement(HandPalm, {
|
|
374
|
+
className: getSize(5)
|
|
375
|
+
}) : /* @__PURE__ */ React2.createElement(Play, {
|
|
376
|
+
className: getSize(5)
|
|
377
|
+
})), /* @__PURE__ */ React2.createElement(Button2, {
|
|
378
|
+
onClick: handleUpdate
|
|
379
|
+
}, /* @__PURE__ */ React2.createElement(ArrowClockwise, {
|
|
380
|
+
className: getSize(5)
|
|
381
|
+
})), /* @__PURE__ */ React2.createElement(Button2, {
|
|
382
|
+
onClick: handleCopy
|
|
383
|
+
}, /* @__PURE__ */ React2.createElement(DownloadSimple, {
|
|
384
|
+
className: getSize(5)
|
|
385
|
+
})), /* @__PURE__ */ React2.createElement("div", {
|
|
386
|
+
className: "grow"
|
|
387
|
+
}), /* @__PURE__ */ React2.createElement(Button2, {
|
|
388
|
+
onClick: handleCreateEpoch,
|
|
389
|
+
title: "Create epoch"
|
|
390
|
+
}, /* @__PURE__ */ React2.createElement(FlagPennant, {
|
|
391
|
+
className: mx(getSize(5))
|
|
392
|
+
})), /* @__PURE__ */ React2.createElement(Button2, {
|
|
393
|
+
onClick: handleCreateInvitation,
|
|
394
|
+
title: "Create Space invitation"
|
|
395
|
+
}, /* @__PURE__ */ React2.createElement(UserCirclePlus, {
|
|
396
|
+
className: mx(getSize(5), "text-blue-500")
|
|
397
|
+
})))
|
|
398
|
+
}, /* @__PURE__ */ React2.createElement(ObjectCreator, {
|
|
399
|
+
space,
|
|
400
|
+
onAddObjects
|
|
401
|
+
}));
|
|
402
|
+
};
|
|
403
|
+
var DebugSpace_default = DebugSpace;
|
|
404
|
+
export {
|
|
405
|
+
DebugSpace_default as default
|
|
406
|
+
};
|
|
407
|
+
//# sourceMappingURL=DebugSpace-ZZ2JLU6F.mjs.map
|