@dxos/plugin-debug 0.8.3 → 0.8.4-main.1da679c

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 (76) hide show
  1. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +20 -0
  2. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +7 -0
  3. package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs → DevtoolsOverviewContainer-EPD6EWT5.mjs} +2 -2
  4. package/dist/lib/browser/{SpaceGenerator-VB6IB2LL.mjs → SpaceGenerator-SB2YRVRT.mjs} +376 -494
  5. package/dist/lib/browser/SpaceGenerator-SB2YRVRT.mjs.map +7 -0
  6. package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-7ODCSP7R.mjs} +27 -37
  7. package/dist/lib/browser/app-graph-builder-7ODCSP7R.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-47JOZTT2.mjs → chunk-5XPIRNQS.mjs} +2 -2
  9. package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-AJA6RYN3.mjs} +2 -2
  10. package/dist/lib/browser/index.mjs +17 -14
  11. package/dist/lib/browser/index.mjs.map +3 -3
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/{react-context-ZQRD2WG2.mjs → react-context-Y537DXK5.mjs} +5 -5
  14. package/dist/lib/browser/{react-context-ZQRD2WG2.mjs.map → react-context-Y537DXK5.mjs.map} +1 -1
  15. package/dist/lib/browser/{react-surface-UI6OK73H.mjs → react-surface-OP75RFNI.mjs} +45 -40
  16. package/dist/lib/browser/react-surface-OP75RFNI.mjs.map +7 -0
  17. package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-XAUQOU7I.mjs} +6 -6
  18. package/dist/lib/browser/{settings-SXQWSIM4.mjs.map → settings-XAUQOU7I.mjs.map} +1 -1
  19. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  20. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  21. package/dist/types/src/capabilities/index.d.ts +5 -5
  22. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  23. package/dist/types/src/capabilities/react-context.d.ts +2 -2
  24. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  25. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  26. package/dist/types/src/capabilities/settings.d.ts +1 -1
  27. package/dist/types/src/components/DebugGraph.d.ts +8 -0
  28. package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
  29. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  30. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +3 -1
  31. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  32. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
  33. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  34. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -3
  35. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  37. package/dist/types/src/components/SpaceGenerator/presets.d.ts +5 -5
  38. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  39. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  40. package/dist/types/src/components/index.d.ts +2 -1
  41. package/dist/types/src/components/index.d.ts.map +1 -1
  42. package/dist/types/src/translations.d.ts +62 -60
  43. package/dist/types/src/translations.d.ts.map +1 -1
  44. package/dist/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +61 -59
  46. package/src/DebugPlugin.tsx +2 -2
  47. package/src/capabilities/app-graph-builder.ts +13 -40
  48. package/src/capabilities/react-surface.tsx +9 -8
  49. package/src/components/DebugGraph.tsx +14 -0
  50. package/src/components/DebugObjectPanel.tsx +1 -1
  51. package/src/components/DebugSettings.tsx +72 -64
  52. package/src/components/SpaceGenerator/ObjectGenerator.tsx +32 -26
  53. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +8 -6
  54. package/src/components/SpaceGenerator/SpaceGenerator.tsx +15 -72
  55. package/src/components/SpaceGenerator/draw-util.ts +3 -3
  56. package/src/components/SpaceGenerator/presets.ts +346 -221
  57. package/src/components/Wireframe.tsx +2 -1
  58. package/src/components/index.ts +1 -1
  59. package/src/translations.ts +8 -4
  60. package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
  61. package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
  62. package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
  63. package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
  64. package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
  65. package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
  66. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
  67. package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
  68. package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
  69. package/dist/types/src/components/DebugApp/index.d.ts +0 -3
  70. package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
  71. package/src/components/DebugApp/DebugApp.tsx +0 -77
  72. package/src/components/DebugApp/Tree.tsx +0 -103
  73. package/src/components/DebugApp/index.ts +0 -7
  74. /package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs.map → DevtoolsOverviewContainer-EPD6EWT5.mjs.map} +0 -0
  75. /package/dist/lib/browser/{chunk-47JOZTT2.mjs.map → chunk-5XPIRNQS.mjs.map} +0 -0
  76. /package/dist/lib/browser/{chunk-KS3YBEL7.mjs.map → chunk-AJA6RYN3.mjs.map} +0 -0
@@ -4,25 +4,22 @@
4
4
 
5
5
  import React, { useCallback, useMemo, useState } from 'react';
6
6
 
7
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
7
+ import { useIntentDispatcher } from '@dxos/app-framework';
8
8
  import { ComputeGraph } from '@dxos/conductor';
9
- import { Filter, Obj, Type } from '@dxos/echo';
10
- import { log } from '@dxos/log';
11
- import { DocumentType } from '@dxos/plugin-markdown/types';
9
+ import { Filter, type Obj } from '@dxos/echo';
10
+ import { Markdown } from '@dxos/plugin-markdown/types';
12
11
  import { SheetType } from '@dxos/plugin-sheet/types';
13
12
  import { DiagramType } from '@dxos/plugin-sketch/types';
14
- import { SpaceAction } from '@dxos/plugin-space/types';
15
13
  import { useClient } from '@dxos/react-client';
16
- import { getTypename, type Space } from '@dxos/react-client/echo';
14
+ import { type Space, getTypename } from '@dxos/react-client/echo';
17
15
  import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
18
16
  import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
19
- import { initializeTable, TableType } from '@dxos/react-ui-table';
20
17
  import { DataType } from '@dxos/schema';
21
18
  import { jsonKeyReplacer, sortKeys } from '@dxos/util';
22
19
 
23
- import { createGenerator, staticGenerators, type ObjectGenerator } from './ObjectGenerator';
24
- import { SchemaTable } from './SchemaTable';
20
+ import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
25
21
  import { generator } from './presets';
