@fluid-internal/presence-definitions 2.93.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.
Files changed (141) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/baseTypes.d.ts +24 -0
  4. package/dist/baseTypes.d.ts.map +1 -0
  5. package/dist/baseTypes.js +7 -0
  6. package/dist/baseTypes.js.map +1 -0
  7. package/dist/broadcastControlsTypes.d.ts +38 -0
  8. package/dist/broadcastControlsTypes.d.ts.map +1 -0
  9. package/dist/broadcastControlsTypes.js +7 -0
  10. package/dist/broadcastControlsTypes.js.map +1 -0
  11. package/dist/exposedInternalTypes.d.ts +137 -0
  12. package/dist/exposedInternalTypes.d.ts.map +1 -0
  13. package/dist/exposedInternalTypes.js +19 -0
  14. package/dist/exposedInternalTypes.js.map +1 -0
  15. package/dist/exposedUtilityTypes.d.ts +108 -0
  16. package/dist/exposedUtilityTypes.d.ts.map +1 -0
  17. package/dist/exposedUtilityTypes.js +7 -0
  18. package/dist/exposedUtilityTypes.js.map +1 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +10 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/internal.d.ts +9 -0
  24. package/dist/internal.d.ts.map +1 -0
  25. package/dist/internal.js +7 -0
  26. package/dist/internal.js.map +1 -0
  27. package/dist/latestMapTypes.d.ts +343 -0
  28. package/dist/latestMapTypes.d.ts.map +1 -0
  29. package/dist/latestMapTypes.js +7 -0
  30. package/dist/latestMapTypes.js.map +1 -0
  31. package/dist/latestTypes.d.ts +183 -0
  32. package/dist/latestTypes.d.ts.map +1 -0
  33. package/dist/latestTypes.js +7 -0
  34. package/dist/latestTypes.js.map +1 -0
  35. package/dist/latestValueTypes.d.ts +108 -0
  36. package/dist/latestValueTypes.d.ts.map +1 -0
  37. package/dist/latestValueTypes.js +7 -0
  38. package/dist/latestValueTypes.js.map +1 -0
  39. package/dist/notificationsManagerTypes.d.ts +144 -0
  40. package/dist/notificationsManagerTypes.d.ts.map +1 -0
  41. package/dist/notificationsManagerTypes.js +7 -0
  42. package/dist/notificationsManagerTypes.js.map +1 -0
  43. package/dist/package.json +11 -0
  44. package/dist/presence.d.ts +224 -0
  45. package/dist/presence.d.ts.map +1 -0
  46. package/dist/presence.js +23 -0
  47. package/dist/presence.js.map +1 -0
  48. package/dist/statesManagerTypes.d.ts +31 -0
  49. package/dist/statesManagerTypes.d.ts.map +1 -0
  50. package/dist/statesManagerTypes.js +7 -0
  51. package/dist/statesManagerTypes.js.map +1 -0
  52. package/dist/types.d.ts +134 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +7 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/validatableTypes.d.ts +79 -0
  57. package/dist/validatableTypes.d.ts.map +1 -0
  58. package/dist/validatableTypes.js +7 -0
  59. package/dist/validatableTypes.js.map +1 -0
  60. package/dist/workspace/workspaceTypes.d.ts +18 -0
  61. package/dist/workspace/workspaceTypes.d.ts.map +1 -0
  62. package/dist/workspace/workspaceTypes.js +7 -0
  63. package/dist/workspace/workspaceTypes.js.map +1 -0
  64. package/dist/workspace-runtime/presenceStatesTypes.d.ts +72 -0
  65. package/dist/workspace-runtime/presenceStatesTypes.d.ts.map +1 -0
  66. package/dist/workspace-runtime/presenceStatesTypes.js +7 -0
  67. package/dist/workspace-runtime/presenceStatesTypes.js.map +1 -0
  68. package/dist/workspace-states/stateDatastoreTypes.d.ts +42 -0
  69. package/dist/workspace-states/stateDatastoreTypes.d.ts.map +1 -0
  70. package/dist/workspace-states/stateDatastoreTypes.js +7 -0
  71. package/dist/workspace-states/stateDatastoreTypes.js.map +1 -0
  72. package/lib/baseTypes.d.ts +24 -0
  73. package/lib/baseTypes.d.ts.map +1 -0
  74. package/lib/baseTypes.js +6 -0
  75. package/lib/baseTypes.js.map +1 -0
  76. package/lib/broadcastControlsTypes.d.ts +38 -0
  77. package/lib/broadcastControlsTypes.d.ts.map +1 -0
  78. package/lib/broadcastControlsTypes.js +6 -0
  79. package/lib/broadcastControlsTypes.js.map +1 -0
  80. package/lib/exposedInternalTypes.d.ts +137 -0
  81. package/lib/exposedInternalTypes.d.ts.map +1 -0
  82. package/lib/exposedInternalTypes.js +16 -0
  83. package/lib/exposedInternalTypes.js.map +1 -0
  84. package/lib/exposedUtilityTypes.d.ts +108 -0
  85. package/lib/exposedUtilityTypes.d.ts.map +1 -0
  86. package/lib/exposedUtilityTypes.js +6 -0
  87. package/lib/exposedUtilityTypes.js.map +1 -0
  88. package/lib/index.d.ts +16 -0
  89. package/lib/index.d.ts.map +1 -0
  90. package/lib/index.js +6 -0
  91. package/lib/index.js.map +1 -0
  92. package/lib/internal.d.ts +9 -0
  93. package/lib/internal.d.ts.map +1 -0
  94. package/lib/internal.js +6 -0
  95. package/lib/internal.js.map +1 -0
  96. package/lib/latestMapTypes.d.ts +343 -0
  97. package/lib/latestMapTypes.d.ts.map +1 -0
  98. package/lib/latestMapTypes.js +6 -0
  99. package/lib/latestMapTypes.js.map +1 -0
  100. package/lib/latestTypes.d.ts +183 -0
  101. package/lib/latestTypes.d.ts.map +1 -0
  102. package/lib/latestTypes.js +6 -0
  103. package/lib/latestTypes.js.map +1 -0
  104. package/lib/latestValueTypes.d.ts +108 -0
  105. package/lib/latestValueTypes.d.ts.map +1 -0
  106. package/lib/latestValueTypes.js +6 -0
  107. package/lib/latestValueTypes.js.map +1 -0
  108. package/lib/notificationsManagerTypes.d.ts +144 -0
  109. package/lib/notificationsManagerTypes.d.ts.map +1 -0
  110. package/lib/notificationsManagerTypes.js +6 -0
  111. package/lib/notificationsManagerTypes.js.map +1 -0
  112. package/lib/presence.d.ts +224 -0
  113. package/lib/presence.d.ts.map +1 -0
  114. package/lib/presence.js +20 -0
  115. package/lib/presence.js.map +1 -0
  116. package/lib/statesManagerTypes.d.ts +31 -0
  117. package/lib/statesManagerTypes.d.ts.map +1 -0
  118. package/lib/statesManagerTypes.js +6 -0
  119. package/lib/statesManagerTypes.js.map +1 -0
  120. package/lib/tsdoc-metadata.json +11 -0
  121. package/lib/types.d.ts +134 -0
  122. package/lib/types.d.ts.map +1 -0
  123. package/lib/types.js +6 -0
  124. package/lib/types.js.map +1 -0
  125. package/lib/validatableTypes.d.ts +79 -0
  126. package/lib/validatableTypes.d.ts.map +1 -0
  127. package/lib/validatableTypes.js +6 -0
  128. package/lib/validatableTypes.js.map +1 -0
  129. package/lib/workspace/workspaceTypes.d.ts +18 -0
  130. package/lib/workspace/workspaceTypes.d.ts.map +1 -0
  131. package/lib/workspace/workspaceTypes.js +6 -0
  132. package/lib/workspace/workspaceTypes.js.map +1 -0
  133. package/lib/workspace-runtime/presenceStatesTypes.d.ts +72 -0
  134. package/lib/workspace-runtime/presenceStatesTypes.d.ts.map +1 -0
  135. package/lib/workspace-runtime/presenceStatesTypes.js +6 -0
  136. package/lib/workspace-runtime/presenceStatesTypes.js.map +1 -0
  137. package/lib/workspace-states/stateDatastoreTypes.d.ts +42 -0
  138. package/lib/workspace-states/stateDatastoreTypes.d.ts.map +1 -0
  139. package/lib/workspace-states/stateDatastoreTypes.js +6 -0
  140. package/lib/workspace-states/stateDatastoreTypes.js.map +1 -0
  141. package/package.json +117 -0
