@pluv/types 3.2.2 → 4.0.0
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 +14 -16
- package/CHANGELOG.md +14 -0
- package/dist/index.d.mts +234 -271
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +1 -0
- package/package.json +15 -10
- package/src/general.ts +12 -0
- package/src/index.ts +1 -0
- package/tsdown.config.ts +14 -0
- package/dist/index.d.ts +0 -387
- package/dist/index.js +0 -46
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@
|
|
3
|
-
>
|
|
2
|
+
> @pluv/types@4.0.0 build /home/runner/work/pluv/pluv/packages/types
|
|
3
|
+
> tsdown
|
|
4
4
|
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m20.23 KB[39m
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m20.23 KB[39m
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.20.0-beta.4[22m powered by rolldown [2mv1.0.0-beta.60[22m
|
|
6
|
+
[34mℹ[39m config file: [4m/home/runner/work/pluv/pluv/packages/types/tsdown.config.ts[24m
|
|
7
|
+
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
8
|
+
[34mℹ[39m target: [34mesnext[39m
|
|
9
|
+
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
|
+
[34mℹ[39m Build start
|
|
11
|
+
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.38 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22mindex.d.mts.map [2m11.86 kB[22m [2m│ gzip: 3.05 kB[22m
|
|
13
|
+
[34mℹ[39m [2mdist/[22mindex.mjs.map [2m 0.76 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
14
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m20.43 kB[22m [2m│ gzip: 4.49 kB[22m
|
|
15
|
+
[34mℹ[39m 4 files, total: 33.43 kB
|
|
16
|
+
[32m✔[39m Build complete in [32m1054ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @pluv/types
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- df5c39c: Update all packages to be ESM only.
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 037074e: Migrated build process from tsup to tsdown.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 2eb5def: Bumped dependencies.
|
|
16
|
+
|
|
3
17
|
## 3.2.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,387 +1,350 @@
|
|
|
1
|
-
import { Subject } from
|
|
1
|
+
import { Subject } from "wonka";
|
|
2
2
|
|
|
3
|
+
//#region src/general.d.ts
|
|
3
4
|
type Constructable = {
|
|
4
|
-
|
|
5
|
+
new (...args: any[]): any;
|
|
5
6
|
};
|
|
6
|
-
type HasRequiredProperty<T> = {
|
|
7
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
8
|
-
}[keyof T] extends never ? false : true;
|
|
7
|
+
type HasRequiredProperty<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T] extends never ? false : true;
|
|
9
8
|
type Maybe<T> = T | Nil;
|
|
10
9
|
type MaybePromise<T> = Promise<T> | T;
|
|
11
10
|
type MaybeReadonlyArray<T> = T[] | readonly T[];
|
|
12
11
|
type Nil = null | undefined;
|
|
13
|
-
type OptionalPropertyNames<T> = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} ? K : never;
|
|
17
|
-
}[keyof T];
|
|
18
|
-
type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
19
|
-
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
20
|
-
};
|
|
21
|
-
type Id<T> = T extends Nil ? T : T extends infer U ? U extends Constructable ? U : {
|
|
22
|
-
[K in keyof U]: U[K];
|
|
23
|
-
} : never;
|
|
12
|
+
type OptionalPropertyNames<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? K : never }[keyof T];
|
|
13
|
+
type SpreadProperties<L, R, K extends keyof L & keyof R> = { [P in K]: L[P] | Exclude<R[P], undefined> };
|
|
14
|
+
type Id<T> = T extends Nil ? T : T extends infer U ? U extends Constructable ? U : { [K in keyof U]: U[K] } : never;
|
|
24
15
|
type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
25
16
|
type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
26
|
-
type DeepPartial<T> = {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
type DeepWriteable<T> = {
|
|
30
|
-
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
31
|
-
};
|
|
32
|
-
type UndefinedProps<T extends Record<string, any>, K extends keyof T = keyof T> = Id<{
|
|
33
|
-
[P in K]?: undefined;
|
|
34
|
-
} & {
|
|
35
|
-
[P in Exclude<keyof T, K>]: T[P];
|
|
36
|
-
}>;
|
|
17
|
+
type DeepPartial<T> = { [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]> };
|
|
18
|
+
type DeepWriteable<T> = { -readonly [P in keyof T]: DeepWriteable<T[P]> };
|
|
19
|
+
type UndefinedProps<T extends Record<string, any>, K extends keyof T = keyof T> = Id<{ [P in K]?: undefined } & { [P in Exclude<keyof T, K>]: T[P] }>;
|
|
37
20
|
type OptionalProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
38
|
-
type NonNilProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & {
|
|
39
|
-
[P in K]-?: NonNullable<T[P]>;
|
|
40
|
-
};
|
|
21
|
+
type NonNilProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
|
|
41
22
|
type JsonPrimitive = string | number | boolean | null;
|
|
42
23
|
type Json = JsonPrimitive | Json[] | readonly Json[] | {
|
|
43
|
-
|
|
24
|
+
[key: string]: Json;
|
|
44
25
|
};
|
|
45
26
|
type JsonObject = Record<string, Json>;
|
|
46
|
-
type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void ? I : never;
|
|
47
|
-
|
|
27
|
+
type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends ((arg: infer I) => void) ? I : never;
|
|
28
|
+
type AreAllOptional<T> = [T] extends [{}] ? keyof T extends never ? true : HasRequiredProperty<T> extends true ? false : true : false;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/pluv/crdt.d.ts
|
|
48
31
|
interface CrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
_initialStorage: (builder: any) => TStorage;
|
|
33
|
+
getEmpty(): CrdtDocLike<TDoc, TStorage>;
|
|
34
|
+
getFactory(initialStorage?: (builder: any) => TStorage): CrdtDocFactory<TDoc, TStorage>;
|
|
35
|
+
getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
|
|
36
|
+
isEmpty(initialStorage: Maybe<string>): boolean;
|
|
54
37
|
}
|
|
55
38
|
interface CrdtLibraryType<TDoc extends CrdtDocFactory<any, any> = CrdtDocFactory<any, any>> {
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
doc: (value: any) => TDoc;
|
|
40
|
+
kind: "loro" | "yjs";
|
|
58
41
|
}
|
|
59
42
|
type CrdtType<TValue extends unknown, TJson extends unknown = any> = Omit<TValue, "__pluvType"> & {
|
|
60
|
-
|
|
43
|
+
__pluvType: () => TJson;
|
|
61
44
|
};
|
|
62
|
-
type InferCrdtJson<T extends unknown> = T extends CrdtType<any, infer IJson> ? InferCrdtJson<IJson> : T extends Record<string, any> ? {
|
|
63
|
-
[P in keyof T]: InferCrdtJson<T[P]>;
|
|
64
|
-
} : T extends (infer IJson)[] ? InferCrdtJson<IJson>[] : T extends readonly (infer IJson)[] ? readonly InferCrdtJson<IJson>[] : T extends Json ? T : string;
|
|
45
|
+
type InferCrdtJson<T extends unknown> = T extends CrdtType<any, infer IJson> ? InferCrdtJson<IJson> : T extends Record<string, any> ? { [P in keyof T]: InferCrdtJson<T[P]> } : T extends (infer IJson)[] ? InferCrdtJson<IJson>[] : T extends readonly (infer IJson)[] ? readonly InferCrdtJson<IJson>[] : T extends Json ? T : string;
|
|
65
46
|
interface DocApplyEncodedStateParams {
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
origin?: string;
|
|
48
|
+
update?: Maybe<string | Uint8Array>;
|
|
68
49
|
}
|
|
69
50
|
interface DocBatchApplyEncodedStateParams {
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
origin?: string;
|
|
52
|
+
updates?: Maybe<readonly Maybe<string | Uint8Array>[]>;
|
|
72
53
|
}
|
|
73
54
|
interface DocSubscribeCallbackParams<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
doc: CrdtDocLike<TDoc, TStorage>;
|
|
56
|
+
local: boolean;
|
|
57
|
+
origin?: string | null;
|
|
58
|
+
update: string;
|
|
78
59
|
}
|
|
79
60
|
interface CrdtDocLike<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
61
|
+
value: TDoc;
|
|
62
|
+
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
63
|
+
batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
|
|
64
|
+
canRedo(): boolean;
|
|
65
|
+
canUndo(): boolean;
|
|
66
|
+
destroy(): void;
|
|
67
|
+
get(key?: undefined): TStorage;
|
|
68
|
+
get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
69
|
+
getEncodedState(): string;
|
|
70
|
+
isEmpty(): boolean;
|
|
71
|
+
rebuildStorage(reference: TStorage): this;
|
|
72
|
+
redo(): this;
|
|
73
|
+
subscribe(listener: (params: DocSubscribeCallbackParams<TDoc, TStorage>) => void): () => void;
|
|
74
|
+
toJson(): InferCrdtJson<TStorage>;
|
|
75
|
+
toJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]>;
|
|
76
|
+
track(): this;
|
|
77
|
+
transact(fn: () => void, origin?: string): this;
|
|
78
|
+
undo(): this;
|
|
98
79
|
}
|
|
99
|
-
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/pluv/enums.d.ts
|
|
100
82
|
declare const ConnectionState: {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
83
|
+
readonly Closed: "closed";
|
|
84
|
+
readonly Connecting: "connecting";
|
|
85
|
+
readonly Open: "open";
|
|
86
|
+
readonly Unavailable: "unavailable";
|
|
87
|
+
readonly Untouched: "untouched";
|
|
106
88
|
};
|
|
107
89
|
type ConnectionState = (typeof ConnectionState)[keyof typeof ConnectionState];
|
|
108
90
|
declare const StorageState: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
91
|
+
Loading: string;
|
|
92
|
+
Offline: string;
|
|
93
|
+
Synced: string;
|
|
94
|
+
Unavailable: string;
|
|
113
95
|
};
|
|
114
96
|
type StorageState = (typeof StorageState)[keyof typeof StorageState];
|
|
115
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/pluv/shared.d.ts
|
|
116
99
|
type BaseUser = {
|
|
117
|
-
|
|
100
|
+
id: string;
|
|
118
101
|
};
|
|
119
102
|
interface BaseClientEventRecord {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
103
|
+
$getOthers: {};
|
|
104
|
+
$initializeSession: {
|
|
105
|
+
presence: JsonObject;
|
|
106
|
+
update: string | null;
|
|
107
|
+
};
|
|
108
|
+
$ping: {};
|
|
109
|
+
$updatePresence: {
|
|
110
|
+
presence: JsonObject;
|
|
111
|
+
};
|
|
112
|
+
$updateStorage: {
|
|
113
|
+
origin: string | null;
|
|
114
|
+
update: string;
|
|
115
|
+
};
|
|
133
116
|
}
|
|
134
117
|
type BaseClientMessage = InferEventMessage<BaseClientEventRecord>;
|
|
135
118
|
type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
presence: JsonObject | null;
|
|
148
|
-
room: string | null;
|
|
149
|
-
timers: {
|
|
150
|
-
presence: number | null;
|
|
151
|
-
};
|
|
152
|
-
user: Id<InferIOAuthorizeUser<TAuthorize>>;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
$pong: {};
|
|
157
|
-
$presenceUpdated: {
|
|
158
|
-
presence: JsonObject;
|
|
159
|
-
timers: {
|
|
160
|
-
presence: number | null;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
$registered: {
|
|
119
|
+
$error: {
|
|
120
|
+
message: string;
|
|
121
|
+
stack?: string | null;
|
|
122
|
+
};
|
|
123
|
+
$exit: {
|
|
124
|
+
sessionId: string;
|
|
125
|
+
};
|
|
126
|
+
$othersReceived: {
|
|
127
|
+
others: {
|
|
128
|
+
[connectionId: string]: {
|
|
129
|
+
connectionId: string;
|
|
164
130
|
presence: JsonObject | null;
|
|
165
|
-
|
|
166
|
-
state: string | null;
|
|
131
|
+
room: string | null;
|
|
167
132
|
timers: {
|
|
168
|
-
|
|
133
|
+
presence: number | null;
|
|
169
134
|
};
|
|
135
|
+
user: Id<InferIOAuthorizeUser<TAuthorize>>;
|
|
136
|
+
};
|
|
170
137
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
138
|
+
};
|
|
139
|
+
$pong: {};
|
|
140
|
+
$presenceUpdated: {
|
|
141
|
+
presence: JsonObject;
|
|
142
|
+
timers: {
|
|
143
|
+
presence: number | null;
|
|
177
144
|
};
|
|
178
|
-
|
|
179
|
-
|
|
145
|
+
};
|
|
146
|
+
$registered: {
|
|
147
|
+
presence: JsonObject | null;
|
|
148
|
+
sessionId: string;
|
|
149
|
+
state: string | null;
|
|
150
|
+
timers: {
|
|
151
|
+
presence: number | null;
|
|
180
152
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
153
|
+
};
|
|
154
|
+
$storageReceived: {
|
|
155
|
+
changeKind: "empty" | "initialized" | "unchanged";
|
|
156
|
+
state: string;
|
|
157
|
+
};
|
|
158
|
+
$storageUpdated: {
|
|
159
|
+
state: string;
|
|
160
|
+
};
|
|
161
|
+
$syncStateReceived: {
|
|
162
|
+
connectionIds: readonly string[];
|
|
163
|
+
};
|
|
164
|
+
$userJoined: {
|
|
165
|
+
connectionId: string;
|
|
166
|
+
presence: JsonObject;
|
|
167
|
+
timers: {
|
|
168
|
+
presence: number | null;
|
|
188
169
|
};
|
|
170
|
+
user: NonNullable<Id<InferIOAuthorizeUser<TAuthorize>>>;
|
|
171
|
+
};
|
|
189
172
|
};
|
|
190
173
|
interface EventMessage<TEvent extends string, TData extends JsonObject = {}> {
|
|
191
|
-
|
|
192
|
-
|
|
174
|
+
data: TData;
|
|
175
|
+
type: TEvent;
|
|
193
176
|
}
|
|
194
|
-
type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
195
|
-
[key in `${TEvent}`]: TData;
|
|
196
|
-
};
|
|
177
|
+
type EventRecord<TEvent extends string, TData extends JsonObject> = { [key in `${TEvent}`]: TData };
|
|
197
178
|
type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
198
179
|
type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? InferIOAuthorizeUser<IAuthorize> extends BaseUser ? {
|
|
199
|
-
|
|
180
|
+
user: InputZodLike<InferIOAuthorizeUser<IAuthorize>>;
|
|
200
181
|
} : null : never;
|
|
201
182
|
type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> = TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
|
|
202
183
|
type InputZodLike<TData extends JsonObject> = {
|
|
203
|
-
|
|
184
|
+
parse: (data: unknown) => TData;
|
|
204
185
|
} & ({
|
|
205
|
-
|
|
186
|
+
_input: TData;
|
|
206
187
|
} | {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
188
|
+
_zod: {
|
|
189
|
+
input: TData;
|
|
190
|
+
};
|
|
210
191
|
});
|
|
211
192
|
type IOAuthorize<TUser extends BaseUser | null = any, TContext extends Record<string, unknown> = {}> = (TUser extends BaseUser ? {
|
|
212
|
-
|
|
213
|
-
|
|
193
|
+
secret?: string;
|
|
194
|
+
user: InputZodLike<TUser>;
|
|
214
195
|
} : null) | ((context: TContext) => TUser extends BaseUser ? {
|
|
215
|
-
|
|
216
|
-
|
|
196
|
+
secret?: string;
|
|
197
|
+
user: InputZodLike<TUser>;
|
|
217
198
|
} : null);
|
|
218
199
|
type IOAuthorizeEventMessage<TIO extends IOLike> = {
|
|
219
|
-
|
|
220
|
-
|
|
200
|
+
connectionId: string;
|
|
201
|
+
user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
|
|
221
202
|
};
|
|
222
203
|
type ProcedureLike<TInput extends Record<string, any> = {}, TOutput extends EventRecord<string, any> = {}> = {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
204
|
+
config: {
|
|
205
|
+
broadcast?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
206
|
+
input?: InputZodLike<TInput> | null;
|
|
207
|
+
resolver: (data: TInput, ...args: any[]) => MaybePromise<TOutput>;
|
|
208
|
+
self?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
209
|
+
sync?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
210
|
+
};
|
|
230
211
|
};
|
|
231
212
|
interface IORouterLike<TEvents extends Record<string, ProcedureLike<any, any>> = {}> {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
213
|
+
_defs: {
|
|
214
|
+
events: TEvents;
|
|
215
|
+
};
|
|
235
216
|
}
|
|
236
217
|
interface IOLike<TAuthorize extends IOAuthorize<any, any> | null = null, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<any>, TEvents extends Record<string, ProcedureLike<any, any>> = {}> extends IORouterLike<TEvents> {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
218
|
+
_defs: {
|
|
219
|
+
authorize: TAuthorize;
|
|
220
|
+
crdt: TCrdt;
|
|
221
|
+
events: TEvents;
|
|
222
|
+
};
|
|
242
223
|
}
|
|
243
224
|
type InferIOCrdtKind<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt extends CrdtLibraryType<infer IDoc> ? IDoc : never : never;
|
|
244
225
|
type InferIOCrdt<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt : never;
|
|
245
|
-
type InferIOEvents<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, any, infer IEvents> ? {
|
|
246
|
-
[P in keyof IEvents]: ProcedureLike<InferIOProcedureInput<IEvents[P]>, InferIOProcedureOutput<IEvents[P]>>;
|
|
247
|
-
} : never;
|
|
226
|
+
type InferIOEvents<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, any, infer IEvents> ? { [P in keyof IEvents]: ProcedureLike<InferIOProcedureInput<IEvents[P]>, InferIOProcedureOutput<IEvents[P]>> } : never;
|
|
248
227
|
type InferIOProcedureInput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
|
|
249
228
|
type InferIOProcedureOutput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
|
|
250
|
-
type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = {
|
|
251
|
-
|
|
252
|
-
};
|
|
253
|
-
type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<{
|
|
254
|
-
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
|
|
255
|
-
}[keyof TEvents]>;
|
|
229
|
+
type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = { [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? Id<IInput> : never };
|
|
230
|
+
type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<{ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never }[keyof TEvents]>;
|
|
256
231
|
type InferIOInput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
|
|
257
232
|
type InferIOOutput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
|
|
258
|
-
type InferEventMessage<TEvents = EventRecord<string, any>, TEvent extends keyof TEvents = keyof TEvents> = TEvents extends EventRecord<string, any> ? {
|
|
259
|
-
[P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never;
|
|
260
|
-
}[TEvent] : never;
|
|
233
|
+
type InferEventMessage<TEvents = EventRecord<string, any>, TEvent extends keyof TEvents = keyof TEvents> = TEvents extends EventRecord<string, any> ? { [P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never }[TEvent] : never;
|
|
261
234
|
type IOEventMessage<TIO extends IOLike<any, any, any>, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = Id<{
|
|
262
|
-
|
|
235
|
+
room: string;
|
|
263
236
|
} & InferEventMessage<InferIOOutput<TIO>, TEvent> & (InferEventMessage<InferIOOutput<TIO>, TEvent>["type"] extends "$error" ? Partial<IOAuthorizeEventMessage<TIO>> : IOAuthorizeEventMessage<TIO>)>;
|
|
264
237
|
type PluvRouterEventConfig = {
|
|
265
|
-
|
|
238
|
+
[P: string]: Pick<ProcedureLike<any, any>, "config">;
|
|
266
239
|
};
|
|
267
|
-
type MergeEvents<TClientEvents extends PluvRouterEventConfig, TServerIO extends IOLike<any, any, any>> = TServerIO extends IOLike<infer IAuthorize, infer ICrdt, infer IServerEvents> ? IOLike<IAuthorize, ICrdt, {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}[keyof IClientOutput] : never;
|
|
271
|
-
} & IServerEvents> : never;
|
|
272
|
-
|
|
240
|
+
type MergeEvents<TClientEvents extends PluvRouterEventConfig, TServerIO extends IOLike<any, any, any>> = TServerIO extends IOLike<infer IAuthorize, infer ICrdt, infer IServerEvents> ? IOLike<IAuthorize, ICrdt, { [P in keyof TClientEvents]: TClientEvents[P] extends ProcedureLike<infer IClientInput, infer IClientOutput> ? { [K in keyof IClientOutput]: K extends keyof IServerEvents ? IServerEvents[K] : ProcedureLike<IClientInput, Id<Pick<IClientOutput, K>>> }[keyof IClientOutput] : never } & IServerEvents> : never;
|
|
241
|
+
//#endregion
|
|
242
|
+
//#region src/pluv/room.d.ts
|
|
273
243
|
interface AuthorizationState<TIO extends IOLike> {
|
|
274
|
-
|
|
275
|
-
|
|
244
|
+
token: string | null;
|
|
245
|
+
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>> | null;
|
|
276
246
|
}
|
|
277
247
|
type OtherSubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>> = (value: Id<UserInfo<TIO, TPresence>> | null) => void;
|
|
278
248
|
type OtherSubscriptionFn<TIO extends IOLike, TPresence extends Record<string, any>> = (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => () => void;
|
|
279
249
|
type OthersSubscriptionEvent<TIO extends IOLike, TPresence extends Record<string, any>> = {
|
|
280
|
-
|
|
250
|
+
kind: "clear";
|
|
281
251
|
} | {
|
|
282
|
-
|
|
283
|
-
|
|
252
|
+
kind: "enter";
|
|
253
|
+
user: Id<UserInfo<TIO, TPresence>>;
|
|
284
254
|
} | {
|
|
285
|
-
|
|
286
|
-
|
|
255
|
+
kind: "leave";
|
|
256
|
+
user: Id<UserInfo<TIO, TPresence>>;
|
|
287
257
|
} | {
|
|
288
|
-
|
|
289
|
-
|
|
258
|
+
kind: "sync";
|
|
259
|
+
users: readonly Id<UserInfo<TIO, TPresence>>[];
|
|
290
260
|
} | {
|
|
291
|
-
|
|
292
|
-
|
|
261
|
+
kind: "update";
|
|
262
|
+
user: Id<UserInfo<TIO, TPresence>>;
|
|
293
263
|
};
|
|
294
264
|
type OthersSubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>> = (value: readonly Id<UserInfo<TIO, TPresence>>[], event: OthersSubscriptionEvent<TIO, TPresence>) => void;
|
|
295
265
|
type OthersSubscriptionFn<TIO extends IOLike, TPresence extends Record<string, any>> = (callback: OthersSubscriptionCallback<TIO, TPresence>) => () => void;
|
|
296
266
|
interface StateNotifierSubjects<TIO extends IOLike, TPresence extends Record<string, any>> {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
267
|
+
connection: Subject<Id<WebSocketState<TIO>>>;
|
|
268
|
+
"my-presence": Subject<TPresence | null>;
|
|
269
|
+
myself: Subject<Readonly<Id<UserInfo<TIO, TPresence>>> | null>;
|
|
270
|
+
others: Subject<readonly Id<UserInfo<TIO, TPresence>>[]>;
|
|
271
|
+
"storage-loaded": Subject<boolean>;
|
|
302
272
|
}
|
|
303
273
|
type InferSubjectValue<TIO extends IOLike, TPresence extends Record<string, any>, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = StateNotifierSubjects<TIO, TPresence>[TSubject] extends Subject<infer IValue> ? Id<IValue> : never;
|
|
304
274
|
type SubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = (value: InferSubjectValue<TIO, TPresence, TSubject>) => void;
|
|
305
275
|
type UpdateMyPresenceAction<TPresence extends Record<string, any>> = Partial<TPresence> | ((oldPresence: TPresence | null) => Partial<TPresence>);
|
|
306
276
|
interface UserInfo<TIO extends IOLike, TPresence extends Record<string, any> = {}> {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
277
|
+
connectionId: string;
|
|
278
|
+
presence: TPresence;
|
|
279
|
+
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
310
280
|
}
|
|
311
281
|
interface WebSocketConnection {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
282
|
+
/**
|
|
283
|
+
* @description How many times a connection attempt was made. This will increment upon each
|
|
284
|
+
* unsuccessful attempt, and will reset upon a successful connection.
|
|
285
|
+
* @date April 13, 2025
|
|
286
|
+
*/
|
|
287
|
+
attempts: number;
|
|
288
|
+
id: string | null;
|
|
289
|
+
state: ConnectionState;
|
|
320
290
|
}
|
|
321
291
|
interface StorageInfo {
|
|
322
|
-
|
|
292
|
+
state: StorageState;
|
|
323
293
|
}
|
|
324
294
|
interface WebSocketState<TIO extends IOLike> {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
295
|
+
authorization: AuthorizationState<TIO>;
|
|
296
|
+
connection: WebSocketConnection;
|
|
297
|
+
storage: StorageInfo;
|
|
298
|
+
webSocket: WebSocket | null;
|
|
329
299
|
}
|
|
330
|
-
type BroadcastProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & {
|
|
331
|
-
[PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>) => Promise<void>;
|
|
332
|
-
};
|
|
300
|
+
type BroadcastProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & { [PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>) => Promise<void> };
|
|
333
301
|
type EventNotifierSubscriptionCallback<TIO extends IOLike<any, any, any>, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
|
|
334
302
|
type EventSubscriptionFn<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = <TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void;
|
|
335
|
-
type EventProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = EventSubscriptionFn<TIO, TEvents> & {
|
|
336
|
-
[PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>) => () => void;
|
|
337
|
-
};
|
|
303
|
+
type EventProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = EventSubscriptionFn<TIO, TEvents> & { [PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>) => () => void };
|
|
338
304
|
type StorageSubscriptionCallback<TStorage extends Record<string, CrdtType<any, any>>, TKey extends keyof TStorage> = (value: InferCrdtJson<TStorage[TKey]>) => void;
|
|
339
305
|
type StorageSubscriptionFn<TStorage extends Record<string, CrdtType<any, any>>> = <TKey extends keyof TStorage>(key: TKey, fn: StorageSubscriptionCallback<TStorage, TKey>) => () => void;
|
|
340
|
-
type StorageRootSubscriptionCallback<TStorage extends Record<string, CrdtType<any, any>>> = (value: {
|
|
341
|
-
[P in keyof TStorage]: InferCrdtJson<TStorage[P]>;
|
|
342
|
-
}) => void;
|
|
306
|
+
type StorageRootSubscriptionCallback<TStorage extends Record<string, CrdtType<any, any>>> = (value: { [P in keyof TStorage]: InferCrdtJson<TStorage[P]> }) => void;
|
|
343
307
|
type StorageRootSubscriptionFn<TStorage extends Record<string, CrdtType<any, any>>> = (callback: StorageRootSubscriptionCallback<TStorage>) => () => void;
|
|
344
|
-
type StorageProxy<TStorage extends Record<string, CrdtType<any, any>>> = StorageSubscriptionFn<TStorage> & StorageRootSubscriptionFn<TStorage> & {
|
|
345
|
-
[PKey in keyof TStorage]: (callback: StorageSubscriptionCallback<TStorage, PKey>) => () => void;
|
|
346
|
-
};
|
|
308
|
+
type StorageProxy<TStorage extends Record<string, CrdtType<any, any>>> = StorageSubscriptionFn<TStorage> & StorageRootSubscriptionFn<TStorage> & { [PKey in keyof TStorage]: (callback: StorageSubscriptionCallback<TStorage, PKey>) => () => void };
|
|
347
309
|
type SubscribeFn<TValue extends unknown> = (callback: (value: TValue) => void) => () => void;
|
|
348
310
|
type SubscribeProxy<TIO extends IOLike, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType<any, any>>, TEvents extends PluvRouterEventConfig> = (<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => () => void) & {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
311
|
+
connection: SubscribeFn<Id<WebSocketState<TIO>>>;
|
|
312
|
+
event: EventProxy<TIO, TEvents>;
|
|
313
|
+
myPresence: SubscribeFn<TPresence | null>;
|
|
314
|
+
myself: SubscribeFn<Id<UserInfo<TIO>> | null>;
|
|
315
|
+
other: OtherSubscriptionFn<TIO, TPresence>;
|
|
316
|
+
others: OthersSubscriptionFn<TIO, TPresence>;
|
|
317
|
+
storage: StorageProxy<TStorage>;
|
|
318
|
+
storageLoaded: SubscribeFn<boolean>;
|
|
357
319
|
};
|
|
358
320
|
interface RoomEventListenerMap {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
321
|
+
close: (event: CloseEvent | null) => void;
|
|
322
|
+
error: (event: Event) => void;
|
|
323
|
+
message: (event: MessageEvent<any>) => void;
|
|
324
|
+
open: (event: Event) => void;
|
|
363
325
|
}
|
|
364
326
|
interface RoomLike<TIO extends IOLike, TDoc extends any, TPresence extends Record<string, any> = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig = {}> {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
327
|
+
id: string;
|
|
328
|
+
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
329
|
+
addEventListener<TKind extends keyof RoomEventListenerMap>(kind: TKind, handler: RoomEventListenerMap[TKind]): () => void;
|
|
330
|
+
canRedo(): boolean;
|
|
331
|
+
canUndo(): boolean;
|
|
332
|
+
getDoc(): CrdtDocLike<TDoc, TStorage>;
|
|
333
|
+
getConnection(): WebSocketConnection;
|
|
334
|
+
getMyPresence(): TPresence;
|
|
335
|
+
getMyself(): Id<UserInfo<TIO, TPresence>> | null;
|
|
336
|
+
getOther(connectionId: string): Id<UserInfo<TIO, TPresence>> | null;
|
|
337
|
+
getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
|
|
338
|
+
getStorage<TKey extends keyof TStorage>(type: TKey): TStorage[TKey] | null;
|
|
339
|
+
getStorageJson(): InferCrdtJson<TStorage> | null;
|
|
340
|
+
getStorageJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]> | null;
|
|
341
|
+
getStorageLoaded: () => boolean;
|
|
342
|
+
redo(): void;
|
|
343
|
+
subscribe: SubscribeProxy<TIO, TPresence, TStorage, TEvents>;
|
|
344
|
+
transact(fn: (storage: TStorage) => void, origin?: string): void;
|
|
345
|
+
undo(): void;
|
|
346
|
+
updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
|
|
385
347
|
}
|
|
386
|
-
|
|
387
|
-
export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdt, type InferIOCrdtKind, type InferIOEvents, type InferIOInput, type InferIOOutput, type InferIOProcedureInput, type InferIOProcedureOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
|
|
348
|
+
//#endregion
|
|
349
|
+
export { type AreAllOptional, type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdt, type InferIOCrdtKind, type InferIOEvents, type InferIOInput, type InferIOOutput, type InferIOProcedureInput, type InferIOProcedureOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
|
|
350
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/general.ts","../src/pluv/crdt.ts","../src/pluv/enums.ts","../src/pluv/shared.ts","../src/pluv/room.ts"],"mappings":";;;KAAY,aAAA;EAAA,QAA0B,IAAA;AAAA;AAAA,KAE1B,mBAAA,oBACI,CAAA,gBAAiB,IAAA,CAAK,CAAA,EAAG,CAAA,YAAa,CAAA,SAC9C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OAAA;EAEpD,QAAA,CAAS,EAAA,GAAK,OAAA,EAAS,QAAA,WAAmB,MAAA;EAE1C,IAAA;EAEA,gBAAA,CAAiB,QAAA,EAAU,sBAAA,CAAuB,SAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/pluv/enums.ts
|
|
2
|
+
const ConnectionState = {
|
|
3
|
+
Closed: "closed",
|
|
4
|
+
Connecting: "connecting",
|
|
5
|
+
Open: "open",
|
|
6
|
+
Unavailable: "unavailable",
|
|
7
|
+
Untouched: "untouched"
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
ConnectionState,
|
|
17
|
-
StorageState
|
|
9
|
+
const StorageState = {
|
|
10
|
+
Loading: "loading",
|
|
11
|
+
Offline: "offline",
|
|
12
|
+
Synced: "synced",
|
|
13
|
+
Unavailable: "unavailable"
|
|
18
14
|
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ConnectionState, StorageState };
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/pluv/enums.ts"],"sourcesContent":["export const ConnectionState = {\n Closed: \"closed\",\n Connecting: \"connecting\",\n Open: \"open\",\n Unavailable: \"unavailable\",\n Untouched: \"untouched\",\n} as const;\n\nexport type ConnectionState = (typeof ConnectionState)[keyof typeof ConnectionState];\n\nexport const StorageState = {\n Loading: \"loading\",\n Offline: \"offline\",\n Synced: \"synced\",\n Unavailable: \"unavailable\",\n};\n\nexport type StorageState = (typeof StorageState)[keyof typeof StorageState];\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC3B,QAAQ;CACR,YAAY;CACZ,MAAM;CACN,aAAa;CACb,WAAW;CACd;AAID,MAAa,eAAe;CACxB,SAAS;CACT,SAAS;CACT,QAAQ;CACR,aAAa;CAChB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "@pluv/io shared types",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "david@pluv.io",
|
|
@@ -14,25 +14,30 @@
|
|
|
14
14
|
"url": "git+https://github.com/pluv-io/pluv.git",
|
|
15
15
|
"directory": "packages/types"
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"types": "./dist/index.d.
|
|
17
|
+
"type": "module",
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"eslint": "^9.
|
|
24
|
-
"
|
|
25
|
-
"typescript": "^5.
|
|
26
|
-
"@pluv/tsconfig": "^
|
|
27
|
-
"eslint-config-pluv": "^
|
|
23
|
+
"eslint": "^9.39.2",
|
|
24
|
+
"tsdown": "0.20.0-beta.4",
|
|
25
|
+
"typescript": "^5.9.3",
|
|
26
|
+
"@pluv/tsconfig": "^4.0.0",
|
|
27
|
+
"eslint-config-pluv": "^4.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"wonka": "^6.3.5"
|
|
31
31
|
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.mjs",
|
|
34
|
+
"./*": "./*"
|
|
35
|
+
},
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "
|
|
34
|
-
"dev": "
|
|
37
|
+
"build": "tsdown",
|
|
38
|
+
"dev": "tsdown --watch",
|
|
35
39
|
"lint": "eslint \"src/**/*.ts*\" --fix --max-warnings 0",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
36
41
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
37
42
|
}
|
|
38
43
|
}
|
package/src/general.ts
CHANGED
|
@@ -76,3 +76,15 @@ export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) e
|
|
|
76
76
|
) => void
|
|
77
77
|
? I
|
|
78
78
|
: never;
|
|
79
|
+
|
|
80
|
+
// Check if all properties in T are optional
|
|
81
|
+
// - If T is {} (no keys), all properties are optional (none exist)
|
|
82
|
+
// - Use HasRequiredProperty which properly handles intersection types
|
|
83
|
+
// - If HasRequiredProperty<T> is false, then all properties are optional
|
|
84
|
+
export type AreAllOptional<T> = [T] extends [{}]
|
|
85
|
+
? keyof T extends never
|
|
86
|
+
? true // T is {} - no properties, so all are "optional" (none exist)
|
|
87
|
+
: HasRequiredProperty<T> extends true
|
|
88
|
+
? false // T has at least one required property
|
|
89
|
+
: true // T has no required properties, so all are optional
|
|
90
|
+
: false;
|
package/src/index.ts
CHANGED
package/tsdown.config.ts
ADDED
package/dist/index.d.ts
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'wonka';
|
|
2
|
-
|
|
3
|
-
type Constructable = {
|
|
4
|
-
new (...args: any[]): any;
|
|
5
|
-
};
|
|
6
|
-
type HasRequiredProperty<T> = {
|
|
7
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
8
|
-
}[keyof T] extends never ? false : true;
|
|
9
|
-
type Maybe<T> = T | Nil;
|
|
10
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
11
|
-
type MaybeReadonlyArray<T> = T[] | readonly T[];
|
|
12
|
-
type Nil = null | undefined;
|
|
13
|
-
type OptionalPropertyNames<T> = {
|
|
14
|
-
[K in keyof T]-?: {} extends {
|
|
15
|
-
[P in K]: T[K];
|
|
16
|
-
} ? K : never;
|
|
17
|
-
}[keyof T];
|
|
18
|
-
type SpreadProperties<L, R, K extends keyof L & keyof R> = {
|
|
19
|
-
[P in K]: L[P] | Exclude<R[P], undefined>;
|
|
20
|
-
};
|
|
21
|
-
type Id<T> = T extends Nil ? T : T extends infer U ? U extends Constructable ? U : {
|
|
22
|
-
[K in keyof U]: U[K];
|
|
23
|
-
} : never;
|
|
24
|
-
type SpreadTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
|
|
25
|
-
type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
|
|
26
|
-
type DeepPartial<T> = {
|
|
27
|
-
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
|
|
28
|
-
};
|
|
29
|
-
type DeepWriteable<T> = {
|
|
30
|
-
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
31
|
-
};
|
|
32
|
-
type UndefinedProps<T extends Record<string, any>, K extends keyof T = keyof T> = Id<{
|
|
33
|
-
[P in K]?: undefined;
|
|
34
|
-
} & {
|
|
35
|
-
[P in Exclude<keyof T, K>]: T[P];
|
|
36
|
-
}>;
|
|
37
|
-
type OptionalProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
38
|
-
type NonNilProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & {
|
|
39
|
-
[P in K]-?: NonNullable<T[P]>;
|
|
40
|
-
};
|
|
41
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
42
|
-
type Json = JsonPrimitive | Json[] | readonly Json[] | {
|
|
43
|
-
[key: string]: Json;
|
|
44
|
-
};
|
|
45
|
-
type JsonObject = Record<string, Json>;
|
|
46
|
-
type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void ? I : never;
|
|
47
|
-
|
|
48
|
-
interface CrdtDocFactory<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
49
|
-
_initialStorage: (builder: any) => TStorage;
|
|
50
|
-
getEmpty(): CrdtDocLike<TDoc, TStorage>;
|
|
51
|
-
getFactory(initialStorage?: (builder: any) => TStorage): CrdtDocFactory<TDoc, TStorage>;
|
|
52
|
-
getInitialized(initialStorage?: (builder: any) => TStorage): CrdtDocLike<TDoc, TStorage>;
|
|
53
|
-
isEmpty(initialStorage: Maybe<string>): boolean;
|
|
54
|
-
}
|
|
55
|
-
interface CrdtLibraryType<TDoc extends CrdtDocFactory<any, any> = CrdtDocFactory<any, any>> {
|
|
56
|
-
doc: (value: any) => TDoc;
|
|
57
|
-
kind: "loro" | "yjs";
|
|
58
|
-
}
|
|
59
|
-
type CrdtType<TValue extends unknown, TJson extends unknown = any> = Omit<TValue, "__pluvType"> & {
|
|
60
|
-
__pluvType: () => TJson;
|
|
61
|
-
};
|
|
62
|
-
type InferCrdtJson<T extends unknown> = T extends CrdtType<any, infer IJson> ? InferCrdtJson<IJson> : T extends Record<string, any> ? {
|
|
63
|
-
[P in keyof T]: InferCrdtJson<T[P]>;
|
|
64
|
-
} : T extends (infer IJson)[] ? InferCrdtJson<IJson>[] : T extends readonly (infer IJson)[] ? readonly InferCrdtJson<IJson>[] : T extends Json ? T : string;
|
|
65
|
-
interface DocApplyEncodedStateParams {
|
|
66
|
-
origin?: string;
|
|
67
|
-
update?: Maybe<string | Uint8Array>;
|
|
68
|
-
}
|
|
69
|
-
interface DocBatchApplyEncodedStateParams {
|
|
70
|
-
origin?: string;
|
|
71
|
-
updates?: Maybe<readonly Maybe<string | Uint8Array>[]>;
|
|
72
|
-
}
|
|
73
|
-
interface DocSubscribeCallbackParams<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
74
|
-
doc: CrdtDocLike<TDoc, TStorage>;
|
|
75
|
-
local: boolean;
|
|
76
|
-
origin?: string | null;
|
|
77
|
-
update: string;
|
|
78
|
-
}
|
|
79
|
-
interface CrdtDocLike<TDoc extends any, TStorage extends Record<string, CrdtType<any, any>>> {
|
|
80
|
-
value: TDoc;
|
|
81
|
-
applyEncodedState(params: DocApplyEncodedStateParams): this;
|
|
82
|
-
batchApplyEncodedState(params: DocBatchApplyEncodedStateParams): this;
|
|
83
|
-
canRedo(): boolean;
|
|
84
|
-
canUndo(): boolean;
|
|
85
|
-
destroy(): void;
|
|
86
|
-
get(key?: undefined): TStorage;
|
|
87
|
-
get<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
88
|
-
getEncodedState(): string;
|
|
89
|
-
isEmpty(): boolean;
|
|
90
|
-
rebuildStorage(reference: TStorage): this;
|
|
91
|
-
redo(): this;
|
|
92
|
-
subscribe(listener: (params: DocSubscribeCallbackParams<TDoc, TStorage>) => void): () => void;
|
|
93
|
-
toJson(): InferCrdtJson<TStorage>;
|
|
94
|
-
toJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]>;
|
|
95
|
-
track(): this;
|
|
96
|
-
transact(fn: () => void, origin?: string): this;
|
|
97
|
-
undo(): this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
declare const ConnectionState: {
|
|
101
|
-
readonly Closed: "closed";
|
|
102
|
-
readonly Connecting: "connecting";
|
|
103
|
-
readonly Open: "open";
|
|
104
|
-
readonly Unavailable: "unavailable";
|
|
105
|
-
readonly Untouched: "untouched";
|
|
106
|
-
};
|
|
107
|
-
type ConnectionState = (typeof ConnectionState)[keyof typeof ConnectionState];
|
|
108
|
-
declare const StorageState: {
|
|
109
|
-
Loading: string;
|
|
110
|
-
Offline: string;
|
|
111
|
-
Synced: string;
|
|
112
|
-
Unavailable: string;
|
|
113
|
-
};
|
|
114
|
-
type StorageState = (typeof StorageState)[keyof typeof StorageState];
|
|
115
|
-
|
|
116
|
-
type BaseUser = {
|
|
117
|
-
id: string;
|
|
118
|
-
};
|
|
119
|
-
interface BaseClientEventRecord {
|
|
120
|
-
$getOthers: {};
|
|
121
|
-
$initializeSession: {
|
|
122
|
-
presence: JsonObject;
|
|
123
|
-
update: string | null;
|
|
124
|
-
};
|
|
125
|
-
$ping: {};
|
|
126
|
-
$updatePresence: {
|
|
127
|
-
presence: JsonObject;
|
|
128
|
-
};
|
|
129
|
-
$updateStorage: {
|
|
130
|
-
origin: string | null;
|
|
131
|
-
update: string;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
type BaseClientMessage = InferEventMessage<BaseClientEventRecord>;
|
|
135
|
-
type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
|
|
136
|
-
$error: {
|
|
137
|
-
message: string;
|
|
138
|
-
stack?: string | null;
|
|
139
|
-
};
|
|
140
|
-
$exit: {
|
|
141
|
-
sessionId: string;
|
|
142
|
-
};
|
|
143
|
-
$othersReceived: {
|
|
144
|
-
others: {
|
|
145
|
-
[connectionId: string]: {
|
|
146
|
-
connectionId: string;
|
|
147
|
-
presence: JsonObject | null;
|
|
148
|
-
room: string | null;
|
|
149
|
-
timers: {
|
|
150
|
-
presence: number | null;
|
|
151
|
-
};
|
|
152
|
-
user: Id<InferIOAuthorizeUser<TAuthorize>>;
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
$pong: {};
|
|
157
|
-
$presenceUpdated: {
|
|
158
|
-
presence: JsonObject;
|
|
159
|
-
timers: {
|
|
160
|
-
presence: number | null;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
$registered: {
|
|
164
|
-
presence: JsonObject | null;
|
|
165
|
-
sessionId: string;
|
|
166
|
-
state: string | null;
|
|
167
|
-
timers: {
|
|
168
|
-
presence: number | null;
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
$storageReceived: {
|
|
172
|
-
changeKind: "empty" | "initialized" | "unchanged";
|
|
173
|
-
state: string;
|
|
174
|
-
};
|
|
175
|
-
$storageUpdated: {
|
|
176
|
-
state: string;
|
|
177
|
-
};
|
|
178
|
-
$syncStateReceived: {
|
|
179
|
-
connectionIds: readonly string[];
|
|
180
|
-
};
|
|
181
|
-
$userJoined: {
|
|
182
|
-
connectionId: string;
|
|
183
|
-
presence: JsonObject;
|
|
184
|
-
timers: {
|
|
185
|
-
presence: number | null;
|
|
186
|
-
};
|
|
187
|
-
user: NonNullable<Id<InferIOAuthorizeUser<TAuthorize>>>;
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
interface EventMessage<TEvent extends string, TData extends JsonObject = {}> {
|
|
191
|
-
data: TData;
|
|
192
|
-
type: TEvent;
|
|
193
|
-
}
|
|
194
|
-
type EventRecord<TEvent extends string, TData extends JsonObject> = {
|
|
195
|
-
[key in `${TEvent}`]: TData;
|
|
196
|
-
};
|
|
197
|
-
type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
|
|
198
|
-
type InferIOAuthorize<TIO extends IOLike<any, any, any>> = TIO extends IOLike<infer IAuthorize, any, any> ? InferIOAuthorizeUser<IAuthorize> extends BaseUser ? {
|
|
199
|
-
user: InputZodLike<InferIOAuthorizeUser<IAuthorize>>;
|
|
200
|
-
} : null : never;
|
|
201
|
-
type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> = TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
|
|
202
|
-
type InputZodLike<TData extends JsonObject> = {
|
|
203
|
-
parse: (data: unknown) => TData;
|
|
204
|
-
} & ({
|
|
205
|
-
_input: TData;
|
|
206
|
-
} | {
|
|
207
|
-
_zod: {
|
|
208
|
-
input: TData;
|
|
209
|
-
};
|
|
210
|
-
});
|
|
211
|
-
type IOAuthorize<TUser extends BaseUser | null = any, TContext extends Record<string, unknown> = {}> = (TUser extends BaseUser ? {
|
|
212
|
-
secret?: string;
|
|
213
|
-
user: InputZodLike<TUser>;
|
|
214
|
-
} : null) | ((context: TContext) => TUser extends BaseUser ? {
|
|
215
|
-
secret?: string;
|
|
216
|
-
user: InputZodLike<TUser>;
|
|
217
|
-
} : null);
|
|
218
|
-
type IOAuthorizeEventMessage<TIO extends IOLike> = {
|
|
219
|
-
connectionId: string;
|
|
220
|
-
user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
|
|
221
|
-
};
|
|
222
|
-
type ProcedureLike<TInput extends Record<string, any> = {}, TOutput extends EventRecord<string, any> = {}> = {
|
|
223
|
-
config: {
|
|
224
|
-
broadcast?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
225
|
-
input?: InputZodLike<TInput> | null;
|
|
226
|
-
resolver: (data: TInput, ...args: any[]) => MaybePromise<TOutput>;
|
|
227
|
-
self?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
228
|
-
sync?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
|
|
229
|
-
};
|
|
230
|
-
};
|
|
231
|
-
interface IORouterLike<TEvents extends Record<string, ProcedureLike<any, any>> = {}> {
|
|
232
|
-
_defs: {
|
|
233
|
-
events: TEvents;
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
interface IOLike<TAuthorize extends IOAuthorize<any, any> | null = null, TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<any>, TEvents extends Record<string, ProcedureLike<any, any>> = {}> extends IORouterLike<TEvents> {
|
|
237
|
-
_defs: {
|
|
238
|
-
authorize: TAuthorize;
|
|
239
|
-
crdt: TCrdt;
|
|
240
|
-
events: TEvents;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
type InferIOCrdtKind<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt extends CrdtLibraryType<infer IDoc> ? IDoc : never : never;
|
|
244
|
-
type InferIOCrdt<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, infer ICrdt, any> ? ICrdt : never;
|
|
245
|
-
type InferIOEvents<TIO extends IOLike<any, any, any>> = TIO extends IOLike<any, any, infer IEvents> ? {
|
|
246
|
-
[P in keyof IEvents]: ProcedureLike<InferIOProcedureInput<IEvents[P]>, InferIOProcedureOutput<IEvents[P]>>;
|
|
247
|
-
} : never;
|
|
248
|
-
type InferIOProcedureInput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
|
|
249
|
-
type InferIOProcedureOutput<TProcedure extends ProcedureLike<any, any>> = TProcedure extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
|
|
250
|
-
type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, any>>> = {
|
|
251
|
-
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? Id<IInput> : never;
|
|
252
|
-
};
|
|
253
|
-
type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<{
|
|
254
|
-
[P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? Id<IOutput> : never;
|
|
255
|
-
}[keyof TEvents]>;
|
|
256
|
-
type InferIOInput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
|
|
257
|
-
type InferIOOutput<TRouter extends IORouterLike<any>> = TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
|
|
258
|
-
type InferEventMessage<TEvents = EventRecord<string, any>, TEvent extends keyof TEvents = keyof TEvents> = TEvents extends EventRecord<string, any> ? {
|
|
259
|
-
[P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never;
|
|
260
|
-
}[TEvent] : never;
|
|
261
|
-
type IOEventMessage<TIO extends IOLike<any, any, any>, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = Id<{
|
|
262
|
-
room: string;
|
|
263
|
-
} & InferEventMessage<InferIOOutput<TIO>, TEvent> & (InferEventMessage<InferIOOutput<TIO>, TEvent>["type"] extends "$error" ? Partial<IOAuthorizeEventMessage<TIO>> : IOAuthorizeEventMessage<TIO>)>;
|
|
264
|
-
type PluvRouterEventConfig = {
|
|
265
|
-
[P: string]: Pick<ProcedureLike<any, any>, "config">;
|
|
266
|
-
};
|
|
267
|
-
type MergeEvents<TClientEvents extends PluvRouterEventConfig, TServerIO extends IOLike<any, any, any>> = TServerIO extends IOLike<infer IAuthorize, infer ICrdt, infer IServerEvents> ? IOLike<IAuthorize, ICrdt, {
|
|
268
|
-
[P in keyof TClientEvents]: TClientEvents[P] extends ProcedureLike<infer IClientInput, infer IClientOutput> ? {
|
|
269
|
-
[K in keyof IClientOutput]: K extends keyof IServerEvents ? IServerEvents[K] : ProcedureLike<IClientInput, Id<Pick<IClientOutput, K>>>;
|
|
270
|
-
}[keyof IClientOutput] : never;
|
|
271
|
-
} & IServerEvents> : never;
|
|
272
|
-
|
|
273
|
-
interface AuthorizationState<TIO extends IOLike> {
|
|
274
|
-
token: string | null;
|
|
275
|
-
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>> | null;
|
|
276
|
-
}
|
|
277
|
-
type OtherSubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>> = (value: Id<UserInfo<TIO, TPresence>> | null) => void;
|
|
278
|
-
type OtherSubscriptionFn<TIO extends IOLike, TPresence extends Record<string, any>> = (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => () => void;
|
|
279
|
-
type OthersSubscriptionEvent<TIO extends IOLike, TPresence extends Record<string, any>> = {
|
|
280
|
-
kind: "clear";
|
|
281
|
-
} | {
|
|
282
|
-
kind: "enter";
|
|
283
|
-
user: Id<UserInfo<TIO, TPresence>>;
|
|
284
|
-
} | {
|
|
285
|
-
kind: "leave";
|
|
286
|
-
user: Id<UserInfo<TIO, TPresence>>;
|
|
287
|
-
} | {
|
|
288
|
-
kind: "sync";
|
|
289
|
-
users: readonly Id<UserInfo<TIO, TPresence>>[];
|
|
290
|
-
} | {
|
|
291
|
-
kind: "update";
|
|
292
|
-
user: Id<UserInfo<TIO, TPresence>>;
|
|
293
|
-
};
|
|
294
|
-
type OthersSubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>> = (value: readonly Id<UserInfo<TIO, TPresence>>[], event: OthersSubscriptionEvent<TIO, TPresence>) => void;
|
|
295
|
-
type OthersSubscriptionFn<TIO extends IOLike, TPresence extends Record<string, any>> = (callback: OthersSubscriptionCallback<TIO, TPresence>) => () => void;
|
|
296
|
-
interface StateNotifierSubjects<TIO extends IOLike, TPresence extends Record<string, any>> {
|
|
297
|
-
connection: Subject<Id<WebSocketState<TIO>>>;
|
|
298
|
-
"my-presence": Subject<TPresence | null>;
|
|
299
|
-
myself: Subject<Readonly<Id<UserInfo<TIO, TPresence>>> | null>;
|
|
300
|
-
others: Subject<readonly Id<UserInfo<TIO, TPresence>>[]>;
|
|
301
|
-
"storage-loaded": Subject<boolean>;
|
|
302
|
-
}
|
|
303
|
-
type InferSubjectValue<TIO extends IOLike, TPresence extends Record<string, any>, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = StateNotifierSubjects<TIO, TPresence>[TSubject] extends Subject<infer IValue> ? Id<IValue> : never;
|
|
304
|
-
type SubscriptionCallback<TIO extends IOLike, TPresence extends Record<string, any>, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = (value: InferSubjectValue<TIO, TPresence, TSubject>) => void;
|
|
305
|
-
type UpdateMyPresenceAction<TPresence extends Record<string, any>> = Partial<TPresence> | ((oldPresence: TPresence | null) => Partial<TPresence>);
|
|
306
|
-
interface UserInfo<TIO extends IOLike, TPresence extends Record<string, any> = {}> {
|
|
307
|
-
connectionId: string;
|
|
308
|
-
presence: TPresence;
|
|
309
|
-
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
310
|
-
}
|
|
311
|
-
interface WebSocketConnection {
|
|
312
|
-
/**
|
|
313
|
-
* @description How many times a connection attempt was made. This will increment upon each
|
|
314
|
-
* unsuccessful attempt, and will reset upon a successful connection.
|
|
315
|
-
* @date April 13, 2025
|
|
316
|
-
*/
|
|
317
|
-
attempts: number;
|
|
318
|
-
id: string | null;
|
|
319
|
-
state: ConnectionState;
|
|
320
|
-
}
|
|
321
|
-
interface StorageInfo {
|
|
322
|
-
state: StorageState;
|
|
323
|
-
}
|
|
324
|
-
interface WebSocketState<TIO extends IOLike> {
|
|
325
|
-
authorization: AuthorizationState<TIO>;
|
|
326
|
-
connection: WebSocketConnection;
|
|
327
|
-
storage: StorageInfo;
|
|
328
|
-
webSocket: WebSocket | null;
|
|
329
|
-
}
|
|
330
|
-
type BroadcastProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & {
|
|
331
|
-
[PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>) => Promise<void>;
|
|
332
|
-
};
|
|
333
|
-
type EventNotifierSubscriptionCallback<TIO extends IOLike<any, any, any>, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
|
|
334
|
-
type EventSubscriptionFn<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = <TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void;
|
|
335
|
-
type EventProxy<TIO extends IOLike, TEvents extends PluvRouterEventConfig> = EventSubscriptionFn<TIO, TEvents> & {
|
|
336
|
-
[PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>) => () => void;
|
|
337
|
-
};
|
|
338
|
-
type StorageSubscriptionCallback<TStorage extends Record<string, CrdtType<any, any>>, TKey extends keyof TStorage> = (value: InferCrdtJson<TStorage[TKey]>) => void;
|
|
339
|
-
type StorageSubscriptionFn<TStorage extends Record<string, CrdtType<any, any>>> = <TKey extends keyof TStorage>(key: TKey, fn: StorageSubscriptionCallback<TStorage, TKey>) => () => void;
|
|
340
|
-
type StorageRootSubscriptionCallback<TStorage extends Record<string, CrdtType<any, any>>> = (value: {
|
|
341
|
-
[P in keyof TStorage]: InferCrdtJson<TStorage[P]>;
|
|
342
|
-
}) => void;
|
|
343
|
-
type StorageRootSubscriptionFn<TStorage extends Record<string, CrdtType<any, any>>> = (callback: StorageRootSubscriptionCallback<TStorage>) => () => void;
|
|
344
|
-
type StorageProxy<TStorage extends Record<string, CrdtType<any, any>>> = StorageSubscriptionFn<TStorage> & StorageRootSubscriptionFn<TStorage> & {
|
|
345
|
-
[PKey in keyof TStorage]: (callback: StorageSubscriptionCallback<TStorage, PKey>) => () => void;
|
|
346
|
-
};
|
|
347
|
-
type SubscribeFn<TValue extends unknown> = (callback: (value: TValue) => void) => () => void;
|
|
348
|
-
type SubscribeProxy<TIO extends IOLike, TPresence extends Record<string, any>, TStorage extends Record<string, CrdtType<any, any>>, TEvents extends PluvRouterEventConfig> = (<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => () => void) & {
|
|
349
|
-
connection: SubscribeFn<Id<WebSocketState<TIO>>>;
|
|
350
|
-
event: EventProxy<TIO, TEvents>;
|
|
351
|
-
myPresence: SubscribeFn<TPresence | null>;
|
|
352
|
-
myself: SubscribeFn<Id<UserInfo<TIO>> | null>;
|
|
353
|
-
other: OtherSubscriptionFn<TIO, TPresence>;
|
|
354
|
-
others: OthersSubscriptionFn<TIO, TPresence>;
|
|
355
|
-
storage: StorageProxy<TStorage>;
|
|
356
|
-
storageLoaded: SubscribeFn<boolean>;
|
|
357
|
-
};
|
|
358
|
-
interface RoomEventListenerMap {
|
|
359
|
-
close: (event: CloseEvent | null) => void;
|
|
360
|
-
error: (event: Event) => void;
|
|
361
|
-
message: (event: MessageEvent<any>) => void;
|
|
362
|
-
open: (event: Event) => void;
|
|
363
|
-
}
|
|
364
|
-
interface RoomLike<TIO extends IOLike, TDoc extends any, TPresence extends Record<string, any> = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TEvents extends PluvRouterEventConfig = {}> {
|
|
365
|
-
id: string;
|
|
366
|
-
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
367
|
-
addEventListener<TKind extends keyof RoomEventListenerMap>(kind: TKind, handler: RoomEventListenerMap[TKind]): () => void;
|
|
368
|
-
canRedo(): boolean;
|
|
369
|
-
canUndo(): boolean;
|
|
370
|
-
getDoc(): CrdtDocLike<TDoc, TStorage>;
|
|
371
|
-
getConnection(): WebSocketConnection;
|
|
372
|
-
getMyPresence(): TPresence;
|
|
373
|
-
getMyself(): Id<UserInfo<TIO, TPresence>> | null;
|
|
374
|
-
getOther(connectionId: string): Id<UserInfo<TIO, TPresence>> | null;
|
|
375
|
-
getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
|
|
376
|
-
getStorage<TKey extends keyof TStorage>(type: TKey): TStorage[TKey] | null;
|
|
377
|
-
getStorageJson(): InferCrdtJson<TStorage> | null;
|
|
378
|
-
getStorageJson<TKey extends keyof TStorage>(type: TKey): InferCrdtJson<TStorage[TKey]> | null;
|
|
379
|
-
getStorageLoaded: () => boolean;
|
|
380
|
-
redo(): void;
|
|
381
|
-
subscribe: SubscribeProxy<TIO, TPresence, TStorage, TEvents>;
|
|
382
|
-
transact(fn: (storage: TStorage) => void, origin?: string): void;
|
|
383
|
-
undo(): void;
|
|
384
|
-
updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export { type BaseClientEventRecord, type BaseClientMessage, type BaseIOEventRecord, type BaseUser, type BroadcastProxy, ConnectionState, type Constructable, type CrdtDocFactory, type CrdtDocLike, type CrdtLibraryType, type CrdtType, type DeepPartial, type DeepWriteable, type DocApplyEncodedStateParams, type DocBatchApplyEncodedStateParams, type DocSubscribeCallbackParams, type EventMessage, type EventNotifierSubscriptionCallback, type EventProxy, type EventRecord, type GetEventMessage, type HasRequiredProperty, type IOAuthorize, type IOAuthorizeEventMessage, type IOEventMessage, type IOLike, type IORouterLike, type Id, type InferCrdtJson, type InferEventMessage, type InferEventsInput, type InferEventsOutput, type InferIOAuthorize, type InferIOAuthorizeUser, type InferIOCrdt, type InferIOCrdtKind, type InferIOEvents, type InferIOInput, type InferIOOutput, type InferIOProcedureInput, type InferIOProcedureOutput, type InputZodLike, type Json, type JsonObject, type JsonPrimitive, type Maybe, type MaybePromise, type MaybeReadonlyArray, type MergeEvents, type NonNilProps, type OptionalProps, type OtherSubscriptionCallback, type OtherSubscriptionFn, type OthersSubscriptionCallback, type OthersSubscriptionEvent, type OthersSubscriptionFn, type PluvRouterEventConfig, type ProcedureLike, type RoomEventListenerMap, type RoomLike, type Spread, type SpreadProperties, type StateNotifierSubjects, type StorageInfo, type StorageProxy, type StorageRootSubscriptionCallback, type StorageRootSubscriptionFn, StorageState, type StorageSubscriptionCallback, type StorageSubscriptionFn, type SubscribeFn, type SubscribeProxy, type SubscriptionCallback, type UndefinedProps, type UpdateMyPresenceAction, type UserInfo, type WebSocketConnection, type WebSocketState };
|
package/dist/index.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
ConnectionState: () => ConnectionState,
|
|
24
|
-
StorageState: () => StorageState
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
|
-
// src/pluv/enums.ts
|
|
29
|
-
var ConnectionState = {
|
|
30
|
-
Closed: "closed",
|
|
31
|
-
Connecting: "connecting",
|
|
32
|
-
Open: "open",
|
|
33
|
-
Unavailable: "unavailable",
|
|
34
|
-
Untouched: "untouched"
|
|
35
|
-
};
|
|
36
|
-
var StorageState = {
|
|
37
|
-
Loading: "loading",
|
|
38
|
-
Offline: "offline",
|
|
39
|
-
Synced: "synced",
|
|
40
|
-
Unavailable: "unavailable"
|
|
41
|
-
};
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
ConnectionState,
|
|
45
|
-
StorageState
|
|
46
|
-
});
|