@noya-app/noya-multiplayer-react 0.1.22 → 0.1.24
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 +15 -0
- package/dist/index.d.mts +65 -46
- package/dist/index.d.ts +65 -46
- package/dist/index.js +265 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/hooks.ts +69 -25
- package/src/index.ts +2 -1
- package/src/inspector/StateInspector.tsx +25 -5
- package/src/{embedded.ts → noyaApp.ts} +58 -7
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
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
9
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
10
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
8
|
+
[32mCJS[39m [1mdist/index.js [22m[32m46.99 KB[39m
|
|
9
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m77.08 KB[39m
|
|
10
|
+
[32mCJS[39m ⚡️ Build success in 69ms
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m41.72 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m77.28 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 69ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
"ComponentPropsWithoutRef" is imported from external module "react" but never used in "src/components/UserPointersOverlay.tsx", "src/inspector/StateInspector.tsx" and "src/hooks.ts".
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 2362ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.44 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.44 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @noya-app/state-manager
|
|
2
2
|
|
|
3
|
+
## 0.1.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 57bf0c9: Improve pixel ratio, toolbar, details
|
|
8
|
+
|
|
9
|
+
## 0.1.23
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3d308c6: Improve noya app hook
|
|
14
|
+
- f14970a: Add useNoyaAppState
|
|
15
|
+
- Updated dependencies [f14970a]
|
|
16
|
+
- @noya-app/state-manager@0.1.22
|
|
17
|
+
|
|
3
18
|
## 0.1.22
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { MultiplayerUser, EphemeralUserData,
|
|
2
|
+
import { MultiplayerUser, EphemeralUserData, ConnectionEvent, Task, MultiplayerStateManager, StateManager, Get, StateManagerOptions, MultiplayerStateManagerOptions, SyncAdapterOptions, TSchema } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, { SetStateAction
|
|
4
|
+
import React, { SetStateAction } from 'react';
|
|
5
|
+
import { Observable, PathKey, GetWithPath } from '@noya-app/observable';
|
|
5
6
|
|
|
6
7
|
declare function getAvatarInitials(name: string): string;
|
|
7
8
|
/**
|
|
@@ -45,6 +46,50 @@ declare const UserPointerIcon: React.NamedExoticComponent<{
|
|
|
45
46
|
color?: string | undefined;
|
|
46
47
|
}>;
|
|
47
48
|
|
|
49
|
+
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
50
|
+
type StateInspectorOptions = {
|
|
51
|
+
colorScheme?: "light" | "dark";
|
|
52
|
+
anchor?: StateInspectorAnchor;
|
|
53
|
+
};
|
|
54
|
+
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, ephemeralUserData, anchor, forceInit, ...props }: {
|
|
55
|
+
state: S;
|
|
56
|
+
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
57
|
+
connectedUsers?: MultiplayerUser[] | undefined;
|
|
58
|
+
tasks?: Task[] | undefined;
|
|
59
|
+
userId?: string | undefined;
|
|
60
|
+
unstyled?: boolean | undefined;
|
|
61
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
62
|
+
ephemeralUserData: EphemeralUserData<E>;
|
|
63
|
+
forceInit: () => void;
|
|
64
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
65
|
+
|
|
66
|
+
declare function useSyncStateManager<S extends object, M>(stateManager: StateManager<S, M>): S;
|
|
67
|
+
declare function useSyncStateManager<S extends object, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
68
|
+
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>];
|
|
69
|
+
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
70
|
+
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
71
|
+
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
|
+
throttle?: number;
|
|
73
|
+
}): {
|
|
74
|
+
data: Record<string, E | undefined>;
|
|
75
|
+
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
76
|
+
currentUserId: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
type UseMultiplayerStateOptions<S extends object, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
79
|
+
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
80
|
+
trackConnectionEvents?: boolean;
|
|
81
|
+
trackTasks?: boolean;
|
|
82
|
+
inspector?: boolean | StateInspectorOptions;
|
|
83
|
+
};
|
|
84
|
+
declare function useMultiplayerState<S extends object, M = void, E = void>(initialState: S | (() => S), options?: UseMultiplayerStateOptions<S, M, E>): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
85
|
+
tasks: Task[];
|
|
86
|
+
userId: string | undefined;
|
|
87
|
+
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
88
|
+
connectedUsers: MultiplayerUser[];
|
|
89
|
+
ephemeralUserData: EphemeralUserData<E>;
|
|
90
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
91
|
+
}];
|
|
92
|
+
|
|
48
93
|
type AppViewType = "editable" | "readOnly" | "preview";
|
|
49
94
|
type AppTheme = "light" | "dark";
|
|
50
95
|
type AppData<State> = {
|
|
@@ -52,18 +97,18 @@ type AppData<State> = {
|
|
|
52
97
|
theme: AppTheme;
|
|
53
98
|
viewType: AppViewType;
|
|
54
99
|
initialState: State;
|
|
55
|
-
inspector: boolean;
|
|
100
|
+
inspector: boolean | StateInspectorOptions;
|
|
56
101
|
};
|
|
57
102
|
declare function createDefaultAppData<State>(initialState: State): AppData<State>;
|
|
58
103
|
declare function getAppData<State>(): AppData<State> | undefined;
|
|
59
104
|
declare function getAppData<State>(initialState: State): AppData<State>;
|
|
60
|
-
type
|
|
105
|
+
type AppDataOptions = {
|
|
61
106
|
schema?: TSchema;
|
|
62
107
|
};
|
|
63
108
|
/**
|
|
64
109
|
* Get data from host app. Fall back to default data.
|
|
65
110
|
*/
|
|
66
|
-
declare function
|
|
111
|
+
declare function useAppData<S extends object>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
67
112
|
type IframeToHostMessage = {
|
|
68
113
|
type: "application.setMenuItems";
|
|
69
114
|
payload: {
|
|
@@ -84,46 +129,20 @@ type HostToIframeMessage = {
|
|
|
84
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
85
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
86
131
|
declare function isEmbeddedApp(): boolean;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
98
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
99
|
-
anchor?: Anchor | undefined;
|
|
100
|
-
forceInit: () => void;
|
|
101
|
-
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
102
|
-
|
|
103
|
-
declare function useSyncStateManager<S extends object, M>(stateManager: StateManager<S, M>): S;
|
|
104
|
-
declare function useSyncStateManager<S extends object, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
105
|
-
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>];
|
|
106
|
-
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
107
|
-
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
108
|
-
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>): {
|
|
109
|
-
data: Record<string, E | undefined>;
|
|
110
|
-
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
111
|
-
currentUserId: string | undefined;
|
|
112
|
-
};
|
|
113
|
-
declare function useMultiplayerState<S extends object, M = void, E = void>(initialState: S | (() => S), options?: MultiplayerStateManagerOptions<S, M> & {
|
|
114
|
-
sync?: (options: {
|
|
115
|
-
ms: MultiplayerStateManager<S, M>;
|
|
116
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
117
|
-
}) => void;
|
|
118
|
-
trackConnectionEvents?: boolean;
|
|
119
|
-
trackTasks?: boolean;
|
|
120
|
-
inspector?: boolean | Pick<ComponentProps<typeof StateInspector>, "colorScheme" | "anchor">;
|
|
121
|
-
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, MultiplayerStateManager<S, M>, {
|
|
122
|
-
tasks: Task[];
|
|
123
|
-
userId: string | undefined;
|
|
124
|
-
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
125
|
-
connectedUsers: MultiplayerUser[];
|
|
126
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
132
|
+
declare function useNoyaAppState<S extends object, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
133
|
+
localStorageKey?: string;
|
|
134
|
+
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
135
|
+
readonly theme: AppTheme;
|
|
136
|
+
readonly viewType: AppViewType;
|
|
137
|
+
readonly tasks: _noya_app_state_manager.Task[];
|
|
138
|
+
readonly userId: string | undefined;
|
|
139
|
+
readonly connectionEvents: _noya_app_state_manager.ConnectionEvent<S>[] | undefined;
|
|
140
|
+
readonly connectedUsers: MultiplayerUser[];
|
|
141
|
+
readonly ephemeralUserData: _noya_app_state_manager.EphemeralUserData<E>;
|
|
142
|
+
readonly multiplayerStateManager: _noya_app_state_manager.MultiplayerStateManager<S, M>;
|
|
127
143
|
}];
|
|
128
144
|
|
|
129
|
-
|
|
145
|
+
declare function useObservable<T>(observable: Observable<T>): T;
|
|
146
|
+
declare function useObservable<T, P extends PathKey[]>(observable: Observable<T>, path: P): GetWithPath<T, P>;
|
|
147
|
+
|
|
148
|
+
export { type AppData, type AppTheme, type AppViewType, type HostToIframeMessage, type IframeToHostMessage, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, UserNameTag, UserPointer, UserPointerContainer, type UserPointerData, UserPointerIcon, type UserPointerProps, UserPointersOverlay, type UserPointersOverlayProps, createDefaultAppData, getAppData, getAvatarInitials, getAvatarStyle, isEmbeddedApp, useAppData, useBroadcastConnectedUsers, useBroadcastMenuItems, useEphemeralUserData, useManagedHistory, useManagedState, useMultiplayerState, useNoyaAppState, useObservable, useSyncMultiplayerStateManager, useSyncStateManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { MultiplayerUser, EphemeralUserData,
|
|
2
|
+
import { MultiplayerUser, EphemeralUserData, ConnectionEvent, Task, MultiplayerStateManager, StateManager, Get, StateManagerOptions, MultiplayerStateManagerOptions, SyncAdapterOptions, TSchema } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, { SetStateAction
|
|
4
|
+
import React, { SetStateAction } from 'react';
|
|
5
|
+
import { Observable, PathKey, GetWithPath } from '@noya-app/observable';
|
|
5
6
|
|
|
6
7
|
declare function getAvatarInitials(name: string): string;
|
|
7
8
|
/**
|
|
@@ -45,6 +46,50 @@ declare const UserPointerIcon: React.NamedExoticComponent<{
|
|
|
45
46
|
color?: string | undefined;
|
|
46
47
|
}>;
|
|
47
48
|
|
|
49
|
+
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
50
|
+
type StateInspectorOptions = {
|
|
51
|
+
colorScheme?: "light" | "dark";
|
|
52
|
+
anchor?: StateInspectorAnchor;
|
|
53
|
+
};
|
|
54
|
+
declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, ephemeralUserData, anchor, forceInit, ...props }: {
|
|
55
|
+
state: S;
|
|
56
|
+
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
57
|
+
connectedUsers?: MultiplayerUser[] | undefined;
|
|
58
|
+
tasks?: Task[] | undefined;
|
|
59
|
+
userId?: string | undefined;
|
|
60
|
+
unstyled?: boolean | undefined;
|
|
61
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
62
|
+
ephemeralUserData: EphemeralUserData<E>;
|
|
63
|
+
forceInit: () => void;
|
|
64
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
65
|
+
|
|
66
|
+
declare function useSyncStateManager<S extends object, M>(stateManager: StateManager<S, M>): S;
|
|
67
|
+
declare function useSyncStateManager<S extends object, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
68
|
+
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>];
|
|
69
|
+
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
70
|
+
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
71
|
+
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
|
+
throttle?: number;
|
|
73
|
+
}): {
|
|
74
|
+
data: Record<string, E | undefined>;
|
|
75
|
+
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
76
|
+
currentUserId: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
type UseMultiplayerStateOptions<S extends object, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
79
|
+
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
80
|
+
trackConnectionEvents?: boolean;
|
|
81
|
+
trackTasks?: boolean;
|
|
82
|
+
inspector?: boolean | StateInspectorOptions;
|
|
83
|
+
};
|
|
84
|
+
declare function useMultiplayerState<S extends object, M = void, E = void>(initialState: S | (() => S), options?: UseMultiplayerStateOptions<S, M, E>): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
85
|
+
tasks: Task[];
|
|
86
|
+
userId: string | undefined;
|
|
87
|
+
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
88
|
+
connectedUsers: MultiplayerUser[];
|
|
89
|
+
ephemeralUserData: EphemeralUserData<E>;
|
|
90
|
+
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
91
|
+
}];
|
|
92
|
+
|
|
48
93
|
type AppViewType = "editable" | "readOnly" | "preview";
|
|
49
94
|
type AppTheme = "light" | "dark";
|
|
50
95
|
type AppData<State> = {
|
|
@@ -52,18 +97,18 @@ type AppData<State> = {
|
|
|
52
97
|
theme: AppTheme;
|
|
53
98
|
viewType: AppViewType;
|
|
54
99
|
initialState: State;
|
|
55
|
-
inspector: boolean;
|
|
100
|
+
inspector: boolean | StateInspectorOptions;
|
|
56
101
|
};
|
|
57
102
|
declare function createDefaultAppData<State>(initialState: State): AppData<State>;
|
|
58
103
|
declare function getAppData<State>(): AppData<State> | undefined;
|
|
59
104
|
declare function getAppData<State>(initialState: State): AppData<State>;
|
|
60
|
-
type
|
|
105
|
+
type AppDataOptions = {
|
|
61
106
|
schema?: TSchema;
|
|
62
107
|
};
|
|
63
108
|
/**
|
|
64
109
|
* Get data from host app. Fall back to default data.
|
|
65
110
|
*/
|
|
66
|
-
declare function
|
|
111
|
+
declare function useAppData<S extends object>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
67
112
|
type IframeToHostMessage = {
|
|
68
113
|
type: "application.setMenuItems";
|
|
69
114
|
payload: {
|
|
@@ -84,46 +129,20 @@ type HostToIframeMessage = {
|
|
|
84
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
85
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
86
131
|
declare function isEmbeddedApp(): boolean;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
98
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
99
|
-
anchor?: Anchor | undefined;
|
|
100
|
-
forceInit: () => void;
|
|
101
|
-
} & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
102
|
-
|
|
103
|
-
declare function useSyncStateManager<S extends object, M>(stateManager: StateManager<S, M>): S;
|
|
104
|
-
declare function useSyncStateManager<S extends object, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
105
|
-
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>];
|
|
106
|
-
declare function useManagedHistory<S extends object, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
107
|
-
declare function useSyncMultiplayerStateManager<S extends object, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
108
|
-
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>): {
|
|
109
|
-
data: Record<string, E | undefined>;
|
|
110
|
-
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
111
|
-
currentUserId: string | undefined;
|
|
112
|
-
};
|
|
113
|
-
declare function useMultiplayerState<S extends object, M = void, E = void>(initialState: S | (() => S), options?: MultiplayerStateManagerOptions<S, M> & {
|
|
114
|
-
sync?: (options: {
|
|
115
|
-
ms: MultiplayerStateManager<S, M>;
|
|
116
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
117
|
-
}) => void;
|
|
118
|
-
trackConnectionEvents?: boolean;
|
|
119
|
-
trackTasks?: boolean;
|
|
120
|
-
inspector?: boolean | Pick<ComponentProps<typeof StateInspector>, "colorScheme" | "anchor">;
|
|
121
|
-
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, MultiplayerStateManager<S, M>, {
|
|
122
|
-
tasks: Task[];
|
|
123
|
-
userId: string | undefined;
|
|
124
|
-
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
125
|
-
connectedUsers: MultiplayerUser[];
|
|
126
|
-
ephemeralUserData: EphemeralUserData<E>;
|
|
132
|
+
declare function useNoyaAppState<S extends object, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
133
|
+
localStorageKey?: string;
|
|
134
|
+
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
135
|
+
readonly theme: AppTheme;
|
|
136
|
+
readonly viewType: AppViewType;
|
|
137
|
+
readonly tasks: _noya_app_state_manager.Task[];
|
|
138
|
+
readonly userId: string | undefined;
|
|
139
|
+
readonly connectionEvents: _noya_app_state_manager.ConnectionEvent<S>[] | undefined;
|
|
140
|
+
readonly connectedUsers: MultiplayerUser[];
|
|
141
|
+
readonly ephemeralUserData: _noya_app_state_manager.EphemeralUserData<E>;
|
|
142
|
+
readonly multiplayerStateManager: _noya_app_state_manager.MultiplayerStateManager<S, M>;
|
|
127
143
|
}];
|
|
128
144
|
|
|
129
|
-
|
|
145
|
+
declare function useObservable<T>(observable: Observable<T>): T;
|
|
146
|
+
declare function useObservable<T, P extends PathKey[]>(observable: Observable<T>, path: P): GetWithPath<T, P>;
|
|
147
|
+
|
|
148
|
+
export { type AppData, type AppTheme, type AppViewType, type HostToIframeMessage, type IframeToHostMessage, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, UserNameTag, UserPointer, UserPointerContainer, type UserPointerData, UserPointerIcon, type UserPointerProps, UserPointersOverlay, type UserPointersOverlayProps, createDefaultAppData, getAppData, getAvatarInitials, getAvatarStyle, isEmbeddedApp, useAppData, useBroadcastConnectedUsers, useBroadcastMenuItems, useEphemeralUserData, useManagedHistory, useManagedState, useMultiplayerState, useNoyaAppState, useObservable, useSyncMultiplayerStateManager, useSyncStateManager };
|