@dxos/react-client 0.8.1-main.ae460ac → 0.8.1-staging.31c3ee1

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 (34) hide show
  1. package/dist/lib/browser/echo/index.mjs +61 -1
  2. package/dist/lib/browser/echo/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/echo/index.cjs +60 -1
  5. package/dist/lib/node/echo/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/echo/index.mjs +61 -1
  8. package/dist/lib/node-esm/echo/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/client/AgentHostingProvider.d.ts +1 -1
  11. package/dist/types/src/client/AgentHostingProvider.d.ts.map +1 -1
  12. package/dist/types/src/echo/index.d.ts +1 -0
  13. package/dist/types/src/echo/index.d.ts.map +1 -1
  14. package/dist/types/src/echo/useQuery.d.ts +1 -1
  15. package/dist/types/src/echo/useQuery.d.ts.map +1 -1
  16. package/dist/types/src/echo/useQueue.d.ts +11 -0
  17. package/dist/types/src/echo/useQueue.d.ts.map +1 -0
  18. package/dist/types/src/echo/useSchema.d.ts +3 -2
  19. package/dist/types/src/echo/useSchema.d.ts.map +1 -1
  20. package/dist/types/src/halo/Passkey.stories.d.ts +2 -1
  21. package/dist/types/src/halo/Passkey.stories.d.ts.map +1 -1
  22. package/dist/types/src/testing/ClientRepeater.d.ts +2 -2
  23. package/dist/types/src/testing/ClientRepeater.d.ts.map +1 -1
  24. package/dist/types/src/testing/ClientRepeater.stories.d.ts +3 -2
  25. package/dist/types/src/testing/ClientRepeater.stories.d.ts.map +1 -1
  26. package/dist/types/src/testing/util.d.ts +3 -2
  27. package/dist/types/src/testing/util.d.ts.map +1 -1
  28. package/dist/types/src/testing/withClientProvider.stories.d.ts +2 -1
  29. package/dist/types/src/testing/withClientProvider.stories.d.ts.map +1 -1
  30. package/package.json +23 -23
  31. package/src/echo/index.ts +1 -0
  32. package/src/echo/useQuery.ts +1 -1
  33. package/src/echo/useQueue.ts +73 -0
  34. package/src/echo/useSchema.ts +19 -3
@@ -13,6 +13,6 @@ export declare const AgentHostingContext: React.Context<AgentHostingProviderClie
13
13
  * @constructor
14
14
  * @deprecated
15
15
  */
