@dxos/plugin-debug 0.8.3 → 0.8.4-main.28f8d3d

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 (51) hide show
  1. package/dist/lib/browser/{DebugApp-WSEJPCKY.mjs → DebugApp-F4UFVW4Y.mjs} +64 -61
  2. package/dist/lib/browser/DebugApp-F4UFVW4Y.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-XJJAOTIT.mjs} +223 -481
  5. package/dist/lib/browser/SpaceGenerator-XJJAOTIT.mjs.map +7 -0
  6. package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-PXPZIIGY.mjs} +7 -7
  7. package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs.map → app-graph-builder-PXPZIIGY.mjs.map} +3 -3
  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 +13 -13
  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-NVAGLAJD.mjs} +3 -3
  14. package/dist/lib/browser/{react-surface-UI6OK73H.mjs → react-surface-UNFNQFWK.mjs} +21 -21
  15. package/dist/lib/browser/react-surface-UNFNQFWK.mjs.map +7 -0
  16. package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-LSSWLM5I.mjs} +4 -4
  17. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  19. package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +1 -1
  20. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +3 -1
  21. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  22. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
  23. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  24. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +1 -1
  25. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
  27. package/dist/types/src/components/SpaceGenerator/presets.d.ts +1 -4
  28. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  29. package/dist/types/src/translations.d.ts +60 -60
  30. package/dist/types/src/translations.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +57 -58
  33. package/src/DebugPlugin.tsx +2 -2
  34. package/src/capabilities/app-graph-builder.ts +3 -3
  35. package/src/capabilities/react-surface.tsx +5 -5
  36. package/src/components/DebugApp/DebugApp.tsx +21 -13
  37. package/src/components/DebugSettings.tsx +2 -2
  38. package/src/components/SpaceGenerator/ObjectGenerator.tsx +31 -25
  39. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +2 -2
  40. package/src/components/SpaceGenerator/SpaceGenerator.tsx +14 -71
  41. package/src/components/SpaceGenerator/draw-util.ts +3 -3
  42. package/src/components/SpaceGenerator/presets.ts +217 -215
  43. package/src/translations.ts +6 -4
  44. package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
  45. package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
  46. package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
  47. /package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs.map → DevtoolsOverviewContainer-EPD6EWT5.mjs.map} +0 -0
  48. /package/dist/lib/browser/{chunk-47JOZTT2.mjs.map → chunk-5XPIRNQS.mjs.map} +0 -0
  49. /package/dist/lib/browser/{chunk-KS3YBEL7.mjs.map → chunk-AJA6RYN3.mjs.map} +0 -0
  50. /package/dist/lib/browser/{react-context-ZQRD2WG2.mjs.map → react-context-NVAGLAJD.mjs.map} +0 -0
  51. /package/dist/lib/browser/{settings-SXQWSIM4.mjs.map → settings-LSSWLM5I.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-debug",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.28f8d3d",
4
4
  "description": "DXOS Surface plugin for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,6 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
15
  "browser": "./dist/lib/browser/index.mjs"
15
16
  }
