@dxos/plugin-debug 0.7.5-main.9cb18ac → 0.7.5-main.9d2a38b

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 (64) hide show
  1. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs → DebugApp-LQHFFK3Y.mjs} +4 -2
  2. package/dist/lib/browser/{DebugApp-HCHR6GKO.mjs.map → DebugApp-LQHFFK3Y.mjs.map} +3 -3
  3. package/dist/lib/browser/{DebugSpace-V3K3PQP6.mjs → DebugSpace-4JHYA7FG.mjs} +7 -5
  4. package/dist/lib/browser/{DebugSpace-V3K3PQP6.mjs.map → DebugSpace-4JHYA7FG.mjs.map} +3 -3
  5. package/dist/lib/browser/{SpaceGenerator-Y2NXBQVR.mjs → SpaceGenerator-NJCG57CU.mjs} +7 -5
  6. package/dist/lib/browser/{SpaceGenerator-Y2NXBQVR.mjs.map → SpaceGenerator-NJCG57CU.mjs.map} +3 -3
  7. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs +177 -0
  8. package/dist/lib/browser/app-graph-builder-FXELWOFS.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-CAENAAHY.mjs → chunk-I3ON45JK.mjs} +3 -3
  10. package/dist/lib/browser/chunk-I3ON45JK.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-6CGQHKET.mjs → chunk-P7GHHMDB.mjs} +1 -1
  12. package/dist/lib/browser/chunk-P7GHHMDB.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +66 -712
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/react-context-OZU6J7G3.mjs +37 -0
  17. package/dist/lib/browser/react-context-OZU6J7G3.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-5GNO6NWP.mjs +468 -0
  19. package/dist/lib/browser/react-surface-5GNO6NWP.mjs.map +7 -0
  20. package/dist/lib/browser/settings-JCZUA643.mjs +25 -0
  21. package/dist/lib/browser/settings-JCZUA643.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +1 -2
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  25. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +185 -0
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/react-context.d.ts +8 -0
  29. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  31. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/settings.d.ts +4 -0
  33. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  34. package/dist/types/src/components/DebugStatus.d.ts.map +1 -1
  35. package/dist/types/src/index.d.ts +1 -2
  36. package/dist/types/src/index.d.ts.map +1 -1
  37. package/dist/types/src/meta.d.ts +1 -2
  38. package/dist/types/src/meta.d.ts.map +1 -1
  39. package/dist/types/src/types.d.ts +0 -3
  40. package/dist/types/src/types.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +43 -51
  43. package/src/DebugPlugin.tsx +58 -345
  44. package/src/capabilities/app-graph-builder.ts +177 -0
  45. package/src/capabilities/index.ts +10 -0
  46. package/src/capabilities/react-context.tsx +38 -0
  47. package/src/capabilities/react-surface.tsx +138 -0
  48. package/src/capabilities/settings.ts +18 -0
  49. package/src/components/DebugApp/DebugApp.tsx +1 -1
  50. package/src/components/DebugSettings.tsx +4 -4
  51. package/src/components/DebugSpace/DebugSpace.tsx +1 -1
  52. package/src/components/DebugStatus.tsx +3 -9
  53. package/src/components/SpaceGenerator/ObjectGenerator.tsx +3 -3
  54. package/src/components/SpaceGenerator/SpaceGenerator.tsx +1 -1
  55. package/src/index.ts +1 -4
  56. package/src/meta.ts +1 -1
  57. package/src/types.ts +0 -13
  58. package/dist/lib/browser/chunk-6CGQHKET.mjs.map +0 -7
  59. package/dist/lib/browser/chunk-CAENAAHY.mjs.map +0 -7
  60. package/dist/lib/browser/meta.mjs +0 -9
  61. package/dist/lib/browser/meta.mjs.map +0 -7
  62. package/dist/types/src/components/DebugSurface.d.ts +0 -9
  63. package/dist/types/src/components/DebugSurface.d.ts.map +0 -1
  64. package/src/components/DebugSurface.tsx +0 -55
