@fluidframework/presence 2.81.1 → 2.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/alpha.d.ts +1 -1
  2. package/dist/exposedUtilityTypes.d.ts +57 -5
  3. package/dist/exposedUtilityTypes.d.ts.map +1 -1
  4. package/dist/exposedUtilityTypes.js.map +1 -1
  5. package/dist/index.d.ts +3 -3
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/internalUtils.d.ts.map +1 -1
  9. package/dist/internalUtils.js.map +1 -1
  10. package/dist/latestMapTypes.d.ts +309 -0
  11. package/dist/latestMapTypes.d.ts.map +1 -0
  12. package/dist/latestMapTypes.js +8 -0
  13. package/dist/latestMapTypes.js.map +1 -0
  14. package/dist/latestMapValueManager.d.ts +4 -265
  15. package/dist/latestMapValueManager.d.ts.map +1 -1
  16. package/dist/latestMapValueManager.js +3 -4
  17. package/dist/latestMapValueManager.js.map +1 -1
  18. package/dist/latestTypes.d.ts +149 -0
  19. package/dist/latestTypes.d.ts.map +1 -0
  20. package/dist/latestTypes.js +7 -0
  21. package/dist/latestTypes.js.map +1 -0
  22. package/dist/latestValueManager.d.ts +1 -144
  23. package/dist/latestValueManager.d.ts.map +1 -1
  24. package/dist/latestValueManager.js +4 -5
  25. package/dist/latestValueManager.js.map +1 -1
  26. package/dist/latestValueTypes.d.ts +0 -11
  27. package/dist/latestValueTypes.d.ts.map +1 -1
  28. package/dist/latestValueTypes.js +0 -36
  29. package/dist/latestValueTypes.js.map +1 -1
  30. package/dist/legacy.alpha.d.ts +1 -1
  31. package/dist/notificationsManager.d.ts +15 -5
  32. package/dist/notificationsManager.d.ts.map +1 -1
  33. package/dist/notificationsManager.js +0 -4
  34. package/dist/notificationsManager.js.map +1 -1
  35. package/dist/notificationsManagerTypes.d.ts +7 -4
  36. package/dist/notificationsManagerTypes.d.ts.map +1 -1
  37. package/dist/notificationsManagerTypes.js.map +1 -1
  38. package/dist/packageVersion.d.ts +1 -1
  39. package/dist/packageVersion.js +1 -1
  40. package/dist/packageVersion.js.map +1 -1
  41. package/dist/stateFactory.d.ts +2 -2
  42. package/dist/stateFactory.d.ts.map +1 -1
  43. package/dist/stateFactory.js.map +1 -1
  44. package/dist/validatableTypes.d.ts.map +1 -1
  45. package/dist/validatableTypes.js.map +1 -1
  46. package/dist/validatedGetter.d.ts +18 -0
  47. package/dist/validatedGetter.d.ts.map +1 -0
  48. package/dist/validatedGetter.js +43 -0
  49. package/dist/validatedGetter.js.map +1 -0
  50. package/lib/alpha.d.ts +1 -1
  51. package/lib/exposedUtilityTypes.d.ts +57 -5
  52. package/lib/exposedUtilityTypes.d.ts.map +1 -1
  53. package/lib/exposedUtilityTypes.js.map +1 -1
  54. package/lib/index.d.ts +3 -3
  55. package/lib/index.d.ts.map +1 -1
  56. package/lib/index.js.map +1 -1
  57. package/lib/internalUtils.d.ts.map +1 -1
  58. package/lib/internalUtils.js.map +1 -1
  59. package/lib/latestMapTypes.d.ts +309 -0
  60. package/lib/latestMapTypes.d.ts.map +1 -0
  61. package/lib/latestMapTypes.js +7 -0
  62. package/lib/latestMapTypes.js.map +1 -0
  63. package/lib/latestMapValueManager.d.ts +4 -265
  64. package/lib/latestMapValueManager.d.ts.map +1 -1
  65. package/lib/latestMapValueManager.js +1 -2
  66. package/lib/latestMapValueManager.js.map +1 -1
  67. package/lib/latestTypes.d.ts +149 -0
  68. package/lib/latestTypes.d.ts.map +1 -0
  69. package/lib/latestTypes.js +6 -0
  70. package/lib/latestTypes.js.map +1 -0
  71. package/lib/latestValueManager.d.ts +1 -144
  72. package/lib/latestValueManager.d.ts.map +1 -1
  73. package/lib/latestValueManager.js +1 -2
  74. package/lib/latestValueManager.js.map +1 -1
  75. package/lib/latestValueTypes.d.ts +0 -11
  76. package/lib/latestValueTypes.d.ts.map +1 -1
  77. package/lib/latestValueTypes.js +1 -34
  78. package/lib/latestValueTypes.js.map +1 -1
  79. package/lib/legacy.alpha.d.ts +1 -1
  80. package/lib/notificationsManager.d.ts +15 -5
  81. package/lib/notificationsManager.d.ts.map +1 -1
  82. package/lib/notificationsManager.js +0 -4
  83. package/lib/notificationsManager.js.map +1 -1
  84. package/lib/notificationsManagerTypes.d.ts +7 -4
  85. package/lib/notificationsManagerTypes.d.ts.map +1 -1
  86. package/lib/notificationsManagerTypes.js.map +1 -1
  87. package/lib/packageVersion.d.ts +1 -1
  88. package/lib/packageVersion.js +1 -1
  89. package/lib/packageVersion.js.map +1 -1
  90. package/lib/stateFactory.d.ts +2 -2
  91. package/lib/stateFactory.d.ts.map +1 -1
  92. package/lib/stateFactory.js.map +1 -1
  93. package/lib/validatableTypes.d.ts.map +1 -1
  94. package/lib/validatableTypes.js.map +1 -1
  95. package/lib/validatedGetter.d.ts +18 -0
  96. package/lib/validatedGetter.d.ts.map +1 -0
  97. package/lib/validatedGetter.js +39 -0
  98. package/lib/validatedGetter.js.map +1 -0
  99. package/package.json +16 -16
