@pluv/client 0.18.0 → 0.19.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 +15 -15
- package/CHANGELOG.md +24 -0
- package/dist/index.d.mts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +93 -172
- package/dist/index.mjs +93 -172
- package/package.json +6 -6
- package/src/AbstractRoom.ts +2 -2
- package/src/MockedRoom.ts +13 -5
- package/src/OtherNotifier.ts +2 -6
- package/src/PluvRoom.ts +17 -10
- package/src/types.ts +10 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@0.
|
|
2
|
+
> @pluv/client@0.19.0 build /home/runner/work/pluv/pluv/packages/client
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
CLI Building entry: src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.1.0
|
|
8
|
+
CLI Target: es6
|
|
9
|
+
ESM Build start
|
|
10
|
+
CJS Build start
|
|
11
|
+
ESM dist/index.mjs 40.97 KB
|
|
12
|
+
ESM ⚡️ Build success in 85ms
|
|
13
|
+
CJS dist/index.js 42.24 KB
|
|
14
|
+
CJS ⚡️ Build success in 108ms
|
|
15
|
+
DTS Build start
|
|
16
|
+
DTS ⚡️ Build success in 3379ms
|
|
17
|
+
DTS dist/index.d.mts 14.33 KB
|
|
18
|
+
DTS dist/index.d.ts 14.33 KB
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 137444b: Updated PluvRoom.updateMyPresence to allow passing in a callback function that exposes the previous presence value and returns a presence update.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
type Presence = {
|
|
11
|
+
selectionId: string | null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const room: PluvRoom = /* ... */;
|
|
15
|
+
const newSelectionId: string | null = /* ... */;
|
|
16
|
+
|
|
17
|
+
room.updateMyPresence({ selectionId: newSelection });
|
|
18
|
+
|
|
19
|
+
// You can reference the previous presence and return a new presence based on it
|
|
20
|
+
room.updateMyPresence((previousPresence) => ({ selectionId: newSelection ?? previousPresence.selectionId }));
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- f5e4370: Fix others' presence not getting tracked in PluvRoom when the user is unauthorized.
|
|
24
|
+
- @pluv/crdt@0.19.0
|
|
25
|
+
- @pluv/types@0.19.0
|
|
26
|
+
|
|
3
27
|
## 0.18.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -18,6 +18,12 @@ declare enum ConnectionState {
|
|
|
18
18
|
Unavailable = "Unavailable",
|
|
19
19
|
Untouched = "Untouched"
|
|
20
20
|
}
|
|
21
|
+
type UpdateMyPresenceAction<TPresence extends JsonObject> = Partial<TPresence> | ((oldPresence: TPresence | null) => Partial<TPresence>);
|
|
22
|
+
interface UserInfo<TIO extends IOLike, TPresence extends JsonObject = {}> {
|
|
23
|
+
connectionId: string;
|
|
24
|
+
presence: TPresence;
|
|
25
|
+
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
26
|
+
}
|
|
21
27
|
interface WebSocketConnection {
|
|
22
28
|
count: number;
|
|
23
29
|
id: string | null;
|
|
@@ -28,11 +34,6 @@ interface WebSocketState<TIO extends IOLike> {
|
|
|
28
34
|
connection: WebSocketConnection;
|
|
29
35
|
webSocket: WebSocket | null;
|
|
30
36
|
}
|
|
31
|
-
interface UserInfo<TIO extends IOLike, TPresence extends JsonObject = {}> {
|
|
32
|
-
connectionId: string;
|
|
33
|
-
presence: TPresence;
|
|
34
|
-
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
35
|
-
}
|
|
36
37
|
|
|
37
38
|
type OtherNotifierSubscriptionCallback<TIO extends IOLike> = (value: Id<UserInfo<TIO>> | null) => void;
|
|
38
39
|
|
|
@@ -70,7 +71,7 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
|
|
|
70
71
|
abstract subscribe<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>): () => void;
|
|
71
72
|
abstract transact(fn: (storage: TStorage) => void, origin?: string): void;
|
|
72
73
|
abstract undo(): void;
|
|
73
|
-
abstract updateMyPresence(presence:
|
|
74
|
+
abstract updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
declare abstract class AbstractStorageStore {
|
|
@@ -116,7 +117,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
116
117
|
canRedo: () => boolean;
|
|
117
118
|
canUndo: () => boolean;
|
|
118
119
|
event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
|
|
119
|
-
getConnection()
|
|
120
|
+
getConnection: () => WebSocketConnection;
|
|
120
121
|
getDoc(): AbstractCrdtDoc<TStorage>;
|
|
121
122
|
getMyPresence: () => TPresence;
|
|
122
123
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
@@ -130,7 +131,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
130
131
|
subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
|
|
131
132
|
transact: (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
132
133
|
undo: () => void;
|
|
133
|
-
updateMyPresence: (presence:
|
|
134
|
+
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
134
135
|
private _observeCrdt;
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -197,8 +198,8 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
197
198
|
connect(): Promise<void>;
|
|
198
199
|
disconnect(): Promise<void>;
|
|
199
200
|
event: (<TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => () => void) & { [event in keyof InferIOOutput<TIO>]: (callback: EventNotifierSubscriptionCallback<TIO, event>) => () => void; };
|
|
200
|
-
getConnection()
|
|
201
|
-
getDoc()
|
|
201
|
+
getConnection: () => WebSocketConnection;
|
|
202
|
+
getDoc: () => AbstractCrdtDoc<TStorage>;
|
|
202
203
|
getMyPresence: () => TPresence;
|
|
203
204
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
204
205
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
@@ -211,7 +212,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
211
212
|
subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
|
|
212
213
|
transact: (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
213
214
|
undo: () => void;
|
|
214
|
-
updateMyPresence: (presence:
|
|
215
|
+
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
215
216
|
private _addToStorageStore;
|
|
216
217
|
private _applyStorageStore;
|
|
217
218
|
private _attachWindowListeners;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare enum ConnectionState {
|
|
|
18
18
|
Unavailable = "Unavailable",
|
|
19
19
|
Untouched = "Untouched"
|
|
20
20
|
}
|
|
21
|
+
type UpdateMyPresenceAction<TPresence extends JsonObject> = Partial<TPresence> | ((oldPresence: TPresence | null) => Partial<TPresence>);
|
|
22
|
+
interface UserInfo<TIO extends IOLike, TPresence extends JsonObject = {}> {
|
|
23
|
+
connectionId: string;
|
|
24
|
+
presence: TPresence;
|
|
25
|
+
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
26
|
+
}
|
|
21
27
|
interface WebSocketConnection {
|
|
22
28
|
count: number;
|
|
23
29
|
id: string | null;
|
|
@@ -28,11 +34,6 @@ interface WebSocketState<TIO extends IOLike> {
|
|
|
28
34
|
connection: WebSocketConnection;
|
|
29
35
|
webSocket: WebSocket | null;
|
|
30
36
|
}
|
|
31
|
-
interface UserInfo<TIO extends IOLike, TPresence extends JsonObject = {}> {
|
|
32
|
-
connectionId: string;
|
|
33
|
-
presence: TPresence;
|
|
34
|
-
user: Id<InferIOAuthorizeUser<InferIOAuthorize<TIO>>>;
|
|
35
|
-
}
|
|
36
37
|
|
|
37
38
|
type OtherNotifierSubscriptionCallback<TIO extends IOLike> = (value: Id<UserInfo<TIO>> | null) => void;
|
|
38
39
|
|
|
@@ -70,7 +71,7 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
|
|
|
70
71
|
abstract subscribe<TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>): () => void;
|
|
71
72
|
abstract transact(fn: (storage: TStorage) => void, origin?: string): void;
|
|
72
73
|
abstract undo(): void;
|
|
73
|
-
abstract updateMyPresence(presence:
|
|
74
|
+
abstract updateMyPresence(presence: UpdateMyPresenceAction<TPresence>): void;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
declare abstract class AbstractStorageStore {
|
|
@@ -116,7 +117,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
116
117
|
canRedo: () => boolean;
|
|
117
118
|
canUndo: () => boolean;
|
|
118
119
|
event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
|
|
119
|
-
getConnection()
|
|
120
|
+
getConnection: () => WebSocketConnection;
|
|
120
121
|
getDoc(): AbstractCrdtDoc<TStorage>;
|
|
121
122
|
getMyPresence: () => TPresence;
|
|
122
123
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
@@ -130,7 +131,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
130
131
|
subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
|
|
131
132
|
transact: (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
132
133
|
undo: () => void;
|
|
133
|
-
updateMyPresence: (presence:
|
|
134
|
+
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
134
135
|
private _observeCrdt;
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -197,8 +198,8 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
197
198
|
connect(): Promise<void>;
|
|
198
199
|
disconnect(): Promise<void>;
|
|
199
200
|
event: (<TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => () => void) & { [event in keyof InferIOOutput<TIO>]: (callback: EventNotifierSubscriptionCallback<TIO, event>) => () => void; };
|
|
200
|
-
getConnection()
|
|
201
|
-
getDoc()
|
|
201
|
+
getConnection: () => WebSocketConnection;
|
|
202
|
+
getDoc: () => AbstractCrdtDoc<TStorage>;
|
|
202
203
|
getMyPresence: () => TPresence;
|
|
203
204
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
204
205
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
@@ -211,7 +212,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
211
212
|
subscribe: <TSubject extends keyof StateNotifierSubjects<TIO, TPresence>>(name: TSubject, callback: SubscriptionCallback<TIO, TPresence, TSubject>) => (() => void);
|
|
212
213
|
transact: (fn: (storage: TStorage) => void, origin?: string) => void;
|
|
213
214
|
undo: () => void;
|
|
214
|
-
updateMyPresence: (presence:
|
|
215
|
+
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
215
216
|
private _addToStorageStore;
|
|
216
217
|
private _applyStorageStore;
|
|
217
218
|
private _attachWindowListeners;
|