@holo-js/flux-react 0.3.27 → 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Holo-JS contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ ad2a58b80c75d7f3c487a239216c5b673fb098de24f8e2254c863e0198cc0da6
package/dist/index.d.ts CHANGED
@@ -8,6 +8,9 @@ interface FluxHookOptions<TManifest extends GeneratedBroadcastManifest = Generat
8
8
  readonly client?: FluxClient<TManifest>;
9
9
  readonly onUnmount?: (cleanup: () => void) => void;
10
10
  }
11
+ interface FluxChannelHookOptions<TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest> extends FluxHookOptions<TManifest> {
12
+ readonly onError?: (error: Error) => void;
13
+ }
11
14
  interface FluxConnectionStatusHookOptions<TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest> extends FluxHookOptions<TManifest> {
12
15
  readonly onChange?: (status: FluxConnectionStatus) => void;
13
16
  }
@@ -17,12 +20,13 @@ interface FluxPresenceHookCallbacks<TMember = unknown> {
17
20
  type FluxPresenceHookState<TMember = unknown> = FluxListenerControls & {
18
21
  readonly members: readonly TMember[];
19
22
  };
20
- declare function useFlux<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxHookOptions<TManifest>): FluxListenerControls;
21
- declare function useFluxPublic<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxHookOptions<TManifest>): FluxListenerControls;
22
- declare function useFluxPrivate<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxHookOptions<TManifest>): FluxListenerControls;
23
- declare function useFluxPresence<TMember = unknown, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, callbacks?: FluxPresenceHookCallbacks<ManifestHookPresenceMember<TMember, TManifest, TChannel>>, options?: FluxHookOptions<TManifest>): FluxPresenceHookState<ManifestHookPresenceMember<TMember, TManifest, TChannel>>;
24
- declare function useFluxNotification<TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, callback: (payload: unknown) => void, options?: FluxHookOptions<TManifest>): FluxListenerControls;
25
- declare function useFluxModel<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxHookOptions<TManifest>): FluxListenerControls;
23
+ declare function useFlux<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxChannelHookOptions<TManifest>): FluxListenerControls;
24
+ declare function useFluxPublic<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxChannelHookOptions<TManifest>): FluxListenerControls;
25
+ declare function useFluxPrivate<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxChannelHookOptions<TManifest>): FluxListenerControls;
26
+ declare function useFluxPresence<TMember = unknown, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, callbacks?: FluxPresenceHookCallbacks<ManifestHookPresenceMember<TMember, TManifest, TChannel>>, options?: FluxChannelHookOptions<TManifest>): FluxPresenceHookState<ManifestHookPresenceMember<TMember, TManifest, TChannel>>;
27
+ declare function useFluxNotification<TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, callback: (payload: unknown) => void, options?: FluxChannelHookOptions<TManifest>): FluxListenerControls;
28
+ declare function useFluxModel<TEvent extends string, TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest, TChannel extends ManifestHookChannel<TManifest> = ManifestHookChannel<TManifest>>(channel: TChannel & ManifestHookChannel<NoInfer<TManifest>>, events: ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent> | readonly ManifestHookEvent<NoInfer<TManifest>, TChannel, TEvent>[], callback: (payload: BroadcastPayloadFor<TEvent>) => void, options?: FluxChannelHookOptions<TManifest>): FluxListenerControls;
26
29
  declare function useFluxConnectionStatus<TManifest extends GeneratedBroadcastManifest = GeneratedBroadcastManifest>(options?: FluxConnectionStatusHookOptions<TManifest>): FluxConnectionStatus;
27
30
 
28
- export { type FluxConnectionStatusHookOptions, type FluxHookOptions, type FluxPresenceHookCallbacks, type FluxPresenceHookState, useFlux, useFluxConnectionStatus, useFluxModel, useFluxNotification, useFluxPresence, useFluxPrivate, useFluxPublic };
31
+ export { useFlux, useFluxConnectionStatus, useFluxModel, useFluxNotification, useFluxPresence, useFluxPrivate, useFluxPublic };
32
+ export type { FluxChannelHookOptions, FluxConnectionStatusHookOptions, FluxHookOptions, FluxPresenceHookCallbacks, FluxPresenceHookState };
package/dist/index.mjs CHANGED
@@ -75,8 +75,9 @@ function useEventSubscription(buildSubscription, events, callback, onUnmount, de
75
75
  }
