@noya-app/noya-multiplayer-react 0.1.23 → 0.1.25
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 +10 -10
- package/CHANGELOG.md +17 -0
- package/dist/index.d.mts +18 -12
- package/dist/index.d.ts +18 -12
- package/dist/index.js +243 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +203 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/ErrorOverlay.tsx +89 -0
- package/src/hooks.ts +82 -16
- package/src/index.ts +1 -0
- package/src/inspector/StateInspector.tsx +2 -6
- package/src/inspector/useStateInspector.tsx +1 -1
- package/src/noyaApp.ts +3 -3
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
|
+
[32mCJS[39m [1mdist/index.js [22m[32m50.28 KB[39m
|
|
9
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m81.82 KB[39m
|
|
10
|
+
[32mCJS[39m ⚡️ Build success in 72ms
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m44.75 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m82.04 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 72ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
|
-
"ComponentPropsWithoutRef" is imported from external module "react" but never used in "src/
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.
|
|
15
|
+
"ComponentPropsWithoutRef" is imported from external module "react" but never used in "src/inspector/StateInspector.tsx", "src/hooks.ts" and "src/components/UserPointersOverlay.tsx".
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4324ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.30 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m7.30 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @noya-app/state-manager
|
|
2
2
|
|
|
3
|
+
## 0.1.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f3e588d: Improve json editing
|
|
8
|
+
- b104428: Package improvements, mainly around json
|
|
9
|
+
- Updated dependencies [f3e588d]
|
|
10
|
+
- Updated dependencies [04542f5]
|
|
11
|
+
- Updated dependencies [b104428]
|
|
12
|
+
- @noya-app/state-manager@0.1.23
|
|
13
|
+
|
|
14
|
+
## 0.1.24
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 57bf0c9: Improve pixel ratio, toolbar, details
|
|
19
|
+
|
|
3
20
|
## 0.1.23
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
|
2
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
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
|
/**
|
|
@@ -50,7 +51,7 @@ type StateInspectorOptions = {
|
|
|
50
51
|
colorScheme?: "light" | "dark";
|
|
51
52
|
anchor?: StateInspectorAnchor;
|
|
52
53
|
};
|
|
53
|
-
declare const StateInspector: React.MemoExoticComponent<(<S
|
|
54
|
+
declare const StateInspector: React.MemoExoticComponent<(<S, M, E>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, ephemeralUserData, anchor, forceInit, ...props }: {
|
|
54
55
|
state: S;
|
|
55
56
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
56
57
|
connectedUsers?: MultiplayerUser[] | undefined;
|
|
@@ -62,23 +63,25 @@ declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E
|
|
|
62
63
|
forceInit: () => void;
|
|
63
64
|
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
64
65
|
|
|
65
|
-
declare function useSyncStateManager<S
|
|
66
|
-
declare function useSyncStateManager<S
|
|
67
|
-
declare function useManagedState<S
|
|
68
|
-
declare function useManagedHistory<S
|
|
69
|
-
declare function useSyncMultiplayerStateManager<S
|
|
70
|
-
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E
|
|
66
|
+
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
67
|
+
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
68
|
+
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>];
|
|
69
|
+
declare function useManagedHistory<S, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
70
|
+
declare function useSyncMultiplayerStateManager<S, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
71
|
+
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
|
+
throttle?: number;
|
|
73
|
+
}): {
|
|
71
74
|
data: Record<string, E | undefined>;
|
|
72
75
|
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
73
76
|
currentUserId: string | undefined;
|
|
74
77
|
};
|
|
75
|
-
type UseMultiplayerStateOptions<S
|
|
78
|
+
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
76
79
|
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
77
80
|
trackConnectionEvents?: boolean;
|
|
78
81
|
trackTasks?: boolean;
|
|
79
82
|
inspector?: boolean | StateInspectorOptions;
|
|
80
83
|
};
|
|
81
|
-
declare function useMultiplayerState<S
|
|
84
|
+
declare function useMultiplayerState<S, 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, {
|
|
82
85
|
tasks: Task[];
|
|
83
86
|
userId: string | undefined;
|
|
84
87
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
@@ -105,7 +108,7 @@ type AppDataOptions = {
|
|
|
105
108
|
/**
|
|
106
109
|
* Get data from host app. Fall back to default data.
|
|
107
110
|
*/
|
|
108
|
-
declare function useAppData<S
|
|
111
|
+
declare function useAppData<S>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
109
112
|
type IframeToHostMessage = {
|
|
110
113
|
type: "application.setMenuItems";
|
|
111
114
|
payload: {
|
|
@@ -126,7 +129,7 @@ type HostToIframeMessage = {
|
|
|
126
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
127
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
128
131
|
declare function isEmbeddedApp(): boolean;
|
|
129
|
-
declare function useNoyaAppState<S
|
|
132
|
+
declare function useNoyaAppState<S, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
130
133
|
localStorageKey?: string;
|
|
131
134
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
132
135
|
readonly theme: AppTheme;
|
|
@@ -139,4 +142,7 @@ declare function useNoyaAppState<S extends object, M = void, E = void>(initialSt
|
|
|
139
142
|
readonly multiplayerStateManager: _noya_app_state_manager.MultiplayerStateManager<S, M>;
|
|
140
143
|
}];
|
|
141
144
|
|
|
142
|
-
|
|
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
|
@@ -2,6 +2,7 @@ import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
|
2
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
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
|
/**
|
|
@@ -50,7 +51,7 @@ type StateInspectorOptions = {
|
|
|
50
51
|
colorScheme?: "light" | "dark";
|
|
51
52
|
anchor?: StateInspectorAnchor;
|
|
52
53
|
};
|
|
53
|
-
declare const StateInspector: React.MemoExoticComponent<(<S
|
|
54
|
+
declare const StateInspector: React.MemoExoticComponent<(<S, M, E>({ state, connectionEvents, connectedUsers, tasks, userId, unstyled, colorScheme, multiplayerStateManager, ephemeralUserData, anchor, forceInit, ...props }: {
|
|
54
55
|
state: S;
|
|
55
56
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
56
57
|
connectedUsers?: MultiplayerUser[] | undefined;
|
|
@@ -62,23 +63,25 @@ declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E
|
|
|
62
63
|
forceInit: () => void;
|
|
63
64
|
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
64
65
|
|
|
65
|
-
declare function useSyncStateManager<S
|
|
66
|
-
declare function useSyncStateManager<S
|
|
67
|
-
declare function useManagedState<S
|
|
68
|
-
declare function useManagedHistory<S
|
|
69
|
-
declare function useSyncMultiplayerStateManager<S
|
|
70
|
-
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E
|
|
66
|
+
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
67
|
+
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): Get<S, P, unknown>;
|
|
68
|
+
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>];
|
|
69
|
+
declare function useManagedHistory<S, M = void>(stateManager: StateManager<S, M>): _noya_app_state_manager.HistorySnapshot<S, M>;
|
|
70
|
+
declare function useSyncMultiplayerStateManager<S, M = void>(multiplayerStateManager: MultiplayerStateManager<S, M>): S;
|
|
71
|
+
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
|
+
throttle?: number;
|
|
73
|
+
}): {
|
|
71
74
|
data: Record<string, E | undefined>;
|
|
72
75
|
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
73
76
|
currentUserId: string | undefined;
|
|
74
77
|
};
|
|
75
|
-
type UseMultiplayerStateOptions<S
|
|
78
|
+
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
76
79
|
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
77
80
|
trackConnectionEvents?: boolean;
|
|
78
81
|
trackTasks?: boolean;
|
|
79
82
|
inspector?: boolean | StateInspectorOptions;
|
|
80
83
|
};
|
|
81
|
-
declare function useMultiplayerState<S
|
|
84
|
+
declare function useMultiplayerState<S, 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, {
|
|
82
85
|
tasks: Task[];
|
|
83
86
|
userId: string | undefined;
|
|
84
87
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
@@ -105,7 +108,7 @@ type AppDataOptions = {
|
|
|
105
108
|
/**
|
|
106
109
|
* Get data from host app. Fall back to default data.
|
|
107
110
|
*/
|
|
108
|
-
declare function useAppData<S
|
|
111
|
+
declare function useAppData<S>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
109
112
|
type IframeToHostMessage = {
|
|
110
113
|
type: "application.setMenuItems";
|
|
111
114
|
payload: {
|
|
@@ -126,7 +129,7 @@ type HostToIframeMessage = {
|
|
|
126
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
127
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
128
131
|
declare function isEmbeddedApp(): boolean;
|
|
129
|
-
declare function useNoyaAppState<S
|
|
132
|
+
declare function useNoyaAppState<S, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
130
133
|
localStorageKey?: string;
|
|
131
134
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
132
135
|
readonly theme: AppTheme;
|
|
@@ -139,4 +142,7 @@ declare function useNoyaAppState<S extends object, M = void, E = void>(initialSt
|
|
|
139
142
|
readonly multiplayerStateManager: _noya_app_state_manager.MultiplayerStateManager<S, M>;
|
|
140
143
|
}];
|
|
141
144
|
|
|
142
|
-
|
|
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 };
|