@@ -0,0 +1,138 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback } from 'react';
6
+
7
+ import {
8
+ Capabilities,
9
+ contributes,
10
+ createIntent,
11
+ createSurface,
12
+ useCapability,
13
+ type PluginsContext,
14
+ } from '@dxos/app-framework';
15
+ import { Devtools } from '@dxos/devtools';
16
+ import { Graph } from '@dxos/plugin-graph';
17
+ import { SpaceAction, CollectionType } from '@dxos/plugin-space/types';
18
+ import {
19
+ SpaceState,
20
+ isSpace,
21
+ isEchoObject,
22
+ type ReactiveEchoObject,
23
+ type ReactiveObject,
24
+ type Space,
25
+ } from '@dxos/react-client/echo';
26
+
27
+ import {
28
+ DebugApp,
29
+ DebugObjectPanel,
30
+ DebugSettings,
31
+ DebugSpace,
32
+ DebugStatus,
33
+ SpaceGenerator,
34
+ Wireframe,
35
+ } from '../components';
36
+ import { DEBUG_PLUGIN } from '../meta';
37
+ import { type DebugSettingsProps } from '../types';
38
+
39
+ type SpaceDebug = {
40
+ type: string;
41
+ space: Space;
42
+ };
43
+
44
+ type GraphDebug = {
45
+ graph: Graph;
46
+ };
47
+
48
+ const isSpaceDebug = (data: any): data is SpaceDebug => data.type === `${DEBUG_PLUGIN}/space` && isSpace(data.space);
49
+ const isGraphDebug = (data: any): data is GraphDebug => data.graph instanceof Graph;
50
+
51
+ export default (context: PluginsContext) =>
52
+ contributes(Capabilities.ReactSurface, [
53
+ createSurface({
54
+ id: `${DEBUG_PLUGIN}/settings`,
55
+ role: 'settings',
56
+ filter: (data): data is any => data.subject === DEBUG_PLUGIN,
57
+ component: () => {
58
+ const settings = useCapability(Capabilities.SettingsStore).getStore<DebugSettingsProps>(DEBUG_PLUGIN)!.value;
59
+ return <DebugSettings settings={settings} />;
60
+ },
61
+ }),
62
+ createSurface({
63
+ id: `${DEBUG_PLUGIN}/status`,
64
+ role: 'status',
65
+ component: () => <DebugStatus />,
66
+ }),
67
+ createSurface({
68
+ id: `${DEBUG_PLUGIN}/complementary`,
69
+ role: 'complementary--debug',
70
+ filter: (data): data is { subject: ReactiveEchoObject<any> } => isEchoObject(data.subject),
71
+ component: ({ data }) => <DebugObjectPanel object={data.subject} />,
72
+ }),
73
+ createSurface({
74
+ id: `${DEBUG_PLUGIN}/devtools`,
75
+ role: 'article',
76
+ filter: (data): data is any => {
77
+ const settings = context
78
+ .requestCapability(Capabilities.SettingsStore)
79
+ .getStore<DebugSettingsProps>(DEBUG_PLUGIN)!.value;
80
+ return data.subject === 'devtools' && !!settings.devtools;
81
+ },
82
+ component: () => <Devtools />,
83
+ }),
84
+ createSurface({
85
+ id: `${DEBUG_PLUGIN}/space`,
86
+ role: 'article',
87
+ filter: (data): data is { subject: SpaceDebug } => isSpaceDebug(data.subject),
88
+ component: ({ data }) => {
89
+ const handleCreateObject = useCallback(
90
+ (objects: ReactiveObject<any>[]) => {
91
+ if (!isSpace(data.subject.space)) {
92
+ return;
93
+ }
94
+
95
+ const collection =
96
+ data.subject.space.state.get() === SpaceState.SPACE_READY &&
97
+ data.subject.space.properties[CollectionType.typename]?.target;
98
+ if (!(collection instanceof CollectionType)) {
99
+ return;
100
+ }
101
+
102
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
103
+ objects.forEach((object) => {
104
+ void dispatch(createIntent(SpaceAction.AddObject, { target: collection, object }));
105
+ });
106
+ },
107
+ [data.subject.space],
108
+ );
109
+
110
+ const deprecated = false;
111
+ return deprecated ? (
112
+ <DebugSpace space={data.subject.space} onAddObjects={handleCreateObject} />
113
+ ) : (
114
+ <SpaceGenerator space={data.subject.space} onCreateObjects={handleCreateObject} />
115
+ );
116
+ },
117
+ }),
118
+ createSurface({
119
+ id: `${DEBUG_PLUGIN}/graph`,
120
+ role: 'article',
121
+ filter: (data): data is { subject: GraphDebug } => isGraphDebug(data.subject),
122
+ component: ({ data }) => <DebugApp graph={data.subject.graph} />,
123
+ }),
124
+ createSurface({
125
+ id: `${DEBUG_PLUGIN}/wireframe`,
126
+ role: ['article', 'section'],
127
+ disposition: 'hoist',
128
+ filter: (data): data is { subject: ReactiveEchoObject<any> } => {
129
+ const settings = context
130
+ .requestCapability(Capabilities.SettingsStore)
131
+ .getStore<DebugSettingsProps>(DEBUG_PLUGIN)!.value;
132
+ return isEchoObject(data.subject) && !!settings.wireframe;
133
+ },
134
+ component: ({ data, role }) => (
135
+ <Wireframe label={`${role}:${name}`} object={data.subject} classNames='row-span-2 overflow-hidden' />
136
+ ),
137
+ }),
138
+ ]);
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes } from '@dxos/app-framework';
6
+ import { create } from '@dxos/react-client/echo';
7
+
8
+ import { DEBUG_PLUGIN } from '../meta';
9
+ import { type DebugSettingsProps, DebugSettingsSchema } from '../types';
10
+
11
+ export default () => {
12
+ const settings = create<DebugSettingsProps>({
13
+ debug: true,
14
+ devtools: true,
15
+ });
16
+
17
+ return contributes(Capabilities.Settings, { schema: DebugSettingsSchema, prefix: DEBUG_PLUGIN, value: settings });
18
+ };
@@ -59,7 +59,7 @@ export const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {
59
59
  </ToggleGroupItem>
60
60
  </ToggleGroup>
61
61
 
62
- <Toolbar.Expander />
62
+ <Toolbar.Separator variant='gap' />
63
63
  <Button onClick={(event) => handleResetClient(event.shiftKey)} title='Reset client'>
64
64
  <Warning className={mx(getSize(5), 'text-red-700')} />
65
65
  </Button>
@@ -5,7 +5,7 @@
5
5
  import { Gift, DownloadSimple, FirstAidKit } from '@phosphor-icons/react';
6
6
  import React, { useEffect, useState } from 'react';
7
7
 
8
- import { parseFileManagerPlugin, useResolvePlugin } from '@dxos/app-framework';
8
+ import { Capabilities, useCapabilities } from '@dxos/app-framework';
9
9
  import { type ConfigProto, defs, SaveConfig, Storage } from '@dxos/config';
10
10
  import { log } from '@dxos/log';
11
11
  import { useClient } from '@dxos/react-client';
@@ -34,7 +34,7 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
34
34
  const download = useFileDownload();
35
35
  // TODO(mykola): Get updates from other places that change Config.
36
36
  const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
37
- const fileManagerPlugin = useResolvePlugin(parseFileManagerPlugin);
37
+ const [upload] = useCapabilities(Capabilities.FileUploader);
38
38
 
39
39
  useEffect(() => {
40
40
  void Storage().then((config) => setStorageConfig(config));
@@ -52,8 +52,8 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
52
52
  const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
53
53
  download(file, fileName);
54
54
 
55
- if (fileManagerPlugin?.provides.file.upload) {
56
- const info = await fileManagerPlugin.provides.file.upload(new File([file], fileName), client.spaces.default);
55
+ if (upload) {
56
+ const info = await upload(new File([file], fileName), client.spaces.default);
57
57
  if (!info) {
58
58
  log.error('diagnostics failed to upload to IPFS');
59
59
  return;
@@ -158,7 +158,7 @@ export const DebugSpace: FC<{
158
158
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' size={5} onClick={handleUpdate} />
159
159
  <IconButton icon='ph--download-simple--regular' iconOnly label='Download' size={5} onClick={handleDownload} />
160
160
 
161
- <Toolbar.Expander />
161
+ <Toolbar.Separator variant='gap' />
162
162
  <IconButton
163
163
  icon='ph--flag-pennant--regular'
164
164
  iconOnly
@@ -4,10 +4,9 @@
4
4
 
5
5
  import React, { useEffect, useRef, useState } from 'react';
6
6
 
7
- import { firstIdInPart, parseGraphPlugin, parseNavigationPlugin, useResolvePlugin } from '@dxos/app-framework';
7
+ import { Capabilities, firstIdInPart, useCapability } from '@dxos/app-framework';
8
8
  import { TimeoutError } from '@dxos/async';
9
9
  import { StatsPanel, useStats } from '@dxos/devtools';
10
- import { log } from '@dxos/log';
11
10
  import { getActiveSpace } from '@dxos/plugin-space';
12
11
  import { StatusBar } from '@dxos/plugin-status-bar';
13
12
  import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
@@ -67,10 +66,7 @@ const ErrorIndicator = () => {
67
66
  useEffect(() => {
68
67
  const errorListener = (event: any) => {
69
68
  const error: Error = event.error ?? event.reason;
70
- // event.preventDefault();
71
69
  if (errorRef.current !== error) {
72
- // eslint-disable-next-line no-console
73
- log.error('onError', { event });
74
70
  errorRef.current = error;
75
71
  forceUpdate({});
76
72
  }
@@ -140,10 +136,8 @@ const SwarmIndicator = () => {
140
136
  // TODO(burdon): Merge with SaveStatus.
141
137
  const SavingIndicator = () => {
142
138
  const [state, _setState] = useState(0);
143
- const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
144
- const graphPlugin = useResolvePlugin(parseGraphPlugin);
145
- const location = navigationPlugin?.provides.location;
146
- const graph = graphPlugin?.provides.graph;
139
+ const location = useCapability(Capabilities.Location);
140
+ const { graph } = useCapability(Capabilities.AppGraph);
147
141
  const _space = location && graph ? getActiveSpace(graph, firstIdInPart(location.active, 'main')) : undefined;
148
142
  // TODO(dmaretskyi): Fix this when we have save status for automerge.
149
143
  // useEffect(() => {
@@ -5,14 +5,14 @@
5
5
  import { addressToA1Notation } from '@dxos/compute';
6
6
  import { type BaseObject, type TypedObject } from '@dxos/echo-schema';
7
7
  import { create, makeRef, type ReactiveObject } from '@dxos/live-object';
8
- import { DocumentType, TextType } from '@dxos/plugin-markdown/types';
9
- import { createSheet } from '@dxos/plugin-sheet';
8
+ import { DocumentType } from '@dxos/plugin-markdown/types';
9
+ import { createSheet } from '@dxos/plugin-sheet/types';
10
10
  import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
11
11
  import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
12
12
  import { faker } from '@dxos/random';
13
13
  import { Filter, type Space } from '@dxos/react-client/echo';
14
14
  import { TableType } from '@dxos/react-ui-table';
15
- import { createView } from '@dxos/schema';
15
+ import { createView, TextType } from '@dxos/schema';
16
16
  import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
17
17
  import { range } from '@dxos/util';
18
18
 
@@ -86,7 +86,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
86
86
  <div role='none' className='flex flex-col divide-y divide-separator'>
87
87
  <Toolbar.Root classNames='p-1'>
88
88
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
89
- <Toolbar.Expander />
89
+ <Toolbar.Separator variant='gap' />
90
90
  <div className='flex'>
91
91
  <Input.Root>
92
92
  <Input.TextInput
package/src/index.ts CHANGED
@@ -2,8 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { DebugPlugin } from './DebugPlugin';
6
-
7
5
  export * from './DebugPlugin';
8
-
9
- export default DebugPlugin;
6
+ export * from './meta';
package/src/meta.ts CHANGED
@@ -6,7 +6,7 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const DEBUG_PLUGIN = 'dxos.org/plugin/debug';
8
8
 
9
- export default {
9
+ export const meta = {
10
10
  id: DEBUG_PLUGIN,
11
11
  name: 'Debug',
12
12
  description: 'DXOS debugging tools.',
package/src/types.ts CHANGED
@@ -4,15 +4,8 @@
4
4
 
5
5
  import { type Context, createContext } from 'react';
6
6
 
7
- import type {
8
- GraphBuilderProvides,
9
- SettingsProvides,
10
- SurfaceProvides,
11
- TranslationsProvides,
12
- } from '@dxos/app-framework';
13
7
  import type { TimerCallback, TimerOptions } from '@dxos/async';
14
8
  import { S } from '@dxos/echo-schema';
15
- import { type PanelProvides } from '@dxos/plugin-deck/types';
16
9
 
17
10
  export type DebugContextType = {
18
11
  running: boolean;
@@ -35,9 +28,3 @@ export const DebugSettingsSchema = S.mutable(
35
28
  );
36
29
 
37
30
  export interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}
38
-
39
- export type DebugPluginProvides = SurfaceProvides &
40
- GraphBuilderProvides &
41
- SettingsProvides<DebugSettingsProps> &
42
- TranslationsProvides &
43
- PanelProvides;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nimport type {\n GraphBuilderProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport type { TimerCallback, TimerOptions } from '@dxos/async';\nimport { S } from '@dxos/echo-schema';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\n\nexport type DebugContextType = {\n running: boolean;\n start: (cb: TimerCallback, options: TimerOptions) => void;\n stop: () => void;\n};\n\nexport const DebugContext: Context<DebugContextType> = createContext<DebugContextType>({\n running: false,\n start: () => {},\n stop: () => {},\n});\n\nexport const DebugSettingsSchema = S.mutable(\n S.Struct({\n devtools: S.optional(S.Boolean),\n debug: S.optional(S.Boolean),\n wireframe: S.optional(S.Boolean),\n }),\n);\n\nexport interface DebugSettingsProps extends S.Schema.Type<typeof DebugSettingsSchema> {}\n\nexport type DebugPluginProvides = SurfaceProvides &\n GraphBuilderProvides &\n SettingsProvides<DebugSettingsProps> &\n TranslationsProvides &\n PanelProvides;\n"],
5
- "mappings": ";AAIA,SAAuBA,qBAAqB;AAS5C,SAASC,SAAS;AASX,IAAMC,eAA0CC,cAAgC;EACrFC,SAAS;EACTC,OAAO,MAAA;EAAO;EACdC,MAAM,MAAA;EAAO;AACf,CAAA;AAEO,IAAMC,sBAAsBC,EAAEC,QACnCD,EAAEE,OAAO;EACPC,UAAUH,EAAEI,SAASJ,EAAEK,OAAO;EAC9BC,OAAON,EAAEI,SAASJ,EAAEK,OAAO;EAC3BE,WAAWP,EAAEI,SAASJ,EAAEK,OAAO;AACjC,CAAA,CAAA;",
6
- "names": ["createContext", "S", "DebugContext", "createContext", "running", "start", "stop", "DebugSettingsSchema", "S", "mutable", "Struct", "devtools", "optional", "Boolean", "debug", "wireframe"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const DEBUG_PLUGIN = 'dxos.org/plugin/debug';\n\nexport default {\n id: DEBUG_PLUGIN,\n name: 'Debug',\n description: 'DXOS debugging tools.',\n icon: 'ph--bug--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-debug',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,eAAe;AAE5B,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
6
- "names": ["DEBUG_PLUGIN", "id", "name", "description", "icon", "source", "tags"]
7
- }
@@ -1,9 +0,0 @@
1
- import {
2
- DEBUG_PLUGIN,
3
- meta_default
4
- } from "./chunk-CAENAAHY.mjs";
5
- export {
6
- DEBUG_PLUGIN,
7
- meta_default as default
8
- };
9
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { type ThemedClassName } from '@dxos/react-ui';
3
- export type SurfaceDebugProps = ThemedClassName<{}>;
4
- /**
5
- * Show surface info.
6
- * NOTE: Remove from @dxos/app-framework if removing this.
7
- */
8
- export declare const DebugSurface: ({ classNames }: SurfaceDebugProps) => React.JSX.Element;
9
- //# sourceMappingURL=DebugSurface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DebugSurface.d.ts","sourceRoot":"","sources":["../../../../src/components/DebugSurface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKpE,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,sBAoC7D,CAAC"}
@@ -1,55 +0,0 @@
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 DebugSurface = ({ 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, role, 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'>{role}</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
- };