76
76
  function useFlux(channel, events, callback, options = {}) {
77
77
  const client = resolveClient(options);
78
+ const onErrorRef = useLatestRef(options.onError);
78
79
  return useEventSubscription(
79
- () => client.private(channel),
80
+ () => client.private(channel).error((error) => onErrorRef.current?.(error)),
80
81
  events,
81
82
  callback,
82
83
  options.onUnmount,
@@ -85,8 +86,9 @@ function useFlux(channel, events, callback, options = {}) {
85
86
  }
86
87
  function useFluxPublic(channel, events, callback, options = {}) {
87
88
  const client = resolveClient(options);
89
+ const onErrorRef = useLatestRef(options.onError);
88
90
  return useEventSubscription(
89
- () => client.channel(channel),
91
+ () => client.channel(channel).error((error) => onErrorRef.current?.(error)),
90
92
  events,
91
93
  callback,
92
94
  options.onUnmount,
@@ -103,8 +105,10 @@ function useFluxPresence(channel, callbacks = {}, options = {}) {
103
105
  const controlsRef = useRef(createNoopControls());
104
106
  const callbacksRef = useLatestRef(callbacks);
105
107
  const onUnmountRef = useLatestRef(options.onUnmount);
108
+ const onErrorRef = useLatestRef(options.onError);
106
109
  useEffect(() => {
107
110
  const subscription = client.presence(channel);
111
+ subscription.error((error) => onErrorRef.current?.(error));
108
112
  let active = true;
109
113
  const updateMembers = (members) => {
110
114
  membersRef.current = members;
@@ -150,7 +154,7 @@ function useFluxPresence(channel, callbacks = {}, options = {}) {
150
154
  }).listen();
151
155
  onUnmountRef.current?.(cleanup);
152
156
  return cleanup;
153
- }, [channel, client, callbacksRef, onUnmountRef]);
157
+ }, [channel, client, callbacksRef, onUnmountRef, onErrorRef]);
154
158
  const controls = useMemo(() => Object.freeze({
155
159
  leave: () => {
156
160
  controlsRef.current.leave();
@@ -175,8 +179,9 @@ function useFluxPresence(channel, callbacks = {}, options = {}) {
175
179
  function useFluxNotification(channel, callback, options = {}) {
176
180
  const client = resolveClient(options);
177
181
  const callbackRef = useLatestRef(callback);
182
+ const onErrorRef = useLatestRef(options.onError);
178
183
  return useControls(() => {
179
- return client.private(channel).notification(
184
+ return client.private(channel).error((error) => onErrorRef.current?.(error)).notification(
180
185
  callbackRef.current
181
186
  );
182
187
  }, options.onUnmount, [client, channel]);
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@holo-js/flux-react",
3
- "version": "0.3.27",
3
+ "version": "0.4.0",
4
4
  "description": "Holo-JS Framework - React and Next hook skeletons for Flux",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/cobraprojects/holo-js.git",
10
+ "directory": "packages/flux-react"
11
+ },
7
12
  "exports": {
8
13
  ".": {
9
14
  "types": "./dist/index.d.ts",
@@ -14,7 +19,8 @@
14
19
  "main": "./dist/index.mjs",
15
20
  "types": "./dist/index.d.ts",
16
21
  "files": [
17
- "dist"
22
+ "dist",
23
+ "LICENSE"
18
24
  ],
19
25
  "scripts": {
20
26
  "build": "tsup",
@@ -23,8 +29,8 @@
23
29
  "test": "vitest --run"
24
30
  },
25
31
  "dependencies": {
26
- "@holo-js/broadcast": "^0.3.27",
27
- "@holo-js/flux": "^0.3.27"
32
+ "@holo-js/broadcast": "^0.4.0",
33
+ "@holo-js/flux": "^0.4.0"
28
34
  },
29
35
  "peerDependencies": {
30
36
  "react": "^19.2.6"
@@ -33,15 +39,15 @@
33
39
  "@types/react": "^19.2.14",
34
40
  "@types/react-dom": "^19.2.3",
35
41
  "@types/react-test-renderer": "^19.1.0",
36
- "@types/node": "^22.10.2",
42
+ "@types/node": "^22.20.5",
37
43
  "react": "^19.2.6",
38
44
  "react-dom": "^19.2.6",
39
45
  "react-test-renderer": "^19.2.6",
40
- "tsup": "^8.3.5",
41
- "typescript": "^5.7.2",
42
- "vitest": "^4.1.5"
46
+ "tsup": "^9.0.0",
47
+ "typescript": "^6.0.3",
48
+ "vitest": "^5.0.5"
43
49
  },
44
50
  "engines": {
45
- "node": "^22.12.0 || ^24.0.0 || ^26.0.0"
51
+ "node": "^22.18.0 || ^24.0.0 || ^26.0.0"
46
52
  }
47
53
  }