@@ -1 +1 @@
1
- {"version":3,"file":"latestValueTypes.js","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAiItE,SAAS,oBAAoB,CAC5B,WAAwC,EACxC,SAA0C;IAE1C,OAAO,GAAkD,EAAE;QAC1D,IAAI,CAAC,CAAC,gBAAgB,IAAI,WAAW,CAAC,EAAE,CAAC;YACxC,iFAAiF;YACjF,WAAW,CAAC,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,gCAAgC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACpC,WAAwC,EACxC,SAA8C;IAE9C,eAAe;IACf,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,gCAAgC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,uEAAuE;IACvE,IAAI,OAAO,WAAW,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO,WAAW,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,sHAAsH;IACtH,mHAAmH;IACnH,sHAAsH;IACtH,2BAA2B;IAC3B,OAAO,oBAAoB,CAAC,WAAW,EAAE,SAA4C,CAAC,CAAC;AACxF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tOpaqueJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport { asDeeplyReadonlyDeserializedJson } from \"./internalUtils.js\";\nimport type { Attendee } from \"./presence.js\";\nimport type { ValidatableRequiredState } from \"./validatableTypes.js\";\n\n/**\n * Metadata for the value state.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMetadata {\n\t/**\n\t * The revision number for value that increases as value is changed.\n\t */\n\trevision: number;\n\t/**\n\t * Local time when the value was last updated.\n\t * @remarks Currently this is a placeholder for future implementation.\n\t */\n\ttimestamp: number;\n}\n\n/**\n * Represents a value that is accessed directly.\n *\n * @system\n * @beta\n */\nexport interface RawValueAccessor<T> {\n\treadonly kind: \"raw\";\n\treadonly data: T;\n}\n\n/**\n * Represents a value that is accessed via a function call, which may result in no value.\n *\n * @system\n * @beta\n */\nexport interface ProxiedValueAccessor<T> {\n\treadonly kind: \"proxied\";\n\treadonly data: T;\n}\n\n/**\n * Union of possible accessor types for a value.\n *\n * @system\n * @beta\n */\nexport type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;\n\n/**\n * Utility type that conditionally represents an accessor type based on the base accessor type.\n *\n * @system\n * @beta\n */\nexport type Accessor<\n\tT,\n\tBaseAccessor extends ValueAccessor<T>,\n> = BaseAccessor extends ProxiedValueAccessor<T>\n\t? () => DeepReadonly<JsonDeserialized<T>> | undefined\n\t: BaseAccessor extends RawValueAccessor<T>\n\t\t? DeepReadonly<JsonDeserialized<T>>\n\t\t: never;\n\n/**\n * State of a value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {\n\t/**\n\t * The value of the state or an accessor function.\n\t *\n\t * @remarks\n\t * If the State object was created with a {@link StateSchemaValidator}, then the `value`\n\t * will be a function returning a validated, deeply readonly `T` or `undefined`.\n\t * Without a validator, `value` will be an unvalidated, deeply readonly `T`.\n\t *\n\t * Any `T` is always deeply readonly, meaning it cannot be modified.\n\t */\n\tvalue: Accessor<T, TValueAccessor>;\n\n\t/**\n\t * Metadata associated with the value.\n\t */\n\tmetadata: LatestMetadata;\n}\n\n/**\n * State of a specific {@link Attendee}'s value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestClientData<\n\tT,\n\tTValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> extends LatestData<T, TValueAccessor> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee;\n}\n\n/**\n * A validator function that can optionally be provided to do runtime validation of the custom data stored in a\n * presence workspace and managed by a state object.\n *\n * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**\n *\n * @returns The validated data, or `undefined` if the data is invalid.\n *\n * @beta\n */\nexport type StateSchemaValidator<T> = (\n\t/**\n\t * Unknown data that should be validated. **This data should not be mutated.**\n\t */\n\tunvalidatedData: unknown,\n) => JsonDeserialized<T> | undefined;\n\ntype StateSchemaValidatorToOpaque<T> = (\n\trawData: OpaqueJsonDeserialized<T>,\n) => OpaqueJsonDeserialized<T> | undefined;\n\nfunction createGetterFunction<T>(\n\tclientState: ValidatableRequiredState<T>,\n\tvalidator: StateSchemaValidatorToOpaque<T>,\n): () => DeepReadonly<JsonDeserialized<T>> | undefined {\n\treturn (): DeepReadonly<JsonDeserialized<T>> | undefined => {\n\t\tif (!(\"validatedValue\" in clientState)) {\n\t\t\t// Stored `value` has not been validated yet, so validate it and save the result.\n\t\t\tclientState.validatedValue = validator(clientState.value);\n\t\t}\n\t\treturn asDeeplyReadonlyDeserializedJson(clientState.validatedValue);\n\t};\n}\n\n/**\n * Creates a getter for a state value that validates the data with a validator if one is provided. Otherwise the value\n * is returned directly.\n *\n * @param clientState - The client state to be validated.\n * @param validator - The validator function to run.\n * @returns Either returns the value directly if a validator is not provided, or a function that will return the\n * validated data.\n */\nexport function createValidatedGetter<T>(\n\tclientState: ValidatableRequiredState<T>,\n\tvalidator: StateSchemaValidator<T> | undefined,\n): (() => DeepReadonly<JsonDeserialized<T>> | undefined) | DeepReadonly<JsonDeserialized<T>> {\n\t// No validator\n\tif (validator === undefined) {\n\t\treturn asDeeplyReadonlyDeserializedJson(clientState.value);\n\t}\n\n\t// Avoid creating another function since one already exists on the item\n\tif (typeof clientState.value === \"function\") {\n\t\treturn clientState.value;\n\t}\n\n\t// OpaqueJsonDeserialized<T> is just a branded alias of JsonDeserialized<T>. At runtime the functions are still passed\n\t// JSON data, regardless of their type representation. Passing that data to a function that expects `unknown`, like\n\t// the user-provided validator function, is always valid, so StateSchemaValidator and StateSchemaValidatorToOpaque are\n\t// functionally equivalent.\n\treturn createGetterFunction(clientState, validator as StateSchemaValidatorToOpaque<T>);\n}\n"]}
1
+ {"version":3,"file":"latestValueTypes.js","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * Metadata for the value state.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMetadata {\n\t/**\n\t * The revision number for value that increases as value is changed.\n\t */\n\trevision: number;\n\t/**\n\t * Local time when the value was last updated.\n\t * @remarks Currently this is a placeholder for future implementation.\n\t */\n\ttimestamp: number;\n}\n\n/**\n * Represents a value that is accessed directly.\n *\n * @system\n * @beta\n */\nexport interface RawValueAccessor<T> {\n\treadonly kind: \"raw\";\n\treadonly data: T;\n}\n\n/**\n * Represents a value that is accessed via a function call, which may result in no value.\n *\n * @system\n * @beta\n */\nexport interface ProxiedValueAccessor<T> {\n\treadonly kind: \"proxied\";\n\treadonly data: T;\n}\n\n/**\n * Union of possible accessor types for a value.\n *\n * @system\n * @beta\n */\nexport type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;\n\n/**\n * Utility type that conditionally represents an accessor type based on the base accessor type.\n *\n * @system\n * @beta\n */\nexport type Accessor<\n\tT,\n\tBaseAccessor extends ValueAccessor<T>,\n> = BaseAccessor extends ProxiedValueAccessor<T>\n\t? () => DeepReadonly<JsonDeserialized<T>> | undefined\n\t: BaseAccessor extends RawValueAccessor<T>\n\t\t? DeepReadonly<JsonDeserialized<T>>\n\t\t: never;\n\n/**\n * State of a value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {\n\t/**\n\t * The value of the state or an accessor function.\n\t *\n\t * @remarks\n\t * If the State object was created with a {@link StateSchemaValidator}, then the `value`\n\t * will be a function returning a validated, deeply readonly `T` or `undefined`.\n\t * Without a validator, `value` will be an unvalidated, deeply readonly `T`.\n\t *\n\t * Any `T` is always deeply readonly, meaning it cannot be modified.\n\t */\n\tvalue: Accessor<T, TValueAccessor>;\n\n\t/**\n\t * Metadata associated with the value.\n\t */\n\tmetadata: LatestMetadata;\n}\n\n/**\n * State of a specific {@link Attendee}'s value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestClientData<\n\tT,\n\tTValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> extends LatestData<T, TValueAccessor> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee;\n}\n\n/**\n * A validator function that can optionally be provided to do runtime validation of the custom data stored in a\n * presence workspace and managed by a state object.\n *\n * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**\n *\n * @returns The validated data, or `undefined` if the data is invalid.\n *\n * @beta\n */\nexport type StateSchemaValidator<T> = (\n\t/**\n\t * Unknown data that should be validated. **This data should not be mutated.**\n\t */\n\tunvalidatedData: unknown,\n) => JsonDeserialized<T> | undefined;\n"]}
@@ -68,7 +68,7 @@ export {
68
68
  InternalUtilityTypes,
69
69
  NotificationEmitter,
70
70
  NotificationListenable,
71
- NotificationSubscriptions,
71
+ NotificationSubscriberSignatures,
72
72
  Notifications,
73
73
  NotificationsManager,
74
74
  NotificationsManagerEvents,
@@ -4,15 +4,25 @@
4
4
  */
5
5
  import type { InternalTypes } from "./exposedInternalTypes.js";
6
6
  import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
7
- import type { NotificationsManager, NotificationSubscriptions } from "./notificationsManagerTypes.js";
7
+ import type { NotificationsManager, NotificationSubscriberSignatures } from "./notificationsManagerTypes.js";
8
8
  /**
9
9
  * Factory for creating a {@link NotificationsManager}.
10
10
  *
11
- * @remarks
12
- * Typescript inference for `Notifications` is not working correctly yet.
13
- * Explicitly specify generics to make result types usable.
11
+ * @alpha
12
+ *
13
+ * @privateRemarks
14
+ * This overload requires explicit specification of the notification listener
15
+ * types. It is useful when a schema is separately defined.
16
+ */
17
+ export declare function Notifications<T extends InternalUtilityTypes.NotificationListeners<T>, Key extends string = string>(initialSubscriptions: Partial<NotificationSubscriberSignatures<T>>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>;
18
+ /**
19
+ * Factory for creating a {@link NotificationsManager}.
14
20
  *
15
21
  * @alpha
22
+ *
23
+ * @privateRemarks
24
+ * This overload infers the notification listener types from the provided
25
+ * subscriptions, simplifying usage when a schema is not separately defined.
16
26
  */
17
- export declare function Notifications<T extends InternalUtilityTypes.NotificationListeners<T>, Key extends string = string>(initialSubscriptions: Partial<NotificationSubscriptions<T>>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>;
27
+ export declare function Notifications<TSubscriptions extends InternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>, Key extends string = string>(initialSubscriptions: Partial<TSubscriptions>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<InternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>>>;
18
28
  //# sourceMappingURL=notificationsManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EACX,oBAAoB,EAGpB,yBAAyB,EAEzB,MAAM,gCAAgC,CAAC;AAmHxC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,CAAC,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EACvD,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GACzD,aAAa,CAAC,cAAc,CAC9B,GAAG,EACH,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAuBA"}
1
+ {"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAGX,oBAAoB,EAEpB,gCAAgC,EAChC,MAAM,gCAAgC,CAAC;AAoHxC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,CAAC,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EACvD,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,GAChE,aAAa,CAAC,cAAc,CAC9B,GAAG,EACH,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAAC;AACF;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,cAAc,SACb,oBAAoB,CAAC,6CAA6C,CAAC,cAAc,CAAC,EACnF,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,cAAc,CAAC,GAC3C,aAAa,CAAC,cAAc,CAC9B,GAAG,EACH,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CACnB,oBAAoB,CAAC,6CAA6C,CAAC,cAAc,CAAC,CAClF,CACD,CAAC"}
@@ -83,10 +83,6 @@ class NotificationsManagerImpl {
83
83
  /**
84
84
  * Factory for creating a {@link NotificationsManager}.
85
85
  *
86
- * @remarks
87
- * Typescript inference for `Notifications` is not working correctly yet.
88
- * Explicitly specify generics to make result types usable.
89
- *
90
86
  * @alpha
91
87
  */
92
88
  export function Notifications(initialSubscriptions) {
@@ -1 +1 @@
1
- {"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;A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IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAC/E,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC1B,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAI5B,oBAA2D;IAM3D,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAGA,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,QAAQ,CAKhB,IAAI,wBAAwB,CAC3B,GAAG,EACH,mBAAmB,CAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport { revealOpaqueJson, toOpaqueJson } from \"./internalUtils.js\";\nimport type {\n\tNotificationsManager,\n\tNotificationsManagerEvents,\n\tNotificationEmitter,\n\tNotificationSubscriptions,\n\tNotificationListenable,\n} from \"./notificationsManagerTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name: string, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name: string, targetAttendee, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal = createEmitter<NotificationSubscriptions<T>>();\n\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriptions<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tupdateValue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst value = revealOpaqueJson(updateValue.value);\n\t\tconst eventName = value.name as keyof Listeners<NotificationSubscriptions<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [attendee, ...value.args] as Parameters<\n\t\t\t\tNotificationSubscriptions<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\"unattendedNotification\", value.name, attendee, ...value.args),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @remarks\n * Typescript inference for `Notifications` is not working correctly yet.\n * Explicitly specify generics to make result types usable.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriptions<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
1
+ {"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AASpE,OAAO,EAAE,mBAAmB,EAAuB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MAAM,wBAAwB;IAqD7B,YACkB,GAAQ,EACR,SAGhB,EACD,oBAAkE;QALjD,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAGzB;QAhDc,WAAM,GAAG,aAAa,EAA8B,CAAC;QAErD,SAAI,G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CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport { revealOpaqueJson, toOpaqueJson } from \"./internalUtils.js\";\nimport type {\n\tNotificationEmitter,\n\tNotificationListenable,\n\tNotificationsManager,\n\tNotificationsManagerEvents,\n\tNotificationSubscriberSignatures,\n} from \"./notificationsManagerTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name: string, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name: string, targetAttendee, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal =\n\t\tcreateEmitter<NotificationSubscriberSignatures<T>>();\n\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriberSignatures<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriberSignatures<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tupdateValue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst value = revealOpaqueJson(updateValue.value);\n\t\tconst eventName = value.name as keyof Listeners<NotificationSubscriberSignatures<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [attendee, ...value.args] as Parameters<\n\t\t\t\tNotificationSubscriberSignatures<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\"unattendedNotification\", value.name, attendee, ...value.args),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n *\n * @privateRemarks\n * This overload requires explicit specification of the notification listener\n * types. It is useful when a schema is separately defined.\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriberSignatures<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n>;\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n *\n * @privateRemarks\n * This overload infers the notification listener types from the provided\n * subscriptions, simplifying usage when a schema is not separately defined.\n */\nexport function Notifications<\n\tTSubscriptions extends\n\t\tInternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<TSubscriptions>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<\n\t\tInternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>\n\t>\n>;\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n\tTSubscriptions extends\n\t\tNotificationSubscriberSignatures<T> = NotificationSubscriberSignatures<T>,\n>(\n\tinitialSubscriptions: Partial<TSubscriptions>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
@@ -48,13 +48,16 @@ export interface NotificationListenable<TListeners extends InternalUtilityTypes.
48
48
  off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
49
49
  }
50
50
  /**
51
- * Record of notification subscriptions.
51
+ * Record of notification subscription signatures transformed from listener emit signatures.
52
+ *
53
+ * @remarks
54
+ * Prepends the `sender: Attendee` parameter to each notification listener signature.
52
55
  *
53
56
  * @sealed
54
57
  * @alpha
55
58
  */
56
- export type NotificationSubscriptions<E extends InternalUtilityTypes.NotificationListeners<E>> = {
57
- [K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>) => void;
59
+ export type NotificationSubscriberSignatures<E extends InternalUtilityTypes.NotificationListeners<E>> = {
60
+ [K in keyof InternalUtilityTypes.NotificationListeners<E>]: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>) => void;
58
61
  };
59
62
  /**
60
63
  * Interface for a notification emitter that can send typed notification to other clients.
@@ -81,7 +84,7 @@ export interface NotificationEmitter<E extends InternalUtilityTypes.Notification
81
84
  * Provides notifications from this client to others and subscription
82
85
  * to their notifications.
83
86
  *
84
- * @remarks Create using {@link Notifications} registered to
87
+ * @remarks Create using {@link (Notifications:1)} registered to
85
88
  * {@link NotificationsWorkspace} or {@link StatesWorkspace}.
86
89
  *
87
90
  * @sealed
@@ -1 +1 @@
1
- {"version":3,"file":"notificationsManagerTypes.d.ts","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,sBAAsB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,OA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AC,CAAC,CAAC,CAAC,GACvB,IAAI,CAAC;IAER;;;;;OAKG;IACH,OAAO,CAAC,CAAC,SAAS,MAAM,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EACpE,gBAAgB,EAAE,CAAC,EACnB,cAAc,EAAE,QAAQ,EACxB,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACvB,IAAI,CAAC;CACR;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB,CACpC,CAAC,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEvD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;CAClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"notificationsManagerTypes.js","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\n\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscriptions.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriptions<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: Attendee,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single attendee.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetAttendee - the single attendee to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetAttendee: Attendee,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link Notifications} registered to\n * {@link NotificationsWorkspace} or {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n"]}
1
+ {"version":3,"file":"notificationsManagerTypes.js","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\n\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscription signatures transformed from listener emit signatures.\n *\n * @remarks\n * Prepends the `sender: Attendee` parameter to each notification listener signature.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriberSignatures<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: Attendee,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single attendee.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetAttendee - the single attendee to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetAttendee: Attendee,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link (Notifications:1)} registered to\n * {@link NotificationsWorkspace} or {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/presence";
8
- export declare const pkgVersion = "2.81.1";
8
+ export declare const pkgVersion = "2.82.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/presence";
8
- export const pkgVersion = "2.81.1";
8
+ export const pkgVersion = "2.82.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/presence\";\nexport const pkgVersion = \"2.81.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/presence\";\nexport const pkgVersion = \"2.82.0\";\n"]}
@@ -12,7 +12,7 @@
12
12
  * @beta
13
13
  */
14
14
  export declare const StateFactory: {
15
- latest: import("./latestValueManager.js").LatestFactory;
16
- latestMap: import("./latestMapValueManager.js").LatestMapFactory;
15
+ latest: import("./latestTypes.js").LatestFactory;
16
+ latestMap: import("./latestMapTypes.js").LatestMapFactory;
17
17
  };
18
18
  //# sourceMappingURL=stateFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stateFactory.d.ts","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
1
+ {"version":3,"file":"stateFactory.d.ts","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;CAGxB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stateFactory.js","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,MAAM;IACN,SAAS;CACT,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { latestMap } from \"./latestMapValueManager.js\";\nimport { latest } from \"./latestValueManager.js\";\n\n/**\n * Factory for creating presence State objects.\n *\n * @remarks\n * Use `latest` to create a {@link LatestRaw} State object.\n * Use `latestMap` to create a {@link LatestMapRaw} State object.\n *\n * @beta\n */\nexport const StateFactory = {\n\tlatest,\n\tlatestMap,\n};\n"]}
1
+ {"version":3,"file":"stateFactory.js","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAMvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,MAAM;IACN,SAAS;CACT,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// These \"unused\" imports are specified to workaround an api-extractor limitation.\n// @ts-expect-error -- Unused import is for type only\nimport type {\n\t// eslint-disable-next-line unused-imports/no-unused-imports\n\tLatestMap,\n} from \"./latestMapTypes.js\";\nimport { latestMap } from \"./latestMapValueManager.js\";\n// @ts-expect-error -- Unused import is for type only\nimport type {\n\t// eslint-disable-next-line unused-imports/no-unused-imports\n\tLatest,\n} from \"./latestTypes.js\";\nimport { latest } from \"./latestValueManager.js\";\n\n/**\n * Factory for creating presence State objects.\n *\n * @remarks\n * Use `latest` to create a {@link LatestRaw} State object.\n * Use `latestMap` to create a {@link LatestMapRaw} State object.\n *\n * @beta\n */\nexport const StateFactory = {\n\tlatest,\n\tlatestMap,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validatableTypes.d.ts","sourceRoot":"","sources":["../src/validatableTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D;;GAEG;AACH,UAAU,mBAAmB,CAAC,MAAM;IACnC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;CAE5D;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAC,MAAM,CAC/C,SAAQ,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC,EACxF,mBAAmB,CAAC,MAAM,CAAC;CAAG;AAEhC;;;GAGG;AACH,MAAM,WAAW,wBAAwB,CAAC,MAAM,CAC/C,SAAQ,IAAI,CAAC,aAAa,CAAC,kBAAkB,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;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,CACpC,CAAC,SACE,aAAa,CAAC,cAAc,CAAC,OAAO,CAAC,GACrC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,GACzC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAE5C,CAAC,SAAS,aAAa,CAAC,cAAc,CAAC,MAAM,MAAM,CAAC,GACjD,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"}
@@ -1 +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"]}
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> =\n\tT extends InternalTypes.ValueDirectory<infer TValue>\n\t\t? InternalUtilityTypes.IfSameType<\n\t\t\t\tT,\n\t\t\t\tInternalTypes.ValueDirectory<T>,\n\t\t\t\t// Use canonical type for exact match\n\t\t\t\tValidatableValueDirectory<TValue>,\n\t\t\t\t// Inexact match => recurse\n\t\t\t\tInternalUtilityTypes.FlattenIntersection<\n\t\t\t\t\tOmit<T, \"items\"> & {\n\t\t\t\t\t\titems: {\n\t\t\t\t\t\t\t[KItems in keyof T[\"items\"]]: ValidatableValueStructure<T[\"items\"][KItems]>;\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t>\n\t\t: T extends\n\t\t\t\t\t| InternalTypes.ValueRequiredState<infer TValue>\n\t\t\t\t\t| InternalTypes.ValueOptionalState<infer TValue>\n\t\t\t? InternalUtilityTypes.FlattenIntersection<\n\t\t\t\t\tOmit<T, keyof ValidatableMetadata<TValue>> & ValidatableMetadata<TValue>\n\t\t\t\t>\n\t\t\t: never;\n"]}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
6
+ import type { StateSchemaValidator } from "./latestValueTypes.js";
7
+ import type { ValidatableRequiredState } from "./validatableTypes.js";
8
+ /**
9
+ * Creates a getter for a state value that validates the data with a validator if one is provided. Otherwise the value
10
+ * is returned directly.
11
+ *
12
+ * @param clientState - The client state to be validated.
13
+ * @param validator - The validator function to run.
14
+ * @returns Either returns the value directly if a validator is not provided, or a function that will return the
15
+ * validated data.
16
+ */
17
+ export declare function createValidatedGetter<T>(clientState: ValidatableRequiredState<T>, validator: StateSchemaValidator<T> | undefined): (() => DeepReadonly<JsonDeserialized<T>> | undefined) | DeepReadonly<JsonDeserialized<T>>;
18
+ //# sourceMappingURL=validatedGetter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatedGetter.d.ts","sourceRoot":"","sources":["../src/validatedGetter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAEhB,MAAM,8DAA8D,CAAC;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAmBtE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACtC,WAAW,EAAE,wBAAwB,CAAC,CAAC,CAAC,EACxC,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,SAAS,GAC5C,CAAC,MAAM,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAgB3F"}
@@ -0,0 +1,39 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { asDeeplyReadonlyDeserializedJson } from "./internalUtils.js";
6
+ function createGetterFunction(clientState, validator) {
7
+ return () => {
8
+ if (!("validatedValue" in clientState)) {
9
+ // Stored `value` has not been validated yet, so validate it and save the result.
10
+ clientState.validatedValue = validator(clientState.value);
11
+ }
12
+ return asDeeplyReadonlyDeserializedJson(clientState.validatedValue);
13
+ };
14
+ }
15
+ /**
16
+ * Creates a getter for a state value that validates the data with a validator if one is provided. Otherwise the value
17
+ * is returned directly.
18
+ *
19
+ * @param clientState - The client state to be validated.
20
+ * @param validator - The validator function to run.
21
+ * @returns Either returns the value directly if a validator is not provided, or a function that will return the
22
+ * validated data.
23
+ */
24
+ export function createValidatedGetter(clientState, validator) {
25
+ // No validator
26
+ if (validator === undefined) {
27
+ return asDeeplyReadonlyDeserializedJson(clientState.value);
28
+ }
29
+ // Avoid creating another function since one already exists on the item
30
+ if (typeof clientState.value === "function") {
31
+ return clientState.value;
32
+ }
33
+ // OpaqueJsonDeserialized<T> is just a branded alias of JsonDeserialized<T>. At runtime the functions are still passed
34
+ // JSON data, regardless of their type representation. Passing that data to a function that expects `unknown`, like
35
+ // the user-provided validator function, is always valid, so StateSchemaValidator and StateSchemaValidatorToOpaque are
36
+ // functionally equivalent.
37
+ return createGetterFunction(clientState, validator);
38
+ }
39
+ //# sourceMappingURL=validatedGetter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validatedGetter.js","sourceRoot":"","sources":["../src/validatedGetter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAQtE,SAAS,oBAAoB,CAC5B,WAAwC,EACxC,SAA0C;IAE1C,OAAO,GAAkD,EAAE;QAC1D,IAAI,CAAC,CAAC,gBAAgB,IAAI,WAAW,CAAC,EAAE,CAAC;YACxC,iFAAiF;YACjF,WAAW,CAAC,cAAc,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,gCAAgC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACpC,WAAwC,EACxC,SAA8C;IAE9C,eAAe;IACf,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,gCAAgC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,uEAAuE;IACvE,IAAI,OAAO,WAAW,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO,WAAW,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,sHAAsH;IACtH,mHAAmH;IACnH,sHAAsH;IACtH,2BAA2B;IAC3B,OAAO,oBAAoB,CAAC,WAAW,EAAE,SAA4C,CAAC,CAAC;AACxF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tOpaqueJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport { asDeeplyReadonlyDeserializedJson } from \"./internalUtils.js\";\nimport type { StateSchemaValidator } from \"./latestValueTypes.js\";\nimport type { ValidatableRequiredState } from \"./validatableTypes.js\";\n\ntype StateSchemaValidatorToOpaque<T> = (\n\trawData: OpaqueJsonDeserialized<T>,\n) => OpaqueJsonDeserialized<T> | undefined;\n\nfunction createGetterFunction<T>(\n\tclientState: ValidatableRequiredState<T>,\n\tvalidator: StateSchemaValidatorToOpaque<T>,\n): () => DeepReadonly<JsonDeserialized<T>> | undefined {\n\treturn (): DeepReadonly<JsonDeserialized<T>> | undefined => {\n\t\tif (!(\"validatedValue\" in clientState)) {\n\t\t\t// Stored `value` has not been validated yet, so validate it and save the result.\n\t\t\tclientState.validatedValue = validator(clientState.value);\n\t\t}\n\t\treturn asDeeplyReadonlyDeserializedJson(clientState.validatedValue);\n\t};\n}\n\n/**\n * Creates a getter for a state value that validates the data with a validator if one is provided. Otherwise the value\n * is returned directly.\n *\n * @param clientState - The client state to be validated.\n * @param validator - The validator function to run.\n * @returns Either returns the value directly if a validator is not provided, or a function that will return the\n * validated data.\n */\nexport function createValidatedGetter<T>(\n\tclientState: ValidatableRequiredState<T>,\n\tvalidator: StateSchemaValidator<T> | undefined,\n): (() => DeepReadonly<JsonDeserialized<T>> | undefined) | DeepReadonly<JsonDeserialized<T>> {\n\t// No validator\n\tif (validator === undefined) {\n\t\treturn asDeeplyReadonlyDeserializedJson(clientState.value);\n\t}\n\n\t// Avoid creating another function since one already exists on the item\n\tif (typeof clientState.value === \"function\") {\n\t\treturn clientState.value;\n\t}\n\n\t// OpaqueJsonDeserialized<T> is just a branded alias of JsonDeserialized<T>. At runtime the functions are still passed\n\t// JSON data, regardless of their type representation. Passing that data to a function that expects `unknown`, like\n\t// the user-provided validator function, is always valid, so StateSchemaValidator and StateSchemaValidatorToOpaque are\n\t// functionally equivalent.\n\treturn createGetterFunction(clientState, validator as StateSchemaValidatorToOpaque<T>);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/presence",
3
- "version": "2.81.1",
3
+ "version": "2.82.0",
4
4
  "description": "A component for lightweight data sharing within a single session",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -73,30 +73,30 @@
73
73
  "temp-directory": "nyc/.nyc_output"
74
74
  },
75
75
  "dependencies": {
76
- "@fluid-internal/client-utils": "~2.81.1",
77
- "@fluidframework/container-definitions": "~2.81.1",
78
- "@fluidframework/container-runtime-definitions": "~2.81.1",
79
- "@fluidframework/core-interfaces": "~2.81.1",
80
- "@fluidframework/core-utils": "~2.81.1",
81
- "@fluidframework/fluid-static": "~2.81.1",
82
- "@fluidframework/id-compressor": "~2.81.1",
83
- "@fluidframework/runtime-definitions": "~2.81.1",
84
- "@fluidframework/telemetry-utils": "~2.81.1"
76
+ "@fluid-internal/client-utils": "~2.82.0",
77
+ "@fluidframework/container-definitions": "~2.82.0",
78
+ "@fluidframework/container-runtime-definitions": "~2.82.0",
79
+ "@fluidframework/core-interfaces": "~2.82.0",
80
+ "@fluidframework/core-utils": "~2.82.0",
81
+ "@fluidframework/fluid-static": "~2.82.0",
82
+ "@fluidframework/id-compressor": "~2.82.0",
83
+ "@fluidframework/runtime-definitions": "~2.82.0",
84
+ "@fluidframework/telemetry-utils": "~2.82.0"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@arethetypeswrong/cli": "^0.18.2",
88
88
  "@biomejs/biome": "~1.9.3",
89
- "@fluid-internal/mocha-test-setup": "~2.81.1",
89
+ "@fluid-internal/mocha-test-setup": "~2.82.0",
90
90
  "@fluid-tools/build-cli": "^0.63.0",
91
91
  "@fluidframework/build-common": "^2.0.3",
92
92
  "@fluidframework/build-tools": "^0.63.0",
93
- "@fluidframework/driver-definitions": "~2.81.1",
94
- "@fluidframework/eslint-config-fluid": "~2.81.1",
95
- "@fluidframework/test-runtime-utils": "~2.81.1",
96
- "@fluidframework/test-utils": "~2.81.1",
93
+ "@fluidframework/driver-definitions": "~2.82.0",
94
+ "@fluidframework/eslint-config-fluid": "~2.82.0",
95
+ "@fluidframework/test-runtime-utils": "~2.82.0",
96
+ "@fluidframework/test-utils": "~2.82.0",
97
97
  "@microsoft/api-extractor": "7.52.11",
98
98
  "@types/mocha": "^10.0.10",
99
- "@types/node": "^18.19.0",
99
+ "@types/node": "~20.19.30",
100
100
  "@types/sinon": "^17.0.3",
101
101
  "c8": "^10.1.3",
102
102
  "concurrently": "^9.2.1",