@noya-app/noya-multiplayer-react 0.1.11 → 0.1.13
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +305 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +305 -172
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/globals.ts +2 -1
- package/src/hooks.ts +74 -18
- package/src/inspector/StateInspector.tsx +242 -172
- package/src/inspector/useLocalStorageState.tsx +2 -0
- package/src/inspector/useStateInspector.tsx +33 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
[34mCLI[39m Target: esnext
|
|
6
6
|
[34mCJS[39m Build start
|
|
7
7
|
[34mESM[39m Build start
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
8
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m25.93 KB[39m
|
|
9
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m47.90 KB[39m
|
|
10
|
+
[32mESM[39m ⚡️ Build success in 21ms
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m29.76 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m47.69 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 21ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
"ComponentPropsWithoutRef" is imported from external module "react" but never used in "src/inspector/StateInspector.tsx" and "src/hooks.ts".
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1253ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.65 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m2.65 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @noya-app/state-manager
|
|
2
2
|
|
|
3
|
+
## 0.1.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 149f2f9: Improve multiplayer
|
|
8
|
+
- Updated dependencies [149f2f9]
|
|
9
|
+
- @noya-app/state-manager@0.1.13
|
|
10
|
+
|
|
11
|
+
## 0.1.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b06dd3a: Add user auth to ws sync
|
|
16
|
+
- Updated dependencies [b06dd3a]
|
|
17
|
+
- @noya-app/state-manager@0.1.12
|
|
18
|
+
|
|
3
19
|
## 0.1.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { ConnectionEvent, StateManager, Get, StateManagerOptions,
|
|
2
|
+
import { ConnectionEvent, MultiplayerUser, Task, MultiplayerStateManager, StateManager, Get, StateManagerOptions, MultiplayerStateManagerOptions } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
4
|
import React, { SetStateAction, ComponentProps } from 'react';
|
|
5
5
|
|
|
6
|
-
type Anchor = "left" | "right";
|
|
7
|
-
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M>({ state, connectionEvents, unstyled, colorScheme,
|
|
6
|
+
type Anchor = "left" | "right" | "bottom left" | "bottom right";
|
|
7
|
+
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, anchor, ...props }: {
|
|
8
8
|
state: S;
|
|
9
9
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
10
|
+
connectedUsers?: MultiplayerUser[] | undefined;
|
|
11
|
+
tasks?: Task[] | undefined;
|
|
12
|
+
userId?: string | undefined;
|
|
10
13
|
unstyled?: boolean | undefined;
|
|
11
14
|
colorScheme?: "light" | "dark" | undefined;
|
|
12
|
-
|
|
15
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
13
16
|
anchor?: Anchor | undefined;
|
|
14
17
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
15
18
|
|
|
@@ -18,12 +21,17 @@ declare function useSyncStateManager<S extends object, M, P extends string>(stat
|
|
|
18
21
|
declare function useManagedState<S extends object, M = void>(createInitialState: () => S, options?: StateManagerOptions<S, M>): readonly [S, (...args: M extends {} ? [metadata: M, action: SetStateAction<S>] : [action: SetStateAction<S>]) => void, StateManager<S, M>];
|
|
19
22
|
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
20
23
|
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
21
|
-
declare function useMultiplayerState<S extends object, M = void>(initialState: S | (() => S), options
|
|
22
|
-
sync?: (
|
|
24
|
+
declare function useMultiplayerState<S extends object, M = void>(initialState: S | (() => S), options?: MultiplayerStateManagerOptions<S, M> & {
|
|
25
|
+
sync?: (options: {
|
|
26
|
+
ms: MultiplayerStateManager<S, M>;
|
|
27
|
+
}) => void;
|
|
23
28
|
trackConnectionEvents?: boolean;
|
|
29
|
+
trackTasks?: boolean;
|
|
24
30
|
inspector?: boolean | Pick<ComponentProps<typeof StateInspector>, "colorScheme" | "anchor">;
|
|
25
31
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, MultiplayerStateManager<S, M>, {
|
|
32
|
+
tasks: Task[];
|
|
26
33
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
34
|
+
connectedUsers: MultiplayerUser[];
|
|
27
35
|
}];
|
|
28
36
|
|
|
29
37
|
export { StateInspector, useManagedHistory, useManagedState, useMultiplayerState, useSyncMultiplayerStateManager, useSyncStateManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { ConnectionEvent, StateManager, Get, StateManagerOptions,
|
|
2
|
+
import { ConnectionEvent, MultiplayerUser, Task, MultiplayerStateManager, StateManager, Get, StateManagerOptions, MultiplayerStateManagerOptions } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
4
|
import React, { SetStateAction, ComponentProps } from 'react';
|
|
5
5
|
|
|
6
|
-
type Anchor = "left" | "right";
|
|
7
|
-
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M>({ state, connectionEvents, unstyled, colorScheme,
|
|
6
|
+
type Anchor = "left" | "right" | "bottom left" | "bottom right";
|
|
7
|
+
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, anchor, ...props }: {
|
|
8
8
|
state: S;
|
|
9
9
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
10
|
+
connectedUsers?: MultiplayerUser[] | undefined;
|
|
11
|
+
tasks?: Task[] | undefined;
|
|
12
|
+
userId?: string | undefined;
|
|
10
13
|
unstyled?: boolean | undefined;
|
|
11
14
|
colorScheme?: "light" | "dark" | undefined;
|
|
12
|
-
|
|
15
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
13
16
|
anchor?: Anchor | undefined;
|
|
14
17
|
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
15
18
|
|
|
@@ -18,12 +21,17 @@ declare function useSyncStateManager<S extends object, M, P extends string>(stat
|
|
|
18
21
|
declare function useManagedState<S extends object, M = void>(createInitialState: () => S, options?: StateManagerOptions<S, M>): readonly [S, (...args: M extends {} ? [metadata: M, action: SetStateAction<S>] : [action: SetStateAction<S>]) => void, StateManager<S, M>];
|
|
19
22
|
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
20
23
|
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
21
|
-
declare function useMultiplayerState<S extends object, M = void>(initialState: S | (() => S), options
|
|
22
|
-
sync?: (
|
|
24
|
+
declare function useMultiplayerState<S extends object, M = void>(initialState: S | (() => S), options?: MultiplayerStateManagerOptions<S, M> & {
|
|
25
|
+
sync?: (options: {
|
|
26
|
+
ms: MultiplayerStateManager<S, M>;
|
|
27
|
+
}) => void;
|
|
23
28
|
trackConnectionEvents?: boolean;
|
|
29
|
+
trackTasks?: boolean;
|
|
24
30
|
inspector?: boolean | Pick<ComponentProps<typeof StateInspector>, "colorScheme" | "anchor">;
|
|
25
31
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, MultiplayerStateManager<S, M>, {
|
|
32
|
+
tasks: Task[];
|
|
26
33
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
34
|
+
connectedUsers: MultiplayerUser[];
|
|
27
35
|
}];
|
|
28
36
|
|
|
29
37
|
export { StateInspector, useManagedHistory, useManagedState, useMultiplayerState, useSyncMultiplayerStateManager, useSyncStateManager };
|