@noya-app/noya-multiplayer-react 0.1.62 → 0.1.64
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 +20 -0
- package/dist/index.bundle.js +50 -17
- package/dist/index.d.mts +87 -24
- package/dist/index.d.ts +87 -24
- package/dist/index.js +2556 -708
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2523 -692
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/NoyaStateContext.tsx +248 -28
- package/src/__tests__/serialize.test.ts +126 -0
- package/src/ai.ts +2 -0
- package/src/index.ts +1 -0
- package/src/inspector/ColoredDot.tsx +17 -0
- package/src/inspector/ObjectRootLabel.tsx +48 -0
- package/src/inspector/StateInspector.tsx +266 -741
- package/src/inspector/StateInspectorArrow.tsx +28 -0
- package/src/inspector/StateInspectorButton.tsx +45 -0
- package/src/inspector/StateInspectorDisclosureSection.tsx +97 -0
- package/src/inspector/StateInspectorRow.tsx +57 -0
- package/src/inspector/StateInspectorTitleLabel.tsx +13 -0
- package/src/inspector/StateInspectorToggleButton.tsx +82 -0
- package/src/inspector/inspectorTheme.ts +21 -0
- package/src/inspector/sections/ActivityEventsSection.tsx +136 -0
- package/src/inspector/sections/EventsSection.tsx +89 -0
- package/src/inspector/sections/HistorySection.tsx +236 -0
- package/src/inspector/serialization.ts +202 -0
- package/src/inspector/utils.ts +60 -0
- package/src/inspector/zip/TinyZip.ts +464 -0
- package/src/inspector/zip/crc32.ts +16 -0
- package/src/inspector/zip/struct.ts +117 -0
- package/src/noyaApp.ts +3 -2
- package/src/useObservable.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { AIToolDefinition, ConnectedUsersManager, EphemeralUserDataManager, NoyaManager, StateManager, StateManagerOptions, NoyaManagerOptions, SyncAdapter, TSchema, Static, PublishCallback, SafeEval, CreateParams, MultiplayerStateManager, ReconnectingWebSocketState, ClientToServerMessage, ServerToClientMessage, MultiplayerStateManagerError } from '@noya-app/state-manager';
|
|
2
|
+
import { AIToolDefinition, ConnectedUsersManager, EphemeralUserDataManager, NoyaManager, StateManager, StateManagerOptions, NoyaManagerOptions, SyncAdapter, TSchema, Static, PublishCallback, ResourceManager, StreamFilter, ActivityEventsManager, MultiplayerPatchMetadata, SafeEval, CreateParams, MultiplayerStateManager, ReconnectingWebSocketState, ClientToServerMessage, ServerToClientMessage, MultiplayerStateManagerError } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, { SetStateAction, ComponentProps } from 'react';
|
|
4
|
+
import React, { SetStateAction, ComponentProps, Dispatch } from 'react';
|
|
5
5
|
import * as _noya_app_noya_schemas from '@noya-app/noya-schemas';
|
|
6
|
-
import { OutputTransform, Input } from '@noya-app/noya-schemas';
|
|
6
|
+
import { Asset, Resource, MediaItem, ResourceMap, ResourceCreateMap, OutputTransform, Input } from '@noya-app/noya-schemas';
|
|
7
7
|
import { GetAtPath, ObservableOptions, PathKey, Observable } from '@noya-app/observable';
|
|
8
8
|
import { MenuItem } from '@noya-app/noya-designsystem';
|
|
9
9
|
|
|
@@ -30,7 +30,7 @@ type UserPointersOverlayProps<E extends UserPointerData> = {
|
|
|
30
30
|
connectedUsersManager: ConnectedUsersManager;
|
|
31
31
|
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
32
32
|
} & RenderUserPointer;
|
|
33
|
-
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement | null;
|
|
33
|
+
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement<any> | null;
|
|
34
34
|
|
|
35
35
|
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
36
36
|
type StateInspectorOptions = {
|
|
@@ -40,7 +40,7 @@ type StateInspectorOptions = {
|
|
|
40
40
|
declare const StateInspector: <S, M extends object, E extends object, MenuT extends string = string>(props: {
|
|
41
41
|
noyaManager: NoyaManager<S, M, E, MenuT>;
|
|
42
42
|
unstyled?: boolean;
|
|
43
|
-
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement | null;
|
|
43
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement<any> | null;
|
|
44
44
|
|
|
45
45
|
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
46
46
|
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): GetAtPath<S, P>;
|
|
@@ -65,9 +65,40 @@ declare function useMultiplayerState<S, M extends object = object, E extends obj
|
|
|
65
65
|
menuItemsManager: _noya_app_state_manager.MenuManager<MenuT>;
|
|
66
66
|
createAsset: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_noya_schemas.Asset>;
|
|
67
67
|
deleteAsset: (id: string) => Promise<void>;
|
|
68
|
-
assets:
|
|
68
|
+
assets: {
|
|
69
|
+
contentType?: string | undefined;
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
url: string;
|
|
73
|
+
size: number;
|
|
74
|
+
width: number | null;
|
|
75
|
+
height: number | null;
|
|
76
|
+
userId: string | null;
|
|
77
|
+
}[];
|
|
69
78
|
}];
|
|
70
79
|
|
|
80
|
+
declare function fetchAssetMap(assets: Asset[]): Promise<Record<string, Uint8Array>>;
|
|
81
|
+
declare function exportAll(noyaManager: NoyaManager<any, any, any, any>): Promise<Uint8Array>;
|
|
82
|
+
declare function encodeAll({ state, schema, assets, assetMap, }: {
|
|
83
|
+
state: unknown;
|
|
84
|
+
schema?: TSchema;
|
|
85
|
+
assets: Asset[];
|
|
86
|
+
assetMap: Record<string, Uint8Array>;
|
|
87
|
+
}): Uint8Array;
|
|
88
|
+
declare function importAll(buffer: Uint8Array | ArrayBuffer, noyaManager: NoyaManager<any, any, any, any>, { shouldAllowSchemaChange, }?: {
|
|
89
|
+
shouldAllowSchemaChange?: ({ oldSchema, newSchema, }: {
|
|
90
|
+
oldSchema: TSchema;
|
|
91
|
+
newSchema: TSchema;
|
|
92
|
+
}) => boolean;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
declare function decodeAll(buffer: Uint8Array | ArrayBuffer): {
|
|
95
|
+
state: unknown;
|
|
96
|
+
schema?: TSchema;
|
|
97
|
+
assets: Asset[];
|
|
98
|
+
assetMap: Record<string, Uint8Array>;
|
|
99
|
+
};
|
|
100
|
+
declare function replaceDeep<T>(obj: T, replacementMap: Record<string, string>): T;
|
|
101
|
+
|
|
71
102
|
declare function useStateInspector<S, M extends object, E extends object, MenuT extends string = string>({ noyaManager, disabled, colorScheme, anchor, }: {
|
|
72
103
|
noyaManager: NoyaManager<S, M, E, MenuT>;
|
|
73
104
|
disabled: boolean;
|
|
@@ -136,8 +167,26 @@ declare function useAnyNoyaStateContext(): AnyNoyaStateContextValue;
|
|
|
136
167
|
declare function useAnyNoyaManager(): NoyaManager<any, any, any, any>;
|
|
137
168
|
declare function useColorScheme(): AppTheme;
|
|
138
169
|
declare function useViewType(): AppViewType;
|
|
139
|
-
declare function useAssets():
|
|
140
|
-
|
|
170
|
+
declare function useAssets(): {
|
|
171
|
+
contentType?: string | undefined;
|
|
172
|
+
id: string;
|
|
173
|
+
createdAt: string;
|
|
174
|
+
url: string;
|
|
175
|
+
size: number;
|
|
176
|
+
width: number | null;
|
|
177
|
+
height: number | null;
|
|
178
|
+
userId: string | null;
|
|
179
|
+
}[];
|
|
180
|
+
declare function useAsset(id: string | undefined): {
|
|
181
|
+
contentType?: string | undefined;
|
|
182
|
+
id: string;
|
|
183
|
+
createdAt: string;
|
|
184
|
+
url: string;
|
|
185
|
+
size: number;
|
|
186
|
+
width: number | null;
|
|
187
|
+
height: number | null;
|
|
188
|
+
userId: string | null;
|
|
189
|
+
} | undefined;
|
|
141
190
|
declare function useAssetManager(): {
|
|
142
191
|
create: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_noya_schemas.Asset>;
|
|
143
192
|
delete: (id: string) => Promise<void>;
|
|
@@ -149,19 +198,15 @@ declare function useSecrets(): _noya_app_state_manager.Secret[];
|
|
|
149
198
|
declare function useSecret(name: string): _noya_app_state_manager.Secret | undefined;
|
|
150
199
|
declare function useInputs(): ({
|
|
151
200
|
id: string;
|
|
152
|
-
kind: "file";
|
|
153
201
|
name: string;
|
|
202
|
+
kind: "file";
|
|
154
203
|
required: boolean;
|
|
155
204
|
toolId: string | null;
|
|
156
205
|
stableId: string;
|
|
157
206
|
description: string | null;
|
|
158
207
|
} | {
|
|
159
208
|
id: string;
|
|
160
|
-
kind: "data";
|
|
161
209
|
name: string;
|
|
162
|
-
required: boolean;
|
|
163
|
-
stableId: string;
|
|
164
|
-
description: string | null;
|
|
165
210
|
schema: {
|
|
166
211
|
default?: string | undefined;
|
|
167
212
|
type: "string";
|
|
@@ -249,12 +294,16 @@ declare function useInputs(): ({
|
|
|
249
294
|
};
|
|
250
295
|
_kind: "Object";
|
|
251
296
|
} | null;
|
|
297
|
+
kind: "data";
|
|
298
|
+
required: boolean;
|
|
299
|
+
stableId: string;
|
|
300
|
+
description: string | null;
|
|
252
301
|
} | {
|
|
253
302
|
authProvider?: "github" | "figma" | null | undefined;
|
|
254
303
|
authScope?: string | null | undefined;
|
|
255
304
|
id: string;
|
|
256
|
-
kind: "secret";
|
|
257
305
|
name: string;
|
|
306
|
+
kind: "secret";
|
|
258
307
|
required: boolean;
|
|
259
308
|
stableId: string;
|
|
260
309
|
description: string | null;
|
|
@@ -264,7 +313,7 @@ declare function useOutputTransforms(): ({
|
|
|
264
313
|
id: string;
|
|
265
314
|
kind: "script";
|
|
266
315
|
stableId: string;
|
|
267
|
-
location: "
|
|
316
|
+
location: "url" | "state";
|
|
268
317
|
order: number;
|
|
269
318
|
} | {
|
|
270
319
|
value: string;
|
|
@@ -279,37 +328,51 @@ declare function useIsInitialized(): boolean;
|
|
|
279
328
|
declare function usePipelineManager(): _noya_app_state_manager.PipelineManager;
|
|
280
329
|
declare const ConnectedUsersContext: React.Context<ConnectedUsersManager | undefined>;
|
|
281
330
|
declare function useConnectedUsersManager(): ConnectedUsersManager | undefined;
|
|
331
|
+
declare function useConnectedUsers(): _noya_app_state_manager.MultiplayerUser[] | undefined;
|
|
332
|
+
declare function useConnectedUser(userId?: string | null): _noya_app_state_manager.MultiplayerUser | undefined;
|
|
282
333
|
declare const AnyEphemeralUserDataManagerContext: React.Context<EphemeralUserDataManager<object> | undefined>;
|
|
283
334
|
declare function useAnyEphemeralUserData(): EphemeralUserDataManager<object> | undefined;
|
|
284
335
|
declare function useCurrentUserId(): string | undefined;
|
|
336
|
+
declare function useIsProcessing(): boolean;
|
|
337
|
+
declare function useResourceManager(): ResourceManager;
|
|
338
|
+
declare function resourceToMediaItem(resource: Resource): MediaItem;
|
|
339
|
+
declare function useResources({ shouldDeleteAssets, }?: {
|
|
340
|
+
shouldDeleteAssets?: boolean;
|
|
341
|
+
}): [ResourceMap, Dispatch<SetStateAction<ResourceCreateMap>>];
|
|
342
|
+
declare function useActivityEvents(streamFilter: StreamFilter): unknown[];
|
|
343
|
+
declare function useActivityEventsForManager(streamFilter: StreamFilter | undefined, activityEventsManager: ActivityEventsManager): unknown[];
|
|
285
344
|
declare const FallbackUntilInitialized: ({ children, fallback, }: {
|
|
286
345
|
children: React.ReactNode;
|
|
287
346
|
fallback?: React.ReactNode;
|
|
288
347
|
}) => React.ReactNode;
|
|
289
348
|
declare function createNoyaContext<Schema extends TSchema, M extends object = object, E extends object = object, MenuT extends string = string>({ schema, mergeHistoryEntries, outputTransforms, inputs, safeEval, }: {
|
|
290
349
|
schema: Schema;
|
|
291
|
-
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M
|
|
350
|
+
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>["mergeHistoryEntries"];
|
|
292
351
|
safeEval?: SafeEval;
|
|
293
352
|
outputTransforms?: CreateParams<OutputTransform>[];
|
|
294
353
|
inputs?: CreateParams<Input>[];
|
|
295
354
|
}): {
|
|
296
355
|
Context: React.Context<NoyaManager<Static<Schema>, M, E, string> | undefined>;
|
|
297
356
|
Provider: ({ children, initialState, ...options }: NoyaStateProviderProps<Static<Schema>, M, E, MenuT>) => React.JSX.Element;
|
|
357
|
+
NoyaContextProvider: ({ children, contextValue, }: {
|
|
358
|
+
children: React.ReactNode;
|
|
359
|
+
contextValue: AnyNoyaStateContextValue;
|
|
360
|
+
}) => React.JSX.Element;
|
|
298
361
|
useValue: {
|
|
299
362
|
(): Static<Schema>;
|
|
300
363
|
<A>(selector: (value: Static<Schema>) => A, options?: Pick<ObservableOptions, "isEqual">): A;
|
|
301
364
|
<P extends PathKey[] | string>(path: P): GetAtPath<Static<Schema>, P>;
|
|
302
365
|
};
|
|
303
366
|
useSetValue: {
|
|
304
|
-
(): (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void;
|
|
305
|
-
<P extends PathKey[] | string>(path: P): (...args: [metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void;
|
|
367
|
+
(): (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void;
|
|
368
|
+
<P extends PathKey[] | string>(path: P): (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void;
|
|
306
369
|
};
|
|
307
370
|
useValueState: {
|
|
308
|
-
(): [Static<Schema>, (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
309
|
-
<A>(selector: (value: Static<Schema>) => A, options?: ObservableOptions): [A, (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
310
|
-
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, (...args: [metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void];
|
|
371
|
+
(): [Static<Schema>, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
372
|
+
<A>(selector: (value: Static<Schema>) => A, options?: ObservableOptions): [A, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
373
|
+
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void];
|
|
311
374
|
};
|
|
312
|
-
useStateManager: () => MultiplayerStateManager<Static<Schema>, M
|
|
375
|
+
useStateManager: () => MultiplayerStateManager<Static<Schema>, Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>>;
|
|
313
376
|
useEphemeralUserDataManager: () => EphemeralUserDataManager<E>;
|
|
314
377
|
useLeftMenuItems: () => MenuItem<MenuT>[];
|
|
315
378
|
useSetLeftMenuItems: (leftMenuItems?: MenuItem<MenuT>[]) => void;
|
|
@@ -317,7 +380,7 @@ declare function createNoyaContext<Schema extends TSchema, M extends object = ob
|
|
|
317
380
|
useSetRightMenuItems: (rightMenuItems?: MenuItem<MenuT>[]) => void;
|
|
318
381
|
useHandleMenuItem: (callback: (type: MenuT) => void) => void;
|
|
319
382
|
useOnSelectMenuItemCallback: () => (type: MenuT) => void;
|
|
320
|
-
useNoyaManager: () => NoyaManager<Static<Schema>, M, E, MenuT>;
|
|
383
|
+
useNoyaManager: () => NoyaManager<Static<Schema>, Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, E, MenuT>;
|
|
321
384
|
useMenu: (options: {
|
|
322
385
|
leftMenuItems?: MenuItem<MenuT>[];
|
|
323
386
|
rightMenuItems?: MenuItem<MenuT>[];
|
|
@@ -365,4 +428,4 @@ declare class WebSocketConnection<State> {
|
|
|
365
428
|
removeListener(listener: (state: ReconnectingWebSocketState) => void): void;
|
|
366
429
|
}
|
|
367
430
|
|
|
368
|
-
export { AnyEphemeralUserDataManagerContext, AnyNoyaStateContext, type AnyNoyaStateContextValue, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, type ConnectionEvent, type ConnectionOptions, FallbackUntilInitialized, type GetAppDataOptions, type NoyaStateProviderProps, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, WebSocketConnection, createDefaultAppData, createNoyaContext, enforceSchema, getAppData, parseAppDataParameter, useAIManager, useAnyEphemeralUserData, useAnyNoyaManager, useAnyNoyaStateContext, useAsset, useAssetManager, useAssets, useCallableAITools, useColorScheme, useConnectedUsersManager, useCurrentUserId, useIOManager, useInputs, useIsInitialized, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useOutputTransforms, usePipelineManager, usePublish, useRegisterAITool, useSecret, useSecretManager, useSecrets, useStateInspector, useSyncStateManager, useViewType };
|
|
431
|
+
export { AnyEphemeralUserDataManagerContext, AnyNoyaStateContext, type AnyNoyaStateContextValue, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, type ConnectionEvent, type ConnectionOptions, FallbackUntilInitialized, type GetAppDataOptions, type NoyaStateProviderProps, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, WebSocketConnection, createDefaultAppData, createNoyaContext, decodeAll, encodeAll, enforceSchema, exportAll, fetchAssetMap, getAppData, importAll, parseAppDataParameter, replaceDeep, resourceToMediaItem, useAIManager, useActivityEvents, useActivityEventsForManager, useAnyEphemeralUserData, useAnyNoyaManager, useAnyNoyaStateContext, useAsset, useAssetManager, useAssets, useCallableAITools, useColorScheme, useConnectedUser, useConnectedUsers, useConnectedUsersManager, useCurrentUserId, useIOManager, useInputs, useIsInitialized, useIsProcessing, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useOutputTransforms, usePipelineManager, usePublish, useRegisterAITool, useResourceManager, useResources, useSecret, useSecretManager, useSecrets, useStateInspector, useSyncStateManager, useViewType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _noya_app_state_manager from '@noya-app/state-manager';
|
|
2
|
-
import { AIToolDefinition, ConnectedUsersManager, EphemeralUserDataManager, NoyaManager, StateManager, StateManagerOptions, NoyaManagerOptions, SyncAdapter, TSchema, Static, PublishCallback, SafeEval, CreateParams, MultiplayerStateManager, ReconnectingWebSocketState, ClientToServerMessage, ServerToClientMessage, MultiplayerStateManagerError } from '@noya-app/state-manager';
|
|
2
|
+
import { AIToolDefinition, ConnectedUsersManager, EphemeralUserDataManager, NoyaManager, StateManager, StateManagerOptions, NoyaManagerOptions, SyncAdapter, TSchema, Static, PublishCallback, ResourceManager, StreamFilter, ActivityEventsManager, MultiplayerPatchMetadata, SafeEval, CreateParams, MultiplayerStateManager, ReconnectingWebSocketState, ClientToServerMessage, ServerToClientMessage, MultiplayerStateManagerError } from '@noya-app/state-manager';
|
|
3
3
|
export * from '@noya-app/state-manager';
|
|
4
|
-
import React, { SetStateAction, ComponentProps } from 'react';
|
|
4
|
+
import React, { SetStateAction, ComponentProps, Dispatch } from 'react';
|
|
5
5
|
import * as _noya_app_noya_schemas from '@noya-app/noya-schemas';
|
|
6
|
-
import { OutputTransform, Input } from '@noya-app/noya-schemas';
|
|
6
|
+
import { Asset, Resource, MediaItem, ResourceMap, ResourceCreateMap, OutputTransform, Input } from '@noya-app/noya-schemas';
|
|
7
7
|
import { GetAtPath, ObservableOptions, PathKey, Observable } from '@noya-app/observable';
|
|
8
8
|
import { MenuItem } from '@noya-app/noya-designsystem';
|
|
9
9
|
|
|
@@ -30,7 +30,7 @@ type UserPointersOverlayProps<E extends UserPointerData> = {
|
|
|
30
30
|
connectedUsersManager: ConnectedUsersManager;
|
|
31
31
|
ephemeralUserDataManager: EphemeralUserDataManager<E>;
|
|
32
32
|
} & RenderUserPointer;
|
|
33
|
-
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement | null;
|
|
33
|
+
declare const UserPointersOverlay: <E extends UserPointerData>(props: UserPointersOverlayProps<E>) => React.ReactElement<any> | null;
|
|
34
34
|
|
|
35
35
|
type StateInspectorAnchor = "left" | "right" | "bottom left" | "bottom right";
|
|
36
36
|
type StateInspectorOptions = {
|
|
@@ -40,7 +40,7 @@ type StateInspectorOptions = {
|
|
|
40
40
|
declare const StateInspector: <S, M extends object, E extends object, MenuT extends string = string>(props: {
|
|
41
41
|
noyaManager: NoyaManager<S, M, E, MenuT>;
|
|
42
42
|
unstyled?: boolean;
|
|
43
|
-
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement | null;
|
|
43
|
+
} & StateInspectorOptions & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">) => React.ReactElement<any> | null;
|
|
44
44
|
|
|
45
45
|
declare function useSyncStateManager<S, M>(stateManager: StateManager<S, M>): S;
|
|
46
46
|
declare function useSyncStateManager<S, M, P extends string>(stateManager: StateManager<S, M>, path: P): GetAtPath<S, P>;
|
|
@@ -65,9 +65,40 @@ declare function useMultiplayerState<S, M extends object = object, E extends obj
|
|
|
65
65
|
menuItemsManager: _noya_app_state_manager.MenuManager<MenuT>;
|
|
66
66
|
createAsset: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_noya_schemas.Asset>;
|
|
67
67
|
deleteAsset: (id: string) => Promise<void>;
|
|
68
|
-
assets:
|
|
68
|
+
assets: {
|
|
69
|
+
contentType?: string | undefined;
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
url: string;
|
|
73
|
+
size: number;
|
|
74
|
+
width: number | null;
|
|
75
|
+
height: number | null;
|
|
76
|
+
userId: string | null;
|
|
77
|
+
}[];
|
|
69
78
|
}];
|
|
70
79
|
|
|
80
|
+
declare function fetchAssetMap(assets: Asset[]): Promise<Record<string, Uint8Array>>;
|
|
81
|
+
declare function exportAll(noyaManager: NoyaManager<any, any, any, any>): Promise<Uint8Array>;
|
|
82
|
+
declare function encodeAll({ state, schema, assets, assetMap, }: {
|
|
83
|
+
state: unknown;
|
|
84
|
+
schema?: TSchema;
|
|
85
|
+
assets: Asset[];
|
|
86
|
+
assetMap: Record<string, Uint8Array>;
|
|
87
|
+
}): Uint8Array;
|
|
88
|
+
declare function importAll(buffer: Uint8Array | ArrayBuffer, noyaManager: NoyaManager<any, any, any, any>, { shouldAllowSchemaChange, }?: {
|
|
89
|
+
shouldAllowSchemaChange?: ({ oldSchema, newSchema, }: {
|
|
90
|
+
oldSchema: TSchema;
|
|
91
|
+
newSchema: TSchema;
|
|
92
|
+
}) => boolean;
|
|
93
|
+
}): Promise<void>;
|
|
94
|
+
declare function decodeAll(buffer: Uint8Array | ArrayBuffer): {
|
|
95
|
+
state: unknown;
|
|
96
|
+
schema?: TSchema;
|
|
97
|
+
assets: Asset[];
|
|
98
|
+
assetMap: Record<string, Uint8Array>;
|
|
99
|
+
};
|
|
100
|
+
declare function replaceDeep<T>(obj: T, replacementMap: Record<string, string>): T;
|
|
101
|
+
|
|
71
102
|
declare function useStateInspector<S, M extends object, E extends object, MenuT extends string = string>({ noyaManager, disabled, colorScheme, anchor, }: {
|
|
72
103
|
noyaManager: NoyaManager<S, M, E, MenuT>;
|
|
73
104
|
disabled: boolean;
|
|
@@ -136,8 +167,26 @@ declare function useAnyNoyaStateContext(): AnyNoyaStateContextValue;
|
|
|
136
167
|
declare function useAnyNoyaManager(): NoyaManager<any, any, any, any>;
|
|
137
168
|
declare function useColorScheme(): AppTheme;
|
|
138
169
|
declare function useViewType(): AppViewType;
|
|
139
|
-
declare function useAssets():
|
|
140
|
-
|
|
170
|
+
declare function useAssets(): {
|
|
171
|
+
contentType?: string | undefined;
|
|
172
|
+
id: string;
|
|
173
|
+
createdAt: string;
|
|
174
|
+
url: string;
|
|
175
|
+
size: number;
|
|
176
|
+
width: number | null;
|
|
177
|
+
height: number | null;
|
|
178
|
+
userId: string | null;
|
|
179
|
+
}[];
|
|
180
|
+
declare function useAsset(id: string | undefined): {
|
|
181
|
+
contentType?: string | undefined;
|
|
182
|
+
id: string;
|
|
183
|
+
createdAt: string;
|
|
184
|
+
url: string;
|
|
185
|
+
size: number;
|
|
186
|
+
width: number | null;
|
|
187
|
+
height: number | null;
|
|
188
|
+
userId: string | null;
|
|
189
|
+
} | undefined;
|
|
141
190
|
declare function useAssetManager(): {
|
|
142
191
|
create: (options: _noya_app_state_manager.CreateAssetOptions | Uint8Array | File | Blob) => Promise<_noya_app_noya_schemas.Asset>;
|
|
143
192
|
delete: (id: string) => Promise<void>;
|
|
@@ -149,19 +198,15 @@ declare function useSecrets(): _noya_app_state_manager.Secret[];
|
|
|
149
198
|
declare function useSecret(name: string): _noya_app_state_manager.Secret | undefined;
|
|
150
199
|
declare function useInputs(): ({
|
|
151
200
|
id: string;
|
|
152
|
-
kind: "file";
|
|
153
201
|
name: string;
|
|
202
|
+
kind: "file";
|
|
154
203
|
required: boolean;
|
|
155
204
|
toolId: string | null;
|
|
156
205
|
stableId: string;
|
|
157
206
|
description: string | null;
|
|
158
207
|
} | {
|
|
159
208
|
id: string;
|
|
160
|
-
kind: "data";
|
|
161
209
|
name: string;
|
|
162
|
-
required: boolean;
|
|
163
|
-
stableId: string;
|
|
164
|
-
description: string | null;
|
|
165
210
|
schema: {
|
|
166
211
|
default?: string | undefined;
|
|
167
212
|
type: "string";
|
|
@@ -249,12 +294,16 @@ declare function useInputs(): ({
|
|
|
249
294
|
};
|
|
250
295
|
_kind: "Object";
|
|
251
296
|
} | null;
|
|
297
|
+
kind: "data";
|
|
298
|
+
required: boolean;
|
|
299
|
+
stableId: string;
|
|
300
|
+
description: string | null;
|
|
252
301
|
} | {
|
|
253
302
|
authProvider?: "github" | "figma" | null | undefined;
|
|
254
303
|
authScope?: string | null | undefined;
|
|
255
304
|
id: string;
|
|
256
|
-
kind: "secret";
|
|
257
305
|
name: string;
|
|
306
|
+
kind: "secret";
|
|
258
307
|
required: boolean;
|
|
259
308
|
stableId: string;
|
|
260
309
|
description: string | null;
|
|
@@ -264,7 +313,7 @@ declare function useOutputTransforms(): ({
|
|
|
264
313
|
id: string;
|
|
265
314
|
kind: "script";
|
|
266
315
|
stableId: string;
|
|
267
|
-
location: "
|
|
316
|
+
location: "url" | "state";
|
|
268
317
|
order: number;
|
|
269
318
|
} | {
|
|
270
319
|
value: string;
|
|
@@ -279,37 +328,51 @@ declare function useIsInitialized(): boolean;
|
|
|
279
328
|
declare function usePipelineManager(): _noya_app_state_manager.PipelineManager;
|
|
280
329
|
declare const ConnectedUsersContext: React.Context<ConnectedUsersManager | undefined>;
|
|
281
330
|
declare function useConnectedUsersManager(): ConnectedUsersManager | undefined;
|
|
331
|
+
declare function useConnectedUsers(): _noya_app_state_manager.MultiplayerUser[] | undefined;
|
|
332
|
+
declare function useConnectedUser(userId?: string | null): _noya_app_state_manager.MultiplayerUser | undefined;
|
|
282
333
|
declare const AnyEphemeralUserDataManagerContext: React.Context<EphemeralUserDataManager<object> | undefined>;
|
|
283
334
|
declare function useAnyEphemeralUserData(): EphemeralUserDataManager<object> | undefined;
|
|
284
335
|
declare function useCurrentUserId(): string | undefined;
|
|
336
|
+
declare function useIsProcessing(): boolean;
|
|
337
|
+
declare function useResourceManager(): ResourceManager;
|
|
338
|
+
declare function resourceToMediaItem(resource: Resource): MediaItem;
|
|
339
|
+
declare function useResources({ shouldDeleteAssets, }?: {
|
|
340
|
+
shouldDeleteAssets?: boolean;
|
|
341
|
+
}): [ResourceMap, Dispatch<SetStateAction<ResourceCreateMap>>];
|
|
342
|
+
declare function useActivityEvents(streamFilter: StreamFilter): unknown[];
|
|
343
|
+
declare function useActivityEventsForManager(streamFilter: StreamFilter | undefined, activityEventsManager: ActivityEventsManager): unknown[];
|
|
285
344
|
declare const FallbackUntilInitialized: ({ children, fallback, }: {
|
|
286
345
|
children: React.ReactNode;
|
|
287
346
|
fallback?: React.ReactNode;
|
|
288
347
|
}) => React.ReactNode;
|
|
289
348
|
declare function createNoyaContext<Schema extends TSchema, M extends object = object, E extends object = object, MenuT extends string = string>({ schema, mergeHistoryEntries, outputTransforms, inputs, safeEval, }: {
|
|
290
349
|
schema: Schema;
|
|
291
|
-
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M
|
|
350
|
+
mergeHistoryEntries?: StateManagerOptions<Static<Schema>, M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>["mergeHistoryEntries"];
|
|
292
351
|
safeEval?: SafeEval;
|
|
293
352
|
outputTransforms?: CreateParams<OutputTransform>[];
|
|
294
353
|
inputs?: CreateParams<Input>[];
|
|
295
354
|
}): {
|
|
296
355
|
Context: React.Context<NoyaManager<Static<Schema>, M, E, string> | undefined>;
|
|
297
356
|
Provider: ({ children, initialState, ...options }: NoyaStateProviderProps<Static<Schema>, M, E, MenuT>) => React.JSX.Element;
|
|
357
|
+
NoyaContextProvider: ({ children, contextValue, }: {
|
|
358
|
+
children: React.ReactNode;
|
|
359
|
+
contextValue: AnyNoyaStateContextValue;
|
|
360
|
+
}) => React.JSX.Element;
|
|
298
361
|
useValue: {
|
|
299
362
|
(): Static<Schema>;
|
|
300
363
|
<A>(selector: (value: Static<Schema>) => A, options?: Pick<ObservableOptions, "isEqual">): A;
|
|
301
364
|
<P extends PathKey[] | string>(path: P): GetAtPath<Static<Schema>, P>;
|
|
302
365
|
};
|
|
303
366
|
useSetValue: {
|
|
304
|
-
(): (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void;
|
|
305
|
-
<P extends PathKey[] | string>(path: P): (...args: [metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void;
|
|
367
|
+
(): (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void;
|
|
368
|
+
<P extends PathKey[] | string>(path: P): (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void;
|
|
306
369
|
};
|
|
307
370
|
useValueState: {
|
|
308
|
-
(): [Static<Schema>, (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
309
|
-
<A>(selector: (value: Static<Schema>) => A, options?: ObservableOptions): [A, (...args: [metadata: M, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
310
|
-
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, (...args: [metadata: M, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void];
|
|
371
|
+
(): [Static<Schema>, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
372
|
+
<A>(selector: (value: Static<Schema>) => A, options?: ObservableOptions): [A, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<Static<Schema>>] | [value: SetStateAction<Static<Schema>>]) => void];
|
|
373
|
+
<P extends PathKey[] | string>(path?: P): [GetAtPath<Static<Schema>, P>, (...args: [metadata: Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, value: SetStateAction<GetAtPath<Static<Schema>, P>>] | [value: SetStateAction<GetAtPath<Static<Schema>, P>>]) => void];
|
|
311
374
|
};
|
|
312
|
-
useStateManager: () => MultiplayerStateManager<Static<Schema>, M
|
|
375
|
+
useStateManager: () => MultiplayerStateManager<Static<Schema>, Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>>;
|
|
313
376
|
useEphemeralUserDataManager: () => EphemeralUserDataManager<E>;
|
|
314
377
|
useLeftMenuItems: () => MenuItem<MenuT>[];
|
|
315
378
|
useSetLeftMenuItems: (leftMenuItems?: MenuItem<MenuT>[]) => void;
|
|
@@ -317,7 +380,7 @@ declare function createNoyaContext<Schema extends TSchema, M extends object = ob
|
|
|
317
380
|
useSetRightMenuItems: (rightMenuItems?: MenuItem<MenuT>[]) => void;
|
|
318
381
|
useHandleMenuItem: (callback: (type: MenuT) => void) => void;
|
|
319
382
|
useOnSelectMenuItemCallback: () => (type: MenuT) => void;
|
|
320
|
-
useNoyaManager: () => NoyaManager<Static<Schema>, M, E, MenuT>;
|
|
383
|
+
useNoyaManager: () => NoyaManager<Static<Schema>, Partial<M & Pick<MultiplayerPatchMetadata, "name" | "timestamp">>, E, MenuT>;
|
|
321
384
|
useMenu: (options: {
|
|
322
385
|
leftMenuItems?: MenuItem<MenuT>[];
|
|
323
386
|
rightMenuItems?: MenuItem<MenuT>[];
|
|
@@ -365,4 +428,4 @@ declare class WebSocketConnection<State> {
|
|
|
365
428
|
removeListener(listener: (state: ReconnectingWebSocketState) => void): void;
|
|
366
429
|
}
|
|
367
430
|
|
|
368
|
-
export { AnyEphemeralUserDataManagerContext, AnyNoyaStateContext, type AnyNoyaStateContextValue, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, type ConnectionEvent, type ConnectionOptions, FallbackUntilInitialized, type GetAppDataOptions, type NoyaStateProviderProps, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, WebSocketConnection, createDefaultAppData, createNoyaContext, enforceSchema, getAppData, parseAppDataParameter, useAIManager, useAnyEphemeralUserData, useAnyNoyaManager, useAnyNoyaStateContext, useAsset, useAssetManager, useAssets, useCallableAITools, useColorScheme, useConnectedUsersManager, useCurrentUserId, useIOManager, useInputs, useIsInitialized, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useOutputTransforms, usePipelineManager, usePublish, useRegisterAITool, useSecret, useSecretManager, useSecrets, useStateInspector, useSyncStateManager, useViewType };
|
|
431
|
+
export { AnyEphemeralUserDataManagerContext, AnyNoyaStateContext, type AnyNoyaStateContextValue, type AppData, type AppTheme, type AppViewType, ConnectedUsersContext, type ConnectionEvent, type ConnectionOptions, FallbackUntilInitialized, type GetAppDataOptions, type NoyaStateProviderProps, type RenderUserPointer, type RenderUserPointerProps, StateInspector, type StateInspectorAnchor, type StateInspectorOptions, type UseMultiplayerStateOptions, type UseNoyaStateOptions, type UseNoyaStateResult, type UserPointerData, UserPointersOverlay, type UserPointersOverlayProps, WebSocketConnection, createDefaultAppData, createNoyaContext, decodeAll, encodeAll, enforceSchema, exportAll, fetchAssetMap, getAppData, importAll, parseAppDataParameter, replaceDeep, resourceToMediaItem, useAIManager, useActivityEvents, useActivityEventsForManager, useAnyEphemeralUserData, useAnyNoyaManager, useAnyNoyaStateContext, useAsset, useAssetManager, useAssets, useCallableAITools, useColorScheme, useConnectedUser, useConnectedUsers, useConnectedUsersManager, useCurrentUserId, useIOManager, useInputs, useIsInitialized, useIsProcessing, useManagedHistory, useManagedState, useMultiplayerState, useNoyaState, useObservable, useOutputTransforms, usePipelineManager, usePublish, useRegisterAITool, useResourceManager, useResources, useSecret, useSecretManager, useSecrets, useStateInspector, useSyncStateManager, useViewType };
|