@fluid-internal/presence-runtime 2.118.0 → 3.0.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 (126) hide show
  1. package/lib/packageVersion.d.ts +1 -1
  2. package/lib/packageVersion.d.ts.map +1 -1
  3. package/lib/packageVersion.js +1 -1
  4. package/lib/packageVersion.js.map +1 -1
  5. package/lib/runtime/extension/containerPresence.d.ts +1 -1
  6. package/lib/runtime/extension/containerPresence.d.ts.map +1 -1
  7. package/lib/runtime/extension/containerPresence.js +5 -3
  8. package/lib/runtime/extension/containerPresence.js.map +1 -1
  9. package/lib/runtime/presenceDatastoreManager.js +71 -37
  10. package/lib/runtime/presenceDatastoreManager.js.map +1 -1
  11. package/lib/runtime/presenceManager.js +13 -8
  12. package/lib/runtime/presenceManager.js.map +1 -1
  13. package/lib/runtime/systemWorkspace.js +20 -13
  14. package/lib/runtime/systemWorkspace.js.map +1 -1
  15. package/lib/states/latestMapValueManager.d.ts.map +1 -1
  16. package/lib/states/latestMapValueManager.js +12 -1
  17. package/lib/states/latestMapValueManager.js.map +1 -1
  18. package/lib/states/latestValueManager.js +6 -1
  19. package/lib/states/latestValueManager.js.map +1 -1
  20. package/lib/states/notificationsManager.js +34 -32
  21. package/lib/states/notificationsManager.js.map +1 -1
  22. package/lib/utils/broadcastControls.js +4 -0
  23. package/lib/utils/broadcastControls.js.map +1 -1
  24. package/lib/utils/internalUtils.d.ts.map +1 -1
  25. package/lib/utils/timerManager.js +4 -5
  26. package/lib/utils/timerManager.js.map +1 -1
  27. package/lib/workspace/presenceStates.js +6 -0
  28. package/lib/workspace/presenceStates.js.map +1 -1
  29. package/package.json +28 -60
  30. package/dist/package.json +0 -4
  31. package/dist/packageVersion.d.ts +0 -9
  32. package/dist/packageVersion.d.ts.map +0 -1
  33. package/dist/packageVersion.js +0 -12
  34. package/dist/packageVersion.js.map +0 -1
  35. package/dist/runtime/extension/containerPresence.d.ts +0 -53
  36. package/dist/runtime/extension/containerPresence.d.ts.map +0 -1
  37. package/dist/runtime/extension/containerPresence.js +0 -90
  38. package/dist/runtime/extension/containerPresence.js.map +0 -1
  39. package/dist/runtime/extension/index.d.ts +0 -6
  40. package/dist/runtime/extension/index.d.ts.map +0 -1
  41. package/dist/runtime/extension/index.js +0 -11
  42. package/dist/runtime/extension/index.js.map +0 -1
  43. package/dist/runtime/presenceDatastoreManager.d.ts +0 -146
  44. package/dist/runtime/presenceDatastoreManager.d.ts.map +0 -1
  45. package/dist/runtime/presenceDatastoreManager.js +0 -666
  46. package/dist/runtime/presenceDatastoreManager.js.map +0 -1
  47. package/dist/runtime/presenceManager.d.ts +0 -16
  48. package/dist/runtime/presenceManager.d.ts.map +0 -1
  49. package/dist/runtime/presenceManager.js +0 -140
  50. package/dist/runtime/presenceManager.js.map +0 -1
  51. package/dist/runtime/protocol.d.ts +0 -126
  52. package/dist/runtime/protocol.d.ts.map +0 -1
  53. package/dist/runtime/protocol.js +0 -20
  54. package/dist/runtime/protocol.js.map +0 -1
  55. package/dist/runtime/runtimeTypes.d.ts +0 -26
  56. package/dist/runtime/runtimeTypes.d.ts.map +0 -1
  57. package/dist/runtime/runtimeTypes.js +0 -7
  58. package/dist/runtime/runtimeTypes.js.map +0 -1
  59. package/dist/runtime/systemWorkspace.d.ts +0 -39
  60. package/dist/runtime/systemWorkspace.d.ts.map +0 -1
  61. package/dist/runtime/systemWorkspace.js +0 -264
  62. package/dist/runtime/systemWorkspace.js.map +0 -1
  63. package/dist/runtime/test.d.ts +0 -12
  64. package/dist/runtime/test.d.ts.map +0 -1
  65. package/dist/runtime/test.js +0 -15
  66. package/dist/runtime/test.js.map +0 -1
  67. package/dist/states/index.d.ts +0 -7
  68. package/dist/states/index.d.ts.map +0 -1
  69. package/dist/states/index.js +0 -12
  70. package/dist/states/index.js.map +0 -1
  71. package/dist/states/latestMapValueManager.d.ts +0 -10
  72. package/dist/states/latestMapValueManager.d.ts.map +0 -1
  73. package/dist/states/latestMapValueManager.js +0 -248
  74. package/dist/states/latestMapValueManager.js.map +0 -1
  75. package/dist/states/latestValueManager.d.ts +0 -10
  76. package/dist/states/latestValueManager.d.ts.map +0 -1
  77. package/dist/states/latestValueManager.js +0 -115
  78. package/dist/states/latestValueManager.js.map +0 -1
  79. package/dist/states/notificationsManager.d.ts +0 -26
  80. package/dist/states/notificationsManager.d.ts.map +0 -1
  81. package/dist/states/notificationsManager.js +0 -97
  82. package/dist/states/notificationsManager.js.map +0 -1
  83. package/dist/states/presence.d.ts +0 -11
  84. package/dist/states/presence.d.ts.map +0 -1
  85. package/dist/states/presence.js +0 -7
  86. package/dist/states/presence.js.map +0 -1
  87. package/dist/states/stateFactory.d.ts +0 -23
  88. package/dist/states/stateFactory.d.ts.map +0 -1
  89. package/dist/states/stateFactory.js +0 -27
  90. package/dist/states/stateFactory.js.map +0 -1
  91. package/dist/states/validatedGetter.d.ts +0 -18
  92. package/dist/states/validatedGetter.d.ts.map +0 -1
  93. package/dist/states/validatedGetter.js +0 -43
  94. package/dist/states/validatedGetter.js.map +0 -1
  95. package/dist/utils/broadcastControls.d.ts +0 -37
  96. package/dist/utils/broadcastControls.d.ts.map +0 -1
  97. package/dist/utils/broadcastControls.js +0 -60
  98. package/dist/utils/broadcastControls.js.map +0 -1
  99. package/dist/utils/index.d.ts +0 -9
  100. package/dist/utils/index.d.ts.map +0 -1
  101. package/dist/utils/index.js +0 -26
  102. package/dist/utils/index.js.map +0 -1
  103. package/dist/utils/internalUtils.d.ts +0 -125
  104. package/dist/utils/internalUtils.d.ts.map +0 -1
  105. package/dist/utils/internalUtils.js +0 -99
  106. package/dist/utils/internalUtils.js.map +0 -1
  107. package/dist/utils/timerManager.d.ts +0 -37
  108. package/dist/utils/timerManager.d.ts.map +0 -1
  109. package/dist/utils/timerManager.js +0 -65
  110. package/dist/utils/timerManager.js.map +0 -1
  111. package/dist/utils/valueManager.d.ts +0 -14
  112. package/dist/utils/valueManager.d.ts.map +0 -1
  113. package/dist/utils/valueManager.js +0 -22
  114. package/dist/utils/valueManager.js.map +0 -1
  115. package/dist/workspace/index.d.ts +0 -7
  116. package/dist/workspace/index.d.ts.map +0 -1
  117. package/dist/workspace/index.js +0 -14
  118. package/dist/workspace/index.js.map +0 -1
  119. package/dist/workspace/presenceStates.d.ts +0 -61
  120. package/dist/workspace/presenceStates.d.ts.map +0 -1
  121. package/dist/workspace/presenceStates.js +0 -235
  122. package/dist/workspace/presenceStates.js.map +0 -1
  123. package/dist/workspace/stateDatastore.d.ts +0 -17
  124. package/dist/workspace/stateDatastore.d.ts.map +0 -1
  125. package/dist/workspace/stateDatastore.js +0 -24
  126. package/dist/workspace/stateDatastore.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestMapValueManager.js","sourceRoot":"","sources":["../../src/states/latestMapValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAiC7D,kEASgD;AAChD,0EAAiF;AAGjF,6DAA6D;AAkB7D,MAAM,YAAY;IAEjB,YACkB,KAAwC,EACxC,OAEhB,EACgB,WAMR;QAVQ,UAAK,GAAL,KAAK,CAAmC;QACxC,YAAO,GAAP,OAAO,CAEvB;QACgB,gBAAW,GAAX,WAAW,CAMnB;QAET,gDAAgD;QAChD,8CAA8C;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IACrD,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,GAAM,EAAE,KAAmD;QAC7E,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QACpB,2CAA2C;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE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B,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,gBAAQ,EAKhB,IAAI,yBAAyB,CAC5B,GAAG,EACH,IAAA,+BAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,CACV,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AA7DW,QAAA,SAAS,aA6DpB","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 {\n\tAttendee,\n\tAttendeeId,\n\tBroadcastControlSettings,\n\tKeySchemaValidator,\n\tLatestData,\n\tLatestMap,\n\tLatestMapArguments,\n\tLatestMapClientData,\n\tLatestMapEvents,\n\tLatestMapFactory,\n\tLatestMapItemUpdatedClientData,\n\tLatestMapRaw,\n\tPresence,\n\tStateMap,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"@fluid-internal/presence-definitions\";\nimport type {\n\tInternalTypes,\n\tPostUpdateAction,\n\tValidatableOptionalState,\n\tValueManager,\n} from \"@fluid-internal/presence-definitions/internal\";\nimport type { StateDatastore } from \"@fluid-internal/presence-definitions/internal/workspace-states\";\nimport type { IEmitter } from \"@fluidframework/core-interfaces/internal\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport {\n\tasDeeplyReadonly,\n\tasDeeplyReadonlyDeserializedJson,\n\tbrandIVM,\n\tisValueRequiredState,\n\tobjectEntries,\n\tobjectKeys,\n\tOptionalBroadcastControl,\n\ttoOpaqueJson,\n} from \"@fluid-internal/presence-runtime/utils\";\nimport { datastoreFromHandle } from \"@fluid-internal/presence-runtime/workspace\";\n\nimport type { SpecificAttendee } from \"./presence.js\";\nimport { createValidatedGetter } from \"./validatedGetter.js\";\n\n/**\n * Collection of validatable optional values in a \"map\" structure.\n *\n * @remarks\n * Validatable equivalent of {@link InternalTypes.MapValueState}.\n */\ninterface ValidatableMapValueState<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 in string]: ValidatableOptionalState<T>;\n\t};\n}\n\nclass ValueMapImpl<T, K extends string> implements StateMap<K, T> {\n\tprivate countDefined: number;\n\tpublic constructor(\n\t\tprivate readonly value: InternalTypes.MapValueState<T, K>,\n\t\tprivate readonly emitter: IEmitter<\n\t\t\tPick<LatestMapEvents<T, K, ValueAccessor<T>>, \"localItemUpdated\" | \"localItemRemoved\">\n\t\t>,\n\t\tprivate readonly localUpdate: (\n\t\t\tupdates: InternalTypes.MapValueState<\n\t\t\t\tT,\n\t\t\t\t// This should be `K`, but will only work if properties are optional.\n\t\t\t\tstring\n\t\t\t>,\n\t\t) => void,\n\t) {\n\t\t// All initial items are expected to be defined.\n\t\t// TODO assert all defined and/or update type.\n\t\tthis.countDefined = Object.keys(value.items).length;\n\t}\n\n\t/**\n\t * Note: caller must ensure key exists in this.value.items.\n\t */\n\tprivate updateItem(key: K, value: InternalTypes.ValueOptionalState<T>[\"value\"]): void {\n\t\tthis.value.rev += 1;\n\t\t// Caller is required to ensure key exists.\n\t\tconst item = this.value.items[key];\n\t\titem.rev += 1;\n\t\titem.timestamp = Date.now();\n\t\tif (value === undefined) {\n\t\t\tdelete item.value;\n\t\t} else {\n\t\t\titem.value = value;\n\t\t}\n\t\tconst update = { rev: this.value.rev, items: { [key]: item } };\n\t\tthis.localUpdate(update);\n\t}\n\n\tpublic clear(): void {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\tpublic delete(key: K): boolean {\n\t\tconst { items } = this.value;\n\t\tconst hasKey = items[key]?.value !== undefined;\n\t\tif (hasKey) {\n\t\t\tthis.countDefined -= 1;\n\t\t\tthis.updateItem(key, undefined);\n\t\t\tthis.emitter.emit(\"localItemRemoved\", { key });\n\t\t}\n\t\treturn hasKey;\n\t}\n\tpublic forEach(\n\t\tcallbackfn: (\n\t\t\tvalue: DeepReadonly<JsonDeserialized<T>>,\n\t\t\tkey: K,\n\t\t\tmap: StateMap<K, T>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void {\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tcallbackfn(asDeeplyReadonlyDeserializedJson(item.value), key as unknown as K, this);\n\t\t\t}\n\t\t}\n\t}\n\tpublic get(key: K): DeepReadonly<JsonDeserialized<T>> | undefined {\n\t\treturn asDeeplyReadonlyDeserializedJson(this.value.items[key]?.value);\n\t}\n\tpublic has(key: K): boolean {\n\t\treturn this.value.items[key]?.value !== undefined;\n\t}\n\tpublic set(key: K, inValue: JsonSerializable<T>): this {\n\t\tconst value = toOpaqueJson<T>(inValue);\n\t\tif (!(key in this.value.items)) {\n\t\t\tthis.countDefined += 1;\n\t\t\tthis.value.items[key] = { rev: 0, timestamp: 0, value };\n\t\t}\n\t\tthis.updateItem(key, value);\n\t\tthis.emitter.emit(\"localItemUpdated\", { key, value: asDeeplyReadonly(inValue) });\n\t\treturn this;\n\t}\n\tpublic get size(): number {\n\t\treturn this.countDefined;\n\t}\n\tpublic keys(): IterableIterator<K> {\n\t\tconst keys: K[] = [];\n\t\tfor (const [key, item] of objectEntries(this.value.items)) {\n\t\t\tif (item.value !== undefined) {\n\t\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\t\tkeys.push(key as unknown as K);\n\t\t\t}\n\t\t}\n\t\treturn keys[Symbol.iterator]();\n\t}\n}\n\n/**\n * Simply returns true for all given string keys.\n */\nfunction anyKeyIsValid<Keys extends string>(unvalidatedKey: string): unvalidatedKey is Keys {\n\treturn true;\n}\n\nclass LatestMapValueManagerImpl<\n\tT,\n\tRegistrationKey extends string,\n\tKeys extends string = string,\n> implements\n\t\tLatestMapRaw<T, Keys>,\n\t\tLatestMap<T, Keys>,\n\t\tRequired<ValueManager<T, InternalTypes.MapValueState<T, Keys>>>\n{\n\tpublic readonly events = createEmitter<LatestMapEvents<T, Keys, ValueAccessor<T>>>();\n\tpublic readonly controls: OptionalBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly key: RegistrationKey,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>,\n\t\t\tValidatableMapValueState<T>\n\t\t>,\n\t\tpublic readonly value: InternalTypes.MapValueState<T, Keys>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\n\t\tprivate readonly validator: StateSchemaValidator<T> | undefined,\n\t\tprivate readonly isValidKey: KeySchemaValidator<Keys>,\n\t) {\n\t\tthis.controls = new OptionalBroadcastControl(controlSettings);\n\n\t\tthis.local = new ValueMapImpl<T, Keys>(\n\t\t\tvalue,\n\t\t\tthis.events,\n\t\t\t(updates: InternalTypes.MapValueState<T, Keys>) => {\n\t\t\t\tdatastore.localUpdate(key, updates, {\n\t\t\t\t\tallowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,\n\t\t\t\t});\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 readonly local: StateMap<Keys, T>;\n\n\tpublic *getRemotes(): IterableIterator<LatestMapClientData<T, Keys, ValueAccessor<T>>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const attendeeId of objectKeys(allKnownStates.states)) {\n\t\t\tif (attendeeId !== allKnownStates.self) {\n\t\t\t\tconst attendee = this.datastore.presence.attendees.getAttendee(attendeeId);\n\t\t\t\tconst items = this.getRemote(attendee);\n\t\t\t\tyield { attendee, items };\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getStateAttendees(): Attendee[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn objectKeys(allKnownStates.states)\n\t\t\t.filter((attendeeId) => attendeeId !== allKnownStates.self)\n\t\t\t.map((attendeeId) => this.datastore.presence.attendees.getAttendee(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T, ValueAccessor<T>>> {\n\t\tconst validator = this.validator;\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId = attendee.attendeeId;\n\t\tconst clientStateMap = allKnownStates.states[attendeeId];\n\t\tif (clientStateMap === undefined) {\n\t\t\tthrow new Error(\"No entry for attendee\");\n\t\t}\n\t\tconst items = new Map<Keys, LatestData<T, ValueAccessor<T>>>();\n\t\tfor (const [key, item] of objectEntries(clientStateMap.items)) {\n\t\t\tif (this.isValidKey(key) && isValueRequiredState(item)) {\n\t\t\t\titems.set(key, {\n\t\t\t\t\tvalue: createValidatedGetter(item, validator),\n\t\t\t\t\tmetadata: { revision: item.rev, timestamp: item.timestamp },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\tpublic update<SpecificAttendeeId extends AttendeeId>(\n\t\tattendee: SpecificAttendee<SpecificAttendeeId>,\n\t\t_received: number,\n\t\tvalue: InternalTypes.MapValueState<T, string>,\n\t): PostUpdateAction[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId: SpecificAttendeeId = attendee.attendeeId;\n\t\tconst currentState = (allKnownStates.states[attendeeId] ??=\n\t\t\t// New attendee - prepare new attendee state directory\n\t\t\t{\n\t\t\t\trev: value.rev,\n\t\t\t\titems: {},\n\t\t\t});\n\t\t// Accumulate individual update keys\n\t\tconst updatedKeyItemPairs: [string, InternalTypes.ValueOptionalState<T>][] = [];\n\t\tfor (const [key, item] of objectEntries(value.items)) {\n\t\t\tconst currentItem = currentState.items[key];\n\t\t\tif (currentItem === undefined || currentItem.rev < item.rev) {\n\t\t\t\tupdatedKeyItemPairs.push([key, item]);\n\t\t\t}\n\t\t}\n\n\t\tif (updatedKeyItemPairs.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Store updates\n\t\tif (value.rev > currentState.rev) {\n\t\t\tcurrentState.rev = value.rev;\n\t\t}\n\t\tconst allUpdates = {\n\t\t\tattendee,\n\t\t\titems: new Map<Keys, LatestData<T, ValueAccessor<T>>>(),\n\t\t};\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [key, item] of updatedKeyItemPairs) {\n\t\t\tconst hadPriorValue = currentState.items[key]?.value;\n\t\t\tcurrentState.items[key] = item;\n\n\t\t\t// Prepare update events, but only for valid keys.\n\t\t\tif (!this.isValidKey(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst metadata = {\n\t\t\t\trevision: item.rev,\n\t\t\t\ttimestamp: item.timestamp,\n\t\t\t};\n\t\t\tif (isValueRequiredState(item)) {\n\t\t\t\tconst updatedItem = {\n\t\t\t\t\tattendee,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: createValidatedGetter(item, this.validator),\n\t\t\t\t\tmetadata,\n\t\t\t\t} satisfies LatestMapItemUpdatedClientData<T, Keys, ValueAccessor<T>>;\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteItemUpdated\", updatedItem));\n\t\t\t\tallUpdates.items.set(key, {\n\t\t\t\t\tvalue: updatedItem.value,\n\t\t\t\t\tmetadata,\n\t\t\t\t});\n\t\t\t} else if (hadPriorValue !== undefined) {\n\t\t\t\tpostUpdateActions.push(() =>\n\t\t\t\t\tthis.events.emit(\"remoteItemRemoved\", {\n\t\t\t\t\t\tattendee,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tmetadata,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis.datastore.update(this.key, attendeeId, currentState);\n\t\t// Only emit remoteUpdated if there are any individual updates, which\n\t\t// accounts for the case where all updates were for invalid keys.\n\t\tif (postUpdateActions.length > 0) {\n\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteUpdated\", allUpdates));\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link LatestMap} or {@link LatestMapRaw} State object.\n */\nexport const latestMap: LatestMapFactory = <\n\tT,\n\tKeys extends string = string,\n\tRegistrationKey extends string = string,\n>(\n\targs?: Partial<LatestMapArguments<T, Keys>>,\n): InternalTypes.ManagerFactory<\n\tRegistrationKey,\n\tInternalTypes.MapValueState<T, Keys>,\n\tLatestMapRaw<T, Keys> & LatestMap<T, Keys>\n> => {\n\tconst settings = args?.settings;\n\tconst initialValues = args?.local;\n\tconst validator = args?.validator;\n\tconst isKeyValid = args?.keyValidator ?? anyKeyIsValid;\n\n\tconst timestamp = Date.now();\n\tconst value: InternalTypes.MapValueState<\n\t\tT,\n\t\t// This should be `Keys`, but will only work if properties are optional.\n\t\tstring\n\t> = { rev: 0, items: {} };\n\t// LatestMapRaw takes ownership of values within initialValues.\n\tif (initialValues !== undefined) {\n\t\tfor (const [key, item] of objectEntries(initialValues)) {\n\t\t\t// TODO: AB#55932: try fixing typing of objectEntries to avoid this cast\n\t\t\tconst assumedValidKey = key as unknown as Keys;\n\t\t\tvalue.items[assumedValidKey] = {\n\t\t\t\trev: 0,\n\t\t\t\ttimestamp,\n\t\t\t\tvalue: toOpaqueJson(item),\n\t\t\t};\n\t\t}\n\t}\n\tconst factory = (\n\t\tkey: RegistrationKey,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tRegistrationKey,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>,\n\t): {\n\t\tinitialData: { value: typeof value; allowableUpdateLatencyMs: number | undefined };\n\t\tmanager: InternalTypes.StateValue<LatestMapRaw<T, Keys> & LatestMap<T, Keys>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<\n\t\t\tLatestMapValueManagerImpl<T, RegistrationKey, Keys>,\n\t\t\tT,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>(\n\t\t\tnew LatestMapValueManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tvalue,\n\t\t\t\tsettings,\n\t\t\t\tvalidator,\n\t\t\t\tisKeyValid,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestMapValueManagerImpl });\n};\n"]}
