@noya-app/noya-multiplayer-react 0.1.24 → 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 +11 -0
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +208 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +168 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/components/ErrorOverlay.tsx +89 -0
- package/src/hooks.ts +39 -14
- 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
|
-
[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[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,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.1.24
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -51,7 +51,7 @@ type StateInspectorOptions = {
|
|
|
51
51
|
colorScheme?: "light" | "dark";
|
|
52
52
|
anchor?: StateInspectorAnchor;
|
|
53
53
|
};
|
|
54
|
-
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 }: {
|
|
55
55
|
state: S;
|
|
56
56
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
57
57
|
connectedUsers?: MultiplayerUser[] | undefined;
|
|
@@ -63,11 +63,11 @@ declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E
|
|
|
63
63
|
forceInit: () => void;
|
|
64
64
|
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
65
65
|
|
|
66
|
-
declare function useSyncStateManager<S
|
|
67
|
-
declare function useSyncStateManager<S
|
|
68
|
-
declare function useManagedState<S
|
|
69
|
-
declare function useManagedHistory<S
|
|
70
|
-
declare function useSyncMultiplayerStateManager<S
|
|
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
71
|
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
72
|
throttle?: number;
|
|
73
73
|
}): {
|
|
@@ -75,13 +75,13 @@ declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>
|
|
|
75
75
|
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
76
76
|
currentUserId: string | undefined;
|
|
77
77
|
};
|
|
78
|
-
type UseMultiplayerStateOptions<S
|
|
78
|
+
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
79
79
|
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
80
80
|
trackConnectionEvents?: boolean;
|
|
81
81
|
trackTasks?: boolean;
|
|
82
82
|
inspector?: boolean | StateInspectorOptions;
|
|
83
83
|
};
|
|
84
|
-
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, {
|
|
85
85
|
tasks: Task[];
|
|
86
86
|
userId: string | undefined;
|
|
87
87
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
@@ -108,7 +108,7 @@ type AppDataOptions = {
|
|
|
108
108
|
/**
|
|
109
109
|
* Get data from host app. Fall back to default data.
|
|
110
110
|
*/
|
|
111
|
-
declare function useAppData<S
|
|
111
|
+
declare function useAppData<S>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
112
112
|
type IframeToHostMessage = {
|
|
113
113
|
type: "application.setMenuItems";
|
|
114
114
|
payload: {
|
|
@@ -129,7 +129,7 @@ type HostToIframeMessage = {
|
|
|
129
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
130
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
131
131
|
declare function isEmbeddedApp(): boolean;
|
|
132
|
-
declare function useNoyaAppState<S
|
|
132
|
+
declare function useNoyaAppState<S, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
133
133
|
localStorageKey?: string;
|
|
134
134
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
135
135
|
readonly theme: AppTheme;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ type StateInspectorOptions = {
|
|
|
51
51
|
colorScheme?: "light" | "dark";
|
|
52
52
|
anchor?: StateInspectorAnchor;
|
|
53
53
|
};
|
|
54
|
-
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 }: {
|
|
55
55
|
state: S;
|
|
56
56
|
connectionEvents?: ConnectionEvent<S>[] | undefined;
|
|
57
57
|
connectedUsers?: MultiplayerUser[] | undefined;
|
|
@@ -63,11 +63,11 @@ declare const StateInspector: React.MemoExoticComponent<(<S extends object, M, E
|
|
|
63
63
|
forceInit: () => void;
|
|
64
64
|
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.JSX.Element | null)>;
|
|
65
65
|
|
|
66
|
-
declare function useSyncStateManager<S
|
|
67
|
-
declare function useSyncStateManager<S
|
|
68
|
-
declare function useManagedState<S
|
|
69
|
-
declare function useManagedHistory<S
|
|
70
|
-
declare function useSyncMultiplayerStateManager<S
|
|
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
71
|
declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>, options?: {
|
|
72
72
|
throttle?: number;
|
|
73
73
|
}): {
|
|
@@ -75,13 +75,13 @@ declare function useEphemeralUserData<E>(ephemeralUserData: EphemeralUserData<E>
|
|
|
75
75
|
metadata: Record<string, _noya_app_state_manager.EphemeralUserMetadata | undefined>;
|
|
76
76
|
currentUserId: string | undefined;
|
|
77
77
|
};
|
|
78
|
-
type UseMultiplayerStateOptions<S
|
|
78
|
+
type UseMultiplayerStateOptions<S, M = void, E = void> = MultiplayerStateManagerOptions<S, M> & {
|
|
79
79
|
sync?: (options: Pick<SyncAdapterOptions<S, M, E>, "ms" | "ephemeralUserData">) => void;
|
|
80
80
|
trackConnectionEvents?: boolean;
|
|
81
81
|
trackTasks?: boolean;
|
|
82
82
|
inspector?: boolean | StateInspectorOptions;
|
|
83
83
|
};
|
|
84
|
-
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, {
|
|
85
85
|
tasks: Task[];
|
|
86
86
|
userId: string | undefined;
|
|
87
87
|
connectionEvents: ConnectionEvent<S>[] | undefined;
|
|
@@ -108,7 +108,7 @@ type AppDataOptions = {
|
|
|
108
108
|
/**
|
|
109
109
|
* Get data from host app. Fall back to default data.
|
|
110
110
|
*/
|
|
111
|
-
declare function useAppData<S
|
|
111
|
+
declare function useAppData<S>(initialState: S, { schema }?: AppDataOptions): AppData<S>;
|
|
112
112
|
type IframeToHostMessage = {
|
|
113
113
|
type: "application.setMenuItems";
|
|
114
114
|
payload: {
|
|
@@ -129,7 +129,7 @@ type HostToIframeMessage = {
|
|
|
129
129
|
declare function useBroadcastConnectedUsers(connectedUsers: MultiplayerUser[]): void;
|
|
130
130
|
declare function useBroadcastMenuItems<T>(menuItems: any[], handleSelectMenuItem: (value: T) => void): void;
|
|
131
131
|
declare function isEmbeddedApp(): boolean;
|
|
132
|
-
declare function useNoyaAppState<S
|
|
132
|
+
declare function useNoyaAppState<S, M = void, E = void>(initialState: S | (() => S), options: UseMultiplayerStateOptions<S, M, E> & {
|
|
133
133
|
localStorageKey?: string;
|
|
134
134
|
}): readonly [S, (...args: M extends {} ? [metadata: M, action: S | ((prevState: S) => S)] : [action: S | ((prevState: S) => S)]) => void, {
|
|
135
135
|
readonly theme: AppTheme;
|