@noya-app/noya-multiplayer-react 0.1.43 → 0.1.44
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 +11 -11
- package/CHANGELOG.md +11 -0
- package/dist/index.bundle.js +40 -7
- package/dist/index.d.mts +70 -60
- package/dist/index.d.ts +70 -60
- package/dist/index.js +306 -271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +313 -278
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
- package/src/NoyaStateContext.tsx +163 -13
- package/src/components/UserPointersOverlay.tsx +56 -129
- package/src/hooks.ts +60 -92
- package/src/index.ts +0 -1
- package/src/inspector/StateInspector.tsx +59 -13
- package/src/inspector/useStateInspector.tsx +18 -15
- package/src/noyaApp.ts +20 -12
- package/src/useObservable.ts +54 -7
- package/src/avatarStyle.ts +0 -82
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectedUsersManager, EphemeralUserDataManager, RPCManager, StandardRPCRequestPayload, StandardRPCResponsePayload, ConnectionEvent, Task, MultiplayerStateManager, AssetManager, SecretManager as SecretManager$1, StateManager, StateManagerOptions, MultiplayerStateManagerOptions, SyncAdapterOptions, AIManager, WorkflowManager, TSchema, Static } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, {
|
|
5
|
-
import { GetAtPath, ObservableOptions, PathKey
|
|
6
|
-
|
|
7
|
-
declare function getAvatarInitials(name: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Create a background color and initials from a name
|
|
10
|
-
*
|
|
11
|
-
* Adapted from https://mui.com/material-ui/react-avatar/
|
|
12
|
-
*/
|
|
13
|
-
declare function getAvatarStyle(name: string): {
|
|
14
|
-
color: string;
|
|
15
|
-
backgroundColor: string;
|
|
16
|
-
};
|
|
4
|
+
import React, { SetStateAction } from 'react';
|
|
5
|
+
import { Observable, GetAtPath, ObservableOptions, PathKey } from '@noya-app/observable';
|
|
17
6
|
|
|
18
7
|
type Point = {
|
|
19
8
|
x: number;
|
|
@@ -22,76 +11,75 @@ type Point = {
|
|
|
22
11
|
type UserPointerData = {
|
|
23
12
|
pointer?: Point;
|
|
24
13
|
};
|
|
25
|
-
type
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
declare const UserPointer_: <E extends UserPointerData>({ user, ephemeralUserData, hideAfter, }: UserPointerProps<E>) => React.JSX.Element | null;
|
|
31
|
-
declare const UserPointer: typeof UserPointer_;
|
|
32
|
-
declare const UserPointerContainer: React.NamedExoticComponent<{
|
|
14
|
+
type RenderUserPointerProps = {
|
|
15
|
+
userId: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
visible: boolean;
|
|
33
18
|
point: Point;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
background: string;
|
|
39
|
-
children: React.ReactNode;
|
|
40
|
-
}>;
|
|
19
|
+
};
|
|
20
|
+
type RenderUserPointer = {
|
|
21
|
+
renderUserPointer: (options: RenderUserPointerProps) => React.ReactNode;
|
|
22
|
+
};
|
|
41
23
|
type UserPointersOverlayProps<E extends UserPointerData> = {
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
25
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
26
|
+
} & RenderUserPointer;
|
|
27
|
+
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement | null;
|
|
28
|
+
|
|
29
|
+
type Secret = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
44
32
|
};
|
|
45
|
-
declare
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
declare class SecretManager {
|
|
34
|
+
rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>;
|
|
35
|
+
constructor(rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>);
|
|
36
|
+
secrets$: Observable<Secret[]>;
|
|
37
|
+
isInitialized$: Observable<boolean>;
|
|
38
|
+
createSecret(name: string, value: string): Promise<StandardRPCResponsePayload>;
|
|
39
|
+
deleteSecret(name: string): Promise<StandardRPCResponsePayload>;
|
|
40
|
+
}
|
|
49
41
|
|
|
50
42
|
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
51
43
|
type StateInspectorOptions = {
|
|
52
44
|
colorScheme?: "light" | "dark";
|
|
53
45
|
anchor?: StateInspectorAnchor;
|
|
54
46
|
};
|
|
55
|
-
declare const StateInspector:
|
|
47
|
+
declare const StateInspector: <S, M, E extends object>(props: {
|
|
56
48
|
state: S;
|
|
57
49
|
connectionEvents?: ConnectionEvent<S>[];
|
|
58
|
-
connectedUsers?: MultiplayerUser[];
|
|
59
50
|
tasks?: Task[];
|
|
60
|
-
userId?: string;
|
|
61
51
|
unstyled?: boolean;
|
|
62
52
|
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
63
53
|
assetManager: AssetManager;
|
|
64
|
-
|
|
54
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
55
|
+
secretManager: SecretManager$1;
|
|
56
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
65
57
|
forceInit: () => void;
|
|
66
|
-
} & StateInspectorOptions &
|
|
58
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement | null;
|
|
67
59
|
|
|
68
60
|
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
69
61
|
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): GetAtPath<S, P>;
|
|
70
62
|
declare function useManagedState<S, 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>];
|
|
71
63
|
declare function useManagedHistory<S, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
72
64
|
declare function useSyncMultiplayerStateManager<S, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}): {
|
|
76
|
-
data: Record<string, E | undefined>;
|
|
77
|
-
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
78
|
-
currentUserId: string | undefined;
|
|
79
|
-
};
|
|
80
|
-
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
81
|
-
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData" | "assetManager">) => void;
|
|
65
|
+
type UseMultiplayerStateOptions<S, M = void, E extends object = object> = MultiplayerStateManagerOptions<S, M> & {
|
|
66
|
+
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserDataManager" | "assetManager">) => void;
|
|
82
67
|
trackConnectionEvents?: boolean;
|
|
83
68
|
trackTasks?: boolean;
|
|
84
69
|
inspector?: boolean | StateInspectorOptions;
|
|
85
70
|
};
|
|
86
|
-
declare function useMultiplayerState<S, M = void, E =
|
|
71
|
+
declare function useMultiplayerState<S, M = void, E extends object = object>(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, {
|
|
87
72
|
tasks: Task[];
|
|
88
|
-
userId: string | undefined;
|
|
89
73
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
75
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
92
76
|
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
93
77
|
assets: _noya_app_state_manager.Asset[];
|
|
94
78
|
assetManager: AssetManager;
|
|
79
|
+
aiManager: AIManager;
|
|
80
|
+
rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>;
|
|
81
|
+
workflowManager: WorkflowManager;
|
|
82
|
+
secretManager: SecretManager;
|
|
95
83
|
createAsset: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_state_manager.Asset>;
|
|
96
84
|
deleteAsset: (id: string) => Promise<void>;
|
|
97
85
|
}];
|
|
@@ -134,13 +122,13 @@ type HostToIframeMessage = {
|
|
|
134
122
|
value: string;
|
|
135
123
|
};
|
|
136
124
|
};
|
|
137
|
-
declare function useBroadcastConnectedUsers(
|
|
125
|
+
declare function useBroadcastConnectedUsers(connectedUsersManager: ConnectedUsersManager): void;
|
|
138
126
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
139
127
|
declare function isEmbeddedApp(): boolean;
|
|
140
|
-
type UseNoyaStateOptions<S, M = void, E =
|
|
128
|
+
type UseNoyaStateOptions<S, M = void, E extends object = object> = UseMultiplayerStateOptions<S, M, E> & {
|
|
141
129
|
offlineStorageKey?: string;
|
|
142
130
|
};
|
|
143
|
-
type UseNoyaStateResult<S, M = void, E =
|
|
131
|
+
type UseNoyaStateResult<S, M = void, E extends object = object> = [
|
|
144
132
|
ReturnType<typeof useMultiplayerState<S, M, E>>[0],
|
|
145
133
|
ReturnType<typeof useMultiplayerState<S, M, E>>[1],
|
|
146
134
|
ReturnType<typeof useMultiplayerState<S, M, E>>[2] & {
|
|
@@ -157,16 +145,17 @@ type UseNoyaStateResult<S, M = void, E = void> = [
|
|
|
157
145
|
* 2. Pass an initial state and a schema: `useNoyaState(initialState, { schema })`
|
|
158
146
|
* 3. Pass only a schema, and a conforming initial state is created automatically: `useNoyaState({ schema })`
|
|
159
147
|
*/
|
|
160
|
-
declare function useNoyaState<S, M = void, E =
|
|
148
|
+
declare function useNoyaState<S, M = void, E extends object = object, O extends UseNoyaStateOptions<S, M, E> = UseNoyaStateOptions<S, M, E>>(...args: [
|
|
161
149
|
initialState: O["schema"] extends TSchema ? Static<O["schema"]> | (() => Static<O["schema"]>) : S | (() => S),
|
|
162
150
|
options?: O
|
|
163
151
|
] | [options: O & {
|
|
164
152
|
schema: TSchema;
|
|
165
153
|
}]): UseNoyaStateResult<O["schema"] extends TSchema ? Static<O["schema"]> : S, M, E>;
|
|
166
154
|
|
|
167
|
-
interface NoyaStateProviderProps<S, M, E> extends Omit<UseNoyaStateOptions<S, M, E>, "schema" | "mergeHistoryEntries"> {
|
|
155
|
+
interface NoyaStateProviderProps<S, M, E extends object> extends Omit<UseNoyaStateOptions<S, M, E>, "schema" | "mergeHistoryEntries"> {
|
|
168
156
|
children: React.ReactNode;
|
|
169
157
|
initialState?: S;
|
|
158
|
+
fallback?: React.ReactNode;
|
|
170
159
|
}
|
|
171
160
|
declare function useAssets(): _noya_app_state_manager.Asset[];
|
|
172
161
|
declare function useAsset(id: string | undefined): _noya_app_state_manager.Asset | undefined;
|
|
@@ -174,13 +163,29 @@ declare function useAssetManager(): {
|
|
|
174
163
|
create: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_state_manager.Asset>;
|
|
175
164
|
delete: (id: string) => Promise<void>;
|
|
176
165
|
};
|
|
177
|
-
declare function
|
|
166
|
+
declare function useAIManager(): AIManager;
|
|
167
|
+
declare function useSecretManager(): SecretManager$1;
|
|
168
|
+
declare function useSecrets(): _noya_app_state_manager.Secret[];
|
|
169
|
+
declare function useSecret(name: string): _noya_app_state_manager.Secret | undefined;
|
|
170
|
+
declare function useIsInitialized(): boolean;
|
|
171
|
+
declare function useWorkflowManager(): WorkflowManager;
|
|
172
|
+
declare const ConnectedUsersContext: React.Context<ConnectedUsersManager | undefined>;
|
|
173
|
+
declare function useConnectedUsersManager(): ConnectedUsersManager | undefined;
|
|
174
|
+
declare const AnyEphemeralUserDataManagerContext: React.Context<EphemeralUserDataManager<object> | undefined>;
|
|
175
|
+
declare function useAnyEphemeralUserData(): EphemeralUserDataManager<object> | undefined;
|
|
176
|
+
declare function useCurrentUserId(): string | undefined;
|
|
177
|
+
declare const FallbackUntilInitialized: ({ children, fallback, }: {
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
fallback?: React.ReactNode;
|
|
180
|
+
}) => React.ReactNode;
|
|
181
|
+
declare function createNoyaContext<Schema extends TSchema, M = void, E extends object = object>({ schema, mergeHistoryEntries, }: {
|
|
178
182
|
schema: Schema;
|
|
179
183
|
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M>["mergeHistoryEntries"];
|
|
180
184
|
}): {
|
|
181
185
|
Context: React.Context<{
|
|
182
186
|
ms: MultiplayerStateManager<Static<Schema>, M>;
|
|
183
187
|
assetManager: AssetManager;
|
|
188
|
+
secretManager: SecretManager$1;
|
|
184
189
|
} | undefined>;
|
|
185
190
|
Provider: ({ children, initialState, ...options }: NoyaStateProviderProps<Static<Schema>, M, E>) => React.JSX.Element;
|
|
186
191
|
useValue: {
|
|
@@ -198,9 +203,14 @@ declare function createNoyaContext<Schema extends TSchema, M = void, E = void>({
|
|
|
198
203
|
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, M extends {} ? (metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>) => void : (value: SetStateAction<GetAtPath<Static<Schema>, P>>) => void];
|
|
199
204
|
};
|
|
200
205
|
useStateManager: () => MultiplayerStateManager<Static<Schema>, M>;
|
|
206
|
+
useEphemeralUserDataManager: () => EphemeralUserDataManager<E>;
|
|
201
207
|
};
|
|
202
208
|
|
|
203
209
|
declare function useObservable<T>(observable: Observable<T>): T;
|
|
210
|
+
declare function useObservable<T, A>(observable: Observable<T>, selector: (value: T) => A, options?: Pick<ObservableOptions, "isEqual">): A;
|
|
204
211
|
declare function useObservable<T, P extends PathKey[] | string>(observable: Observable<T>, path: P): GetAtPath<T, P>;
|
|
212
|
+
declare function useObservable<T>(observable: Observable<T> | undefined): T | undefined;
|
|
213
|
+
declare function useObservable<T, A>(observable: Observable<T> | undefined, selector: (value: T) => A, options?: Pick<ObservableOptions, "isEqual">): A | undefined;
|
|
214
|
+
declare function useObservable<T, P extends PathKey[] | string>(observable: Observable<T> | undefined, path: P): GetAtPath<T, P> | undefined;
|
|
205
215
|
|
|
206
|
-
export { type AppData, type AppTheme, type AppViewType, type GetAppDataOptions, type HostToIframeMessage, type IframeToHostMessage, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult,
|
|
216
|
+
export { AnyEphemeralUserDataManagerContext, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, FallbackUntilInitialized, type GetAppDataOptions, type HostToIframeMessage, type IframeToHostMessage, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, createDefaultAppData, createNoyaContext, enforceSchema, getAppData, isEmbeddedApp, parseAppDataParameter, useAIManager, useAnyEphemeralUserData, useAsset, useAssetManager, useAssets, useBroadcastConnectedUsers, useBroadcastMenuItems, useConnectedUsersManager, useCurrentUserId, useIsInitialized, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useSecret, useSecretManager, useSecrets, useSyncMultiplayerStateManager, useSyncStateManager, useWorkflowManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { ConnectedUsersManager, EphemeralUserDataManager, RPCManager, StandardRPCRequestPayload, StandardRPCResponsePayload, ConnectionEvent, Task, MultiplayerStateManager, AssetManager, SecretManager as SecretManager$1, StateManager, StateManagerOptions, MultiplayerStateManagerOptions, SyncAdapterOptions, AIManager, WorkflowManager, TSchema, Static } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, {
|
|
5
|
-
import { GetAtPath, ObservableOptions, PathKey
|
|
6
|
-
|
|
7
|
-
declare function getAvatarInitials(name: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Create a background color and initials from a name
|
|
10
|
-
*
|
|
11
|
-
* Adapted from https://mui.com/material-ui/react-avatar/
|
|
12
|
-
*/
|
|
13
|
-
declare function getAvatarStyle(name: string): {
|
|
14
|
-
color: string;
|
|
15
|
-
backgroundColor: string;
|
|
16
|
-
};
|
|
4
|
+
import React, { SetStateAction } from 'react';
|
|
5
|
+
import { Observable, GetAtPath, ObservableOptions, PathKey } from '@noya-app/observable';
|
|
17
6
|
|
|
18
7
|
type Point = {
|
|
19
8
|
x: number;
|
|
@@ -22,76 +11,75 @@ type Point = {
|
|
|
22
11
|
type UserPointerData = {
|
|
23
12
|
pointer?: Point;
|
|
24
13
|
};
|
|
25
|
-
type
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
declare const UserPointer_: <E extends UserPointerData>({ user, ephemeralUserData, hideAfter, }: UserPointerProps<E>) => React.JSX.Element | null;
|
|
31
|
-
declare const UserPointer: typeof UserPointer_;
|
|
32
|
-
declare const UserPointerContainer: React.NamedExoticComponent<{
|
|
14
|
+
type RenderUserPointerProps = {
|
|
15
|
+
userId: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
visible: boolean;
|
|
33
18
|
point: Point;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
background: string;
|
|
39
|
-
children: React.ReactNode;
|
|
40
|
-
}>;
|
|
19
|
+
};
|
|
20
|
+
type RenderUserPointer = {
|
|
21
|
+
renderUserPointer: (options: RenderUserPointerProps) => React.ReactNode;
|
|
22
|
+
};
|
|
41
23
|
type UserPointersOverlayProps<E extends UserPointerData> = {
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
25
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
26
|
+
} & RenderUserPointer;
|
|
27
|
+
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement | null;
|
|
28
|
+
|
|
29
|
+
type Secret = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
44
32
|
};
|
|
45
|
-
declare
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
declare class SecretManager {
|
|
34
|
+
rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>;
|
|
35
|
+
constructor(rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>);
|
|
36
|
+
secrets$: Observable<Secret[]>;
|
|
37
|
+
isInitialized$: Observable<boolean>;
|
|
38
|
+
createSecret(name: string, value: string): Promise<StandardRPCResponsePayload>;
|
|
39
|
+
deleteSecret(name: string): Promise<StandardRPCResponsePayload>;
|
|
40
|
+
}
|
|
49
41
|
|
|
50
42
|
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
51
43
|
type StateInspectorOptions = {
|
|
52
44
|
colorScheme?: "light" | "dark";
|
|
53
45
|
anchor?: StateInspectorAnchor;
|
|
54
46
|
};
|
|
55
|
-
declare const StateInspector:
|
|
47
|
+
declare const StateInspector: <S, M, E extends object>(props: {
|
|
56
48
|
state: S;
|
|
57
49
|
connectionEvents?: ConnectionEvent<S>[];
|
|
58
|
-
connectedUsers?: MultiplayerUser[];
|
|
59
50
|
tasks?: Task[];
|
|
60
|
-
userId?: string;
|
|
61
51
|
unstyled?: boolean;
|
|
62
52
|
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
63
53
|
assetManager: AssetManager;
|
|
64
|
-
|
|
54
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
55
|
+
secretManager: SecretManager$1;
|
|
56
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
65
57
|
forceInit: () => void;
|
|
66
|
-
} & StateInspectorOptions &
|
|
58
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement | null;
|
|
67
59
|
|
|
68
60
|
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
69
61
|
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): GetAtPath<S, P>;
|
|
70
62
|
declare function useManagedState<S, 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>];
|
|
71
63
|
declare function useManagedHistory<S, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
72
64
|
declare function useSyncMultiplayerStateManager<S, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}): {
|
|
76
|
-
data: Record<string, E | undefined>;
|
|
77
|
-
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
78
|
-
currentUserId: string | undefined;
|
|
79
|
-
};
|
|
80
|
-
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
81
|
-
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData" | "assetManager">) => void;
|
|
65
|
+
type UseMultiplayerStateOptions<S, M = void, E extends object = object> = MultiplayerStateManagerOptions<S, M> & {
|
|
66
|
+
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserDataManager" | "assetManager">) => void;
|
|
82
67
|
trackConnectionEvents?: boolean;
|
|
83
68
|
trackTasks?: boolean;
|
|
84
69
|
inspector?: boolean | StateInspectorOptions;
|
|
85
70
|
};
|
|
86
|
-
declare function useMultiplayerState<S, M = void, E =
|
|
71
|
+
declare function useMultiplayerState<S, M = void, E extends object = object>(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, {
|
|
87
72
|
tasks: Task[];
|
|
88
|
-
userId: string | undefined;
|
|
89
73
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
connectedUsersManager: ConnectedUsersManager;
|
|
75
|
+
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
92
76
|
multiplayerStateManager: MultiplayerStateManager<S, M>;
|
|
93
77
|
assets: _noya_app_state_manager.Asset[];
|
|
94
78
|
assetManager: AssetManager;
|
|
79
|
+
aiManager: AIManager;
|
|
80
|
+
rpcManager: RPCManager<StandardRPCRequestPayload, StandardRPCResponsePayload>;
|
|
81
|
+
workflowManager: WorkflowManager;
|
|
82
|
+
secretManager: SecretManager;
|
|
95
83
|
createAsset: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_state_manager.Asset>;
|
|
96
84
|
deleteAsset: (id: string) => Promise<void>;
|
|
97
85
|
}];
|
|
@@ -134,13 +122,13 @@ type HostToIframeMessage = {
|
|
|
134
122
|
value: string;
|
|
135
123
|
};
|
|
136
124
|
};
|
|
137
|
-
declare function useBroadcastConnectedUsers(
|
|
125
|
+
declare function useBroadcastConnectedUsers(connectedUsersManager: ConnectedUsersManager): void;
|
|
138
126
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
139
127
|
declare function isEmbeddedApp(): boolean;
|
|
140
|
-
type UseNoyaStateOptions<S, M = void, E =
|
|
128
|
+
type UseNoyaStateOptions<S, M = void, E extends object = object> = UseMultiplayerStateOptions<S, M, E> & {
|
|
141
129
|
offlineStorageKey?: string;
|
|
142
130
|
};
|
|
143
|
-
type UseNoyaStateResult<S, M = void, E =
|
|
131
|
+
type UseNoyaStateResult<S, M = void, E extends object = object> = [
|
|
144
132
|
ReturnType<typeof useMultiplayerState<S, M, E>>[0],
|
|
145
133
|
ReturnType<typeof useMultiplayerState<S, M, E>>[1],
|
|
146
134
|
ReturnType<typeof useMultiplayerState<S, M, E>>[2] & {
|
|
@@ -157,16 +145,17 @@ type UseNoyaStateResult<S, M = void, E = void> = [
|
|
|
157
145
|
* 2. Pass an initial state and a schema: `useNoyaState(initialState, { schema })`
|
|
158
146
|
* 3. Pass only a schema, and a conforming initial state is created automatically: `useNoyaState({ schema })`
|
|
159
147
|
*/
|
|
160
|
-
declare function useNoyaState<S, M = void, E =
|
|
148
|
+
declare function useNoyaState<S, M = void, E extends object = object, O extends UseNoyaStateOptions<S, M, E> = UseNoyaStateOptions<S, M, E>>(...args: [
|
|
161
149
|
initialState: O["schema"] extends TSchema ? Static<O["schema"]> | (() => Static<O["schema"]>) : S | (() => S),
|
|
162
150
|
options?: O
|
|
163
151
|
] | [options: O & {
|
|
164
152
|
schema: TSchema;
|
|
165
153
|
}]): UseNoyaStateResult<O["schema"] extends TSchema ? Static<O["schema"]> : S, M, E>;
|
|
166
154
|
|
|
167
|
-
interface NoyaStateProviderProps<S, M, E> extends Omit<UseNoyaStateOptions<S, M, E>, "schema" | "mergeHistoryEntries"> {
|
|
155
|
+
interface NoyaStateProviderProps<S, M, E extends object> extends Omit<UseNoyaStateOptions<S, M, E>, "schema" | "mergeHistoryEntries"> {
|
|
168
156
|
children: React.ReactNode;
|
|
169
157
|
initialState?: S;
|
|
158
|
+
fallback?: React.ReactNode;
|
|
170
159
|
}
|
|
171
160
|
declare function useAssets(): _noya_app_state_manager.Asset[];
|
|
172
161
|
declare function useAsset(id: string | undefined): _noya_app_state_manager.Asset | undefined;
|
|
@@ -174,13 +163,29 @@ declare function useAssetManager(): {
|
|
|
174
163
|
create: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_state_manager.Asset>;
|
|
175
164
|
delete: (id: string) => Promise<void>;
|
|
176
165
|
};
|
|
177
|
-
declare function
|
|
166
|
+
declare function useAIManager(): AIManager;
|
|
167
|
+
declare function useSecretManager(): SecretManager$1;
|
|
168
|
+
declare function useSecrets(): _noya_app_state_manager.Secret[];
|
|
169
|
+
declare function useSecret(name: string): _noya_app_state_manager.Secret | undefined;
|
|
170
|
+
declare function useIsInitialized(): boolean;
|
|
171
|
+
declare function useWorkflowManager(): WorkflowManager;
|
|
172
|
+
declare const ConnectedUsersContext: React.Context<ConnectedUsersManager | undefined>;
|
|
173
|
+
declare function useConnectedUsersManager(): ConnectedUsersManager | undefined;
|
|
174
|
+
declare const AnyEphemeralUserDataManagerContext: React.Context<EphemeralUserDataManager<object> | undefined>;
|
|
175
|
+
declare function useAnyEphemeralUserData(): EphemeralUserDataManager<object> | undefined;
|
|
176
|
+
declare function useCurrentUserId(): string | undefined;
|
|
177
|
+
declare const FallbackUntilInitialized: ({ children, fallback, }: {
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
fallback?: React.ReactNode;
|
|
180
|
+
}) => React.ReactNode;
|
|
181
|
+
declare function createNoyaContext<Schema extends TSchema, M = void, E extends object = object>({ schema, mergeHistoryEntries, }: {
|
|
178
182
|
schema: Schema;
|
|
179
183
|
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M>["mergeHistoryEntries"];
|
|
180
184
|
}): {
|
|
181
185
|
Context: React.Context<{
|
|
182
186
|
ms: MultiplayerStateManager<Static<Schema>, M>;
|
|
183
187
|
assetManager: AssetManager;
|
|
188
|
+
secretManager: SecretManager$1;
|
|
184
189
|
} | undefined>;
|
|
185
190
|
Provider: ({ children, initialState, ...options }: NoyaStateProviderProps<Static<Schema>, M, E>) => React.JSX.Element;
|
|
186
191
|
useValue: {
|
|
@@ -198,9 +203,14 @@ declare function createNoyaContext<Schema extends TSchema, M = void, E = void>({
|
|
|
198
203
|
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, M extends {} ? (metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>) => void : (value: SetStateAction<GetAtPath<Static<Schema>, P>>) => void];
|
|
199
204
|
};
|
|
200
205
|
useStateManager: () => MultiplayerStateManager<Static<Schema>, M>;
|
|
206
|
+
useEphemeralUserDataManager: () => EphemeralUserDataManager<E>;
|
|
201
207
|
};
|
|
202
208
|
|
|
203
209
|
declare function useObservable<T>(observable: Observable<T>): T;
|
|
210
|
+
declare function useObservable<T, A>(observable: Observable<T>, selector: (value: T) => A, options?: Pick<ObservableOptions, "isEqual">): A;
|
|
204
211
|
declare function useObservable<T, P extends PathKey[] | string>(observable: Observable<T>, path: P): GetAtPath<T, P>;
|
|
212
|
+
declare function useObservable<T>(observable: Observable<T> | undefined): T | undefined;
|
|
213
|
+
declare function useObservable<T, A>(observable: Observable<T> | undefined, selector: (value: T) => A, options?: Pick<ObservableOptions, "isEqual">): A | undefined;
|
|
214
|
+
declare function useObservable<T, P extends PathKey[] | string>(observable: Observable<T> | undefined, path: P): GetAtPath<T, P> | undefined;
|
|
205
215
|
|
|
206
|
-
export { type AppData, type AppTheme, type AppViewType, type GetAppDataOptions, type HostToIframeMessage, type IframeToHostMessage, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult,
|
|
216
|
+
export { AnyEphemeralUserDataManagerContext, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, FallbackUntilInitialized, type GetAppDataOptions, type HostToIframeMessage, type IframeToHostMessage, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, createDefaultAppData, createNoyaContext, enforceSchema, getAppData, isEmbeddedApp, parseAppDataParameter, useAIManager, useAnyEphemeralUserData, useAsset, useAssetManager, useAssets, useBroadcastConnectedUsers, useBroadcastMenuItems, useConnectedUsersManager, useCurrentUserId, useIsInitialized, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useSecret, useSecretManager, useSecrets, useSyncMultiplayerStateManager, useSyncStateManager, useWorkflowManager };
|