@fluidframework/presence 2.33.0-333010 → 2.33.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 (153) hide show
  1. package/README.md +24 -24
  2. package/dist/alpha.d.ts +29 -25
  3. package/dist/baseTypes.d.ts +3 -3
  4. package/dist/baseTypes.js.map +1 -1
  5. package/dist/broadcastControls.d.ts +1 -1
  6. package/dist/broadcastControls.js.map +1 -1
  7. package/dist/datastorePresenceManagerFactory.d.ts +5 -5
  8. package/dist/datastorePresenceManagerFactory.d.ts.map +1 -1
  9. package/dist/datastorePresenceManagerFactory.js +6 -6
  10. package/dist/datastorePresenceManagerFactory.js.map +1 -1
  11. package/dist/experimentalAccess.d.ts +4 -4
  12. package/dist/experimentalAccess.d.ts.map +1 -1
  13. package/dist/experimentalAccess.js +6 -6
  14. package/dist/experimentalAccess.js.map +1 -1
  15. package/dist/exposedInternalTypes.d.ts +1 -1
  16. package/dist/exposedInternalTypes.js.map +1 -1
  17. package/dist/exposedUtilityTypes.d.ts +0 -8
  18. package/dist/exposedUtilityTypes.d.ts.map +1 -1
  19. package/dist/exposedUtilityTypes.js.map +1 -1
  20. package/dist/index.d.ts +8 -7
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +6 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/internalTypes.d.ts +3 -3
  25. package/dist/internalTypes.d.ts.map +1 -1
  26. package/dist/internalTypes.js.map +1 -1
  27. package/dist/internalUtils.d.ts +5 -0
  28. package/dist/internalUtils.d.ts.map +1 -1
  29. package/dist/internalUtils.js +8 -1
  30. package/dist/internalUtils.js.map +1 -1
  31. package/dist/latestMapValueManager.d.ts +57 -39
  32. package/dist/latestMapValueManager.d.ts.map +1 -1
  33. package/dist/latestMapValueManager.js +48 -39
  34. package/dist/latestMapValueManager.js.map +1 -1
  35. package/dist/latestValueManager.d.ts +38 -20
  36. package/dist/latestValueManager.d.ts.map +1 -1
  37. package/dist/latestValueManager.js +32 -28
  38. package/dist/latestValueManager.js.map +1 -1
  39. package/dist/latestValueTypes.d.ts +9 -10
  40. package/dist/latestValueTypes.d.ts.map +1 -1
  41. package/dist/latestValueTypes.js.map +1 -1
  42. package/dist/notificationsManager.d.ts +15 -10
  43. package/dist/notificationsManager.d.ts.map +1 -1
  44. package/dist/notificationsManager.js +8 -5
  45. package/dist/notificationsManager.js.map +1 -1
  46. package/dist/presence.d.ts +82 -66
  47. package/dist/presence.d.ts.map +1 -1
  48. package/dist/presence.js +5 -5
  49. package/dist/presence.js.map +1 -1
  50. package/dist/presenceDatastoreManager.d.ts +12 -10
  51. package/dist/presenceDatastoreManager.d.ts.map +1 -1
  52. package/dist/presenceDatastoreManager.js +10 -8
  53. package/dist/presenceDatastoreManager.js.map +1 -1
  54. package/dist/presenceManager.d.ts +2 -2
  55. package/dist/presenceManager.d.ts.map +1 -1
  56. package/dist/presenceManager.js +14 -22
  57. package/dist/presenceManager.js.map +1 -1
  58. package/dist/presenceStates.d.ts +14 -13
  59. package/dist/presenceStates.d.ts.map +1 -1
  60. package/dist/presenceStates.js +22 -15
  61. package/dist/presenceStates.js.map +1 -1
  62. package/dist/stateDatastore.d.ts +5 -4
  63. package/dist/stateDatastore.d.ts.map +1 -1
  64. package/dist/stateDatastore.js.map +1 -1
  65. package/dist/stateFactory.d.ts +22 -0
  66. package/dist/stateFactory.d.ts.map +1 -0
  67. package/dist/stateFactory.js +25 -0
  68. package/dist/stateFactory.js.map +1 -0
  69. package/dist/systemWorkspace.d.ts +7 -7
  70. package/dist/systemWorkspace.d.ts.map +1 -1
  71. package/dist/systemWorkspace.js +23 -23
  72. package/dist/systemWorkspace.js.map +1 -1
  73. package/dist/types.d.ts +50 -33
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/types.js +0 -1
  76. package/dist/types.js.map +1 -1
  77. package/lib/alpha.d.ts +29 -25
  78. package/lib/baseTypes.d.ts +3 -3
  79. package/lib/baseTypes.js.map +1 -1
  80. package/lib/broadcastControls.d.ts +1 -1
  81. package/lib/broadcastControls.js.map +1 -1
  82. package/lib/datastorePresenceManagerFactory.d.ts +5 -5
  83. package/lib/datastorePresenceManagerFactory.d.ts.map +1 -1
  84. package/lib/datastorePresenceManagerFactory.js +4 -4
  85. package/lib/datastorePresenceManagerFactory.js.map +1 -1
  86. package/lib/experimentalAccess.d.ts +4 -4
  87. package/lib/experimentalAccess.d.ts.map +1 -1
  88. package/lib/experimentalAccess.js +4 -4
  89. package/lib/experimentalAccess.js.map +1 -1
  90. package/lib/exposedInternalTypes.d.ts +1 -1
  91. package/lib/exposedInternalTypes.js.map +1 -1
  92. package/lib/exposedUtilityTypes.d.ts +0 -8
  93. package/lib/exposedUtilityTypes.d.ts.map +1 -1
  94. package/lib/exposedUtilityTypes.js.map +1 -1
  95. package/lib/index.d.ts +8 -7
  96. package/lib/index.d.ts.map +1 -1
  97. package/lib/index.js +4 -5
  98. package/lib/index.js.map +1 -1
  99. package/lib/internalTypes.d.ts +3 -3
  100. package/lib/internalTypes.d.ts.map +1 -1
  101. package/lib/internalTypes.js.map +1 -1
  102. package/lib/internalUtils.d.ts +5 -0
  103. package/lib/internalUtils.d.ts.map +1 -1
  104. package/lib/internalUtils.js +6 -0
  105. package/lib/internalUtils.js.map +1 -1
  106. package/lib/latestMapValueManager.d.ts +57 -39
  107. package/lib/latestMapValueManager.d.ts.map +1 -1
  108. package/lib/latestMapValueManager.js +47 -38
  109. package/lib/latestMapValueManager.js.map +1 -1
  110. package/lib/latestValueManager.d.ts +38 -20
  111. package/lib/latestValueManager.d.ts.map +1 -1
  112. package/lib/latestValueManager.js +31 -27
  113. package/lib/latestValueManager.js.map +1 -1
  114. package/lib/latestValueTypes.d.ts +9 -10
  115. package/lib/latestValueTypes.d.ts.map +1 -1
  116. package/lib/latestValueTypes.js.map +1 -1
  117. package/lib/notificationsManager.d.ts +15 -10
  118. package/lib/notificationsManager.d.ts.map +1 -1
  119. package/lib/notificationsManager.js +8 -5
  120. package/lib/notificationsManager.js.map +1 -1
  121. package/lib/presence.d.ts +82 -66
  122. package/lib/presence.d.ts.map +1 -1
  123. package/lib/presence.js +4 -4
  124. package/lib/presence.js.map +1 -1
  125. package/lib/presenceDatastoreManager.d.ts +12 -10
  126. package/lib/presenceDatastoreManager.d.ts.map +1 -1
  127. package/lib/presenceDatastoreManager.js +10 -8
  128. package/lib/presenceDatastoreManager.js.map +1 -1
  129. package/lib/presenceManager.d.ts +2 -2
  130. package/lib/presenceManager.d.ts.map +1 -1
  131. package/lib/presenceManager.js +14 -22
  132. package/lib/presenceManager.js.map +1 -1
  133. package/lib/presenceStates.d.ts +14 -13
  134. package/lib/presenceStates.d.ts.map +1 -1
  135. package/lib/presenceStates.js +22 -15
  136. package/lib/presenceStates.js.map +1 -1
  137. package/lib/stateDatastore.d.ts +5 -4
  138. package/lib/stateDatastore.d.ts.map +1 -1
  139. package/lib/stateDatastore.js.map +1 -1
  140. package/lib/stateFactory.d.ts +22 -0
  141. package/lib/stateFactory.d.ts.map +1 -0
  142. package/lib/stateFactory.js +22 -0
  143. package/lib/stateFactory.js.map +1 -0
  144. package/lib/systemWorkspace.d.ts +7 -7
  145. package/lib/systemWorkspace.d.ts.map +1 -1
  146. package/lib/systemWorkspace.js +24 -24
  147. package/lib/systemWorkspace.js.map +1 -1
  148. package/lib/tsdoc-metadata.json +1 -1
  149. package/lib/types.d.ts +50 -33
  150. package/lib/types.d.ts.map +1 -1
  151. package/lib/types.js +0 -1
  152. package/lib/types.js.map +1 -1
  153. package/package.json +19 -19