@@ -25,7 +26,7 @@
25
26
  "dependencies": {
26
27
  "@antv/graphlib": "^2.0.4",
27
28
  "@antv/layout": "^1.2.13",
28
- "@automerge/automerge": "3.0.0-beta.4",
29
+ "@automerge/automerge": "3.1.1",
29
30
  "@preact-signals/safe-react": "^0.9.0",
30
31
  "@preact/signals-core": "^1.9.0",
31
32
  "@tldraw/tldraw": "^3.0.0",
@@ -33,75 +34,73 @@
33
34
  "react-json-tree": "^0.18.0",
34
35
  "react-resize-detector": "^11.0.1",
35
36
  "workerize-loader": "^2.0.2",
36
- "@dxos/app-framework": "0.8.3",
37
- "@dxos/async": "0.8.3",
38
- "@dxos/compute": "0.8.3",
39
- "@dxos/client-services": "0.8.3",
40
- "@dxos/config": "0.8.3",
41
- "@dxos/conductor": "0.8.3",
42
- "@dxos/context": "0.8.3",
43
- "@dxos/devtools": "0.8.3",
44
- "@dxos/echo": "0.8.3",
45
- "@dxos/echo-generator": "0.8.3",
46
- "@dxos/echo-pipeline": "0.8.3",
47
- "@dxos/echo-schema": "0.8.3",
48
- "@dxos/functions": "0.8.3",
49
- "@dxos/invariant": "0.8.3",
50
- "@dxos/local-storage": "0.8.3",
51
- "@dxos/live-object": "0.8.3",
52
- "@dxos/keys": "0.8.3",
53
- "@dxos/log": "0.8.3",
54
- "@dxos/plugin-client": "0.8.3",
55
- "@dxos/plugin-deck": "0.8.3",
56
- "@dxos/plugin-graph": "0.8.3",
57
- "@dxos/plugin-markdown": "0.8.3",
58
- "@dxos/plugin-meeting": "0.8.3",
59
- "@dxos/plugin-sheet": "0.8.3",
60
- "@dxos/plugin-space": "0.8.3",
61
- "@dxos/plugin-script": "0.8.3",
62
- "@dxos/plugin-table": "0.8.3",
63
- "@dxos/plugin-status-bar": "0.8.3",
64
- "@dxos/protocols": "0.8.3",
65
- "@dxos/plugin-theme": "0.8.3",
66
- "@dxos/react-client": "0.8.3",
67
- "@dxos/react-ui-attention": "0.8.3",
68
- "@dxos/react-ui-canvas-compute": "0.8.3",
69
- "@dxos/react-ui-canvas-editor": "0.8.3",
70
- "@dxos/random": "0.8.3",
71
- "@dxos/react-ui-form": "0.8.3",
72
- "@dxos/react-ui-kanban": "0.8.3",
73
- "@dxos/react-hooks": "0.8.3",
74
- "@dxos/react-ui-stack": "0.8.3",
75
- "@dxos/react-ui-table": "0.8.3",
76
- "@dxos/react-ui-syntax-highlighter": "0.8.3",
77
- "@dxos/schema": "0.8.3",
78
- "@dxos/util": "0.8.3",
79
- "@dxos/plugin-sketch": "0.8.3"
37
+ "@dxos/app-framework": "0.8.4-main.28f8d3d",
38
+ "@dxos/async": "0.8.4-main.28f8d3d",
39
+ "@dxos/compute": "0.8.4-main.28f8d3d",
40
+ "@dxos/client-services": "0.8.4-main.28f8d3d",
41
+ "@dxos/conductor": "0.8.4-main.28f8d3d",
42
+ "@dxos/config": "0.8.4-main.28f8d3d",
43
+ "@dxos/devtools": "0.8.4-main.28f8d3d",
44
+ "@dxos/context": "0.8.4-main.28f8d3d",
45
+ "@dxos/echo": "0.8.4-main.28f8d3d",
46
+ "@dxos/echo-generator": "0.8.4-main.28f8d3d",
47
+ "@dxos/echo-pipeline": "0.8.4-main.28f8d3d",
48
+ "@dxos/echo-schema": "0.8.4-main.28f8d3d",
49
+ "@dxos/functions": "0.8.4-main.28f8d3d",
50
+ "@dxos/keys": "0.8.4-main.28f8d3d",
51
+ "@dxos/invariant": "0.8.4-main.28f8d3d",
52
+ "@dxos/live-object": "0.8.4-main.28f8d3d",
53
+ "@dxos/local-storage": "0.8.4-main.28f8d3d",
54
+ "@dxos/log": "0.8.4-main.28f8d3d",
55
+ "@dxos/plugin-client": "0.8.4-main.28f8d3d",
56
+ "@dxos/plugin-deck": "0.8.4-main.28f8d3d",
57
+ "@dxos/plugin-graph": "0.8.4-main.28f8d3d",
58
+ "@dxos/plugin-meeting": "0.8.4-main.28f8d3d",
59
+ "@dxos/plugin-script": "0.8.4-main.28f8d3d",
60
+ "@dxos/plugin-sheet": "0.8.4-main.28f8d3d",
61
+ "@dxos/plugin-markdown": "0.8.4-main.28f8d3d",
62
+ "@dxos/plugin-space": "0.8.4-main.28f8d3d",
63
+ "@dxos/plugin-status-bar": "0.8.4-main.28f8d3d",
64
+ "@dxos/plugin-sketch": "0.8.4-main.28f8d3d",
65
+ "@dxos/plugin-table": "0.8.4-main.28f8d3d",
66
+ "@dxos/plugin-theme": "0.8.4-main.28f8d3d",
67
+ "@dxos/protocols": "0.8.4-main.28f8d3d",
68
+ "@dxos/random": "0.8.4-main.28f8d3d",
69
+ "@dxos/react-client": "0.8.4-main.28f8d3d",
70
+ "@dxos/react-hooks": "0.8.4-main.28f8d3d",
71
+ "@dxos/react-ui-attention": "0.8.4-main.28f8d3d",
72
+ "@dxos/react-ui-form": "0.8.4-main.28f8d3d",
73
+ "@dxos/react-ui-canvas-editor": "0.8.4-main.28f8d3d",
74
+ "@dxos/react-ui-canvas-compute": "0.8.4-main.28f8d3d",
75
+ "@dxos/react-ui-kanban": "0.8.4-main.28f8d3d",
76
+ "@dxos/react-ui-stack": "0.8.4-main.28f8d3d",
77
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.28f8d3d",
78
+ "@dxos/react-ui-table": "0.8.4-main.28f8d3d",
79
+ "@dxos/schema": "0.8.4-main.28f8d3d",
80
+ "@dxos/util": "0.8.4-main.28f8d3d"
80
81
  },
