@pluv/client 5.0.1 → 5.0.3
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 +1765 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -8
- 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/PluvProcedure.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { AbstractCrdtDocFactory, InferDocLike } from "@pluv/crdt";
|
|
2
|
-
import type { EventRecord, IOLike, InputZodLike, JsonObject, ProcedureLike } from "@pluv/types";
|
|
3
|
-
import type { EventResolver, MergeEventRecords } from "./types";
|
|
4
|
-
|
|
5
|
-
export interface PluvProcedureConfig<
|
|
6
|
-
TIO extends IOLike,
|
|
7
|
-
TInput extends JsonObject,
|
|
8
|
-
TOutput extends EventRecord<string, any>,
|
|
9
|
-
TPresence extends Record<string, any>,
|
|
10
|
-
TCrdt extends AbstractCrdtDocFactory<any, any>,
|
|
11
|
-
> {
|
|
12
|
-
broadcast?: EventResolver<TIO, TInput, TOutput, TPresence, InferDocLike<TCrdt>> | null;
|
|
13
|
-
input?: InputZodLike<TInput>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class PluvProcedure<
|
|
17
|
-
TIO extends IOLike,
|
|
18
|
-
TInput extends JsonObject,
|
|
19
|
-
TOutput extends EventRecord<string, any>,
|
|
20
|
-
TPresence extends Record<string, any>,
|
|
21
|
-
TCrdt extends AbstractCrdtDocFactory<any, any>,
|
|
22
|
-
TFilled extends "input" | "broadcast" | "",
|
|
23
|
-
> implements ProcedureLike<TInput, TOutput> {
|
|
24
|
-
private _broadcast: EventResolver<
|
|
25
|
-
TIO,
|
|
26
|
-
TInput,
|
|
27
|
-
Partial<TOutput>,
|
|
28
|
-
TPresence,
|
|
29
|
-
InferDocLike<TCrdt>
|
|
30
|
-
> | null = null;
|
|
31
|
-
private _input: InputZodLike<TInput> | null = null;
|
|
32
|
-
|
|
33
|
-
public get config(): ProcedureLike<TInput, TOutput>["config"] {
|
|
34
|
-
return {
|
|
35
|
-
broadcast: this._broadcast?.bind(this) ?? null,
|
|
36
|
-
input: this._input ?? null,
|
|
37
|
-
resolver: this._resolver(),
|
|
38
|
-
} as ProcedureLike<TInput, TOutput>["config"];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
constructor(config: PluvProcedureConfig<TIO, TInput, TOutput, TPresence, TCrdt> = {}) {
|
|
42
|
-
const { broadcast, input } = config;
|
|
43
|
-
|
|
44
|
-
this._broadcast = broadcast ?? null;
|
|
45
|
-
this._input = input ?? null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public broadcast<TResult extends EventRecord<string, any> = {}>(
|
|
49
|
-
resolver: EventResolver<TIO, TInput, TResult, TPresence, InferDocLike<TCrdt>>,
|
|
50
|
-
): Omit<
|
|
51
|
-
PluvProcedure<
|
|
52
|
-
TIO,
|
|
53
|
-
TInput,
|
|
54
|
-
MergeEventRecords<[TOutput, TResult]>,
|
|
55
|
-
TPresence,
|
|
56
|
-
TCrdt,
|
|
57
|
-
TFilled | "input" | "broadcast"
|
|
58
|
-
>,
|
|
59
|
-
TFilled | "input" | "broadcast"
|
|
60
|
-
> {
|
|
61
|
-
const { broadcast } = this.config;
|
|
62
|
-
|
|
63
|
-
if (!!broadcast) throw new Error("Broadcast was already defined for this procedure");
|
|
64
|
-
|
|
65
|
-
return new PluvProcedure<
|
|
66
|
-
TIO,
|
|
67
|
-
TInput,
|
|
68
|
-
MergeEventRecords<[TOutput, TResult]>,
|
|
69
|
-
TPresence,
|
|
70
|
-
TCrdt,
|
|
71
|
-
TFilled | "input" | "broadcast"
|
|
72
|
-
>({
|
|
73
|
-
...(this.config as any),
|
|
74
|
-
broadcast: resolver as any,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public input<TData extends JsonObject>(
|
|
79
|
-
input: InputZodLike<TData>,
|
|
80
|
-
): Omit<PluvProcedure<TIO, TData, {}, TPresence, TCrdt, TFilled | "input">, TFilled | "input"> {
|
|
81
|
-
return new PluvProcedure<TIO, TData, {}, TPresence, TCrdt, TFilled | "input">({ input });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private _resolver(): EventResolver<TIO, TInput, TOutput, TPresence, InferDocLike<TCrdt>> {
|
|
85
|
-
return (data, context) => this._broadcast?.(data, context) as TOutput;
|
|
86
|
-
}
|
|
87
|
-
}
|