@@ -29,7 +29,7 @@ class NotificationsManagerImpl {
29
29
  // This is a notification, so we want to send it immediately.
30
30
  { allowableUpdateLatencyMs: 0 });
31
31
  },
32
- unicast: (name, targetClient, ...args) => {
32
+ unicast: (name, targetAttendee, ...args) => {
33
33
  this.datastore.localUpdate(this.key, {
34
34
  rev: 0,
35
35
  timestamp: 0,
@@ -37,7 +37,7 @@ class NotificationsManagerImpl {
37
37
  ignoreUnmonitored: true,
38
38
  },
39
39
  // This is a notification, so we want to send it immediately.
40
- { allowableUpdateLatencyMs: 0, targetClientId: targetClient.getConnectionId() });
40
+ { allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() });
41
41
  },
42
42
  };
43
43
  // Workaround for types
@@ -58,17 +58,20 @@ class NotificationsManagerImpl {
58
58
  }
59
59
  }
60
60
  }
61
- update(client, _received, value) {
61
+ get presence() {
62
+ return this.datastore.presence;
63
+ }
64
+ update(attendee, _received, value) {
62
65
  const postUpdateActions = [];
63
66
  const eventName = value.value.name;
64
67
  if (this.notificationsInternal.hasListeners(eventName)) {
65
68
  // Without schema validation, we don't know that the args are the correct type.
66
69
  // For now we assume the user is sending the correct types and there is no corruption along the way.
67
- const args = [client, ...value.value.args];
70
+ const args = [attendee, ...value.value.args];
68
71
  postUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));
69
72
  }
70
73
  else {
71
- postUpdateActions.push(() => this.events.emit("unattendedNotification", value.value.name, client, ...value.value.args));
74
+ postUpdateActions.push(() => this.events.emit("unattendedNotification", value.value.name, attendee, ...value.value.args));
72
75
  }
73
76
  return postUpdateActions;
