@pluv/client 5.0.1 → 5.0.2
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/dist/index.d.mts +355 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1770 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -5
- package/CHANGELOG.md +0 -2415
- package/eslint.config.mjs +0 -4
- package/src/AbstractStorageStore.ts +0 -19
- package/src/CrdtManager.ts +0 -119
- package/src/CrdtNotifier.ts +0 -46
- package/src/EventNotifier.ts +0 -39
- package/src/ListenerManager.ts +0 -21
- package/src/MockedRoom.ts +0 -457
- package/src/PluvClient.ts +0 -204
- package/src/PluvProcedure.ts +0 -87
- package/src/PluvRoom.ts +0 -1610
- package/src/PluvRouter.ts +0 -71
- package/src/StateNotifier.ts +0 -41
- package/src/StorageStore.ts +0 -31
- package/src/UsersManager.ts +0 -341
- package/src/UsersNotifier.ts +0 -66
- package/src/constants.ts +0 -2
- package/src/createClient.ts +0 -14
- package/src/index.ts +0 -36
- package/src/infer.ts +0 -12
- package/src/register.ts +0 -20
- package/src/types.ts +0 -78
- package/src/utils/debounce.ts +0 -27
- package/src/utils/identity.ts +0 -1
- package/src/utils/index.ts +0 -3
- package/src/utils/pickBy.ts +0 -16
- package/tsconfig.json +0 -5
- package/tsdown.config.ts +0 -14
package/src/types.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CrdtDocLike,
|
|
3
|
-
EventRecord,
|
|
4
|
-
Id,
|
|
5
|
-
InferIOAuthorize,
|
|
6
|
-
InferIOAuthorizeUser,
|
|
7
|
-
IOLike,
|
|
8
|
-
JsonObject,
|
|
9
|
-
MaybePromise,
|
|
10
|
-
UserInfo,
|
|
11
|
-
} from "@pluv/types";
|
|
12
|
-
import type { PluvClient } from "./PluvClient";
|
|
13
|
-
|
|
14
|
-
export interface AuthorizationState<TIO extends IOLike> {
|
|
15
|
-
token: string | null;
|
|
16
|
-
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>> | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type EventResolver<
|
|
20
|
-
TIO extends IOLike,
|
|
21
|
-
TInput extends JsonObject,
|
|
22
|
-
TOutput extends EventRecord<string, any>,
|
|
23
|
-
TPresence extends Record<string, any>,
|
|
24
|
-
TDocLike extends CrdtDocLike<any, any>,
|
|
25
|
-
> = (
|
|
26
|
-
data: TInput,
|
|
27
|
-
context: EventResolverContext<TIO, TPresence, TDocLike>,
|
|
28
|
-
) => MaybePromise<TOutput | void>;
|
|
29
|
-
|
|
30
|
-
export interface EventResolverContext<
|
|
31
|
-
TIO extends IOLike,
|
|
32
|
-
TPresence extends Record<string, any>,
|
|
33
|
-
TDocLike extends CrdtDocLike<any, any>,
|
|
34
|
-
> {
|
|
35
|
-
doc: TDocLike;
|
|
36
|
-
others: readonly UserInfo<TIO, TPresence>[];
|
|
37
|
-
room: string;
|
|
38
|
-
user: UserInfo<TIO, TPresence>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type InferMetadata<TClient extends PluvClient<any, any, any, any>> =
|
|
42
|
-
TClient extends PluvClient<any, any, any, infer IMetadata> ? IMetadata : never;
|
|
43
|
-
|
|
44
|
-
export interface InternalSubscriptions {
|
|
45
|
-
observeCrdt: (() => void) | null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export type MergeEventRecords<
|
|
49
|
-
TEventRecords extends EventRecord<string, any>[],
|
|
50
|
-
TRoot extends EventRecord<string, any> = {},
|
|
51
|
-
> = TEventRecords extends [
|
|
52
|
-
infer IHead extends EventRecord<string, any>,
|
|
53
|
-
...infer ITail extends EventRecord<string, any>[],
|
|
54
|
-
]
|
|
55
|
-
? MergeEventRecords<
|
|
56
|
-
ITail,
|
|
57
|
-
Omit<TRoot, keyof IHead> & {
|
|
58
|
-
[P in keyof IHead]: TRoot extends Record<P, any> ? TRoot[P] | IHead[P] : IHead[P];
|
|
59
|
-
}
|
|
60
|
-
>
|
|
61
|
-
: Id<TRoot>;
|
|
62
|
-
|
|
63
|
-
export interface PluvClientLimits {
|
|
64
|
-
/**
|
|
65
|
-
* @description Maximum size of presence object in bytes
|
|
66
|
-
*/
|
|
67
|
-
presenceMaxSize?: number | null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface PublicKeyParams<TMetadata extends JsonObject> {
|
|
71
|
-
metadata: TMetadata;
|
|
72
|
-
}
|
|
73
|
-
export type PublicKey<TMetadata extends JsonObject> =
|
|
74
|
-
string | ((params: PublicKeyParams<TMetadata>) => string);
|
|
75
|
-
|
|
76
|
-
export type WithMetadata<TMetadata extends JsonObject = {}> = keyof TMetadata extends never
|
|
77
|
-
? { metadata?: undefined }
|
|
78
|
-
: { metadata: TMetadata };
|
package/src/utils/debounce.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const debounce = <TFunc extends (...args: any[]) => any>(
|
|
2
|
-
fn: TFunc,
|
|
3
|
-
options?: { wait: number; immediate?: boolean },
|
|
4
|
-
): ((...args: Parameters<TFunc>) => void) => {
|
|
5
|
-
const { wait, immediate = false } = options ?? {};
|
|
6
|
-
|
|
7
|
-
let prevResult: ReturnType<TFunc> | undefined;
|
|
8
|
-
let timeout: number | null = null;
|
|
9
|
-
|
|
10
|
-
return (...args: Parameters<TFunc>): void => {
|
|
11
|
-
if (typeof timeout === "number") clearTimeout(timeout);
|
|
12
|
-
|
|
13
|
-
timeout = setTimeout(() => {
|
|
14
|
-
timeout = null;
|
|
15
|
-
|
|
16
|
-
if (!immediate) prevResult = fn(args);
|
|
17
|
-
}, wait) as number;
|
|
18
|
-
|
|
19
|
-
if (immediate && !timeout) {
|
|
20
|
-
fn(args);
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return prevResult;
|
|
26
|
-
};
|
|
27
|
-
};
|
package/src/utils/identity.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const identity = <T extends unknown>(x: T): T => x;
|
package/src/utils/index.ts
DELETED
package/src/utils/pickBy.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const pickBy = <T extends Record<string, any>>(
|
|
2
|
-
obj: T,
|
|
3
|
-
by: (value: T[keyof T]) => boolean,
|
|
4
|
-
): Partial<T> => {
|
|
5
|
-
const result: Partial<T> = {};
|
|
6
|
-
const keys: (keyof T)[] = Object.keys(obj);
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
9
|
-
const key = keys[i];
|
|
10
|
-
const value = obj[key];
|
|
11
|
-
|
|
12
|
-
if (by(value)) result[key] = value;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return result;
|
|
16
|
-
};
|
package/tsconfig.json
DELETED
package/tsdown.config.ts
DELETED