@@ -1,10 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { LatestFactory } from "@fluid-internal/presence-definitions";
6
- /**
7
- * Factory for creating a {@link Latest} or {@link LatestRaw} State object.
8
- */
9
- export declare const latest: LatestFactory;
10
- //# sourceMappingURL=latestValueManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueManager.d.ts","sourceRoot":"","sources":["../../src/states/latestValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EASX,aAAa,EAKb,MAAM,sCAAsC,CAAC;AAqI9C;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,aAsCpB,CAAC"}
@@ -1,115 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.latest = void 0;
8
- const client_utils_1 = require("@fluid-internal/client-utils");
9
- const internal_1 = require("@fluidframework/core-utils/internal");
10
- const utils_1 = require("@fluid-internal/presence-runtime/utils");
11
- const workspace_1 = require("@fluid-internal/presence-runtime/workspace");
12
- const validatedGetter_js_1 = require("./validatedGetter.js");
13
- class LatestValueManagerImpl {
14
- constructor(key, datastore, value, controlSettings, validator) {
15
- this.key = key;
16
- this.datastore = datastore;
17
- this.value = value;
18
- this.validator = validator;
19
- this.events = (0, client_utils_1.createEmitter)();
20
- this.controls = new utils_1.OptionalBroadcastControl(controlSettings);
21
- }
22
- get presence() {
23
- return this.datastore.presence;
24
- }
25
- get local() {
26
- return (0, utils_1.asDeeplyReadonlyDeserializedJson)(this.value.value);
27
- }
28
- set local(value) {
29
- this.value.rev += 1;
30
- this.value.timestamp = Date.now();
31
- this.value.value = (0, utils_1.toOpaqueJson)(value);
32
- this.datastore.localUpdate(this.key, this.value, {
33
- allowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,
34
- });
35
- this.events.emit("localUpdated", { value: (0, utils_1.asDeeplyReadonly)(value) });
36
- }
37
- *getRemotes() {
38
- const allKnownStates = this.datastore.knownValues(this.key);
39
- for (const [attendeeId, clientState] of (0, utils_1.objectEntries)(allKnownStates.states)) {
40
- if (attendeeId !== allKnownStates.self) {
41
- yield {
42
- attendee: this.datastore.presence.attendees.getAttendee(attendeeId),
43
- value: (0, validatedGetter_js_1.createValidatedGetter)(clientState, this.validator),
44
- metadata: {
45
- revision: clientState.rev,
46
- timestamp: clientState.timestamp,
47
- },
48
- };
49
- }
50
- }
51
- }
52
- getStateAttendees() {
53
- const allKnownStates = this.datastore.knownValues(this.key);
54
- return Object.keys(allKnownStates.states)
55
- .filter((attendeeId) => attendeeId !== allKnownStates.self)
56
- .map((attendeeId) => this.datastore.presence.attendees.getAttendee(attendeeId));
57
- }
58
- getRemote(attendee) {
59
- const allKnownStates = this.datastore.knownValues(this.key);
60
- const clientState = allKnownStates.states[attendee.attendeeId];
61
- if (clientState === undefined) {
62
- throw new Error("No entry for attendee");
63
- }
64
- return {
65
- value: (0, validatedGetter_js_1.createValidatedGetter)(clientState, this.validator),
66
- metadata: { revision: clientState.rev, timestamp: Date.now() },
67
- };
68
- }
69
- update(attendee, _received, value) {
70
- const allKnownStates = this.datastore.knownValues(this.key);
71
- const attendeeId = attendee.attendeeId;
72
- const currentState = allKnownStates.states[attendeeId];
73
- if (currentState !== undefined && currentState.rev >= value.rev) {
74
- return [];
75
- }
76
- this.datastore.update(this.key, attendeeId, value);
77
- return [
78
- () => this.events.emit("remoteUpdated", {
79
- attendee,
80
- value: (0, validatedGetter_js_1.createValidatedGetter)(value, this.validator),
81
- metadata: { revision: value.rev, timestamp: value.timestamp },
82
- }),
83
- ];
84
- }
85
- }
86
- /**
87
- * Shallow clone an object that might be null.
88
- *
89
- * @param value - The object to clone
90
- * @returns A shallow clone of the input value
91
- */
92
- function shallowCloneNullableObject(value) {
93
- return value === null ? value : (0, internal_1.shallowCloneObject)(value);
94
- }
95
- /**
96
- * Factory for creating a {@link Latest} or {@link LatestRaw} State object.
97
- */
98
- const latest = (args) => {
99
- const { local, settings, validator } = args;
100
- // Latest takes ownership of the initial local value but makes a shallow
101
- // copy for basic protection.
102
- const opaqueLocal = (0, utils_1.toOpaqueJson)(local);
103
- const value = {
104
- rev: 0,
105
- timestamp: Date.now(),
106
- value: shallowCloneNullableObject(opaqueLocal),
107
- };
108
- const factory = (key, datastoreHandle) => ({
109
- initialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },
110
- manager: (0, utils_1.brandIVM)(new LatestValueManagerImpl(key, (0, workspace_1.datastoreFromHandle)(datastoreHandle), value, settings, validator)),
111
- });
112
- return Object.assign(factory, { instanceBase: LatestValueManagerImpl });
113
- };
114
- exports.latest = latest;
115
- //# sourceMappingURL=latestValueManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueManager.js","sourceRoot":"","sources":["../../src/states/latestValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AA2B7D,kEAAyE;AAGzE,kEAOgD;AAChD,0EAAiF;AAEjF,6DAA6D;AAE7D,MAAM,sBAAsB;IAS3B,YACkB,GAAQ,EACR,SAAmE,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AY,EAAI,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAwC;QAClD,GAAG,EAAE,CAAC;QACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK,EAAE,0BAA0B,CAAC,WAAW,CAAC;KAC9C,CAAC;IACF,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,gBAAQ,EAChB,IAAI,sBAAsB,CACzB,GAAG,EACH,IAAA,+BAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,SAAS,CACT,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACzE,CAAC,CAAC;AAtCW,QAAA,MAAM,UAsCjB","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 {\n\tAttendee,\n\tBroadcastControlSettings,\n\tLatest,\n\tLatestArguments,\n\tLatestArgumentsRaw,\n\tLatestClientData,\n\tLatestData,\n\tLatestEvents,\n\tLatestFactory,\n\tLatestRaw,\n\tPresence,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"@fluid-internal/presence-definitions\";\nimport type {\n\tInternalTypes,\n\tPostUpdateAction,\n\tValueManager,\n} from \"@fluid-internal/presence-definitions/internal\";\nimport type { StateDatastore } from \"@fluid-internal/presence-definitions/internal/workspace-states\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\nimport { shallowCloneObject } from \"@fluidframework/core-utils/internal\";\n\nimport type { FlattenUnionWithOptionals } from \"@fluid-internal/presence-runtime/utils\";\nimport {\n\tasDeeplyReadonly,\n\tasDeeplyReadonlyDeserializedJson,\n\tbrandIVM,\n\tobjectEntries,\n\tOptionalBroadcastControl,\n\ttoOpaqueJson,\n} from \"@fluid-internal/presence-runtime/utils\";\nimport { datastoreFromHandle } from \"@fluid-internal/presence-runtime/workspace\";\n\nimport { createValidatedGetter } from \"./validatedGetter.js\";\n\nclass LatestValueManagerImpl<T, Key extends string>\n\timplements\n\t\tLatestRaw<T>,\n\t\tLatest<T>,\n\t\tRequired<ValueManager<T, InternalTypes.ValueRequiredState<T>>>\n{\n\tpublic readonly events = createEmitter<LatestEvents<T, ValueAccessor<T>>>();\n\tpublic readonly controls: OptionalBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<Key, InternalTypes.ValueRequiredState<T>>,\n\t\tpublic readonly value: InternalTypes.ValueRequiredState<T>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\n\t\tprivate readonly validator: StateSchemaValidator<T> | undefined,\n\t) {\n\t\tthis.controls = new OptionalBroadcastControl(controlSettings);\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic get local(): DeepReadonly<JsonDeserialized<T>> {\n\t\treturn asDeeplyReadonlyDeserializedJson(this.value.value);\n\t}\n\n\tpublic set local(value: JsonSerializable<T>) {\n\t\tthis.value.rev += 1;\n\t\tthis.value.timestamp = Date.now();\n\t\tthis.value.value = toOpaqueJson<T>(value);\n\t\tthis.datastore.localUpdate(this.key, this.value, {\n\t\t\tallowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,\n\t\t});\n\n\t\tthis.events.emit(\"localUpdated\", { value: asDeeplyReadonly(value) });\n\t}\n\n\tpublic *getRemotes(): IterableIterator<LatestClientData<T, ValueAccessor<T>>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const [attendeeId, clientState] of objectEntries(allKnownStates.states)) {\n\t\t\tif (attendeeId !== allKnownStates.self) {\n\t\t\t\tyield {\n\t\t\t\t\tattendee: this.datastore.presence.attendees.getAttendee(attendeeId),\n\t\t\t\t\tvalue: createValidatedGetter(clientState, this.validator),\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\trevision: clientState.rev,\n\t\t\t\t\t\ttimestamp: clientState.timestamp,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic getStateAttendees(): Attendee[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn Object.keys(allKnownStates.states)\n\t\t\t.filter((attendeeId) => attendeeId !== allKnownStates.self)\n\t\t\t.map((attendeeId) => this.datastore.presence.attendees.getAttendee(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): LatestData<T, ValueAccessor<T>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst clientState = allKnownStates.states[attendee.attendeeId];\n\t\tif (clientState === undefined) {\n\t\t\tthrow new Error(\"No entry for attendee\");\n\t\t}\n\t\treturn {\n\t\t\tvalue: createValidatedGetter(clientState, this.validator),\n\t\t\tmetadata: { revision: clientState.rev, timestamp: Date.now() },\n\t\t};\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tvalue: InternalTypes.ValueRequiredState<T>,\n\t): PostUpdateAction[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst attendeeId = attendee.attendeeId;\n\t\tconst currentState = allKnownStates.states[attendeeId];\n\t\tif (currentState !== undefined && currentState.rev >= value.rev) {\n\t\t\treturn [];\n\t\t}\n\t\tthis.datastore.update(this.key, attendeeId, value);\n\t\treturn [\n\t\t\t() =>\n\t\t\t\tthis.events.emit(\"remoteUpdated\", {\n\t\t\t\t\tattendee,\n\t\t\t\t\tvalue: createValidatedGetter(value, this.validator),\n\t\t\t\t\tmetadata: { revision: value.rev, timestamp: value.timestamp },\n\t\t\t\t}),\n\t\t];\n\t}\n}\n\n/**\n * Shallow clone an object that might be null.\n *\n * @param value - The object to clone\n * @returns A shallow clone of the input value\n */\nfunction shallowCloneNullableObject<T extends object | null>(value: T): T {\n\treturn value === null ? value : shallowCloneObject(value);\n}\n\n/**\n * Factory for creating a {@link Latest} or {@link LatestRaw} State object.\n */\nexport const latest: LatestFactory = <T extends object | null, Key extends string = string>(\n\targs: FlattenUnionWithOptionals<LatestArguments<T> | LatestArgumentsRaw<T>>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<T>,\n\tLatestRaw<T> & Latest<T>\n> => {\n\tconst { local, settings, validator } = args;\n\t// Latest takes ownership of the initial local value but makes a shallow\n\t// copy for basic protection.\n\tconst opaqueLocal = toOpaqueJson<T>(local);\n\tconst value: InternalTypes.ValueRequiredState<T> = {\n\t\trev: 0,\n\t\ttimestamp: Date.now(),\n\t\tvalue: shallowCloneNullableObject(opaqueLocal),\n\t};\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<T>\n\t\t>,\n\t): {\n\t\tinitialData: { value: typeof value; allowableUpdateLatencyMs: number | undefined };\n\t\tmanager: InternalTypes.StateValue<LatestRaw<T> & Latest<T>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<LatestValueManagerImpl<T, Key>, T, InternalTypes.ValueRequiredState<T>>(\n\t\t\tnew LatestValueManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tvalue,\n\t\t\t\tsettings,\n\t\t\t\tvalidator,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestValueManagerImpl });\n};\n"]}
@@ -1,26 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { InternalPresenceUtilityTypes, NotificationsConfiguration, NotificationSubscriberSignatures, NotificationsWithSubscriptionsConfiguration } from "@fluid-internal/presence-definitions";
6
- /**
7
- * Factory for creating a {@link @fluid-internal/presence-definitions#NotificationsManager}.
8
- *
9
- * @alpha
10
- *
11
- * @privateRemarks
12
- * This overload requires explicit specification of the notification listener
13
- * types. It is useful when a schema is separately defined.
14
- */
15
- export declare function Notifications<T extends InternalPresenceUtilityTypes.NotificationListeners<T>, Key extends string = string>(initialSubscriptions: Partial<NotificationSubscriberSignatures<T>>): NotificationsConfiguration<T, Key>;
16
- /**
17
- * Factory for creating a {@link @fluid-internal/presence-definitions#NotificationsManager}.
18
- *
19
- * @alpha
20
- *
21
- * @privateRemarks
22
- * This overload infers the notification listener types from the provided
23
- * subscriptions, simplifying usage when a schema is not separately defined.
24
- */
25
- export declare function Notifications<TSubscriptions extends InternalPresenceUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>, Key extends string = string>(initialSubscriptions: Partial<TSubscriptions>): NotificationsWithSubscriptionsConfiguration<TSubscriptions, Key>;
26
- //# sourceMappingURL=notificationsManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../../src/states/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAEX,4BAA4B,EAG5B,0BAA0B,EAG1B,gCAAgC,EAChC,2CAA2C,EAE3C,MAAM,sCAAsC,CAAC;AA+H9C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,CAAC,SAAS,4BAA4B,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAC/D,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,GAChE,0BAA0B,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,cAAc,SACb,4BAA4B,CAAC,6CAA6C,CAAC,cAAc,CAAC,EAC3F,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,cAAc,CAAC,GAC3C,2CAA2C,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC"}
@@ -1,97 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Notifications = void 0;
8
- const client_utils_1 = require("@fluid-internal/client-utils");
9
- const utils_1 = require("@fluid-internal/presence-runtime/utils");
10
- const workspace_1 = require("@fluid-internal/presence-runtime/workspace");
11
- /**
12
- * Object.keys retyped to support specific records keys and
13
- * branded string-based keys.
14
- */
15
- const recordKeys = Object.keys;
16
- class NotificationsManagerImpl {
17
- constructor(key, datastore, initialSubscriptions) {
18
- this.key = key;
19
- this.datastore = datastore;
20
- this.events = (0, client_utils_1.createEmitter)();
21
- this.emit = {
22
- broadcast: (name, ...args) => {
23
- this.datastore.localUpdate(this.key, {
24
- rev: 0,
25
- timestamp: 0,
26
- value: (0, utils_1.toOpaqueJson)({
27
- name,
28
- args: [...args],
29
- }),
30
- ignoreUnmonitored: true,
31
- },
32
- // This is a notification, so we want to send it immediately.
33
- { allowableUpdateLatencyMs: 0 });
34
- },
35
- unicast: (name, targetAttendee, ...args) => {
36
- this.datastore.localUpdate(this.key, {
37
- rev: 0,
38
- timestamp: 0,
39
- value: (0, utils_1.toOpaqueJson)({
40
- name,
41
- args: [...args],
42
- }),
43
- ignoreUnmonitored: true,
44
- },
45
- // This is a notification, so we want to send it immediately.
46
- { allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() });
47
- },
48
- };
49
- // Workaround for types
50
- this.notificationsInternal = (0, client_utils_1.createEmitter)();
51
- this.notifications = this.notificationsInternal;
52
- // Add event listeners provided at instantiation
53
- for (const subscriptionName of recordKeys(initialSubscriptions)) {
54
- // Lingering Event typing issues with Notifications specialization requires
55
- // this cast. The only thing that really matters is that name is a string.
56
- const name = subscriptionName;
57
- const value = initialSubscriptions[subscriptionName];
58
- // This check should not be needed while using exactOptionalPropertyTypes, but
59
- // typescript appears to ignore that with Partial<>. Good to be defensive
60
- // against callers sending `undefined` anyway.
61
- if (value !== undefined) {
62
- this.notificationsInternal.on(name, value);
63
- }
64
- }
65
- }
66
- get presence() {
67
- return this.datastore.presence;
68
- }
69
- update(attendee, _received, updateValue) {
70
- const postUpdateActions = [];
71
- const value = (0, utils_1.revealOpaqueJson)(updateValue.value);
72
- const eventName = value.name;
73
- if (this.notificationsInternal.hasListeners(eventName)) {
74
- // Without schema validation, we don't know that the args are the correct type.
75
- // For now we assume the user is sending the correct types and there is no corruption along the way.
76
- const args = [attendee, ...value.args];
77
- postUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));
78
- }
79
- else {
80
- postUpdateActions.push(() => this.events.emit("unattendedNotification", value.name, attendee, ...value.args));
81
- }
82
- return postUpdateActions;
83
- }
84
- }
85
- /**
86
- * Factory for creating a {@link @fluid-internal/presence-definitions#NotificationsManager}.
87
- *
88
- * @alpha
89
- */
90
- function Notifications(initialSubscriptions) {
91
- const factory = (key, datastoreHandle) => ({
92
- manager: (0, utils_1.brandIVM)(new NotificationsManagerImpl(key, (0, workspace_1.datastoreFromHandle)(datastoreHandle), initialSubscriptions)),
93
- });
94
- return Object.assign(factory, { instanceBase: NotificationsManagerImpl });
95
- }
96
- exports.Notifications = Notifications;
97
- //# sourceMappingURL=notificationsManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notificationsManager.js","sourceRoot":"","sources":["../../src/states/notificationsManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAsB7D,kEAIgD;AAChD,0EAAiF;AAEjF;;;GAGG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAiE,CAAC;AAE5F,MA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B,aAAa,CAM5B,oBAA6C;IAM7C,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAGA,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,IAAA,gBAAQ,EAKhB,IAAI,wBAAwB,CAC3B,GAAG,EACH,IAAA,+BAAmB,EAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC;AAlCD,sCAkCC","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 {\n\tAttendee,\n\tInternalPresenceUtilityTypes,\n\tNotificationEmitter,\n\tNotificationListenable,\n\tNotificationsConfiguration,\n\tNotificationsManager,\n\tNotificationsManagerEvents,\n\tNotificationSubscriberSignatures,\n\tNotificationsWithSubscriptionsConfiguration,\n\tPresenceWithNotifications as Presence,\n} from \"@fluid-internal/presence-definitions\";\nimport type {\n\tInternalTypes,\n\tPostUpdateAction,\n\tValueManager,\n} from \"@fluid-internal/presence-definitions/internal\";\nimport type { StateDatastore } from \"@fluid-internal/presence-definitions/internal/workspace-states\";\nimport type { Listeners } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport {\n\tbrandIVM,\n\trevealOpaqueJson,\n\ttoOpaqueJson,\n} from \"@fluid-internal/presence-runtime/utils\";\nimport { datastoreFromHandle } from \"@fluid-internal/presence-runtime/workspace\";\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 InternalPresenceUtilityTypes.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 @fluid-internal/presence-definitions#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 InternalPresenceUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriberSignatures<T>>,\n): NotificationsConfiguration<T, Key>;\n\n/**\n * Factory for creating a {@link @fluid-internal/presence-definitions#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\tInternalPresenceUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<TSubscriptions>,\n): NotificationsWithSubscriptionsConfiguration<TSubscriptions, Key>;\n\n/**\n * Factory for creating a {@link @fluid-internal/presence-definitions#NotificationsManager}.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalPresenceUtilityTypes.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"]}
@@ -1,11 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { Attendee, AttendeeId } from "@fluid-internal/presence-definitions";
6
- /**
7
- * Utility type limiting to a specific attendee. (An attendee with
8
- * a specific session ID - not just any session ID.)
9
- */
10
- export type SpecificAttendee<SpecificAttendeeId extends AttendeeId> = string extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;
11
- //# sourceMappingURL=presence.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/states/presence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,kBAAkB,SAAS,UAAU,IACjE,MAAM,SAAS,kBAAkB,GAAG,KAAK,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC"}
@@ -1,7 +0,0 @@
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=presence.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/states/presence.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 { Attendee, AttendeeId } from \"@fluid-internal/presence-definitions\";\n\n/**\n * Utility type limiting to a specific attendee. (An attendee with\n * a specific session ID - not just any session ID.)\n */\nexport type SpecificAttendee<SpecificAttendeeId extends AttendeeId> =\n\tstring extends SpecificAttendeeId ? never : Attendee<SpecificAttendeeId>;\n"]}
@@ -1,23 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { LatestFactory, LatestMapFactory } from "@fluid-internal/presence-definitions";
6
- /**
7
- * Factory for creating presence State objects.
8
- *
9
- * @remarks
10
- * Use `latest` to create a {@link @fluidframework/presence#Latest} or {@link @fluidframework/presence#LatestRaw} State object.
11
- * Use `latestMap` to create a {@link @fluidframework/presence#LatestMap} or {@link @fluidframework/presence#LatestMapRaw} State object.
12
- *
13
- * @public
14
- *
15
- * @privateRemarks
16
- * Explicit typing is used here to work around a limitation in TypeScript (and fully support
17
- * {@link https://www.typescriptlang.org/tsconfig/#isolatedDeclarations | isolatedDeclarations}).
18
- */
19
- export declare const StateFactory: {
20
- readonly latest: LatestFactory;
21
- readonly latestMap: LatestMapFactory;
22
- };
23
- //# sourceMappingURL=stateFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateFactory.d.ts","sourceRoot":"","sources":["../../src/states/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAK5F;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,EAAE;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;CAI5B,CAAC"}
@@ -1,27 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.StateFactory = void 0;
8
- const latestMapValueManager_js_1 = require("./latestMapValueManager.js");
9
- const latestValueManager_js_1 = require("./latestValueManager.js");
10
- /**
11
- * Factory for creating presence State objects.
12
- *
13
- * @remarks
14
- * Use `latest` to create a {@link @fluidframework/presence#Latest} or {@link @fluidframework/presence#LatestRaw} State object.
15
- * Use `latestMap` to create a {@link @fluidframework/presence#LatestMap} or {@link @fluidframework/presence#LatestMapRaw} State object.
16
- *
17
- * @public
18
- *
19
- * @privateRemarks
20
- * Explicit typing is used here to work around a limitation in TypeScript (and fully support
21
- * {@link https://www.typescriptlang.org/tsconfig/#isolatedDeclarations | isolatedDeclarations}).
22
- */
23
- exports.StateFactory = {
24
- latest: latestValueManager_js_1.latest,
25
- latestMap: latestMapValueManager_js_1.latestMap,
26
- };
27
- //# sourceMappingURL=stateFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stateFactory.js","sourceRoot":"","sources":["../../src/states/stateFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,yEAAuD;AACvD,mEAAiD;AAEjD;;;;;;;;;;;;GAYG;AACU,QAAA,YAAY,GAGrB;IACH,MAAM,EAAN,8BAAM;IACN,SAAS,EAAT,oCAAS;CACA,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { LatestFactory, LatestMapFactory } from \"@fluid-internal/presence-definitions\";\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 @fluidframework/presence#Latest} or {@link @fluidframework/presence#LatestRaw} State object.\n * Use `latestMap` to create a {@link @fluidframework/presence#LatestMap} or {@link @fluidframework/presence#LatestMapRaw} State object.\n *\n * @public\n *\n * @privateRemarks\n * Explicit typing is used here to work around a limitation in TypeScript (and fully support\n * {@link https://www.typescriptlang.org/tsconfig/#isolatedDeclarations | isolatedDeclarations}).\n */\nexport const StateFactory: {\n\treadonly latest: LatestFactory;\n\treadonly latestMap: LatestMapFactory;\n} = {\n\tlatest,\n\tlatestMap,\n} as const;\n"]}
@@ -1,18 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { StateSchemaValidator } from "@fluid-internal/presence-definitions";
6
- import type { ValidatableRequiredState } from "@fluid-internal/presence-definitions/internal";
7
- import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"validatedGetter.d.ts","sourceRoot":"","sources":["../../src/states/validatedGetter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAEhB,MAAM,8DAA8D,CAAC;AAqBtE;;;;;;;;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"}
@@ -1,43 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createValidatedGetter = void 0;
8
- const utils_1 = require("@fluid-internal/presence-runtime/utils");
9
- function createGetterFunction(clientState, validator) {
10
- return () => {
11
- if (!("validatedValue" in clientState)) {
12
- // Stored `value` has not been validated yet, so validate it and save the result.
13
- clientState.validatedValue = validator(clientState.value);
14
- }
15
- return (0, utils_1.asDeeplyReadonlyDeserializedJson)(clientState.validatedValue);
16
- };
17
- }
18
- /**
19
- * Creates a getter for a state value that validates the data with a validator if one is provided. Otherwise the value
20
- * is returned directly.
21
- *
22
- * @param clientState - The client state to be validated.
23
- * @param validator - The validator function to run.
24
- * @returns Either returns the value directly if a validator is not provided, or a function that will return the
25
- * validated data.
26
- */
27
- function createValidatedGetter(clientState, validator) {
28
- // No validator
29
- if (validator === undefined) {
30
- return (0, utils_1.asDeeplyReadonlyDeserializedJson)(clientState.value);
31
- }
32
- // Avoid creating another function since one already exists on the item
33
- if (typeof clientState.value === "function") {
34
- return clientState.value;
35
- }
36
- // OpaqueJsonDeserialized<T> is just a branded alias of JsonDeserialized<T>. At runtime the functions are still passed
37
- // JSON data, regardless of their type representation. Passing that data to a function that expects `unknown`, like
38
- // the user-provided validator function, is always valid, so StateSchemaValidator and StateSchemaValidatorToOpaque are
39
- // functionally equivalent.
40
- return createGetterFunction(clientState, validator);
41
- }
42
- exports.createValidatedGetter = createValidatedGetter;
43
- //# sourceMappingURL=validatedGetter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validatedGetter.js","sourceRoot":"","sources":["../../src/states/validatedGetter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,kEAA0F;AAM1F,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,IAAA,wCAAgC,EAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACrE,CAAC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACpC,WAAwC,EACxC,SAA8C;IAE9C,eAAe;IACf,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAA,wCAAgC,EAAC,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;AAnBD,sDAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { StateSchemaValidator } from \"@fluid-internal/presence-definitions\";\nimport type { ValidatableRequiredState } from \"@fluid-internal/presence-definitions/internal\";\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n\tOpaqueJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport { asDeeplyReadonlyDeserializedJson } from \"@fluid-internal/presence-runtime/utils\";\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,37 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import type { BroadcastControls, BroadcastControlSettings } from "@fluid-internal/presence-definitions";
6
- declare class ForcedRefreshControl implements Pick<BroadcastControls & {
7
- forcedRefreshIntervalMs: number | undefined;
8
- }, "forcedRefreshIntervalMs"> {
9
- private _forcedRefreshInterval;
10
- constructor(settings?: BroadcastControlSettings);
11
- get forcedRefreshIntervalMs(): number | undefined;
12
- set forcedRefreshIntervalMs(value: number | undefined);
13
- }
14
- /**
15
- * Implements {@link BroadcastControls} for States Managers
16
- * where returning `undefined` settings are allowed.
17
- */
18
- export declare class OptionalBroadcastControl extends ForcedRefreshControl implements BroadcastControls {
19
- allowableUpdateLatencyMs: number | undefined;
20
- constructor(settings?: BroadcastControlSettings);
21
- }
22
- /**
23
- * Implements {@link BroadcastControls} but always provides defined value for
24
- * {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}.
25
- *
26
- * If {@link BroadcastControls.allowableUpdateLatencyMs | allowableUpdateLatencyMs}
27
- * is set to `undefined`, the default will be restored.
28
- */
29
- export declare class RequiredBroadcastControl extends ForcedRefreshControl implements BroadcastControls {
30
- private readonly defaultAllowableUpdateLatencyMs;
31
- private _allowableUpdateLatencyMs;
32
- constructor(defaultAllowableUpdateLatencyMs: number);
33
- get allowableUpdateLatencyMs(): number;
34
- set allowableUpdateLatencyMs(value: number | undefined);
35
- }
36
- export {};
37
- //# sourceMappingURL=broadcastControls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"broadcastControls.d.ts","sourceRoot":"","sources":["../../src/utils/broadcastControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,sCAAsC,CAAC;AAE9C,cAAM,oBACL,YACC,IAAI,CACH,iBAAiB,GAAG;IAAE,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,EACnE,yBAAyB,CACzB;IAEF,OAAO,CAAC,sBAAsB,CAAqB;gBAEhC,QAAQ,CAAC,EAAE,wBAAwB;IAItD,IAAW,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAEvD;IACD,IAAW,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAU3D;CACD;AAED;;;GAGG;AACH,qBAAa,wBACZ,SAAQ,oBACR,YAAW,iBAAiB;IAErB,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEjC,QAAQ,CAAC,EAAE,wBAAwB;CAItD;AAED;;;;;;GAMG;AACH,qBAAa,wBACZ,SAAQ,oBACR,YAAW,iBAAiB;IAIT,OAAO,CAAC,QAAQ,CAAC,+BAA+B;IAFnE,OAAO,CAAC,yBAAyB,CAAS;gBAEN,+BAA+B,EAAE,MAAM;IAK3E,IAAW,wBAAwB,IAAI,MAAM,CAE5C;IACD,IAAW,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAE5D;CACD"}