@dxos/plugin-debug 0.6.13 → 0.6.14-main.1366248

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 (71) hide show
  1. package/dist/lib/browser/{DebugGlobal-H56M2VL4.mjs → DebugGlobal-ZTCBF3XR.mjs} +5 -5
  2. package/dist/lib/browser/{DebugSpace-NHPMLATA.mjs → DebugSpace-22PW7RJM.mjs} +16 -41
  3. package/dist/lib/browser/DebugSpace-22PW7RJM.mjs.map +7 -0
  4. package/dist/lib/browser/chunk-CAENAAHY.mjs +18 -0
  5. package/dist/lib/browser/chunk-CAENAAHY.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-ED5L5YYI.mjs → chunk-H3BJHVRD.mjs} +5 -8
  7. package/dist/lib/browser/chunk-H3BJHVRD.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-RYK3J66D.mjs → chunk-LZEK532R.mjs} +11 -4
  9. package/dist/lib/browser/chunk-LZEK532R.mjs.map +7 -0
  10. package/dist/lib/browser/index.mjs +264 -145
  11. package/dist/lib/browser/index.mjs.map +4 -4
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/meta.mjs +1 -1
  14. package/dist/types/src/DebugPlugin.d.ts +1 -3
  15. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  16. package/dist/types/src/components/DebugObjectPanel.d.ts +7 -0
  17. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -0
  18. package/dist/types/src/components/DebugPanel.d.ts +3 -3
  19. package/dist/types/src/components/DebugPanel.d.ts.map +1 -1
  20. package/dist/types/src/components/DebugSpace.stories.d.ts +3 -13
  21. package/dist/types/src/components/DebugSpace.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  23. package/dist/types/src/components/ObjectCreator.d.ts +5 -5
  24. package/dist/types/src/components/ObjectCreator.d.ts.map +1 -1
  25. package/dist/types/src/components/ObjectCreator.stories.d.ts +3 -14
  26. package/dist/types/src/components/ObjectCreator.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/SurfaceDebug.d.ts +9 -0
  28. package/dist/types/src/components/SurfaceDebug.d.ts.map +1 -0
  29. package/dist/types/src/components/Wireframe.d.ts +5 -4
  30. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  31. package/dist/types/src/components/index.d.ts +3 -4
  32. package/dist/types/src/components/index.d.ts.map +1 -1
  33. package/dist/types/src/meta.d.ts +5 -9
  34. package/dist/types/src/meta.d.ts.map +1 -1
  35. package/dist/types/src/scaffolding/generator.d.ts +1 -2
  36. package/dist/types/src/scaffolding/generator.d.ts.map +1 -1
  37. package/dist/types/src/translations.d.ts +1 -0
  38. package/dist/types/src/translations.d.ts.map +1 -1
  39. package/dist/types/src/types.d.ts +10 -6
  40. package/dist/types/src/types.d.ts.map +1 -1
  41. package/package.json +46 -47
  42. package/src/DebugPlugin.tsx +137 -47
  43. package/src/components/DebugObjectPanel.tsx +22 -0
  44. package/src/components/DebugPanel.tsx +4 -9
  45. package/src/components/DebugSettings.tsx +13 -13
  46. package/src/components/DebugSpace.stories.tsx +6 -3
  47. package/src/components/DebugStatus.tsx +20 -13
  48. package/src/components/ObjectCreator.stories.tsx +13 -10
  49. package/src/components/ObjectCreator.tsx +12 -21
  50. package/src/components/SurfaceDebug.tsx +55 -0
  51. package/src/components/Wireframe.tsx +20 -11
  52. package/src/components/index.ts +4 -5
  53. package/src/meta.ts +16 -0
  54. package/src/scaffolding/generator.ts +4 -15
  55. package/src/translations.ts +1 -0
  56. package/src/types.ts +13 -6
  57. package/dist/lib/browser/DebugSpace-NHPMLATA.mjs.map +0 -7
  58. package/dist/lib/browser/DevtoolsMain-RWT3FLJ6.mjs +0 -15
  59. package/dist/lib/browser/DevtoolsMain-RWT3FLJ6.mjs.map +0 -7
  60. package/dist/lib/browser/chunk-ED5L5YYI.mjs.map +0 -7
  61. package/dist/lib/browser/chunk-RYK3J66D.mjs.map +0 -7
  62. package/dist/lib/browser/chunk-WEGYHXMB.mjs +0 -21
  63. package/dist/lib/browser/chunk-WEGYHXMB.mjs.map +0 -7
  64. package/dist/types/src/components/DevtoolsMain.d.ts +0 -4
  65. package/dist/types/src/components/DevtoolsMain.d.ts.map +0 -1
  66. package/dist/types/src/types.test.d.ts +0 -2
  67. package/dist/types/src/types.test.d.ts.map +0 -1
  68. package/src/components/DevtoolsMain.tsx +0 -15
  69. package/src/meta.tsx +0 -19
  70. package/src/types.test.ts +0 -13
  71. /package/dist/lib/browser/{DebugGlobal-H56M2VL4.mjs.map → DebugGlobal-ZTCBF3XR.mjs.map} +0 -0
