@towns-protocol/react-sdk 0.0.208 → 0.0.210
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObservable.d.ts","sourceRoot":"","sources":["../../src/useObservable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAI1E,yBAAiB,gBAAgB,CAAC;IAC9B;;;OAGG;IACH,KAAY,cAAc,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"useObservable.d.ts","sourceRoot":"","sources":["../../src/useObservable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAI1E,yBAAiB,gBAAgB,CAAC;IAC9B;;;OAGG;IACH,KAAY,cAAc,CAAC,WAAW,IAClC,WAAW,SAAS,UAAU,CAAC,MAAM,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IAKvE;;;OAGG;IACH,KAAY,QAAQ,CAAC,IAAI,IACrB,IAAI,SAAS,cAAc,CAAC,MAAM,aAAa,CAAC,GAC1C;QACI;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,+DAA+D;QAC/D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;QAExC,2DAA2D;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;KACnC,GACD;QACI;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,+DAA+D;QAC/D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;QAE/B,2DAA2D;QAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;KACnC,CAAA;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,CAAC,CAAA;IACP,iEAAiE;IACjE,KAAK,EAAE,KAAK,GAAG,SAAS,CAAA;IACxB,+BAA+B;IAC/B,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;IACtC,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;IAClB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAA;IAChB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CACzB,KAAK,EACL,IAAI,GAAG,KAAK,SAAS,cAAc,CAAC,MAAM,aAAa,CAAC,GAAG,aAAa,GAAG,KAAK,EAClF,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAmDjG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@towns-protocol/react-sdk",
|
|
3
3
|
"description": "React Hooks for Towns Protocol SDK",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.210",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
7
7
|
"types": "./dist/types/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"watch": "yarn build -w"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@towns-protocol/sdk": "^0.0.
|
|
24
|
+
"@towns-protocol/sdk": "^0.0.210",
|
|
25
25
|
"ethers": "^5.7.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@types/react-dom": "^18.2.4",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^8.29.0",
|
|
36
36
|
"@typescript-eslint/parser": "^8.29.0",
|
|
37
|
-
"eslint": "^8.57.
|
|
38
|
-
"eslint-plugin-import": "^
|
|
37
|
+
"eslint": "^8.57.1",
|
|
38
|
+
"eslint-plugin-import-x": "^4.10.2",
|
|
39
39
|
"eslint-plugin-react": "^7.32.2",
|
|
40
40
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
41
41
|
"eslint-plugin-tsdoc": "^0.3.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
72
|
"typings": "./dist/types/index.d.ts",
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "8aa8a629ece460a2bb51f430da46db19e8861761"
|
|
74
74
|
}
|
package/src/useObservable.ts
CHANGED
|
@@ -9,9 +9,8 @@ export namespace ObservableConfig {
|
|
|
9
9
|
* Configuration options for an observable.
|
|
10
10
|
* It can be used to configure the behavior of the `useObservable` hook.
|
|
11
11
|
*/
|
|
12
|
-
export type FromObservable<Observable_> =
|
|
13
|
-
? FromData<Data>
|
|
14
|
-
: never
|
|
12
|
+
export type FromObservable<Observable_> =
|
|
13
|
+
Observable_ extends Observable<infer Data> ? FromData<Data> : never
|
|
15
14
|
|
|
16
15
|
// TODO: Some util props:
|
|
17
16
|
// - select: select a subset of the data, or transform it
|
|
@@ -20,31 +19,32 @@ export namespace ObservableConfig {
|
|
|
20
19
|
* Create configuration options for an observable from the data type.
|
|
21
20
|
* It can be used to configure the behavior of the `useObservable` hook.
|
|
22
21
|
*/
|
|
23
|
-
export type FromData<Data> =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
export type FromData<Data> =
|
|
23
|
+
Data extends PersistedModel<infer UnwrappedData>
|
|
24
|
+
? {
|
|
25
|
+
/**
|
|
26
|
+
* Trigger the update immediately, without waiting for the first update.
|
|
27
|
+
* @defaultValue true
|
|
28
|
+
*/
|
|
29
|
+
fireImmediately?: boolean
|
|
30
|
+
/** Callback function to be called when the data is updated. */
|
|
31
|
+
onUpdate?: (data: UnwrappedData) => void
|
|
32
|
+
// TODO: when an error occurs? store errors? RPC error?
|
|
33
|
+
/** Callback function to be called when an error occurs. */
|
|
34
|
+
onError?: (error: Error) => void
|
|
35
|
+
}
|
|
36
|
+
: {
|
|
37
|
+
/**
|
|
38
|
+
* Trigger the update immediately, without waiting for the first update.
|
|
39
|
+
* @defaultValue true
|
|
40
|
+
*/
|
|
41
|
+
fireImmediately?: boolean
|
|
42
|
+
/** Callback function to be called when the data is updated. */
|
|
43
|
+
onUpdate?: (data: Data) => void
|
|
44
|
+
// TODO: when an error occurs? store errors? RPC error?
|
|
45
|
+
/** Callback function to be called when an error occurs. */
|
|
46
|
+
onError?: (error: Error) => void
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|