@dxos/app-graph 0.8.4-main.3f58842 → 0.8.4-main.406dc2a

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.
@@ -2,40 +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 { type Meta } from '@storybook/react-vite';
9
- import { Option, pipe } from 'effect';
6
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
7
+ import * as Function from 'effect/Function';
8
+ import * as Option from 'effect/Option';
10
9
  import React, { type PropsWithChildren, useCallback, useContext, useEffect, useMemo, useState } from 'react';
11
10
 
12
11
  import {
13
- live,
14
- isSpace,
12
+ Expando,
13
+ Filter,
14
+ type Live,
15
15
  Query,
16
16
  type QueryResult,
17
17
  type Space,
18
18
  SpaceState,
19
- Expando,
20
- type Live,
21
- Filter,
19
+ isSpace,
20
+ live,
22
21
  } from '@dxos/client/echo';
23
22
  import { Obj, Type } from '@dxos/echo';
24
23
  import { faker } from '@dxos/random';
25
24
  import { type Client, useClient } from '@dxos/react-client';
26
25
  import { withClientProvider } from '@dxos/react-client/testing';
27
- import { Input, Select, Icon, IconButton } from '@dxos/react-ui';
26
+ import { Icon, IconButton, Input, Select } from '@dxos/react-ui';
27
+ import { withTheme } from '@dxos/react-ui/testing';
28
28
  import { Path, Tree } from '@dxos/react-ui-list';
29
29
  import { getSize, mx } from '@dxos/react-ui-theme';
30
- import { withTheme } from '@dxos/storybook-utils';
31
30
  import { byPosition, isNonNullable, safeParseInt } from '@dxos/util';
32
31
 
33
- import { JsonTree } from './Tree';
34
32
  import { type ExpandableGraph, ROOT_ID } from '../graph';
35
33
  import { GraphBuilder, createExtension, rxFromObservable, rxFromSignal } from '../graph-builder';
36
34
  import { type Node } from '../node';
37
35
  import { rxFromQuery } from '../testing';
38
36
 
37
+ import { JsonTree } from './Tree';
38
+
39
39
  const DEFAULT_PERIOD = 500;
40
40
 
41
41
  enum Action {
@@ -61,7 +61,7 @@ const createGraph = (client: Client, registry: Registry.Registry): ExpandableGra
61
61
  id: 'space',
62
62
  connector: (node) =>
63
63
  Rx.make((get) =>
64
- pipe(
64
+ Function.pipe(
65
65
  get(node),
66
66
  Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
67
67
  Option.map(() => {
@@ -85,7 +85,7 @@ const createGraph = (client: Client, registry: Registry.Registry): ExpandableGra
85
85
  connector: (node) => {
86
86
  let query: QueryResult<Live<Expando>> | undefined;
87
87
  return Rx.make((get) =>
88
- pipe(
88
+ Function.pipe(
89
89
  get(node),
90
90
  Option.flatMap((node) => (isSpace(node.data) ? Option.some(node.data) : Option.none())),
91
91
  Option.map((space) => {
@@ -246,23 +246,25 @@ const Controls = ({ children }: PropsWithChildren) => {
246
246
  );
247
247
  };
248
248
 
249
- const meta: Meta = {
249
+ const meta = {
250
250
  title: 'sdk/app-graph/EchoGraph',
251
251
  decorators: [
252
+ withTheme,
252
253
  withClientProvider({
253
254
  createIdentity: true,
254
- onIdentityCreated: async ({ client }) => {
255
+ onCreateIdentity: async ({ client }) => {
255
256
  await client.spaces.create();
256
257
  await client.spaces.create();
257
258
  },
258
259
  }),
259
- withTheme,
260
260
  ],
261
- };
261
+ } satisfies Meta<typeof Registry>;
262
262
 
263
263
  export default meta;
264
264
 
265
- export const JsonView = {
265
+ type Story = StoryObj<typeof meta>;
266
+
267
+ export const JsonView: Story = {
266
268
  render: () => {
267
269
  const client = useClient();
268
270
  const registry = useContext(RegistryContext);
@@ -278,7 +280,7 @@ export const JsonView = {
278
280
  },
279
281
  };
280
282
 
281
- export const TreeView = {
283
+ export const TreeView: Story = {
282
284
  render: () => {
283
285
  const client = useClient();
284
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) => {