@fluidframework/presence 2.10.0-307399
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/LICENSE +21 -0
- package/README.md +216 -0
- package/dist/alpha.d.ts +58 -0
- package/dist/baseTypes.d.ts +24 -0
- package/dist/baseTypes.d.ts.map +1 -0
- package/dist/baseTypes.js +7 -0
- package/dist/baseTypes.js.map +1 -0
- package/dist/container-definitions/containerExtensions.d.ts +137 -0
- package/dist/container-definitions/containerExtensions.d.ts.map +1 -0
- package/dist/container-definitions/containerExtensions.js +7 -0
- package/dist/container-definitions/containerExtensions.js.map +1 -0
- package/dist/container-definitions/index.d.ts +7 -0
- package/dist/container-definitions/index.d.ts.map +1 -0
- package/dist/container-definitions/index.js +7 -0
- package/dist/container-definitions/index.js.map +1 -0
- package/dist/container-definitions/runtime.d.ts +12 -0
- package/dist/container-definitions/runtime.d.ts.map +1 -0
- package/dist/container-definitions/runtime.js +7 -0
- package/dist/container-definitions/runtime.js.map +1 -0
- package/dist/core-interfaces/exposedUtilityTypes.d.ts +446 -0
- package/dist/core-interfaces/exposedUtilityTypes.d.ts.map +1 -0
- package/dist/core-interfaces/exposedUtilityTypes.js +11 -0
- package/dist/core-interfaces/exposedUtilityTypes.js.map +1 -0
- package/dist/core-interfaces/index.d.ts +10 -0
- package/dist/core-interfaces/index.d.ts.map +1 -0
- package/dist/core-interfaces/index.js +7 -0
- package/dist/core-interfaces/index.js.map +1 -0
- package/dist/core-interfaces/jsonDeserialized.d.ts +109 -0
- package/dist/core-interfaces/jsonDeserialized.d.ts.map +1 -0
- package/dist/core-interfaces/jsonDeserialized.js +7 -0
- package/dist/core-interfaces/jsonDeserialized.js.map +1 -0
- package/dist/core-interfaces/jsonSerializable.d.ts +120 -0
- package/dist/core-interfaces/jsonSerializable.d.ts.map +1 -0
- package/dist/core-interfaces/jsonSerializable.js +7 -0
- package/dist/core-interfaces/jsonSerializable.js.map +1 -0
- package/dist/core-interfaces/jsonSerializationErrors.d.ts +31 -0
- package/dist/core-interfaces/jsonSerializationErrors.d.ts.map +1 -0
- package/dist/core-interfaces/jsonSerializationErrors.js +7 -0
- package/dist/core-interfaces/jsonSerializationErrors.js.map +1 -0
- package/dist/core-interfaces/jsonType.d.ts +29 -0
- package/dist/core-interfaces/jsonType.d.ts.map +1 -0
- package/dist/core-interfaces/jsonType.js +7 -0
- package/dist/core-interfaces/jsonType.js.map +1 -0
- package/dist/datastorePresenceManagerFactory.d.ts +48 -0
- package/dist/datastorePresenceManagerFactory.d.ts.map +1 -0
- package/dist/datastorePresenceManagerFactory.js +79 -0
- package/dist/datastorePresenceManagerFactory.js.map +1 -0
- package/dist/datastoreSupport.d.ts +31 -0
- package/dist/datastoreSupport.d.ts.map +1 -0
- package/dist/datastoreSupport.js +82 -0
- package/dist/datastoreSupport.js.map +1 -0
- package/dist/events/events.d.ts +198 -0
- package/dist/events/events.d.ts.map +1 -0
- package/dist/events/events.js +157 -0
- package/dist/events/events.js.map +1 -0
- package/dist/experimentalAccess.d.ts +15 -0
- package/dist/experimentalAccess.d.ts.map +1 -0
- package/dist/experimentalAccess.js +46 -0
- package/dist/experimentalAccess.js.map +1 -0
- package/dist/exposedInternalTypes.d.ts +100 -0
- package/dist/exposedInternalTypes.d.ts.map +1 -0
- package/dist/exposedInternalTypes.js +19 -0
- package/dist/exposedInternalTypes.js.map +1 -0
- package/dist/exposedUtilityTypes.d.ts +63 -0
- package/dist/exposedUtilityTypes.d.ts.map +1 -0
- package/dist/exposedUtilityTypes.js +7 -0
- package/dist/exposedUtilityTypes.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/internalTypes.d.ts +39 -0
- package/dist/internalTypes.d.ts.map +1 -0
- package/dist/internalTypes.js +14 -0
- package/dist/internalTypes.js.map +1 -0
- package/dist/latestMapValueManager.d.ts +182 -0
- package/dist/latestMapValueManager.d.ts.map +1 -0
- package/dist/latestMapValueManager.js +206 -0
- package/dist/latestMapValueManager.js.map +1 -0
- package/dist/latestValueControls.d.ts +44 -0
- package/dist/latestValueControls.d.ts.map +1 -0
- package/dist/latestValueControls.js +28 -0
- package/dist/latestValueControls.js.map +1 -0
- package/dist/latestValueManager.d.ts +69 -0
- package/dist/latestValueManager.d.ts.map +1 -0
- package/dist/latestValueManager.js +100 -0
- package/dist/latestValueManager.js.map +1 -0
- package/dist/latestValueTypes.d.ts +44 -0
- package/dist/latestValueTypes.d.ts.map +1 -0
- package/dist/latestValueTypes.js +7 -0
- package/dist/latestValueTypes.js.map +1 -0
- package/dist/notificationsManager.d.ts +101 -0
- package/dist/notificationsManager.d.ts.map +1 -0
- package/dist/notificationsManager.js +82 -0
- package/dist/notificationsManager.js.map +1 -0
- package/dist/package.json +15 -0
- package/dist/presence.d.ts +180 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +23 -0
- package/dist/presence.js.map +1 -0
- package/dist/presenceDatastoreManager.d.ts +91 -0
- package/dist/presenceDatastoreManager.d.ts.map +1 -0
- package/dist/presenceDatastoreManager.js +248 -0
- package/dist/presenceDatastoreManager.js.map +1 -0
- package/dist/presenceManager.d.ts +20 -0
- package/dist/presenceManager.d.ts.map +1 -0
- package/dist/presenceManager.js +104 -0
- package/dist/presenceManager.js.map +1 -0
- package/dist/presenceStates.d.ts +78 -0
- package/dist/presenceStates.d.ts.map +1 -0
- package/dist/presenceStates.js +182 -0
- package/dist/presenceStates.js.map +1 -0
- package/dist/stateDatastore.d.ts +35 -0
- package/dist/stateDatastore.d.ts.map +1 -0
- package/dist/stateDatastore.js +26 -0
- package/dist/stateDatastore.js.map +1 -0
- package/dist/systemWorkspace.d.ts +51 -0
- package/dist/systemWorkspace.d.ts.map +1 -0
- package/dist/systemWorkspace.js +180 -0
- package/dist/systemWorkspace.js.map +1 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/dist/valueManager.d.ts +19 -0
- package/dist/valueManager.d.ts.map +1 -0
- package/dist/valueManager.js +26 -0
- package/dist/valueManager.js.map +1 -0
- package/lib/alpha.d.ts +58 -0
- package/lib/baseTypes.d.ts +24 -0
- package/lib/baseTypes.d.ts.map +1 -0
- package/lib/baseTypes.js +6 -0
- package/lib/baseTypes.js.map +1 -0
- package/lib/container-definitions/containerExtensions.d.ts +137 -0
- package/lib/container-definitions/containerExtensions.d.ts.map +1 -0
- package/lib/container-definitions/containerExtensions.js +6 -0
- package/lib/container-definitions/containerExtensions.js.map +1 -0
- package/lib/container-definitions/index.d.ts +7 -0
- package/lib/container-definitions/index.d.ts.map +1 -0
- package/lib/container-definitions/index.js +6 -0
- package/lib/container-definitions/index.js.map +1 -0
- package/lib/container-definitions/runtime.d.ts +12 -0
- package/lib/container-definitions/runtime.d.ts.map +1 -0
- package/lib/container-definitions/runtime.js +6 -0
- package/lib/container-definitions/runtime.js.map +1 -0
- package/lib/core-interfaces/exposedUtilityTypes.d.ts +446 -0
- package/lib/core-interfaces/exposedUtilityTypes.d.ts.map +1 -0
- package/lib/core-interfaces/exposedUtilityTypes.js +10 -0
- package/lib/core-interfaces/exposedUtilityTypes.js.map +1 -0
- package/lib/core-interfaces/index.d.ts +10 -0
- package/lib/core-interfaces/index.d.ts.map +1 -0
- package/lib/core-interfaces/index.js +6 -0
- package/lib/core-interfaces/index.js.map +1 -0
- package/lib/core-interfaces/jsonDeserialized.d.ts +109 -0
- package/lib/core-interfaces/jsonDeserialized.d.ts.map +1 -0
- package/lib/core-interfaces/jsonDeserialized.js +6 -0
- package/lib/core-interfaces/jsonDeserialized.js.map +1 -0
- package/lib/core-interfaces/jsonSerializable.d.ts +120 -0
- package/lib/core-interfaces/jsonSerializable.d.ts.map +1 -0
- package/lib/core-interfaces/jsonSerializable.js +6 -0
- package/lib/core-interfaces/jsonSerializable.js.map +1 -0
- package/lib/core-interfaces/jsonSerializationErrors.d.ts +31 -0
- package/lib/core-interfaces/jsonSerializationErrors.d.ts.map +1 -0
- package/lib/core-interfaces/jsonSerializationErrors.js +6 -0
- package/lib/core-interfaces/jsonSerializationErrors.js.map +1 -0
- package/lib/core-interfaces/jsonType.d.ts +29 -0
- package/lib/core-interfaces/jsonType.d.ts.map +1 -0
- package/lib/core-interfaces/jsonType.js +6 -0
- package/lib/core-interfaces/jsonType.js.map +1 -0
- package/lib/datastorePresenceManagerFactory.d.ts +48 -0
- package/lib/datastorePresenceManagerFactory.d.ts.map +1 -0
- package/lib/datastorePresenceManagerFactory.js +75 -0
- package/lib/datastorePresenceManagerFactory.js.map +1 -0
- package/lib/datastoreSupport.d.ts +31 -0
- package/lib/datastoreSupport.d.ts.map +1 -0
- package/lib/datastoreSupport.js +77 -0
- package/lib/datastoreSupport.js.map +1 -0
- package/lib/events/events.d.ts +198 -0
- package/lib/events/events.d.ts.map +1 -0
- package/lib/events/events.js +152 -0
- package/lib/events/events.js.map +1 -0
- package/lib/experimentalAccess.d.ts +15 -0
- package/lib/experimentalAccess.d.ts.map +1 -0
- package/lib/experimentalAccess.js +42 -0
- package/lib/experimentalAccess.js.map +1 -0
- package/lib/exposedInternalTypes.d.ts +100 -0
- package/lib/exposedInternalTypes.d.ts.map +1 -0
- package/lib/exposedInternalTypes.js +16 -0
- package/lib/exposedInternalTypes.js.map +1 -0
- package/lib/exposedUtilityTypes.d.ts +63 -0
- package/lib/exposedUtilityTypes.d.ts.map +1 -0
- package/lib/exposedUtilityTypes.js +6 -0
- package/lib/exposedUtilityTypes.js.map +1 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/internalTypes.d.ts +39 -0
- package/lib/internalTypes.d.ts.map +1 -0
- package/lib/internalTypes.js +11 -0
- package/lib/internalTypes.js.map +1 -0
- package/lib/latestMapValueManager.d.ts +182 -0
- package/lib/latestMapValueManager.d.ts.map +1 -0
- package/lib/latestMapValueManager.js +202 -0
- package/lib/latestMapValueManager.js.map +1 -0
- package/lib/latestValueControls.d.ts +44 -0
- package/lib/latestValueControls.d.ts.map +1 -0
- package/lib/latestValueControls.js +24 -0
- package/lib/latestValueControls.js.map +1 -0
- package/lib/latestValueManager.d.ts +69 -0
- package/lib/latestValueManager.d.ts.map +1 -0
- package/lib/latestValueManager.js +96 -0
- package/lib/latestValueManager.js.map +1 -0
- package/lib/latestValueTypes.d.ts +44 -0
- package/lib/latestValueTypes.d.ts.map +1 -0
- package/lib/latestValueTypes.js +6 -0
- package/lib/latestValueTypes.js.map +1 -0
- package/lib/notificationsManager.d.ts +101 -0
- package/lib/notificationsManager.d.ts.map +1 -0
- package/lib/notificationsManager.js +78 -0
- package/lib/notificationsManager.js.map +1 -0
- package/lib/presence.d.ts +180 -0
- package/lib/presence.d.ts.map +1 -0
- package/lib/presence.js +20 -0
- package/lib/presence.js.map +1 -0
- package/lib/presenceDatastoreManager.d.ts +91 -0
- package/lib/presenceDatastoreManager.d.ts.map +1 -0
- package/lib/presenceDatastoreManager.js +244 -0
- package/lib/presenceDatastoreManager.js.map +1 -0
- package/lib/presenceManager.d.ts +20 -0
- package/lib/presenceManager.d.ts.map +1 -0
- package/lib/presenceManager.js +100 -0
- package/lib/presenceManager.js.map +1 -0
- package/lib/presenceStates.d.ts +78 -0
- package/lib/presenceStates.d.ts.map +1 -0
- package/lib/presenceStates.js +177 -0
- package/lib/presenceStates.js.map +1 -0
- package/lib/stateDatastore.d.ts +35 -0
- package/lib/stateDatastore.d.ts.map +1 -0
- package/lib/stateDatastore.js +21 -0
- package/lib/stateDatastore.js.map +1 -0
- package/lib/systemWorkspace.d.ts +51 -0
- package/lib/systemWorkspace.d.ts.map +1 -0
- package/lib/systemWorkspace.js +176 -0
- package/lib/systemWorkspace.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types.d.ts +92 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +7 -0
- package/lib/types.js.map +1 -0
- package/lib/valueManager.d.ts +19 -0
- package/lib/valueManager.d.ts.map +1 -0
- package/lib/valueManager.js +21 -0
- package/lib/valueManager.js.map +1 -0
- package/package.json +175 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { InternalUtilityTypes as CoreInternalUtilityTypes, JsonDeserialized, JsonSerializable } from "@fluidframework/presence/internal/core-interfaces";
|
|
6
|
+
/**
|
|
7
|
+
* Collection of utility types that are not intended to be used/imported
|
|
8
|
+
* directly outside of this package.
|
|
9
|
+
*
|
|
10
|
+
* @alpha
|
|
11
|
+
* @system
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace InternalUtilityTypes {
|
|
14
|
+
/**
|
|
15
|
+
* Recursively/deeply makes all properties of a type readonly.
|
|
16
|
+
*
|
|
17
|
+
* @system
|
|
18
|
+
*/
|
|
19
|
+
type FullyReadonly<T> = {
|
|
20
|
+
readonly [K in keyof T]: FullyReadonly<T[K]>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `true` iff the given type is an acceptable shape for a notification.
|
|
24
|
+
*
|
|
25
|
+
* @system
|
|
26
|
+
*/
|
|
27
|
+
type IsNotificationEvent<Event> = Event extends (...args: infer P) => void ? CoreInternalUtilityTypes.IfSameType<P, JsonSerializable<P> & JsonDeserialized<P>, true, false> : false;
|
|
28
|
+
/**
|
|
29
|
+
* Used to specify the kinds of notifications emitted by a {@link NotificationSubscribable}.
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
*
|
|
33
|
+
* Any object type is a valid NotificationEvents, but only the notification-like
|
|
34
|
+
* properties of that type will be included.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* interface MyNotifications {
|
|
40
|
+
* load: (user: string, data: IUserData) => void;
|
|
41
|
+
* requestPause: (period: number) => void;
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @system
|
|
46
|
+
*/
|
|
47
|
+
type NotificationEvents<E> = {
|
|
48
|
+
[P in string & keyof E as IsNotificationEvent<E[P]> extends true ? P : never]: E[P];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* {@link @fluidframework/core-interfaces#JsonDeserialized} version of the parameters of a function.
|
|
52
|
+
*
|
|
53
|
+
* @system
|
|
54
|
+
*/
|
|
55
|
+
type JsonDeserializedParameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? JsonDeserialized<P> : never;
|
|
56
|
+
/**
|
|
57
|
+
* {@link @fluidframework/core-interfaces#JsonSerializable} version of the parameters of a function.
|
|
58
|
+
*
|
|
59
|
+
* @system
|
|
60
|
+
*/
|
|
61
|
+
type JsonSerializableParameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? JsonSerializable<P> : never;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=exposedUtilityTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposedUtilityTypes.d.ts","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,oBAAoB,IAAI,wBAAwB,EAChD,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,mDAAmD,CAAC;AAE3D;;;;;;GAMG;AAEH,yBAAiB,oBAAoB,CAAC;IACrC;;;;OAIG;IACH,KAAY,aAAa,CAAC,CAAC,IAAI;QAC9B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5C,CAAC;IAEF;;;;OAIG;IACH,KAAY,mBAAmB,CAAC,KAAK,IAAI,KAAK,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,IAAI,GAC9E,wBAAwB,CAAC,UAAU,CACnC,CAAC,EACD,gBAAgB,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,EACzC,IAAI,EACJ,KAAK,CACL,GACA,KAAK,CAAC;IAET;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAY,kBAAkB,CAAC,CAAC,IAAI;SAClC,CAAC,IAAI,MAAM,GAAG,MAAM,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;KACnF,CAAC;IAEF;;;;OAIG;IACH,KAAY,0BAA0B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CACnF,GAAG,IAAI,EAAE,MAAM,CAAC,KACZ,GAAG,GACL,gBAAgB,CAAC,CAAC,CAAC,GACnB,KAAK,CAAC;IAET;;;;OAIG;IACH,KAAY,0BAA0B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC,SAAS,CACnF,GAAG,IAAI,EAAE,MAAM,CAAC,KACZ,GAAG,GACL,gBAAgB,CAAC,CAAC,CAAC,GACnB,KAAK,CAAC;CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exposedUtilityTypes.js","sourceRoot":"","sources":["../src/exposedUtilityTypes.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 {\n\tInternalUtilityTypes as CoreInternalUtilityTypes,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/presence/internal/core-interfaces\";\n\n/**\n * Collection of utility types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @alpha\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/**\n\t * Recursively/deeply makes all properties of a type readonly.\n\t *\n\t * @system\n\t */\n\texport type FullyReadonly<T> = {\n\t\treadonly [K in keyof T]: FullyReadonly<T[K]>;\n\t};\n\n\t/**\n\t * `true` iff the given type is an acceptable shape for a notification.\n\t *\n\t * @system\n\t */\n\texport type IsNotificationEvent<Event> = Event extends (...args: infer P) => void\n\t\t? CoreInternalUtilityTypes.IfSameType<\n\t\t\t\tP,\n\t\t\t\tJsonSerializable<P> & JsonDeserialized<P>,\n\t\t\t\ttrue,\n\t\t\t\tfalse\n\t\t\t>\n\t\t: false;\n\n\t/**\n\t * Used to specify the kinds of notifications emitted by a {@link NotificationSubscribable}.\n\t *\n\t * @remarks\n\t *\n\t * Any object type is a valid NotificationEvents, but only the notification-like\n\t * properties of that type will be included.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * interface MyNotifications {\n\t * load: (user: string, data: IUserData) => void;\n\t * requestPause: (period: number) => void;\n\t * }\n\t * ```\n\t *\n\t * @system\n\t */\n\texport type NotificationEvents<E> = {\n\t\t[P in string & keyof E as IsNotificationEvent<E[P]> extends true ? P : never]: E[P];\n\t};\n\n\t/**\n\t * {@link @fluidframework/core-interfaces#JsonDeserialized} version of the parameters of a function.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedParameters<T extends (...args: any) => any> = T extends (\n\t\t...args: infer P\n\t) => any\n\t\t? JsonDeserialized<P>\n\t\t: never;\n\n\t/**\n\t * {@link @fluidframework/core-interfaces#JsonSerializable} version of the parameters of a function.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableParameters<T extends (...args: any) => any> = T extends (\n\t\t...args: infer P\n\t) => any\n\t\t? JsonSerializable<P>\n\t\t: never;\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Experimental package for client presence within a connected session.
|
|
7
|
+
*
|
|
8
|
+
* See {@link https://github.com/microsoft/FluidFramework/tree/main/packages/framework/presence#readme | README.md } for an overview of the package.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export type { ClientConnectionId } from "./baseTypes.js";
|
|
13
|
+
export type { PresenceNotifications, PresenceNotificationsSchema, PresenceStates, PresenceStatesEntries, PresenceStatesEntry, PresenceStatesSchema, PresenceWorkspaceAddress, } from "./types.js";
|
|
14
|
+
export { type ClientSessionId, type IPresence, type ISessionClient, type PresenceEvents, SessionClientStatus, } from "./presence.js";
|
|
15
|
+
export { acquirePresence } from "./experimentalAccess.js";
|
|
16
|
+
export { acquirePresenceViaDataObject, type ExperimentalPresenceDO, ExperimentalPresenceManager, } from "./datastorePresenceManagerFactory.js";
|
|
17
|
+
export type { LatestValueControls } from "./latestValueControls.js";
|
|
18
|
+
export { LatestMap, type LatestMapItemRemovedClientData, type LatestMapItemValueClientData, type LatestMapValueClientData, type LatestMapValueManager, type LatestMapValueManagerEvents, type ValueMap, } from "./latestMapValueManager.js";
|
|
19
|
+
export { Latest, type LatestValueManager, type LatestValueManagerEvents, } from "./latestValueManager.js";
|
|
20
|
+
export type { LatestValueClientData, LatestValueData, LatestValueMetadata, } from "./latestValueTypes.js";
|
|
21
|
+
export { type NotificationEmitter, type NotificationSubscribable, type NotificationSubscriptions, Notifications, type NotificationsManager, type NotificationsManagerEvents, } from "./notificationsManager.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAgBH,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,YAAY,EACX,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,mBAAmB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EACN,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,2BAA2B,GAC3B,MAAM,sCAAsC,CAAC;AAE9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EACN,SAAS,EACT,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,QAAQ,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,MAAM,EACN,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,GAC7B,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,qBAAqB,EACrB,eAAe,EACf,mBAAmB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,aAAa,EACb,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,GAC/B,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Notifications = exports.Latest = exports.LatestMap = exports.ExperimentalPresenceManager = exports.acquirePresenceViaDataObject = exports.acquirePresence = exports.SessionClientStatus = void 0;
|
|
8
|
+
var presence_js_1 = require("./presence.js");
|
|
9
|
+
Object.defineProperty(exports, "SessionClientStatus", { enumerable: true, get: function () { return presence_js_1.SessionClientStatus; } });
|
|
10
|
+
var experimentalAccess_js_1 = require("./experimentalAccess.js");
|
|
11
|
+
Object.defineProperty(exports, "acquirePresence", { enumerable: true, get: function () { return experimentalAccess_js_1.acquirePresence; } });
|
|
12
|
+
var datastorePresenceManagerFactory_js_1 = require("./datastorePresenceManagerFactory.js");
|
|
13
|
+
Object.defineProperty(exports, "acquirePresenceViaDataObject", { enumerable: true, get: function () { return datastorePresenceManagerFactory_js_1.acquirePresenceViaDataObject; } });
|
|
14
|
+
Object.defineProperty(exports, "ExperimentalPresenceManager", { enumerable: true, get: function () { return datastorePresenceManagerFactory_js_1.ExperimentalPresenceManager; } });
|
|
15
|
+
var latestMapValueManager_js_1 = require("./latestMapValueManager.js");
|
|
16
|
+
Object.defineProperty(exports, "LatestMap", { enumerable: true, get: function () { return latestMapValueManager_js_1.LatestMap; } });
|
|
17
|
+
var latestValueManager_js_1 = require("./latestValueManager.js");
|
|
18
|
+
Object.defineProperty(exports, "Latest", { enumerable: true, get: function () { return latestValueManager_js_1.Latest; } });
|
|
19
|
+
var notificationsManager_js_1 = require("./notificationsManager.js");
|
|
20
|
+
Object.defineProperty(exports, "Notifications", { enumerable: true, get: function () { return notificationsManager_js_1.Notifications; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoCH,6CAMuB;AADtB,kHAAA,mBAAmB,OAAA;AAGpB,iEAA0D;AAAjD,wHAAA,eAAe,OAAA;AAExB,2FAI8C;AAH7C,kJAAA,4BAA4B,OAAA;AAE5B,iJAAA,2BAA2B,OAAA;AAI5B,uEAQoC;AAPnC,qHAAA,SAAS,OAAA;AAQV,iEAIiC;AAHhC,+GAAA,MAAM,OAAA;AAUP,qEAOmC;AAHlC,wHAAA,aAAa,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Experimental package for client presence within a connected session.\n *\n * See {@link https://github.com/microsoft/FluidFramework/tree/main/packages/framework/presence#readme | README.md } for an overview of the package.\n *\n * @packageDocumentation\n */\n\n// If desired these are the \"required\" types from core-interfaces.\n// export type {\n// \tInternalUtilityTypes,\n// \tJsonDeserialized,\n// \tJsonSerializable,\n// } from \"@fluidframework/presence/internal/core-interfaces\";\n\n// If desired these are the \"required\" types from events.\n// export type {\n// \tEvents,\n// \tIsEvent,\n// \tISubscribable,\n// } from \"@fluidframework/presence/internal/events\";\n\nexport type { ClientConnectionId } from \"./baseTypes.js\";\n\nexport type {\n\tPresenceNotifications,\n\tPresenceNotificationsSchema,\n\tPresenceStates,\n\tPresenceStatesEntries,\n\tPresenceStatesEntry,\n\tPresenceStatesSchema,\n\tPresenceWorkspaceAddress,\n} from \"./types.js\";\n\nexport {\n\ttype ClientSessionId,\n\ttype IPresence,\n\ttype ISessionClient,\n\ttype PresenceEvents,\n\tSessionClientStatus,\n} from \"./presence.js\";\n\nexport { acquirePresence } from \"./experimentalAccess.js\";\n\nexport {\n\tacquirePresenceViaDataObject,\n\ttype ExperimentalPresenceDO,\n\tExperimentalPresenceManager,\n} from \"./datastorePresenceManagerFactory.js\";\n\nexport type { LatestValueControls } from \"./latestValueControls.js\";\nexport {\n\tLatestMap,\n\ttype LatestMapItemRemovedClientData,\n\ttype LatestMapItemValueClientData,\n\ttype LatestMapValueClientData,\n\ttype LatestMapValueManager,\n\ttype LatestMapValueManagerEvents,\n\ttype ValueMap,\n} from \"./latestMapValueManager.js\";\nexport {\n\tLatest,\n\ttype LatestValueManager,\n\ttype LatestValueManagerEvents,\n} from \"./latestValueManager.js\";\nexport type {\n\tLatestValueClientData,\n\tLatestValueData,\n\tLatestValueMetadata,\n} from \"./latestValueTypes.js\";\n\nexport {\n\ttype NotificationEmitter,\n\ttype NotificationSubscribable,\n\ttype NotificationSubscriptions,\n\tNotifications,\n\ttype NotificationsManager,\n\ttype NotificationsManagerEvents,\n} from \"./notificationsManager.js\";\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
6
|
+
import type { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
7
|
+
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
8
|
+
import type { ClientSessionId, ISessionClient } from "./presence.js";
|
|
9
|
+
import type { IRuntimeInternal } from "@fluidframework/presence/internal/container-definitions/internal";
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface ClientRecord<TValue extends InternalTypes.ValueDirectoryOrState<unknown> | undefined> {
|
|
14
|
+
[ClientSessionId: ClientSessionId]: Exclude<TValue, undefined>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Object.entries retyped to support branded string-based keys.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const brandedObjectEntries: <K extends string, T>(o: Record<K, T>) => [K, T][];
|
|
22
|
+
/**
|
|
23
|
+
* This interface is a subset of (IContainerRuntime & IRuntimeInternal) and
|
|
24
|
+
* (IFluidDataStoreRuntime) that is needed by the Presence States.
|
|
25
|
+
*
|
|
26
|
+
* @privateRemarks
|
|
27
|
+
* Replace with non-DataStore based interface.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export type IEphemeralRuntime = Pick<(IContainerRuntime & IRuntimeInternal) | IFluidDataStoreRuntime, "clientId" | "connected" | "getAudience" | "getQuorum" | "off" | "on" | "submitSignal"> & Partial<Pick<IFluidDataStoreRuntime, "logger">>;
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
|
|
36
|
+
readonly value?: TValueState;
|
|
37
|
+
update(client: ISessionClient, received: number, value: TValueState): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=internalTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalTypes.d.ts","sourceRoot":"","sources":["../src/internalTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,SAAS;IAKvE,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAC/D;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,2BAC7B,OAAO,CAAC,EAAE,CAAC,CAAC,KACX,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAEd;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CACnC,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,sBAAsB,EAC/D,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI,GAAG,cAAc,CACtF,GACA,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,MAAM,EACN,WAAW,SACV,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAG1F,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.brandedObjectEntries = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Object.entries retyped to support branded string-based keys.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
exports.brandedObjectEntries = Object.entries;
|
|
14
|
+
//# sourceMappingURL=internalTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalTypes.js","sourceRoot":"","sources":["../src/internalTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsBH;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC,OAE9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ClientSessionId, ISessionClient } from \"./presence.js\";\n\nimport type { IRuntimeInternal } from \"@fluidframework/presence/internal/container-definitions/internal\";\n\n/**\n * @internal\n */\nexport interface ClientRecord<\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown> | undefined,\n> {\n\t// Caution: any particular item may or may not exist\n\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t[ClientSessionId: ClientSessionId]: Exclude<TValue, undefined>;\n}\n\n/**\n * Object.entries retyped to support branded string-based keys.\n *\n * @internal\n */\nexport const brandedObjectEntries = Object.entries as <K extends string, T>(\n\to: Record<K, T>,\n) => [K, T][];\n\n/**\n * This interface is a subset of (IContainerRuntime & IRuntimeInternal) and\n * (IFluidDataStoreRuntime) that is needed by the Presence States.\n *\n * @privateRemarks\n * Replace with non-DataStore based interface.\n *\n * @internal\n */\nexport type IEphemeralRuntime = Pick<\n\t(IContainerRuntime & IRuntimeInternal) | IFluidDataStoreRuntime,\n\t\"clientId\" | \"connected\" | \"getAudience\" | \"getQuorum\" | \"off\" | \"on\" | \"submitSignal\"\n> &\n\tPartial<Pick<IFluidDataStoreRuntime, \"logger\">>;\n\n/**\n * @internal\n */\nexport interface ValueManager<\n\tTValue,\n\tTValueState extends\n\t\tInternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>,\n> {\n\t// Most value managers should provide value - implement Required<ValueManager<...>>\n\treadonly value?: TValueState;\n\tupdate(client: ISessionClient, received: number, value: TValueState): void;\n}\n"]}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { LatestValueControls } from "./latestValueControls.js";
|
|
6
|
+
import type { LatestValueClientData, LatestValueData, LatestValueMetadata } from "./latestValueTypes.js";
|
|
7
|
+
import type { ClientSessionId, ISessionClient } from "./presence.js";
|
|
8
|
+
import type { JsonDeserialized, JsonSerializable } from "@fluidframework/presence/internal/core-interfaces";
|
|
9
|
+
import type { ISubscribable } from "@fluidframework/presence/internal/events";
|
|
10
|
+
import type { InternalTypes } from "@fluidframework/presence/internal/exposedInternalTypes";
|
|
11
|
+
import type { InternalUtilityTypes } from "@fluidframework/presence/internal/exposedUtilityTypes";
|
|
12
|
+
/**
|
|
13
|
+
* Collection of latest known values for a specific client.
|
|
14
|
+
*
|
|
15
|
+
* @sealed
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
|
+
export interface LatestMapValueClientData<T, Keys extends string | number, SpecificSessionClientId extends ClientSessionId = ClientSessionId> {
|
|
19
|
+
/**
|
|
20
|
+
* Associated client.
|
|
21
|
+
*/
|
|
22
|
+
client: ISessionClient<SpecificSessionClientId>;
|
|
23
|
+
/**
|
|
24
|
+
* @privateRemarks This could be regular map currently as no Map is
|
|
25
|
+
* stored internally and a new instance is created for every request.
|
|
26
|
+
*/
|
|
27
|
+
items: ReadonlyMap<Keys, LatestValueData<T>>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* State of a single item value, its key, and its metadata.
|
|
31
|
+
*
|
|
32
|
+
* @sealed
|
|
33
|
+
* @alpha
|
|
34
|
+
*/
|
|
35
|
+
export interface LatestMapItemValueClientData<T, K extends string | number> extends LatestValueClientData<T> {
|
|
36
|
+
key: K;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Identifier and metadata for a removed item.
|
|
40
|
+
*
|
|
41
|
+
* @sealed
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
export interface LatestMapItemRemovedClientData<K extends string | number> {
|
|
45
|
+
client: ISessionClient;
|
|
46
|
+
key: K;
|
|
47
|
+
metadata: LatestValueMetadata;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @sealed
|
|
51
|
+
* @alpha
|
|
52
|
+
*/
|
|
53
|
+
export interface LatestMapValueManagerEvents<T, K extends string | number> {
|
|
54
|
+
/**
|
|
55
|
+
* Raised when any item's value for remote client is updated.
|
|
56
|
+
* @param updates - Map of one or more values updated.
|
|
57
|
+
*
|
|
58
|
+
* @remarks The event does not include item removals.
|
|
59
|
+
*
|
|
60
|
+
* @eventProperty
|
|
61
|
+
*/
|
|
62
|
+
updated: (updates: LatestMapValueClientData<T, K>) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Raised when specific item's value is updated.
|
|
65
|
+
* @param updatedItem - Updated item value.
|
|
66
|
+
*
|
|
67
|
+
* @eventProperty
|
|
68
|
+
*/
|
|
69
|
+
itemUpdated: (updatedItem: LatestMapItemValueClientData<T, K>) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Raised when specific item is removed.
|
|
72
|
+
* @param removedItem - Removed item.
|
|
73
|
+
*
|
|
74
|
+
* @eventProperty
|
|
75
|
+
*/
|
|
76
|
+
itemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Map of local client's values. Modifications are transmitted to all other connected clients.
|
|
80
|
+
*
|
|
81
|
+
* @sealed
|
|
82
|
+
* @alpha
|
|
83
|
+
*/
|
|
84
|
+
export interface ValueMap<K extends string | number, V> {
|
|
85
|
+
/**
|
|
86
|
+
* ${@link ValueMap.delete}s all elements in the ValueMap.
|
|
87
|
+
* @remarks This is not yet implemented.
|
|
88
|
+
*/
|
|
89
|
+
clear(): void;
|
|
90
|
+
/**
|
|
91
|
+
* @returns true if an element in the ValueMap existed and has been removed, or false if
|
|
92
|
+
* the element does not exist.
|
|
93
|
+
* @remarks No entry is fully removed. Instead an undefined placeholder is locally and
|
|
94
|
+
* transmitted to all other clients. For better performance limit the number of deleted
|
|
95
|
+
* entries and reuse keys when possible.
|
|
96
|
+
* @privateRemarks In the future we may add a mechanism to remove the placeholder, at least
|
|
97
|
+
* from transmissions after sufficient time has passed.
|
|
98
|
+
*/
|
|
99
|
+
delete(key: K): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Executes a provided function once per each key/value pair in the ValueMap, in arbitrary order.
|
|
102
|
+
*/
|
|
103
|
+
forEach(callbackfn: (value: InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>, key: K, map: ValueMap<K, V>) => void, thisArg?: unknown): void;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a specified element from the ValueMap object.
|
|
106
|
+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
107
|
+
*/
|
|
108
|
+
get(key: K): InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>> | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
111
|
+
*/
|
|
112
|
+
has(key: K): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Adds a new element with a specified key and value to the ValueMap. If an element with the same key already exists, the element will be updated.
|
|
115
|
+
* The value will be transmitted to all other connected clients.
|
|
116
|
+
*
|
|
117
|
+
* @remarks Manager assumes ownership of the value and its references.
|
|
118
|
+
* Make a deep clone before setting, if needed. No comparison is done to detect changes; all
|
|
119
|
+
* sets are transmitted.
|
|
120
|
+
*/
|
|
121
|
+
set(key: K, value: JsonSerializable<V> & JsonDeserialized<V>): this;
|
|
122
|
+
/**
|
|
123
|
+
* @returns the number of elements in the ValueMap.
|
|
124
|
+
*/
|
|
125
|
+
readonly size: number;
|
|
126
|
+
/**
|
|
127
|
+
* Returns an iterable of entries in the map.
|
|
128
|
+
*/
|
|
129
|
+
/**
|
|
130
|
+
* Returns an iterable of key, value pairs for every entry in the map.
|
|
131
|
+
*/
|
|
132
|
+
/**
|
|
133
|
+
* Returns an iterable of keys in the map.
|
|
134
|
+
*/
|
|
135
|
+
keys(): IterableIterator<K>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Value manager that provides a `Map` of latest known values from this client to
|
|
139
|
+
* others and read access to their values.
|
|
140
|
+
* Entries in the map may vary over time and by client, but all values are expected to
|
|
141
|
+
* be of the same type, which may be a union type.
|
|
142
|
+
*
|
|
143
|
+
* @remarks Create using {@link LatestMap} registered to {@link PresenceStates}.
|
|
144
|
+
*
|
|
145
|
+
* @sealed
|
|
146
|
+
* @alpha
|
|
147
|
+
*/
|
|
148
|
+
export interface LatestMapValueManager<T, Keys extends string | number = string | number> {
|
|
149
|
+
/**
|
|
150
|
+
* Events for LatestMap value manager.
|
|
151
|
+
*/
|
|
152
|
+
readonly events: ISubscribable<LatestMapValueManagerEvents<T, Keys>>;
|
|
153
|
+
/**
|
|
154
|
+
* Controls for management of sending updates.
|
|
155
|
+
*/
|
|
156
|
+
readonly controls: LatestValueControls;
|
|
157
|
+
/**
|
|
158
|
+
* Current value map for this client.
|
|
159
|
+
*/
|
|
160
|
+
readonly local: ValueMap<Keys, T>;
|
|
161
|
+
/**
|
|
162
|
+
* Iterable access to remote clients' map of values.
|
|
163
|
+
*/
|
|
164
|
+
clientValues(): IterableIterator<LatestMapValueClientData<T, Keys>>;
|
|
165
|
+
/**
|
|
166
|
+
* Array of known clients.
|
|
167
|
+
*/
|
|
168
|
+
clients(): ISessionClient[];
|
|
169
|
+
/**
|
|
170
|
+
* Access to a specific client's map of values.
|
|
171
|
+
*/
|
|
172
|
+
clientValue(client: ISessionClient): ReadonlyMap<Keys, LatestValueData<T>>;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Factory for creating a {@link LatestMapValueManager}.
|
|
176
|
+
*
|
|
177
|
+
* @alpha
|
|
178
|
+
*/
|
|
179
|
+
export declare function LatestMap<T extends object, Keys extends string | number = string | number, RegistrationKey extends string = string>(initialValues?: {
|
|
180
|
+
[K in Keys]: JsonSerializable<T> & JsonDeserialized<T>;
|
|
181
|
+
}, controls?: LatestValueControls): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T>, LatestMapValueManager<T, Keys>>;
|
|
182
|
+
//# sourceMappingURL=latestMapValueManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"latestMapValueManager.d.ts","sour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) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LatestMap = void 0;
|
|
8
|
+
const latestValueControls_js_1 = require("./latestValueControls.js");
|
|
9
|
+
const stateDatastore_js_1 = require("./stateDatastore.js");
|
|
10
|
+
const valueManager_js_1 = require("./valueManager.js");
|
|
11
|
+
const events_1 = require("@fluidframework/presence/internal/events");
|
|
12
|
+
class ValueMapImpl {
|
|
13
|
+
constructor(value, localUpdate) {
|
|
14
|
+
this.value = value;
|
|
15
|
+
this.localUpdate = localUpdate;
|
|
16
|
+
// All initial items are expected to be defined.
|
|
17
|
+
// TODO assert all defined and/or update type.
|
|
18
|
+
this.countDefined = Object.keys(value.items).length;
|
|
19
|
+
}
|
|
20
|
+
updateItem(key, value) {
|
|
21
|
+
this.value.rev += 1;
|
|
22
|
+
const item = this.value.items[key];
|
|
23
|
+
item.rev += 1;
|
|
24
|
+
item.timestamp = Date.now();
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
delete item.value;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
item.value = value;
|
|
30
|
+
}
|
|
31
|
+
const update = { rev: this.value.rev, items: { [key]: item } };
|
|
32
|
+
this.localUpdate(update, /* forceUpdate */ false);
|
|
33
|
+
}
|
|
34
|
+
clear() {
|
|
35
|
+
throw new Error("Method not implemented.");
|
|
36
|
+
}
|
|
37
|
+
delete(key) {
|
|
38
|
+
const { items } = this.value;
|
|
39
|
+
const hasKey = items[key]?.value !== undefined;
|
|
40
|
+
if (hasKey) {
|
|
41
|
+
this.countDefined -= 1;
|
|
42
|
+
this.updateItem(key, undefined);
|
|
43
|
+
}
|
|
44
|
+
return hasKey;
|
|
45
|
+
}
|
|
46
|
+
forEach(callbackfn, thisArg) {
|
|
47
|
+
for (const [key, item] of Object.entries(this.value.items)) {
|
|
48
|
+
if (item.value !== undefined) {
|
|
49
|
+
// TODO: see about typing InternalTypes.MapValueState with K
|
|
50
|
+
callbackfn(item.value, key, this);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
get(key) {
|
|
55
|
+
return this.value.items[key]?.value;
|
|
56
|
+
}
|
|
57
|
+
has(key) {
|
|
58
|
+
return this.value.items[key]?.value !== undefined;
|
|
59
|
+
}
|
|
60
|
+
set(key, value) {
|
|
61
|
+
if (!(key in this.value.items)) {
|
|
62
|
+
this.countDefined += 1;
|
|
63
|
+
this.value.items[key] = { rev: 0, timestamp: 0, value };
|
|
64
|
+
}
|
|
65
|
+
this.updateItem(key, value);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
get size() {
|
|
69
|
+
return this.countDefined;
|
|
70
|
+
}
|
|
71
|
+
keys() {
|
|
72
|
+
const keys = [];
|
|
73
|
+
for (const [key, item] of Object.entries(this.value.items)) {
|
|
74
|
+
if (item.value !== undefined) {
|
|
75
|
+
keys.push(key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return keys[Symbol.iterator]();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class LatestMapValueManagerImpl {
|
|
82
|
+
constructor(key, datastore, value, controlSettings) {
|
|
83
|
+
this.key = key;
|
|
84
|
+
this.datastore = datastore;
|
|
85
|
+
this.value = value;
|
|
86
|
+
this.events = (0, events_1.createEmitter)();
|
|
87
|
+
this.controls = new latestValueControls_js_1.LatestValueControl(controlSettings);
|
|
88
|
+
this.local = new ValueMapImpl(value, (updates, forceUpdate) => {
|
|
89
|
+
datastore.localUpdate(key, updates, forceUpdate);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
*clientValues() {
|
|
93
|
+
const allKnownStates = this.datastore.knownValues(this.key);
|
|
94
|
+
for (const clientSessionId of Object.keys(allKnownStates.states)) {
|
|
95
|
+
if (clientSessionId !== allKnownStates.self) {
|
|
96
|
+
const client = this.datastore.lookupClient(clientSessionId);
|
|
97
|
+
const items = this.clientValue(client);
|
|
98
|
+
yield { client, items };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
clients() {
|
|
103
|
+
const allKnownStates = this.datastore.knownValues(this.key);
|
|
104
|
+
return Object.keys(allKnownStates.states)
|
|
105
|
+
.filter((clientSessionId) => clientSessionId !== allKnownStates.self)
|
|
106
|
+
.map((clientSessionId) => this.datastore.lookupClient(clientSessionId));
|
|
107
|
+
}
|
|
108
|
+
clientValue(client) {
|
|
109
|
+
const allKnownStates = this.datastore.knownValues(this.key);
|
|
110
|
+
const clientSessionId = client.sessionId;
|
|
111
|
+
if (!(clientSessionId in allKnownStates.states)) {
|
|
112
|
+
throw new Error("No entry for client");
|
|
113
|
+
}
|
|
114
|
+
const clientStateMap = allKnownStates.states[clientSessionId];
|
|
115
|
+
const items = new Map();
|
|
116
|
+
for (const [key, item] of Object.entries(clientStateMap.items)) {
|
|
117
|
+
const value = item.value;
|
|
118
|
+
if (value !== undefined) {
|
|
119
|
+
items.set(key, {
|
|
120
|
+
value,
|
|
121
|
+
metadata: { revision: item.rev, timestamp: item.timestamp },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return items;
|
|
126
|
+
}
|
|
127
|
+
update(client, _received, value) {
|
|
128
|
+
const allKnownStates = this.datastore.knownValues(this.key);
|
|
129
|
+
const clientSessionId = client.sessionId;
|
|
130
|
+
if (!(clientSessionId in allKnownStates.states)) {
|
|
131
|
+
// New client - prepare new client state directory
|
|
132
|
+
allKnownStates.states[clientSessionId] = { rev: value.rev, items: {} };
|
|
133
|
+
}
|
|
134
|
+
const currentState = allKnownStates.states[clientSessionId];
|
|
135
|
+
// Accumulate individual update keys
|
|
136
|
+
const updatedItemKeys = [];
|
|
137
|
+
for (const [key, item] of Object.entries(value.items)) {
|
|
138
|
+
if (!(key in currentState.items) || currentState.items[key].rev < item.rev) {
|
|
139
|
+
updatedItemKeys.push(key);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (updatedItemKeys.length === 0) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Store updates
|
|
146
|
+
if (value.rev > currentState.rev) {
|
|
147
|
+
currentState.rev = value.rev;
|
|
148
|
+
}
|
|
149
|
+
const allUpdates = {
|
|
150
|
+
client,
|
|
151
|
+
items: new Map(),
|
|
152
|
+
};
|
|
153
|
+
for (const key of updatedItemKeys) {
|
|
154
|
+
const item = value.items[key];
|
|
155
|
+
const hadPriorValue = currentState.items[key]?.value;
|
|
156
|
+
currentState.items[key] = item;
|
|
157
|
+
const metadata = { revision: item.rev, timestamp: item.timestamp };
|
|
158
|
+
if (item.value !== undefined) {
|
|
159
|
+
this.events.emit("itemUpdated", {
|
|
160
|
+
client,
|
|
161
|
+
key,
|
|
162
|
+
value: item.value,
|
|
163
|
+
metadata,
|
|
164
|
+
});
|
|
165
|
+
allUpdates.items.set(key, { value: item.value, metadata });
|
|
166
|
+
}
|
|
167
|
+
else if (hadPriorValue !== undefined) {
|
|
168
|
+
this.events.emit("itemRemoved", {
|
|
169
|
+
client,
|
|
170
|
+
key,
|
|
171
|
+
metadata,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
this.datastore.update(this.key, clientSessionId, currentState);
|
|
176
|
+
this.events.emit("updated", allUpdates);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Factory for creating a {@link LatestMapValueManager}.
|
|
181
|
+
*
|
|
182
|
+
* @alpha
|
|
183
|
+
*/
|
|
184
|
+
function LatestMap(initialValues, controls) {
|
|
185
|
+
const timestamp = Date.now();
|
|
186
|
+
const value = { rev: 0, items: {} };
|
|
187
|
+
// LatestMapValueManager takes ownership of values within initialValues.
|
|
188
|
+
if (initialValues !== undefined) {
|
|
189
|
+
for (const key of Object.keys(initialValues)) {
|
|
190
|
+
value.items[key] = { rev: 0, timestamp, value: initialValues[key] };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const controlSettings = controls
|
|
194
|
+
? { ...controls }
|
|
195
|
+
: {
|
|
196
|
+
allowableUpdateLatency: 60,
|
|
197
|
+
forcedRefreshInterval: 0,
|
|
198
|
+
};
|
|
199
|
+
const factory = (key, datastoreHandle) => ({
|
|
200
|
+
value,
|
|
201
|
+
manager: (0, valueManager_js_1.brandIVM)(new LatestMapValueManagerImpl(key, (0, stateDatastore_js_1.datastoreFromHandle)(datastoreHandle), value, controlSettings)),
|
|
202
|
+
});
|
|
203
|
+
return Object.assign(factory, { instanceBase: LatestMapValueManagerImpl });
|
|
204
|
+
}
|
|
205
|
+
exports.LatestMap = LatestMap;
|
|
206
|
+
//# sourceMappingURL=latestMapValueManager.js.map
|