81
82
  "devDependencies": {
82
- "@effect-rx/rx-react": "^0.34.1",
83
- "@effect/platform": "0.80.12",
84
- "@phosphor-icons/react": "^2.1.5",
83
+ "@effect-rx/rx-react": "0.38.0",
84
+ "@effect/platform": "0.90.2",
85
85
  "@types/react": "~18.2.0",
86
86
  "@types/react-dom": "~18.2.0",
87
- "effect": "3.14.21",
87
+ "effect": "3.17.7",
88
88
  "react": "~18.2.0",
89
89
  "react-dom": "~18.2.0",
90
90
  "vite": "5.4.7",
91
- "@dxos/react-ui": "0.8.3",
92
- "@dxos/react-ui-theme": "0.8.3",
93
- "@dxos/storybook-utils": "0.8.3"
91
+ "@dxos/react-ui-theme": "0.8.4-main.28f8d3d",
92
+ "@dxos/storybook-utils": "0.8.4-main.28f8d3d",
93
+ "@dxos/react-ui": "0.8.4-main.28f8d3d"
94
94
  },
95
95
  "peerDependencies": {
96
96
  "@effect-rx/rx-react": "^0.34.1",
97
- "@effect/platform": "0.80.12",
98
- "@phosphor-icons/react": "^2.1.5",
97
+ "@effect/platform": "^0.80.12",
99
98
  "effect": "^3.13.3",
100
99
  "react": "~18.2.0",
101
100
  "react-dom": "~18.2.0",
102
- "@dxos/react-ui-theme": "0.8.3",
103
- "@dxos/react-ui": "0.8.3",
104
- "@dxos/random": "0.8.3"
101
+ "@dxos/random": "0.8.4-main.28f8d3d",
102
+ "@dxos/react-ui-theme": "0.8.4-main.28f8d3d",
103
+ "@dxos/react-ui": "0.8.4-main.28f8d3d"
105
104
  },
106
105
  "publishConfig": {
107
106
  "access": "public"
@@ -2,12 +2,12 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes, defineModule, definePlugin, Events } from '@dxos/app-framework';
5
+ import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
6
  import { type Client } from '@dxos/react-client';
7
7
 
8
8
  import { AppGraphBuilder, DebugSettings, ReactContext, ReactSurface } from './capabilities';
