@fluidframework/presence 2.81.0-374083 → 2.81.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 (168) hide show
  1. package/dist/broadcastControls.d.ts +1 -33
  2. package/dist/broadcastControls.d.ts.map +1 -1
  3. package/dist/broadcastControls.js.map +1 -1
  4. package/dist/broadcastControlsTypes.d.ts +38 -0
  5. package/dist/broadcastControlsTypes.d.ts.map +1 -0
  6. package/dist/broadcastControlsTypes.js +7 -0
  7. package/dist/broadcastControlsTypes.js.map +1 -0
  8. package/dist/exposedInternalTypes.d.ts +3 -3
  9. package/dist/exposedInternalTypes.d.ts.map +1 -1
  10. package/dist/exposedInternalTypes.js.map +1 -1
  11. package/dist/exposedUtilityTypes.d.ts +2 -2
  12. package/dist/exposedUtilityTypes.d.ts.map +1 -1
  13. package/dist/exposedUtilityTypes.js.map +1 -1
  14. package/dist/getPresence.d.ts.map +1 -1
  15. package/dist/getPresence.js.map +1 -1
  16. package/dist/index.d.ts +3 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/internalUtils.d.ts +1 -3
  20. package/dist/internalUtils.d.ts.map +1 -1
  21. package/dist/internalUtils.js +0 -2
  22. package/dist/internalUtils.js.map +1 -1
  23. package/dist/latestMapValueManager.d.ts +1 -1
  24. package/dist/latestMapValueManager.d.ts.map +1 -1
  25. package/dist/latestMapValueManager.js.map +1 -1
  26. package/dist/latestValueManager.d.ts +1 -8
  27. package/dist/latestValueManager.d.ts.map +1 -1
  28. package/dist/latestValueManager.js +1 -2
  29. package/dist/latestValueManager.js.map +1 -1
  30. package/dist/latestValueTypes.d.ts +1 -1
  31. package/dist/latestValueTypes.d.ts.map +1 -1
  32. package/dist/latestValueTypes.js.map +1 -1
  33. package/dist/notificationsManager.d.ts +1 -102
  34. package/dist/notificationsManager.d.ts.map +1 -1
  35. package/dist/notificationsManager.js.map +1 -1
  36. package/dist/notificationsManagerTypes.d.ts +108 -0
  37. package/dist/notificationsManagerTypes.d.ts.map +1 -0
  38. package/dist/notificationsManagerTypes.js +7 -0
  39. package/dist/notificationsManagerTypes.js.map +1 -0
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.d.ts.map +1 -1
  42. package/dist/packageVersion.js +1 -1
  43. package/dist/packageVersion.js.map +1 -1
  44. package/dist/presence.d.ts +1 -1
  45. package/dist/presence.d.ts.map +1 -1
  46. package/dist/presence.js.map +1 -1
  47. package/dist/presenceDatastoreManager.d.ts +3 -11
  48. package/dist/presenceDatastoreManager.d.ts.map +1 -1
  49. package/dist/presenceDatastoreManager.js +12 -19
  50. package/dist/presenceDatastoreManager.js.map +1 -1
  51. package/dist/presenceManager.d.ts +1 -1
  52. package/dist/presenceManager.d.ts.map +1 -1
  53. package/dist/presenceManager.js +3 -7
  54. package/dist/presenceManager.js.map +1 -1
  55. package/dist/presenceStates.d.ts +4 -2
  56. package/dist/presenceStates.d.ts.map +1 -1
  57. package/dist/presenceStates.js.map +1 -1
  58. package/dist/runtimeTypes.d.ts +26 -0
  59. package/dist/runtimeTypes.d.ts.map +1 -0
  60. package/dist/{internalTypes.js → runtimeTypes.js} +1 -1
  61. package/dist/runtimeTypes.js.map +1 -0
  62. package/dist/stateDatastore.d.ts +11 -2
  63. package/dist/stateDatastore.d.ts.map +1 -1
  64. package/dist/stateDatastore.js.map +1 -1
  65. package/dist/statesManagerTypes.d.ts +27 -0
  66. package/dist/statesManagerTypes.d.ts.map +1 -0
  67. package/dist/statesManagerTypes.js +7 -0
  68. package/dist/statesManagerTypes.js.map +1 -0
  69. package/dist/systemWorkspace.d.ts.map +1 -1
  70. package/dist/systemWorkspace.js +1 -2
  71. package/dist/systemWorkspace.js.map +1 -1
  72. package/dist/types.d.ts +7 -6
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/types.js.map +1 -1
  75. package/dist/{internalTypes.d.ts → validatableTypes.d.ts} +1 -59
  76. package/dist/validatableTypes.d.ts.map +1 -0
  77. package/dist/validatableTypes.js +7 -0
  78. package/dist/validatableTypes.js.map +1 -0
  79. package/dist/valueManager.d.ts +1 -1
  80. package/dist/valueManager.d.ts.map +1 -1
  81. package/dist/valueManager.js.map +1 -1
  82. package/lib/broadcastControls.d.ts +1 -33
  83. package/lib/broadcastControls.d.ts.map +1 -1
  84. package/lib/broadcastControls.js.map +1 -1
  85. package/lib/broadcastControlsTypes.d.ts +38 -0
  86. package/lib/broadcastControlsTypes.d.ts.map +1 -0
  87. package/lib/broadcastControlsTypes.js +6 -0
  88. package/lib/broadcastControlsTypes.js.map +1 -0
  89. package/lib/exposedInternalTypes.d.ts +3 -3
  90. package/lib/exposedInternalTypes.d.ts.map +1 -1
  91. package/lib/exposedInternalTypes.js.map +1 -1
  92. package/lib/exposedUtilityTypes.d.ts +2 -2
  93. package/lib/exposedUtilityTypes.d.ts.map +1 -1
  94. package/lib/exposedUtilityTypes.js.map +1 -1
  95. package/lib/getPresence.d.ts.map +1 -1
  96. package/lib/getPresence.js.map +1 -1
  97. package/lib/index.d.ts +3 -2
  98. package/lib/index.d.ts.map +1 -1
  99. package/lib/index.js +1 -1
  100. package/lib/index.js.map +1 -1
  101. package/lib/internalUtils.d.ts +1 -3
  102. package/lib/internalUtils.d.ts.map +1 -1
  103. package/lib/internalUtils.js +0 -2
  104. package/lib/internalUtils.js.map +1 -1
  105. package/lib/latestMapValueManager.d.ts +1 -1
  106. package/lib/latestMapValueManager.d.ts.map +1 -1
  107. package/lib/latestMapValueManager.js.map +1 -1
  108. package/lib/latestValueManager.d.ts +1 -8
  109. package/lib/latestValueManager.d.ts.map +1 -1
  110. package/lib/latestValueManager.js +1 -1
  111. package/lib/latestValueManager.js.map +1 -1
  112. package/lib/latestValueTypes.d.ts +1 -1
  113. package/lib/latestValueTypes.d.ts.map +1 -1
  114. package/lib/latestValueTypes.js.map +1 -1
  115. package/lib/notificationsManager.d.ts +1 -102
  116. package/lib/notificationsManager.d.ts.map +1 -1
  117. package/lib/notificationsManager.js.map +1 -1
  118. package/lib/notificationsManagerTypes.d.ts +108 -0
  119. package/lib/notificationsManagerTypes.d.ts.map +1 -0
  120. package/lib/notificationsManagerTypes.js +6 -0
  121. package/lib/notificationsManagerTypes.js.map +1 -0
  122. package/lib/packageVersion.d.ts +1 -1
  123. package/lib/packageVersion.d.ts.map +1 -1
  124. package/lib/packageVersion.js +1 -1
  125. package/lib/packageVersion.js.map +1 -1
  126. package/lib/presence.d.ts +1 -1
  127. package/lib/presence.d.ts.map +1 -1
  128. package/lib/presence.js.map +1 -1
  129. package/lib/presenceDatastoreManager.d.ts +3 -11
  130. package/lib/presenceDatastoreManager.d.ts.map +1 -1
  131. package/lib/presenceDatastoreManager.js +12 -18
  132. package/lib/presenceDatastoreManager.js.map +1 -1
  133. package/lib/presenceManager.d.ts +1 -1
  134. package/lib/presenceManager.d.ts.map +1 -1
  135. package/lib/presenceManager.js +3 -7
  136. package/lib/presenceManager.js.map +1 -1
  137. package/lib/presenceStates.d.ts +4 -2
  138. package/lib/presenceStates.d.ts.map +1 -1
  139. package/lib/presenceStates.js.map +1 -1
  140. package/lib/runtimeTypes.d.ts +26 -0
  141. package/lib/runtimeTypes.d.ts.map +1 -0
  142. package/lib/{internalTypes.js → runtimeTypes.js} +1 -1
  143. package/lib/runtimeTypes.js.map +1 -0
  144. package/lib/stateDatastore.d.ts +11 -2
  145. package/lib/stateDatastore.d.ts.map +1 -1
  146. package/lib/stateDatastore.js.map +1 -1
  147. package/lib/statesManagerTypes.d.ts +27 -0
  148. package/lib/statesManagerTypes.d.ts.map +1 -0
  149. package/lib/statesManagerTypes.js +6 -0
  150. package/lib/statesManagerTypes.js.map +1 -0
  151. package/lib/systemWorkspace.d.ts.map +1 -1
  152. package/lib/systemWorkspace.js +1 -2
  153. package/lib/systemWorkspace.js.map +1 -1
  154. package/lib/types.d.ts +7 -6
  155. package/lib/types.d.ts.map +1 -1
  156. package/lib/types.js.map +1 -1
  157. package/lib/{internalTypes.d.ts → validatableTypes.d.ts} +1 -59
  158. package/lib/validatableTypes.d.ts.map +1 -0
  159. package/lib/validatableTypes.js +6 -0
  160. package/lib/validatableTypes.js.map +1 -0
  161. package/lib/valueManager.d.ts +1 -1
  162. package/lib/valueManager.d.ts.map +1 -1
  163. package/lib/valueManager.js.map +1 -1
  164. package/package.json +16 -16
  165. package/dist/internalTypes.d.ts.map +0 -1
  166. package/dist/internalTypes.js.map +0 -1
  167. package/lib/internalTypes.d.ts.map +0 -1
  168. package/lib/internalTypes.js.map +0 -1
@@ -4,8 +4,17 @@
4
4
  */
5
5
  import type { ClientConnectionId } from "./baseTypes.js";
6
6
  import type { InternalTypes } from "./exposedInternalTypes.js";
