@dxos/app-graph 0.8.4-main.84f28bd → 0.8.4-main.ae835ea
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 +207 -149
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +207 -149
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/graph-builder.d.ts +15 -4
- package/dist/types/src/graph-builder.d.ts.map +1 -1
- package/dist/types/src/graph.d.ts +7 -3
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/node.d.ts +1 -1
- package/dist/types/src/node.d.ts.map +1 -1
- package/dist/types/src/stories/EchoGraph.stories.d.ts +8 -10
- package/dist/types/src/stories/EchoGraph.stories.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +1 -1
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -33
- package/src/graph-builder.test.ts +67 -9
- package/src/graph-builder.ts +69 -22
- package/src/graph.test.ts +2 -2
- package/src/graph.ts +20 -19
- package/src/node.ts +5 -3
- package/src/signals-integration.test.ts +7 -7
- package/src/stories/EchoGraph.stories.tsx +29 -26
- package/src/testing.ts +1 -1
|
@@ -2,41 +2,40 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Registry, RegistryContext, Rx, useRxValue } from '@effect-rx/rx-react';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
6
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Option from 'effect/Option';
|
|
11
9
|
import React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
12
10
|
|
|
13
11
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
Expando,
|
|
13
|
+
Filter,
|
|
14
|
+
type Live,
|
|
16
15
|
Query,
|
|
17
16
|
type QueryResult,
|
|
18
17
|
type Space,
|
|
19
18
|
SpaceState,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Filter,
|
|
19
|
+
isSpace,
|
|
20
|
+
live,
|
|
23
21
|
} from '@dxos/client/echo';
|
|
24
22
|
import { Obj, Type } from '@dxos/echo';
|
|
25
23
|
import { faker } from '@dxos/random';
|
|
26
24
|
import { type Client, useClient } from '@dxos/react-client';
|
|
27
25
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
28
|
-
import {
|
|
26
|
+
import { Icon, IconButton, Input, Select } from '@dxos/react-ui';
|
|
27
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
29
28
|
import { Path, Tree } from '@dxos/react-ui-list';
|
|
30
29
|
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
31
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
32
30
|
import { byPosition, isNonNullable, safeParseInt } from '@dxos/util';
|
|
33
31
|
|
|
34
|
-
import { JsonTree } from './Tree';
|
|
35
32
|
import { type ExpandableGraph, ROOT_ID } from '../graph';
|
|
36
33
|
import { GraphBuilder, createExtension, rxFromObservable, rxFromSignal } from '../graph-builder';
|
|
37
34
|
import { type Node } from '../node';
|
|
38
35
|
import { rxFromQuery } from '../testing';
|
|
39
36
|
|
|
37
|
+
import { JsonTree } from './Tree';
|
|
38
|
+
|
|
40
39
|
const DEFAULT_PERIOD = 500;
|
|
41
40
|
|
|
42
41
|
enum Action {
|
|
@@ -62,7 +61,7 @@ const createGraph = (client: Client, registry: Registry.Registry): ExpandableGra
|
|
|
62
61
|
id: 'space',
|
|
63
62
|
connector: (node) =>
|
|
64
63
|
Rx.make((get) =>
|
|
65
|
-
pipe(
|
|
64
|
+
Function.pipe(
|
|
66
65
|
get(node),
|
|
67
66
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
68
67
|
Option.map(() => {
|
|
@@ -86,7 +85,7 @@ const createGraph = (client: Client, registry: Registry.Registry): ExpandableGra
|
|
|
86
85
|
connector: (node) => {
|
|
87
86
|
let query: QueryResult<Live<Expando>> | undefined;
|
|
88
87
|
return Rx.make((get) =>
|
|
89
|
-
pipe(
|
|
88
|
+
Function.pipe(
|
|
90
89
|
get(node),
|
|
91
90
|
Option.flatMap((node) => (isSpace(node.data) ? Option.some(node.data) : Option.none())),
|
|
92
91
|
Option.map((space) => {
|
|
@@ -205,7 +204,11 @@ const Controls = ({ children }: PropsWithChildren) => {
|
|
|
205
204
|
return (
|
|
206
205
|
<>
|
|
207
206
|
<div className='flex shrink-0 p-2 space-x-2'>
|
|
208
|
-
<
|
|
207
|
+
<IconButton
|
|
208
|
+
icon={generating ? 'ph--pause--regular' : 'ph--play--regular'}
|
|
209
|
+
label={generating ? 'Pause' : 'Play'}
|
|
210
|
+
onClick={() => setGenerating((generating) => !generating)}
|
|
211
|
+
/>
|
|
209
212
|
<div className='relative' title='mutation period'>
|
|
210
213
|
<Input.Root>
|
|
211
214
|
<Input.TextInput
|
|
@@ -217,11 +220,9 @@ const Controls = ({ children }: PropsWithChildren) => {
|
|
|
217
220
|
onChange={({ target: { value } }) => setActionInterval(value)}
|
|
218
221
|
/>
|
|
219
222
|
</Input.Root>
|
|
220
|
-
<
|
|
223
|
+
<Icon icon='ph--timer--regular' classNames={mx('absolute inline-end-1 block-start-1 mt-[6px]', getSize(3))} />
|
|
221
224
|
</div>
|
|
222
|
-
<
|
|
223
|
-
<Plus />
|
|
224
|
-
</Button>
|
|
225
|
+
<IconButton icon='ph--plus--regular' label='Add' onClick={() => action && runAction(client, action)} />
|
|
225
226
|
<Select.Root value={action?.toString()} onValueChange={(action) => setAction(action as unknown as Action)}>
|
|
226
227
|
<Select.TriggerButton placeholder='Select value' />
|
|
227
228
|
<Select.Portal>
|
|
@@ -245,23 +246,25 @@ const Controls = ({ children }: PropsWithChildren) => {
|
|
|
245
246
|
);
|
|
246
247
|
};
|
|
247
248
|
|
|
248
|
-
const meta
|
|
249
|
+
const meta = {
|
|
249
250
|
title: 'sdk/app-graph/EchoGraph',
|
|
250
251
|
decorators: [
|
|
252
|
+
withTheme,
|
|
251
253
|
withClientProvider({
|
|
252
254
|
createIdentity: true,
|
|
253
|
-
|
|
255
|
+
onCreateIdentity: async ({ client }) => {
|
|
254
256
|
await client.spaces.create();
|
|
255
257
|
await client.spaces.create();
|
|
256
258
|
},
|
|
257
259
|
}),
|
|
258
|
-
withTheme,
|
|
259
260
|
],
|
|
260
|
-
}
|
|
261
|
+
} satisfies Meta<typeof Registry>;
|
|
261
262
|
|
|
262
263
|
export default meta;
|
|
263
264
|
|
|
264
|
-
|
|
265
|
+
type Story = StoryObj<typeof meta>;
|
|
266
|
+
|
|
267
|
+
export const JsonView: Story = {
|
|
265
268
|
render: () => {
|
|
266
269
|
const client = useClient();
|
|
267
270
|
const registry = useContext(RegistryContext);
|
|
@@ -277,7 +280,7 @@ export const JsonView = {
|
|
|
277
280
|
},
|
|
278
281
|
};
|
|
279
282
|
|
|
280
|
-
export const TreeView = {
|
|
283
|
+
export const TreeView: Story = {
|
|
281
284
|
render: () => {
|
|
282
285
|
const client = useClient();
|
|
283
286
|
const registry = useContext(RegistryContext);
|
package/src/testing.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Rx } from '@effect-rx/rx-react';
|
|
6
6
|
|
|
7
|
+
import { type AnyEchoObject } from '@dxos/echo/internal';
|
|
7
8
|
import { type QueryResult } from '@dxos/echo-db';
|
|
8
|
-
import { type AnyEchoObject } from '@dxos/echo-schema';
|
|
9
9
|
|
|
10
10
|
export const rxFromQuery = <T extends AnyEchoObject>(query: QueryResult<T>): Rx.Rx<T[]> => {
|
|
11
11
|
return Rx.make((get) => {
|