@@ -0,0 +1,108 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
6
+ import type { Attendee } from "./presence.js";
7
+ /**
8
+ * Metadata for the value state.
9
+ *
10
+ * @sealed
11
+ * @public
12
+ */
13
+ export interface LatestMetadata {
14
+ /**
15
+ * The revision number for value that increases as value is changed.
16
+ */
17
+ revision: number;
18
+ /**
19
+ * Local time when the value was last updated.
20
+ * @remarks Currently this is a placeholder for future implementation.
21
+ */
22
+ timestamp: number;
23
+ }
24
+ /**
25
+ * Represents a value that is accessed directly.
26
+ *
27
+ * @system
28
+ * @public
29
+ */
30
+ export interface RawValueAccessor<T> {
31
+ readonly kind: "raw";
32
+ readonly data: T;
33
+ }
34
+ /**
35
+ * Represents a value that is accessed via a function call, which may result in no value.
36
+ *
37
+ * @system
38
+ * @public
39
+ */
40
+ export interface ProxiedValueAccessor<T> {
41
+ readonly kind: "proxied";
42
+ readonly data: T;
43
+ }
44
+ /**
45
+ * Union of possible accessor types for a value.
46
+ *
47
+ * @system
48
+ * @public
49
+ */
50
+ export type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;
51
+ /**
52
+ * Utility type that conditionally represents an accessor type based on the base accessor type.
53
+ *
54
+ * @system
55
+ * @public
56
+ */
57
+ export type Accessor<T, BaseAccessor extends ValueAccessor<T>> = BaseAccessor extends ProxiedValueAccessor<T> ? () => DeepReadonly<JsonDeserialized<T>> | undefined : BaseAccessor extends RawValueAccessor<T> ? DeepReadonly<JsonDeserialized<T>> : never;
58
+ /**
59
+ * State of a value and its metadata.
60
+ *
61
+ * @sealed
62
+ * @public
63
+ */
64
+ export interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {
65
+ /**
66
+ * The value of the state or an accessor function.
67
+ *
68
+ * @remarks
69
+ * If the State object was created with a {@link StateSchemaValidator}, then the `value`
70
+ * will be a function returning a validated, deeply readonly `T` or `undefined`.
71
+ * Without a validator, `value` will be an unvalidated, deeply readonly `T`.
72
+ *
73
+ * Any `T` is always deeply readonly, meaning it cannot be modified.
74
+ */
75
+ value: Accessor<T, TValueAccessor>;
76
+ /**
77
+ * Metadata associated with the value.
78
+ */
79
+ metadata: LatestMetadata;
80
+ }
81
+ /**
82
+ * State of a specific {@link Attendee}'s value and its metadata.
83
+ *
84
+ * @sealed
85
+ * @public
86
+ */
87
+ export interface LatestClientData<T, TValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> extends LatestData<T, TValueAccessor> {
88
+ /**
89
+ * Associated {@link Attendee}.
90
+ */
91
+ attendee: Attendee;
92
+ }
93
+ /**
94
+ * A validator function that can optionally be provided to do runtime validation of the custom data stored in a
95
+ * presence workspace and managed by a state object.
96
+ *
97
+ * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**
98
+ *
99
+ * @returns The validated data, or `undefined` if the data is invalid.
100
+ *
101
+ * @public
102
+ */
103
+ export type StateSchemaValidator<T> = (
104
+ /**
105
+ * Unknown data that should be validated. **This data should not be mutated.**
106
+ */
107
+ unvalidatedData: unknown) => JsonDeserialized<T> | undefined;
108
+ //# sourceMappingURL=latestValueTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latestValueTypes.d.ts","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,IAC5D,YAAY,SAAS,oBAAoB,CAAC,CAAC,CAAC,GACzC,MAAM,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GACnD,YAAY,SAAS,gBAAgB,CAAC,CAAC,CAAC,GACvC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACjC,KAAK,CAAC;AAEX;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,cAAc,SAAS,aAAa,CAAC,CAAC,CAAC;IACrE;;;;;;;;;OASG;IACH,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAEnC;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAChC,CAAC,EACD,cAAc,SAAS,aAAa,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAChE,SAAQ,UAAU,CAAC,CAAC,EAAE,cAAc,CAAC;IACtC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;AACrC;;GAEG;AACH,eAAe,EAAE,OAAO,KACpB,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC"}
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=latestValueTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latestValueTypes.js","sourceRoot":"","sources":["../src/latestValueTypes.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\tDeepReadonly,\n\tJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * Metadata for the value state.\n *\n * @sealed\n * @public\n */\nexport interface LatestMetadata {\n\t/**\n\t * The revision number for value that increases as value is changed.\n\t */\n\trevision: number;\n\t/**\n\t * Local time when the value was last updated.\n\t * @remarks Currently this is a placeholder for future implementation.\n\t */\n\ttimestamp: number;\n}\n\n/**\n * Represents a value that is accessed directly.\n *\n * @system\n * @public\n */\nexport interface RawValueAccessor<T> {\n\treadonly kind: \"raw\";\n\treadonly data: T;\n}\n\n/**\n * Represents a value that is accessed via a function call, which may result in no value.\n *\n * @system\n * @public\n */\nexport interface ProxiedValueAccessor<T> {\n\treadonly kind: \"proxied\";\n\treadonly data: T;\n}\n\n/**\n * Union of possible accessor types for a value.\n *\n * @system\n * @public\n */\nexport type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;\n\n/**\n * Utility type that conditionally represents an accessor type based on the base accessor type.\n *\n * @system\n * @public\n */\nexport type Accessor<T, BaseAccessor extends ValueAccessor<T>> =\n\tBaseAccessor extends ProxiedValueAccessor<T>\n\t\t? () => DeepReadonly<JsonDeserialized<T>> | undefined\n\t\t: BaseAccessor extends RawValueAccessor<T>\n\t\t\t? DeepReadonly<JsonDeserialized<T>>\n\t\t\t: never;\n\n/**\n * State of a value and its metadata.\n *\n * @sealed\n * @public\n */\nexport interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {\n\t/**\n\t * The value of the state or an accessor function.\n\t *\n\t * @remarks\n\t * If the State object was created with a {@link StateSchemaValidator}, then the `value`\n\t * will be a function returning a validated, deeply readonly `T` or `undefined`.\n\t * Without a validator, `value` will be an unvalidated, deeply readonly `T`.\n\t *\n\t * Any `T` is always deeply readonly, meaning it cannot be modified.\n\t */\n\tvalue: Accessor<T, TValueAccessor>;\n\n\t/**\n\t * Metadata associated with the value.\n\t */\n\tmetadata: LatestMetadata;\n}\n\n/**\n * State of a specific {@link Attendee}'s value and its metadata.\n *\n * @sealed\n * @public\n */\nexport interface LatestClientData<\n\tT,\n\tTValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> extends LatestData<T, TValueAccessor> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee;\n}\n\n/**\n * A validator function that can optionally be provided to do runtime validation of the custom data stored in a\n * presence workspace and managed by a state object.\n *\n * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**\n *\n * @returns The validated data, or `undefined` if the data is invalid.\n *\n * @public\n */\nexport type StateSchemaValidator<T> = (\n\t/**\n\t * Unknown data that should be validated. **This data should not be mutated.**\n\t */\n\tunvalidatedData: unknown,\n) => JsonDeserialized<T> | undefined;\n"]}
@@ -0,0 +1,144 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { Listenable, Off } from "@fluidframework/core-interfaces";
6
+ import type { InternalTypes } from "./exposedInternalTypes.js";
7
+ import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
8
+ import type { Attendee, PresenceWithNotifications as Presence } from "./presence.js";
9
+ /**
10
+ * @sealed
11
+ * @alpha
12
+ */
13
+ export interface NotificationsManagerEvents {
14
+ /**
15
+ * Raised when notification is received, but no subscribers were found.
16
+ *
17
+ * @eventProperty
18
+ */
19
+ unattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;
20
+ }
21
+ /**
22
+ * An object which allows the registration of listeners so that subscribers can be
23
+ * notified when a notification happens.
24
+ *
25
+ * @sealed
26
+ * @alpha
27
+ */
28
+ export interface NotificationListenable<TListeners extends InternalUtilityTypes.NotificationListeners<TListeners>> {
29
+ /**
30
+ * Register a notification listener.
31
+ * @param notificationName - the name of the notification
32
+ * @param listener - The listener function to run when the notification is fired.
33
+ * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.
34
+ * Calling the deregistration function more than once will have no effect.
35
+ *
36
+ * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.
37
+ * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.
38
+ * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.
39
+ */
40
+ on<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): Off;
41
+ /**
42
+ * Deregister notification listener.
43
+ * @param notificationName - The name of the notification.
44
+ * @param listener - The listener function to remove from the current set of notification listeners.
45
+ * @remarks If `listener` is not currently registered, this method will have no effect.
46
+ *
47
+ * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.
48
+ */
49
+ off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
50
+ }
51
+ /**
52
+ * Record of notification subscription signatures transformed from listener emit signatures.
53
+ *
54
+ * @remarks
55
+ * Prepends the `sender: Attendee` parameter to each notification listener signature.
56
+ *
57
+ * @sealed
58
+ * @alpha
59
+ */
60
+ export type NotificationSubscriberSignatures<E extends InternalUtilityTypes.NotificationListeners<E>> = {
61
+ [K in keyof InternalUtilityTypes.NotificationListeners<E>]: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>) => void;
62
+ };
63
+ /**
64
+ * Interface for a notification emitter that can send typed notification to other clients.
65
+ *
66
+ * @sealed
67
+ * @alpha
68
+ */
69
+ export interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {
70
+ /**
71
+ * Emits a notification with the specified name and arguments, notifying all clients.
72
+ * @param notificationName - the name of the notification to fire
73
+ * @param args - the arguments sent with the notification
74
+ */
75
+ broadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, ...args: Parameters<E[K]>): void;
76
+ /**
77
+ * Emits a notification with the specified name and arguments, notifying a single attendee.
78
+ * @param notificationName - the name of the notification to fire
79
+ * @param targetAttendee - the single attendee to notify
80
+ * @param args - the arguments sent with the notification
81
+ */
82
+ unicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, targetAttendee: Attendee, ...args: Parameters<E[K]>): void;
83
+ }
84
+ /**
85
+ * Provides notifications from this client to others and subscription
86
+ * to their notifications.
87
+ *
88
+ * @remarks Create using {@link @fluidframework/presence#(Notifications:1)} registered to
89
+ * {@link NotificationsWorkspace} or {@link StatesWorkspace}.
90
+ *
91
+ * @sealed
92
+ * @alpha
93
+ */
94
+ export interface NotificationsManager<T extends InternalUtilityTypes.NotificationListeners<T>> {
95
+ /**
96
+ * Containing {@link Presence}
97
+ */
98
+ readonly presence: Presence;
99
+ /**
100
+ * Events for Notifications manager.
101
+ */
102
+ readonly events: Listenable<NotificationsManagerEvents>;
103
+ /**
104
+ * Send notifications to other clients.
105
+ */
106
+ readonly emit: NotificationEmitter<T>;
107
+ /**
108
+ * Provides subscription to notifications from other clients.
109
+ */
110
+ readonly notifications: NotificationListenable<T>;
111
+ }
112
+ /**
113
+ * Type alias for the return type of {@link @fluidframework/presence#(Notifications:1)}.
114
+ *
115
+ * @remarks
116
+ * Use this type instead of any InternalPresenceTypes that may be revealed from
117
+ * examining factory return type.
118
+ *
119
+ * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain
120
+ * allowed registration keys for this Notification within a workspace.
121
+ * Specification is recommended to highlight connection between schema and
122
+ * factory when spread across modules.
123
+ *
124
+ * @alpha
125
+ * @sealed
126
+ */
127
+ export type NotificationsConfiguration<T extends InternalUtilityTypes.NotificationListeners<T>, RegistrationKeyRestrictions extends string = string> = InternalTypes.ManagerFactory<RegistrationKeyRestrictions, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>;
128
+ /**
129
+ * Type alias for the return type of {@link @fluidframework/presence#(Notifications:2)}.
130
+ *
131
+ * @remarks
132
+ * Use this type instead of any InternalPresenceTypes that may be revealed from
133
+ * examining factory return type.
134
+ *
135
+ * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain
136
+ * allowed registration keys for this Notification within a workspace.
137
+ * Specification is recommended to highlight connection between schema and
138
+ * factory when spread across modules.
139
+ *
140
+ * @alpha
141
+ * @sealed
142
+ */
143
+ export type NotificationsWithSubscriptionsConfiguration<TSubscriptions extends InternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>, RegistrationKeyRestrictions extends string = string> = InternalTypes.ManagerFactory<RegistrationKeyRestrictions, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<InternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>>>;
144
+ //# sourceMappingURL=notificationsManagerTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationsManagerTypes.d.ts","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,sBAAsB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACxF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB,CACtC,UAAU,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,UAAU,CAAC;IAEzE;;;;;;;;;;OAUG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,oBAAoB,CAAC,qBAAqB,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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=notificationsManagerTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationsManagerTypes.js","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscription signatures transformed from listener emit signatures.\n *\n * @remarks\n * Prepends the `sender: Attendee` parameter to each notification listener signature.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriberSignatures<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: Attendee,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single attendee.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetAttendee - the single attendee to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetAttendee: Attendee,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link @fluidframework/presence#(Notifications:1)} registered to\n * {@link NotificationsWorkspace} or {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n\n/**\n * Type alias for the return type of {@link @fluidframework/presence#(Notifications:1)}.\n *\n * @remarks\n * Use this type instead of any InternalPresenceTypes that may be revealed from\n * examining factory return type.\n *\n * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain\n * allowed registration keys for this Notification within a workspace.\n * Specification is recommended to highlight connection between schema and\n * factory when spread across modules.\n *\n * @alpha\n * @sealed\n */\nexport type NotificationsConfiguration<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tRegistrationKeyRestrictions extends string = string,\n> = InternalTypes.ManagerFactory<\n\tRegistrationKeyRestrictions,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n>;\n\n/**\n * Type alias for the return type of {@link @fluidframework/presence#(Notifications:2)}.\n *\n * @remarks\n * Use this type instead of any InternalPresenceTypes that may be revealed from\n * examining factory return type.\n *\n * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain\n * allowed registration keys for this Notification within a workspace.\n * Specification is recommended to highlight connection between schema and\n * factory when spread across modules.\n *\n * @alpha\n * @sealed\n */\nexport type NotificationsWithSubscriptionsConfiguration<\n\tTSubscriptions extends\n\t\tInternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>,\n\tRegistrationKeyRestrictions extends string = string,\n> = InternalTypes.ManagerFactory<\n\tRegistrationKeyRestrictions,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<\n\t\tInternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>\n\t>\n>;\n"]}
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@fluid-internal/presence-definitions",
3
+ "type": "commonjs",
4
+ "exports": {
5
+ ".": "./index.js",
6
+ "./internal": "./internal.js",
7
+ "./internal/workspace": "./workspace/workspaceTypes.js",
8
+ "./internal/workspace-runtime": "./workspace-runtime/presenceStatesTypes.js",
9
+ "./internal/workspace-states": "./workspace-states/stateDatastoreTypes.js"
10
+ }
11
+ }
@@ -0,0 +1,224 @@
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 { SessionId } from "@fluidframework/id-compressor";
7
+ import type { ClientConnectionId } from "./baseTypes.js";
8
+ import type { BroadcastControlSettings } from "./broadcastControlsTypes.js";
9
+ import type { NotificationsWorkspace, NotificationsWorkspaceSchema, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "./types.js";
10
+ /**
11
+ * A Fluid client session identifier.
12
+ *
13
+ * @remarks
14
+ * Each client once connected to a session is given a unique identifier for the
15
+ * duration of the session. If a client disconnects and reconnects, it will
16
+ * retain its identifier. Prefer use of {@link Attendee} as a way to
17
+ * identify clients in a session. {@link Attendee.attendeeId} will provide
18
+ * the session ID.
19
+ *
20
+ * @public
21
+ */
22
+ export type AttendeeId = SessionId & {
23
+ readonly AttendeeId: "AttendeeId";
24
+ };
25
+ /**
26
+ * The connection status of the {@link Attendee}.
27
+ *
28
+ * @public
29
+ */
30
+ export declare const AttendeeStatus: {
31
+ /**
32
+ * The {@link Attendee} is connected to the Fluid service.
33
+ */
34
+ readonly Connected: "Connected";
35
+ /**
36
+ * The {@link Attendee} is not connected to the Fluid service.
37
+ */
38
+ readonly Disconnected: "Disconnected";
39
+ };
40
+ /**
41
+ * Represents the connection status of an {@link Attendee}.
42
+ *
43
+ * This type can be either `'Connected'` or `'Disconnected'`, indicating whether
44
+ * the attendee is currently connected to the Fluid service.
45
+ *
46
+ * When `'Disconnected'`:
47
+ * - State changes are kept locally and communicated to others upon reconnect.
48
+ * - Notification requests are discarded (silently).
49
+ *
50
+ * @public
51
+ */
52
+ export type AttendeeStatus = (typeof AttendeeStatus)[keyof typeof AttendeeStatus];
53
+ /**
54
+ * A client within a Fluid session (period of container connectivity to service).
55
+ *
56
+ * @remarks
57
+ * Note: This is very preliminary attendee representation.
58
+ *
59
+ * {@link Attendee} should be used as key to distinguish between different
60
+ * clients as they join, rejoin, and disconnect from a session. While a
61
+ * client's {@link ClientConnectionId} from {@link Attendee.getConnectionStatus}
62
+ * may change over time, `Attendee` will be fixed.
63
+ *
64
+ * @privateRemarks
65
+ * As this is evolved, pay attention to how this relates to Audience, Service
66
+ * Audience, and Quorum representations of clients and users.
67
+ *
68
+ * @sealed
69
+ * @public
70
+ */
71
+ export interface Attendee<SpecificAttendeeId extends AttendeeId = AttendeeId> {
72
+ /**
73
+ * The session ID of the client that is stable over all connections.
74
+ */
75
+ readonly attendeeId: SpecificAttendeeId;
76
+ /**
77
+ * Get current client connection ID.
78
+ *
79
+ * @returns Current client connection ID.
80
+ *
81
+ * @remarks
82
+ * Connection ID will change on reconnect.
83
+ *
84
+ * If {@link Attendee.getConnectionStatus} is {@link (AttendeeStatus:variable).Disconnected}, this will represent the last known connection ID.
85
+ */
86
+ getConnectionId(): ClientConnectionId;
87
+ /**
88
+ * Get connection status of attendee.
89
+ *
90
+ * @returns Connection status of attendee.
91
+ *
92
+ */
93
+ getConnectionStatus(): AttendeeStatus;
94
+ }
95
+ /**
96
+ * Events from {@link Presence.attendees}.
97
+ *
98
+ * @sealed
99
+ * @public
100
+ */
101
+ export interface AttendeesEvents {
102
+ /**
103
+ * Raised when new client joins session.
104
+ *
105
+ * @eventProperty
106
+ */
107
+ attendeeConnected: (attendee: Attendee) => void;
108
+ /**
109
+ * Raised when client appears disconnected from session.
110
+ *
111
+ * @eventProperty
112
+ */
113
+ attendeeDisconnected: (attendee: Attendee) => void;
114
+ }
115
+ /**
116
+ * Events from {@link Presence}.
117
+ *
118
+ * @sealed
119
+ * @public
120
+ */
121
+ export interface PresenceEvents {
122
+ /**
123
+ * Raised when a workspace is activated within the session.
124
+ *
125
+ * "Activated" means that a workspace is being used by a client and this
126
+ * client is seeing information for the first time.
127
+ *
128
+ * @remarks
129
+ * Local workspaces may be passively acquired/registered when this event
130
+ * is raised. For a notifications workspace, that lazy registration must
131
+ * be done before the event handler returns to ensure no notifications
132
+ * are missed.
133
+ */
134
+ workspaceActivated: (workspaceAddress: WorkspaceAddress, type: "States" | "Notifications" | "Unknown") => void;
135
+ }
136
+ /**
137
+ * Provides top-level access to Presence feature set including known
138
+ * {@link Attendee}s within a session and their custom states kept
139
+ * under {@link StatesWorkspace}s.
140
+ *
141
+ * @sealed
142
+ * @public
143
+ */
144
+ export interface Presence {
145
+ /**
146
+ * Events for Presence.
147
+ */
148
+ readonly events: Listenable<PresenceEvents>;
149
+ /**
150
+ * Container-wide {@link Attendee} information and event provider.
151
+ *
152
+ * @remarks
153
+ * This provides access to all {@link Attendee}s in the session, including
154
+ * the current client. As {@link StatesWorkspace} aren't required to be
155
+ * uniform across an application, some {@link Attendee}s may be enumerated
156
+ * here while not being present in any particular {@link StatesWorkspace}.
157
+ */
158
+ readonly attendees: {
159
+ /**
160
+ * Events for {@link Attendee}s.
161
+ */
162
+ readonly events: Listenable<AttendeesEvents>;
163
+ /**
164
+ * Get all {@link Attendee}s in the session.
165
+ *
166
+ * @remarks
167
+ * Attendee states are dynamic and will change as clients join and leave
168
+ * the session.
169
+ */
170
+ getAttendees(): ReadonlySet<Attendee>;
171
+ /**
172
+ * Lookup a specific {@link Attendee} in the session.
173
+ *
174
+ * @param clientId - Client connection or session ID
175
+ */
176
+ getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee;
177
+ /**
178
+ * Get this client's {@link Attendee}.
179
+ *
180
+ * @returns This client's attendee.
181
+ */
182
+ getMyself(): Attendee;
183
+ };
184
+ /**
185
+ * Provides access to {@link StatesWorkspace}s that allow clients to
186
+ * manage custom states.
187
+ */
188
+ readonly states: {
189
+ /**
190
+ * Acquires a {@link StatesWorkspace} from store or adds new one.
191
+ *
192
+ * @param workspaceAddress - Address of the requested {@link StatesWorkspace}
193
+ * @param requestedStates - Requested states for the workspace
194
+ * @param controls - Optional settings for default broadcast controls
195
+ * @returns A {@link StatesWorkspace}
196
+ */
197
+ getWorkspace<StatesSchema extends Partial<StatesWorkspaceSchema<SchemaKeys>>, SchemaKeys extends string & keyof StatesSchema = string & keyof StatesSchema>(workspaceAddress: WorkspaceAddress, requestedStates: StatesSchema, controls?: BroadcastControlSettings): StatesWorkspace<StatesSchema, unknown, SchemaKeys>;
198
+ };
199
+ }
200
+ /**
201
+ * Provides top-level access to Presence feature set including known
202
+ * {@link Attendee}s within a session and their custom states and
203
+ * notifications kept under {@link StatesWorkspace}s and
204
+ * {@link NotificationsWorkspace}s.
205
+ *
206
+ * @remarks
207
+ * To access this alpha API, cast any `{@link Presence}` to `PresenceWithNotifications`.
208
+ *
209
+ * @sealed
210
+ * @alpha
211
+ */
212
+ export interface PresenceWithNotifications extends Presence {
213
+ readonly notifications: {
214
+ /**
215
+ * Acquires a Notifications workspace from store or adds new one.
216
+ *
217
+ * @param workspaceAddress - Address of the requested Notifications Workspace
218
+ * @param requestedNotifications - Requested notifications for the workspace
219
+ * @returns A Notifications workspace
220
+ */
221
+ getWorkspace<NotificationsSchema extends Partial<NotificationsWorkspaceSchema<SchemaKeys>>, SchemaKeys extends string & keyof NotificationsSchema = string & keyof NotificationsSchema>(notificationsId: WorkspaceAddress, requestedNotifications: NotificationsSchema): NotificationsWorkspace<NotificationsSchema, SchemaKeys>;
222
+ };
223
+ }
224
+ //# sourceMappingURL=presence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.d.ts","sour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1B,eAAe,EAAE,gBAAgB,EACjC,sBAAsB,EAAE,mBAAmB,GACzC,sBAAsB,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;KAC3D,CAAC;CACF"}
@@ -0,0 +1,23 @@
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.AttendeeStatus = void 0;
8
+ /**
9
+ * The connection status of the {@link Attendee}.
10
+ *
11
+ * @public
12
+ */
13
+ exports.AttendeeStatus = {
14
+ /**
15
+ * The {@link Attendee} is connected to the Fluid service.
16
+ */
17
+ Connected: "Connected",
18
+ /**
19
+ * The {@link Attendee} is not connected to the Fluid service.
20
+ */
21
+ Disconnected: "Disconnected",
22
+ };
23
+ //# sourceMappingURL=presence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6BH;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC7B;;OAEG;IACH,SAAS,EAAE,WAAW;IAEtB;;OAEG;IACH,YAAY,EAAE,cAAc;CACnB,CAAC","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 { SessionId } from \"@fluidframework/id-compressor\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type {\n\tNotificationsWorkspace,\n\tNotificationsWorkspaceSchema,\n\tStatesWorkspace,\n\tStatesWorkspaceSchema,\n\tWorkspaceAddress,\n} from \"./types.js\";\n\n/**\n * A Fluid client session identifier.\n *\n * @remarks\n * Each client once connected to a session is given a unique identifier for the\n * duration of the session. If a client disconnects and reconnects, it will\n * retain its identifier. Prefer use of {@link Attendee} as a way to\n * identify clients in a session. {@link Attendee.attendeeId} will provide\n * the session ID.\n *\n * @public\n */\nexport type AttendeeId = SessionId & { readonly AttendeeId: \"AttendeeId\" };\n\n/**\n * The connection status of the {@link Attendee}.\n *\n * @public\n */\nexport const AttendeeStatus = {\n\t/**\n\t * The {@link Attendee} is connected to the Fluid service.\n\t */\n\tConnected: \"Connected\",\n\n\t/**\n\t * The {@link Attendee} is not connected to the Fluid service.\n\t */\n\tDisconnected: \"Disconnected\",\n} as const;\n\n/**\n * Represents the connection status of an {@link Attendee}.\n *\n * This type can be either `'Connected'` or `'Disconnected'`, indicating whether\n * the attendee is currently connected to the Fluid service.\n *\n * When `'Disconnected'`:\n * - State changes are kept locally and communicated to others upon reconnect.\n * - Notification requests are discarded (silently).\n *\n * @public\n */\nexport type AttendeeStatus = (typeof AttendeeStatus)[keyof typeof AttendeeStatus];\n\n/**\n * A client within a Fluid session (period of container connectivity to service).\n *\n * @remarks\n * Note: This is very preliminary attendee representation.\n *\n * {@link Attendee} should be used as key to distinguish between different\n * clients as they join, rejoin, and disconnect from a session. While a\n * client's {@link ClientConnectionId} from {@link Attendee.getConnectionStatus}\n * may change over time, `Attendee` will be fixed.\n *\n * @privateRemarks\n * As this is evolved, pay attention to how this relates to Audience, Service\n * Audience, and Quorum representations of clients and users.\n *\n * @sealed\n * @public\n */\nexport interface Attendee<SpecificAttendeeId extends AttendeeId = AttendeeId> {\n\t/**\n\t * The session ID of the client that is stable over all connections.\n\t */\n\treadonly attendeeId: SpecificAttendeeId;\n\n\t/**\n\t * Get current client connection ID.\n\t *\n\t * @returns Current client connection ID.\n\t *\n\t * @remarks\n\t * Connection ID will change on reconnect.\n\t *\n\t * If {@link Attendee.getConnectionStatus} is {@link (AttendeeStatus:variable).Disconnected}, this will represent the last known connection ID.\n\t */\n\tgetConnectionId(): ClientConnectionId;\n\n\t/**\n\t * Get connection status of attendee.\n\t *\n\t * @returns Connection status of attendee.\n\t *\n\t */\n\tgetConnectionStatus(): AttendeeStatus;\n}\n\n/**\n * Events from {@link Presence.attendees}.\n *\n * @sealed\n * @public\n */\nexport interface AttendeesEvents {\n\t/**\n\t * Raised when new client joins session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeConnected: (attendee: Attendee) => void;\n\n\t/**\n\t * Raised when client appears disconnected from session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeDisconnected: (attendee: Attendee) => void;\n}\n\n/**\n * Events from {@link Presence}.\n *\n * @sealed\n * @public\n */\nexport interface PresenceEvents {\n\t/**\n\t * Raised when a workspace is activated within the session.\n\t *\n\t * \"Activated\" means that a workspace is being used by a client and this\n\t * client is seeing information for the first time.\n\t *\n\t * @remarks\n\t * Local workspaces may be passively acquired/registered when this event\n\t * is raised. For a notifications workspace, that lazy registration must\n\t * be done before the event handler returns to ensure no notifications\n\t * are missed.\n\t */\n\tworkspaceActivated: (\n\t\tworkspaceAddress: WorkspaceAddress,\n\t\ttype: \"States\" | \"Notifications\" | \"Unknown\",\n\t) => void;\n}\n\n/**\n * Provides top-level access to Presence feature set including known\n * {@link Attendee}s within a session and their custom states kept\n * under {@link StatesWorkspace}s.\n *\n * @sealed\n * @public\n */\nexport interface Presence {\n\t/**\n\t * Events for Presence.\n\t */\n\treadonly events: Listenable<PresenceEvents>;\n\n\t/**\n\t * Container-wide {@link Attendee} information and event provider.\n\t *\n\t * @remarks\n\t * This provides access to all {@link Attendee}s in the session, including\n\t * the current client. As {@link StatesWorkspace} aren't required to be\n\t * uniform across an application, some {@link Attendee}s may be enumerated\n\t * here while not being present in any particular {@link StatesWorkspace}.\n\t */\n\treadonly attendees: {\n\t\t/**\n\t\t * Events for {@link Attendee}s.\n\t\t */\n\t\treadonly events: Listenable<AttendeesEvents>;\n\n\t\t/**\n\t\t * Get all {@link Attendee}s in the session.\n\t\t *\n\t\t * @remarks\n\t\t * Attendee states are dynamic and will change as clients join and leave\n\t\t * the session.\n\t\t */\n\t\tgetAttendees(): ReadonlySet<Attendee>;\n\n\t\t/**\n\t\t * Lookup a specific {@link Attendee} in the session.\n\t\t *\n\t\t * @param clientId - Client connection or session ID\n\t\t */\n\t\tgetAttendee(clientId: ClientConnectionId | AttendeeId): Attendee;\n\n\t\t/**\n\t\t * Get this client's {@link Attendee}.\n\t\t *\n\t\t * @returns This client's attendee.\n\t\t */\n\t\tgetMyself(): Attendee;\n\t};\n\n\t/**\n\t * Provides access to {@link StatesWorkspace}s that allow clients to\n\t * manage custom states.\n\t */\n\treadonly states: {\n\t\t/**\n\t\t * Acquires a {@link StatesWorkspace} from store or adds new one.\n\t\t *\n\t\t * @param workspaceAddress - Address of the requested {@link StatesWorkspace}\n\t\t * @param requestedStates - Requested states for the workspace\n\t\t * @param controls - Optional settings for default broadcast controls\n\t\t * @returns A {@link StatesWorkspace}\n\t\t */\n\t\tgetWorkspace<\n\t\t\tStatesSchema extends Partial<StatesWorkspaceSchema<SchemaKeys>>,\n\t\t\tSchemaKeys extends string & keyof StatesSchema = string & keyof StatesSchema,\n\t\t>(\n\t\t\tworkspaceAddress: WorkspaceAddress,\n\t\t\trequestedStates: StatesSchema,\n\t\t\tcontrols?: BroadcastControlSettings,\n\t\t): StatesWorkspace<StatesSchema, unknown, SchemaKeys>;\n\t};\n}\n\n/**\n * Provides top-level access to Presence feature set including known\n * {@link Attendee}s within a session and their custom states and\n * notifications kept under {@link StatesWorkspace}s and\n * {@link NotificationsWorkspace}s.\n *\n * @remarks\n * To access this alpha API, cast any `{@link Presence}` to `PresenceWithNotifications`.\n *\n * @sealed\n * @alpha\n */\nexport interface PresenceWithNotifications extends Presence {\n\treadonly notifications: {\n\t\t/**\n\t\t * Acquires a Notifications workspace from store or adds new one.\n\t\t *\n\t\t * @param workspaceAddress - Address of the requested Notifications Workspace\n\t\t * @param requestedNotifications - Requested notifications for the workspace\n\t\t * @returns A Notifications workspace\n\t\t */\n\t\tgetWorkspace<\n\t\t\tNotificationsSchema extends Partial<NotificationsWorkspaceSchema<SchemaKeys>>,\n\t\t\tSchemaKeys extends string & keyof NotificationsSchema = string &\n\t\t\t\tkeyof NotificationsSchema,\n\t\t>(\n\t\t\tnotificationsId: WorkspaceAddress,\n\t\t\trequestedNotifications: NotificationsSchema,\n\t\t): NotificationsWorkspace<NotificationsSchema, SchemaKeys>;\n\t};\n}\n"]}
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { InternalTypes } from "./exposedInternalTypes.js";
6
+ import type { Attendee } from "./presence.js";
7
+ /**
8
+ * A function to be called at the end of an update frame
9
+ *
10
+ * @internal
11
+ */
12
+ export type PostUpdateAction = () => void;
13
+ /**
14
+ * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)
15
+ *
16
+ * @remarks
17
+ * See uses of `unbrandIVM`.
18
+ *
19
+ * @internal
20
+ */
21
+ export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
22
+ readonly value?: TValueState;
23
+ /**
24
+ * Process an update of `value` for remote attendee.
25
+ * @param attendee - The attendee whose `value` is being updated
26
+ * @param received - The revision number received
27
+ * @param value - The new `value` state
28
+ */
29
+ update(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];
30
+ }
31
+ //# sourceMappingURL=statesManagerTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statesManagerTypes.d.ts","sourceRoot":"","sources":["../src/statesManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C;;;;;;;GAOG;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;IAE7B;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAAC;CACrF"}
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=statesManagerTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statesManagerTypes.js","sourceRoot":"","sources":["../src/statesManagerTypes.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 { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * A function to be called at the end of an update frame\n *\n * @internal\n */\nexport type PostUpdateAction = () => void;\n\n/**\n * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)\n *\n * @remarks\n * See uses of `unbrandIVM`.\n *\n * @internal\n */\nexport interface ValueManager<\n\tTValue,\n\tTValueState extends\n\t\tInternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>,\n> {\n\t// State objects should provide value - implement Required<ValueManager<...>>\n\treadonly value?: TValueState;\n\n\t/**\n\t * Process an update of `value` for remote attendee.\n\t * @param attendee - The attendee whose `value` is being updated\n\t * @param received - The revision number received\n\t * @param value - The new `value` state\n\t */\n\tupdate(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];\n}\n"]}