74
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAQ7D,2DAA+E;AAC/E,uDAA6C;AA0I7C;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MAAM,wBAAwB;IA+C7B,YACkB,GAAQ,EACR,SAGhB,EACD,oBAA2D;QAL1C,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAGzB;QA1Cc,WAAM,GAAG,IAAA,4BAAa,GAA8B,CAAC;QAErD,SAAI,GAA2B;YAC9C,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE;gBAC5B,IAAI,CAAC,SAAS,CAAC,WAAW,CACzB,IAAI,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IAEM,MAAM,CACZ,MAAsB,EACtB,SAAiB,EACjB,KAAuE;QAEvE,MAAM,iBAAiB,GAAuB,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,IAAqD,CAAC;QACpF,IAAI,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,+EAA+E;YAC/E,oGAAoG;YACpG,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAExC,CAAC;YACF,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACP,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,wBAAwB,EACxB,KAAK,CAAC,KAAK,CAAC,IAAI,EAChB,MAAM,EACN,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CACnB,CACD,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC1B,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAI5B,oBAA2D;IAM3D,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAGA,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,wBAAwB,CAC3B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC;AAhCD,sCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners, Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport type { ISessionClient } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.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: (\n\t\tname: string,\n\t\tsender: ISessionClient,\n\t\t...content: unknown[]\n\t) => 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: ISessionClient,\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: ISessionClient,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscriptions.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriptions<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: ISessionClient,\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 string & 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 client.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetClient - the single client to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetClient: ISessionClient,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Value manager that provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link Notifications} registered to {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\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 * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name, targetClient, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetClient.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal = createEmitter<NotificationSubscriptions<T>>();\n\n\t// @ts-expect-error TODO\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriptions<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic update(\n\t\tclient: ISessionClient,\n\t\t_received: number,\n\t\tvalue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst eventName = value.value.name as keyof Listeners<NotificationSubscriptions<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [client, ...value.value.args] as Parameters<\n\t\t\t\tNotificationSubscriptions<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\n\t\t\t\t\t\"unattendedNotification\",\n\t\t\t\t\tvalue.value.name,\n\t\t\t\t\tclient,\n\t\t\t\t\t...value.value.args,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @remarks\n * Typescript inference for `Notifications` is not working correctly yet.\n * Explicitly specify generics to make result types usable.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
1
+ {"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAQ7D,2DAA+E;AAC/E,uDAA6C;AA4I7C;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MAAM,wBAAwB;IA+C7B,YACkB,GAAQ,EACR,SAGhB,EACD,oBAA2D;QAL1C,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAG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EAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC;AAhCD,sCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners, Listenable, Off } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport type { Attendee, Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.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 subscriptions.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriptions<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in string & 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 string & 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 string & 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 Notifications} 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 * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name, targetAttendee, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: { name, args: [...(args as JsonTypeWith<never>[])] },\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal = createEmitter<NotificationSubscriptions<T>>();\n\n\t// @ts-expect-error TODO\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriptions<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tvalue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst eventName = value.value.name as keyof Listeners<NotificationSubscriptions<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [attendee, ...value.value.args] as Parameters<\n\t\t\t\tNotificationSubscriptions<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\n\t\t\t\t\t\"unattendedNotification\",\n\t\t\t\t\tvalue.value.name,\n\t\t\t\t\tattendee,\n\t\t\t\t\t...value.value.args,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @remarks\n * Typescript inference for `Notifications` is not working correctly yet.\n * Explicitly specify generics to make result types usable.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
@@ -6,42 +6,42 @@ import type { Listenable } from "@fluidframework/core-interfaces";
6
6
  import type { SessionId } from "@fluidframework/id-compressor";
7
7
  import type { ClientConnectionId } from "./baseTypes.js";
8
8
  import type { BroadcastControlSettings } from "./broadcastControls.js";
9
- import type { PresenceNotifications, PresenceNotificationsSchema, PresenceStates, PresenceStatesSchema, PresenceWorkspaceAddress } from "./types.js";
9
+ import type { NotificationsWorkspace, NotificationsWorkspaceSchema, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "./types.js";
10
10
  /**
11
11
  * A Fluid client session identifier.
12
12
  *
13
13
  * @remarks
14
14
  * Each client once connected to a session is given a unique identifier for the
15
15
  * duration of the session. If a client disconnects and reconnects, it will
16
- * retain its identifier. Prefer use of {@link ISessionClient} as a way to
17
- * identify clients in a session. {@link ISessionClient.sessionId} will provide
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
18
  * the session ID.
19
19
  *
20
20
  * @alpha
21
21
  */
22
- export type ClientSessionId = SessionId & {
23
- readonly ClientSessionId: "ClientSessionId";
22
+ export type AttendeeId = SessionId & {
23
+ readonly AttendeeId: "AttendeeId";
24
24
  };
25
25
  /**
26
- * The connection status of the {@link ISessionClient}.
26
+ * The connection status of the {@link Attendee}.
27
27
  *
28
28
  * @alpha
29
29
  */
30
- export declare const SessionClientStatus: {
30
+ export declare const AttendeeStatus: {
31
31
  /**
32
- * The session client is connected to the Fluid service.
32
+ * The {@link Attendee} is connected to the Fluid service.
33
33
  */
34
34
  readonly Connected: "Connected";
35
35
  /**
36
- * The session client is not connected to the Fluid service.
36
+ * The {@link Attendee} is not connected to the Fluid service.
37
37
  */
38
38
  readonly Disconnected: "Disconnected";
39
39
  };
40
40
  /**
41
- * Represents the connection status of an {@link ISessionClient}.
41
+ * Represents the connection status of an {@link Attendee}.
42
42
  *
43
43
  * This type can be either `'Connected'` or `'Disconnected'`, indicating whether
44
- * the session client is currently connected to the Fluid service.
44
+ * the attendee is currently connected to the Fluid service.
45
45
  *
46
46
  * When `'Disconnected'`:
47
47
  * - State changes are kept locally and communicated to others upon reconnect.
@@ -49,17 +49,17 @@ export declare const SessionClientStatus: {
49
49
  *
50
50
  * @alpha
51
51
  */
52
- export type SessionClientStatus = (typeof SessionClientStatus)[keyof typeof SessionClientStatus];
52
+ export type AttendeeStatus = (typeof AttendeeStatus)[keyof typeof AttendeeStatus];
53
53
  /**
54
54
  * A client within a Fluid session (period of container connectivity to service).
55
55
  *
56
56
  * @remarks
57
- * Note: This is very preliminary session client representation.
57
+ * Note: This is very preliminary attendee representation.
58
58
  *
59
- * `ISessionClient` should be used as key to distinguish between different
59
+ * {@link Attendee} should be used as key to distinguish between different
60
60
  * clients as they join, rejoin, and disconnect from a session. While a
61
- * client's {@link ClientConnectionId} from {@link ISessionClient.getConnectionStatus}
62
- * may change over time, `ISessionClient` will be fixed.
61
+ * client's {@link ClientConnectionId} from {@link Attendee.getConnectionStatus}
62
+ * may change over time, `Attendee` will be fixed.
63
63
  *
64
64
  * @privateRemarks
65
65
  * As this is evolved, pay attention to how this relates to Audience, Service
@@ -68,11 +68,11 @@ export type SessionClientStatus = (typeof SessionClientStatus)[keyof typeof Sess
68
68
  * @sealed
69
69
  * @alpha
70
70
  */
71
- export interface ISessionClient<SpecificSessionClientId extends ClientSessionId = ClientSessionId> {
71
+ export interface Attendee<SpecificAttendeeId extends AttendeeId = AttendeeId> {
72
72
  /**
73
73
  * The session ID of the client that is stable over all connections.
74
74
  */
75
- readonly sessionId: SpecificSessionClientId;
75
+ readonly attendeeId: SpecificAttendeeId;
76
76
  /**
77
77
  * Get current client connection ID.
78
78
  *
@@ -81,41 +81,47 @@ export interface ISessionClient<SpecificSessionClientId extends ClientSessionId
81
81
  * @remarks
82
82
  * Connection ID will change on reconnect.
83
83
  *
84
- * If {@link ISessionClient.getConnectionStatus} is {@link (SessionClientStatus:variable).Disconnected}, this will represent the last known connection ID.
84
+ * If {@link Attendee.getConnectionStatus} is {@link (AttendeeStatus:variable).Disconnected}, this will represent the last known connection ID.
85
85
  */
86
86
  getConnectionId(): ClientConnectionId;
87
87
  /**
88
- * Get connection status of session client.
88
+ * Get connection status of attendee.
89
89
  *
90
- * @returns Connection status of session client.
90
+ * @returns Connection status of attendee.
91
91
  *
92
92
  */
93
- getConnectionStatus(): SessionClientStatus;
93
+ getConnectionStatus(): AttendeeStatus;
94
94
  }
95
95
  /**
96
- * Utility type limiting to a specific session client. (A session client with
96
+ * Utility type limiting to a specific attendee. (A attendee with
97
97
  * a specific session ID - not just any session ID.)
98
98
  *
99
99
  * @internal
100
100
  */
101
- export type SpecificSessionClient<SpecificSessionClientId extends ClientSessionId> = string extends SpecificSessionClientId ? never : ISessionClient<SpecificSessionClientId>;
101
+ export type SpecificAttendee<SpecificAttendeeId extends AttendeeId> = string extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;
102
102
  /**
103
103
  * @sealed
104
104
  * @alpha
105
105
  */
106
- export interface PresenceEvents {
106
+ export interface AttendeesEvents {
107
107
  /**
108
108
  * Raised when new client joins session.
109
109
  *
110
110
  * @eventProperty
111
111
  */
112
- attendeeJoined: (attendee: ISessionClient) => void;
112
+ attendeeConnected: (attendee: Attendee) => void;
113
113
  /**
114
114
  * Raised when client appears disconnected from session.
115
115
  *
116
116
  * @eventProperty
117
117
  */
118
- attendeeDisconnected: (attendee: ISessionClient) => void;
118
+ attendeeDisconnected: (attendee: Attendee) => void;
119
+ }
120
+ /**
121
+ * @sealed
122
+ * @alpha
123
+ */
124
+ export interface PresenceEvents {
119
125
  /**
120
126
  * Raised when a workspace is activated within the session.
121
127
  *
@@ -128,7 +134,7 @@ export interface PresenceEvents {
128
134
  * be done before the event handler returns to ensure no notifications
129
135
  * are missed.
130
136
  */
131
- workspaceActivated: (workspaceAddress: PresenceWorkspaceAddress, type: "States" | "Notifications" | "Unknown") => void;
137
+ workspaceActivated: (workspaceAddress: WorkspaceAddress, type: "States" | "Notifications" | "Unknown") => void;
132
138
  }
133
139
  /**
134
140
  * Presence represents known clients within a session and their custom states and notifications.
@@ -136,47 +142,57 @@ export interface PresenceEvents {
136
142
  * @sealed
137
143
  * @alpha
138
144
  */
139
- export interface IPresence {
145
+ export interface Presence {
140
146
  /**
141
147
  * Events for Presence.
142
148
  */
143
149
  readonly events: Listenable<PresenceEvents>;
144
- /**
145
- * Get all attendees in the session.
146
- *
147
- * @remarks
148
- * Attendee states are dynamic and will change as clients join and leave
149
- * the session.
150
- */
151
- getAttendees(): ReadonlySet<ISessionClient>;
152
- /**
153
- * Lookup a specific attendee in the session.
154
- *
155
- * @param clientId - Client connection or session ID
156
- */
157
- getAttendee(clientId: ClientConnectionId | ClientSessionId): ISessionClient;
158
- /**
159
- * Get this client's session client.
160
- *
161
- * @returns This client's session client.
162
- */
163
- getMyself(): ISessionClient;
164
- /**
165
- * Acquires a PresenceStates workspace from store or adds new one.
166
- *
167
- * @param workspaceAddress - Address of the requested PresenceStates Workspace
168
- * @param requestedContent - Requested states for the workspace
169
- * @param controls - Optional settings for default broadcast controls
170
- * @returns A PresenceStates workspace
171
- */
172
- getStates<StatesSchema extends PresenceStatesSchema>(workspaceAddress: PresenceWorkspaceAddress, requestedContent: StatesSchema, controls?: BroadcastControlSettings): PresenceStates<StatesSchema>;
173
- /**
174
- * Acquires a Notifications workspace from store or adds new one.
175
- *
176
- * @param workspaceAddress - Address of the requested Notifications Workspace
177
- * @param requestedContent - Requested notifications for the workspace
178
- * @returns A Notifications workspace
179
- */
180
- getNotifications<NotificationsSchema extends PresenceNotificationsSchema>(notificationsId: PresenceWorkspaceAddress, requestedContent: NotificationsSchema): PresenceNotifications<NotificationsSchema>;
150
+ readonly attendees: {
151
+ /**
152
+ * Events for {@link Attendee}s.
153
+ */
154
+ readonly events: Listenable<AttendeesEvents>;
155
+ /**
156
+ * Get all {@link Attendee}s in the session.
157
+ *
158
+ * @remarks
159
+ * Attendee states are dynamic and will change as clients join and leave
160
+ * the session.
161
+ */
162
+ getAttendees(): ReadonlySet<Attendee>;
163
+ /**
164
+ * Lookup a specific {@link Attendee} in the session.
165
+ *
166
+ * @param clientId - Client connection or session ID
167
+ */
168
+ getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee;
169
+ /**
170
+ * Get this client's {@link Attendee}.
171
+ *
172
+ * @returns This client's attendee.
173
+ */
174
+ getMyself(): Attendee;
175
+ };
176
+ readonly states: {
177
+ /**
178
+ * Acquires a StatesWorkspace from store or adds new one.
179
+ *
180
+ * @param workspaceAddress - Address of the requested StatesWorkspace
181
+ * @param requestedStates - Requested states for the workspace
182
+ * @param controls - Optional settings for default broadcast controls
183
+ * @returns A StatesWorkspace
184
+ */
185
+ getWorkspace<StatesSchema extends StatesWorkspaceSchema>(workspaceAddress: WorkspaceAddress, requestedStates: StatesSchema, controls?: BroadcastControlSettings): StatesWorkspace<StatesSchema>;
186
+ };
187
+ readonly notifications: {
188
+ /**
189
+ * Acquires a Notifications workspace from store or adds new one.
190
+ *
191
+ * @param workspaceAddress - Address of the requested Notifications Workspace
192
+ * @param requestedNotifications - Requested notifications for the workspace
193
+ * @returns A Notifications workspace
194
+ */
195
+ getWorkspace<NotificationsSchema extends NotificationsWorkspaceSchema>(notificationsId: WorkspaceAddress, requestedNotifications: NotificationsSchema): NotificationsWorkspace<NotificationsSchema>;
196
+ };
181
197
  }
182
198
  //# sourceMappingURL=presence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,O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,CAAC,QAAQ,EAAE,kBAAkB,GAAG,UAAU,GAAG,QAAQ,CAAC;QAEjE;;;;WAIG;QACH,SAAS,IAAI,QAAQ,CAAC;KACtB,CAAC;IAEF,QAAQ,CAAC,MAAM,EAAE;QAChB;;;;;;;WAOG;QACH,YAAY,CAAC,YAAY,SAAS,qBAAqB,EACtD,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,YAAY,EAC7B,QAAQ,CAAC,EAAE,wBAAwB,GACjC,eAAe,CAAC,YAAY,CAAC,CAAC;KACjC,CAAC;IAEF,QAAQ,CAAC,aAAa,EAAE;QACvB;;;;;;WAMG;QACH,YAAY,CAAC,mBAAmB,SAAS,4BAA4B,EACpE,eAAe,EAAE,gBAAgB,EACjC,sBAAsB,EAAE,mBAAmB,GACzC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;KAC/C,CAAC;CACF"}
package/dist/presence.js CHANGED
@@ -4,19 +4,19 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SessionClientStatus = void 0;
7
+ exports.AttendeeStatus = void 0;
8
8
  /**
9
- * The connection status of the {@link ISessionClient}.
9
+ * The connection status of the {@link Attendee}.
10
10
  *
11
11
  * @alpha
12
12
  */
13
- exports.SessionClientStatus = {
13
+ exports.AttendeeStatus = {
14
14
  /**
15
- * The session client is connected to the Fluid service.
15
+ * The {@link Attendee} is connected to the Fluid service.
16
16
  */
17
17
  Connected: "Connected",
18
18
  /**
19
- * The session client is not connected to the Fluid service.
19
+ * The {@link Attendee} is not connected to the Fluid service.
20
20
  */
21
21
  Disconnected: "Disconnected",
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"presence.js","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6BH;;;;GAIG;AACU,QAAA,mBAAmB,GAAG;IAClC;;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 \"./broadcastControls.js\";\nimport type {\n\tPresenceNotifications,\n\tPresenceNotificationsSchema,\n\tPresenceStates,\n\tPresenceStatesSchema,\n\tPresenceWorkspaceAddress,\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 ISessionClient} as a way to\n * identify clients in a session. {@link ISessionClient.sessionId} will provide\n * the session ID.\n *\n * @alpha\n */\nexport type ClientSessionId = SessionId & { readonly ClientSessionId: \"ClientSessionId\" };\n\n/**\n * The connection status of the {@link ISessionClient}.\n *\n * @alpha\n */\nexport const SessionClientStatus = {\n\t/**\n\t * The session client is connected to the Fluid service.\n\t */\n\tConnected: \"Connected\",\n\n\t/**\n\t * The session client 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 ISessionClient}.\n *\n * This type can be either `'Connected'` or `'Disconnected'`, indicating whether\n * the session client 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 * @alpha\n */\nexport type SessionClientStatus =\n\t(typeof SessionClientStatus)[keyof typeof SessionClientStatus];\n\n/**\n * A client within a Fluid session (period of container connectivity to service).\n *\n * @remarks\n * Note: This is very preliminary session client representation.\n *\n * `ISessionClient` 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 ISessionClient.getConnectionStatus}\n * may change over time, `ISessionClient` 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 * @alpha\n */\nexport interface ISessionClient<\n\tSpecificSessionClientId extends ClientSessionId = ClientSessionId,\n> {\n\t/**\n\t * The session ID of the client that is stable over all connections.\n\t */\n\treadonly sessionId: SpecificSessionClientId;\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 ISessionClient.getConnectionStatus} is {@link (SessionClientStatus:variable).Disconnected}, this will represent the last known connection ID.\n\t */\n\tgetConnectionId(): ClientConnectionId;\n\n\t/**\n\t * Get connection status of session client.\n\t *\n\t * @returns Connection status of session client.\n\t *\n\t */\n\tgetConnectionStatus(): SessionClientStatus;\n}\n\n/**\n * Utility type limiting to a specific session client. (A session client with\n * a specific session ID - not just any session ID.)\n *\n * @internal\n */\nexport type SpecificSessionClient<SpecificSessionClientId extends ClientSessionId> =\n\tstring extends SpecificSessionClientId ? never : ISessionClient<SpecificSessionClientId>;\n\n/**\n * @sealed\n * @alpha\n */\nexport interface PresenceEvents {\n\t/**\n\t * Raised when new client joins session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeJoined: (attendee: ISessionClient) => void;\n\n\t/**\n\t * Raised when client appears disconnected from session.\n\t *\n\t * @eventProperty\n\t */\n\tattendeeDisconnected: (attendee: ISessionClient) => void;\n\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: PresenceWorkspaceAddress,\n\t\ttype: \"States\" | \"Notifications\" | \"Unknown\",\n\t) => void;\n}\n\n/**\n * Presence represents known clients within a session and their custom states and notifications.\n *\n * @sealed\n * @alpha\n */\nexport interface IPresence {\n\t/**\n\t * Events for Presence.\n\t */\n\treadonly events: Listenable<PresenceEvents>;\n\n\t/**\n\t * Get all attendees in the session.\n\t *\n\t * @remarks\n\t * Attendee states are dynamic and will change as clients join and leave\n\t * the session.\n\t */\n\tgetAttendees(): ReadonlySet<ISessionClient>;\n\n\t/**\n\t * Lookup a specific attendee in the session.\n\t *\n\t * @param clientId - Client connection or session ID\n\t */\n\tgetAttendee(clientId: ClientConnectionId | ClientSessionId): ISessionClient;\n\n\t/**\n\t * Get this client's session client.\n\t *\n\t * @returns This client's session client.\n\t */\n\tgetMyself(): ISessionClient;\n\n\t/**\n\t * Acquires a PresenceStates workspace from store or adds new one.\n\t *\n\t * @param workspaceAddress - Address of the requested PresenceStates Workspace\n\t * @param requestedContent - Requested states for the workspace\n\t * @param controls - Optional settings for default broadcast controls\n\t * @returns A PresenceStates workspace\n\t */\n\tgetStates<StatesSchema extends PresenceStatesSchema>(\n\t\tworkspaceAddress: PresenceWorkspaceAddress,\n\t\trequestedContent: StatesSchema,\n\t\tcontrols?: BroadcastControlSettings,\n\t): PresenceStates<StatesSchema>;\n\n\t/**\n\t * Acquires a Notifications workspace from store or adds new one.\n\t *\n\t * @param workspaceAddress - Address of the requested Notifications Workspace\n\t * @param requestedContent - Requested notifications for the workspace\n\t * @returns A Notifications workspace\n\t */\n\tgetNotifications<NotificationsSchema extends PresenceNotificationsSchema>(\n\t\tnotificationsId: PresenceWorkspaceAddress,\n\t\trequestedContent: NotificationsSchema,\n\t): PresenceNotifications<NotificationsSchema>;\n}\n"]}
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 \"./broadcastControls.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 * @alpha\n */\nexport type AttendeeId = SessionId & { readonly AttendeeId: \"AttendeeId\" };\n\n/**\n * The connection status of the {@link Attendee}.\n *\n * @alpha\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 * @alpha\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 * @alpha\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 * Utility type limiting to a specific attendee. (A attendee with\n * a specific session ID - not just any session ID.)\n *\n * @internal\n */\nexport type SpecificAttendee<SpecificAttendeeId extends AttendeeId> =\n\tstring extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;\n\n/**\n * @sealed\n * @alpha\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 * @sealed\n * @alpha\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 * Presence represents known clients within a session and their custom states and notifications.\n *\n * @sealed\n * @alpha\n */\nexport interface Presence {\n\t/**\n\t * Events for Presence.\n\t */\n\treadonly events: Listenable<PresenceEvents>;\n\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\treadonly states: {\n\t\t/**\n\t\t * Acquires a StatesWorkspace from store or adds new one.\n\t\t *\n\t\t * @param workspaceAddress - Address of the requested 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 StatesWorkspace\n\t\t */\n\t\tgetWorkspace<StatesSchema extends StatesWorkspaceSchema>(\n\t\t\tworkspaceAddress: WorkspaceAddress,\n\t\t\trequestedStates: StatesSchema,\n\t\t\tcontrols?: BroadcastControlSettings,\n\t\t): StatesWorkspace<StatesSchema>;\n\t};\n\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<NotificationsSchema extends NotificationsWorkspaceSchema>(\n\t\t\tnotificationsId: WorkspaceAddress,\n\t\t\trequestedNotifications: NotificationsSchema,\n\t\t): NotificationsWorkspace<NotificationsSchema>;\n\t};\n}\n"]}
@@ -8,23 +8,23 @@ import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/intern
8
8
  import type { ClientConnectionId } from "./baseTypes.js";
9
9
  import type { BroadcastControlSettings } from "./broadcastControls.js";
10
10
  import type { IEphemeralRuntime } from "./internalTypes.js";
11
- import type { ClientSessionId, ISessionClient, PresenceEvents } from "./presence.js";
11
+ import type { AttendeeId, Attendee, Presence, PresenceEvents } from "./presence.js";
12
12
  import type { ClientUpdateEntry, PresenceStatesInternal } from "./presenceStates.js";
13
13
  import type { SystemWorkspaceDatastore } from "./systemWorkspace.js";
14
- import type { PresenceStates, PresenceStatesSchema, PresenceWorkspaceAddress } from "./types.js";
14
+ import type { AnyWorkspace, NotificationsWorkspace, NotificationsWorkspaceSchema, StatesWorkspace, StatesWorkspaceSchema, WorkspaceAddress } from "./types.js";
15
15
  import type { IExtensionMessage } from "@fluidframework/presence/internal/container-definitions/internal";
16
- interface PresenceWorkspaceEntry<TSchema extends PresenceStatesSchema> {
17
- public: PresenceStates<TSchema>;
16
+ interface AnyWorkspaceEntry<TSchema extends StatesWorkspaceSchema> {
17
+ public: AnyWorkspace<TSchema>;
18
18
  internal: PresenceStatesInternal;
19
19
  }
20
20
  interface SystemDatastore {
21
21
  "system:presence": SystemWorkspaceDatastore;
22
22
  }
23
- type InternalWorkspaceAddress = `${"s" | "n"}:${PresenceWorkspaceAddress}`;
23
+ type InternalWorkspaceAddress = `${"s" | "n"}:${WorkspaceAddress}`;
24
24
  interface GeneralDatastoreMessageContent {
25
25
  [WorkspaceAddress: string]: {
26
26
  [StateValueManagerKey: string]: {
27
- [ClientSessionId: ClientSessionId]: ClientUpdateEntry;
27
+ [AttendeeId: AttendeeId]: ClientUpdateEntry;
28
28
  };
29
29
  };
30
30
  }
@@ -54,27 +54,29 @@ interface ClientJoinMessage extends IInboundSignalMessage {
54
54
  */
55
55
  export interface PresenceDatastoreManager {
56
56
  joinSession(clientId: ClientConnectionId): void;
57
- getWorkspace<TSchema extends PresenceStatesSchema>(internalWorkspaceAddress: InternalWorkspaceAddress, requestedContent: TSchema, controls?: BroadcastControlSettings): PresenceStates<TSchema>;
57
+ getWorkspace<TSchema extends StatesWorkspaceSchema>(internalWorkspaceAddress: `s:${WorkspaceAddress}`, requestedContent: TSchema, controls?: BroadcastControlSettings): StatesWorkspace<TSchema>;
58
+ getWorkspace<TSchema extends NotificationsWorkspaceSchema>(internalWorkspaceAddress: `n:${WorkspaceAddress}`, requestedContent: TSchema): NotificationsWorkspace<TSchema>;
58
59
  processSignal(message: IExtensionMessage, local: boolean): void;
59
60
  }
60
61
  /**
61
62
  * Manages singleton datastore for all Presence.
62
63
  */
63
64
  export declare class PresenceDatastoreManagerImpl implements PresenceDatastoreManager {
64
- private readonly clientSessionId;
65
+ private readonly attendeeId;
65
66
  private readonly runtime;
66
67
  private readonly lookupClient;
67
68
  private readonly logger;
68
69
  private readonly events;
70
+ private readonly presence;
69
71
  private readonly datastore;
70
72
  private averageLatency;
71
73
  private returnedMessages;
72
74
  private refreshBroadcastRequested;
73
75
  private readonly timer;
74
76
  private readonly workspaces;
75
- constructor(clientSessionId: ClientSessionId, runtime: IEphemeralRuntime, lookupClient: (clientId: ClientSessionId) => ISessionClient, logger: ITelemetryLoggerExt | undefined, events: IEmitter<Pick<PresenceEvents, "workspaceActivated">>, systemWorkspaceDatastore: SystemWorkspaceDatastore, systemWorkspace: PresenceWorkspaceEntry<PresenceStatesSchema>);
77
+ constructor(attendeeId: AttendeeId, runtime: IEphemeralRuntime, lookupClient: (clientId: AttendeeId) => Attendee, logger: ITelemetryLoggerExt | undefined, events: IEmitter<PresenceEvents>, presence: Presence, systemWorkspaceDatastore: SystemWorkspaceDatastore, systemWorkspace: AnyWorkspaceEntry<StatesWorkspaceSchema>);
76
78
  joinSession(clientId: ClientConnectionId): void;
77
- getWorkspace<TSchema extends PresenceStatesSchema>(internalWorkspaceAddress: InternalWorkspaceAddress, requestedContent: TSchema, controls?: BroadcastControlSettings): PresenceStates<TSchema>;
79
+ getWorkspace<TSchema extends StatesWorkspaceSchema>(internalWorkspaceAddress: InternalWorkspaceAddress, requestedContent: TSchema, controls?: BroadcastControlSettings): AnyWorkspace<TSchema>;
78
80
  /**
79
81
  * The combined contents of all queued updates. Will be undefined when no messages are queued.
80
82
  */
@@ -1 +1 @@
1
- {"version":3,"file":"presenceDatastoreManager.d.ts","sourceRoot":"","sources":["../src/presenceDatastoreManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EACX,iBAAiB,EAEjB,sBAAsB,EAEtB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EACX,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kEAAkE,CAAC;AAE1G,UAAU,sBAAsB,CAAC,OAAO,SAAS,oBAAoB;IACpE,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,sBAAsB,CAAC;CACjC;AAED,UAAU,eAAe;IACxB,iBAAiB,EAAE,wBAAwB,CAAC;CAC5C;AAED,KAAK,wBAAwB,GAAG,GAAG,GAAG,GAAG,GAA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,EAC3E,KAAK,EAAE,OAAO,GACZ,IAAI;IA+FP;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;CAgE3B"}
@@ -30,10 +30,10 @@ function mergeGeneralDatastoreMessageContent(base, newData) {
30
30
  const mergedData = queueDatastore[workspaceName] ?? {};
31
31
  // Iterate over each value manager and its data, merging it as needed.
32
32
  for (const [valueManagerKey, valueManagerValue] of (0, internalUtils_js_1.objectEntries)(workspaceData)) {
33
- for (const [clientSessionId, value] of (0, internalUtils_js_1.objectEntries)(valueManagerValue)) {
33
+ for (const [attendeeId, value] of (0, internalUtils_js_1.objectEntries)(valueManagerValue)) {
34
34
  const mergeObject = (mergedData[valueManagerKey] ??= {});
35
- const oldData = mergeObject[clientSessionId];
36
- mergeObject[clientSessionId] = (0, presenceStates_js_1.mergeValueDirectory)(oldData, value, 0);
35
+ const oldData = mergeObject[attendeeId];
36
+ mergeObject[attendeeId] = (0, presenceStates_js_1.mergeValueDirectory)(oldData, value, 0);
37
37
  }
38
38
  }
39
39
  // Store the merged data in the function-local queue workspace. The whole contents of this
@@ -46,12 +46,13 @@ function mergeGeneralDatastoreMessageContent(base, newData) {
46
46
  * Manages singleton datastore for all Presence.
47
47
  */
48
48
  class PresenceDatastoreManagerImpl {
49
- constructor(clientSessionId, runtime, lookupClient, logger, events, systemWorkspaceDatastore, systemWorkspace) {
50
- this.clientSessionId = clientSessionId;
49
+ constructor(attendeeId, runtime, lookupClient, logger, events, presence, systemWorkspaceDatastore, systemWorkspace) {
50
+ this.attendeeId = attendeeId;
51
51
  this.runtime = runtime;
52
52
  this.lookupClient = lookupClient;
53
53
  this.logger = logger;
54
54
  this.events = events;
55
+ this.presence = presence;
55
56
  this.averageLatency = 0;
56
57
  this.returnedMessages = 0;
57
58
  this.refreshBroadcastRequested = false;
@@ -92,14 +93,15 @@ class PresenceDatastoreManagerImpl {
92
93
  }
93
94
  const updates = {};
94
95
  for (const [key, value] of Object.entries(states)) {
95
- updates[key] = { [this.clientSessionId]: value };
96
+ updates[key] = { [this.attendeeId]: value };
96
97
  }
97
98
  this.enqueueMessage({
98
99
  [internalWorkspaceAddress]: updates,
99
100
  }, options);
100
101
  };
101
102
  const entry = (0, presenceStates_js_1.createPresenceStates)({
102
- clientSessionId: this.clientSessionId,
103
+ presence: this.presence,
104
+ attendeeId: this.attendeeId,
103
105
  lookupClient: this.lookupClient,
104
106
  localUpdate,
105
107
  }, workspaceDatastore, requestedContent, controls);
@@ -193,7 +195,7 @@ class PresenceDatastoreManagerImpl {
193
195
  processSignal(
194
196
  // Note: IInboundSignalMessage is used here in place of IExtensionMessage
195
197
  // as IExtensionMessage's strictly JSON `content` creates type compatibility
196
- // issues with `ClientSessionId` keys and really unknown value content.
198
+ // issues with `AttendeeId` keys and really unknown value content.
197
199
  // IExtensionMessage is a subset of IInboundSignalMessage so this is safe.
198
200
  // Change types of DatastoreUpdateMessage | ClientJoinMessage to
199
201
  // IExtensionMessage<> derivatives to see the issues.