7
- import type { ClientRecord, ValidatableValueDirectoryOrState, ValidatableValueStructure } from "./internalTypes.js";
8
7
  import type { AttendeeId, PresenceWithNotifications as Presence } from "./presence.js";
8
+ import type { ValidatableValueDirectoryOrState, ValidatableValueStructure } from "./validatableTypes.js";
9
+ /**
10
+ * Basic structure of set of {@link Attendee} records within Presence datastore
11
+ *
12
+ * @remarks
13
+ * This is commonly exists per named state in State Managers.
14
+ */
15
+ export interface ClientRecord<TValue extends ValidatableValueDirectoryOrState<unknown>> {
16
+ [AttendeeId: AttendeeId]: TValue;
17
+ }
9
18
  /**
10
19
  * Miscellaneous options for local state updates
11
20
  */
@@ -43,5 +52,5 @@ export declare function handleFromDatastore<TKey extends string, TValue extends
43
52
  /**
44
53
  * Helper to get the datastore back from its handle.
45
54
  */
46
- export declare function datastoreFromHandle<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue>;
55
+ export declare function datastoreFromHandle<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue>;
47
56
  //# sourceMappingURL=stateDatastore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stateDatastore.d.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BAAmB,CAGjC,MAAwD;IACzD,OAAO,MAAiD,CAAC;AAC1D,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type {\n\tClientRecord,\n\tValidatableValueDirectoryOrState,\n\tValidatableValueStructure,\n} from \"./internalTypes.js\";\nimport type { AttendeeId, PresenceWithNotifications as Presence } from \"./presence.js\";\n\n// type StateDatastoreSchemaNode<\n// \tTValue extends InternalTypes.ValueDirectoryOrState<any> = InternalTypes.ValueDirectoryOrState<unknown>,\n// > = TValue extends InternalTypes.ValueDirectoryOrState<infer T> ? InternalTypes.ValueDirectoryOrState<T> : never;\n\n// export interface StateDatastoreSchema {\n// \t// This type is not precise. It may\n// \t// need to be replaced with StatesWorkspace schema pattern\n// \t// similar to what is commented out.\n// \t[key: string]: InternalTypes.ValueDirectoryOrState<unknown>;\n// \t// [key: string]: StateDatastoreSchemaNode;\n// }\n\n/**\n * Miscellaneous options for local state updates\n */\nexport interface LocalStateUpdateOptions {\n\t/**\n\t * When defined, this is the maximum time in milliseconds that this\n\t * update is allowed to be delayed before it must be sent to service.\n\t * When `undefined`, the callee may determine maximum delay.\n\t */\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * Contract for States Workspace to support State Manager access to\n * datastore and general internal presence knowledge.\n */\nexport interface StateDatastore<\n\tTKey extends string,\n\tTLocalUpdateValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTStoredValue extends\n\t\tValidatableValueDirectoryOrState<unknown> = ValidatableValueStructure<TLocalUpdateValue>,\n> {\n\treadonly presence: Presence;\n\tlocalUpdate(\n\t\tkey: TKey,\n\t\tvalue: TLocalUpdateValue & {\n\t\t\tignoreUnmonitored?: true;\n\t\t},\n\t\toptions: LocalStateUpdateOptions,\n\t): void;\n\tupdate(key: TKey, attendeeId: AttendeeId, value: TStoredValue): void;\n\tknownValues(key: TKey): {\n\t\tself: AttendeeId | undefined;\n\t\tstates: ClientRecord<TStoredValue>;\n\t};\n}\n\n/**\n * Helper to get a handle from a datastore.\n */\nexport function handleFromDatastore<\n\t// Constraining TSchema would be great, but it seems nested types (at least with undefined) cause trouble.\n\t// TSchema as `unknown` still provides some type safety.\n\t// TSchema extends StateDatastoreSchema,\n\tTKey extends string /* & keyof TSchema */,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(\n\tdatastore: StateDatastore<TKey, TValue>,\n): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>> {\n\treturn datastore as unknown as InternalTypes.StateDatastoreHandle<\n\t\tTKey,\n\t\tExclude<TValue, undefined>\n\t>;\n}\n\n/**\n * Helper to get the datastore back from its handle.\n */\nexport function datastoreFromHandle<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue> {\n\treturn handle as unknown as StateDatastore<TKey, TValue>;\n}\n"]}
1
+ {"version":3,"file":"stateDatastore.js","sourceRoot":"","sources":["../src/stateDatastore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6EH;;GAEG;AACH,SAAgB,mBAAmB,CAOlC,SAAuC;IAEvC,OAAO,SAGN,CAAC;AACH,CAAC;AAbD,kDAaC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAGjC,MAAwD;IACzD,OAAO,MAAiD,CAAC;AAC1D,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { AttendeeId, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport type {\n\tValidatableValueDirectoryOrState,\n\tValidatableValueStructure,\n} from \"./validatableTypes.js\";\n\n/**\n * Basic structure of set of {@link Attendee} records within Presence datastore\n *\n * @remarks\n * This is commonly exists per named state in State Managers.\n */\nexport interface ClientRecord<TValue extends ValidatableValueDirectoryOrState<unknown>> {\n\t// Caution: any particular item may or may not exist\n\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t[AttendeeId: AttendeeId]: TValue;\n}\n\n// type StateDatastoreSchemaNode<\n// \tTValue extends InternalTypes.ValueDirectoryOrState<any> = InternalTypes.ValueDirectoryOrState<unknown>,\n// > = TValue extends InternalTypes.ValueDirectoryOrState<infer T> ? InternalTypes.ValueDirectoryOrState<T> : never;\n\n// export interface StateDatastoreSchema {\n// \t// This type is not precise. It may\n// \t// need to be replaced with StatesWorkspace schema pattern\n// \t// similar to what is commented out.\n// \t[key: string]: InternalTypes.ValueDirectoryOrState<unknown>;\n// \t// [key: string]: StateDatastoreSchemaNode;\n// }\n\n/**\n * Miscellaneous options for local state updates\n */\nexport interface LocalStateUpdateOptions {\n\t/**\n\t * When defined, this is the maximum time in milliseconds that this\n\t * update is allowed to be delayed before it must be sent to service.\n\t * When `undefined`, the callee may determine maximum delay.\n\t */\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * Contract for States Workspace to support State Manager access to\n * datastore and general internal presence knowledge.\n */\nexport interface StateDatastore<\n\tTKey extends string,\n\tTLocalUpdateValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTStoredValue extends\n\t\tValidatableValueDirectoryOrState<unknown> = ValidatableValueStructure<TLocalUpdateValue>,\n> {\n\treadonly presence: Presence;\n\tlocalUpdate(\n\t\tkey: TKey,\n\t\tvalue: TLocalUpdateValue & {\n\t\t\tignoreUnmonitored?: true;\n\t\t},\n\t\toptions: LocalStateUpdateOptions,\n\t): void;\n\tupdate(key: TKey, attendeeId: AttendeeId, value: TStoredValue): void;\n\tknownValues(key: TKey): {\n\t\tself: AttendeeId | undefined;\n\t\tstates: ClientRecord<TStoredValue>;\n\t};\n}\n\n/**\n * Helper to get a handle from a datastore.\n */\nexport function handleFromDatastore<\n\t// Constraining TSchema would be great, but it seems nested types (at least with undefined) cause trouble.\n\t// TSchema as `unknown` still provides some type safety.\n\t// TSchema extends StateDatastoreSchema,\n\tTKey extends string /* & keyof TSchema */,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(\n\tdatastore: StateDatastore<TKey, TValue>,\n): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>> {\n\treturn datastore as unknown as InternalTypes.StateDatastoreHandle<\n\t\tTKey,\n\t\tExclude<TValue, undefined>\n\t>;\n}\n\n/**\n * Helper to get the datastore back from its handle.\n */\nexport function datastoreFromHandle<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue> {\n\treturn handle as unknown as StateDatastore<TKey, TValue>;\n}\n"]}
@@ -0,0 +1,27 @@
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
+ export type PostUpdateAction = () => void;
11
+ /**
12
+ * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)
13
+ *
14
+ * @remarks
15
+ * See uses of `unbrandIVM`.
16
+ */
17
+ export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
18
+ readonly value?: TValueState;
19
+ /**
20
+ * Process an update of `value` for remote attendee.
21
+ * @param attendee - The attendee whose `value` is being updated
22
+ * @param received - The revision number received
23
+ * @param value - The new `value` state
24
+ */
25
+ update(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];
26
+ }
27
+ //# 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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C;;;;;GAKG;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 */\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 */\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"systemWorkspace.d.ts","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAGrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,OAAO,KAAK,EAAY,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;GAKG;AACH,UAAU,oBAAqB,SAAQ,aAAa,CAAC,kBAAkB;IACtE,KAAK,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,iBAAiB,EAAE;QAClB,CAAC,YAAY,EAAE,kBAAkB,GAAG,oBAAoB,CAAC;KACzD,CAAC;CACF;AAmCD;;GAEG;AACH,MAAM,WAAW,eAGhB,SAAQ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AAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,iBAAiB,EAAE;QAClB,CAAC,YAAY,EAAE,kBAAkB,GAAG,oBAAoB,CAAC;KACzD,CAAC;CACF;AAmCD;;GAEG;AACH,MAAM,WAAW,eAGhB,SAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC7C;;;;;OAKG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;IAE5F;;;;OAIG;IACH,wBAAwB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACvE;AAsRD;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,wBAAwB,EACnC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,EAC/D,QAAQ,EAAE,SAAS,GACjB;IACF,SAAS,EAAE,eAAe,CAAC;IAC3B,WAAW,EAAE;QACZ,QAAQ,EAAE,sBAAsB,CAAC;QACjC,MAAM,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAC;KAC5C,CAAC;CACF,CASA"}
@@ -129,8 +129,7 @@ class SystemWorkspaceImpl {
129
129
  }
130
130
  this.staleConnectionTimer.setTimeout(this.resolveStaleConnections.bind(this), 30_000);
131
131
  this.selfAttendee.setConnected();
132
- // TODO: AB#56686: self-Attendee never announced as Connected - Emit this event once there are tests in place
133
- // this.events.emit("attendeeConnected", this.selfAttendee);
132
+ this.events.emit("attendeeConnected", this.selfAttendee);
134
133
  }
135
134
  }