9
9
  import { meta } from './meta';
10
- import translations from './translations';
10
+ import { translations } from './translations';
11
11
 
12
12
  // TODO(wittjosiah): Rename to DevtoolsPlugin?
13
13
  export const DebugPlugin = () => {
@@ -5,11 +5,11 @@
5
5
  import { Rx } from '@effect-rx/rx-react';
6
6
  import { Option, pipe } from 'effect';
7
7
 
8
- import { contributes, Capabilities, type PluginContext } from '@dxos/app-framework';
8
+ import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
9
9
  import { Obj } from '@dxos/echo';
10
10
  import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
11
- import { createExtension, ROOT_ID, rxFromSignal } from '@dxos/plugin-graph';
12
- import { getActiveSpace, SPACE_PLUGIN } from '@dxos/plugin-space';
11
+ import { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';
12
+ import { SPACE_PLUGIN, getActiveSpace } from '@dxos/plugin-space';
13
13
 
14
14
  import { DEBUG_PLUGIN } from '../meta';
15
15
  import { Devtools } from '../types';
@@ -7,14 +7,14 @@ import React, { useCallback } from 'react';
7
7
 
8
8
  import {
9
9
  Capabilities,
10
+ LayoutAction,
11
+ type PluginContext,
10
12
  chain,
11
13
  contributes,
12
14
  createIntent,
13
15
  createSurface,
14
- LayoutAction,
15
16
  useCapability,
16
17
  useIntentDispatcher,
17
- type PluginContext,
18
18
  } from '@dxos/app-framework';
19
19
  import {
20
20
  AutomergePanel,
@@ -43,14 +43,14 @@ import {
43
43
  TracingPanel,
44
44
  WorkflowPanel,
45
45
  } from '@dxos/devtools';
46
- import { Obj, Type } from '@dxos/echo';
46
+ import { Obj } from '@dxos/echo';
47
47
  import { SettingsStore } from '@dxos/local-storage';
48
48
  import { log } from '@dxos/log';
49
49
  import { ClientCapabilities } from '@dxos/plugin-client';
50
50
  import { Graph } from '@dxos/plugin-graph';
51
51
  import { ScriptAction } from '@dxos/plugin-script/types';
52
52
  import { SpaceAction } from '@dxos/plugin-space/types';
53
- import { SpaceState, isSpace, type Space, parseId } from '@dxos/react-client/echo';
53
+ import { type Space, SpaceState, isSpace, parseId } from '@dxos/react-client/echo';
54
54
  import { StackItem } from '@dxos/react-ui-stack';
55
55
  import { DataType } from '@dxos/schema';
56
56
 
@@ -111,7 +111,7 @@ export default (context: PluginContext) =>
111
111
 
112
112
  const collection =
113
113
  data.subject.space.state.get() === SpaceState.SPACE_READY &&
114
- data.subject.space.properties[Type.getTypename(DataType.Collection)]?.target;
114
+ data.subject.space.properties[DataType.Collection.typename]?.target;
115
115
  if (!Obj.instanceOf(DataType.Collection, collection)) {
116
116
  return;
117
117
  }
@@ -2,17 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Gauge, Graph as GraphIcon, Gear, Toolbox, Warning } from '@phosphor-icons/react';
6
5
  import React, { type FC, useEffect, useState } from 'react';
7
6
 
8
7
  import { type Graph } from '@dxos/plugin-graph';
9
8
  import { useClient, useConfig } from '@dxos/react-client';
10
- import { Button, ToggleGroup, ToggleGroupItem, Toolbar } from '@dxos/react-ui';
11
- import { getSize, mx } from '@dxos/react-ui-theme';
9
+ import { Icon, IconButton, ToggleGroup, ToggleGroupItem, Toolbar } from '@dxos/react-ui';
12
10
 
13
- import { Json, Tree } from './Tree';
14
11
  import { Container } from '../Container';
15
12
 
13
+ import { Json, Tree } from './Tree';
14
+
16
15
  export const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {
17
16
  const [view, setView] = useState<'config' | 'diagnostics' | 'graph'>('graph');
18
17
  const [data, setData] = useState<any>({});
@@ -49,23 +48,32 @@ export const DebugApp: FC<{ graph: Graph }> = ({ graph }) => {
49
48
  <Toolbar.Root classNames='p-1'>
50
49
  <ToggleGroup type='single' value={view}>
51
50
  <ToggleGroupItem value={'graph'} onClick={() => setView('graph')} title={'Plugin graph'}>
52
- <GraphIcon className={getSize(5)} />
51
+ <Icon icon='ph--graph--regular' size={5} />
53
52
  </ToggleGroupItem>
54
53
  <ToggleGroupItem value={'diagnostics'} onClick={() => setView('diagnostics')} title={'Diagnostics'}>
55
- <Gauge className={getSize(5)} />
54
+ <Icon icon='ph--gauge--regular' size={5} />
56
55
  </ToggleGroupItem>
57
56
  <ToggleGroupItem value={'config'} onClick={() => setView('config')} title={'Config'}>
58
- <Gear className={getSize(5)} />
57
+ <Icon icon='ph--gear--regular' size={5} />
59
58
  </ToggleGroupItem>
60
59
  </ToggleGroup>
61
60
 
62
61
  <Toolbar.Separator variant='gap' />
63
- <Button onClick={(event) => handleResetClient(event.shiftKey)} title='Reset client'>
64
- <Warning className={mx(getSize(5), 'text-red-700')} />
65
- </Button>
66
- <Button onClick={handleOpenDevtools} title='Open Devtools'>
67
- <Toolbox weight='duotone' className={mx(getSize(5), 'text-700')} />
68
- </Button>
62
+ <IconButton
63
+ icon='ph--warning--regular'
64
+ iconOnly
65
+ size={5}
66
+ classNames='text-red-700'
67
+ onClick={(event) => handleResetClient(event.shiftKey)}
68
+ label='Reset client'
69
+ />
70
+ <IconButton
71
+ icon='ph--toolbox--duotone'
72
+ iconOnly
73
+ size={5}
74
+ onClick={handleOpenDevtools}
75
+ label='Open Devtools'
76
+ />
69
77
  </Toolbar.Root>
70
78
  }
71
79
  >
@@ -5,10 +5,10 @@
5
5
  import React, { useEffect, useState } from 'react';
6
6
 
7
7
  import { Capabilities, useCapabilities } from '@dxos/app-framework';
8
- import { type ConfigProto, defs, SaveConfig, Storage } from '@dxos/config';
8
+ import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
9
9
  import { log } from '@dxos/log';
10
10
  import { useClient } from '@dxos/react-client';
11
- import { useTranslation, Button, Toast, Input, useFileDownload, Select, Icon } from '@dxos/react-ui';
11
+ import { Button, Icon, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
12
12
  import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
13
13
  import { setDeep } from '@dxos/util';
14
14
 
@@ -2,58 +2,64 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { type PromiseIntentDispatcher, createIntent } from '@dxos/app-framework';
5
6
  import { addressToA1Notation } from '@dxos/compute';
6
7
  import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
7
- import { DXN, Filter, Key, Obj, Ref } from '@dxos/echo';
8
+ import { DXN, Filter, Key, Obj, Ref, Type } from '@dxos/echo';
8
9
  import { type TypedObject } from '@dxos/echo-schema';
9
- import { DocumentType } from '@dxos/plugin-markdown/types';
10
+ import { Markdown } from '@dxos/plugin-markdown/types';
10
11
  import { createSheet } from '@dxos/plugin-sheet/types';
11
- import { SheetType, type CellValue } from '@dxos/plugin-sheet/types';
12
+ import { type CellValue, SheetType } from '@dxos/plugin-sheet/types';
12
13
  import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
14
+ import { SpaceAction } from '@dxos/plugin-space/types';
13
15
  import { faker } from '@dxos/random';
16
+ import { type Client } from '@dxos/react-client';
14
17
  import { type Space } from '@dxos/react-client/echo';
15
- import { TableType } from '@dxos/react-ui-table';
16
- import { createView, DataType } from '@dxos/schema';
17
- import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
18
+ import { DataType } from '@dxos/schema';
19
+ import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
18
20
  import { range } from '@dxos/util';
19
21
 
20
22
  const generator: ValueGenerator = faker as any;
21
23
 
22
24
  export type ObjectGenerator<T extends Obj.Any> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
23
25
 
24
- export const createGenerator = <T extends Obj.Any>(type: TypedObject<T>): ObjectGenerator<T> => {
25
- return async (space: Space, n: number, cb?: (objects: T[]) => void): Promise<T[]> => {
26
- // Find or create mutable schema.
27
- const schema =
28
- (await space.db.schemaRegistry.query({ typename: type.typename }).firstOrUndefined()) ??
29
- (await space.db.schemaRegistry.register([type]))[0];
26
+ const findViewByTypename = async (views: DataType.View[], typename: string) => {
27
+ return views.find((view) => view.query.typename === typename);
28
+ };
30
29
 
31
- // Create objects.
32
- const generate = createAsyncGenerator(generator, schema.snapshot, { db: space.db });
33
- const objects = await generate.createObjects(n);
30
+ export const createGenerator = <T extends Obj.Any>(
31
+ client: Client,
32
+ dispatch: PromiseIntentDispatcher,
33
+ schema: TypedObject<T>,
34
+ ): ObjectGenerator<T> => {
35
+ return async (space: Space, n: number, cb?: (objects: T[]) => void): Promise<T[]> => {
36
+ const typename = schema.typename;
34
37
 
35
38
  // Find or create table and view.
36
- const { objects: tables } = await space.db.query(Filter.type(TableType)).run();
37
- const table = tables.find((table) => table.view?.target?.query?.typename === type.typename);
38
- if (!table) {
39
- const name = type.typename.split('/').pop() ?? type.typename;
40
- const view = createView({ name, typename: type.typename, jsonSchema: schema.jsonSchema });
41
- space.db.add(Obj.make(TableType, { name, view: Ref.make(view) }));
39
+ const { objects: views } = await space.db.query(Filter.type(DataType.View)).run();
40
+ const view = await findViewByTypename(views, typename);
41
+ const staticSchema = client?.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
42
+ if (!view && !staticSchema) {
43
+ await dispatch(createIntent(SpaceAction.AddSchema, { space, schema }));
44
+ } else if (!view && staticSchema) {
45
+ await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename }));
42
46
  }
43
47
 
44
- return objects;
48
+ // Create objects.
49
+ const generate = createAsyncGenerator(generator, schema, { db: space.db });
50
+ return generate.createObjects(n);
45
51
  };
46
52
  };
47
53
 
48
54
  export const staticGenerators = new Map<string, ObjectGenerator<any>>([
49
55
  [
50
- DocumentType.typename,
56
+ Markdown.Document.typename,
51
57
  async (space, n, cb) => {
52
58
  const objects = range(n).map(() => {
53
59
  return space.db.add(
54
- Obj.make(DocumentType, {
60
+ Markdown.makeDocument({
55
61
  name: faker.commerce.productName(),
56
- content: Ref.make(Obj.make(DataType.Text, { content: faker.lorem.sentences(5) })),
62
+ content: faker.lorem.sentences(5),
57
63
  }),
58
64
  );
59
65
  });
@@ -4,7 +4,7 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
- import { type Meta } from '@storybook/react';
7
+ import { type Meta } from '@storybook/react-vite';
8
8
  import React from 'react';
9
9
 
10
10
  import { IntentPlugin } from '@dxos/app-framework';
@@ -32,7 +32,7 @@ const meta: Meta = {
32
32
  withPluginManager({
33
33
  plugins: [
34
34
  ClientPlugin({
35
- onClientInitialized: async (_, client) => {
35
+ onClientInitialized: async ({ client }) => {
36
36
  await client.halo.createIdentity();
37
37
  },
38
38
  }),
@@ -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,7 +108,7 @@ 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>
@@ -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';