@dxos/react-client 0.8.0 → 0.8.1-main.013e445

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.
@@ -0,0 +1,11 @@
1
+ import type { Queue } from '@dxos/client/echo';
2
+ import type { BaseEchoObject } from '@dxos/echo-schema';
3
+ import { type DXN } from '@dxos/keys';
4
+ export type UseQueueOptions = {
5
+ pollInterval?: number;
6
+ };
7
+ /**
8
+ * Polls the given Edge queue.
9
+ */
10
+ export declare const useQueue: <T extends BaseEchoObject>(queueDxn?: DXN, options?: UseQueueOptions) => Queue<T> | undefined;
11
+ //# sourceMappingURL=useQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQueue.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQueue.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAMtC,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AAIH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,aACpC,GAAG,YACL,eAAe,KACvB,KAAK,CAAC,CAAC,CAAC,GAAG,SAgCb,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import '@dxos-theme';
2
+ import React from 'react';
2
3
  declare const _default: {
3
4
  title: string;
4
- render: () => import("react/jsx-runtime").JSX.Element;
5
+ render: () => React.JSX.Element;
5
6
  };
6
7
  export default _default;
7
8
  export declare const Default: {
@@ -1 +1 @@
1
- {"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;;;;;AA2HrB,wBAGE;AAsBF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
1
+ {"version":3,"file":"Passkey.stories.d.ts","sourceRoot":"","sources":["../../../../src/halo/Passkey.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAsB,MAAM,OAAO,CAAC;;;;;AAyH3C,wBAGE;AAsBF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type FC } from 'react';
1
+ import React, { type FC } from 'react';
2
2
  import { Client, type PublicKey } from '@dxos/client';
3
3
  import { type TypedObject } from '@dxos/echo-schema';
4
4
  import { type WithClientProviderProps } from './withClientProvider';
@@ -24,5 +24,5 @@ export type ClientRepeaterProps<P extends ClientRepeatedComponentProps> = {
24
24
  * The `Component` property is rendered n times, once for each peer.
25
25
  * @deprecated use `withClientProvider`.
26
26
  */
27
- export declare const ClientRepeater: <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => import("react/jsx-runtime").JSX.Element | null;
27
+ export declare const ClientRepeater: <P extends ClientRepeatedComponentProps>(props: ClientRepeaterProps<P>) => React.JSX.Element | null;
28
28
  //# sourceMappingURL=ClientRepeater.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientRepeater.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAY,KAAK,EAAE,EAAqB,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,MAAM,4BAA4B,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE/F,MAAM,MAAM,2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C;AAGhE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,4BAA4B,IAAI;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,EAAE,CAAC,4BAA4B,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,EAAE,CAAC,2BAA2B,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;CAChC,GAAG,IAAI,CAAC,uBAAuB,EAAE,gBAAgB,GAAG,aAAa,GAAG,gBAAgB,CAAC,CAAC;AAEvF;;;;GAIG;AAMH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,4BAA4B,SAAS,mBAAmB,CAAC,CAAC,CAAC,6BA2DnG,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import '@dxos-theme';
2
+ import React from 'react';
2
3
  declare const _default: {
3
4
  title: string;
4
5
  decorators: import("@storybook/react").Decorator[];
5
6
  };
6
7
  export default _default;
7
8
  export declare const Default: {
8
- render: () => import("react/jsx-runtime").JSX.Element;
9
+ render: () => React.JSX.Element;
9
10
  };
10
11
  export declare const Space: {
11
- render: () => import("react/jsx-runtime").JSX.Element;
12
+ render: () => React.JSX.Element;
12
13
  };
13
14
  //# sourceMappingURL=ClientRepeater.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientRepeater.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;;;;;AAYrB,wBAGE;AAgCF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAEjB,CAAC"}
1
+ {"version":3,"file":"ClientRepeater.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;;;;;AAU1B,wBAGE;AAgCF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,KAAK;;CAEjB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { Client, type Config } from '@dxos/client';
2
3
  import { type Space } from '@dxos/client/echo';
3
4
  export declare const createClient: ({ config, createIdentity, createSpace, }?: {
@@ -8,6 +9,6 @@ export declare const createClient: ({ config, createIdentity, createSpace, }?: {
8
9
  client: Client;
9
10
  space: Space | undefined;
10
11
  }>;
11
- export declare const createClientContextProvider: (client: Client) => Promise<({ children }: any) => import("react/jsx-runtime").JSX.Element>;
12
- export declare const createClientProvider: (client: Client) => Promise<({ children }: any) => import("react/jsx-runtime").JSX.Element>;
12
+ export declare const createClientContextProvider: (client: Client) => Promise<({ children }: any) => React.JSX.Element>;
13
+ export declare const createClientProvider: (client: Client) => Promise<({ children }: any) => React.JSX.Element>;
13
14
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAY,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,YAAY,8CAItB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE;;;EActE,CAAC;AAEF,eAAO,MAAM,2BAA2B,WAAkB,MAAM,4BACxC,GAAG,6CAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAkB,MAAM,4BACjC,GAAG,6CAC1B,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAY,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,eAAO,MAAM,YAAY,8CAItB;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE;;;EActE,CAAC;AAEF,eAAO,MAAM,2BAA2B,WAAkB,MAAM,4BACxC,GAAG,uBAC1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAkB,MAAM,4BACjC,GAAG,uBAC1B,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import '@dxos-theme';
2
+ import React from 'react';
2
3
  declare const _default: {
3
4
  title: string;
4
- render: () => import("react/jsx-runtime").JSX.Element | null;
5
+ render: () => React.JSX.Element | null;
5
6
  };
6
7
  export default _default;
7
8
  export declare const Default: {
@@ -1 +1 @@
1
- {"version":3,"file":"withClientProvider.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;;;;;AAkCrB,wBAGE;AAaF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAMpB,CAAC"}
1
+ {"version":3,"file":"withClientProvider.stories.d.ts","sourceRoot":"","sources":["../../../../src/testing/withClientProvider.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;;;;;AAgC1B,wBAGE;AAaF,eAAO,MAAM,OAAO;;CAEnB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAMpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-client",
3
- "version": "0.8.0",
3
+ "version": "0.8.1-main.013e445",
4
4
  "description": "React client API",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -78,40 +78,40 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "react-error-boundary": "^4.0.13",
81
- "@dxos/async": "0.8.0",
82
- "@dxos/codec-protobuf": "0.8.0",
83
- "@dxos/config": "0.8.0",
84
- "@dxos/client": "0.8.0",
85
- "@dxos/debug": "0.8.0",
86
- "@dxos/echo-schema": "0.8.0",
87
- "@dxos/echo-signals": "0.8.0",
88
- "@dxos/invariant": "0.8.0",
89
- "@dxos/log": "0.8.0",
90
- "@dxos/node-std": "0.8.0",
91
- "@dxos/react-hooks": "0.8.0",
92
- "@dxos/util": "0.8.0",
93
- "@dxos/protocols": "0.8.0"
81
+ "@dxos/async": "0.8.1-main.013e445",
82
+ "@dxos/codec-protobuf": "0.8.1-main.013e445",
83
+ "@dxos/config": "0.8.1-main.013e445",
84
+ "@dxos/client": "0.8.1-main.013e445",
85
+ "@dxos/debug": "0.8.1-main.013e445",
86
+ "@dxos/echo-schema": "0.8.1-main.013e445",
87
+ "@dxos/echo-signals": "0.8.1-main.013e445",
88
+ "@dxos/invariant": "0.8.1-main.013e445",
89
+ "@dxos/log": "0.8.1-main.013e445",
90
+ "@dxos/node-std": "0.8.1-main.013e445",
91
+ "@dxos/protocols": "0.8.1-main.013e445",
92
+ "@dxos/react-hooks": "0.8.1-main.013e445",
93
+ "@dxos/util": "0.8.1-main.013e445"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/react": "~18.2.0",
97
97
  "@types/react-dom": "~18.2.0",
98
98
  "react": "~18.2.0",
99
99
  "react-dom": "~18.2.0",
100
- "@dxos/react-ui": "0.8.0",
101
- "@dxos/react-ui-syntax-highlighter": "0.8.0",
102
- "@dxos/random": "0.8.0",
103
- "@dxos/react-ui-theme": "0.8.0",
104
- "@dxos/storybook-utils": "0.8.0",
105
- "@dxos/test-utils": "0.8.0"
100
+ "@dxos/random": "0.8.1-main.013e445",
101
+ "@dxos/react-ui": "0.8.1-main.013e445",
102
+ "@dxos/react-ui-syntax-highlighter": "0.8.1-main.013e445",
103
+ "@dxos/react-ui-theme": "0.8.1-main.013e445",
104
+ "@dxos/storybook-utils": "0.8.1-main.013e445",
105
+ "@dxos/test-utils": "0.8.1-main.013e445"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "react": "~18.2.0",
109
109
  "react-dom": "~18.2.0"
110
110
  },
111
111
  "optionalDependencies": {
112
- "@dxos/random": "0.8.0",
113
- "@dxos/react-ui": "0.8.0",
114
- "@dxos/react-ui-theme": "0.8.0"
112
+ "@dxos/random": "0.8.1-main.013e445",
113
+ "@dxos/react-ui": "0.8.1-main.013e445",
114
+ "@dxos/react-ui-theme": "0.8.1-main.013e445"
115
115
  },
116
116
  "publishConfig": {
117
117
  "access": "public"
package/src/echo/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from './useSchema';
10
10
  export * from './useSpaces';
11
11
  export * from './useSpaceInvitations';
12
12
  export * from './useSubscription';
13
+ export * from './useQueue';
@@ -0,0 +1,61 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useMemo } from 'react';
6
+
7
+ import type { Queue } from '@dxos/client/echo';
8
+ import { raise } from '@dxos/debug';
9
+ import type { BaseEchoObject } from '@dxos/echo-schema';
10
+ import { type DXN } from '@dxos/keys';
11
+
12
+ import { useClient } from '../client';
13
+
14
+ const MIN_POLL_INTERVAL = 1_000;
15
+
16
+ export type UseQueueOptions = {
17
+ pollInterval?: number;
18
+ };
19
+
20
+ /**
21
+ * Polls the given Edge queue.
22
+ */
23
+ // TODO(burdon): Replace polling with socket?
24
+ // TODO(dmaretskyi): Move into client package.
25
+ // TODO(dmaretskyi): Consider passing the space into the hook to support queue DXNs without space id.
26
+ export const useQueue = <T extends BaseEchoObject>(
27
+ queueDxn?: DXN,
28
+ options: UseQueueOptions = {},
29
+ ): Queue<T> | undefined => {
30
+ const client = useClient();
31
+ const queue = useMemo<Queue<T> | undefined>(() => {
32
+ if (!queueDxn) {
33
+ return undefined;
34
+ }
35
+
36
+ const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError('Invalid queue DXN'));
37
+
38
+ return client.spaces.get(spaceId)?.queues.get<T>(queueDxn);
39
+ }, [client, queueDxn?.toString()]);
40
+
41
+ useEffect(() => {
42
+ void queue?.refresh();
43
+ }, [queue]);
44
+
45
+ useEffect(() => {
46
+ let timeout: NodeJS.Timeout;
47
+ if (options.pollInterval) {
48
+ const poll = () => {
49
+ void queue?.refresh().finally(() => {
50
+ timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));
51
+ });
52
+ };
53
+
54
+ poll();
55
+ }
56
+
57
+ return () => clearTimeout(timeout);
58
+ }, [queue, options.pollInterval]);
59
+
60
+ return queue;
61
+ };