@fluidframework/presence 2.81.1 → 2.82.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/dist/alpha.d.ts +1 -1
- package/dist/exposedUtilityTypes.d.ts +57 -5
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internalUtils.d.ts.map +1 -1
- package/dist/internalUtils.js.map +1 -1
- package/dist/latestMapTypes.d.ts +309 -0
- package/dist/latestMapTypes.d.ts.map +1 -0
- package/dist/latestMapTypes.js +8 -0
- package/dist/latestMapTypes.js.map +1 -0
- package/dist/latestMapValueManager.d.ts +4 -265
- package/dist/latestMapValueManager.d.ts.map +1 -1
- package/dist/latestMapValueManager.js +3 -4
- package/dist/latestMapValueManager.js.map +1 -1
- package/dist/latestTypes.d.ts +149 -0
- package/dist/latestTypes.d.ts.map +1 -0
- package/dist/latestTypes.js +7 -0
- package/dist/latestTypes.js.map +1 -0
- package/dist/latestValueManager.d.ts +1 -144
- package/dist/latestValueManager.d.ts.map +1 -1
- package/dist/latestValueManager.js +4 -5
- package/dist/latestValueManager.js.map +1 -1
- package/dist/latestValueTypes.d.ts +0 -11
- package/dist/latestValueTypes.d.ts.map +1 -1
- package/dist/latestValueTypes.js +0 -36
- package/dist/latestValueTypes.js.map +1 -1
- package/dist/legacy.alpha.d.ts +1 -1
- package/dist/notificationsManager.d.ts +15 -5
- package/dist/notificationsManager.d.ts.map +1 -1
- package/dist/notificationsManager.js +0 -4
- package/dist/notificationsManager.js.map +1 -1
- package/dist/notificationsManagerTypes.d.ts +7 -4
- package/dist/notificationsManagerTypes.d.ts.map +1 -1
- package/dist/notificationsManagerTypes.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/stateFactory.d.ts +2 -2
- package/dist/stateFactory.d.ts.map +1 -1
- package/dist/stateFactory.js.map +1 -1
- package/dist/validatableTypes.d.ts.map +1 -1
- package/dist/validatableTypes.js.map +1 -1
- package/dist/validatedGetter.d.ts +18 -0
- package/dist/validatedGetter.d.ts.map +1 -0
- package/dist/validatedGetter.js +43 -0
- package/dist/validatedGetter.js.map +1 -0
- package/lib/alpha.d.ts +1 -1
- package/lib/exposedUtilityTypes.d.ts +57 -5
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internalUtils.d.ts.map +1 -1
- package/lib/internalUtils.js.map +1 -1
- package/lib/latestMapTypes.d.ts +309 -0
- package/lib/latestMapTypes.d.ts.map +1 -0
- package/lib/latestMapTypes.js +7 -0
- package/lib/latestMapTypes.js.map +1 -0
- package/lib/latestMapValueManager.d.ts +4 -265
- package/lib/latestMapValueManager.d.ts.map +1 -1
- package/lib/latestMapValueManager.js +1 -2
- package/lib/latestMapValueManager.js.map +1 -1
- package/lib/latestTypes.d.ts +149 -0
- package/lib/latestTypes.d.ts.map +1 -0
- package/lib/latestTypes.js +6 -0
- package/lib/latestTypes.js.map +1 -0
- package/lib/latestValueManager.d.ts +1 -144
- package/lib/latestValueManager.d.ts.map +1 -1
- package/lib/latestValueManager.js +1 -2
- package/lib/latestValueManager.js.map +1 -1
- package/lib/latestValueTypes.d.ts +0 -11
- package/lib/latestValueTypes.d.ts.map +1 -1
- package/lib/latestValueTypes.js +1 -34
- package/lib/latestValueTypes.js.map +1 -1
- package/lib/legacy.alpha.d.ts +1 -1
- package/lib/notificationsManager.d.ts +15 -5
- package/lib/notificationsManager.d.ts.map +1 -1
- package/lib/notificationsManager.js +0 -4
- package/lib/notificationsManager.js.map +1 -1
- package/lib/notificationsManagerTypes.d.ts +7 -4
- package/lib/notificationsManagerTypes.d.ts.map +1 -1
- package/lib/notificationsManagerTypes.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/stateFactory.d.ts +2 -2
- package/lib/stateFactory.d.ts.map +1 -1
- package/lib/stateFactory.js.map +1 -1
- package/lib/validatableTypes.d.ts.map +1 -1
- package/lib/validatableTypes.js.map +1 -1
- package/lib/validatedGetter.d.ts +18 -0
- package/lib/validatedGetter.d.ts.map +1 -0
- package/lib/validatedGetter.js +39 -0
- package/lib/validatedGetter.js.map +1 -0
- package/package.json +16 -16
|
@@ -2,247 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type { LatestClientData, LatestData, LatestMetadata, ProxiedValueAccessor, RawValueAccessor, StateSchemaValidator, ValueAccessor } from "./latestValueTypes.js";
|
|
10
|
-
import type { AttendeeId, Attendee, Presence } from "./presence.js";
|
|
11
|
-
/**
|
|
12
|
-
* A validator function that can optionally be provided to do runtime validation
|
|
13
|
-
* of the custom key listed in a {@link LatestMap}.
|
|
14
|
-
*
|
|
15
|
-
* @param unvalidatedKey - The unknown key that should be validated.
|
|
16
|
-
*
|
|
17
|
-
* @returns True if the key is valid.
|
|
18
|
-
*
|
|
19
|
-
* @beta
|
|
20
|
-
*/
|
|
21
|
-
export type KeySchemaValidator<Keys extends string> = (unvalidatedKey: string) => unvalidatedKey is Keys;
|
|
22
|
-
/**
|
|
23
|
-
* Collection of latest known values for a specific {@link Attendee}.
|
|
24
|
-
*
|
|
25
|
-
* @sealed
|
|
26
|
-
* @beta
|
|
27
|
-
*/
|
|
28
|
-
export interface LatestMapClientData<T, Keys extends string, TValueAccessor extends ValueAccessor<T>, SpecificAttendeeId extends AttendeeId = AttendeeId> {
|
|
29
|
-
/**
|
|
30
|
-
* Associated {@link Attendee}.
|
|
31
|
-
*/
|
|
32
|
-
attendee: Attendee<SpecificAttendeeId>;
|
|
33
|
-
/**
|
|
34
|
-
* Map of items for the state.
|
|
35
|
-
*
|
|
36
|
-
* @privateRemarks This could be regular map currently as no Map is
|
|
37
|
-
* stored internally and a new instance is created for every request.
|
|
38
|
-
*/
|
|
39
|
-
items: ReadonlyMap<Keys, LatestData<T, TValueAccessor>>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* State of a single item value, its key, and its metadata.
|
|
43
|
-
*
|
|
44
|
-
* @sealed
|
|
45
|
-
* @beta
|
|
46
|
-
*/
|
|
47
|
-
export interface LatestMapItemUpdatedClientData<T, K extends string, TValueAccessor extends ValueAccessor<T>> extends LatestClientData<T, TValueAccessor> {
|
|
48
|
-
/**
|
|
49
|
-
* Key of the updated item.
|
|
50
|
-
*/
|
|
51
|
-
key: K;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Identifier and metadata for a removed item.
|
|
55
|
-
*
|
|
56
|
-
* @sealed
|
|
57
|
-
* @beta
|
|
58
|
-
*/
|
|
59
|
-
export interface LatestMapItemRemovedClientData<K extends string> {
|
|
60
|
-
/**
|
|
61
|
-
* Associated {@link Attendee}.
|
|
62
|
-
*/
|
|
63
|
-
attendee: Attendee;
|
|
64
|
-
/**
|
|
65
|
-
* Key of the removed item.
|
|
66
|
-
*/
|
|
67
|
-
key: K;
|
|
68
|
-
/**
|
|
69
|
-
* Metadata associated with the removal of the item.
|
|
70
|
-
*/
|
|
71
|
-
metadata: LatestMetadata;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Events from {@link LatestMapRaw}.
|
|
75
|
-
*
|
|
76
|
-
* @sealed
|
|
77
|
-
* @beta
|
|
78
|
-
*/
|
|
79
|
-
export interface LatestMapEvents<T, K extends string, TRemoteValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> {
|
|
80
|
-
/**
|
|
81
|
-
* Raised when any item's value for remote client is updated.
|
|
82
|
-
* @param updates - Map of one or more values updated.
|
|
83
|
-
*
|
|
84
|
-
* @remarks The event does not include item removals.
|
|
85
|
-
*
|
|
86
|
-
* @eventProperty
|
|
87
|
-
*/
|
|
88
|
-
remoteUpdated: (updates: LatestMapClientData<T, K, TRemoteValueAccessor>) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Raised when specific item's value of remote client is updated.
|
|
91
|
-
* @param updatedItem - Updated item value.
|
|
92
|
-
*
|
|
93
|
-
* @eventProperty
|
|
94
|
-
*/
|
|
95
|
-
remoteItemUpdated: (updatedItem: LatestMapItemUpdatedClientData<T, K, TRemoteValueAccessor>) => void;
|
|
96
|
-
/**
|
|
97
|
-
* Raised when specific item of remote client is removed.
|
|
98
|
-
* @param removedItem - Removed item.
|
|
99
|
-
*
|
|
100
|
-
* @eventProperty
|
|
101
|
-
*/
|
|
102
|
-
remoteItemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;
|
|
103
|
-
/**
|
|
104
|
-
* Raised when specific local item's value is updated.
|
|
105
|
-
* @param updatedItem - Updated item value.
|
|
106
|
-
*
|
|
107
|
-
* @eventProperty
|
|
108
|
-
*/
|
|
109
|
-
localItemUpdated: (updatedItem: {
|
|
110
|
-
value: DeepReadonly<JsonSerializable<T>>;
|
|
111
|
-
key: K;
|
|
112
|
-
}) => void;
|
|
113
|
-
/**
|
|
114
|
-
* Raised when specific local item is removed.
|
|
115
|
-
* @param removedItem - Removed item.
|
|
116
|
-
*
|
|
117
|
-
* @eventProperty
|
|
118
|
-
*/
|
|
119
|
-
localItemRemoved: (removedItem: {
|
|
120
|
-
key: K;
|
|
121
|
-
}) => void;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Events from {@link LatestMapRaw}.
|
|
125
|
-
*
|
|
126
|
-
* @sealed
|
|
127
|
-
* @beta
|
|
128
|
-
*/
|
|
129
|
-
export type LatestMapRawEvents<T, K extends string> = LatestMapEvents<T, K, RawValueAccessor<T>>;
|
|
130
|
-
/**
|
|
131
|
-
* Map of local client's values. Modifications are transmitted to all other connected clients.
|
|
132
|
-
*
|
|
133
|
-
* @sealed
|
|
134
|
-
* @beta
|
|
135
|
-
*/
|
|
136
|
-
export interface StateMap<K extends string, V> {
|
|
137
|
-
/**
|
|
138
|
-
* ${@link StateMap.delete}s all elements in the StateMap.
|
|
139
|
-
* @remarks This is not yet implemented.
|
|
140
|
-
*/
|
|
141
|
-
clear(): void;
|
|
142
|
-
/**
|
|
143
|
-
* Removes the element with the specified key from the StateMap, if it exists.
|
|
144
|
-
*
|
|
145
|
-
* @returns true if an element in the StateMap existed and has been removed, or false if
|
|
146
|
-
* the element does not exist.
|
|
147
|
-
* @remarks No entry is fully removed. Instead an undefined placeholder is locally and
|
|
148
|
-
* transmitted to all other clients. For better performance limit the number of deleted
|
|
149
|
-
* entries and reuse keys when possible.
|
|
150
|
-
* @privateRemarks In the future we may add a mechanism to remove the placeholder, at least
|
|
151
|
-
* from transmissions after sufficient time has passed.
|
|
152
|
-
*/
|
|
153
|
-
delete(key: K): boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Executes a provided function once per each key/value pair in the StateMap, in arbitrary order.
|
|
156
|
-
*/
|
|
157
|
-
forEach(callbackfn: (value: DeepReadonly<JsonDeserialized<V>>, key: K, map: StateMap<K, V>) => void, thisArg?: unknown): void;
|
|
158
|
-
/**
|
|
159
|
-
* Returns the element with the specified key from the StateMap, if it exists.
|
|
160
|
-
*
|
|
161
|
-
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
162
|
-
*/
|
|
163
|
-
get(key: K): DeepReadonly<JsonDeserialized<V>> | undefined;
|
|
164
|
-
/**
|
|
165
|
-
* Checks if an element with the specified key exists in the StateMap.
|
|
166
|
-
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
167
|
-
*/
|
|
168
|
-
has(key: K): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* Adds a new element with a specified key and value to the StateMap. If an element with the same key already exists, the element will be updated.
|
|
171
|
-
* The value will be transmitted to all other connected clients.
|
|
172
|
-
*
|
|
173
|
-
* @remarks Manager assumes ownership of the value and its references.
|
|
174
|
-
* Make a deep clone before setting, if needed. No comparison is done to detect changes; all
|
|
175
|
-
* sets are transmitted.
|
|
176
|
-
*/
|
|
177
|
-
set(key: K, value: JsonSerializable<V>): this;
|
|
178
|
-
/**
|
|
179
|
-
* The number of elements in the StateMap.
|
|
180
|
-
*/
|
|
181
|
-
readonly size: number;
|
|
182
|
-
/**
|
|
183
|
-
* Returns an iterable of entries in the map.
|
|
184
|
-
*/
|
|
185
|
-
/**
|
|
186
|
-
* Returns an iterable of key, value pairs for every entry in the map.
|
|
187
|
-
*/
|
|
188
|
-
/**
|
|
189
|
-
* Returns an iterable of keys in the map.
|
|
190
|
-
*/
|
|
191
|
-
keys(): IterableIterator<K>;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* State that provides a `Map` of latest known values from this client to
|
|
195
|
-
* others and read access to their values.
|
|
196
|
-
* Entries in the map may vary over time and by client, but all values are expected to
|
|
197
|
-
* be of the same type, which may be a union type.
|
|
198
|
-
*
|
|
199
|
-
* @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.
|
|
200
|
-
*
|
|
201
|
-
* @sealed
|
|
202
|
-
* @beta
|
|
203
|
-
*/
|
|
204
|
-
export interface LatestMap<T, Keys extends string = string, TRemoteAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> {
|
|
205
|
-
/**
|
|
206
|
-
* Containing {@link Presence}
|
|
207
|
-
*/
|
|
208
|
-
readonly presence: Presence;
|
|
209
|
-
/**
|
|
210
|
-
* Events for LatestMap.
|
|
211
|
-
*/
|
|
212
|
-
readonly events: Listenable<LatestMapEvents<T, Keys, TRemoteAccessor>>;
|
|
213
|
-
/**
|
|
214
|
-
* Controls for management of sending updates.
|
|
215
|
-
*/
|
|
216
|
-
readonly controls: BroadcastControls;
|
|
217
|
-
/**
|
|
218
|
-
* Current value map for this client.
|
|
219
|
-
*/
|
|
220
|
-
readonly local: StateMap<Keys, T>;
|
|
221
|
-
/**
|
|
222
|
-
* Iterable access to remote clients' map of values.
|
|
223
|
-
*/
|
|
224
|
-
getRemotes(): IterableIterator<LatestMapClientData<T, Keys, TRemoteAccessor>>;
|
|
225
|
-
/**
|
|
226
|
-
* Array of {@link Attendee}s that have provided states.
|
|
227
|
-
*/
|
|
228
|
-
getStateAttendees(): Attendee[];
|
|
229
|
-
/**
|
|
230
|
-
* Access to a specific client's map of values.
|
|
231
|
-
*/
|
|
232
|
-
getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T, TRemoteAccessor>>;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* State that provides a `Map` of latest known values from this client to
|
|
236
|
-
* others and read access to their values.
|
|
237
|
-
* Entries in the map may vary over time and by client, but all values are expected to
|
|
238
|
-
* be of the same type, which may be a union type.
|
|
239
|
-
*
|
|
240
|
-
* @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.
|
|
241
|
-
*
|
|
242
|
-
* @sealed
|
|
243
|
-
* @beta
|
|
244
|
-
*/
|
|
245
|
-
export type LatestMapRaw<T, Keys extends string = string> = LatestMap<T, Keys, RawValueAccessor<T>>;
|
|
5
|
+
import type { JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
+
import type { BroadcastControlSettings } from "./broadcastControlsTypes.js";
|
|
7
|
+
import type { KeySchemaValidator, LatestMapFactory } from "./latestMapTypes.js";
|
|
8
|
+
import type { StateSchemaValidator } from "./latestValueTypes.js";
|
|
246
9
|
/**
|
|
247
10
|
* Arguments that are passed to the {@link StateFactory.latestMap} function.
|
|
248
11
|
*
|
|
@@ -282,30 +45,6 @@ export interface LatestMapArguments<T, Keys extends string = string> extends Lat
|
|
|
282
45
|
*/
|
|
283
46
|
keyValidator?: KeySchemaValidator<Keys>;
|
|
284
47
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.
|
|
287
|
-
*
|
|
288
|
-
* @beta
|
|
289
|
-
* @sealed
|
|
290
|
-
*/
|
|
291
|
-
export interface LatestMapFactory {
|
|
292
|
-
/**
|
|
293
|
-
* Factory for creating a {@link LatestMap} State object.
|
|
294
|
-
*
|
|
295
|
-
* @remarks
|
|
296
|
-
* This overload is used when called with {@link LatestMapArguments}.
|
|
297
|
-
* That is, if a validator function is provided.
|
|
298
|
-
*/
|
|
299
|
-
<T, Keys extends string = string, RegistrationKey extends string = string>(args: LatestMapArguments<T, Keys>): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMap<T, Keys>>;
|
|
300
|
-
/**
|
|
301
|
-
* Factory for creating a {@link LatestMapRaw} State object.
|
|
302
|
-
*
|
|
303
|
-
* @remarks
|
|
304
|
-
* This overload is used when called with {@link LatestMapArgumentsRaw}.
|
|
305
|
-
* That is, if a validator function is _not_ provided.
|
|
306
|
-
*/
|
|
307
|
-
<T, Keys extends string = string, RegistrationKey extends string = string>(args?: LatestMapArgumentsRaw<T, Keys>): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapRaw<T, Keys>>;
|
|
308
|
-
}
|
|
309
48
|
/**
|
|
310
49
|
* Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.
|
|
311
50
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestMapValueManager.d.ts","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"latestMapValueManager.d.ts","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAGX,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAGtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAU5E,OAAO,KAAK,EACX,kBAAkB,EAIlB,gBAAgB,EAIhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAc,oBAAoB,EAAiB,MAAM,uBAAuB,CAAC;AAgS7F;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM;IACrE;;OAEG;IACH,KAAK,CAAC,EAAE;SACN,CAAC,IAAI,IAAI,GAAG,gBAAgB,CAAC,CAAC,CAAC;KAChC,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAChD;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,CAClE,SAAQ,qBAAqB,CAAC,CAAC,EAAE,IAAI,CAAC;IACtC;;;;OAIG;IACH,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACnC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBA6DvB,CAAC"}
|
|
@@ -8,8 +8,8 @@ exports.latestMap = void 0;
|
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const broadcastControls_js_1 = require("./broadcastControls.js");
|
|
10
10
|
const internalUtils_js_1 = require("./internalUtils.js");
|
|
11
|
-
const latestValueTypes_js_1 = require("./latestValueTypes.js");
|
|
12
11
|
const stateDatastore_js_1 = require("./stateDatastore.js");
|
|
12
|
+
const validatedGetter_js_1 = require("./validatedGetter.js");
|
|
13
13
|
const valueManager_js_1 = require("./valueManager.js");
|
|
14
14
|
class ValueMapImpl {
|
|
15
15
|
constructor(value, emitter, localUpdate) {
|
|
@@ -141,7 +141,7 @@ class LatestMapValueManagerImpl {
|
|
|
141
141
|
for (const [key, item] of (0, internalUtils_js_1.objectEntries)(clientStateMap.items)) {
|
|
142
142
|
if (this.isValidKey(key) && (0, internalUtils_js_1.isValueRequiredState)(item)) {
|
|
143
143
|
items.set(key, {
|
|
144
|
-
value: (0,
|
|
144
|
+
value: (0, validatedGetter_js_1.createValidatedGetter)(item, validator),
|
|
145
145
|
metadata: { revision: item.rev, timestamp: item.timestamp },
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -192,7 +192,7 @@ class LatestMapValueManagerImpl {
|
|
|
192
192
|
const updatedItem = {
|
|
193
193
|
attendee,
|
|
194
194
|
key,
|
|
195
|
-
value: (0,
|
|
195
|
+
value: (0, validatedGetter_js_1.createValidatedGetter)(item, this.validator),
|
|
196
196
|
metadata,
|
|
197
197
|
};
|
|
198
198
|
postUpdateActions.push(() => this.events.emit("remoteItemUpdated", updatedItem));
|
|
@@ -218,7 +218,6 @@ class LatestMapValueManagerImpl {
|
|
|
218
218
|
return postUpdateActions;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
// #endregion
|
|
222
221
|
/**
|
|
223
222
|
* Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.
|
|
224
223
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestMapValueManager.js","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAS7D,iEAAkE;AAGlE,yDAO4B;AAC5B,+DAA8D;AAW9D,2DAA+E;AAG/E,uDAA6C;AAgQ7C,MAAM,YAAY;IAEjB,YACkB,KAAwC,EACxC,OAEhB,EACgB,WAMR;QAVQ,UAAK,GAAL,KAAK,CAAmC;QACxC,YAAO,GAAP,OAAO,CAEvB;QACgB,gBAAW,GAAX,WAAW,CAMnB;QAET,gDAAgD;QAChD,8CAA8C;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IACr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QACjC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,IAAA,gCAAa,EAAC,aAAa,CAAC,EAAE,CAAC;YACxD,wEAAwE;YACxE,MAAM,eAAe,GAAG,GAAsB,CAAC;YAC/C,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG;gBAC9B,GAAG,EAAE,CAAC;gBACN,SAAS;gBACT,KAAK,EAAE,IAAA,+BAAY,EAAC,IAAI,CAAC;aACzB,CAAC;QACH,CAAC;IACF,CAAC;IACD,MAAM,OAAO,GAAG,CACf,GAAoB,EACpB,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,yBAAyB,CAC5B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AA7DW,QAAA,SAAS,aA6DpB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport type { IEmitter } from \"@fluidframework/core-interfaces/internal\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport {\n\tasDeeplyReadonly,\n\tasDeeplyReadonlyDeserializedJson,\n\tisValueRequiredState,\n\tobjectEntries,\n\tobjectKeys,\n\ttoOpaqueJson,\n} from \"./internalUtils.js\";\nimport { createValidatedGetter } from \"./latestValueTypes.js\";\nimport type {\n\tLatestClientData,\n\tLatestData,\n\tLatestMetadata,\n\tProxiedValueAccessor,\n\tRawValueAccessor,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"./latestValueTypes.js\";\nimport type { AttendeeId, Attendee, Presence, SpecificAttendee } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport type { ValidatableOptionalState } from \"./validatableTypes.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * A validator function that can optionally be provided to do runtime validation\n * of the custom key listed in a {@link LatestMap}.\n *\n * @param unvalidatedKey - The unknown key that should be validated.\n *\n * @returns True if the key is valid.\n *\n * @beta\n */\nexport type KeySchemaValidator<Keys extends string> = (\n\tunvalidatedKey: string,\n) => unvalidatedKey is Keys;\n\n/**\n * Collection of validatable optional values in a \"map\" structure.\n *\n * @remarks\n * Validatable equivalent of {@link InternalTypes.MapValueState}.\n */\ninterface ValidatableMapValueState<T> {\n\trev: number;\n\titems: {\n\t\t// Caution: any particular item may or may not exist\n\t\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t\t[name in string]: ValidatableOptionalState<T>;\n\t};\n}\n\n/**\n * Collection of latest known values for a specific {@link Attendee}.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMapClientData<\n\tT,\n\tKeys extends string,\n\tTValueAccessor extends ValueAccessor<T>,\n\tSpecificAttendeeId extends AttendeeId = AttendeeId,\n> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee<SpecificAttendeeId>;\n\n\t/**\n\t * Map of items for the state.\n\t *\n\t * @privateRemarks This could be regular map currently as no Map is\n\t * stored internally and a new instance is created for every request.\n\t */\n\titems: ReadonlyMap<Keys, LatestData<T, TValueAccessor>>;\n}\n\n/**\n * State of a single item value, its key, and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMapItemUpdatedClientData<\n\tT,\n\tK extends string,\n\tTValueAccessor extends ValueAccessor<T>,\n> extends LatestClientData<T, TValueAccessor> {\n\t/**\n\t * Key of the updated item.\n\t */\n\tkey: K;\n}\n\n/**\n * Identifier and metadata for a removed item.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMapItemRemovedClientData<K extends string> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee;\n\t/**\n\t * Key of the removed item.\n\t */\n\tkey: K;\n\t/**\n\t * Metadata associated with the removal of the item.\n\t */\n\tmetadata: LatestMetadata;\n}\n\n/**\n * Events from {@link LatestMapRaw}.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMapEvents<\n\tT,\n\tK extends string,\n\tTRemoteValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> {\n\t/**\n\t * Raised when any item's value for remote client is updated.\n\t * @param updates - Map of one or more values updated.\n\t *\n\t * @remarks The event does not include item removals.\n\t *\n\t * @eventProperty\n\t */\n\tremoteUpdated: (updates: LatestMapClientData<T, K, TRemoteValueAccessor>) => void;\n\n\t/**\n\t * Raised when specific item's value of remote client is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\tremoteItemUpdated: (\n\t\tupdatedItem: LatestMapItemUpdatedClientData<T, K, TRemoteValueAccessor>,\n\t) => void;\n\n\t/**\n\t * Raised when specific item of remote client is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\tremoteItemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;\n\n\t/**\n\t * Raised when specific local item's value is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemUpdated: (updatedItem: {\n\t\tvalue: DeepReadonly<JsonSerializable<T>>;\n\t\tkey: K;\n\t}) => void;\n\n\t/**\n\t * Raised when specific local item is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemRemoved: (removedItem: {\n\t\tkey: K;\n\t}) => void;\n}\n\n/**\n * Events from {@link LatestMapRaw}.\n *\n * @sealed\n * @beta\n */\nexport type LatestMapRawEvents<T, K extends string> = LatestMapEvents<\n\tT,\n\tK,\n\tRawValueAccessor<T>\n>;\n\n/**\n * Map of local client's values. Modifications are transmitted to all other connected clients.\n *\n * @sealed\n * @beta\n */\nexport interface StateMap<K extends string, V> {\n\t/**\n\t * ${@link StateMap.delete}s all elements in the StateMap.\n\t * @remarks This is not yet implemented.\n\t */\n\tclear(): void;\n\n\t/**\n\t * Removes the element with the specified key from the StateMap, if it exists.\n\t *\n\t * @returns true if an element in the StateMap existed and has been removed, or false if\n\t * the element does not exist.\n\t * @remarks No entry is fully removed. Instead an undefined placeholder is locally and\n\t * transmitted to all other clients. For better performance limit the number of deleted\n\t * entries and reuse keys when possible.\n\t * @privateRemarks In the future we may add a mechanism to remove the placeholder, at least\n\t * from transmissions after sufficient time has passed.\n\t */\n\tdelete(key: K): boolean;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the StateMap, in arbitrary order.\n\t */\n\tforEach(\n\t\tcallbackfn: (\n\t\t\tvalue: DeepReadonly<JsonDeserialized<V>>,\n\t\t\tkey: K,\n\t\t\tmap: StateMap<K, V>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void;\n\n\t/**\n\t * Returns the element with the specified key from the StateMap, if it exists.\n\t *\n\t * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.\n\t */\n\tget(key: K): DeepReadonly<JsonDeserialized<V>> | undefined;\n\n\t/**\n\t * Checks if an element with the specified key exists in the StateMap.\n\t * @returns boolean indicating whether an element with the specified key exists or not.\n\t */\n\thas(key: K): boolean;\n\n\t/**\n\t * Adds a new element with a specified key and value to the StateMap. If an element with the same key already exists, the element will be updated.\n\t * The value will be transmitted to all other connected clients.\n\t *\n\t * @remarks Manager assumes ownership of the value and its references.\n\t * Make a deep clone before setting, if needed. No comparison is done to detect changes; all\n\t * sets are transmitted.\n\t */\n\tset(key: K, value: JsonSerializable<V>): this;\n\n\t/**\n\t * The number of elements in the StateMap.\n\t */\n\treadonly size: number;\n\n\t/**\n\t * Returns an iterable of entries in the map.\n\t */\n\t// [Symbol.iterator](): IterableIterator<[K, DeepReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t */\n\t// entries(): IterableIterator<[K, DeepReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t */\n\tkeys(): IterableIterator<K>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t */\n\t// values(): IterableIterator<DeepReadonly<JsonDeserialized<V>>>;\n}\n\nclass ValueMapImpl<T, K extends string> implements StateMap<K, T> {\n\tprivate countDefined: number;\n\tpublic constructor(\n\t\tprivate readonly value: InternalTypes.MapValueState<T, K>,\n\t\tprivate readonly emitter: IEmitter<\n\t\t\tPick<LatestMapEvents<T, K, ValueAccessor<T>>, \"localItemUpdated\" | \"localItemRemoved\">\n\t\t>,\n\t\tprivate readonly localUpdate: (\n\t\t\tupdates: InternalTypes.MapValueState<\n\t\t\t\tT,\n\t\t\t\t// This should be `K`, but will only work if properties are optional.\n\t\t\t\tstring\n\t\t\t>,\n\t\t) => void,\n\t) {\n\t\t// All initial items are expected to be defined.\n\t\t// TODO assert all defined and/or update type.\n\t\tthis.countDefined = Object.keys(value.items).length;\n\t}\n\n\t/**\n\t * Note: caller must ensure key exists in this.value.items.\n\t */\n\tprivate updateItem(key: K, value: InternalTypes.ValueOptionalState<T>[\"value\"]): void {\n\t\tthis.value.rev += 1;\n\t\t// Caller is required to ensure key exists.\n\t\tconst item = this.value.items[key];\n\t\titem.rev += 1;\n\t\titem.timestamp = Date.now();\n\t\tif (value === undefined) {\n\t\t\tdelete item.value;\n\t\t} else {\n\t\t\titem.value = value;\n\t\t}\n\t\tconst update = { rev: this.value.rev, items: { [key]: item } };\n\t\tthis.localUpdate(update);\n\t}\n\n\tpublic clear(): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tpublic delete(key: K): boolean {\n\t\tconst { items } = this.value;\n\t\tconst hasKey = items[key]?.value !== undefined;\n\t\tif (hasKey) {\n\t\t\tthis.countDefined -= 1;\n\t\t\tthis.updateItem(key, undefined);\n\t\t\tthis.emitter.emit(\"localItemRemoved\", { key });\n\t\t}\n\t\treturn hasKey;\n\t}\n\tpublic forEach(\n\t\tcallbackfn: (\n\t\t\tvalue: DeepReadonly<JsonDeserialized<T>>,\n\t\t\tkey: K,\n\t\t\tmap: StateMap<K, T>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tcallbackfn(asDeeplyReadonlyDeserializedJson(item.value), key as unknown as K, this);\n\t\t\t}\n\t\t}\n\t}\n\tpublic get(key: K): DeepReadonly<JsonDeserialized<T>> | undefined {\n\t\treturn asDeeplyReadonlyDeserializedJson(this.value.items[key]?.value);\n\t}\n\tpublic has(key: K): boolean {\n\t\treturn this.value.items[key]?.value !== undefined;\n\t}\n\tpublic set(key: K, inValue: JsonSerializable<T>): this {\n\t\tconst value = toOpaqueJson<T>(inValue);\n\t\tif (!(key in this.value.items)) {\n\t\t\tthis.countDefined += 1;\n\t\t\tthis.value.items[key] = { rev: 0, timestamp: 0, value };\n\t\t}\n\t\tthis.updateItem(key, value);\n\t\tthis.emitter.emit(\"localItemUpdated\", { key, value: asDeeplyReadonly(inValue) });\n\t\treturn this;\n\t}\n\tpublic get size(): number {\n\t\treturn this.countDefined;\n\t}\n\tpublic keys(): IterableIterator<K> {\n\t\tconst keys: K[] = [];\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tkeys.push(key as unknown as K);\n\t\t\t}\n\t\t}\n\t\treturn keys[Symbol.iterator]();\n\t}\n}\n\n/**\n * State that provides a `Map` of latest known values from this client to\n * others and read access to their values.\n * Entries in the map may vary over time and by client, but all values are expected to\n * be of the same type, which may be a union type.\n *\n * @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMap<\n\tT,\n\tKeys extends string = string,\n\tTRemoteAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for LatestMap.\n\t */\n\treadonly events: Listenable<LatestMapEvents<T, Keys, TRemoteAccessor>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current value map for this client.\n\t */\n\treadonly local: StateMap<Keys, T>;\n\t/**\n\t * Iterable access to remote clients' map of values.\n\t */\n\tgetRemotes(): IterableIterator<LatestMapClientData<T, Keys, TRemoteAccessor>>;\n\t/**\n\t * Array of {@link Attendee}s that have provided states.\n\t */\n\tgetStateAttendees(): Attendee[];\n\t/**\n\t * Access to a specific client's map of values.\n\t */\n\tgetRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T, TRemoteAccessor>>;\n}\n\n/**\n * State that provides a `Map` of latest known values from this client to\n * others and read access to their values.\n * Entries in the map may vary over time and by client, but all values are expected to\n * be of the same type, which may be a union type.\n *\n * @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type LatestMapRaw<T, Keys extends string = string> = LatestMap<\n\tT,\n\tKeys,\n\tRawValueAccessor<T>\n>;\n\n/**\n * Simply returns true for all given string keys.\n */\nfunction anyKeyIsValid<Keys extends string>(unvalidatedKey: string): unvalidatedKey is Keys {\n\treturn true;\n}\n\nclass LatestMapValueManagerImpl<\n\tT,\n\tRegistrationKey extends string,\n\tKeys extends string = string,\n> implements\n\t\tLatestMapRaw<T, Keys>,\n\t\tLatestMap<T, Keys>,\n\t\tRequired<ValueManager<T, InternalTypes.MapValueState<T, Keys>>>\n{\n\tpublic readonly events = createEmitter<LatestMapEvents<T, Keys, ValueAccessor<T>>>();\n\tpublic readonly controls: OptionalBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly key: RegistrationKey,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>,\n\t\t\tValidatableMapValueState<T>\n\t\t>,\n\t\tpublic readonly value: InternalTypes.MapValueState<T, Keys>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\n\t\tprivate readonly validator: StateSchemaValidator<T> | undefined,\n\t\tprivate readonly isValidKey: KeySchemaValidator<Keys>,\n\t) {\n\t\tthis.controls = new OptionalBroadcastControl(controlSettings);\n\n\t\tthis.local = new ValueMapImpl<T, Keys>(\n\t\t\tvalue,\n\t\t\tthis.events,\n\t\t\t(updates: InternalTypes.MapValueState<T, Keys>) => {\n\t\t\t\tdatastore.localUpdate(key, updates, {\n\t\t\t\t\tallowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic readonly local: StateMap<Keys, T>;\n\n\tpublic *getRemotes(): IterableIterator<LatestMapClientData<T, Keys, ValueAccessor<T>>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const attendeeId of objectKeys(allKnownStates.states)) {\n\t\t\tif (attendeeId !== allKnownStates.self) {\n\t\t\t\tconst attendee = this.datastore.presence.attendees.getAttendee(attendeeId);\n\t\t\t\tconst items = this.getRemote(attendee);\n\t\t\t\tyield { attendee, items };\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getStateAttendees(): Attendee[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn objectKeys(allKnownStates.states)\n\t\t\t.filter((attendeeId) => attendeeId !== allKnownStates.self)\n\t\t\t.map((attendeeId) => this.datastore.presence.attendees.getAttendee(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T, ValueAccessor<T>>> {\n\t\tconst validator = this.validator;\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId = attendee.attendeeId;\n\t\tconst clientStateMap = allKnownStates.states[attendeeId];\n\t\tif (clientStateMap === undefined) {\n\t\t\tthrow new Error(\"No entry for attendee\");\n\t\t}\n\t\tconst items = new Map<Keys, LatestData<T, ValueAccessor<T>>>();\n\t\tfor (const [key, item] of objectEntries(clientStateMap.items)) {\n\t\t\tif (this.isValidKey(key) && isValueRequiredState(item)) {\n\t\t\t\titems.set(key, {\n\t\t\t\t\tvalue: createValidatedGetter(item, validator),\n\t\t\t\t\tmetadata: { revision: item.rev, timestamp: item.timestamp },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\tpublic update<SpecificAttendeeId extends AttendeeId>(\n\t\tattendee: SpecificAttendee<SpecificAttendeeId>,\n\t\t_received: number,\n\t\tvalue: InternalTypes.MapValueState<T, string>,\n\t): PostUpdateAction[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId: SpecificAttendeeId = attendee.attendeeId;\n\t\tconst currentState = (allKnownStates.states[attendeeId] ??=\n\t\t\t// New attendee - prepare new attendee state directory\n\t\t\t{\n\t\t\t\trev: value.rev,\n\t\t\t\titems: {},\n\t\t\t});\n\t\t// Accumulate individual update keys\n\t\tconst updatedKeyItemPairs: [string, InternalTypes.ValueOptionalState<T>][] = [];\n\t\tfor (const [key, item] of objectEntries(value.items)) {\n\t\t\tconst currentItem = currentState.items[key];\n\t\t\tif (currentItem === undefined || currentItem.rev < item.rev) {\n\t\t\t\tupdatedKeyItemPairs.push([key, item]);\n\t\t\t}\n\t\t}\n\n\t\tif (updatedKeyItemPairs.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Store updates\n\t\tif (value.rev > currentState.rev) {\n\t\t\tcurrentState.rev = value.rev;\n\t\t}\n\t\tconst allUpdates = {\n\t\t\tattendee,\n\t\t\titems: new Map<Keys, LatestData<T, ValueAccessor<T>>>(),\n\t\t};\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [key, item] of updatedKeyItemPairs) {\n\t\t\tconst hadPriorValue = currentState.items[key]?.value;\n\t\t\tcurrentState.items[key] = item;\n\n\t\t\t// Prepare update events, but only for valid keys.\n\t\t\tif (!this.isValidKey(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst metadata = {\n\t\t\t\trevision: item.rev,\n\t\t\t\ttimestamp: item.timestamp,\n\t\t\t};\n\t\t\tif (isValueRequiredState(item)) {\n\t\t\t\tconst updatedItem = {\n\t\t\t\t\tattendee,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: createValidatedGetter(item, this.validator),\n\t\t\t\t\tmetadata,\n\t\t\t\t} satisfies LatestMapItemUpdatedClientData<T, Keys, ValueAccessor<T>>;\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteItemUpdated\", updatedItem));\n\t\t\t\tallUpdates.items.set(key, {\n\t\t\t\t\tvalue: updatedItem.value,\n\t\t\t\t\tmetadata,\n\t\t\t\t});\n\t\t\t} else if (hadPriorValue !== undefined) {\n\t\t\t\tpostUpdateActions.push(() =>\n\t\t\t\t\tthis.events.emit(\"remoteItemRemoved\", {\n\t\t\t\t\t\tattendee,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis.datastore.update(this.key, attendeeId, currentState);\n\t\t// Only emit remoteUpdated if there are any individual updates, which\n\t\t// accounts for the case where all updates were for invalid keys.\n\t\tif (postUpdateActions.length > 0) {\n\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteUpdated\", allUpdates));\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory.latestMap} function.\n *\n * @input\n * @beta\n */\nexport interface LatestMapArgumentsRaw<T, Keys extends string = string> {\n\t/**\n\t * The initial value of the local state.\n\t */\n\tlocal?: {\n\t\t[K in Keys]: JsonSerializable<T>;\n\t};\n\n\t/**\n\t * See {@link BroadcastControlSettings}.\n\t */\n\tsettings?: BroadcastControlSettings | undefined;\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory.latestMap} function.\n *\n * @input\n * @beta\n */\nexport interface LatestMapArguments<T, Keys extends string = string>\n\textends LatestMapArgumentsRaw<T, Keys> {\n\t/**\n\t * An optional function that will be called at runtime to validate data value\n\t * under a key. A runtime validator is strongly recommended.\n\t * @see {@link StateSchemaValidator}.\n\t */\n\tvalidator: StateSchemaValidator<T>;\n\t/**\n\t * An optional function that will be called at runtime to validate the presence\n\t * data key. A runtime validator is strongly recommended when key type is not\n\t * simply `string`.\n\t * @see {@link KeySchemaValidator}.\n\t */\n\tkeyValidator?: KeySchemaValidator<Keys>;\n}\n\n// #region factory function overloads\n// Overloads should be ordered from most specific to least specific when combined.\n\n/**\n * Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.\n *\n * @beta\n * @sealed\n */\nexport interface LatestMapFactory {\n\t/**\n\t * Factory for creating a {@link LatestMap} State object.\n\t *\n\t * @remarks\n\t * This overload is used when called with {@link LatestMapArguments}.\n\t * That is, if a validator function is provided.\n\t */\n\t<T, Keys extends string = string, RegistrationKey extends string = string>(\n\t\targs: LatestMapArguments<T, Keys>,\n\t): InternalTypes.ManagerFactory<\n\t\tRegistrationKey,\n\t\tInternalTypes.MapValueState<T, Keys>,\n\t\tLatestMap<T, Keys>\n\t>;\n\n\t/**\n\t * Factory for creating a {@link LatestMapRaw} State object.\n\t *\n\t * @remarks\n\t * This overload is used when called with {@link LatestMapArgumentsRaw}.\n\t * That is, if a validator function is _not_ provided.\n\t */\n\t<T, Keys extends string = string, RegistrationKey extends string = string>(\n\t\targs?: LatestMapArgumentsRaw<T, Keys>,\n\t): InternalTypes.ManagerFactory<\n\t\tRegistrationKey,\n\t\tInternalTypes.MapValueState<T, Keys>,\n\t\tLatestMapRaw<T, Keys>\n\t>;\n}\n\n// #endregion\n\n/**\n * Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.\n */\nexport const latestMap: LatestMapFactory = <\n\tT,\n\tKeys extends string = string,\n\tRegistrationKey extends string = string,\n>(\n\targs?: Partial<LatestMapArguments<T, Keys>>,\n): InternalTypes.ManagerFactory<\n\tRegistrationKey,\n\tInternalTypes.MapValueState<T, Keys>,\n\tLatestMapRaw<T, Keys> & LatestMap<T, Keys>\n> => {\n\tconst settings = args?.settings;\n\tconst initialValues = args?.local;\n\tconst validator = args?.validator;\n\tconst isKeyValid = args?.keyValidator ?? anyKeyIsValid;\n\n\tconst timestamp = Date.now();\n\tconst value: InternalTypes.MapValueState<\n\t\tT,\n\t\t// This should be `Keys`, but will only work if properties are optional.\n\t\tstring\n\t> = { rev: 0, items: {} };\n\t// LatestMapRaw takes ownership of values within initialValues.\n\tif (initialValues !== undefined) {\n\t\tfor (const [key, item] of objectEntries(initialValues)) {\n\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\tconst assumedValidKey = key as unknown as Keys;\n\t\t\tvalue.items[assumedValidKey] = {\n\t\t\t\trev: 0,\n\t\t\t\ttimestamp,\n\t\t\t\tvalue: toOpaqueJson(item),\n\t\t\t};\n\t\t}\n\t}\n\tconst factory = (\n\t\tkey: RegistrationKey,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>,\n\t): {\n\t\tinitialData: { value: typeof value; allowableUpdateLatencyMs: number | undefined };\n\t\tmanager: InternalTypes.StateValue<LatestMapRaw<T, Keys> & LatestMap<T, Keys>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<\n\t\t\tLatestMapValueManagerImpl<T, RegistrationKey, Keys>,\n\t\t\tT,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>(\n\t\t\tnew LatestMapValueManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tvalue,\n\t\t\t\tsettings,\n\t\t\t\tvalidator,\n\t\t\t\tisKeyValid,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestMapValueManagerImpl });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"latestMapValueManager.js","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAQ7D,iEAAkE;AAGlE,yDAO4B;AAa5B,2DAA+E;AAG/E,6DAA6D;AAC7D,uDAA6C;AAkB7C,MAAM,YAAY;IAEjB,YACkB,KAAwC,EACxC,OAEhB,EACgB,WAMR;QAVQ,UAAK,GAAL,KAAK,CAAmC;QACxC,YAAO,GAAP,OAAO,CAEvB;QACgB,gBAAW,GAAX,WAAW,CAMnB;QAET,gDAAgD;QAChD,8CAA8C;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IACrD,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,GAAM,EAAE,KAAmD;QAC7E,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACpB,2CAA2C;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,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SAAS;gBACT,KAAK,EAAE,IAAA,+BAAY,EAAC,IAAI,CAAC;aACzB,CAAC;QACH,CAAC;IACF,CAAC;IACD,MAAM,OAAO,GAAG,CACf,GAAoB,EACpB,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,yBAAyB,CAC5B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AA7DW,QAAA,SAAS,aA6DpB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { IEmitter } from \"@fluidframework/core-interfaces/internal\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport {\n\tasDeeplyReadonly,\n\tasDeeplyReadonlyDeserializedJson,\n\tisValueRequiredState,\n\tobjectEntries,\n\tobjectKeys,\n\ttoOpaqueJson,\n} from \"./internalUtils.js\";\nimport type {\n\tKeySchemaValidator,\n\tLatestMap,\n\tLatestMapClientData,\n\tLatestMapEvents,\n\tLatestMapFactory,\n\tLatestMapItemUpdatedClientData,\n\tLatestMapRaw,\n\tStateMap,\n} from \"./latestMapTypes.js\";\nimport type { LatestData, StateSchemaValidator, ValueAccessor } from \"./latestValueTypes.js\";\nimport type { AttendeeId, Attendee, Presence, SpecificAttendee } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport type { ValidatableOptionalState } from \"./validatableTypes.js\";\nimport { createValidatedGetter } from \"./validatedGetter.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Collection of validatable optional values in a \"map\" structure.\n *\n * @remarks\n * Validatable equivalent of {@link InternalTypes.MapValueState}.\n */\ninterface ValidatableMapValueState<T> {\n\trev: number;\n\titems: {\n\t\t// Caution: any particular item may or may not exist\n\t\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t\t[name in string]: ValidatableOptionalState<T>;\n\t};\n}\n\nclass ValueMapImpl<T, K extends string> implements StateMap<K, T> {\n\tprivate countDefined: number;\n\tpublic constructor(\n\t\tprivate readonly value: InternalTypes.MapValueState<T, K>,\n\t\tprivate readonly emitter: IEmitter<\n\t\t\tPick<LatestMapEvents<T, K, ValueAccessor<T>>, \"localItemUpdated\" | \"localItemRemoved\">\n\t\t>,\n\t\tprivate readonly localUpdate: (\n\t\t\tupdates: InternalTypes.MapValueState<\n\t\t\t\tT,\n\t\t\t\t// This should be `K`, but will only work if properties are optional.\n\t\t\t\tstring\n\t\t\t>,\n\t\t) => void,\n\t) {\n\t\t// All initial items are expected to be defined.\n\t\t// TODO assert all defined and/or update type.\n\t\tthis.countDefined = Object.keys(value.items).length;\n\t}\n\n\t/**\n\t * Note: caller must ensure key exists in this.value.items.\n\t */\n\tprivate updateItem(key: K, value: InternalTypes.ValueOptionalState<T>[\"value\"]): void {\n\t\tthis.value.rev += 1;\n\t\t// Caller is required to ensure key exists.\n\t\tconst item = this.value.items[key];\n\t\titem.rev += 1;\n\t\titem.timestamp = Date.now();\n\t\tif (value === undefined) {\n\t\t\tdelete item.value;\n\t\t} else {\n\t\t\titem.value = value;\n\t\t}\n\t\tconst update = { rev: this.value.rev, items: { [key]: item } };\n\t\tthis.localUpdate(update);\n\t}\n\n\tpublic clear(): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tpublic delete(key: K): boolean {\n\t\tconst { items } = this.value;\n\t\tconst hasKey = items[key]?.value !== undefined;\n\t\tif (hasKey) {\n\t\t\tthis.countDefined -= 1;\n\t\t\tthis.updateItem(key, undefined);\n\t\t\tthis.emitter.emit(\"localItemRemoved\", { key });\n\t\t}\n\t\treturn hasKey;\n\t}\n\tpublic forEach(\n\t\tcallbackfn: (\n\t\t\tvalue: DeepReadonly<JsonDeserialized<T>>,\n\t\t\tkey: K,\n\t\t\tmap: StateMap<K, T>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tcallbackfn(asDeeplyReadonlyDeserializedJson(item.value), key as unknown as K, this);\n\t\t\t}\n\t\t}\n\t}\n\tpublic get(key: K): DeepReadonly<JsonDeserialized<T>> | undefined {\n\t\treturn asDeeplyReadonlyDeserializedJson(this.value.items[key]?.value);\n\t}\n\tpublic has(key: K): boolean {\n\t\treturn this.value.items[key]?.value !== undefined;\n\t}\n\tpublic set(key: K, inValue: JsonSerializable<T>): this {\n\t\tconst value = toOpaqueJson<T>(inValue);\n\t\tif (!(key in this.value.items)) {\n\t\t\tthis.countDefined += 1;\n\t\t\tthis.value.items[key] = { rev: 0, timestamp: 0, value };\n\t\t}\n\t\tthis.updateItem(key, value);\n\t\tthis.emitter.emit(\"localItemUpdated\", { key, value: asDeeplyReadonly(inValue) });\n\t\treturn this;\n\t}\n\tpublic get size(): number {\n\t\treturn this.countDefined;\n\t}\n\tpublic keys(): IterableIterator<K> {\n\t\tconst keys: K[] = [];\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tkeys.push(key as unknown as K);\n\t\t\t}\n\t\t}\n\t\treturn keys[Symbol.iterator]();\n\t}\n}\n\n/**\n * Simply returns true for all given string keys.\n */\nfunction anyKeyIsValid<Keys extends string>(unvalidatedKey: string): unvalidatedKey is Keys {\n\treturn true;\n}\n\nclass LatestMapValueManagerImpl<\n\tT,\n\tRegistrationKey extends string,\n\tKeys extends string = string,\n> implements\n\t\tLatestMapRaw<T, Keys>,\n\t\tLatestMap<T, Keys>,\n\t\tRequired<ValueManager<T, InternalTypes.MapValueState<T, Keys>>>\n{\n\tpublic readonly events = createEmitter<LatestMapEvents<T, Keys, ValueAccessor<T>>>();\n\tpublic readonly controls: OptionalBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly key: RegistrationKey,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>,\n\t\t\tValidatableMapValueState<T>\n\t\t>,\n\t\tpublic readonly value: InternalTypes.MapValueState<T, Keys>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\n\t\tprivate readonly validator: StateSchemaValidator<T> | undefined,\n\t\tprivate readonly isValidKey: KeySchemaValidator<Keys>,\n\t) {\n\t\tthis.controls = new OptionalBroadcastControl(controlSettings);\n\n\t\tthis.local = new ValueMapImpl<T, Keys>(\n\t\t\tvalue,\n\t\t\tthis.events,\n\t\t\t(updates: InternalTypes.MapValueState<T, Keys>) => {\n\t\t\t\tdatastore.localUpdate(key, updates, {\n\t\t\t\t\tallowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic readonly local: StateMap<Keys, T>;\n\n\tpublic *getRemotes(): IterableIterator<LatestMapClientData<T, Keys, ValueAccessor<T>>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const attendeeId of objectKeys(allKnownStates.states)) {\n\t\t\tif (attendeeId !== allKnownStates.self) {\n\t\t\t\tconst attendee = this.datastore.presence.attendees.getAttendee(attendeeId);\n\t\t\t\tconst items = this.getRemote(attendee);\n\t\t\t\tyield { attendee, items };\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getStateAttendees(): Attendee[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn objectKeys(allKnownStates.states)\n\t\t\t.filter((attendeeId) => attendeeId !== allKnownStates.self)\n\t\t\t.map((attendeeId) => this.datastore.presence.attendees.getAttendee(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T, ValueAccessor<T>>> {\n\t\tconst validator = this.validator;\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId = attendee.attendeeId;\n\t\tconst clientStateMap = allKnownStates.states[attendeeId];\n\t\tif (clientStateMap === undefined) {\n\t\t\tthrow new Error(\"No entry for attendee\");\n\t\t}\n\t\tconst items = new Map<Keys, LatestData<T, ValueAccessor<T>>>();\n\t\tfor (const [key, item] of objectEntries(clientStateMap.items)) {\n\t\t\tif (this.isValidKey(key) && isValueRequiredState(item)) {\n\t\t\t\titems.set(key, {\n\t\t\t\t\tvalue: createValidatedGetter(item, validator),\n\t\t\t\t\tmetadata: { revision: item.rev, timestamp: item.timestamp },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\tpublic update<SpecificAttendeeId extends AttendeeId>(\n\t\tattendee: SpecificAttendee<SpecificAttendeeId>,\n\t\t_received: number,\n\t\tvalue: InternalTypes.MapValueState<T, string>,\n\t): PostUpdateAction[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId: SpecificAttendeeId = attendee.attendeeId;\n\t\tconst currentState = (allKnownStates.states[attendeeId] ??=\n\t\t\t// New attendee - prepare new attendee state directory\n\t\t\t{\n\t\t\t\trev: value.rev,\n\t\t\t\titems: {},\n\t\t\t});\n\t\t// Accumulate individual update keys\n\t\tconst updatedKeyItemPairs: [string, InternalTypes.ValueOptionalState<T>][] = [];\n\t\tfor (const [key, item] of objectEntries(value.items)) {\n\t\t\tconst currentItem = currentState.items[key];\n\t\t\tif (currentItem === undefined || currentItem.rev < item.rev) {\n\t\t\t\tupdatedKeyItemPairs.push([key, item]);\n\t\t\t}\n\t\t}\n\n\t\tif (updatedKeyItemPairs.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Store updates\n\t\tif (value.rev > currentState.rev) {\n\t\t\tcurrentState.rev = value.rev;\n\t\t}\n\t\tconst allUpdates = {\n\t\t\tattendee,\n\t\t\titems: new Map<Keys, LatestData<T, ValueAccessor<T>>>(),\n\t\t};\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [key, item] of updatedKeyItemPairs) {\n\t\t\tconst hadPriorValue = currentState.items[key]?.value;\n\t\t\tcurrentState.items[key] = item;\n\n\t\t\t// Prepare update events, but only for valid keys.\n\t\t\tif (!this.isValidKey(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst metadata = {\n\t\t\t\trevision: item.rev,\n\t\t\t\ttimestamp: item.timestamp,\n\t\t\t};\n\t\t\tif (isValueRequiredState(item)) {\n\t\t\t\tconst updatedItem = {\n\t\t\t\t\tattendee,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: createValidatedGetter(item, this.validator),\n\t\t\t\t\tmetadata,\n\t\t\t\t} satisfies LatestMapItemUpdatedClientData<T, Keys, ValueAccessor<T>>;\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteItemUpdated\", updatedItem));\n\t\t\t\tallUpdates.items.set(key, {\n\t\t\t\t\tvalue: updatedItem.value,\n\t\t\t\t\tmetadata,\n\t\t\t\t});\n\t\t\t} else if (hadPriorValue !== undefined) {\n\t\t\t\tpostUpdateActions.push(() =>\n\t\t\t\t\tthis.events.emit(\"remoteItemRemoved\", {\n\t\t\t\t\t\tattendee,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis.datastore.update(this.key, attendeeId, currentState);\n\t\t// Only emit remoteUpdated if there are any individual updates, which\n\t\t// accounts for the case where all updates were for invalid keys.\n\t\tif (postUpdateActions.length > 0) {\n\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteUpdated\", allUpdates));\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory.latestMap} function.\n *\n * @input\n * @beta\n */\nexport interface LatestMapArgumentsRaw<T, Keys extends string = string> {\n\t/**\n\t * The initial value of the local state.\n\t */\n\tlocal?: {\n\t\t[K in Keys]: JsonSerializable<T>;\n\t};\n\n\t/**\n\t * See {@link BroadcastControlSettings}.\n\t */\n\tsettings?: BroadcastControlSettings | undefined;\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory.latestMap} function.\n *\n * @input\n * @beta\n */\nexport interface LatestMapArguments<T, Keys extends string = string>\n\textends LatestMapArgumentsRaw<T, Keys> {\n\t/**\n\t * An optional function that will be called at runtime to validate data value\n\t * under a key. A runtime validator is strongly recommended.\n\t * @see {@link StateSchemaValidator}.\n\t */\n\tvalidator: StateSchemaValidator<T>;\n\t/**\n\t * An optional function that will be called at runtime to validate the presence\n\t * data key. A runtime validator is strongly recommended when key type is not\n\t * simply `string`.\n\t * @see {@link KeySchemaValidator}.\n\t */\n\tkeyValidator?: KeySchemaValidator<Keys>;\n}\n\n/**\n * Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.\n */\nexport const latestMap: LatestMapFactory = <\n\tT,\n\tKeys extends string = string,\n\tRegistrationKey extends string = string,\n>(\n\targs?: Partial<LatestMapArguments<T, Keys>>,\n): InternalTypes.ManagerFactory<\n\tRegistrationKey,\n\tInternalTypes.MapValueState<T, Keys>,\n\tLatestMapRaw<T, Keys> & LatestMap<T, Keys>\n> => {\n\tconst settings = args?.settings;\n\tconst initialValues = args?.local;\n\tconst validator = args?.validator;\n\tconst isKeyValid = args?.keyValidator ?? anyKeyIsValid;\n\n\tconst timestamp = Date.now();\n\tconst value: InternalTypes.MapValueState<\n\t\tT,\n\t\t// This should be `Keys`, but will only work if properties are optional.\n\t\tstring\n\t> = { rev: 0, items: {} };\n\t// LatestMapRaw takes ownership of values within initialValues.\n\tif (initialValues !== undefined) {\n\t\tfor (const [key, item] of objectEntries(initialValues)) {\n\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\tconst assumedValidKey = key as unknown as Keys;\n\t\t\tvalue.items[assumedValidKey] = {\n\t\t\t\trev: 0,\n\t\t\t\ttimestamp,\n\t\t\t\tvalue: toOpaqueJson(item),\n\t\t\t};\n\t\t}\n\t}\n\tconst factory = (\n\t\tkey: RegistrationKey,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>,\n\t): {\n\t\tinitialData: { value: typeof value; allowableUpdateLatencyMs: number | undefined };\n\t\tmanager: InternalTypes.StateValue<LatestMapRaw<T, Keys> & LatestMap<T, Keys>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<\n\t\t\tLatestMapValueManagerImpl<T, RegistrationKey, Keys>,\n\t\t\tT,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>(\n\t\t\tnew LatestMapValueManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tvalue,\n\t\t\t\tsettings,\n\t\t\t\tvalidator,\n\t\t\t\tisKeyValid,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestMapValueManagerImpl });\n};\n"]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { Listenable } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { DeepReadonly, JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
7
|
+
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js";
|
|
8
|
+
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
9
|
+
import type { LatestClientData, LatestData, ProxiedValueAccessor, RawValueAccessor, StateSchemaValidator, ValueAccessor } from "./latestValueTypes.js";
|
|
10
|
+
import type { Attendee, Presence } from "./presence.js";
|
|
11
|
+
/**
|
|
12
|
+
* Events from {@link LatestRaw}.
|
|
13
|
+
*
|
|
14
|
+
* @sealed
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export interface LatestEvents<T, TRemoteValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> {
|
|
18
|
+
/**
|
|
19
|
+
* Raised when remote client's value is updated, which may be the same value.
|
|
20
|
+
*
|
|
21
|
+
* @eventProperty
|
|
22
|
+
*/
|
|
23
|
+
remoteUpdated: (update: LatestClientData<T, TRemoteValueAccessor>) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Raised when local client's value is updated, which may be the same value.
|
|
26
|
+
*
|
|
27
|
+
* @eventProperty
|
|
28
|
+
*/
|
|
29
|
+
localUpdated: (update: {
|
|
30
|
+
value: DeepReadonly<JsonSerializable<T>>;
|
|
31
|
+
}) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Events from {@link LatestRaw}.
|
|
35
|
+
*
|
|
36
|
+
* @sealed
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export type LatestRawEvents<T> = LatestEvents<T, RawValueAccessor<T>>;
|
|
40
|
+
/**
|
|
41
|
+
* State that provides the latest known value from this client to others and read access to their values.
|
|
42
|
+
* All participant clients must provide a value.
|
|
43
|
+
*
|
|
44
|
+
* @remarks Create using {@link StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}.
|
|
45
|
+
*
|
|
46
|
+
* @sealed
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export type LatestRaw<T> = Latest<T, RawValueAccessor<T>>;
|
|
50
|
+
/**
|
|
51
|
+
* State that provides the latest known value from this client to others and read access to their values.
|
|
52
|
+
* All participant clients must provide a value.
|
|
53
|
+
*
|
|
54
|
+
* @remarks Create using {@link StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}.
|
|
55
|
+
*
|
|
56
|
+
* @sealed
|
|
57
|
+
* @beta
|
|
58
|
+
*/
|
|
59
|
+
export interface Latest<T, TRemoteAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> {
|
|
60
|
+
/**
|
|
61
|
+
* Containing {@link Presence}
|
|
62
|
+
*/
|
|
63
|
+
readonly presence: Presence;
|
|
64
|
+
/**
|
|
65
|
+
* Events for LatestRaw.
|
|
66
|
+
*/
|
|
67
|
+
readonly events: Listenable<LatestEvents<T, TRemoteAccessor>>;
|
|
68
|
+
/**
|
|
69
|
+
* Controls for management of sending updates.
|
|
70
|
+
*/
|
|
71
|
+
readonly controls: BroadcastControls;
|
|
72
|
+
/**
|
|
73
|
+
* Current state for this client.
|
|
74
|
+
* State for this client that will be transmitted to all other connected clients.
|
|
75
|
+
* @remarks Manager assumes ownership of the value and its references. Make a deep clone before
|
|
76
|
+
* setting, if needed. No comparison is done to detect changes; all sets are transmitted.
|
|
77
|
+
*/
|
|
78
|
+
get local(): DeepReadonly<JsonDeserialized<T>>;
|
|
79
|
+
set local(value: JsonSerializable<T>);
|
|
80
|
+
/**
|
|
81
|
+
* Array of {@link Attendee}s that have provided states.
|
|
82
|
+
*/
|
|
83
|
+
getStateAttendees(): Attendee[];
|
|
84
|
+
/**
|
|
85
|
+
* Iterable access to remote clients' values.
|
|
86
|
+
*/
|
|
87
|
+
getRemotes(): IterableIterator<LatestClientData<T, TRemoteAccessor>>;
|
|
88
|
+
/**
|
|
89
|
+
* Access to a specific attendee's value.
|
|
90
|
+
*/
|
|
91
|
+
getRemote(attendee: Attendee): LatestData<T, TRemoteAccessor>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Arguments that are passed to the {@link StateFactory}.{@link LatestFactory|latest} function to create a {@link LatestRaw} State object.
|
|
95
|
+
*
|
|
96
|
+
* @input
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
export interface LatestArgumentsRaw<T extends object | null> {
|
|
100
|
+
/**
|
|
101
|
+
* The initial value of the local state.
|
|
102
|
+
*
|
|
103
|
+
* @remarks
|
|
104
|
+
* `latest` assumes ownership of the value and its references.
|
|
105
|
+
* Make a deep clone before passing, if needed.
|
|
106
|
+
*/
|
|
107
|
+
local: JsonSerializable<T>;
|
|
108
|
+
/**
|
|
109
|
+
* See {@link BroadcastControlSettings}.
|
|
110
|
+
*/
|
|
111
|
+
settings?: BroadcastControlSettings | undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Arguments that are passed to the {@link StateFactory}.{@link LatestFactory|latest} function to create a {@link Latest} State object.
|
|
115
|
+
*
|
|
116
|
+
* @input
|
|
117
|
+
* @beta
|
|
118
|
+
*/
|
|
119
|
+
export interface LatestArguments<T extends object | null> extends LatestArgumentsRaw<T> {
|
|
120
|
+
/**
|
|
121
|
+
* See {@link StateSchemaValidator}.
|
|
122
|
+
*/
|
|
123
|
+
validator: StateSchemaValidator<T>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Factory for creating a {@link Latest} or {@link LatestRaw} State object.
|
|
127
|
+
*
|
|
128
|
+
* @beta
|
|
129
|
+
* @sealed
|
|
130
|
+
*/
|
|
131
|
+
export interface LatestFactory {
|
|
132
|
+
/**
|
|
133
|
+
* Factory for creating a {@link Latest} State object.
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* This overload is used when called with {@link LatestArguments}.
|
|
137
|
+
* That is, if a validator function is provided.
|
|
138
|
+
*/
|
|
139
|
+
<T extends object | null, Key extends string = string>(args: LatestArguments<T>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, Latest<T>>;
|
|
140
|
+
/**
|
|
141
|
+
* Factory for creating a {@link LatestRaw} State object.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* This overload is used when called with {@link LatestArgumentsRaw}.
|
|
145
|
+
* That is, if a validator function is _not_ provided.
|
|
146
|
+
*/
|
|
147
|
+
<T extends object | null, Key extends string = string>(args: LatestArgumentsRaw<T>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>>;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=latestTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latestTypes.d.ts","sourceRoot":"","sources":["../src/latestTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAC5B,CAAC,EACD,oBAAoB,S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ErE;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;CAC9D;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI;IAC1D;;;;;;OAMG;IACH,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAChD;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACtF;;OAEG;IACH,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;;;OAMG;IACH,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,MAAM,EACpD,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GACtB,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAErF;;;;;;OAMG;IACH,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,EAAE,GAAG,SAAS,MAAM,GAAG,MAAM,EACpD,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,GACzB,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CACxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latestTypes.js","sourceRoot":"","sources":["../src/latestTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type {\n\tLatestClientData,\n\tLatestData,\n\tProxiedValueAccessor,\n\tRawValueAccessor,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"./latestValueTypes.js\";\nimport type { Attendee, Presence } from \"./presence.js\";\n\n/**\n * Events from {@link LatestRaw}.\n *\n * @sealed\n * @beta\n */\nexport interface LatestEvents<\n\tT,\n\tTRemoteValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> {\n\t/**\n\t * Raised when remote client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tremoteUpdated: (update: LatestClientData<T, TRemoteValueAccessor>) => void;\n\n\t/**\n\t * Raised when local client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalUpdated: (update: { value: DeepReadonly<JsonSerializable<T>> }) => void;\n}\n\n/**\n * Events from {@link LatestRaw}.\n *\n * @sealed\n * @beta\n */\nexport type LatestRawEvents<T> = LatestEvents<T, RawValueAccessor<T>>;\n\n/**\n * State that provides the latest known value from this client to others and read access to their values.\n * All participant clients must provide a value.\n *\n * @remarks Create using {@link StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type LatestRaw<T> = Latest<T, RawValueAccessor<T>>;\n\n/**\n * State that provides the latest known value from this client to others and read access to their values.\n * All participant clients must provide a value.\n *\n * @remarks Create using {@link StateFactory}.{@link LatestFactory|latest} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport interface Latest<\n\tT,\n\tTRemoteAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for LatestRaw.\n\t */\n\treadonly events: Listenable<LatestEvents<T, TRemoteAccessor>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current state for this client.\n\t * State for this client that will be transmitted to all other connected clients.\n\t * @remarks Manager assumes ownership of the value and its references. Make a deep clone before\n\t * setting, if needed. No comparison is done to detect changes; all sets are transmitted.\n\t */\n\tget local(): DeepReadonly<JsonDeserialized<T>>;\n\tset local(value: JsonSerializable<T>);\n\n\t/**\n\t * Array of {@link Attendee}s that have provided states.\n\t */\n\tgetStateAttendees(): Attendee[];\n\n\t/**\n\t * Iterable access to remote clients' values.\n\t */\n\tgetRemotes(): IterableIterator<LatestClientData<T, TRemoteAccessor>>;\n\n\t/**\n\t * Access to a specific attendee's value.\n\t */\n\tgetRemote(attendee: Attendee): LatestData<T, TRemoteAccessor>;\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory}.{@link LatestFactory|latest} function to create a {@link LatestRaw} State object.\n *\n * @input\n * @beta\n */\nexport interface LatestArgumentsRaw<T extends object | null> {\n\t/**\n\t * The initial value of the local state.\n\t *\n\t * @remarks\n\t * `latest` assumes ownership of the value and its references.\n\t * Make a deep clone before passing, if needed.\n\t */\n\tlocal: JsonSerializable<T>;\n\n\t/**\n\t * See {@link BroadcastControlSettings}.\n\t */\n\tsettings?: BroadcastControlSettings | undefined;\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory}.{@link LatestFactory|latest} function to create a {@link Latest} State object.\n *\n * @input\n * @beta\n */\nexport interface LatestArguments<T extends object | null> extends LatestArgumentsRaw<T> {\n\t/**\n\t * See {@link StateSchemaValidator}.\n\t */\n\tvalidator: StateSchemaValidator<T>;\n}\n\n/**\n * Factory for creating a {@link Latest} or {@link LatestRaw} State object.\n *\n * @beta\n * @sealed\n */\nexport interface LatestFactory {\n\t/**\n\t * Factory for creating a {@link Latest} State object.\n\t *\n\t * @remarks\n\t * This overload is used when called with {@link LatestArguments}.\n\t * That is, if a validator function is provided.\n\t */\n\t<T extends object | null, Key extends string = string>(\n\t\targs: LatestArguments<T>,\n\t): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, Latest<T>>;\n\n\t/**\n\t * Factory for creating a {@link LatestRaw} State object.\n\t *\n\t * @remarks\n\t * This overload is used when called with {@link LatestArgumentsRaw}.\n\t * That is, if a validator function is _not_ provided.\n\t */\n\t<T extends object | null, Key extends string = string>(\n\t\targs: LatestArgumentsRaw<T>,\n\t): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>>;\n}\n"]}
|