@dxos/app-graph 0.8.3 → 0.8.4-main.f9ba587
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/dist/lib/browser/index.mjs +6 -6
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +6 -6
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/stories/EchoGraph.stories.d.ts +3 -8
- package/dist/types/src/stories/EchoGraph.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -24
- package/src/stories/EchoGraph.stories.tsx +5 -122
- package/dist/lib/node/index.cjs +0 -816
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-graph",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.f9ba587",
|
|
4
4
|
"description": "Constructs knowledge graphs for the purpose of building applications on top of",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,44 +26,44 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@preact/signals-core": "^1.9.0",
|
|
28
28
|
"main-thread-scheduling": "^14.1.1",
|
|
29
|
-
"@dxos/async": "0.8.
|
|
30
|
-
"@dxos/debug": "0.8.
|
|
31
|
-
"@dxos/echo": "0.8.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/echo-signals": "0.8.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/live-object": "0.8.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
29
|
+
"@dxos/async": "0.8.4-main.f9ba587",
|
|
30
|
+
"@dxos/debug": "0.8.4-main.f9ba587",
|
|
31
|
+
"@dxos/echo": "0.8.4-main.f9ba587",
|
|
32
|
+
"@dxos/echo-schema": "0.8.4-main.f9ba587",
|
|
33
|
+
"@dxos/echo-signals": "0.8.4-main.f9ba587",
|
|
34
|
+
"@dxos/invariant": "0.8.4-main.f9ba587",
|
|
35
|
+
"@dxos/live-object": "0.8.4-main.f9ba587",
|
|
36
|
+
"@dxos/log": "0.8.4-main.f9ba587",
|
|
37
|
+
"@dxos/util": "0.8.4-main.f9ba587"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@effect-rx/rx-react": "
|
|
41
|
-
"@effect/platform": "0.
|
|
40
|
+
"@effect-rx/rx-react": "0.38.0",
|
|
41
|
+
"@effect/platform": "0.88.0",
|
|
42
42
|
"@phosphor-icons/react": "^2.1.5",
|
|
43
43
|
"@types/react": "~18.2.0",
|
|
44
44
|
"@types/react-dom": "~18.2.0",
|
|
45
|
-
"effect": "3.
|
|
45
|
+
"effect": "3.16.13",
|
|
46
46
|
"react": "~18.2.0",
|
|
47
47
|
"react-dom": "~18.2.0",
|
|
48
48
|
"vite": "5.4.7",
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-
|
|
52
|
-
"@dxos/react-ui
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/react-ui-tabs": "0.8.
|
|
55
|
-
"@dxos/react-ui-theme": "0.8.
|
|
56
|
-
"@dxos/storybook-utils": "0.8.
|
|
49
|
+
"@dxos/echo-db": "0.8.4-main.f9ba587",
|
|
50
|
+
"@dxos/random": "0.8.4-main.f9ba587",
|
|
51
|
+
"@dxos/react-client": "0.8.4-main.f9ba587",
|
|
52
|
+
"@dxos/react-ui": "0.8.4-main.f9ba587",
|
|
53
|
+
"@dxos/react-ui-list": "0.8.4-main.f9ba587",
|
|
54
|
+
"@dxos/react-ui-tabs": "0.8.4-main.f9ba587",
|
|
55
|
+
"@dxos/react-ui-theme": "0.8.4-main.f9ba587",
|
|
56
|
+
"@dxos/storybook-utils": "0.8.4-main.f9ba587"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@effect-rx/rx-react": "^0.34.1",
|
|
60
|
-
"@effect/platform": "0.80.12",
|
|
60
|
+
"@effect/platform": "^0.80.12",
|
|
61
61
|
"@phosphor-icons/react": "^2.1.5",
|
|
62
62
|
"effect": "3.14.21",
|
|
63
63
|
"react": "~18.2.0",
|
|
64
64
|
"react-dom": "~18.2.0",
|
|
65
|
-
"@dxos/react-ui": "0.8.
|
|
66
|
-
"@dxos/react-ui-theme": "0.8.
|
|
65
|
+
"@dxos/react-ui": "0.8.4-main.f9ba587",
|
|
66
|
+
"@dxos/react-ui-theme": "0.8.4-main.f9ba587"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
@@ -6,6 +6,7 @@ import '@dxos-theme';
|
|
|
6
6
|
|
|
7
7
|
import { type Registry, RegistryContext, Rx, useRxValue } from '@effect-rx/rx-react';
|
|
8
8
|
import { Pause, Play, Plus, Timer } from '@phosphor-icons/react';
|
|
9
|
+
import { type Meta } from '@storybook/react-vite';
|
|
9
10
|
import { Option, pipe } from 'effect';
|
|
10
11
|
import React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
11
12
|
|
|
@@ -26,7 +27,6 @@ import { type Client, useClient } from '@dxos/react-client';
|
|
|
26
27
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
27
28
|
import { Button, Input, Select } from '@dxos/react-ui';
|
|
28
29
|
import { Path, Tree } from '@dxos/react-ui-list';
|
|
29
|
-
import { Tabs } from '@dxos/react-ui-tabs';
|
|
30
30
|
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
31
31
|
import { withTheme } from '@dxos/storybook-utils';
|
|
32
32
|
import { byPosition, isNonNullable, safeParseInt } from '@dxos/util';
|
|
@@ -245,10 +245,9 @@ const Controls = ({ children }: PropsWithChildren) => {
|
|
|
245
245
|
);
|
|
246
246
|
};
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
const meta: Meta = {
|
|
249
249
|
title: 'sdk/app-graph/EchoGraph',
|
|
250
250
|
decorators: [
|
|
251
|
-
withTheme,
|
|
252
251
|
withClientProvider({
|
|
253
252
|
createIdentity: true,
|
|
254
253
|
onIdentityCreated: async ({ client }) => {
|
|
@@ -256,9 +255,12 @@ export default {
|
|
|
256
255
|
await client.spaces.create();
|
|
257
256
|
},
|
|
258
257
|
}),
|
|
258
|
+
withTheme,
|
|
259
259
|
],
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
+
export default meta;
|
|
263
|
+
|
|
262
264
|
export const JsonView = {
|
|
263
265
|
render: () => {
|
|
264
266
|
const client = useClient();
|
|
@@ -372,122 +374,3 @@ export const TreeView = {
|
|
|
372
374
|
);
|
|
373
375
|
},
|
|
374
376
|
};
|
|
375
|
-
|
|
376
|
-
// TODO(wittjosiah): Remove.
|
|
377
|
-
export const TabTreeView = {
|
|
378
|
-
render: () => {
|
|
379
|
-
const client = useClient();
|
|
380
|
-
const registry = useContext(RegistryContext);
|
|
381
|
-
const graph = useMemo(() => createGraph(client, registry), [client, registry]);
|
|
382
|
-
const state = useMemo(() => new Map<string, Live<{ open: boolean; current: boolean }>>(), []);
|
|
383
|
-
|
|
384
|
-
const useItems = useCallback(
|
|
385
|
-
(node?: Node, options?: { disposition?: string; sort?: boolean }) => {
|
|
386
|
-
const connections = useRxValue(graph.connections(node?.id ?? ROOT_ID));
|
|
387
|
-
return options?.sort ? connections.toSorted((a, b) => byPosition(a.properties, b.properties)) : connections;
|
|
388
|
-
},
|
|
389
|
-
[graph],
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
const getProps = useCallback(
|
|
393
|
-
(node: Node, path: string[]) => {
|
|
394
|
-
const children = graph
|
|
395
|
-
.getConnections(node.id, 'outbound')
|
|
396
|
-
.map((n) => {
|
|
397
|
-
// Break cycles.
|
|
398
|
-
const nextPath = [...path, node.id];
|
|
399
|
-
return nextPath.includes(n.id) ? undefined : (n as Node);
|
|
400
|
-
})
|
|
401
|
-
.filter(isNonNullable) as Node[];
|
|
402
|
-
const parentOf =
|
|
403
|
-
children.length > 0 ? children.map(({ id }) => id) : node.properties.role === 'branch' ? [] : undefined;
|
|
404
|
-
return {
|
|
405
|
-
id: node.id,
|
|
406
|
-
label: node.id,
|
|
407
|
-
icon: node.type === 'dxos.org/type/Space' ? 'ph--planet--regular' : 'ph--placeholder--regular',
|
|
408
|
-
parentOf,
|
|
409
|
-
};
|
|
410
|
-
},
|
|
411
|
-
[graph],
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
const isOpen = useCallback(
|
|
415
|
-
(_path: string[]) => {
|
|
416
|
-
const path = Path.create(..._path);
|
|
417
|
-
const object = state.get(path) ?? live({ open: true, current: false });
|
|
418
|
-
if (!state.has(path)) {
|
|
419
|
-
state.set(path, object);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return object.open;
|
|
423
|
-
},
|
|
424
|
-
[state],
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
const isCurrent = useCallback(
|
|
428
|
-
(_path: string[]) => {
|
|
429
|
-
const path = Path.create(..._path);
|
|
430
|
-
const object = state.get(path) ?? live({ open: false, current: false });
|
|
431
|
-
if (!state.has(path)) {
|
|
432
|
-
state.set(path, object);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
return object.current;
|
|
436
|
-
},
|
|
437
|
-
[state],
|
|
438
|
-
);
|
|
439
|
-
|
|
440
|
-
const onOpenChange = useCallback(
|
|
441
|
-
({ path: _path, open }: { path: string[]; open: boolean }) => {
|
|
442
|
-
const path = Path.create(..._path);
|
|
443
|
-
const object = state.get(path);
|
|
444
|
-
object!.open = open;
|
|
445
|
-
},
|
|
446
|
-
[state],
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
const onSelect = useCallback(
|
|
450
|
-
({ path: _path, current }: { path: string[]; current: boolean }) => {
|
|
451
|
-
const path = Path.create(..._path);
|
|
452
|
-
const object = state.get(path);
|
|
453
|
-
object!.current = current;
|
|
454
|
-
},
|
|
455
|
-
[state],
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
const spaces = useItems(graph.root);
|
|
459
|
-
|
|
460
|
-
return (
|
|
461
|
-
<>
|
|
462
|
-
<Controls />
|
|
463
|
-
<Tabs.Root defaultValue={spaces[0].id}>
|
|
464
|
-
<Tabs.Tablist>
|
|
465
|
-
{spaces.map((space) => {
|
|
466
|
-
return (
|
|
467
|
-
<Tabs.Tab key={space.id} value={space.id}>
|
|
468
|
-
{space.id}
|
|
469
|
-
</Tabs.Tab>
|
|
470
|
-
);
|
|
471
|
-
})}
|
|
472
|
-
</Tabs.Tablist>
|
|
473
|
-
{spaces.map((space) => {
|
|
474
|
-
return (
|
|
475
|
-
<Tabs.Tabpanel key={space.id} value={space.id}>
|
|
476
|
-
<Tree
|
|
477
|
-
id={space.id}
|
|
478
|
-
root={space}
|
|
479
|
-
useItems={useItems}
|
|
480
|
-
getProps={getProps}
|
|
481
|
-
isOpen={isOpen}
|
|
482
|
-
isCurrent={isCurrent}
|
|
483
|
-
onOpenChange={onOpenChange}
|
|
484
|
-
onSelect={onSelect}
|
|
485
|
-
/>
|
|
486
|
-
</Tabs.Tabpanel>
|
|
487
|
-
);
|
|
488
|
-
})}
|
|
489
|
-
</Tabs.Root>
|
|
490
|
-
</>
|
|
491
|
-
);
|
|
492
|
-
},
|
|
493
|
-
};
|