16
- export declare const AgentHostingProvider: (props: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const AgentHostingProvider: (props: PropsWithChildren) => React.JSX.Element;
17
17
  export declare const useAgentHostingClient: () => AgentHostingProviderClient | null;
18
18
  //# sourceMappingURL=AgentHostingProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/AgentHostingProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAiB,KAAK,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAE3F,OAAO,EAAE,KAAK,0BAA0B,EAAgD,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,mBAAmB,kDAAyD,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,4CAM5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,yCAEjC,CAAC"}
1
+ {"version":3,"file":"AgentHostingProvider.d.ts","sourceRoot":"","sources":["../../../../src/client/AgentHostingProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAiB,KAAK,iBAAiB,EAAwB,MAAM,OAAO,CAAC;AAE3F,OAAO,EAAE,KAAK,0BAA0B,EAAgD,MAAM,cAAc,CAAC;AAC7G,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAK3C,MAAM,MAAM,yBAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvE,eAAO,MAAM,mBAAmB,kDAAyD,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,UAAW,iBAAiB,sBAM5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,yCAEjC,CAAC"}
@@ -5,4 +5,5 @@ export * from './useSchema';
5
5
  export * from './useSpaces';
6
6
  export * from './useSpaceInvitations';
7
7
  export * from './useSubscription';
8
+ export * from './useQueue';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/echo/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAElC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/echo/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAElC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import { type Echo, type FilterSource, type ReactiveEchoObject, type QueryOptions, type Space } from '@dxos/client/echo';
1
+ import { type Echo, type FilterSource, type QueryOptions, type ReactiveEchoObject, type Space } from '@dxos/client/echo';
2
2
  /**
3
3
  * Create subscription.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,YAAY,EAEjB,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EACjB,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AAEH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,gBAC1C,KAAK,GAAG,IAAI,WACjB,YAAY,CAAC,CAAC,CAAC,YACd,YAAY,SACf,GAAG,EAAE,KACX,CAAC,EAwBH,CAAC"}
1
+ {"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../../../src/echo/useQuery.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,YAAY,EAGjB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AAEH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,kBAAkB,CAAC,GAAG,CAAC,gBAC1C,KAAK,GAAG,IAAI,WACjB,YAAY,CAAC,CAAC,CAAC,YACd,YAAY,SACf,GAAG,EAAE,KACX,CAAC,EAwBH,CAAC"}
@@ -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;AAKH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,aACpC,GAAG,YACL,eAAe,KACvB,KAAK,CAAC,CAAC,CAAC,GAAG,SA2Cb,CAAC"}
@@ -1,7 +1,8 @@
1
+ import { type Client } from '@dxos/client';
1
2
  import { type Space } from '@dxos/client/echo';
2
- import { type EchoSchema } from '@dxos/echo-schema';
3
+ import { type BaseSchema } from '@dxos/echo-schema';
3
4
  /**
4
5
  * Subscribe to and retrieve schema changes from a space's schema registry.
5
6
  */
6
- export declare const useSchema: (space: Space | undefined, typename: string | undefined) => EchoSchema | undefined;
7
+ export declare const useSchema: (client: Client, space: Space | undefined, typename: string | undefined) => BaseSchema | undefined;
7
8
  //# sourceMappingURL=useSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSchema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,SAAS,UAAW,KAAK,GAAG,SAAS,YAAY,MAAM,GAAG,SAAS,KAAG,UAAU,GAAG,SA0B/F,CAAC"}
1
+ {"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../../src/echo/useSchema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,SAAS,WACZ,MAAM,SACP,KAAK,GAAG,SAAS,YACd,MAAM,GAAG,SAAS,KAC3B,UAAU,GAAG,SAqCf,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,2BAA2B,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;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,mDA2DnG,CAAC"}
1
+ {"version":3,"file":"ClientRepeater.d.ts","sourceRoot":"","sources":["../../../../src/testing/ClientRepeater.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,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,2BAA2B,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;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.1-main.ae460ac",
3
+ "version": "0.8.1-staging.31c3ee1",
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/client": "0.8.1-main.ae460ac",
82
- "@dxos/async": "0.8.1-main.ae460ac",
83
- "@dxos/codec-protobuf": "0.8.1-main.ae460ac",
84
- "@dxos/debug": "0.8.1-main.ae460ac",
85
- "@dxos/config": "0.8.1-main.ae460ac",
86
- "@dxos/echo-schema": "0.8.1-main.ae460ac",
87
- "@dxos/invariant": "0.8.1-main.ae460ac",
88
- "@dxos/echo-signals": "0.8.1-main.ae460ac",
89
- "@dxos/log": "0.8.1-main.ae460ac",
90
- "@dxos/node-std": "0.8.1-main.ae460ac",
91
- "@dxos/react-hooks": "0.8.1-main.ae460ac",
92
- "@dxos/util": "0.8.1-main.ae460ac",
93
- "@dxos/protocols": "0.8.1-main.ae460ac"
81
+ "@dxos/async": "0.8.1-staging.31c3ee1",
82
+ "@dxos/client": "0.8.1-staging.31c3ee1",
83
+ "@dxos/codec-protobuf": "0.8.1-staging.31c3ee1",
84
+ "@dxos/config": "0.8.1-staging.31c3ee1",
85
+ "@dxos/echo-signals": "0.8.1-staging.31c3ee1",
86
+ "@dxos/echo-schema": "0.8.1-staging.31c3ee1",
87
+ "@dxos/log": "0.8.1-staging.31c3ee1",
88
+ "@dxos/invariant": "0.8.1-staging.31c3ee1",
89
+ "@dxos/debug": "0.8.1-staging.31c3ee1",
90
+ "@dxos/node-std": "0.8.1-staging.31c3ee1",
91
+ "@dxos/protocols": "0.8.1-staging.31c3ee1",
92
+ "@dxos/util": "0.8.1-staging.31c3ee1",
93
+ "@dxos/react-hooks": "0.8.1-staging.31c3ee1"
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/random": "0.8.1-main.ae460ac",
101
- "@dxos/react-ui": "0.8.1-main.ae460ac",
102
- "@dxos/storybook-utils": "0.8.1-main.ae460ac",
103
- "@dxos/react-ui-syntax-highlighter": "0.8.1-main.ae460ac",
104
- "@dxos/test-utils": "0.8.1-main.ae460ac",
105
- "@dxos/react-ui-theme": "0.8.1-main.ae460ac"
100
+ "@dxos/random": "0.8.1-staging.31c3ee1",
101
+ "@dxos/react-ui-syntax-highlighter": "0.8.1-staging.31c3ee1",
102
+ "@dxos/react-ui-theme": "0.8.1-staging.31c3ee1",
103
+ "@dxos/react-ui": "0.8.1-staging.31c3ee1",
104
+ "@dxos/storybook-utils": "0.8.1-staging.31c3ee1",
105
+ "@dxos/test-utils": "0.8.1-staging.31c3ee1"
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.1-main.ae460ac",
113
- "@dxos/react-ui": "0.8.1-main.ae460ac",
114
- "@dxos/react-ui-theme": "0.8.1-main.ae460ac"
112
+ "@dxos/random": "0.8.1-staging.31c3ee1",
113
+ "@dxos/react-ui": "0.8.1-staging.31c3ee1",
114
+ "@dxos/react-ui-theme": "0.8.1-staging.31c3ee1"
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';
@@ -9,9 +9,9 @@ import {
9
9
  type Echo,
10
10
  type FilterSource,
11
11
  Filter,
12
- type ReactiveEchoObject,
13
12
  type Query,
14
13
  type QueryOptions,
14
+ type ReactiveEchoObject,
15
15
  type Space,
16
16
  } from '@dxos/client/echo';
17
17
 
@@ -0,0 +1,73 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect, useMemo, useRef } 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
+ // TODO(ZaymonFC): If queue is unchanged returned object should be refferentially stable on poll.
27
+ export const useQueue = <T extends BaseEchoObject>(
28
+ queueDxn?: DXN,
29
+ options: UseQueueOptions = {},
30
+ ): Queue<T> | undefined => {
31
+ const client = useClient();
32
+ const mountedRef = useRef(true);
33
+
34
+ const queue = useMemo<Queue<T> | undefined>(() => {
35
+ if (!queueDxn) {
36
+ return undefined;
37
+ }
38
+ const { spaceId } = queueDxn.asQueueDXN() ?? raise(new TypeError('Invalid queue DXN'));
39
+ return client.spaces.get(spaceId)?.queues.get<T>(queueDxn);
40
+ }, [client, queueDxn?.toString()]);
41
+
42
+ useEffect(() => {
43
+ void queue?.refresh();
44
+ }, [queue]);
45
+
46
+ useEffect(() => {
47
+ let timeout: NodeJS.Timeout;
48
+ mountedRef.current = true;
49
+
50
+ const poll = () => {
51
+ if (!mountedRef.current) {
52
+ return;
53
+ }
54
+
55
+ void queue?.refresh().finally(() => {
56
+ if (mountedRef.current && options.pollInterval) {
57
+ timeout = setTimeout(poll, Math.max(options.pollInterval ?? 0, MIN_POLL_INTERVAL));
58
+ }
59
+ });
60
+ };
61
+
62
+ if (options.pollInterval) {
63
+ poll();
64
+ }
65
+
66
+ return () => {
67
+ mountedRef.current = false;
68
+ clearTimeout(timeout);
69
+ };
70
+ }, [queue, options.pollInterval]);
71
+
72
+ return queue;
73
+ };
@@ -4,13 +4,18 @@
4
4
 
5
5
  import { useMemo, useSyncExternalStore } from 'react';
6
6
 
7
+ import { type Client } from '@dxos/client';
7
8
  import { type Space } from '@dxos/client/echo';
8
- import { type EchoSchema } from '@dxos/echo-schema';
9
+ import { ImmutableSchema, type BaseSchema } from '@dxos/echo-schema';
9
10
 
10
11
  /**
11
12
  * Subscribe to and retrieve schema changes from a space's schema registry.
12
13
  */
13
- export const useSchema = (space: Space | undefined, typename: string | undefined): EchoSchema | undefined => {
14
+ export const useSchema = (
15
+ client: Client,
16
+ space: Space | undefined,
17
+ typename: string | undefined,
18
+ ): BaseSchema | undefined => {
14
19
  const { subscribe, getSchema } = useMemo(() => {
15
20
  if (!typename || !space) {
16
21
  return {
@@ -19,8 +24,18 @@ export const useSchema = (space: Space | undefined, typename: string | undefined
19
24
  };
20
25
  }
21
26
 
27
+ const staticSchema = client.graph.schemaRegistry.getSchema(typename);
28
+ if (staticSchema) {
29
+ // Don't inline into getSchema, need a stable reference.
30
+ const immutableSchema = new ImmutableSchema(staticSchema);
31
+ return {
32
+ subscribe: () => () => {},
33
+ getSchema: () => immutableSchema,
34
+ };
35
+ }
36
+
22
37
  const query = space.db.schemaRegistry.query({ typename });
23
- const initialResult = query.runSync()[0];
38
+ const initialResult: BaseSchema = query.runSync()[0];
24
39
  let currentSchema = initialResult;
25
40
 
26
41
  return {
@@ -29,6 +44,7 @@ export const useSchema = (space: Space | undefined, typename: string | undefined
29
44
  currentSchema = query.results[0];
30
45
  onStoreChange();
31
46
  });
47
+
32
48
  return unsubscribe;
33
49
  },
34
50
  getSchema: () => currentSchema,