136
135
  resolveStaleConnections() {
@@ -1 +1 @@
1
- {"version":3,"file":"systemWorkspace.js","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAK7D,yDAAsD;AAEtD,+CAA+C;AAE/C,uDAAiD;AAsBj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AC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAED,oEAAoE;QACpE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACD;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACpC,UAAsB,EACtB,SAAmC,EACnC,MAA+D,EAC/D,QAAmB;IAQnB,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnF,OAAO;QACN,SAAS;QACT,WAAW,EAAE;YACZ,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,SAA2D;SACnE;KACD,CAAC;AACH,CAAC;AApBD,sDAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IEmitter, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { PostUpdateAction } from \"./internalTypes.js\";\nimport { revealOpaqueJson } from \"./internalUtils.js\";\nimport type { Attendee, AttendeesEvents, AttendeeId, Presence } from \"./presence.js\";\nimport { AttendeeStatus } from \"./presence.js\";\nimport type { PresenceStatesInternal } from \"./presenceStates.js\";\nimport { TimerManager } from \"./timerManager.js\";\nimport type { AnyWorkspace, StatesWorkspaceSchema } from \"./types.js\";\n\n/**\n * `ConnectionValueState` is known value state for `clientToSessionId` data.\n *\n * @remarks\n * It is {@link InternalTypes.ValueRequiredState} with a known value type.\n */\ninterface ConnectionValueState extends InternalTypes.ValueStateMetadata {\n\tvalue: AttendeeId;\n}\n\n/**\n * The system workspace's datastore structure.\n */\nexport interface SystemWorkspaceDatastore {\n\tclientToSessionId: {\n\t\t[ConnectionId: ClientConnectionId]: ConnectionValueState;\n\t};\n}\n\nclass SessionClient implements Attendee {\n\tprivate connectionStatus: AttendeeStatus = AttendeeStatus.Disconnected;\n\n\tpublic constructor(\n\t\tpublic readonly attendeeId: AttendeeId,\n\t\t/**\n\t\t * Order is used to track the most recent client connection\n\t\t * during a session.\n\t\t */\n\t\tpublic order: number = 0,\n\t\tpublic connectionId: ClientConnectionId | undefined = undefined,\n\t) {}\n\n\tpublic getConnectionId(): ClientConnectionId {\n\t\tif (this.connectionId === undefined) {\n\t\t\tthrow new Error(\"Client has never been connected\");\n\t\t}\n\t\treturn this.connectionId;\n\t}\n\n\tpublic getConnectionStatus(): AttendeeStatus {\n\t\treturn this.connectionStatus;\n\t}\n\n\tpublic setConnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Connected;\n\t}\n\n\tpublic setDisconnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Disconnected;\n\t}\n}\n\n/**\n * Internal workspace that manages metadata for session attendees.\n */\nexport interface SystemWorkspace\n\t// Portion of Presence that is handled by SystemWorkspace along with\n\t// responsibility for emitting \"attendeeConnected\" events.\n\textends Exclude<Presence[\"attendees\"], never> {\n\t/**\n\t * Must be called when the current client acquires a new connection.\n\t *\n\t * @param clientConnectionId - The new client connection ID.\n\t * @param audienceOutOfDate - When true, audience cannot be used as authoritative.\n\t */\n\tonConnectionAdded(clientConnectionId: ClientConnectionId, audienceOutOfDate: boolean): void;\n\n\t/**\n\t * Removes the client connection ID from the system workspace.\n\t *\n\t * @param clientConnectionId - The client connection ID to remove.\n\t */\n\tremoveClientConnectionId(clientConnectionId: ClientConnectionId): void;\n}\n\nclass SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {\n\tprivate readonly selfAttendee: SessionClient;\n\t/**\n\t * `attendees` is this client's understanding of the attendees in the\n\t * session. The map covers entries for both session ids and connection\n\t * ids, which are never expected to collide, but if they did for same\n\t * client that would be fine.\n\t * An entry is for session ID if the value's `attendeeId` matches the key.\n\t */\n\tprivate readonly attendees = new Map<ClientConnectionId | AttendeeId, SessionClient>();\n\n\t// When local client disconnects, we lose the connectivity status updates for remote attendees in the session.\n\t// Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.\n\tprivate readonly staleConnectionClients = new Set<SessionClient>();\n\n\tprivate readonly staleConnectionTimer = new TimerManager();\n\n\tpublic constructor(\n\t\tattendeeId: AttendeeId,\n\t\tprivate readonly datastore: SystemWorkspaceDatastore,\n\t\tpublic readonly events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\t\tprivate readonly audience: IAudience,\n\t) {\n\t\tthis.selfAttendee = new SessionClient(attendeeId);\n\t\tthis.attendees.set(attendeeId, this.selfAttendee);\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\t_content: TSchemaAdditional,\n\t): never {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tpublic processUpdate(\n\t\t_received: number,\n\t\t_timeModifier: number,\n\t\t/**\n\t\t * Remote datastore typed to match {@link PresenceStatesInternal.processUpdate}'s\n\t\t * `ValueUpdateRecord` type that uses {@link InternalTypes.ValueRequiredState}\n\t\t * and expects an Opaque JSON type. (We get away with a non-`unknown` value type\n\t\t * per TypeScript's method parameter bivariance.) Proper type would be\n\t\t * {@link ConnectionValueState} directly.\n\t\t * {@link ClientConnectionId} use for index is also a deviation, but conveniently\n\t\t * the accurate {@link AttendeeId} type is just a branded string, and\n\t\t * {@link ClientConnectionId} is just `string`.\n\t\t */\n\t\tremoteDatastore: {\n\t\t\tclientToSessionId: {\n\t\t\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<\n\t\t\t\t\tConnectionValueState[\"value\"]\n\t\t\t\t>;\n\t\t\t};\n\t\t},\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[] {\n\t\tconst audienceMembers = this.audience.getMembers();\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [clientConnectionId, value] of Object.entries(\n\t\t\trevealOpaqueJson(remoteDatastore.clientToSessionId),\n\t\t)) {\n\t\t\tconst attendeeId = value.value;\n\t\t\tconst { attendee, isJoining } = this.ensureAttendee({\n\t\t\t\tattendeeId,\n\t\t\t\tclientConnectionId,\n\t\t\t\torder: value.rev,\n\t\t\t\tisSender: senderConnectionId === clientConnectionId,\n\t\t\t\tisInAudience: audienceMembers.has(clientConnectionId),\n\t\t\t});\n\t\t\t// If the attendee is joining the session, add them to the list of joining attendees to be announced later.\n\t\t\tif (isJoining) {\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"attendeeConnected\", attendee));\n\t\t\t}\n\n\t\t\tconst knownSessionId = this.datastore.clientToSessionId[clientConnectionId];\n\t\t\tif (knownSessionId === undefined) {\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = value;\n\t\t\t} else {\n\t\t\t\tassert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);\n\t\t\t}\n\t\t}\n\n\t\treturn postUpdateActions;\n\t}\n\n\tpublic onConnectionAdded(\n\t\tclientConnectionId: ClientConnectionId,\n\t\taudienceOutOfDate: boolean,\n\t): void {\n\t\tassert(\n\t\t\tthis.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected,\n\t\t\t0xaad /* Local client should be 'Disconnected' before adding new connection. */,\n\t\t);\n\n\t\tconst selfInAudience = this.audience.getMember(clientConnectionId) !== undefined;\n\t\tassert(\n\t\t\tselfInAudience || audienceOutOfDate,\n\t\t\t0xcc0 /* Local client must be in audience for presence to handle added connection. */,\n\t\t);\n\n\t\tif (!(clientConnectionId in this.datastore.clientToSessionId)) {\n\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = {\n\t\t\t\trev: this.selfAttendee.order++,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tvalue: this.selfAttendee.attendeeId,\n\t\t\t};\n\t\t}\n\n\t\t// Update the self attendee connection information, but not connection\n\t\t// status yet. Connection status is updated once self is in audience -\n\t\t// see later. It is only once our connection is known to audience that\n\t\t// audience can be used to track other attendees' connection statuses\n\t\t// and we seek to present a consistent view locally.\n\t\tthis.selfAttendee.connectionId = clientConnectionId;\n\t\tthis.attendees.set(clientConnectionId, this.selfAttendee);\n\n\t\tif (selfInAudience) {\n\t\t\t// Mark 'Connected' remote attendees connections as stale\n\t\t\t// Performance note: This will visit attendees multiple times as the\n\t\t\t// attendee map has attendeeIds and connectionIds entries that point to\n\t\t\t// the same attendee. But the getConnectionStatus check is cheap and\n\t\t\t// staleConnectionClients.add will handle duplicates.\n\t\t\tthis.staleConnectionClients.clear();\n\t\t\tfor (const staleConnectionClient of this.attendees.values()) {\n\t\t\t\tif (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {\n\t\t\t\t\tthis.staleConnectionClients.add(staleConnectionClient);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.staleConnectionTimer.setTimeout(this.resolveStaleConnections.bind(this), 30_000);\n\n\t\t\tthis.selfAttendee.setConnected();\n\t\t\t// TODO: AB#56686: self-Attendee never announced as Connected - Emit this event once there are tests in place\n\t\t\t// this.events.emit(\"attendeeConnected\", this.selfAttendee);\n\t\t}\n\t}\n\n\tprivate resolveStaleConnections(): void {\n\t\tconst consideredDisconnected = [];\n\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t// Confirm that audience no longer has connection. It is possible\n\t\t\t// but unlikely that no one mentioned the attendee in this period\n\t\t\t// and that they were never disconnected.\n\t\t\tif (this.audience.getMember(client.getConnectionId()) === undefined) {\n\t\t\t\tconsideredDisconnected.push(client);\n\t\t\t\tclient.setDisconnected();\n\t\t\t}\n\t\t}\n\t\tfor (const client of consideredDisconnected) {\n\t\t\tthis.events.emit(\"attendeeDisconnected\", client);\n\t\t}\n\t\tthis.staleConnectionClients.clear();\n\t}\n\n\tpublic removeClientConnectionId(clientConnectionId: ClientConnectionId): void {\n\t\tconst attendee = this.attendees.get(clientConnectionId);\n\t\tif (!attendee) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the local connection is being removed, clear the stale connection timer\n\t\tif (attendee === this.selfAttendee) {\n\t\t\tthis.staleConnectionTimer.clearTimeout();\n\t\t} else {\n\t\t\t// When self is not connected, audience may go through a refresh that\n\t\t\t// removes members and adds them back. Defer any removals until self\n\t\t\t// is connected implying audience is stable.\n\t\t\tif (this.selfAttendee.getConnectionStatus() !== AttendeeStatus.Connected) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,\n\t\t// therefore we should not change the attendee connection status or emit a disconnect event.\n\t\tconst attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;\n\t\tconst connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;\n\t\tif (!attendeeReconnected && connected) {\n\t\t\tattendee.setDisconnected();\n\t\t\tthis.events.emit(\"attendeeDisconnected\", attendee);\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\t}\n\n\tpublic getAttendees(): ReadonlySet<Attendee> {\n\t\treturn new Set(this.attendees.values());\n\t}\n\n\tpublic getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee {\n\t\tconst attendee = this.attendees.get(clientId);\n\t\tif (attendee) {\n\t\t\treturn attendee;\n\t\t}\n\n\t\t// TODO: Restore option to add attendee on demand to handle internal\n\t\t// lookup cases that must come from internal data.\n\t\t// There aren't any resiliency mechanisms in place to handle a missed\n\t\t// ClientJoin right now.\n\t\tthrow new Error(\"Attendee not found\");\n\t}\n\n\tpublic getMyself(): Attendee {\n\t\treturn this.selfAttendee;\n\t}\n\n\t/**\n\t * Make sure the given client session and connection ID pair are represented\n\t * in the attendee map. If not present, SessionClient is created and added\n\t * to map. If present, make sure the current connection ID is updated.\n\t */\n\tprivate ensureAttendee({\n\t\tattendeeId,\n\t\tclientConnectionId,\n\t\torder,\n\t\tisSender,\n\t\tisInAudience,\n\t}: {\n\t\tattendeeId: AttendeeId;\n\t\tclientConnectionId: ClientConnectionId;\n\t\torder: number;\n\t\tisSender: boolean;\n\t\tisInAudience: boolean;\n\t}): { attendee: SessionClient; isJoining: boolean } {\n\t\tlet attendee = this.attendees.get(attendeeId);\n\t\tlet isConnected = false;\n\t\tlet isJoining = false;\n\n\t\tif (attendee === undefined) {\n\t\t\t// New attendee. Create SessionClient and add session ID based\n\t\t\t// entry to map.\n\t\t\tattendee = new SessionClient(attendeeId, order, clientConnectionId);\n\t\t\tthis.attendees.set(attendeeId, attendee);\n\t\t\t// If the attendee update is from the sending remote client itself\n\t\t\t// OR if the attendee is present in audience,\n\t\t\t// then the attendee is considered connected. (Otherwise, leave\n\t\t\t// state as disconnected - default.)\n\t\t\tif (isSender || isInAudience) {\n\t\t\t\tisConnected = true;\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Known attendee is considered connected if\n\t\t\tisConnected =\n\t\t\t\t// this information is at least up to date with current knowledge\n\t\t\t\torder >= attendee.order &&\n\t\t\t\t// AND in the audience OR\n\t\t\t\t(isInAudience ||\n\t\t\t\t\t// not in audience, but client is the sender and has newer\n\t\t\t\t\t// info. (Assume that audience is out of date and attendee\n\t\t\t\t\t// is joining.)\n\t\t\t\t\t(isSender && order > attendee.order));\n\n\t\t\tif (order > attendee.order) {\n\t\t\t\t// The given association is newer than the one we have.\n\t\t\t\t// Update the order and current connection ID.\n\t\t\t\tattendee.order = order;\n\t\t\t\tattendee.connectionId = clientConnectionId;\n\t\t\t}\n\n\t\t\t// Known attendee is joining the session if they are currently disconnected.\n\t\t\tif (isConnected && attendee.getConnectionStatus() === AttendeeStatus.Disconnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t}\n\n\t\tif (isConnected) {\n\t\t\t// If the attendee is connected, remove them from the stale connection set\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\n\t\t// Always update entry for the connection ID. (Okay if already set.)\n\t\tthis.attendees.set(clientConnectionId, attendee);\n\n\t\treturn { attendee, isJoining };\n\t}\n}\n\n/**\n * Instantiates the system workspace.\n */\nexport function createSystemWorkspace(\n\tattendeeId: AttendeeId,\n\tdatastore: SystemWorkspaceDatastore,\n\tevents: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\taudience: IAudience,\n): {\n\tworkspace: SystemWorkspace;\n\tstatesEntry: {\n\t\tinternal: PresenceStatesInternal;\n\t\tpublic: AnyWorkspace<StatesWorkspaceSchema>;\n\t};\n} {\n\tconst workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);\n\treturn {\n\t\tworkspace,\n\t\tstatesEntry: {\n\t\t\tinternal: workspace,\n\t\t\tpublic: undefined as unknown as AnyWorkspace<StatesWorkspaceSchema>,\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"systemWorkspace.js","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA6D;AAI7D,yDAAsD;AAEtD,+CAA+C;AAG/C,uDAAiD;AAsBjD,MAAM,aAAa;IAGlB,YACiB,UAAsB;IACtC;;;OAGG;IACI,QAAgB,CAAC,EACjB,eAA+C,SAAS;QAN/C,eAAU,GAAV,UAAU,CAAY;QAK/B,UAAK,GAAL,KAAK,CAAY;QACjB,iBAAY,GAAZ,YAAY,CAA4C;QATxD,qBAAgB,GAAmB,4BAAc,CAAC,YAAY,CAAC;IAUpE,CAAC;IAEG,eAAe;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,mBAAmB;QACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,gBAAgB,GAAG,4BAAc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D;SACnE;KACD,CAAC;AACH,CAAC;AApBD,sDAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IEmitter, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport { revealOpaqueJson } from \"./internalUtils.js\";\nimport type { Attendee, AttendeesEvents, AttendeeId, Presence } from \"./presence.js\";\nimport { AttendeeStatus } from \"./presence.js\";\nimport type { PresenceStatesInternal } from \"./presenceStates.js\";\nimport type { PostUpdateAction } from \"./statesManagerTypes.js\";\nimport { TimerManager } from \"./timerManager.js\";\nimport type { AnyWorkspace, StatesWorkspaceSchema } from \"./types.js\";\n\n/**\n * `ConnectionValueState` is known value state for `clientToSessionId` data.\n *\n * @remarks\n * It is {@link InternalTypes.ValueRequiredState} with a known value type.\n */\ninterface ConnectionValueState extends InternalTypes.ValueStateMetadata {\n\tvalue: AttendeeId;\n}\n\n/**\n * The system workspace's datastore structure.\n */\nexport interface SystemWorkspaceDatastore {\n\tclientToSessionId: {\n\t\t[ConnectionId: ClientConnectionId]: ConnectionValueState;\n\t};\n}\n\nclass SessionClient implements Attendee {\n\tprivate connectionStatus: AttendeeStatus = AttendeeStatus.Disconnected;\n\n\tpublic constructor(\n\t\tpublic readonly attendeeId: AttendeeId,\n\t\t/**\n\t\t * Order is used to track the most recent client connection\n\t\t * during a session.\n\t\t */\n\t\tpublic order: number = 0,\n\t\tpublic connectionId: ClientConnectionId | undefined = undefined,\n\t) {}\n\n\tpublic getConnectionId(): ClientConnectionId {\n\t\tif (this.connectionId === undefined) {\n\t\t\tthrow new Error(\"Client has never been connected\");\n\t\t}\n\t\treturn this.connectionId;\n\t}\n\n\tpublic getConnectionStatus(): AttendeeStatus {\n\t\treturn this.connectionStatus;\n\t}\n\n\tpublic setConnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Connected;\n\t}\n\n\tpublic setDisconnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Disconnected;\n\t}\n}\n\n/**\n * Internal workspace that manages metadata for session attendees.\n */\nexport interface SystemWorkspace\n\t// Portion of Presence that is handled by SystemWorkspace along with\n\t// responsibility for emitting \"attendeeConnected\" events.\n\textends Exclude<Presence[\"attendees\"], never> {\n\t/**\n\t * Must be called when the current client acquires a new connection.\n\t *\n\t * @param clientConnectionId - The new client connection ID.\n\t * @param audienceOutOfDate - When true, audience cannot be used as authoritative.\n\t */\n\tonConnectionAdded(clientConnectionId: ClientConnectionId, audienceOutOfDate: boolean): void;\n\n\t/**\n\t * Removes the client connection ID from the system workspace.\n\t *\n\t * @param clientConnectionId - The client connection ID to remove.\n\t */\n\tremoveClientConnectionId(clientConnectionId: ClientConnectionId): void;\n}\n\nclass SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {\n\tprivate readonly selfAttendee: SessionClient;\n\t/**\n\t * `attendees` is this client's understanding of the attendees in the\n\t * session. The map covers entries for both session ids and connection\n\t * ids, which are never expected to collide, but if they did for same\n\t * client that would be fine.\n\t * An entry is for session ID if the value's `attendeeId` matches the key.\n\t */\n\tprivate readonly attendees = new Map<ClientConnectionId | AttendeeId, SessionClient>();\n\n\t// When local client disconnects, we lose the connectivity status updates for remote attendees in the session.\n\t// Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.\n\tprivate readonly staleConnectionClients = new Set<SessionClient>();\n\n\tprivate readonly staleConnectionTimer = new TimerManager();\n\n\tpublic constructor(\n\t\tattendeeId: AttendeeId,\n\t\tprivate readonly datastore: SystemWorkspaceDatastore,\n\t\tpublic readonly events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\t\tprivate readonly audience: IAudience,\n\t) {\n\t\tthis.selfAttendee = new SessionClient(attendeeId);\n\t\tthis.attendees.set(attendeeId, this.selfAttendee);\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\t_content: TSchemaAdditional,\n\t): never {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tpublic processUpdate(\n\t\t_received: number,\n\t\t_timeModifier: number,\n\t\t/**\n\t\t * Remote datastore typed to match {@link PresenceStatesInternal.processUpdate}'s\n\t\t * `ValueUpdateRecord` type that uses {@link InternalTypes.ValueRequiredState}\n\t\t * and expects an Opaque JSON type. (We get away with a non-`unknown` value type\n\t\t * per TypeScript's method parameter bivariance.) Proper type would be\n\t\t * {@link ConnectionValueState} directly.\n\t\t * {@link ClientConnectionId} use for index is also a deviation, but conveniently\n\t\t * the accurate {@link AttendeeId} type is just a branded string, and\n\t\t * {@link ClientConnectionId} is just `string`.\n\t\t */\n\t\tremoteDatastore: {\n\t\t\tclientToSessionId: {\n\t\t\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<\n\t\t\t\t\tConnectionValueState[\"value\"]\n\t\t\t\t>;\n\t\t\t};\n\t\t},\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[] {\n\t\tconst audienceMembers = this.audience.getMembers();\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [clientConnectionId, value] of Object.entries(\n\t\t\trevealOpaqueJson(remoteDatastore.clientToSessionId),\n\t\t)) {\n\t\t\tconst attendeeId = value.value;\n\t\t\tconst { attendee, isJoining } = this.ensureAttendee({\n\t\t\t\tattendeeId,\n\t\t\t\tclientConnectionId,\n\t\t\t\torder: value.rev,\n\t\t\t\tisSender: senderConnectionId === clientConnectionId,\n\t\t\t\tisInAudience: audienceMembers.has(clientConnectionId),\n\t\t\t});\n\t\t\t// If the attendee is joining the session, add them to the list of joining attendees to be announced later.\n\t\t\tif (isJoining) {\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"attendeeConnected\", attendee));\n\t\t\t}\n\n\t\t\tconst knownSessionId = this.datastore.clientToSessionId[clientConnectionId];\n\t\t\tif (knownSessionId === undefined) {\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = value;\n\t\t\t} else {\n\t\t\t\tassert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);\n\t\t\t}\n\t\t}\n\n\t\treturn postUpdateActions;\n\t}\n\n\tpublic onConnectionAdded(\n\t\tclientConnectionId: ClientConnectionId,\n\t\taudienceOutOfDate: boolean,\n\t): void {\n\t\tassert(\n\t\t\tthis.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected,\n\t\t\t0xaad /* Local client should be 'Disconnected' before adding new connection. */,\n\t\t);\n\n\t\tconst selfInAudience = this.audience.getMember(clientConnectionId) !== undefined;\n\t\tassert(\n\t\t\tselfInAudience || audienceOutOfDate,\n\t\t\t0xcc0 /* Local client must be in audience for presence to handle added connection. */,\n\t\t);\n\n\t\tif (!(clientConnectionId in this.datastore.clientToSessionId)) {\n\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = {\n\t\t\t\trev: this.selfAttendee.order++,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t\tvalue: this.selfAttendee.attendeeId,\n\t\t\t};\n\t\t}\n\n\t\t// Update the self attendee connection information, but not connection\n\t\t// status yet. Connection status is updated once self is in audience -\n\t\t// see later. It is only once our connection is known to audience that\n\t\t// audience can be used to track other attendees' connection statuses\n\t\t// and we seek to present a consistent view locally.\n\t\tthis.selfAttendee.connectionId = clientConnectionId;\n\t\tthis.attendees.set(clientConnectionId, this.selfAttendee);\n\n\t\tif (selfInAudience) {\n\t\t\t// Mark 'Connected' remote attendees connections as stale\n\t\t\t// Performance note: This will visit attendees multiple times as the\n\t\t\t// attendee map has attendeeIds and connectionIds entries that point to\n\t\t\t// the same attendee. But the getConnectionStatus check is cheap and\n\t\t\t// staleConnectionClients.add will handle duplicates.\n\t\t\tthis.staleConnectionClients.clear();\n\t\t\tfor (const staleConnectionClient of this.attendees.values()) {\n\t\t\t\tif (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {\n\t\t\t\t\tthis.staleConnectionClients.add(staleConnectionClient);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.staleConnectionTimer.setTimeout(this.resolveStaleConnections.bind(this), 30_000);\n\n\t\t\tthis.selfAttendee.setConnected();\n\t\t\tthis.events.emit(\"attendeeConnected\", this.selfAttendee);\n\t\t}\n\t}\n\n\tprivate resolveStaleConnections(): void {\n\t\tconst consideredDisconnected = [];\n\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t// Confirm that audience no longer has connection. It is possible\n\t\t\t// but unlikely that no one mentioned the attendee in this period\n\t\t\t// and that they were never disconnected.\n\t\t\tif (this.audience.getMember(client.getConnectionId()) === undefined) {\n\t\t\t\tconsideredDisconnected.push(client);\n\t\t\t\tclient.setDisconnected();\n\t\t\t}\n\t\t}\n\t\tfor (const client of consideredDisconnected) {\n\t\t\tthis.events.emit(\"attendeeDisconnected\", client);\n\t\t}\n\t\tthis.staleConnectionClients.clear();\n\t}\n\n\tpublic removeClientConnectionId(clientConnectionId: ClientConnectionId): void {\n\t\tconst attendee = this.attendees.get(clientConnectionId);\n\t\tif (!attendee) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the local connection is being removed, clear the stale connection timer\n\t\tif (attendee === this.selfAttendee) {\n\t\t\tthis.staleConnectionTimer.clearTimeout();\n\t\t} else {\n\t\t\t// When self is not connected, audience may go through a refresh that\n\t\t\t// removes members and adds them back. Defer any removals until self\n\t\t\t// is connected implying audience is stable.\n\t\t\tif (this.selfAttendee.getConnectionStatus() !== AttendeeStatus.Connected) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,\n\t\t// therefore we should not change the attendee connection status or emit a disconnect event.\n\t\tconst attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;\n\t\tconst connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;\n\t\tif (!attendeeReconnected && connected) {\n\t\t\tattendee.setDisconnected();\n\t\t\tthis.events.emit(\"attendeeDisconnected\", attendee);\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\t}\n\n\tpublic getAttendees(): ReadonlySet<Attendee> {\n\t\treturn new Set(this.attendees.values());\n\t}\n\n\tpublic getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee {\n\t\tconst attendee = this.attendees.get(clientId);\n\t\tif (attendee) {\n\t\t\treturn attendee;\n\t\t}\n\n\t\t// TODO: Restore option to add attendee on demand to handle internal\n\t\t// lookup cases that must come from internal data.\n\t\t// There aren't any resiliency mechanisms in place to handle a missed\n\t\t// ClientJoin right now.\n\t\tthrow new Error(\"Attendee not found\");\n\t}\n\n\tpublic getMyself(): Attendee {\n\t\treturn this.selfAttendee;\n\t}\n\n\t/**\n\t * Make sure the given client session and connection ID pair are represented\n\t * in the attendee map. If not present, SessionClient is created and added\n\t * to map. If present, make sure the current connection ID is updated.\n\t */\n\tprivate ensureAttendee({\n\t\tattendeeId,\n\t\tclientConnectionId,\n\t\torder,\n\t\tisSender,\n\t\tisInAudience,\n\t}: {\n\t\tattendeeId: AttendeeId;\n\t\tclientConnectionId: ClientConnectionId;\n\t\torder: number;\n\t\tisSender: boolean;\n\t\tisInAudience: boolean;\n\t}): { attendee: SessionClient; isJoining: boolean } {\n\t\tlet attendee = this.attendees.get(attendeeId);\n\t\tlet isConnected = false;\n\t\tlet isJoining = false;\n\n\t\tif (attendee === undefined) {\n\t\t\t// New attendee. Create SessionClient and add session ID based\n\t\t\t// entry to map.\n\t\t\tattendee = new SessionClient(attendeeId, order, clientConnectionId);\n\t\t\tthis.attendees.set(attendeeId, attendee);\n\t\t\t// If the attendee update is from the sending remote client itself\n\t\t\t// OR if the attendee is present in audience,\n\t\t\t// then the attendee is considered connected. (Otherwise, leave\n\t\t\t// state as disconnected - default.)\n\t\t\tif (isSender || isInAudience) {\n\t\t\t\tisConnected = true;\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t} else {\n\t\t\t// Known attendee is considered connected if\n\t\t\tisConnected =\n\t\t\t\t// this information is at least up to date with current knowledge\n\t\t\t\torder >= attendee.order &&\n\t\t\t\t// AND in the audience OR\n\t\t\t\t(isInAudience ||\n\t\t\t\t\t// not in audience, but client is the sender and has newer\n\t\t\t\t\t// info. (Assume that audience is out of date and attendee\n\t\t\t\t\t// is joining.)\n\t\t\t\t\t(isSender && order > attendee.order));\n\n\t\t\tif (order > attendee.order) {\n\t\t\t\t// The given association is newer than the one we have.\n\t\t\t\t// Update the order and current connection ID.\n\t\t\t\tattendee.order = order;\n\t\t\t\tattendee.connectionId = clientConnectionId;\n\t\t\t}\n\n\t\t\t// Known attendee is joining the session if they are currently disconnected.\n\t\t\tif (isConnected && attendee.getConnectionStatus() === AttendeeStatus.Disconnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t}\n\n\t\tif (isConnected) {\n\t\t\t// If the attendee is connected, remove them from the stale connection set\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\n\t\t// Always update entry for the connection ID. (Okay if already set.)\n\t\tthis.attendees.set(clientConnectionId, attendee);\n\n\t\treturn { attendee, isJoining };\n\t}\n}\n\n/**\n * Instantiates the system workspace.\n */\nexport function createSystemWorkspace(\n\tattendeeId: AttendeeId,\n\tdatastore: SystemWorkspaceDatastore,\n\tevents: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\taudience: IAudience,\n): {\n\tworkspace: SystemWorkspace;\n\tstatesEntry: {\n\t\tinternal: PresenceStatesInternal;\n\t\tpublic: AnyWorkspace<StatesWorkspaceSchema>;\n\t};\n} {\n\tconst workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);\n\treturn {\n\t\tworkspace,\n\t\tstatesEntry: {\n\t\t\tinternal: workspace,\n\t\t\tpublic: undefined as unknown as AnyWorkspace<StatesWorkspaceSchema>,\n\t\t},\n\t};\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { BroadcastControls } from "./broadcastControls.js";
5
+ import type { BroadcastControls } from "./broadcastControlsTypes.js";
6
6
  import type { InternalTypes } from "./exposedInternalTypes.js";
7
- import type { NotificationsManager } from "./notificationsManager.js";
7
+ import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
8
+ import type { NotificationsManager } from "./notificationsManagerTypes.js";
8
9
  import type { Presence, PresenceWithNotifications } from "./presence.js";
9
10
  /**
10
11
  * Unique address within a session.
@@ -40,7 +41,7 @@ export interface StatesWorkspaceSchema {
40
41
  /**
41
42
  * Key-value pairs of State objects registered with the {@link StatesWorkspace}.
42
43
  */
43
- [key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;
44
+ [key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<unknown>>;
44
45
  }
45
46
  /**
46
47
  * Map of State objects registered with {@link StatesWorkspace}.
@@ -70,7 +71,7 @@ export interface StatesWorkspace<TSchema extends StatesWorkspaceSchema, TManager
70
71
  * @param key - new unique key for the State object within the workspace
71
72
  * @param manager - factory for creating a State object
72
73
  */
73
- add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>, TManager extends TManagerConstraints>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is StatesWorkspace<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>, TManagerConstraints>;
74
+ add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>, TManager extends TManagerConstraints>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is StatesWorkspace<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>, TManagerConstraints>;
74
75
  /**
75
76
  * Registry of State objects.
76
77
  */
@@ -92,7 +93,7 @@ export interface StatesWorkspace<TSchema extends StatesWorkspaceSchema, TManager
92
93
  * @alpha
93
94
  */
94
95
  export interface NotificationsWorkspaceSchema {
95
- [key: string]: InternalTypes.ManagerFactory<typeof key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<any>>;
96
+ [key: string]: InternalTypes.ManagerFactory<typeof key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<InternalUtilityTypes.NotificationListeners<unknown>>>;
96
97
  }
97
98
  /**
98
99
  * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s
@@ -113,7 +114,7 @@ export interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSc
113
114
  * @param key - new unique key for the `NotificationsManager` within the workspace
114
115
  * @param manager - factory for creating a `NotificationsManager`
115
116
  */
116
- add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>, TManager extends NotificationsManager<any>>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is NotificationsWorkspace<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>>;
117
+ add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>, TManager extends NotificationsManager<InternalUtilityTypes.NotificationListeners<unknown>>>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is NotificationsWorkspace<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>>;
117
118
  /**
118
119
  * Registry of `NotificationsManager`s.
119
120
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK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,MAAM,EACnB,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAC3D,QAAQ,SAAS,oBAAoB,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAE1F,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3D,OAAO,CAAC,IAAI,IAAI,sBAAsB,CACxC,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAC5E,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;CAC7C;AAID;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,OAAO,SAAS,qBAAqB,EACrC,mBAAmB,GAAG,OAAO,CAC5B,SAAQ,eAAe,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAExD,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;CAC7C"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.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 { BroadcastControls } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { NotificationsManager } from \"./notificationsManager.js\";\nimport type { Presence, PresenceWithNotifications } from \"./presence.js\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @beta\n */\nexport type WorkspaceAddress = `${string}:${string}`;\n\n/**\n * Single entry in {@link StatesWorkspaceSchema} or {@link NotificationsWorkspaceSchema}.\n *\n * @beta\n */\nexport type StatesWorkspaceEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n// #region StatesWorkspace\n\n/**\n * Schema for a {@link StatesWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link StatesWorkspace} providing access to State objects.\n *\n * @beta\n */\nexport interface StatesWorkspaceSchema {\n\t/**\n\t * Key-value pairs of State objects registered with the {@link StatesWorkspace}.\n\t */\n\t[key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;\n}\n\n/**\n * Map of State objects registered with {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type StatesWorkspaceEntries<TSchema extends StatesWorkspaceSchema> = {\n\t/**\n\t * Registered State objects.\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `StatesWorkspace` maintains a registry of State objects that all share and provide access to\n * presence state values across client members in a session.\n *\n * State objects offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @beta\n */\nexport interface StatesWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new State object with the {@link StatesWorkspace}.\n\t * @param key - new unique key for the State object within the workspace\n\t * @param manager - factory for creating a State object\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is StatesWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of State objects.\n\t */\n\treadonly states: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Default controls for management of broadcast updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n}\n\n// #endregion StatesWorkspace\n\n// #region NotificationsWorkspace\n\n/**\n * Schema for a {@link NotificationsWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link NotificationsWorkspace} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface NotificationsWorkspaceSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<any>\n\t>;\n}\n\n/**\n * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @privateRemarks\n * This should be kept mostly in sync with {@link StatesWorkspace}. Notably the\n * return type of `add` is limited here and the `controls` property is omitted.\n * The `PresenceStatesImpl` class implements `AnyWorkspace` and therefore\n * `NotificationsWorkspace`, so long as this is proper subset.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSchema> {\n\t/**\n\t * Registers a new `NotificationsManager` with the {@link NotificationsWorkspace}.\n\t * @param key - new unique key for the `NotificationsManager` within the workspace\n\t * @param manager - factory for creating a `NotificationsManager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends NotificationsManager<any>,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is NotificationsWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>\n\t>;\n\n\t/**\n\t * Registry of `NotificationsManager`s.\n\t */\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Containing {@link PresenceWithNotifications}\n\t */\n\treadonly presence: PresenceWithNotifications;\n}\n\n// #endregion NotificationsWorkspace\n\n/**\n * `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}.\n */\nexport interface AnyWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> extends StatesWorkspace<TSchema, TManagerConstraints> {\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\t// TO be removed if/when notifications are fully supported\n\treadonly presence: PresenceWithNotifications;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.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 { BroadcastControls } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { NotificationsManager } from \"./notificationsManagerTypes.js\";\nimport type { Presence, PresenceWithNotifications } from \"./presence.js\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @beta\n */\nexport type WorkspaceAddress = `${string}:${string}`;\n\n/**\n * Single entry in {@link StatesWorkspaceSchema} or {@link NotificationsWorkspaceSchema}.\n *\n * @beta\n */\nexport type StatesWorkspaceEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n// #region StatesWorkspace\n\n/**\n * Schema for a {@link StatesWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link StatesWorkspace} providing access to State objects.\n *\n * @beta\n */\nexport interface StatesWorkspaceSchema {\n\t/**\n\t * Key-value pairs of State objects registered with the {@link StatesWorkspace}.\n\t */\n\t[key: string]: StatesWorkspaceEntry<\n\t\ttypeof key,\n\t\tInternalTypes.ValueDirectoryOrState<unknown>\n\t>;\n}\n\n/**\n * Map of State objects registered with {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type StatesWorkspaceEntries<TSchema extends StatesWorkspaceSchema> = {\n\t/**\n\t * Registered State objects.\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `StatesWorkspace` maintains a registry of State objects that all share and provide access to\n * presence state values across client members in a session.\n *\n * State objects offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @beta\n */\nexport interface StatesWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new State object with the {@link StatesWorkspace}.\n\t * @param key - new unique key for the State object within the workspace\n\t * @param manager - factory for creating a State object\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is StatesWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of State objects.\n\t */\n\treadonly states: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Default controls for management of broadcast updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n}\n\n// #endregion StatesWorkspace\n\n// #region NotificationsWorkspace\n\n/**\n * Schema for a {@link NotificationsWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link NotificationsWorkspace} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface NotificationsWorkspaceSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<InternalUtilityTypes.NotificationListeners<unknown>>\n\t>;\n}\n\n/**\n * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @privateRemarks\n * This should be kept mostly in sync with {@link StatesWorkspace}. Notably the\n * return type of `add` is limited here and the `controls` property is omitted.\n * The `PresenceStatesImpl` class implements `AnyWorkspace` and therefore\n * `NotificationsWorkspace`, so long as this is proper subset.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSchema> {\n\t/**\n\t * Registers a new `NotificationsManager` with the {@link NotificationsWorkspace}.\n\t * @param key - new unique key for the `NotificationsManager` within the workspace\n\t * @param manager - factory for creating a `NotificationsManager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\t\tTManager extends NotificationsManager<InternalUtilityTypes.NotificationListeners<unknown>>,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is NotificationsWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>\n\t>;\n\n\t/**\n\t * Registry of `NotificationsManager`s.\n\t */\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Containing {@link PresenceWithNotifications}\n\t */\n\treadonly presence: PresenceWithNotifications;\n}\n\n// #endregion NotificationsWorkspace\n\n/**\n * `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}.\n */\nexport interface AnyWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> extends StatesWorkspace<TSchema, TManagerConstraints> {\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\t// TO be removed if/when notifications are fully supported\n\treadonly presence: PresenceWithNotifications;\n}\n"]}
@@ -2,66 +2,8 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { ExtensionHost as ContainerExtensionHost } from "@fluidframework/container-runtime-definitions/internal";
6
5
  import type { InternalUtilityTypes, OpaqueJsonDeserialized } from "@fluidframework/core-interfaces/internal";
7
6
  import type { InternalTypes } from "./exposedInternalTypes.js";
8
- import type { AttendeeId, Attendee } from "./presence.js";
9
- import type { OutboundAcknowledgementMessage, OutboundClientJoinMessage, OutboundDatastoreUpdateMessage, SignalMessages } from "./protocol.js";
10
- /**
11
- * Presence {@link ContainerExtension} version of {@link @fluidframework/container-runtime-definitions#ExtensionRuntimeProperties}
12
- */
13
- export interface ExtensionRuntimeProperties {
14
- SignalMessages: SignalMessages;
15
- }
16
- /**
17
- * Presence specific ExtensionHost
18
- */
19
- export type ExtensionHost = ContainerExtensionHost<ExtensionRuntimeProperties>;
20
- /**
21
- * Basic structure of set of {@link Attendee} records within Presence datastore
22
- *
23
- * @remarks
24
- * This is commonly exists per named state in State Managers.
25
- */
26
- export interface ClientRecord<TValue extends ValidatableValueDirectoryOrState<unknown>> {
27
- [AttendeeId: AttendeeId]: TValue;
28
- }
29
- /**
30
- * This interface is a subset of ExtensionHost (and mostly of
31
- * FluidDataStoreRuntime) that is needed by the Presence States.
32
- *
33
- * @privateRemarks
34
- * Replace with non-DataStore based interface.
35
- */
36
- export type IEphemeralRuntime = Omit<ExtensionHost, "logger" | "submitAddressedSignal"> & Partial<Pick<ExtensionHost, "logger">> & {
37
- /**
38
- * Submits the signal to be sent to other clients.
39
- * @param type - Type of the signal.
40
- * @param content - Content of the signal. Should be a JSON serializable object or primitive.
41
- * @param targetClientId - When specified, the signal is only sent to the provided client id.
42
- */
43
- submitSignal: (message: OutboundAcknowledgementMessage | OutboundClientJoinMessage | OutboundDatastoreUpdateMessage) => void;
44
- };
45
- /**
46
- * Contract for State Managers as used by a States Workspace (`PresenceStatesImpl`)
47
- *
48
- * @remarks
49
- * See uses of `unbrandIVM`.
50
- */
51
- export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
52
- readonly value?: TValueState;
53
- /**
54
- * Process an update of `value` for remote attendee.
55
- * @param attendee - The attendee whose `value` is being updated
56
- * @param received - The revision number received
57
- * @param value - The new `value` state
58
- */
59
- update(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];
60
- }
61
- /**
62
- * A function to be called at the end of an update frame
63
- */
64
- export type PostUpdateAction = () => void;
65
7
  /**
66
8
  * Metadata for a value that may have been validated by a {@link StateSchemaValidator} function.
67
9
  */
@@ -124,4 +66,4 @@ export type ValidatableValueStructure<T extends InternalTypes.ValueDirectory<unk
124
66
  };
125
67
  }>> : T extends InternalTypes.ValueRequiredState<infer TValue> | InternalTypes.ValueOptionalState<infer TValue> ? InternalUtilityTypes.FlattenIntersection<Omit<T, keyof ValidatableMetadata<TValue>> & ValidatableMetadata<TValue>> : never;
