@drakkar.software/starfish-client 3.0.0-alpha.7 → 3.0.0-alpha.9
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/README.md +21 -0
- package/dist/append-log.d.ts +158 -0
- package/dist/bindings/legend.d.ts +23 -0
- package/dist/bindings/legend.js +32 -0
- package/dist/bindings/legend.js.map +2 -2
- package/dist/bindings/zustand.d.ts +38 -0
- package/dist/bindings/zustand.js +235 -50
- package/dist/bindings/zustand.js.map +3 -3
- package/dist/client.d.ts +60 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +313 -52
- package/dist/index.js.map +4 -4
- package/dist/mobile-lifecycle.d.ts +28 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoreApi } from "zustand/vanilla";
|
|
2
|
-
import type { StarfishStore } from "./bindings/zustand.js";
|
|
2
|
+
import type { StarfishStore, StarfishLogStore } from "./bindings/zustand.js";
|
|
3
3
|
/**
|
|
4
4
|
* Minimal interface matching React Native's `AppState` module.
|
|
5
5
|
* Pass `AppState` from `react-native` directly.
|
|
@@ -69,3 +69,30 @@ export interface MobileLifecycleOptions {
|
|
|
69
69
|
* @returns A cleanup function that removes all event listeners.
|
|
70
70
|
*/
|
|
71
71
|
export declare function createMobileLifecycle(store: StoreApi<StarfishStore>, deps: MobileLifecycleDeps, options?: MobileLifecycleOptions): () => void;
|
|
72
|
+
export interface AppendLogLifecycleOptions {
|
|
73
|
+
/**
|
|
74
|
+
* Pull new elements when the app returns to the foreground.
|
|
75
|
+
* Only pulls if the store is online and not already loading.
|
|
76
|
+
* Default: `true`.
|
|
77
|
+
*/
|
|
78
|
+
pullOnForeground?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Wires React Native app lifecycle events to an append-log store
|
|
82
|
+
* (`createStarfishLog`). A log is read-only, so this only pulls on foreground
|
|
83
|
+
* (there is nothing to flush on background). NetInfo connectivity changes are
|
|
84
|
+
* forwarded to `store.getState().setOnline()`.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { AppState } from "react-native"
|
|
88
|
+
* import NetInfo from "@react-native-community/netinfo"
|
|
89
|
+
* import { createStarfishLog, createAppendLogMobileLifecycle } from "@drakkar.software/starfish-client"
|
|
90
|
+
*
|
|
91
|
+
* const store = createStarfishLog({ cursor })
|
|
92
|
+
* const cleanup = createAppendLogMobileLifecycle(store, { appState: AppState, netInfo: NetInfo })
|
|
93
|
+
* useEffect(() => cleanup, [])
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @returns A cleanup function that removes all event listeners.
|
|
97
|
+
*/
|
|
98
|
+
export declare function createAppendLogMobileLifecycle(store: StoreApi<StarfishLogStore>, deps: MobileLifecycleDeps, options?: AppendLogLifecycleOptions): () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakkar.software/starfish-client",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/Drakkar-Software/starfish.git",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@drakkar.software/starfish-protocol": "3.0.0-alpha.
|
|
63
|
+
"@drakkar.software/starfish-protocol": "3.0.0-alpha.9"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@legendapp/state": "^2.0.0",
|