@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
|
@@ -0,0 +1,309 @@
|
|
|
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, LatestMetadata, ProxiedValueAccessor, RawValueAccessor, StateSchemaValidator, ValueAccessor } from "./latestValueTypes.js";
|
|
10
|
+
import type { Attendee, AttendeeId, 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}.{@link LatestMapFactory|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}.{@link LatestMapFactory|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>>;
|
|
246
|
+
/**
|
|
247
|
+
* Arguments that are passed to the {@link StateFactory}.{@link LatestMapFactory|latestMap} function.
|
|
248
|
+
*
|
|
249
|
+
* @input
|
|
250
|
+
* @beta
|
|
251
|
+
*/
|
|
252
|
+
export interface LatestMapArgumentsRaw<T, Keys extends string = string> {
|
|
253
|
+
/**
|
|
254
|
+
* The initial value of the local state.
|
|
255
|
+
*/
|
|
256
|
+
local?: {
|
|
257
|
+
[K in Keys]: JsonSerializable<T>;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* See {@link BroadcastControlSettings}.
|
|
261
|
+
*/
|
|
262
|
+
settings?: BroadcastControlSettings | undefined;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Arguments that are passed to the {@link StateFactory}.{@link LatestMapFactory|latestMap} function.
|
|
266
|
+
*
|
|
267
|
+
* @input
|
|
268
|
+
* @beta
|
|
269
|
+
*/
|
|
270
|
+
export interface LatestMapArguments<T, Keys extends string = string> extends LatestMapArgumentsRaw<T, Keys> {
|
|
271
|
+
/**
|
|
272
|
+
* An optional function that will be called at runtime to validate data value
|
|
273
|
+
* under a key. A runtime validator is strongly recommended.
|
|
274
|
+
* @see {@link StateSchemaValidator}.
|
|
275
|
+
*/
|
|
276
|
+
validator: StateSchemaValidator<T>;
|
|
277
|
+
/**
|
|
278
|
+
* An optional function that will be called at runtime to validate the presence
|
|
279
|
+
* data key. A runtime validator is strongly recommended when key type is not
|
|
280
|
+
* simply `string`.
|
|
281
|
+
* @see {@link KeySchemaValidator}.
|
|
282
|
+
*/
|
|
283
|
+
keyValidator?: KeySchemaValidator<Keys>;
|
|
284
|
+
}
|
|
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
|
+
//# sourceMappingURL=latestMapTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latestMapTypes.d.ts","sourceRoot":"","sources":["../src/latestMapTypes.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,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpE;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,CAAC,IAAI,SAAS,MAAM,IAAI,CACrD,cAAc,EAAE,MAAM,KAClB,cAAc,IAAI,IAAI,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAC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C,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;IAEnC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;CACxC;AAKD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,MAAM,EACxE,IAAI,EAAE,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,GAC/B,aAAa,CAAC,cAAc,CAC9B,eAAe,EACf,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,EACpC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAClB,CAAC;IAEF;;;;;;OAMG;IACH,CAAC,CAAC,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,MAAM,EACxE,IAAI,CAAC,EAAE,qBAAqB,CAAC,CAAC,EAAE,IAAI,CAAC,GACnC,aAAa,CAAC,cAAc,CAC9B,eAAe,EACf,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,EACpC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CACrB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latestMapTypes.js","sourceRoot":"","sources":["../src/latestMapTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AA8ZH,aAAa","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\tLatestMetadata,\n\tProxiedValueAccessor,\n\tRawValueAccessor,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"./latestValueTypes.js\";\nimport type { Attendee, AttendeeId, Presence } from \"./presence.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 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\n\t/**\n\t * Key of the removed item.\n\t */\n\tkey: K;\n\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: { key: K }) => 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\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}.{@link LatestMapFactory|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\n\t/**\n\t * Iterable access to remote clients' map of values.\n\t */\n\tgetRemotes(): IterableIterator<LatestMapClientData<T, Keys, TRemoteAccessor>>;\n\n\t/**\n\t * Array of {@link Attendee}s that have provided states.\n\t */\n\tgetStateAttendees(): Attendee[];\n\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}.{@link LatestMapFactory|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 * Arguments that are passed to the {@link StateFactory}.{@link LatestMapFactory|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}.{@link LatestMapFactory|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\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"]}
|
|
@@ -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"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { createEmitter } from "@fluid-internal/client-utils";
|
|
6
6
|
import { OptionalBroadcastControl } from "./broadcastControls.js";
|
|
7
7
|
import { asDeeplyReadonly, asDeeplyReadonlyDeserializedJson, isValueRequiredState, objectEntries, objectKeys, toOpaqueJson, } from "./internalUtils.js";
|
|
8
|
-
import { createValidatedGetter } from "./latestValueTypes.js";
|
|
9
8
|
import { datastoreFromHandle } from "./stateDatastore.js";
|
|
9
|
+
import { createValidatedGetter } from "./validatedGetter.js";
|
|
10
10
|
import { brandIVM } from "./valueManager.js";
|
|
11
11
|
class ValueMapImpl {
|
|
12
12
|
constructor(value, emitter, localUpdate) {
|
|
@@ -215,7 +215,6 @@ class LatestMapValueManagerImpl {
|
|
|
215
215
|
return postUpdateActions;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
// #endregion
|
|
219
218
|
/**
|
|
220
219
|
* Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.
|
|
221
220
|
*/
|