126
68
  export {};
127
- //# sourceMappingURL=internalTypes.d.ts.map
69
+ //# sourceMappingURL=validatableTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatableTypes.d.ts","sourceRoot":"","sources":["../src/validatableTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,oBAAoB,EAC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M,MAAM,CAAC,GACrD,oBAAoB,CAAC,UAAU,CAC/B,CAAC,EACD,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,EAE/B,yBAAyB,CAAC,MAAM,CAAC,EAEjC,oBAAoB,CAAC,mBAAmB,CACvC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAClB,KAAK,EAAE;SACL,MAAM,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,yBAAyB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;KAC3E,CAAC;CACF,CACD,CACD,GACA,CAAC,SACE,aAAa,CAAC,kBAAkB,CAAC,MAAM,MAAM,CAAC,GAC9C,aAAa,CAAC,kBAAkB,CAAC,MAAM,MAAM,CAAC,GAChD,oBAAoB,CAAC,mBAAmB,CACxC,IAAI,CAAC,CAAC,EAAE,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,CACxE,GACA,KAAK,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=validatableTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatableTypes.js","sourceRoot":"","sources":["../src/validatableTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tInternalUtilityTypes,\n\tOpaqueJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\n\n/**\n * Metadata for a value that may have been validated by a {@link StateSchemaValidator} function.\n */\ninterface ValidatableMetadata<TValue> {\n\t/**\n\t * Contains a validated value or undefined if `value` is invalid.\n\t *\n\t * This property will not be present if the data has not been validated.\n\t * If it is present and `undefined`, the value has been checked and found to be invalid.\n\t * Otherwise it will be the validated value.\n\t */\n\tvalidatedValue?: OpaqueJsonDeserialized<TValue> | undefined;\n\t// typeCheck: \"do you have me?\";\n}\n\n/**\n * Represents data with optional value that may have been validated by a\n * {@link StateSchemaValidator} function.\n */\nexport interface ValidatableOptionalState<TValue>\n\textends Omit<InternalTypes.ValueOptionalState<TValue>, keyof ValidatableMetadata<TValue>>,\n\t\tValidatableMetadata<TValue> {}\n\n/**\n * Represents data with required value that may have been validated by a\n * {@link StateSchemaValidator} function.\n */\nexport interface ValidatableRequiredState<TValue>\n\textends Omit<InternalTypes.ValueRequiredState<TValue>, keyof ValidatableMetadata<TValue>>,\n\t\tValidatableMetadata<TValue> {}\n\n/**\n * A directory of validatable values, where each value may be an optional\n * state or another directory.\n *\n * @remarks\n * The is the validatable version of {@link InternalTypes.ValueDirectory}.\n */\nexport interface ValidatableValueDirectory<T> {\n\trev: number;\n\titems: {\n\t\t// Caution: any particular item may or may not exist\n\t\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t\t[name: string | number]: ValidatableOptionalState<T> | ValidatableValueDirectory<T>;\n\t};\n}\n\n/**\n * Convenience type for a validatable required state or a directory of values.\n *\n * @remarks\n * This is the validatable version of {@link InternalTypes.ValueDirectoryOrState}.\n */\nexport type ValidatableValueDirectoryOrState<T> =\n\t| ValidatableRequiredState<T>\n\t| ValidatableValueDirectory<T>;\n\n/**\n * Transforms basic value datastore / protocol type into equivalent type\n * with validation support.\n *\n * @remarks\n * Use when some more specific or parameterized type equivalent of\n * `InternalTypes.Value(Directory|RequiredState|OptionalState)` is needed.\n *\n * Basically, wherever a `*ValueState` appears it is extended with\n * {@link ValidatableMetadata} to support validation.\n */\nexport type ValidatableValueStructure<\n\tT extends\n\t\t| InternalTypes.ValueDirectory<unknown>\n\t\t| InternalTypes.ValueRequiredState<unknown>\n\t\t| InternalTypes.ValueOptionalState<unknown>,\n> = T extends InternalTypes.ValueDirectory<infer TValue>\n\t? InternalUtilityTypes.IfSameType<\n\t\t\tT,\n\t\t\tInternalTypes.ValueDirectory<T>,\n\t\t\t// Use canonical type for exact match\n\t\t\tValidatableValueDirectory<TValue>,\n\t\t\t// Inexact match => recurse\n\t\t\tInternalUtilityTypes.FlattenIntersection<\n\t\t\t\tOmit<T, \"items\"> & {\n\t\t\t\t\titems: {\n\t\t\t\t\t\t[KItems in keyof T[\"items\"]]: ValidatableValueStructure<T[\"items\"][KItems]>;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t>\n\t\t>\n\t: T extends\n\t\t\t\t| InternalTypes.ValueRequiredState<infer TValue>\n\t\t\t\t| InternalTypes.ValueOptionalState<infer TValue>\n\t\t? InternalUtilityTypes.FlattenIntersection<\n\t\t\t\tOmit<T, keyof ValidatableMetadata<TValue>> & ValidatableMetadata<TValue>\n\t\t\t>\n\t\t: never;\n"]}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import type { InternalTypes } from "./exposedInternalTypes.js";
6
- import type { ValueManager } from "./internalTypes.js";
6
+ import type { ValueManager } from "./statesManagerTypes.js";
7
7
  /**
8
8
  * Given a value manager, return opaque InternalTypes.StateValue.
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"valueManager.d.ts","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,QAAQ,CACvB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAE/D,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,GAC5D,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAE7C;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAC9D,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAEzF"}
1
+ {"version":3,"file":"valueManager.d.ts","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,QAAQ,CACvB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAE/D,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,GAC5D,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAE7C;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAC9D,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAEzF"}
@@ -1 +1 @@
1
- {"version":3,"file":"valueManager.js","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;GAEG;AACH,SAAgB,QAAQ,CAKvB,OAA8D;IAE9D,OAAO,OAA2E,CAAC;AACpF,CAAC;AARD,4BAQC;AAED;;GAEG;AACH,SAAgB,UAAU,CAIxB,OAAoD;IACrD,OAAO,OAAuD,CAAC;AAChE,CAAC;AAND,gCAMC","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 { ValueManager } from \"./internalTypes.js\";\n\n/**\n * Given a value manager, return opaque InternalTypes.StateValue.\n */\nexport function brandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(\n\tmanager: TManagerInterface & ValueManager<TValue, TValueState>,\n): InternalTypes.StateValue<TManagerInterface> {\n\treturn manager as TManagerInterface as InternalTypes.StateValue<TManagerInterface>;\n}\n\n/**\n * Extract the value manager from an opaque InternalTypes.StateValue.\n */\nexport function unbrandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(branded: InternalTypes.StateValue<TManagerInterface>): ValueManager<TValue, TValueState> {\n\treturn branded as unknown as ValueManager<TValue, TValueState>;\n}\n"]}
1
+ {"version":3,"file":"valueManager.js","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;GAEG;AACH,SAAgB,QAAQ,CAKvB,OAA8D;IAE9D,OAAO,OAA2E,CAAC;AACpF,CAAC;AARD,4BAQC;AAED;;GAEG;AACH,SAAgB,UAAU,CAIxB,OAAoD;IACrD,OAAO,OAAuD,CAAC;AAChE,CAAC;AAND,gCAMC","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 { ValueManager } from \"./statesManagerTypes.js\";\n\n/**\n * Given a value manager, return opaque InternalTypes.StateValue.\n */\nexport function brandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(\n\tmanager: TManagerInterface & ValueManager<TValue, TValueState>,\n): InternalTypes.StateValue<TManagerInterface> {\n\treturn manager as TManagerInterface as InternalTypes.StateValue<TManagerInterface>;\n}\n\n/**\n * Extract the value manager from an opaque InternalTypes.StateValue.\n */\nexport function unbrandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(branded: InternalTypes.StateValue<TManagerInterface>): ValueManager<TValue, TValueState> {\n\treturn branded as unknown as ValueManager<TValue, TValueState>;\n}\n"]}
@@ -2,39 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- /**
6
- * Common controls for States objects.
7
- *
8
- * @sealed
9
- * @beta
10
- */
11
- export interface BroadcastControls {
12
- /**
13
- * Maximum time in milliseconds that a local value update is allowed
14
- * to remain pending before it must be broadcast.
15
- *
16
- * @remarks
17
- * There is no guarantee of broadcast within time allowed
18
- * as other conditions such as disconnect or service throttling may
19
- * cause a delay.
20
- *
21
- * Setting to `undefined` will restore to a system default.
22
- */
23
- allowableUpdateLatencyMs: number | undefined;
24
- }
25
- /**
26
- * Value set to configure {@link BroadcastControls}.
27
- *
28
- * @beta
29
- */
30
- export interface BroadcastControlSettings {
31
- /**
32
- * {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}
33
- *
34
- * @defaultValue 60 [milliseconds]
35
- */
36
- readonly allowableUpdateLatencyMs?: number;
37
- }
5
+ import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControlsTypes.js";
38
6
  declare class ForcedRefreshControl implements Pick<BroadcastControls & {
39
7
  forcedRefreshIntervalMs: number | undefined;
40
8
  }, "forcedRefreshIntervalMs"> {
@@ -1 +1 @@
1
- {"version":3,"file":"broadcastControls.d.ts","sourceRoot":"","sources":["../src/broadcastControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;;;;;;;;OAUG;IACH,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC;CAc7C;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;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,GAAG,QAAQ,EAAE,wBAAwB,CAAC;IACpE,CAAC;CACD;AAED;;;;;;GAMG;AACH,MAAM,OAAO,wBACZ,SAAQ,oBAAoB;IAK5B,YAAoC,+BAAuC;QAC1E,KAAK,EAAE,CAAC;QAD2B,oCAA+B,GAA/B,+BAA+B,CAAQ;QAE1E,IAAI,CAAC,yBAAyB,GAAG,+BAA+B,CAAC;IAClE,CAAC;IAED,IAAW,wBAAwB;QAClC,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACvC,CAAC;IACD,IAAW,wBAAwB,CAAC,KAAyB;QAC5D,IAAI,CAAC,yBAAyB,GAAG,KAAK,IAAI,IAAI,CAAC,+BAA+B,CAAC;IAChF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Common controls for States objects.\n *\n * @sealed\n * @beta\n */\nexport interface BroadcastControls {\n\t/**\n\t * Maximum time in milliseconds that a local value update is allowed\n\t * to remain pending before it must be broadcast.\n\t *\n\t * @remarks\n\t * There is no guarantee of broadcast within time allowed\n\t * as other conditions such as disconnect or service throttling may\n\t * cause a delay.\n\t *\n\t * Setting to `undefined` will restore to a system default.\n\t */\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Target time in milliseconds between oldest changed local state\n\t * has been broadcast and forced rebroadcast of all local values.\n\t * A value of less than 10 disables forced refresh.\n\t *\n\t * @privateRemarks\n\t * Any time less than 10 milliseconds is likely to generate too\n\t * many signals. Ideally this feature becomes obsolete as\n\t * we understand the system better and account for holes.\n\t */\n\t// forcedRefreshIntervalMs is removed until it is supported.\n\t// forcedRefreshIntervalMs: number | undefined;\n}\n\n/**\n * Value set to configure {@link BroadcastControls}.\n *\n * @beta\n */\nexport interface BroadcastControlSettings {\n\t/**\n\t * {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}\n\t *\n\t * @defaultValue 60 [milliseconds]\n\t */\n\treadonly allowableUpdateLatencyMs?: number;\n\n\t/**\n\t * {@inheritdoc BroadcastControls.forcedRefreshIntervalMs}\n\t *\n\t * @defaultValue 0 (disabled)\n\t */\n\t// forcedRefreshIntervalMs is removed until it is supported.\n\t// readonly forcedRefreshIntervalMs?: number;\n}\n\nclass ForcedRefreshControl\n\timplements\n\t\tPick<\n\t\t\tBroadcastControls & { forcedRefreshIntervalMs: number | undefined },\n\t\t\t\"forcedRefreshIntervalMs\"\n\t\t>\n{\n\tprivate _forcedRefreshInterval: number | undefined;\n\n\tpublic constructor(settings?: BroadcastControlSettings) {\n\t\t// this._forcedRefreshInterval = settings?.forcedRefreshIntervalMs;\n\t}\n\n\tpublic get forcedRefreshIntervalMs(): number | undefined {\n\t\treturn this._forcedRefreshInterval;\n\t}\n\tpublic set forcedRefreshIntervalMs(value: number | undefined) {\n\t\tif (value === undefined) {\n\t\t\tthis._forcedRefreshInterval = undefined;\n\t\t} else {\n\t\t\tthis._forcedRefreshInterval = value >= 10 ? value : undefined;\n\t\t\tif (value >= 10) {\n\t\t\t\t// TODO: enable periodic forced refresh\n\t\t\t\tthrow new Error(\"Forced Refresh feature is not implemented\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implements {@link BroadcastControls} for States Managers\n * where returning `undefined` settings are allowed.\n */\nexport class OptionalBroadcastControl\n\textends ForcedRefreshControl\n\timplements BroadcastControls\n{\n\tpublic allowableUpdateLatencyMs: number | undefined;\n\n\tpublic constructor(settings?: BroadcastControlSettings) {\n\t\tsuper(settings);\n\t\tthis.allowableUpdateLatencyMs = settings?.allowableUpdateLatencyMs;\n\t}\n}\n\n/**\n * Implements {@link BroadcastControls} but always provides defined value for\n * {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}.\n *\n * If {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}\n * is set to `undefined`, the default will be restored.\n */\nexport class RequiredBroadcastControl\n\textends ForcedRefreshControl\n\timplements BroadcastControls\n{\n\tprivate _allowableUpdateLatencyMs: number;\n\n\tpublic constructor(private readonly defaultAllowableUpdateLatencyMs: number) {\n\t\tsuper();\n\t\tthis._allowableUpdateLatencyMs = defaultAllowableUpdateLatencyMs;\n\t}\n\n\tpublic get allowableUpdateLatencyMs(): number {\n\t\treturn this._allowableUpdateLatencyMs;\n\t}\n\tpublic set allowableUpdateLatencyMs(value: number | undefined) {\n\t\tthis._allowableUpdateLatencyMs = value ?? this.defaultAllowableUpdateLatencyMs;\n\t}\n}\n"]}
1
+ {"version":3,"file":"broadcastControls.js","sourceRoot":"","sources":["../src/broadcastControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,oBAAoB;IASzB,YAAmB,QAAmC;QACrD,mEAAmE;IACpE,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACpC,CAAC;IACD,IAAW,uBAAuB,CAAC,KAAyB;QAC3D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;QACzC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,sBAAsB,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAC9D,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;gBACjB,uCAAuC;gBACvC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC9D,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,wBACZ,SAAQ,oBAAoB;IAK5B,YAAmB,QAAmC;QACrD,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,wBAAwB,GAAG,QAAQ,EAAE,wBAAwB,CAAC;IACpE,CAAC;CACD;AAED;;;;;;GAMG;AACH,MAAM,OAAO,wBACZ,SAAQ,oBAAoB;IAK5B,YAAoC,+BAAuC;QAC1E,KAAK,EAAE,CAAC;QAD2B,oCAA+B,GAA/B,+BAA+B,CAAQ;QAE1E,IAAI,CAAC,yBAAyB,GAAG,+BAA+B,CAAC;IAClE,CAAC;IAED,IAAW,wBAAwB;QAClC,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACvC,CAAC;IACD,IAAW,wBAAwB,CAAC,KAAyB;QAC5D,IAAI,CAAC,yBAAyB,GAAG,KAAK,IAAI,IAAI,CAAC,+BAA+B,CAAC;IAChF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\n\nclass ForcedRefreshControl\n\timplements\n\t\tPick<\n\t\t\tBroadcastControls & { forcedRefreshIntervalMs: number | undefined },\n\t\t\t\"forcedRefreshIntervalMs\"\n\t\t>\n{\n\tprivate _forcedRefreshInterval: number | undefined;\n\n\tpublic constructor(settings?: BroadcastControlSettings) {\n\t\t// this._forcedRefreshInterval = settings?.forcedRefreshIntervalMs;\n\t}\n\n\tpublic get forcedRefreshIntervalMs(): number | undefined {\n\t\treturn this._forcedRefreshInterval;\n\t}\n\tpublic set forcedRefreshIntervalMs(value: number | undefined) {\n\t\tif (value === undefined) {\n\t\t\tthis._forcedRefreshInterval = undefined;\n\t\t} else {\n\t\t\tthis._forcedRefreshInterval = value >= 10 ? value : undefined;\n\t\t\tif (value >= 10) {\n\t\t\t\t// TODO: enable periodic forced refresh\n\t\t\t\tthrow new Error(\"Forced Refresh feature is not implemented\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implements {@link BroadcastControls} for States Managers\n * where returning `undefined` settings are allowed.\n */\nexport class OptionalBroadcastControl\n\textends ForcedRefreshControl\n\timplements BroadcastControls\n{\n\tpublic allowableUpdateLatencyMs: number | undefined;\n\n\tpublic constructor(settings?: BroadcastControlSettings) {\n\t\tsuper(settings);\n\t\tthis.allowableUpdateLatencyMs = settings?.allowableUpdateLatencyMs;\n\t}\n}\n\n/**\n * Implements {@link BroadcastControls} but always provides defined value for\n * {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}.\n *\n * If {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}\n * is set to `undefined`, the default will be restored.\n */\nexport class RequiredBroadcastControl\n\textends ForcedRefreshControl\n\timplements BroadcastControls\n{\n\tprivate _allowableUpdateLatencyMs: number;\n\n\tpublic constructor(private readonly defaultAllowableUpdateLatencyMs: number) {\n\t\tsuper();\n\t\tthis._allowableUpdateLatencyMs = defaultAllowableUpdateLatencyMs;\n\t}\n\n\tpublic get allowableUpdateLatencyMs(): number {\n\t\treturn this._allowableUpdateLatencyMs;\n\t}\n\tpublic set allowableUpdateLatencyMs(value: number | undefined) {\n\t\tthis._allowableUpdateLatencyMs = value ?? this.defaultAllowableUpdateLatencyMs;\n\t}\n}\n"]}
@@ -0,0 +1,38 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Common controls for States objects.
7
+ *
8
+ * @sealed
9
+ * @beta
10
+ */
11
+ export interface BroadcastControls {
12
+ /**
13
+ * Maximum time in milliseconds that a local value update is allowed
14
+ * to remain pending before it must be broadcast.
15
+ *
16
+ * @remarks
17
+ * There is no guarantee of broadcast within time allowed
18
+ * as other conditions such as disconnect or service throttling may
19
+ * cause a delay.
20
+ *
21
+ * Setting to `undefined` will restore to a system default.
22
+ */
23
+ allowableUpdateLatencyMs: number | undefined;
24
+ }
25
+ /**
26
+ * Value set to configure {@link BroadcastControls}.
27
+ *
28
+ * @beta
29
+ */
30
+ export interface BroadcastControlSettings {
31
+ /**
32
+ * {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}
33
+ *
34
+ * @defaultValue 60 [milliseconds]
35
+ */
36
+ readonly allowableUpdateLatencyMs?: number;
37
+ }
38
+ //# sourceMappingURL=broadcastControlsTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcastControlsTypes.d.ts","sourceRoot":"","sources":["../src/broadcastControlsTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;;;;;;;;OAUG;IACH,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC;CAc7C;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;;OAIG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAS3C"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=broadcastControlsTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcastControlsTypes.js","sourceRoot":"","sources":["../src/broadcastControlsTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Common controls for States objects.\n *\n * @sealed\n * @beta\n */\nexport interface BroadcastControls {\n\t/**\n\t * Maximum time in milliseconds that a local value update is allowed\n\t * to remain pending before it must be broadcast.\n\t *\n\t * @remarks\n\t * There is no guarantee of broadcast within time allowed\n\t * as other conditions such as disconnect or service throttling may\n\t * cause a delay.\n\t *\n\t * Setting to `undefined` will restore to a system default.\n\t */\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Target time in milliseconds between oldest changed local state\n\t * has been broadcast and forced rebroadcast of all local values.\n\t * A value of less than 10 disables forced refresh.\n\t *\n\t * @privateRemarks\n\t * Any time less than 10 milliseconds is likely to generate too\n\t * many signals. Ideally this feature becomes obsolete as\n\t * we understand the system better and account for holes.\n\t */\n\t// forcedRefreshIntervalMs is removed until it is supported.\n\t// forcedRefreshIntervalMs: number | undefined;\n}\n\n/**\n * Value set to configure {@link BroadcastControls}.\n *\n * @beta\n */\nexport interface BroadcastControlSettings {\n\t/**\n\t * {@inheritdoc BroadcastControls.allowableUpdateLatencyMs}\n\t *\n\t * @defaultValue 60 [milliseconds]\n\t */\n\treadonly allowableUpdateLatencyMs?: number;\n\n\t/**\n\t * {@inheritdoc BroadcastControls.forcedRefreshIntervalMs}\n\t *\n\t * @defaultValue 0 (disabled)\n\t */\n\t// forcedRefreshIntervalMs is removed until it is supported.\n\t// readonly forcedRefreshIntervalMs?: number;\n}\n"]}