@@ -3,29 +3,24 @@
3
3
  //
4
4
 
5
5
  import { formatDistance } from 'date-fns';
6
- import React, { type FC, type PropsWithChildren, type ReactNode } from 'react';
6
+ import React, { type PropsWithChildren, type ReactNode } from 'react';
7
7
 
8
8
  import { useConfig } from '@dxos/react-client';
9
- import { DensityProvider } from '@dxos/react-ui';
10
9
 
11
- export const DebugPanel: FC<PropsWithChildren<{ menu: ReactNode }>> = ({ menu, children }) => {
10
+ export const DebugPanel = ({ menu, children }: PropsWithChildren<{ menu: ReactNode }>) => {
12
11
  const config = useConfig();
13
12
  return (
14
13
  <>
15
- <div className='flex shrink-0 p-2 space-x-2'>
16
- <DensityProvider density='fine'>{menu}</DensityProvider>
17
- </div>
14
+ <div className='flex shrink-0 p-2 space-x-2'>{menu}</div>
18
15
  <div className='flex flex-col grow px-2 overflow-hidden'>
19
16
  <div className='flex flex-col grow overflow-auto'>{children}</div>
20
-
21
17
  {config.values?.runtime?.app?.build?.timestamp && (
22
18
  <div className='p-2 text-sm font-mono'>
23
- {config.values?.runtime?.app?.build?.version} (
19
+ {config.values?.runtime?.app?.build?.version}
24
20
  {formatDistance(new Date(config.values?.runtime?.app?.build?.timestamp), new Date(), {
25
21
  addSuffix: true,
26
22
  includeSeconds: true,
27
23
  })}
28
- )
29
24
  </div>
30
25
  )}
31
26
  </div>
@@ -8,9 +8,9 @@ import React, { useEffect, useState } from 'react';
8
8
  import { parseFileManagerPlugin, useResolvePlugin } from '@dxos/app-framework';
9
9
  import { type ConfigProto, defs, SaveConfig, Storage } from '@dxos/config';
10
10
  import { log } from '@dxos/log';
11
- import { SettingsValue } from '@dxos/plugin-settings';
12
11
  import { useClient } from '@dxos/react-client';
13
12
  import { useTranslation, Button, Toast, Input, useFileDownload, Select } from '@dxos/react-ui';
13
+ import { DeprecatedFormInput } from '@dxos/react-ui-data';
14
14
  import { getSize, mx } from '@dxos/react-ui-theme';
15
15
  import { setDeep } from '@dxos/util';
16
16
 
@@ -80,25 +80,25 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
80
80
 
81
81
  return (
82
82
  <>
83
- <SettingsValue label={t('settings show debug panel')}>
83
+ <DeprecatedFormInput label={t('settings show debug panel')}>
84
84
  <Input.Switch checked={settings.debug} onCheckedChange={(checked) => (settings.debug = !!checked)} />
85
- </SettingsValue>
86
- <SettingsValue label={t('settings show devtools panel')}>
85
+ </DeprecatedFormInput>
86
+ <DeprecatedFormInput label={t('settings show devtools panel')}>
87
87
  <Input.Switch checked={settings.devtools} onCheckedChange={(checked) => (settings.devtools = !!checked)} />
88
- </SettingsValue>
89
- <SettingsValue label={t('settings wireframe')}>
88
+ </DeprecatedFormInput>
89
+ <DeprecatedFormInput label={t('settings wireframe')}>
90
90
  <Input.Switch checked={settings.wireframe} onCheckedChange={(checked) => (settings.wireframe = !!checked)} />
91
- </SettingsValue>
92
- <SettingsValue label={t('settings download diagnostics')}>
91
+ </DeprecatedFormInput>
92
+ <DeprecatedFormInput label={t('settings download diagnostics')}>
93
93
  <Button onClick={handleDownload}>
94
94
  <DownloadSimple className={getSize(5)} />
95
95
  </Button>
96
- </SettingsValue>
97
- <SettingsValue label={t('settings repair')}>
96
+ </DeprecatedFormInput>
97
+ <DeprecatedFormInput label={t('settings repair')}>
98
98
  <Button onClick={handleRepair}>
99
99
  <FirstAidKit className={getSize(5)} />
100
100
  </Button>
101
- </SettingsValue>
101
+ </DeprecatedFormInput>
102
102
 
103
103
  {/* TODO(burdon): Move to layout? */}
104
104
  {toast && (
@@ -113,7 +113,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
113
113
  </Toast.Root>
114
114
  )}
115
115
 
116
- <SettingsValue label={t('settings choose storage adaptor')}>
116
+ <DeprecatedFormInput label={t('settings choose storage adaptor')}>
117
117
  <Select.Root
118
118
  value={
119
119
  Object.entries(StorageAdapters).find(
@@ -144,7 +144,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
144
144
  </Select.Content>
145
145
  </Select.Portal>
146
146
  </Select.Root>
147
- </SettingsValue>
147
+ </DeprecatedFormInput>
148
148
  </>
149
149
  );
150
150
  };
@@ -4,6 +4,7 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
+ import { type Meta } from '@storybook/react';
7
8
  import React, { useEffect } from 'react';
8
9
 
9
10
  import { createSpaceObjectGenerator } from '@dxos/echo-generator';
@@ -28,8 +29,10 @@ const Story = () => {
28
29
  return <DebugSpace space={space} />;
29
30
  };
30
31
 
31
- export default {
32
- title: 'plugin-debug/DebugSpace',
32
+ export const Default = {};
33
+
34
+ const meta: Meta = {
35
+ title: 'plugins/plugin-debug/DebugSpace',
33
36
  component: DebugSpace,
34
37
  render: () => <ClientRepeater component={Story} createSpace />,
35
38
  parameters: {
@@ -37,4 +40,4 @@ export default {
37
40
  },
38
41
  };
39
42
 
40
- export const Default = {};
43
+ export default meta;
@@ -2,7 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { ChartBar, Circle, Lightning, LightningSlash } from '@phosphor-icons/react';
6
5
  import React, { useEffect, useRef, useState } from 'react';
7
6
 
8
7
  import { firstIdInPart, parseGraphPlugin, parseNavigationPlugin, useResolvePlugin } from '@dxos/app-framework';
@@ -13,7 +12,8 @@ import { getActiveSpace } from '@dxos/plugin-space';
13
12
  import { StatusBar } from '@dxos/plugin-status-bar';
14
13
  import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
15
14
  import { useNetworkStatus } from '@dxos/react-client/mesh';
16
- import { getSize, mx } from '@dxos/react-ui-theme';
15
+ import { Icon } from '@dxos/react-ui';
16
+ import { mx } from '@dxos/react-ui-theme';
17
17
 
18
18
  const styles = {
19
19
  success: 'text-sky-300 dark:text-green-700',
@@ -97,13 +97,13 @@ const ErrorIndicator = () => {
97
97
  if (errorRef.current) {
98
98
  return (
99
99
  <StatusBar.Button title={errorRef.current.message} onClick={handleReset}>
100
- <Circle weight='fill' className={mx(styles.error, getSize(3))} />
100
+ <Icon icon='ph--warning-circle--duotone' size={4} classNames={styles.error} />
101
101
  </StatusBar.Button>
102
102
  );
103
103
  } else {
104
104
  return (
105
105
  <StatusBar.Item title='No errors.'>
106
- <Circle weight='fill' className={getSize(3)} />
106
+ <Icon icon='ph--check--regular' size={4} />
107
107
  </StatusBar.Item>
108
108
  );
109
109
  }
@@ -122,21 +122,22 @@ const SwarmIndicator = () => {
122
122
  if (state === 0) {
123
123
  return (
124
124
  <StatusBar.Item title='Connected to swarm.'>
125
- <Lightning className={getSize(4)} />
125
+ <Icon icon='ph--lightning--regular' size={4} />
126
126
  </StatusBar.Item>
127
127
  );
128
128
  } else {
129
129
  return (
130
130
  <StatusBar.Item title='Disconnected from swarm.'>
131
- <LightningSlash className={mx(styles.warning, getSize(4))} />
131
+ <Icon icon='ph--lightning-slash--regular' size={4} classNames={styles.warning} />
132
132
  </StatusBar.Item>
133
133
  );
134
134
  }
135
135
  };
136
136
 
137
137
  /**
138
- * Space saving indicator.
138
+ * Data saving indicator.
139
139
  */
140
+ // TODO(burdon): Merge with SaveStatus.
140
141
  const SavingIndicator = () => {
141
142
  const [state, _setState] = useState(0);
142
143
  const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
@@ -167,20 +168,20 @@ const SavingIndicator = () => {
167
168
  case 2:
168
169
  return (
169
170
  <StatusBar.Item title='Edit not saved.'>
170
- <Circle weight='fill' className={mx(styles.warning, getSize(3))} />
171
+ <Icon icon='ph--circle--duotone' size={4} classNames={styles.warning} />
171
172
  </StatusBar.Item>
172
173
  );
173
174
  case 1:
174
175
  return (
175
176
  <StatusBar.Item title='Saving...'>
176
- <Circle weight='fill' className={mx(styles.success, getSize(3))} />
177
+ <Icon icon='ph--circle--duotone' size={4} classNames={styles.success} />
177
178
  </StatusBar.Item>
178
179
  );
179
180
  case 0:
180
181
  default:
181
182
  return (
182
183
  <StatusBar.Item title='Modified indicator.'>
183
- <Circle weight='fill' className={getSize(3)} />
184
+ <Icon icon='ph--circle--duotone' size={4} />
184
185
  </StatusBar.Item>
185
186
  );
186
187
  }
@@ -193,10 +194,16 @@ const PerformanceIndicator = () => {
193
194
  return (
194
195
  <>
195
196
  <StatusBar.Button onClick={() => setVisible((visible) => !visible)} title='Performance panels'>
196
- <ChartBar />
197
+ <Icon icon='ph--chart-bar--regular' size={4} />
197
198
  </StatusBar.Button>
198
199
  {visible && (
199
- <div className='z-20 absolute bottom-[24px] w-[450px] border-l border-y border-separator'>
200
+ <div
201
+ className={mx(
202
+ 'z-20 absolute bottom-[--statusbar-size] right-4 w-[450px]',
203
+ 'overflow-x-hidden overflow-y-auto scrollbar-thin',
204
+ 'border-x border-y border-separator',
205
+ )}
206
+ >
200
207
  <StatsPanel stats={stats} onRefresh={refreshStats} />
201
208
  </div>
202
209
  )}
@@ -204,7 +211,7 @@ const PerformanceIndicator = () => {
204
211
  );
205
212
  };
206
213
 
207
- const indicators = [PerformanceIndicator, SavingIndicator, ErrorIndicator, SwarmIndicator];
214
+ const indicators = [SavingIndicator, SwarmIndicator, PerformanceIndicator, ErrorIndicator];
208
215
 
209
216
  export const DebugStatus = () => {
210
217
  return (
@@ -4,15 +4,16 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import React, { type FC, useEffect } from 'react';
7
+ import { type Meta } from '@storybook/react';
8
+ import React, { useEffect } from 'react';
8
9
 
9
10
  import { createSpaceObjectGenerator } from '@dxos/echo-generator';
10
11
  import { type ReactiveObject, useSpaces } from '@dxos/react-client/echo';
11
12
  import { ClientRepeater } from '@dxos/react-client/testing';
12
13
 
13
- import { ObjectCreator } from './ObjectCreator';
14
+ import { ObjectCreator, type ObjectCreatorProps } from './ObjectCreator';
14
15
 
15
- const Story: FC = () => {
16
+ const Story = () => {
16
17
  const [space] = useSpaces();
17
18
  useEffect(() => {
18
19
  if (space) {
@@ -21,19 +22,21 @@ const Story: FC = () => {
21
22
  }
22
23
  }, [space]);
23
24
 
24
- const handleCreate = (objects: ReactiveObject<any>[]) => {
25
- console.log('Created:', objects);
26
- };
27
-
28
25
  if (!space) {
29
26
  return null;
30
27
  }
31
28
 
29
+ const handleCreate: ObjectCreatorProps['onAddObjects'] = (objects: ReactiveObject<any>[]) => {
30
+ console.log('Created:', objects);
31
+ };
32
+
32
33
  return <ObjectCreator space={space} onAddObjects={handleCreate} />;
33
34
  };
34
35
 
35
- export default {
36
- title: 'plugin-debug/SchemaList',
36
+ export const Default = {};
37
+
38
+ const meta: Meta = {
39
+ title: 'plugins/plugin-debug/SchemaList',
37
40
  component: ObjectCreator,
38
41
  render: () => <ClientRepeater component={Story} createSpace />,
39
42
  parameters: {
@@ -41,4 +44,4 @@ export default {
41
44
  },
42
45
  };
43
46
 
44
- export const Default = {};
47
+ export default meta;
@@ -2,11 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { type FC, useMemo, useState } from 'react';
5
+ import React, { useMemo, useState } from 'react';
6
6
 
7
- import { type EchoReactiveObject, type ReactiveObject } from '@dxos/echo-schema';
8
- import { type Space } from '@dxos/react-client/echo';
9
- import { Button, DensityProvider } from '@dxos/react-ui';
7
+ import { type EchoReactiveObject, type ReactiveObject, type Space } from '@dxos/react-client/echo';
8
+ import { Button } from '@dxos/react-ui';
10
9
  import { createColumnBuilder, type TableColumnDef, Table } from '@dxos/react-ui-table';
11
10
 
12
11
  import { SchemasNames, createSpaceObjectGenerator } from '../scaffolding';
@@ -22,10 +21,12 @@ export type CreateObjectsParams = {
22
21
 
23
22
  const CREATE_OBJECTS_IN_ONE_CHUNK = 10;
24
23
 
25
- export const ObjectCreator: FC<{
24
+ export type ObjectCreatorProps = {
26
25
  space: Space;
27
26
  onAddObjects?: (objects: ReactiveObject<any>[]) => void;
28
- }> = ({ space, onAddObjects }) => {
27
+ };
28
+
29
+ export const ObjectCreator = ({ space, onAddObjects }: ObjectCreatorProps) => {
29
30
  const generator = useMemo(() => createSpaceObjectGenerator(space), [space]);
30
31
 
31
32
  const [objectsToCreate, setObjectsToCreate] = useState<CreateObjectsParams[]>([
@@ -45,14 +46,6 @@ export const ObjectCreator: FC<{
45
46
  mutationSize: 10,
46
47
  maxContentLength: 1000,
47
48
  },
48
- {
49
- enabled: true,
50
- schema: SchemasNames.sheet,
51
- objectsCount: 10,
52
- mutationsCount: 10,
53
- mutationSize: 10,
54
- maxContentLength: 1000,
55
- },
56
49
  ]);
57
50
 
58
51
  const handleCreate = async () => {
@@ -95,13 +88,11 @@ export const ObjectCreator: FC<{
95
88
 
96
89
  return (
97
90
  <>
98
- <DensityProvider density={'fine'}>
99
- <Table.Root>
100
- <Table.Viewport>
101
- <Table.Main<CreateObjectsParams> columns={columns} data={objectsToCreate} />
102
- </Table.Viewport>
103
- </Table.Root>
104
- </DensityProvider>
91
+ <Table.Root>
92
+ <Table.Viewport>
93
+ <Table.Main<CreateObjectsParams> columns={columns} data={objectsToCreate} />
94
+ </Table.Viewport>
95
+ </Table.Root>
105
96
  <Button onClick={handleCreate}>Create</Button>
106
97
  </>
107
98
  );
@@ -0,0 +1,55 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useMemo, useState } from 'react';
6
+
7
+ import { type DebugInfo, useSurfaceRoot } from '@dxos/app-framework';
8
+ import { Button, Icon, type ThemedClassName } from '@dxos/react-ui';
9
+ import { mx } from '@dxos/react-ui-theme';
10
+
11
+ // TODO(burdon): Move to debug panel.
12
+
13
+ export type SurfaceDebugProps = ThemedClassName<{}>;
14
+
15
+ /**
16
+ * Show surface info.
17
+ * NOTE: Remove from @dxos/app-framework if removing this.
18
+ */
19
+ export const SurfaceDebug = ({ classNames }: SurfaceDebugProps) => {
20
+ const context = useSurfaceRoot();
21
+ const [surfaces, setSurfaces] = useState<DebugInfo[]>([]);
22
+ const renderMap = useMemo(() => new Map<string, { last: number; delta: number }>(), []);
23
+ const handleRefresh = () => {
24
+ if (context.debugInfo) {
25
+ setSurfaces(
26
+ Array.from(context.debugInfo.values())
27
+ .sort(({ created: a }, { created: b }) => a - b)
28
+ .map((surface) => {
29
+ const state = renderMap.get(surface.id) ?? { last: 0, delta: 0 };
30
+ renderMap.set(surface.id, { last: surface.renderCount, delta: surface.renderCount - state.last });
31
+ return surface;
32
+ }),
33
+ );
34
+ }
35
+ };
36
+
37
+ return (
38
+ <div className={mx('flex flex-col border border-separator overflow-hidden bg-modalSurface', classNames)}>
39
+ <div className='flex flex-col h-full w-full p-2'>
40
+ {surfaces.map(({ id, name, renderCount }) => (
41
+ <div key={id} className='grid grid-cols-[1fr_3rem_3rem] items-center text-xs font-mono whitespace-nowrap'>
42
+ <span className='px-1 truncate'>{name}</span>
43
+ <span className='px-1 text-right'>{renderCount}</span>
44
+ <span className='px-1 text-right'>{renderMap.get(id)?.delta}</span>
45
+ </div>
46
+ ))}
47
+ </div>
48
+ <div className='flex justify-center text-sm items-center'>
49
+ <Button onClick={handleRefresh}>
50
+ <Icon icon='ph--arrow-clockwise--regular' size={4} />
51
+ </Button>
52
+ </div>
53
+ </div>
54
+ );
55
+ };
@@ -5,27 +5,36 @@
5
5
  import React from 'react';
6
6
  import { useResizeDetector } from 'react-resize-detector';
7
7
 
8
- import { createAttendableAttributes } from '@dxos/react-ui-attention';
8
+ import { fullyQualifiedId } from '@dxos/react-client/echo';
9
+ import { type ThemedClassName } from '@dxos/react-ui';
10
+ import { useAttendableAttributes } from '@dxos/react-ui-attention';
11
+ import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
9
12
  import { mx } from '@dxos/react-ui-theme';
10
13
 
14
+ // TODO(burdon): Create generic container with wireframe mode.
15
+ export type WireframeProps = ThemedClassName<{
16
+ label?: string;
17
+ object?: any;
18
+ }>;
19
+
11
20
  // TODO(burdon): Make focusable and attendable with input.
12
- export const Wireframe = ({ label, data, className }: { label?: string; data?: any; className?: string }) => {
13
- const attendableAttrs = createAttendableAttributes(data);
21
+ export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
22
+ const attendableAttrs = useAttendableAttributes(fullyQualifiedId(object));
14
23
  const { width, height, ref } = useResizeDetector();
15
24
  return (
16
- <div ref={ref} className={mx('relative grow min-bs-96', className)} {...attendableAttrs}>
17
- <div className='absolute inset-2 flex flex-col overflow-hidden font-mono'>
25
+ <div ref={ref} className={mx('relative grow min-bs-96', classNames)} {...attendableAttrs}>
26
+ <div className='absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono'>
18
27
  <div className='flex justify-between'>
19
28
  <div>{label}</div>
20
29
  <div>{`[${width}x${height}]`}</div>
21
30
  </div>
22
- <div className='flex grow overflow-auto'>
23
- {data && (
24
- <pre className='text-neutral-500 text-sm whitespace-pre-line'>{JSON.stringify(data, undefined, 1)}</pre>
25
- )}
26
- </div>
31
+ {object && (
32
+ <SyntaxHighlighter language='json' classNames='flex w-full text-xs opacity-75 rounded'>
33
+ {JSON.stringify(object, undefined, 2)}
34
+ </SyntaxHighlighter>
35
+ )}
27
36
  </div>
28
- <svg width={width} height={height} className='bg-transparent [&>*]:stroke-neutral-500'>
37
+ <svg width={width} height={height} className='bg-transparent [&>*]:text-subdued'>
29
38
  <rect x={0} y={0} width={width} height={height} strokeWidth={1} fill='none' />
30
39
  <line x1={0} y1={0} x2={width} y2={height} strokeWidth={1} />
31
40
  <line x1={0} y1={height} x2={width} y2={0} strokeWidth={1} />
@@ -2,13 +2,12 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import { lazy } from 'react';
6
6
 
7
- // Lazily load components for content surfaces.
8
- export const DebugGlobal = React.lazy(() => import('./DebugGlobal'));
9
- export const DebugSpace = React.lazy(() => import('./DebugSpace'));
10
- export const DevtoolsMain = React.lazy(() => import('./DevtoolsMain'));
7
+ export const DebugGlobal = lazy(() => import('./DebugGlobal'));
8
+ export const DebugSpace = lazy(() => import('./DebugSpace'));
11
9
 
10
+ export * from './DebugObjectPanel';
12
11
  export * from './DebugSettings';
13
12
  export * from './DebugStatus';
14
13
  export * from './Wireframe';
package/src/meta.ts ADDED
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type PluginMeta } from '@dxos/app-framework';
6
+
7
+ export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
8
+
9
+ export default {
10
+ id: DEBUG_PLUGIN,
11
+ name: 'Debug',
12
+ description: 'DXOS debugging tools.',
13
+ icon: 'ph--bug--regular',
14
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',
15
+ tags: ['experimental'],
16
+ } satisfies PluginMeta;
@@ -22,24 +22,22 @@ import {
22
22
  import { create } from '@dxos/echo-schema';
23
23
  import { log } from '@dxos/log';
24
24
  import { DocumentType, TextType } from '@dxos/plugin-markdown/types';
25
- import { createTestSheet } from '@dxos/plugin-sheet/testing';
26
- import { SheetType } from '@dxos/plugin-sheet/types';
27
- import { TLDrawStoreAdapter } from '@dxos/plugin-sketch';
25
+ import { TLDrawStoreAdapter } from '@dxos/plugin-sketch/sdk';
28
26
  import { CanvasType, DiagramType, TLDRAW_SCHEMA } from '@dxos/plugin-sketch/types';
29
27
  import { faker } from '@dxos/random';
30
28
  import { createDocAccessor, type Space } from '@dxos/react-client/echo';
31
29
 
32
- // TODO(wittjosiah): Remove? Just use typenames.
30
+ // TODO(burdon): Move to echo-generator.
31
+
32
+ // TODO(wittjosiah): Remove? Just use DXNs.
33
33
  export enum SchemasNames {
34
34
  document = 'dxos.org/type/Document',
35
35
  diagram = 'dxos.org/type/Diagram',
36
- sheet = 'dxos.org/type/SheetType',
37
36
  }
38
37
 
39
38
  export const SchemasMap: TestSchemaMap<SchemasNames> = {
40
39
  [SchemasNames.document]: DocumentType,
41
40
  [SchemasNames.diagram]: DiagramType,
42
- [SchemasNames.sheet]: SheetType,
43
41
  };
44
42
 
45
43
  export const ObjectGenerators: TestGeneratorMap<SchemasNames> = {
@@ -55,11 +53,6 @@ export const ObjectGenerators: TestGeneratorMap<SchemasNames> = {
55
53
  canvas: create(CanvasType, { schema: TLDRAW_SCHEMA, content: {} }),
56
54
  };
57
55
  },
58
-
59
- [SchemasNames.sheet]: () => {
60
- const name = faker.lorem.sentence({ min: 2, max: 3 });
61
- return createTestSheet({ name });
62
- },
63
56
  };
64
57
 
65
58
  export const MutationsGenerators: TestMutationsMap<SchemasNames> = {
@@ -147,10 +140,6 @@ export const MutationsGenerators: TestMutationsMap<SchemasNames> = {
147
140
  }
148
141
  }
149
142
  },
150
-
151
- [SchemasNames.sheet]: async (object, params) => {
152
- // TODO: Implement.
153
- },
154
143
  };
155
144
 
156
145
  export const createSpaceObjectGenerator = (space: Space) =>
@@ -30,6 +30,7 @@ export default [
30
30
  'settings storage adapter changed alert':
31
31
  'Warning: Swapping the storage adapter will make your data unavailable.',
32
32
  'settings space fragmentation': 'Enable AM space fragmentation',
33
+ 'open debug panel label': 'Show Debug',
33
34
  },
34
35
  },
35
36
  },
package/src/types.ts CHANGED
@@ -12,6 +12,8 @@ import type {
12
12
  TranslationsProvides,
13
13
  } from '@dxos/app-framework';
14
14
  import type { TimerCallback, TimerOptions } from '@dxos/async';
15
+ import { S } from '@dxos/echo-schema';
16
+ import { type PanelProvides } from '@dxos/plugin-deck/types';
15
17
 
16
18
  import { DEBUG_PLUGIN } from './meta';
17
19
 
@@ -32,14 +34,19 @@ export const DebugContext: Context<DebugContextType> = createContext<DebugContex
32
34
  stop: () => {},
33
35
  });
34
36
 
35
- export type DebugSettingsProps = {
36
- devtools?: boolean;
37
- debug?: boolean;
38
- wireframe?: boolean;
39
- };
37
+ export const DebugSettingsSchema = S.mutable(
38
+ S.Struct({
39
+ devtools: S.optional(S.Boolean),
40
+ debug: S.optional(S.Boolean),
41
+ wireframe: S.optional(S.Boolean),
42
+ }),
43
+ );
44
+
45
+ export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
40
46
 
41
47
  export type DebugPluginProvides = SurfaceProvides &
42
48
  IntentResolverProvides &
43
49
  GraphBuilderProvides &
44
50
  SettingsProvides<DebugSettingsProps> &
45
- TranslationsProvides;
51
+ TranslationsProvides &
52
+ PanelProvides;