@dxos/echo-react 0.8.4-main.e00bdcdb52 → 0.8.4-main.effb148878

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/echo-react",
3
- "version": "0.8.4-main.e00bdcdb52",
3
+ "version": "0.8.4-main.effb148878",
4
4
  "description": "React integration for ECHO.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": false,
14
14
  "type": "module",
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "@effect-atom/atom": "^0.5.1",
29
29
  "@effect-atom/atom-react": "^0.5.0",
30
- "@dxos/echo": "0.8.4-main.e00bdcdb52",
31
- "@dxos/echo-atom": "0.8.4-main.e00bdcdb52"
30
+ "@dxos/echo-atom": "0.8.4-main.effb148878",
31
+ "@dxos/echo": "0.8.4-main.effb148878"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@testing-library/react": "^16.3.0",
@@ -36,7 +36,7 @@
36
36
  "@types/react-dom": "~19.2.3",
37
37
  "react": "~19.2.3",
38
38
  "react-dom": "~19.2.3",
39
- "@dxos/echo-db": "0.8.4-main.e00bdcdb52"
39
+ "@dxos/echo-db": "0.8.4-main.effb148878"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "~19.2.3"
package/src/index.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  //
4
4
 
5
5
  export * from './useQuery';
6
- export * from './useSchema';
6
+ export * from './useType';
7
7
  export * from './useObject';
@@ -8,8 +8,7 @@
8
8
  import { renderHook } from '@testing-library/react';
9
9
  import { describe, expect, test } from 'vitest';
10
10
 
11
- import { Filter } from '@dxos/client/echo';
12
- import { Obj, Type } from '@dxos/echo';
11
+ import { Filter, Obj, Type } from '@dxos/echo';
13
12
  import { TestSchema } from '@dxos/echo/testing';
14
13
 
15
14
  import { createClient, createClientContextProvider } from '../testing/util';
@@ -7,36 +7,35 @@ import { useMemo, useSyncExternalStore } from 'react';
7
7
  import { type Database, type Type } from '@dxos/echo';
8
8
 
9
9
  /**
10
- * Subscribe to and retrieve schema changes from a space's schema registry.
10
+ * Subscribe to and retrieve type changes from a space's schema registry.
11
11
  */
12
- export const useSchema = <T extends Type.AnyEntity = Type.AnyEntity>(
12
+ export const useType = <T extends Type.AnyEntity = Type.AnyEntity>(
13
13
  db?: Database.Database,
14
14
  typename?: string,
15
15
  ): T | undefined => {
16
- const { subscribe, getSchema } = useMemo(() => {
16
+ const { subscribe, getType } = useMemo(() => {
17
17
  if (!typename || !db) {
18
18
  return {
19
19
  subscribe: () => () => {},
20
- getSchema: () => undefined,
20
+ getType: (): T | undefined => undefined,
21
21
  };
22
22
  }
23
23
 
24
24
  const query = db.schemaRegistry.query({ typename, location: ['database', 'runtime'] });
25
- const initialResult = query.runSync()[0];
26
- let currentSchema = initialResult;
25
+ let currentType = query.runSync()[0] as T | undefined;
27
26
 
28
27
  return {
29
28
  subscribe: (onStoreChange: () => void) => {
30
29
  const unsubscribe = query.subscribe(() => {
31
- currentSchema = query.results[0];
30
+ currentType = query.results[0] as T | undefined;
32
31
  onStoreChange();
33
32
  });
34
33
 
35
34
  return unsubscribe;
36
35
  },
37
- getSchema: () => currentSchema,
36
+ getType: (): T | undefined => currentType,
38
37
  };
39
38
  }, [typename, db]);
40
39
 
41
- return useSyncExternalStore(subscribe, getSchema) as T;
40
+ return useSyncExternalStore(subscribe, getType);
42
41
  };
@@ -1,6 +0,0 @@
1
- import { type Database, type Type } from '@dxos/echo';
2
- /**
3
- * Subscribe to and retrieve schema changes from a space's schema registry.
4
- */
5
- export declare const useSchema: <T extends Type.AnyEntity = Type.AnyEntity>(db?: Database.Database, typename?: string) => T | undefined;
6
- //# sourceMappingURL=useSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../../src/useSchema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,OAC5D,QAAQ,CAAC,QAAQ,aACX,MAAM,KAChB,CAAC,GAAG,SA2BN,CAAC"}