@fluidframework/presence 2.32.0 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/dist/alpha.d.ts +29 -25
- package/dist/baseTypes.d.ts +3 -3
- package/dist/baseTypes.js.map +1 -1
- package/dist/broadcastControls.d.ts +1 -1
- package/dist/broadcastControls.js.map +1 -1
- package/dist/datastorePresenceManagerFactory.d.ts +5 -5
- package/dist/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/dist/datastorePresenceManagerFactory.js +6 -6
- package/dist/datastorePresenceManagerFactory.js.map +1 -1
- package/dist/experimentalAccess.d.ts +4 -4
- package/dist/experimentalAccess.d.ts.map +1 -1
- package/dist/experimentalAccess.js +6 -6
- package/dist/experimentalAccess.js.map +1 -1
- package/dist/exposedInternalTypes.d.ts +1 -1
- package/dist/exposedInternalTypes.js.map +1 -1
- package/dist/exposedUtilityTypes.d.ts +0 -8
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +3 -3
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/internalUtils.d.ts +5 -0
- package/dist/internalUtils.d.ts.map +1 -1
- package/dist/internalUtils.js +8 -1
- package/dist/internalUtils.js.map +1 -1
- package/dist/latestMapValueManager.d.ts +57 -39
- package/dist/latestMapValueManager.d.ts.map +1 -1
- package/dist/latestMapValueManager.js +48 -39
- package/dist/latestMapValueManager.js.map +1 -1
- package/dist/latestValueManager.d.ts +38 -20
- package/dist/latestValueManager.d.ts.map +1 -1
- package/dist/latestValueManager.js +32 -28
- package/dist/latestValueManager.js.map +1 -1
- package/dist/latestValueTypes.d.ts +9 -10
- package/dist/latestValueTypes.d.ts.map +1 -1
- package/dist/latestValueTypes.js.map +1 -1
- package/dist/notificationsManager.d.ts +15 -10
- package/dist/notificationsManager.d.ts.map +1 -1
- package/dist/notificationsManager.js +8 -5
- package/dist/notificationsManager.js.map +1 -1
- package/dist/presence.d.ts +82 -66
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +5 -5
- package/dist/presence.js.map +1 -1
- package/dist/presenceDatastoreManager.d.ts +12 -10
- package/dist/presenceDatastoreManager.d.ts.map +1 -1
- package/dist/presenceDatastoreManager.js +10 -8
- package/dist/presenceDatastoreManager.js.map +1 -1
- package/dist/presenceManager.d.ts +2 -2
- package/dist/presenceManager.d.ts.map +1 -1
- package/dist/presenceManager.js +14 -22
- package/dist/presenceManager.js.map +1 -1
- package/dist/presenceStates.d.ts +14 -13
- package/dist/presenceStates.d.ts.map +1 -1
- package/dist/presenceStates.js +22 -15
- package/dist/presenceStates.js.map +1 -1
- package/dist/stateDatastore.d.ts +5 -4
- package/dist/stateDatastore.d.ts.map +1 -1
- package/dist/stateDatastore.js.map +1 -1
- package/dist/stateFactory.d.ts +22 -0
- package/dist/stateFactory.d.ts.map +1 -0
- package/dist/stateFactory.js +25 -0
- package/dist/stateFactory.js.map +1 -0
- package/dist/systemWorkspace.d.ts +7 -7
- package/dist/systemWorkspace.d.ts.map +1 -1
- package/dist/systemWorkspace.js +23 -23
- package/dist/systemWorkspace.js.map +1 -1
- package/dist/types.d.ts +50 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/lib/alpha.d.ts +29 -25
- package/lib/baseTypes.d.ts +3 -3
- package/lib/baseTypes.js.map +1 -1
- package/lib/broadcastControls.d.ts +1 -1
- package/lib/broadcastControls.js.map +1 -1
- package/lib/datastorePresenceManagerFactory.d.ts +5 -5
- package/lib/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/lib/datastorePresenceManagerFactory.js +4 -4
- package/lib/datastorePresenceManagerFactory.js.map +1 -1
- package/lib/experimentalAccess.d.ts +4 -4
- package/lib/experimentalAccess.d.ts.map +1 -1
- package/lib/experimentalAccess.js +4 -4
- package/lib/experimentalAccess.js.map +1 -1
- package/lib/exposedInternalTypes.d.ts +1 -1
- package/lib/exposedInternalTypes.js.map +1 -1
- package/lib/exposedUtilityTypes.d.ts +0 -8
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/index.d.ts +8 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -5
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +3 -3
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/internalUtils.d.ts +5 -0
- package/lib/internalUtils.d.ts.map +1 -1
- package/lib/internalUtils.js +6 -0
- package/lib/internalUtils.js.map +1 -1
- package/lib/latestMapValueManager.d.ts +57 -39
- package/lib/latestMapValueManager.d.ts.map +1 -1
- package/lib/latestMapValueManager.js +47 -38
- package/lib/latestMapValueManager.js.map +1 -1
- package/lib/latestValueManager.d.ts +38 -20
- package/lib/latestValueManager.d.ts.map +1 -1
- package/lib/latestValueManager.js +31 -27
- package/lib/latestValueManager.js.map +1 -1
- package/lib/latestValueTypes.d.ts +9 -10
- package/lib/latestValueTypes.d.ts.map +1 -1
- package/lib/latestValueTypes.js.map +1 -1
- package/lib/notificationsManager.d.ts +15 -10
- package/lib/notificationsManager.d.ts.map +1 -1
- package/lib/notificationsManager.js +8 -5
- package/lib/notificationsManager.js.map +1 -1
- package/lib/presence.d.ts +82 -66
- package/lib/presence.d.ts.map +1 -1
- package/lib/presence.js +4 -4
- package/lib/presence.js.map +1 -1
- package/lib/presenceDatastoreManager.d.ts +12 -10
- package/lib/presenceDatastoreManager.d.ts.map +1 -1
- package/lib/presenceDatastoreManager.js +10 -8
- package/lib/presenceDatastoreManager.js.map +1 -1
- package/lib/presenceManager.d.ts +2 -2
- package/lib/presenceManager.d.ts.map +1 -1
- package/lib/presenceManager.js +14 -22
- package/lib/presenceManager.js.map +1 -1
- package/lib/presenceStates.d.ts +14 -13
- package/lib/presenceStates.d.ts.map +1 -1
- package/lib/presenceStates.js +22 -15
- package/lib/presenceStates.js.map +1 -1
- package/lib/stateDatastore.d.ts +5 -4
- package/lib/stateDatastore.d.ts.map +1 -1
- package/lib/stateDatastore.js.map +1 -1
- package/lib/stateFactory.d.ts +22 -0
- package/lib/stateFactory.d.ts.map +1 -0
- package/lib/stateFactory.js +22 -0
- package/lib/stateFactory.js.map +1 -0
- package/lib/systemWorkspace.d.ts +7 -7
- package/lib/systemWorkspace.d.ts.map +1 -1
- package/lib/systemWorkspace.js +24 -24
- package/lib/systemWorkspace.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +50 -33
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestMapValueManager.js","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAS7D,iEAAkE;AAIlE,yDAA+D;AAO/D,2DAA+E;AAC/E,uDAA6C;AAwL7C,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,oEAAoE;QACpE,MAAM,IAAI,GAAG,IAAI,CAAC,KAA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AAE,EAAE,CAAC;IAC1B,wEAAwE;IACxE,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QACjC,KAAK,MAAM,GAAG,IAAI,IAAA,6BAAU,EAAC,aAAa,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;QACrE,CAAC;IACF,CAAC;IACD,MAAM,OAAO,GAAG,CACf,GAAoB,EACpB,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,yBAAyB,CAC5B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,CACR,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAC5E,CAAC;AAnDD,8BAmDC","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 { Listenable } from \"@fluidframework/core-interfaces\";\nimport type { IEmitter } from \"@fluidframework/core-interfaces/internal\";\nimport type {\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControls.js\";\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport { objectEntries, objectKeys } from \"./internalUtils.js\";\nimport type {\n\tLatestValueClientData,\n\tLatestValueData,\n\tLatestValueMetadata,\n} from \"./latestValueTypes.js\";\nimport type { ClientSessionId, ISessionClient, SpecificSessionClient } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Collection of latest known values for a specific client.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapValueClientData<\n\tT,\n\tKeys extends string | number,\n\tSpecificSessionClientId extends ClientSessionId = ClientSessionId,\n> {\n\t/**\n\t * Associated client.\n\t */\n\tclient: ISessionClient<SpecificSessionClientId>;\n\n\t/**\n\t * @privateRemarks This could be regular map currently as no Map is\n\t * stored internally and a new instance is created for every request.\n\t */\n\titems: ReadonlyMap<Keys, LatestValueData<T>>;\n}\n\n/**\n * State of a single item value, its key, and its metadata.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapItemValueClientData<T, K extends string | number>\n\textends LatestValueClientData<T> {\n\tkey: K;\n}\n\n/**\n * Identifier and metadata for a removed item.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapItemRemovedClientData<K extends string | number> {\n\tclient: ISessionClient;\n\tkey: K;\n\tmetadata: LatestValueMetadata;\n}\n\n/**\n * @sealed\n * @alpha\n */\nexport interface LatestMapValueManagerEvents<T, K extends string | number> {\n\t/**\n\t * Raised when any item's value for remote client is updated.\n\t * @param updates - Map of one or more values updated.\n\t *\n\t * @remarks The event does not include item removals.\n\t *\n\t * @eventProperty\n\t */\n\tupdated: (updates: LatestMapValueClientData<T, K>) => void;\n\n\t/**\n\t * Raised when specific item's value of remote client is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\titemUpdated: (updatedItem: LatestMapItemValueClientData<T, K>) => void;\n\n\t/**\n\t * Raised when specific item of remote client is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\titemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;\n\n\t/**\n\t * Raised when specific local item's value is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemUpdated: (updatedItem: {\n\t\tvalue: InternalUtilityTypes.FullyReadonly<JsonSerializable<T> & JsonDeserialized<T>>;\n\t\tkey: K;\n\t}) => void;\n\n\t/**\n\t * Raised when specific local item is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemRemoved: (removedItem: {\n\t\tkey: K;\n\t}) => void;\n}\n\n/**\n * Map of local client's values. Modifications are transmitted to all other connected clients.\n *\n * @sealed\n * @alpha\n */\nexport interface ValueMap<K extends string | number, V> {\n\t/**\n\t * ${@link ValueMap.delete}s all elements in the ValueMap.\n\t * @remarks This is not yet implemented.\n\t */\n\tclear(): void;\n\n\t/**\n\t * @returns true if an element in the ValueMap existed and has been removed, or false if\n\t * the element does not exist.\n\t * @remarks No entry is fully removed. Instead an undefined placeholder is locally and\n\t * transmitted to all other clients. For better performance limit the number of deleted\n\t * entries and reuse keys when possible.\n\t * @privateRemarks In the future we may add a mechanism to remove the placeholder, at least\n\t * from transmissions after sufficient time has passed.\n\t */\n\tdelete(key: K): boolean;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the ValueMap, in arbitrary order.\n\t */\n\tforEach(\n\t\tcallbackfn: (\n\t\t\tvalue: InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>,\n\t\t\tkey: K,\n\t\t\tmap: ValueMap<K, V>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void;\n\n\t/**\n\t * Returns a specified element from the ValueMap object.\n\t * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.\n\t */\n\tget(key: K): InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>> | undefined;\n\n\t/**\n\t * @returns boolean indicating whether an element with the specified key exists or not.\n\t */\n\thas(key: K): boolean;\n\n\t/**\n\t * Adds a new element with a specified key and value to the ValueMap. If an element with the same key already exists, the element will be updated.\n\t * The value will be transmitted to all other connected clients.\n\t *\n\t * @remarks Manager assumes ownership of the value and its references.\n\t * Make a deep clone before setting, if needed. No comparison is done to detect changes; all\n\t * sets are transmitted.\n\t */\n\tset(key: K, value: JsonSerializable<V> & JsonDeserialized<V>): this;\n\n\t/**\n\t * @returns the number of elements in the ValueMap.\n\t */\n\treadonly size: number;\n\n\t/**\n\t * Returns an iterable of entries in the map.\n\t */\n\t// [Symbol.iterator](): IterableIterator<[K, InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t */\n\t// entries(): IterableIterator<[K, InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t */\n\tkeys(): IterableIterator<K>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t */\n\t// values(): IterableIterator<InternalUtilityTypes.FullyReadonly<JsonDeserialized<V>>>;\n}\n\nclass ValueMapImpl<T, K extends string | number> implements ValueMap<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<LatestMapValueManagerEvents<T, K>, \"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 | number\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\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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: InternalUtilityTypes.FullyReadonly<JsonDeserialized<T>>,\n\t\t\tkey: K,\n\t\t\tmap: ValueMap<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\tcallbackfn(item.value, key, this);\n\t\t\t}\n\t\t}\n\t}\n\tpublic get(key: K): InternalUtilityTypes.FullyReadonly<JsonDeserialized<T>> | undefined {\n\t\treturn 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, value: JsonSerializable<T> & JsonDeserialized<T>): this {\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 });\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\tkeys.push(key);\n\t\t\t}\n\t\t}\n\t\treturn keys[Symbol.iterator]();\n\t}\n}\n\n/**\n * Value manager that provides a `Map` of latest known values from this client to\n * others and read access to their values.\n * Entries in the map may vary over time and by client, but all values are expected to\n * be of the same type, which may be a union type.\n *\n * @remarks Create using {@link LatestMap} registered to {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapValueManager<T, Keys extends string | number = string | number> {\n\t/**\n\t * Events for LatestMap value manager.\n\t */\n\treadonly events: Listenable<LatestMapValueManagerEvents<T, Keys>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current value map for this client.\n\t */\n\treadonly local: ValueMap<Keys, T>;\n\t/**\n\t * Iterable access to remote clients' map of values.\n\t */\n\tclientValues(): IterableIterator<LatestMapValueClientData<T, Keys>>;\n\t/**\n\t * Array of known remote clients.\n\t */\n\tclients(): ISessionClient[];\n\t/**\n\t * Access to a specific client's map of values.\n\t */\n\tclientValue(client: ISessionClient): ReadonlyMap<Keys, LatestValueData<T>>;\n}\n\nclass LatestMapValueManagerImpl<\n\tT,\n\tRegistrationKey extends string,\n\tKeys extends string | number = string | number,\n> implements\n\t\tLatestMapValueManager<T, Keys>,\n\t\tRequired<ValueManager<T, InternalTypes.MapValueState<T, Keys>>>\n{\n\tpublic readonly events = createEmitter<LatestMapValueManagerEvents<T, Keys>>();\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>,\n\t\tpublic readonly value: InternalTypes.MapValueState<T, Keys>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\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 readonly local: ValueMap<Keys, T>;\n\n\tpublic *clientValues(): IterableIterator<LatestMapValueClientData<T, Keys>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const clientSessionId of objectKeys(allKnownStates.states)) {\n\t\t\tif (clientSessionId !== allKnownStates.self) {\n\t\t\t\tconst client = this.datastore.lookupClient(clientSessionId);\n\t\t\t\tconst items = this.clientValue(client);\n\t\t\t\tyield { client, items };\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic clients(): ISessionClient[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn objectKeys(allKnownStates.states)\n\t\t\t.filter((clientSessionId) => clientSessionId !== allKnownStates.self)\n\t\t\t.map((clientSessionId) => this.datastore.lookupClient(clientSessionId));\n\t}\n\n\tpublic clientValue(client: ISessionClient): ReadonlyMap<Keys, LatestValueData<T>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst clientSessionId = client.sessionId;\n\t\tconst clientStateMap = allKnownStates.states[clientSessionId];\n\t\tif (clientStateMap === undefined) {\n\t\t\tthrow new Error(\"No entry for client\");\n\t\t}\n\t\tconst items = new Map<Keys, LatestValueData<T>>();\n\t\tfor (const [key, item] of objectEntries(clientStateMap.items)) {\n\t\t\tconst value = item.value;\n\t\t\tif (value !== undefined) {\n\t\t\t\titems.set(key, {\n\t\t\t\t\tvalue,\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<SpecificSessionClientId extends ClientSessionId>(\n\t\tclient: SpecificSessionClient<SpecificSessionClientId>,\n\t\t_received: number,\n\t\tvalue: InternalTypes.MapValueState<T, string | number>,\n\t): PostUpdateAction[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst clientSessionId: SpecificSessionClientId = client.sessionId;\n\t\tconst currentState = (allKnownStates.states[clientSessionId] ??=\n\t\t\t// New client - prepare new client state directory\n\t\t\t{\n\t\t\t\trev: value.rev,\n\t\t\t\titems: {} as unknown as InternalTypes.MapValueState<T, Keys>[\"items\"],\n\t\t\t});\n\t\t// Accumulate individual update keys\n\t\tconst updatedItemKeys: Keys[] = [];\n\t\tfor (const [key, item] of objectEntries(value.items)) {\n\t\t\t// TODO: Key validation needs to be added here.\n\t\t\tconst validKey = key as Keys;\n\t\t\tif (!(key in currentState.items) || currentState.items[validKey].rev < item.rev) {\n\t\t\t\tupdatedItemKeys.push(validKey);\n\t\t\t}\n\t\t}\n\n\t\tif (updatedItemKeys.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\tclient,\n\t\t\titems: new Map<Keys, LatestValueData<T>>(),\n\t\t};\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const key of updatedItemKeys) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst item = value.items[key]!;\n\t\t\tconst hadPriorValue = currentState.items[key]?.value;\n\t\t\tcurrentState.items[key] = item;\n\t\t\tconst metadata = { revision: item.rev, timestamp: item.timestamp };\n\t\t\tif (item.value !== undefined) {\n\t\t\t\tconst itemValue = item.value;\n\t\t\t\tconst updatedItem = {\n\t\t\t\t\tclient,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: itemValue,\n\t\t\t\t\tmetadata,\n\t\t\t\t};\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"itemUpdated\", updatedItem));\n\t\t\t\tallUpdates.items.set(key, { value: itemValue, metadata });\n\t\t\t} else if (hadPriorValue !== undefined) {\n\t\t\t\tpostUpdateActions.push(() =>\n\t\t\t\t\tthis.events.emit(\"itemRemoved\", {\n\t\t\t\t\t\tclient,\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, clientSessionId, currentState);\n\t\tpostUpdateActions.push(() => this.events.emit(\"updated\", allUpdates));\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link LatestMapValueManager}.\n *\n * @alpha\n */\nexport function LatestMap<\n\tT extends object,\n\tKeys extends string | number = string | number,\n\tRegistrationKey extends string = string,\n>(\n\tinitialValues?: {\n\t\t[K in Keys]: JsonSerializable<T> & JsonDeserialized<T>;\n\t},\n\tcontrols?: BroadcastControlSettings,\n): InternalTypes.ManagerFactory<\n\tRegistrationKey,\n\tInternalTypes.MapValueState<T, Keys>,\n\tLatestMapValueManager<T, Keys>\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 | number\n\t> = { rev: 0, items: {} };\n\t// LatestMapValueManager takes ownership of values within initialValues.\n\tif (initialValues !== undefined) {\n\t\tfor (const key of objectKeys(initialValues)) {\n\t\t\tvalue.items[key] = { rev: 0, timestamp, value: initialValues[key] };\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<LatestMapValueManager<T, Keys>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: controls?.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\tcontrols,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestMapValueManagerImpl });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"latestMapValueManager.js","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAU7D,iEAAkE;AAGlE,yDAAiF;AAGjF,2DAA+E;AAC/E,uDAA6C;AAwL7C,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,oEAAoE;QACpE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAE,CAAC;QACpC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,KAAK,CAAC;QACnB,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAC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MAAM,KAAK,GAIP,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC1B,+DAA+D;IAC/D,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QACjC,KAAK,MAAM,GAAG,IAAI,IAAA,6BAAU,EAAC,aAAa,CAAC,EAAE,CAAC;YAC7C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG;gBAClB,GAAG,EAAE,CAAC;gBACN,SAAS;gBACT,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC;aACzB,CAAC;QACH,CAAC;IACF,CAAC;IACD,MAAM,OAAO,GAAG,CACf,GAAoB,EACpB,eAGC,EAIA,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,wBAAwB,EAAE;QACpF,OAAO,EAAE,IAAA,0BAAQ,EAKhB,IAAI,4BAA4B,CAC/B,GAAG,EACH,IAAA,uCAAmB,EAAC,eAAe,CAAC,EACpC,KAAK,EACL,QAAQ,CACR,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,4BAA4B,EAAE,CAAC,CAAC;AAC/E,CAAC;AAvDD,8BAuDC","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 { Listenable } from \"@fluidframework/core-interfaces\";\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 type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControls.js\";\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport { asDeeplyReadonly, objectEntries, objectKeys } from \"./internalUtils.js\";\nimport type { LatestClientData, LatestData, LatestMetadata } from \"./latestValueTypes.js\";\nimport type { AttendeeId, Attendee, Presence, SpecificAttendee } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Collection of latest known values for a specific client.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapClientData<\n\tT,\n\tKeys extends string | number,\n\tSpecificAttendeeId extends AttendeeId = AttendeeId,\n> {\n\t/**\n\t * Associated attendee.\n\t */\n\tattendee: Attendee<SpecificAttendeeId>;\n\n\t/**\n\t * @privateRemarks This could be regular map currently as no Map is\n\t * stored internally and a new instance is created for every request.\n\t */\n\titems: ReadonlyMap<Keys, LatestData<T>>;\n}\n\n/**\n * State of a single item value, its key, and its metadata.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapItemUpdatedClientData<T, K extends string | number>\n\textends LatestClientData<T> {\n\tkey: K;\n}\n\n/**\n * Identifier and metadata for a removed item.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapItemRemovedClientData<K extends string | number> {\n\tattendee: Attendee;\n\tkey: K;\n\tmetadata: LatestMetadata;\n}\n\n/**\n * @sealed\n * @alpha\n */\nexport interface LatestMapRawEvents<T, K extends string | number> {\n\t/**\n\t * Raised when any item's value for remote client is updated.\n\t * @param updates - Map of one or more values updated.\n\t *\n\t * @remarks The event does not include item removals.\n\t *\n\t * @eventProperty\n\t */\n\tremoteUpdated: (updates: LatestMapClientData<T, K>) => void;\n\n\t/**\n\t * Raised when specific item's value of remote client is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\tremoteItemUpdated: (updatedItem: LatestMapItemUpdatedClientData<T, K>) => void;\n\n\t/**\n\t * Raised when specific item of remote client is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\tremoteItemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;\n\n\t/**\n\t * Raised when specific local item's value is updated.\n\t * @param updatedItem - Updated item value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemUpdated: (updatedItem: {\n\t\tvalue: DeepReadonly<JsonSerializable<T> & JsonDeserialized<T>>;\n\t\tkey: K;\n\t}) => void;\n\n\t/**\n\t * Raised when specific local item is removed.\n\t * @param removedItem - Removed item.\n\t *\n\t * @eventProperty\n\t */\n\tlocalItemRemoved: (removedItem: {\n\t\tkey: K;\n\t}) => void;\n}\n\n/**\n * Map of local client's values. Modifications are transmitted to all other connected clients.\n *\n * @sealed\n * @alpha\n */\nexport interface StateMap<K extends string | number, V> {\n\t/**\n\t * ${@link StateMap.delete}s all elements in the StateMap.\n\t * @remarks This is not yet implemented.\n\t */\n\tclear(): void;\n\n\t/**\n\t * @returns true if an element in the StateMap existed and has been removed, or false if\n\t * the element does not exist.\n\t * @remarks No entry is fully removed. Instead an undefined placeholder is locally and\n\t * transmitted to all other clients. For better performance limit the number of deleted\n\t * entries and reuse keys when possible.\n\t * @privateRemarks In the future we may add a mechanism to remove the placeholder, at least\n\t * from transmissions after sufficient time has passed.\n\t */\n\tdelete(key: K): boolean;\n\n\t/**\n\t * Executes a provided function once per each key/value pair in the StateMap, in arbitrary order.\n\t */\n\tforEach(\n\t\tcallbackfn: (\n\t\t\tvalue: DeepReadonly<JsonDeserialized<V>>,\n\t\t\tkey: K,\n\t\t\tmap: StateMap<K, V>,\n\t\t) => void,\n\t\tthisArg?: unknown,\n\t): void;\n\n\t/**\n\t * Returns a specified element from the StateMap object.\n\t * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.\n\t */\n\tget(key: K): DeepReadonly<JsonDeserialized<V>> | undefined;\n\n\t/**\n\t * @returns boolean indicating whether an element with the specified key exists or not.\n\t */\n\thas(key: K): boolean;\n\n\t/**\n\t * Adds a new element with a specified key and value to the StateMap. If an element with the same key already exists, the element will be updated.\n\t * The value will be transmitted to all other connected clients.\n\t *\n\t * @remarks Manager assumes ownership of the value and its references.\n\t * Make a deep clone before setting, if needed. No comparison is done to detect changes; all\n\t * sets are transmitted.\n\t */\n\tset(key: K, value: JsonSerializable<V> & JsonDeserialized<V>): this;\n\n\t/**\n\t * @returns the number of elements in the StateMap.\n\t */\n\treadonly size: number;\n\n\t/**\n\t * Returns an iterable of entries in the map.\n\t */\n\t// [Symbol.iterator](): IterableIterator<[K, DeepReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of key, value pairs for every entry in the map.\n\t */\n\t// entries(): IterableIterator<[K, DeepReadonly<JsonDeserialized<V>>]>;\n\n\t/**\n\t * Returns an iterable of keys in the map.\n\t */\n\tkeys(): IterableIterator<K>;\n\n\t/**\n\t * Returns an iterable of values in the map.\n\t */\n\t// values(): IterableIterator<DeepReadonly<JsonDeserialized<V>>>;\n}\n\nclass ValueMapImpl<T, K extends string | number> 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<LatestMapRawEvents<T, K>, \"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 | number\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\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\tcallbackfn(asDeeplyReadonly(item.value), key, this);\n\t\t\t}\n\t\t}\n\t}\n\tpublic get(key: K): DeepReadonly<JsonDeserialized<T>> | undefined {\n\t\treturn asDeeplyReadonly(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, value: JsonSerializable<T> & JsonDeserialized<T>): this {\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(value) });\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\tkeys.push(key);\n\t\t\t}\n\t\t}\n\t\treturn keys[Symbol.iterator]();\n\t}\n}\n\n/**\n * State that provides a `Map` of latest known values from this client to\n * others and read access to their values.\n * Entries in the map may vary over time and by client, but all values are expected to\n * be of the same type, which may be a union type.\n *\n * @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestMapRaw<T, Keys extends string | number = string | number> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for LatestMapRaw.\n\t */\n\treadonly events: Listenable<LatestMapRawEvents<T, Keys>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current value map for this client.\n\t */\n\treadonly local: StateMap<Keys, T>;\n\t/**\n\t * Iterable access to remote clients' map of values.\n\t */\n\tgetRemotes(): IterableIterator<LatestMapClientData<T, Keys>>;\n\t/**\n\t * Array of {@link Attendee}s that have provided states.\n\t */\n\tgetStateAttendees(): Attendee[];\n\t/**\n\t * Access to a specific client's map of values.\n\t */\n\tgetRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T>>;\n}\n\nclass LatestMapRawValueManagerImpl<\n\tT,\n\tRegistrationKey extends string,\n\tKeys extends string | number = string | number,\n> implements\n\t\tLatestMapRaw<T, Keys>,\n\t\tRequired<ValueManager<T, InternalTypes.MapValueState<T, Keys>>>\n{\n\tpublic readonly events = createEmitter<LatestMapRawEvents<T, Keys>>();\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>,\n\t\tpublic readonly value: InternalTypes.MapValueState<T, Keys>,\n\t\tcontrolSettings: BroadcastControlSettings | undefined,\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>> {\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.lookupClient(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.lookupClient(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T>> {\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>>();\n\t\tfor (const [key, item] of objectEntries(clientStateMap.items)) {\n\t\t\tconst value = item.value;\n\t\t\tif (value !== undefined) {\n\t\t\t\titems.set(key, {\n\t\t\t\t\tvalue: asDeeplyReadonly(value),\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 | number>,\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: {} as unknown as InternalTypes.MapValueState<T, Keys>[\"items\"],\n\t\t\t});\n\t\t// Accumulate individual update keys\n\t\tconst updatedItemKeys: Keys[] = [];\n\t\tfor (const [key, item] of objectEntries(value.items)) {\n\t\t\t// TODO: Key validation needs to be added here.\n\t\t\tconst validKey = key as Keys;\n\t\t\tif (!(key in currentState.items) || currentState.items[validKey].rev < item.rev) {\n\t\t\t\tupdatedItemKeys.push(validKey);\n\t\t\t}\n\t\t}\n\n\t\tif (updatedItemKeys.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>>(),\n\t\t};\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const key of updatedItemKeys) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tconst item = value.items[key]!;\n\t\t\tconst hadPriorValue = currentState.items[key]?.value;\n\t\t\tcurrentState.items[key] = item;\n\t\t\tconst metadata = { revision: item.rev, timestamp: item.timestamp };\n\t\t\tif (item.value !== undefined) {\n\t\t\t\tconst itemValue = asDeeplyReadonly(item.value);\n\t\t\t\tconst updatedItem = {\n\t\t\t\t\tattendee,\n\t\t\t\t\tkey,\n\t\t\t\t\tvalue: itemValue,\n\t\t\t\t\tmetadata,\n\t\t\t\t};\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"remoteItemUpdated\", updatedItem));\n\t\t\t\tallUpdates.items.set(key, { value: itemValue, metadata });\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\tpostUpdateActions.push(() => this.events.emit(\"remoteUpdated\", allUpdates));\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Arguments that are passed to the {@link StateFactory.latestMap} function.\n *\n * @alpha\n */\nexport interface LatestMapArguments<T, Keys extends string | number = string | number> {\n\t/**\n\t * The initial value of the local state.\n\t */\n\tlocal?: {\n\t\t[K in Keys]: JsonSerializable<T> & JsonDeserialized<T>;\n\t};\n\n\t/**\n\t * See {@link BroadcastControlSettings}.\n\t */\n\tsettings?: BroadcastControlSettings | undefined;\n}\n\n/**\n * Factory for creating a {@link LatestMapRaw} State object.\n *\n * @alpha\n */\nexport function latestMap<\n\tT,\n\tKeys extends string | number = string | number,\n\tRegistrationKey extends string = string,\n>(\n\targs?: LatestMapArguments<T, Keys>,\n): InternalTypes.ManagerFactory<\n\tRegistrationKey,\n\tInternalTypes.MapValueState<T, Keys>,\n\tLatestMapRaw<T, Keys>\n> {\n\tconst settings = args?.settings;\n\tconst initialValues = args?.local;\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 | number\n\t> = { rev: 0, items: {} };\n\t// LatestMapRaw takes ownership of values within initialValues.\n\tif (initialValues !== undefined) {\n\t\tfor (const key of objectKeys(initialValues)) {\n\t\t\tvalue.items[key] = {\n\t\t\t\trev: 0,\n\t\t\t\ttimestamp,\n\t\t\t\tvalue: initialValues[key],\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>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<\n\t\t\tLatestMapRawValueManagerImpl<T, RegistrationKey, Keys>,\n\t\t\tT,\n\t\t\tInternalTypes.MapValueState<T, Keys>\n\t\t>(\n\t\t\tnew LatestMapRawValueManagerImpl(\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),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestMapRawValueManagerImpl });\n}\n"]}
|
|
@@ -3,46 +3,49 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { Listenable } from "@fluidframework/core-interfaces";
|
|
6
|
-
import type { JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
+
import type { DeepReadonly, JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
7
7
|
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControls.js";
|
|
8
8
|
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type { ISessionClient } from "./presence.js";
|
|
9
|
+
import type { LatestClientData, LatestData } from "./latestValueTypes.js";
|
|
10
|
+
import type { Attendee, Presence } from "./presence.js";
|
|
12
11
|
/**
|
|
13
12
|
* @sealed
|
|
14
13
|
* @alpha
|
|
15
14
|
*/
|
|
16
|
-
export interface
|
|
15
|
+
export interface LatestRawEvents<T> {
|
|
17
16
|
/**
|
|
18
17
|
* Raised when remote client's value is updated, which may be the same value.
|
|
19
18
|
*
|
|
20
19
|
* @eventProperty
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
remoteUpdated: (update: LatestClientData<T>) => void;
|
|
23
22
|
/**
|
|
24
23
|
* Raised when local client's value is updated, which may be the same value.
|
|
25
24
|
*
|
|
26
25
|
* @eventProperty
|
|
27
26
|
*/
|
|
28
27
|
localUpdated: (update: {
|
|
29
|
-
value:
|
|
28
|
+
value: DeepReadonly<JsonSerializable<T> & JsonDeserialized<T>>;
|
|
30
29
|
}) => void;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
|
-
*
|
|
32
|
+
* State that provides the latest known value from this client to others and read access to their values.
|
|
34
33
|
* All participant clients must provide a value.
|
|
35
34
|
*
|
|
36
|
-
* @remarks Create using {@link
|
|
35
|
+
* @remarks Create using {@link StateFactory.latest} registered to {@link StatesWorkspace}.
|
|
37
36
|
*
|
|
38
37
|
* @sealed
|
|
39
38
|
* @alpha
|
|
40
39
|
*/
|
|
41
|
-
export interface
|
|
40
|
+
export interface LatestRaw<T> {
|
|
42
41
|
/**
|
|
43
|
-
*
|
|
42
|
+
* Containing {@link Presence}
|
|
44
43
|
*/
|
|
45
|
-
readonly
|
|
44
|
+
readonly presence: Presence;
|
|
45
|
+
/**
|
|
46
|
+
* Events for LatestRaw.
|
|
47
|
+
*/
|
|
48
|
+
readonly events: Listenable<LatestRawEvents<T>>;
|
|
46
49
|
/**
|
|
47
50
|
* Controls for management of sending updates.
|
|
48
51
|
*/
|
|
@@ -53,25 +56,40 @@ export interface LatestValueManager<T> {
|
|
|
53
56
|
* @remarks Manager assumes ownership of the value and its references. Make a deep clone before
|
|
54
57
|
* setting, if needed. No comparison is done to detect changes; all sets are transmitted.
|
|
55
58
|
*/
|
|
56
|
-
get local():
|
|
59
|
+
get local(): DeepReadonly<JsonDeserialized<T>>;
|
|
57
60
|
set local(value: JsonSerializable<T> & JsonDeserialized<T>);
|
|
58
61
|
/**
|
|
59
62
|
* Iterable access to remote clients' values.
|
|
60
63
|
*/
|
|
61
|
-
|
|
64
|
+
getRemotes(): IterableIterator<LatestClientData<T>>;
|
|
65
|
+
/**
|
|
66
|
+
* Array of {@link Attendee}s that have provided states.
|
|
67
|
+
*/
|
|
68
|
+
getStateAttendees(): Attendee[];
|
|
69
|
+
/**
|
|
70
|
+
* Access to a specific attendee's value.
|
|
71
|
+
*/
|
|
72
|
+
getRemote(attendee: Attendee): LatestData<T>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Arguments that are passed to the {@link StateFactory.latest} function.
|
|
76
|
+
*
|
|
77
|
+
* @alpha
|
|
78
|
+
*/
|
|
79
|
+
export interface LatestArguments<T extends object | null> {
|
|
62
80
|
/**
|
|
63
|
-
*
|
|
81
|
+
* The initial value of the local state.
|
|
64
82
|
*/
|
|
65
|
-
|
|
83
|
+
local: JsonSerializable<T> & JsonDeserialized<T> & (object | null);
|
|
66
84
|
/**
|
|
67
|
-
*
|
|
85
|
+
* See {@link BroadcastControlSettings}.
|
|
68
86
|
*/
|
|
69
|
-
|
|
87
|
+
settings?: BroadcastControlSettings | undefined;
|
|
70
88
|
}
|
|
71
89
|
/**
|
|
72
|
-
* Factory for creating a {@link
|
|
90
|
+
* Factory for creating a {@link LatestRaw} State object.
|
|
73
91
|
*
|
|
74
92
|
* @alpha
|
|
75
93
|
*/
|
|
76
|
-
export declare function
|
|
94
|
+
export declare function latest<T extends object | null, Key extends string = string>(args: LatestArguments<T>): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>>;
|
|
77
95
|
//# sourceMappingURL=latestValueManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueManager.d.ts","sourceRoot":"","sources":["../src/latestValueManager.ts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ineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.latest = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
10
10
|
const broadcastControls_js_1 = require("./broadcastControls.js");
|
|
@@ -19,8 +19,11 @@ class LatestValueManagerImpl {
|
|
|
19
19
|
this.events = (0, client_utils_1.createEmitter)();
|
|
20
20
|
this.controls = new broadcastControls_js_1.OptionalBroadcastControl(controlSettings);
|
|
21
21
|
}
|
|
22
|
+
get presence() {
|
|
23
|
+
return this.datastore.presence;
|
|
24
|
+
}
|
|
22
25
|
get local() {
|
|
23
|
-
return this.value.value;
|
|
26
|
+
return (0, internalUtils_js_1.asDeeplyReadonly)(this.value.value);
|
|
24
27
|
}
|
|
25
28
|
set local(value) {
|
|
26
29
|
this.value.rev += 1;
|
|
@@ -29,72 +32,73 @@ class LatestValueManagerImpl {
|
|
|
29
32
|
this.datastore.localUpdate(this.key, this.value, {
|
|
30
33
|
allowableUpdateLatencyMs: this.controls.allowableUpdateLatencyMs,
|
|
31
34
|
});
|
|
32
|
-
this.events.emit("localUpdated", { value });
|
|
35
|
+
this.events.emit("localUpdated", { value: (0, internalUtils_js_1.asDeeplyReadonly)(value) });
|
|
33
36
|
}
|
|
34
|
-
*
|
|
37
|
+
*getRemotes() {
|
|
35
38
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
36
|
-
for (const [
|
|
37
|
-
if (
|
|
39
|
+
for (const [attendeeId, value] of (0, internalUtils_js_1.objectEntries)(allKnownStates.states)) {
|
|
40
|
+
if (attendeeId !== allKnownStates.self) {
|
|
38
41
|
yield {
|
|
39
|
-
|
|
40
|
-
value: value.value,
|
|
42
|
+
attendee: this.datastore.lookupClient(attendeeId),
|
|
43
|
+
value: (0, internalUtils_js_1.asDeeplyReadonly)(value.value),
|
|
41
44
|
metadata: { revision: value.rev, timestamp: value.timestamp },
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
getStateAttendees() {
|
|
47
50
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
48
51
|
return Object.keys(allKnownStates.states)
|
|
49
|
-
.filter((
|
|
50
|
-
.map((
|
|
52
|
+
.filter((attendeeId) => attendeeId !== allKnownStates.self)
|
|
53
|
+
.map((attendeeId) => this.datastore.lookupClient(attendeeId));
|
|
51
54
|
}
|
|
52
|
-
|
|
55
|
+
getRemote(attendee) {
|
|
53
56
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
54
|
-
const clientState = allKnownStates.states[
|
|
57
|
+
const clientState = allKnownStates.states[attendee.attendeeId];
|
|
55
58
|
if (clientState === undefined) {
|
|
56
59
|
throw new Error("No entry for clientId");
|
|
57
60
|
}
|
|
58
61
|
return {
|
|
59
|
-
value: clientState.value,
|
|
62
|
+
value: (0, internalUtils_js_1.asDeeplyReadonly)(clientState.value),
|
|
60
63
|
metadata: { revision: clientState.rev, timestamp: Date.now() },
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
|
-
update(
|
|
66
|
+
update(attendee, _received, value) {
|
|
64
67
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
65
|
-
const
|
|
66
|
-
const currentState = allKnownStates.states[
|
|
68
|
+
const attendeeId = attendee.attendeeId;
|
|
69
|
+
const currentState = allKnownStates.states[attendeeId];
|
|
67
70
|
if (currentState !== undefined && currentState.rev >= value.rev) {
|
|
68
71
|
return [];
|
|
69
72
|
}
|
|
70
|
-
this.datastore.update(this.key,
|
|
73
|
+
this.datastore.update(this.key, attendeeId, value);
|
|
71
74
|
return [
|
|
72
|
-
() => this.events.emit("
|
|
73
|
-
|
|
74
|
-
value: value.value,
|
|
75
|
+
() => this.events.emit("remoteUpdated", {
|
|
76
|
+
attendee,
|
|
77
|
+
value: (0, internalUtils_js_1.asDeeplyReadonly)(value.value),
|
|
75
78
|
metadata: { revision: value.rev, timestamp: value.timestamp },
|
|
76
79
|
}),
|
|
77
80
|
];
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
/**
|
|
81
|
-
* Factory for creating a {@link
|
|
84
|
+
* Factory for creating a {@link LatestRaw} State object.
|
|
82
85
|
*
|
|
83
86
|
* @alpha
|
|
84
87
|
*/
|
|
85
|
-
function
|
|
86
|
-
|
|
88
|
+
function latest(args) {
|
|
89
|
+
const { local, settings } = args;
|
|
90
|
+
// Latest takes ownership of the initial local value but makes a shallow
|
|
87
91
|
// copy for basic protection.
|
|
88
92
|
const value = {
|
|
89
93
|
rev: 0,
|
|
90
94
|
timestamp: Date.now(),
|
|
91
|
-
value: (0, internal_1.shallowCloneObject)(
|
|
95
|
+
value: local === null ? local : (0, internal_1.shallowCloneObject)(local),
|
|
92
96
|
};
|
|
93
97
|
const factory = (key, datastoreHandle) => ({
|
|
94
|
-
initialData: { value, allowableUpdateLatencyMs:
|
|
95
|
-
manager: (0, valueManager_js_1.brandIVM)(new LatestValueManagerImpl(key, (0, stateDatastore_js_1.datastoreFromHandle)(datastoreHandle), value,
|
|
98
|
+
initialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },
|
|
99
|
+
manager: (0, valueManager_js_1.brandIVM)(new LatestValueManagerImpl(key, (0, stateDatastore_js_1.datastoreFromHandle)(datastoreHandle), value, settings)),
|
|
96
100
|
});
|
|
97
101
|
return Object.assign(factory, { instanceBase: LatestValueManagerImpl });
|
|
98
102
|
}
|
|
99
|
-
exports.
|
|
103
|
+
exports.latest = latest;
|
|
100
104
|
//# sourceMappingURL=latestValueManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueManager.js","sourceRoot":"","sources":["../src/latestValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAM7D,kEAAyE;AAGzE,iEAAkE;AAIlE,yDAAmD;AAGnD,2DAA+E;AAC/E,uDAA6C;AAmE7C,MAAM,sBAAsB;IAQ3B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;QAC5D,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACjE,OAAO,EAAE,CAAC;QACX,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO;YACN,GAAG,EAAE,CACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE;gBAC3B,MAAM;gBACN,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,QAAQ,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;aAC7D,CAAC;SACH,CAAC;IACH,CAAC;CACD;AAED;;;;GAIG;AACH,SAAgB,MAAM,CACrB,YAAgE,EAChE,QAAmC;IAMnC,yEAAyE;IACzE,6BAA6B;IAC7B,MAAM,KAAK,GAAwC;QAClD,GAAG,EAAE,CAAC;QACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK,EAAE,IAAA,6BAAkB,EAAC,YAAY,CAAC;KACvC,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,0BAAQ,EAChB,IAAI,sBAAsB,CAAC,GAAG,EAAE,IAAA,uCAAmB,EAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CACtF;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACzE,CAAC;AA/BD,wBA+BC","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 { Listenable } from \"@fluidframework/core-interfaces\";\nimport type {\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\nimport { shallowCloneObject } from \"@fluidframework/core-utils/internal\";\n\nimport type { BroadcastControls, BroadcastControlSettings } from \"./broadcastControls.js\";\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport { objectEntries } from \"./internalUtils.js\";\nimport type { LatestValueClientData, LatestValueData } from \"./latestValueTypes.js\";\nimport type { ISessionClient } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface LatestValueManagerEvents<T> {\n\t/**\n\t * Raised when remote client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tupdated: (update: LatestValueClientData<T>) => void;\n\n\t/**\n\t * Raised when local client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalUpdated: (update: {\n\t\tvalue: InternalUtilityTypes.FullyReadonly<JsonSerializable<T> & JsonDeserialized<T>>;\n\t}) => void;\n}\n\n/**\n * Value manager that provides the latest known value from this client to others and read access to their values.\n * All participant clients must provide a value.\n *\n * @remarks Create using {@link Latest} registered to {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestValueManager<T> {\n\t/**\n\t * Events for Latest value manager.\n\t */\n\treadonly events: Listenable<LatestValueManagerEvents<T>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current state for this client.\n\t * State for this client that will be transmitted to all other connected clients.\n\t * @remarks Manager assumes ownership of the value and its references. Make a deep clone before\n\t * setting, if needed. No comparison is done to detect changes; all sets are transmitted.\n\t */\n\tget local(): InternalUtilityTypes.FullyReadonly<JsonDeserialized<T>>;\n\tset local(value: JsonSerializable<T> & JsonDeserialized<T>);\n\n\t/**\n\t * Iterable access to remote clients' values.\n\t */\n\tclientValues(): IterableIterator<LatestValueClientData<T>>;\n\t/**\n\t * Array of known remote clients.\n\t */\n\tclients(): ISessionClient[];\n\t/**\n\t * Access to a specific client's value.\n\t */\n\tclientValue(client: ISessionClient): LatestValueData<T>;\n}\n\nclass LatestValueManagerImpl<T, Key extends string>\n\timplements\n\t\tLatestValueManager<T>,\n\t\tRequired<ValueManager<T, InternalTypes.ValueRequiredState<T>>>\n{\n\tpublic readonly events = createEmitter<LatestValueManagerEvents<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) {\n\t\tthis.controls = new OptionalBroadcastControl(controlSettings);\n\t}\n\n\tpublic get local(): InternalUtilityTypes.FullyReadonly<JsonDeserialized<T>> {\n\t\treturn this.value.value;\n\t}\n\n\tpublic set local(value: JsonSerializable<T> & JsonDeserialized<T>) {\n\t\tthis.value.rev += 1;\n\t\tthis.value.timestamp = Date.now();\n\t\tthis.value.value = 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 });\n\t}\n\n\tpublic *clientValues(): IterableIterator<LatestValueClientData<T>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const [clientSessionId, value] of objectEntries(allKnownStates.states)) {\n\t\t\tif (clientSessionId !== allKnownStates.self) {\n\t\t\t\tyield {\n\t\t\t\t\tclient: this.datastore.lookupClient(clientSessionId),\n\t\t\t\t\tvalue: value.value,\n\t\t\t\t\tmetadata: { revision: value.rev, timestamp: value.timestamp },\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic clients(): ISessionClient[] {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\treturn Object.keys(allKnownStates.states)\n\t\t\t.filter((clientSessionId) => clientSessionId !== allKnownStates.self)\n\t\t\t.map((clientSessionId) => this.datastore.lookupClient(clientSessionId));\n\t}\n\n\tpublic clientValue(client: ISessionClient): LatestValueData<T> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tconst clientState = allKnownStates.states[client.sessionId];\n\t\tif (clientState === undefined) {\n\t\t\tthrow new Error(\"No entry for clientId\");\n\t\t}\n\t\treturn {\n\t\t\tvalue: clientState.value,\n\t\t\tmetadata: { revision: clientState.rev, timestamp: Date.now() },\n\t\t};\n\t}\n\n\tpublic update(\n\t\tclient: ISessionClient,\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 clientSessionId = client.sessionId;\n\t\tconst currentState = allKnownStates.states[clientSessionId];\n\t\tif (currentState !== undefined && currentState.rev >= value.rev) {\n\t\t\treturn [];\n\t\t}\n\t\tthis.datastore.update(this.key, clientSessionId, value);\n\t\treturn [\n\t\t\t() =>\n\t\t\t\tthis.events.emit(\"updated\", {\n\t\t\t\t\tclient,\n\t\t\t\t\tvalue: value.value,\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 * Factory for creating a {@link LatestValueManager}.\n *\n * @alpha\n */\nexport function Latest<T extends object, Key extends string = string>(\n\tinitialValue: JsonSerializable<T> & JsonDeserialized<T> & object,\n\tcontrols?: BroadcastControlSettings,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<T>,\n\tLatestValueManager<T>\n> {\n\t// LatestValueManager takes ownership of initialValue but makes a shallow\n\t// copy for basic protection.\n\tconst value: InternalTypes.ValueRequiredState<T> = {\n\t\trev: 0,\n\t\ttimestamp: Date.now(),\n\t\tvalue: shallowCloneObject(initialValue),\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<LatestValueManager<T>>;\n\t} => ({\n\t\tinitialData: { value, allowableUpdateLatencyMs: controls?.allowableUpdateLatencyMs },\n\t\tmanager: brandIVM<LatestValueManagerImpl<T, Key>, T, InternalTypes.ValueRequiredState<T>>(\n\t\t\tnew LatestValueManagerImpl(key, datastoreFromHandle(datastoreHandle), value, controls),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestValueManagerImpl });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"latestValueManager.js","sourceRoot":"","sources":["../src/latestValueManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA6D;AAO7D,kEAAyE;AAGzE,iEAAkE;AAGlE,yDAAqE;AAGrE,2DAA+E;AAC/E,uDAA6C;AAwE7C,MAAM,sBAAsB;IAM3B,YACkB,GAAQ,EACR,SAAmE,EACpE,KAA0C,EAC1D,eAAqD;QAHpC,QAAG,GAAH,GAAG,CAAK;QACR,cAAS,GAAT,SAAS,CAA0D;QACpE,UAAK,GAAL,KAAK,CAAqC;QAN3C,WAAM,GAAG,IAAA,4BAAa,GAAsB,CAAC;QAS5D,IAAI,CAAC,QAAQ,GAAG,IAAI,+CAAwB,CAAC,eAAe,CAAC,CAAC;IAC/D,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;IAChC,CAA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CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO;YACN,GAAG,EAAE,CACJ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE;gBACjC,QAAQ;gBACR,KAAK,EAAE,IAAA,mCAAgB,EAAC,KAAK,CAAC,KAAK,CAAC;gBACpC,QAAQ,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE;aAC7D,CAAC;SACH,CAAC;IACH,CAAC;CACD;AAoBD;;;;GAIG;AACH,SAAgB,MAAM,CACrB,IAAwB;IAExB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAEjC,wEAAwE;IACxE,6BAA6B;IAC7B,MAAM,KAAK,GAAwC;QAClD,GAAG,EAAE,CAAC;QACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,6BAAkB,EAAC,KAAK,CAAC;KACzD,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,0BAAQ,EAChB,IAAI,sBAAsB,CAAC,GAAG,EAAE,IAAA,uCAAmB,EAAC,eAAe,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CACtF;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC,CAAC;AACzE,CAAC;AA5BD,wBA4BC","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 { Listenable } from \"@fluidframework/core-interfaces\";\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 { BroadcastControls, BroadcastControlSettings } from \"./broadcastControls.js\";\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { PostUpdateAction, ValueManager } from \"./internalTypes.js\";\nimport { asDeeplyReadonly, objectEntries } from \"./internalUtils.js\";\nimport type { LatestClientData, LatestData } from \"./latestValueTypes.js\";\nimport type { Attendee, Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface LatestRawEvents<T> {\n\t/**\n\t * Raised when remote client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tremoteUpdated: (update: LatestClientData<T>) => void;\n\n\t/**\n\t * Raised when local client's value is updated, which may be the same value.\n\t *\n\t * @eventProperty\n\t */\n\tlocalUpdated: (update: {\n\t\tvalue: DeepReadonly<JsonSerializable<T> & JsonDeserialized<T>>;\n\t}) => void;\n}\n\n/**\n * State that provides the latest known value from this client to others and read access to their values.\n * All participant clients must provide a value.\n *\n * @remarks Create using {@link StateFactory.latest} registered to {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestRaw<T> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for LatestRaw.\n\t */\n\treadonly events: Listenable<LatestRawEvents<T>>;\n\n\t/**\n\t * Controls for management of sending updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Current state for this client.\n\t * State for this client that will be transmitted to all other connected clients.\n\t * @remarks Manager assumes ownership of the value and its references. Make a deep clone before\n\t * setting, if needed. No comparison is done to detect changes; all sets are transmitted.\n\t */\n\tget local(): DeepReadonly<JsonDeserialized<T>>;\n\tset local(value: JsonSerializable<T> & JsonDeserialized<T>);\n\n\t/**\n\t * Iterable access to remote clients' values.\n\t */\n\tgetRemotes(): IterableIterator<LatestClientData<T>>;\n\t/**\n\t * Array of {@link Attendee}s that have provided states.\n\t */\n\tgetStateAttendees(): Attendee[];\n\t/**\n\t * Access to a specific attendee's value.\n\t */\n\tgetRemote(attendee: Attendee): LatestData<T>;\n}\n\nclass LatestValueManagerImpl<T, Key extends string>\n\timplements LatestRaw<T>, Required<ValueManager<T, InternalTypes.ValueRequiredState<T>>>\n{\n\tpublic readonly events = createEmitter<LatestRawEvents<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) {\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 asDeeplyReadonly(this.value.value);\n\t}\n\n\tpublic set local(value: JsonSerializable<T> & JsonDeserialized<T>) {\n\t\tthis.value.rev += 1;\n\t\tthis.value.timestamp = Date.now();\n\t\tthis.value.value = 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>> {\n\t\tconst allKnownStates = this.datastore.knownValues(this.key);\n\t\tfor (const [attendeeId, value] of objectEntries(allKnownStates.states)) {\n\t\t\tif (attendeeId !== allKnownStates.self) {\n\t\t\t\tyield {\n\t\t\t\t\tattendee: this.datastore.lookupClient(attendeeId),\n\t\t\t\t\tvalue: asDeeplyReadonly(value.value),\n\t\t\t\t\tmetadata: { revision: value.rev, timestamp: value.timestamp },\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.lookupClient(attendeeId));\n\t}\n\n\tpublic getRemote(attendee: Attendee): LatestData<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 clientId\");\n\t\t}\n\t\treturn {\n\t\t\tvalue: asDeeplyReadonly(clientState.value),\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: asDeeplyReadonly(value.value),\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 * Arguments that are passed to the {@link StateFactory.latest} function.\n *\n * @alpha\n */\nexport interface LatestArguments<T extends object | null> {\n\t/**\n\t * The initial value of the local state.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tlocal: JsonSerializable<T> & JsonDeserialized<T> & (object | null);\n\n\t/**\n\t * See {@link BroadcastControlSettings}.\n\t */\n\tsettings?: BroadcastControlSettings | undefined;\n}\n\n/**\n * Factory for creating a {@link LatestRaw} State object.\n *\n * @alpha\n */\nexport function latest<T extends object | null, Key extends string = string>(\n\targs: LatestArguments<T>,\n): InternalTypes.ManagerFactory<Key, InternalTypes.ValueRequiredState<T>, LatestRaw<T>> {\n\tconst { local, settings } = args;\n\n\t// Latest takes ownership of the initial local value but makes a shallow\n\t// copy for basic protection.\n\tconst value: InternalTypes.ValueRequiredState<T> = {\n\t\trev: 0,\n\t\ttimestamp: Date.now(),\n\t\tvalue: local === null ? local : shallowCloneObject(local),\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>>;\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(key, datastoreFromHandle(datastoreHandle), value, settings),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: LatestValueManagerImpl });\n}\n"]}
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import type { JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
-
import type {
|
|
7
|
-
import type { ISessionClient } from "./presence.js";
|
|
5
|
+
import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
+
import type { Attendee } from "./presence.js";
|
|
8
7
|
/**
|
|
9
8
|
* Metadata for the value state.
|
|
10
9
|
*
|
|
11
10
|
* @sealed
|
|
12
11
|
* @alpha
|
|
13
12
|
*/
|
|
14
|
-
export interface
|
|
13
|
+
export interface LatestMetadata {
|
|
15
14
|
/**
|
|
16
15
|
* The revision number for value that increases as value is changed.
|
|
17
16
|
*/
|
|
@@ -28,17 +27,17 @@ export interface LatestValueMetadata {
|
|
|
28
27
|
* @sealed
|
|
29
28
|
* @alpha
|
|
30
29
|
*/
|
|
31
|
-
export interface
|
|
32
|
-
value:
|
|
33
|
-
metadata:
|
|
30
|
+
export interface LatestData<T> {
|
|
31
|
+
value: DeepReadonly<JsonDeserialized<T>>;
|
|
32
|
+
metadata: LatestMetadata;
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
|
-
* State of a specific
|
|
35
|
+
* State of a specific attendee's value and its metadata.
|
|
37
36
|
*
|
|
38
37
|
* @sealed
|
|
39
38
|
* @alpha
|
|
40
39
|
*/
|
|
41
|
-
export interface
|
|
42
|
-
|
|
40
|
+
export interface LatestClientData<T> extends LatestData<T> {
|
|
41
|
+
attendee: Attendee;
|
|
43
42
|
}
|
|
44
43
|
//# sourceMappingURL=latestValueTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueTypes.d.ts","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"latestValueTypes.d.ts","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC9B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,KAAK,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IACzD,QAAQ,EAAE,QAAQ,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueTypes.js","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {
|
|
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 * @alpha\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 * State of a value and its metadata.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestData<T> {\n\tvalue: DeepReadonly<JsonDeserialized<T>>;\n\tmetadata: LatestMetadata;\n}\n\n/**\n * State of a specific attendee's value and its metadata.\n *\n * @sealed\n * @alpha\n */\nexport interface LatestClientData<T> extends LatestData<T> {\n\tattendee: Attendee;\n}\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { Listenable, Off } from "@fluidframework/core-interfaces";
|
|
6
6
|
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
7
7
|
import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { Attendee, Presence } from "./presence.js";
|
|
9
9
|
/**
|
|
10
10
|
* @sealed
|
|
11
11
|
* @alpha
|
|
@@ -16,7 +16,7 @@ export interface NotificationsManagerEvents {
|
|
|
16
16
|
*
|
|
17
17
|
* @eventProperty
|
|
18
18
|
*/
|
|
19
|
-
unattendedNotification: (name: string, sender:
|
|
19
|
+
unattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* An object which allows the registration of listeners so that subscribers can be
|
|
@@ -37,7 +37,7 @@ export interface NotificationListenable<TListeners extends InternalUtilityTypes.
|
|
|
37
37
|
* @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.
|
|
38
38
|
* If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.
|
|
39
39
|
*/
|
|
40
|
-
on<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender:
|
|
40
|
+
on<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): Off;
|
|
41
41
|
/**
|
|
42
42
|
* Deregister notification listener.
|
|
43
43
|
* @param notificationName - The name of the notification.
|
|
@@ -46,7 +46,7 @@ export interface NotificationListenable<TListeners extends InternalUtilityTypes.
|
|
|
46
46
|
*
|
|
47
47
|
* Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.
|
|
48
48
|
*/
|
|
49
|
-
off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender:
|
|
49
|
+
off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Record of notification subscriptions.
|
|
@@ -55,7 +55,7 @@ export interface NotificationListenable<TListeners extends InternalUtilityTypes.
|
|
|
55
55
|
* @alpha
|
|
56
56
|
*/
|
|
57
57
|
export type NotificationSubscriptions<E extends InternalUtilityTypes.NotificationListeners<E>> = {
|
|
58
|
-
[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (sender:
|
|
58
|
+
[K in string & keyof InternalUtilityTypes.NotificationListeners<E>]: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>) => void;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Interface for a notification emitter that can send typed notification to other clients.
|
|
@@ -71,23 +71,28 @@ export interface NotificationEmitter<E extends InternalUtilityTypes.Notification
|
|
|
71
71
|
*/
|
|
72
72
|
broadcast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, ...args: Parameters<E[K]>): void;
|
|
73
73
|
/**
|
|
74
|
-
* Emits a notification with the specified name and arguments, notifying a single
|
|
74
|
+
* Emits a notification with the specified name and arguments, notifying a single attendee.
|
|
75
75
|
* @param notificationName - the name of the notification to fire
|
|
76
|
-
* @param
|
|
76
|
+
* @param targetAttendee - the single attendee to notify
|
|
77
77
|
* @param args - the arguments sent with the notification
|
|
78
78
|
*/
|
|
79
|
-
unicast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K,
|
|
79
|
+
unicast<K extends string & keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, targetAttendee: Attendee, ...args: Parameters<E[K]>): void;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
82
|
+
* Provides notifications from this client to others and subscription
|
|
83
83
|
* to their notifications.
|
|
84
84
|
*
|
|
85
|
-
* @remarks Create using {@link Notifications} registered to
|
|
85
|
+
* @remarks Create using {@link Notifications} registered to
|
|
86
|
+
* {@link NotificationsWorkspace} or {@link StatesWorkspace}.
|
|
86
87
|
*
|
|
87
88
|
* @sealed
|
|
88
89
|
* @alpha
|
|
89
90
|
*/
|
|
90
91
|
export interface NotificationsManager<T extends InternalUtilityTypes.NotificationListeners<T>> {
|
|
92
|
+
/**
|
|
93
|
+
* Containing {@link Presence}
|
|
94
|
+
*/
|
|
95
|
+
readonly presence: Presence;
|
|
91
96
|
/**
|
|
92
97
|
* Events for Notifications manager.
|
|
93
98
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAGlF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAa,UAAU,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAGlF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIxD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,sBAAsB,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