22
+ import { SchemaTable } from './SchemaTable';
26
23
 
27
24
  export type SpaceGeneratorProps = {
28
25
  space: Space;
@@ -32,21 +29,21 @@ export type SpaceGeneratorProps = {
32
29
  export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
33
30
  const { dispatchPromise: dispatch } = useIntentDispatcher();
34
31
  const client = useClient();
35
- const staticTypes = [DocumentType, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
36
- const mutableTypes = [DataType.Organization, DataType.Project, DataType.Person, DataType.Message];
32
+ const staticTypes = [Markdown.Document, DiagramType, SheetType, ComputeGraph]; // TODO(burdon): Make extensible.
33
+ const recordTypes = [DataType.Organization, DataType.Person, DataType.Task];
37
34
  const [count, setCount] = useState(1);
38
35
  const [info, setInfo] = useState<any>({});
39
36
  const presets = useMemo(() => generator(), []);
40
37
 
41
38
  // Create type generators.
42
39
  const typeMap = useMemo(() => {
43
- client.addTypes([...staticTypes, ...presets.schemas]);
44
- const mutableGenerators = new Map<string, ObjectGenerator<any>>(
45
- mutableTypes.map((type) => [type.typename, createGenerator(type as any)]),
40
+ client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
41
+ const recordGenerators = new Map<string, ObjectGenerator<any>>(
42
+ recordTypes.map((type) => [type.typename, createGenerator(client, dispatch, type as any)]),
46
43
  );
47
44
 
48
- return new Map([...staticGenerators, ...presets.items, ...mutableGenerators]);
49
- }, [client, mutableTypes]);
45
+ return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
46
+ }, [client, recordTypes]);
50
47
 
51
48
  // Query space to get info.
52
49
  const updateInfo = async () => {
@@ -90,64 +87,10 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
90
87
  [typeMap, count],
91
88
  );
92
89
 
93
- // TODO(wittjosiah): Remove. Replace with proper echo import.
94
- const handleLoadTables = useCallback(async () => {
95
- const input = document.createElement('input');
96
- input.type = 'file';
97
- input.accept = '.json';
98
-
99
- input.onchange = async (e) => {
100
- const file = (e.target as HTMLInputElement).files?.[0];
101
- if (!file) {
102
- return;
103
- }
104
-
105
- try {
106
- const content = await file.text();
107
- const data = JSON.parse(content);
108
- const schemas = await space.db.schemaRegistry.register(data.schemas.map(Type.toEffectSchema));
109
- // TODO(wittjosiah): If the schema is already registered this should skip.
110
- await Promise.all(
111
- schemas.map(async (schema) => {
112
- const parts = schema.typename.split('/');
113
- const name = parts[parts.length - 1];
114
- const table = Obj.make(TableType, { name, threads: [] });
115
- await initializeTable({ client, space, table, typename: schema.typename });
116
- await dispatch(createIntent(SpaceAction.AddObject, { target: space, object: table }));
117
- return table;
118
- }),
119
- );
120
- // TODO(wittjosiah): This should query the space for schemas.
121
- await Promise.all(
122
- data.objects.map(async ({ id, '@type': typename, ...fields }: any) => {
123
- const schema = schemas.find((s) => `dxn:type:${s.typename}:${s.version}` === typename);
124
- if (!schema) {
125
- log.warn('Missing schema for object', { id, typename });
126
- return;
127
- }
128
- const object = Obj.make(schema, fields);
129
- space.db.add(object);
130
- return object;
131
- }),
132
- );
133
- } catch (err) {
134
- log.catch(err);
135
- }
136
- };
137
-
138
- input.click();
139
- }, []);
140
-
141
90
  return (
142
91
  <div role='none' className='flex flex-col grow overflow-hidden'>
143
92
  <Toolbar.Root classNames='border-be border-subduedSeparator'>
144
93
  <IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
145
- <IconButton
146
- icon='ph--file-arrow-up--regular'
147
- iconOnly
148
- label='Load tables from JSON'
149
- onClick={handleLoadTables}
150
- />
151
94
  <Toolbar.Separator variant='gap' />
152
95
  <Input.Root>
153
96
  <Input.TextInput
@@ -165,11 +108,11 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
165
108
 
166
109
  <div className='flex flex-col overflow-y-auto divide-y divide-separator'>
167
110
  <SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
168
- <SchemaTable types={mutableTypes} objects={info.objects} label='Mutable Types' onClick={handleCreateData} />
111
+ <SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
169
112
  <SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
170
113
 
171
114
  <div>
172
- <SyntaxHighlighter classNames='flex text-xs' language='json'>
115
+ <SyntaxHighlighter language='json' classNames='text-xs'>
173
116
  {JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
174
117
  </SyntaxHighlighter>
175
118
  </div>
@@ -3,17 +3,17 @@
3
3
  //
4
4
 
5
5
  // TODO(burdon): workerize-loader dep.
6
- import { Graph, type Edge, type PlainObject } from '@antv/graphlib';
6
+ import { type Edge, Graph, type PlainObject } from '@antv/graphlib';
7
7
  import {
8
- type Layout,
9
8
  D3ForceLayout,
10
9
  type D3ForceLayoutOptions,
11
10
  GridLayout,
12
11
  type GridLayoutOptions,
12
+ type Layout,
13
13
  RadialLayout,
14
14
  type RadialLayoutOptions,
15
15
  } from '@antv/layout';
16
- import { createBindingId, createShapeId, type Editor, type SerializedStore, type TLRecord } from '@tldraw/tldraw';
16
+ import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
17
17
 
18
18
  import { faker } from '@dxos/random';
19
19
  import { isNotFalsy, range } from '@dxos/util';