@fluidframework/presence 2.92.0 → 2.100.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 +4 -4
- package/dist/alpha.d.ts +6 -4
- package/dist/beta.d.ts +5 -2
- package/dist/getPresence.d.ts +4 -9
- package/dist/getPresence.d.ts.map +1 -1
- package/dist/getPresence.js +6 -86
- package/dist/getPresence.js.map +1 -1
- package/dist/index.d.ts +4 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/legacy.alpha.d.ts +6 -4
- package/dist/package.json +1 -15
- package/dist/public.d.ts +69 -0
- package/lib/alpha.d.ts +6 -4
- package/lib/beta.d.ts +5 -2
- package/lib/getPresence.d.ts +4 -9
- package/lib/getPresence.d.ts.map +1 -1
- package/lib/getPresence.js +6 -85
- package/lib/getPresence.js.map +1 -1
- package/lib/index.d.ts +4 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/legacy.alpha.d.ts +6 -4
- package/lib/public.d.ts +69 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/package.json +32 -78
- package/dist/baseTypes.d.ts +0 -24
- package/dist/baseTypes.d.ts.map +0 -1
- package/dist/baseTypes.js +0 -7
- package/dist/baseTypes.js.map +0 -1
- package/dist/broadcastControls.d.ts +0 -37
- package/dist/broadcastControls.d.ts.map +0 -1
- package/dist/broadcastControls.js +0 -60
- package/dist/broadcastControls.js.map +0 -1
- package/dist/broadcastControlsTypes.d.ts +0 -38
- package/dist/broadcastControlsTypes.d.ts.map +0 -1
- package/dist/broadcastControlsTypes.js +0 -7
- package/dist/broadcastControlsTypes.js.map +0 -1
- package/dist/exposedInternalTypes.d.ts +0 -138
- package/dist/exposedInternalTypes.d.ts.map +0 -1
- package/dist/exposedInternalTypes.js +0 -19
- package/dist/exposedInternalTypes.js.map +0 -1
- package/dist/exposedUtilityTypes.d.ts +0 -108
- package/dist/exposedUtilityTypes.d.ts.map +0 -1
- package/dist/exposedUtilityTypes.js +0 -7
- package/dist/exposedUtilityTypes.js.map +0 -1
- package/dist/internalUtils.d.ts +0 -125
- package/dist/internalUtils.d.ts.map +0 -1
- package/dist/internalUtils.js +0 -99
- package/dist/internalUtils.js.map +0 -1
- package/dist/latestMapTypes.d.ts +0 -343
- package/dist/latestMapTypes.d.ts.map +0 -1
- package/dist/latestMapTypes.js +0 -7
- package/dist/latestMapTypes.js.map +0 -1
- package/dist/latestMapValueManager.d.ts +0 -52
- package/dist/latestMapValueManager.d.ts.map +0 -1
- package/dist/latestMapValueManager.js +0 -250
- package/dist/latestMapValueManager.js.map +0 -1
- package/dist/latestTypes.d.ts +0 -183
- package/dist/latestTypes.d.ts.map +0 -1
- package/dist/latestTypes.js +0 -7
- package/dist/latestTypes.js.map +0 -1
- package/dist/latestValueManager.d.ts +0 -10
- package/dist/latestValueManager.d.ts.map +0 -1
- package/dist/latestValueManager.js +0 -117
- package/dist/latestValueManager.js.map +0 -1
- package/dist/latestValueTypes.d.ts +0 -108
- package/dist/latestValueTypes.d.ts.map +0 -1
- package/dist/latestValueTypes.js +0 -7
- package/dist/latestValueTypes.js.map +0 -1
- package/dist/notificationsManager.d.ts +0 -27
- package/dist/notificationsManager.d.ts.map +0 -1
- package/dist/notificationsManager.js +0 -98
- package/dist/notificationsManager.js.map +0 -1
- package/dist/notificationsManagerTypes.d.ts +0 -144
- package/dist/notificationsManagerTypes.d.ts.map +0 -1
- package/dist/notificationsManagerTypes.js +0 -7
- package/dist/notificationsManagerTypes.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/presence.d.ts +0 -229
- package/dist/presence.d.ts.map +0 -1
- package/dist/presence.js +0 -23
- package/dist/presence.js.map +0 -1
- package/dist/presenceDatastoreManager.d.ts +0 -149
- package/dist/presenceDatastoreManager.d.ts.map +0 -1
- package/dist/presenceDatastoreManager.js +0 -667
- package/dist/presenceDatastoreManager.js.map +0 -1
- package/dist/presenceManager.d.ts +0 -16
- package/dist/presenceManager.d.ts.map +0 -1
- package/dist/presenceManager.js +0 -140
- package/dist/presenceManager.js.map +0 -1
- package/dist/presenceStates.d.ts +0 -102
- package/dist/presenceStates.d.ts.map +0 -1
- package/dist/presenceStates.js +0 -231
- package/dist/presenceStates.js.map +0 -1
- package/dist/protocol.d.ts +0 -111
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -20
- package/dist/protocol.js.map +0 -1
- package/dist/runtimeTypes.d.ts +0 -26
- package/dist/runtimeTypes.d.ts.map +0 -1
- package/dist/runtimeTypes.js +0 -7
- package/dist/runtimeTypes.js.map +0 -1
- package/dist/stateDatastore.d.ts +0 -56
- package/dist/stateDatastore.d.ts.map +0 -1
- package/dist/stateDatastore.js +0 -22
- package/dist/stateDatastore.js.map +0 -1
- package/dist/stateFactory.d.ts +0 -18
- package/dist/stateFactory.d.ts.map +0 -1
- package/dist/stateFactory.js +0 -23
- package/dist/stateFactory.js.map +0 -1
- package/dist/statesManagerTypes.d.ts +0 -27
- package/dist/statesManagerTypes.d.ts.map +0 -1
- package/dist/statesManagerTypes.js +0 -7
- package/dist/statesManagerTypes.js.map +0 -1
- package/dist/systemWorkspace.d.ts +0 -58
- package/dist/systemWorkspace.d.ts.map +0 -1
- package/dist/systemWorkspace.js +0 -265
- package/dist/systemWorkspace.js.map +0 -1
- package/dist/timerManager.d.ts +0 -37
- package/dist/timerManager.d.ts.map +0 -1
- package/dist/timerManager.js +0 -65
- package/dist/timerManager.js.map +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
- package/dist/validatableTypes.d.ts +0 -69
- package/dist/validatableTypes.d.ts.map +0 -1
- package/dist/validatableTypes.js +0 -7
- package/dist/validatableTypes.js.map +0 -1
- package/dist/validatedGetter.d.ts +0 -18
- package/dist/validatedGetter.d.ts.map +0 -1
- package/dist/validatedGetter.js +0 -43
- package/dist/validatedGetter.js.map +0 -1
- package/dist/valueManager.d.ts +0 -15
- package/dist/valueManager.d.ts.map +0 -1
- package/dist/valueManager.js +0 -22
- package/dist/valueManager.js.map +0 -1
- package/lib/baseTypes.d.ts +0 -24
- package/lib/baseTypes.d.ts.map +0 -1
- package/lib/baseTypes.js +0 -6
- package/lib/baseTypes.js.map +0 -1
- package/lib/broadcastControls.d.ts +0 -37
- package/lib/broadcastControls.d.ts.map +0 -1
- package/lib/broadcastControls.js +0 -55
- package/lib/broadcastControls.js.map +0 -1
- package/lib/broadcastControlsTypes.d.ts +0 -38
- package/lib/broadcastControlsTypes.d.ts.map +0 -1
- package/lib/broadcastControlsTypes.js +0 -6
- package/lib/broadcastControlsTypes.js.map +0 -1
- package/lib/exposedInternalTypes.d.ts +0 -138
- package/lib/exposedInternalTypes.d.ts.map +0 -1
- package/lib/exposedInternalTypes.js +0 -16
- package/lib/exposedInternalTypes.js.map +0 -1
- package/lib/exposedUtilityTypes.d.ts +0 -108
- package/lib/exposedUtilityTypes.d.ts.map +0 -1
- package/lib/exposedUtilityTypes.js +0 -6
- package/lib/exposedUtilityTypes.js.map +0 -1
- package/lib/internalUtils.d.ts +0 -125
- package/lib/internalUtils.d.ts.map +0 -1
- package/lib/internalUtils.js +0 -90
- package/lib/internalUtils.js.map +0 -1
- package/lib/latestMapTypes.d.ts +0 -343
- package/lib/latestMapTypes.d.ts.map +0 -1
- package/lib/latestMapTypes.js +0 -6
- package/lib/latestMapTypes.js.map +0 -1
- package/lib/latestMapValueManager.d.ts +0 -52
- package/lib/latestMapValueManager.d.ts.map +0 -1
- package/lib/latestMapValueManager.js +0 -246
- package/lib/latestMapValueManager.js.map +0 -1
- package/lib/latestTypes.d.ts +0 -183
- package/lib/latestTypes.d.ts.map +0 -1
- package/lib/latestTypes.js +0 -6
- package/lib/latestTypes.js.map +0 -1
- package/lib/latestValueManager.d.ts +0 -10
- package/lib/latestValueManager.d.ts.map +0 -1
- package/lib/latestValueManager.js +0 -113
- package/lib/latestValueManager.js.map +0 -1
- package/lib/latestValueTypes.d.ts +0 -108
- package/lib/latestValueTypes.d.ts.map +0 -1
- package/lib/latestValueTypes.js +0 -6
- package/lib/latestValueTypes.js.map +0 -1
- package/lib/notificationsManager.d.ts +0 -27
- package/lib/notificationsManager.d.ts.map +0 -1
- package/lib/notificationsManager.js +0 -94
- package/lib/notificationsManager.js.map +0 -1
- package/lib/notificationsManagerTypes.d.ts +0 -144
- package/lib/notificationsManagerTypes.d.ts.map +0 -1
- package/lib/notificationsManagerTypes.js +0 -6
- package/lib/notificationsManagerTypes.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/lib/presence.d.ts +0 -229
- package/lib/presence.d.ts.map +0 -1
- package/lib/presence.js +0 -20
- package/lib/presence.js.map +0 -1
- package/lib/presenceDatastoreManager.d.ts +0 -149
- package/lib/presenceDatastoreManager.d.ts.map +0 -1
- package/lib/presenceDatastoreManager.js +0 -663
- package/lib/presenceDatastoreManager.js.map +0 -1
- package/lib/presenceManager.d.ts +0 -16
- package/lib/presenceManager.d.ts.map +0 -1
- package/lib/presenceManager.js +0 -136
- package/lib/presenceManager.js.map +0 -1
- package/lib/presenceStates.d.ts +0 -102
- package/lib/presenceStates.d.ts.map +0 -1
- package/lib/presenceStates.js +0 -225
- package/lib/presenceStates.js.map +0 -1
- package/lib/protocol.d.ts +0 -111
- package/lib/protocol.d.ts.map +0 -1
- package/lib/protocol.js +0 -17
- package/lib/protocol.js.map +0 -1
- package/lib/runtimeTypes.d.ts +0 -26
- package/lib/runtimeTypes.d.ts.map +0 -1
- package/lib/runtimeTypes.js +0 -6
- package/lib/runtimeTypes.js.map +0 -1
- package/lib/stateDatastore.d.ts +0 -56
- package/lib/stateDatastore.d.ts.map +0 -1
- package/lib/stateDatastore.js +0 -17
- package/lib/stateDatastore.js.map +0 -1
- package/lib/stateFactory.d.ts +0 -18
- package/lib/stateFactory.d.ts.map +0 -1
- package/lib/stateFactory.js +0 -20
- package/lib/stateFactory.js.map +0 -1
- package/lib/statesManagerTypes.d.ts +0 -27
- package/lib/statesManagerTypes.d.ts.map +0 -1
- package/lib/statesManagerTypes.js +0 -6
- package/lib/statesManagerTypes.js.map +0 -1
- package/lib/systemWorkspace.d.ts +0 -58
- package/lib/systemWorkspace.d.ts.map +0 -1
- package/lib/systemWorkspace.js +0 -261
- package/lib/systemWorkspace.js.map +0 -1
- package/lib/timerManager.d.ts +0 -37
- package/lib/timerManager.d.ts.map +0 -1
- package/lib/timerManager.js +0 -61
- package/lib/timerManager.js.map +0 -1
- package/lib/types.d.ts +0 -132
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/lib/validatableTypes.d.ts +0 -69
- package/lib/validatableTypes.d.ts.map +0 -1
- package/lib/validatableTypes.js +0 -6
- package/lib/validatableTypes.js.map +0 -1
- package/lib/validatedGetter.d.ts +0 -18
- package/lib/validatedGetter.d.ts.map +0 -1
- package/lib/validatedGetter.js +0 -39
- package/lib/validatedGetter.js.map +0 -1
- package/lib/valueManager.d.ts +0 -15
- package/lib/valueManager.d.ts.map +0 -1
- package/lib/valueManager.js +0 -17
- package/lib/valueManager.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueManager.js","sourceRoot":"","sources":["../src/latestValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAIlE,OAAO,EACN,gBAAgB,EAChB,gCAAgC,EAChC,aAA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AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkB,CACpC,IAA2E,EAK1E,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC5C,wEAAwE;IACxE,6BAA6B;IAC7B,MAAM,WAAW,GAAG,YAAY,CAAI,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,QAAQ,CAChB,IAAI,sBAAsB,CACzB,GAAG,EACH,mBAAmB,CAAC,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","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\tDeepReadonly,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\nimport { shallowCloneObject } from \"@fluidframework/core-utils/internal\";\n\nimport { OptionalBroadcastControl } from \"./broadcastControls.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { FlattenUnionWithOptionals } from \"./internalUtils.js\";\nimport {\n\tasDeeplyReadonly,\n\tasDeeplyReadonlyDeserializedJson,\n\tobjectEntries,\n\ttoOpaqueJson,\n} from \"./internalUtils.js\";\nimport type {\n\tLatest,\n\tLatestArguments,\n\tLatestArgumentsRaw,\n\tLatestEvents,\n\tLatestFactory,\n\tLatestRaw,\n} from \"./latestTypes.js\";\nimport type {\n\tLatestClientData,\n\tLatestData,\n\tStateSchemaValidator,\n\tValueAccessor,\n} from \"./latestValueTypes.js\";\nimport type { Attendee, Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport { createValidatedGetter } from \"./validatedGetter.js\";\nimport { brandIVM } from \"./valueManager.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,108 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { DeepReadonly, JsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
-
import type { Attendee } from "./presence.js";
|
|
7
|
-
/**
|
|
8
|
-
* Metadata for the value state.
|
|
9
|
-
*
|
|
10
|
-
* @sealed
|
|
11
|
-
* @beta
|
|
12
|
-
*/
|
|
13
|
-
export interface LatestMetadata {
|
|
14
|
-
/**
|
|
15
|
-
* The revision number for value that increases as value is changed.
|
|
16
|
-
*/
|
|
17
|
-
revision: number;
|
|
18
|
-
/**
|
|
19
|
-
* Local time when the value was last updated.
|
|
20
|
-
* @remarks Currently this is a placeholder for future implementation.
|
|
21
|
-
*/
|
|
22
|
-
timestamp: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Represents a value that is accessed directly.
|
|
26
|
-
*
|
|
27
|
-
* @system
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
|
-
export interface RawValueAccessor<T> {
|
|
31
|
-
readonly kind: "raw";
|
|
32
|
-
readonly data: T;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Represents a value that is accessed via a function call, which may result in no value.
|
|
36
|
-
*
|
|
37
|
-
* @system
|
|
38
|
-
* @beta
|
|
39
|
-
*/
|
|
40
|
-
export interface ProxiedValueAccessor<T> {
|
|
41
|
-
readonly kind: "proxied";
|
|
42
|
-
readonly data: T;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Union of possible accessor types for a value.
|
|
46
|
-
*
|
|
47
|
-
* @system
|
|
48
|
-
* @beta
|
|
49
|
-
*/
|
|
50
|
-
export type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;
|
|
51
|
-
/**
|
|
52
|
-
* Utility type that conditionally represents an accessor type based on the base accessor type.
|
|
53
|
-
*
|
|
54
|
-
* @system
|
|
55
|
-
* @beta
|
|
56
|
-
*/
|
|
57
|
-
export type Accessor<T, BaseAccessor extends ValueAccessor<T>> = BaseAccessor extends ProxiedValueAccessor<T> ? () => DeepReadonly<JsonDeserialized<T>> | undefined : BaseAccessor extends RawValueAccessor<T> ? DeepReadonly<JsonDeserialized<T>> : never;
|
|
58
|
-
/**
|
|
59
|
-
* State of a value and its metadata.
|
|
60
|
-
*
|
|
61
|
-
* @sealed
|
|
62
|
-
* @beta
|
|
63
|
-
*/
|
|
64
|
-
export interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {
|
|
65
|
-
/**
|
|
66
|
-
* The value of the state or an accessor function.
|
|
67
|
-
*
|
|
68
|
-
* @remarks
|
|
69
|
-
* If the State object was created with a {@link StateSchemaValidator}, then the `value`
|
|
70
|
-
* will be a function returning a validated, deeply readonly `T` or `undefined`.
|
|
71
|
-
* Without a validator, `value` will be an unvalidated, deeply readonly `T`.
|
|
72
|
-
*
|
|
73
|
-
* Any `T` is always deeply readonly, meaning it cannot be modified.
|
|
74
|
-
*/
|
|
75
|
-
value: Accessor<T, TValueAccessor>;
|
|
76
|
-
/**
|
|
77
|
-
* Metadata associated with the value.
|
|
78
|
-
*/
|
|
79
|
-
metadata: LatestMetadata;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* State of a specific {@link Attendee}'s value and its metadata.
|
|
83
|
-
*
|
|
84
|
-
* @sealed
|
|
85
|
-
* @beta
|
|
86
|
-
*/
|
|
87
|
-
export interface LatestClientData<T, TValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>> extends LatestData<T, TValueAccessor> {
|
|
88
|
-
/**
|
|
89
|
-
* Associated {@link Attendee}.
|
|
90
|
-
*/
|
|
91
|
-
attendee: Attendee;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* A validator function that can optionally be provided to do runtime validation of the custom data stored in a
|
|
95
|
-
* presence workspace and managed by a state object.
|
|
96
|
-
*
|
|
97
|
-
* @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**
|
|
98
|
-
*
|
|
99
|
-
* @returns The validated data, or `undefined` if the data is invalid.
|
|
100
|
-
*
|
|
101
|
-
* @beta
|
|
102
|
-
*/
|
|
103
|
-
export type StateSchemaValidator<T> = (
|
|
104
|
-
/**
|
|
105
|
-
* Unknown data that should be validated. **This data should not be mutated.**
|
|
106
|
-
*/
|
|
107
|
-
unvalidatedData: unknown) => JsonDeserialized<T> | undefined;
|
|
108
|
-
//# sourceMappingURL=latestValueTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,gBAAgB,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,YAAY,SAAS,aAAa,CAAC,CAAC,CAAC,IAC5D,YAAY,SAAS,oBAAoB,CAAC,CAAC,CAAC,GACzC,MAAM,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GACnD,YAAY,SAAS,gBAAgB,CAAC,CAAC,CAAC,GACvC,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACjC,KAAK,CAAC;AAEX;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,cAAc,SAAS,aAAa,CAAC,CAAC,CAAC;IACrE;;;;;;;;;OASG;IACH,KAAK,EAAE,QAAQ,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAEnC;;OAEG;IACH,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAChC,CAAC,EACD,cAAc,SAAS,aAAa,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAChE,SAAQ,UAAU,CAAC,CAAC,EAAE,cAAc,CAAC;IACtC;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;AACrC;;GAEG;AACH,eAAe,EAAE,OAAO,KACpB,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC"}
|
package/lib/latestValueTypes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"latestValueTypes.js","sourceRoot":"","sources":["../src/latestValueTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tDeepReadonly,\n\tJsonDeserialized,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * Metadata for the value state.\n *\n * @sealed\n * @beta\n */\nexport interface LatestMetadata {\n\t/**\n\t * The revision number for value that increases as value is changed.\n\t */\n\trevision: number;\n\t/**\n\t * Local time when the value was last updated.\n\t * @remarks Currently this is a placeholder for future implementation.\n\t */\n\ttimestamp: number;\n}\n\n/**\n * Represents a value that is accessed directly.\n *\n * @system\n * @beta\n */\nexport interface RawValueAccessor<T> {\n\treadonly kind: \"raw\";\n\treadonly data: T;\n}\n\n/**\n * Represents a value that is accessed via a function call, which may result in no value.\n *\n * @system\n * @beta\n */\nexport interface ProxiedValueAccessor<T> {\n\treadonly kind: \"proxied\";\n\treadonly data: T;\n}\n\n/**\n * Union of possible accessor types for a value.\n *\n * @system\n * @beta\n */\nexport type ValueAccessor<T> = RawValueAccessor<T> | ProxiedValueAccessor<T>;\n\n/**\n * Utility type that conditionally represents an accessor type based on the base accessor type.\n *\n * @system\n * @beta\n */\nexport type Accessor<T, BaseAccessor extends ValueAccessor<T>> =\n\tBaseAccessor extends ProxiedValueAccessor<T>\n\t\t? () => DeepReadonly<JsonDeserialized<T>> | undefined\n\t\t: BaseAccessor extends RawValueAccessor<T>\n\t\t\t? DeepReadonly<JsonDeserialized<T>>\n\t\t\t: never;\n\n/**\n * State of a value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestData<T, TValueAccessor extends ValueAccessor<T>> {\n\t/**\n\t * The value of the state or an accessor function.\n\t *\n\t * @remarks\n\t * If the State object was created with a {@link StateSchemaValidator}, then the `value`\n\t * will be a function returning a validated, deeply readonly `T` or `undefined`.\n\t * Without a validator, `value` will be an unvalidated, deeply readonly `T`.\n\t *\n\t * Any `T` is always deeply readonly, meaning it cannot be modified.\n\t */\n\tvalue: Accessor<T, TValueAccessor>;\n\n\t/**\n\t * Metadata associated with the value.\n\t */\n\tmetadata: LatestMetadata;\n}\n\n/**\n * State of a specific {@link Attendee}'s value and its metadata.\n *\n * @sealed\n * @beta\n */\nexport interface LatestClientData<\n\tT,\n\tTValueAccessor extends ValueAccessor<T> = ProxiedValueAccessor<T>,\n> extends LatestData<T, TValueAccessor> {\n\t/**\n\t * Associated {@link Attendee}.\n\t */\n\tattendee: Attendee;\n}\n\n/**\n * A validator function that can optionally be provided to do runtime validation of the custom data stored in a\n * presence workspace and managed by a state object.\n *\n * @param unvalidatedData - The unknown data that should be validated. **This data should not be mutated.**\n *\n * @returns The validated data, or `undefined` if the data is invalid.\n *\n * @beta\n */\nexport type StateSchemaValidator<T> = (\n\t/**\n\t * Unknown data that should be validated. **This data should not be mutated.**\n\t */\n\tunvalidatedData: unknown,\n) => JsonDeserialized<T> | undefined;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
|
|
6
|
-
import type { NotificationsConfiguration, NotificationSubscriberSignatures, NotificationsWithSubscriptionsConfiguration } from "./notificationsManagerTypes.js";
|
|
7
|
-
/**
|
|
8
|
-
* Factory for creating a {@link NotificationsManager}.
|
|
9
|
-
*
|
|
10
|
-
* @alpha
|
|
11
|
-
*
|
|
12
|
-
* @privateRemarks
|
|
13
|
-
* This overload requires explicit specification of the notification listener
|
|
14
|
-
* types. It is useful when a schema is separately defined.
|
|
15
|
-
*/
|
|
16
|
-
export declare function Notifications<T extends InternalUtilityTypes.NotificationListeners<T>, Key extends string = string>(initialSubscriptions: Partial<NotificationSubscriberSignatures<T>>): NotificationsConfiguration<T, Key>;
|
|
17
|
-
/**
|
|
18
|
-
* Factory for creating a {@link NotificationsManager}.
|
|
19
|
-
*
|
|
20
|
-
* @alpha
|
|
21
|
-
*
|
|
22
|
-
* @privateRemarks
|
|
23
|
-
* This overload infers the notification listener types from the provided
|
|
24
|
-
* subscriptions, simplifying usage when a schema is not separately defined.
|
|
25
|
-
*/
|
|
26
|
-
export declare function Notifications<TSubscriptions extends InternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>, Key extends string = string>(initialSubscriptions: Partial<TSubscriptions>): NotificationsWithSubscriptionsConfiguration<TSubscriptions, Key>;
|
|
27
|
-
//# sourceMappingURL=notificationsManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsManager.d.ts","sourceRoot":"","sources":["../src/notificationsManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAGX,0BAA0B,EAG1B,gCAAgC,EAChC,2CAA2C,EAC3C,MAAM,gCAAgC,CAAC;AAoHxC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,CAAC,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EACvD,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC,CAAC,CAAC,GAChE,0BAA0B,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtC;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,cAAc,SACb,oBAAoB,CAAC,6CAA6C,CAAC,cAAc,CAAC,EACnF,GAAG,SAAS,MAAM,GAAG,MAAM,EAE3B,oBAAoB,EAAE,OAAO,CAAC,cAAc,CAAC,GAC3C,2CAA2C,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { createEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import { revealOpaqueJson, toOpaqueJson } from "./internalUtils.js";
|
|
7
|
-
import { datastoreFromHandle } from "./stateDatastore.js";
|
|
8
|
-
import { brandIVM } from "./valueManager.js";
|
|
9
|
-
/**
|
|
10
|
-
* Object.keys retyped to support specific records keys and
|
|
11
|
-
* branded string-based keys.
|
|
12
|
-
*/
|
|
13
|
-
const recordKeys = Object.keys;
|
|
14
|
-
class NotificationsManagerImpl {
|
|
15
|
-
constructor(key, datastore, initialSubscriptions) {
|
|
16
|
-
this.key = key;
|
|
17
|
-
this.datastore = datastore;
|
|
18
|
-
this.events = createEmitter();
|
|
19
|
-
this.emit = {
|
|
20
|
-
broadcast: (name, ...args) => {
|
|
21
|
-
this.datastore.localUpdate(this.key, {
|
|
22
|
-
rev: 0,
|
|
23
|
-
timestamp: 0,
|
|
24
|
-
value: toOpaqueJson({
|
|
25
|
-
name,
|
|
26
|
-
args: [...args],
|
|
27
|
-
}),
|
|
28
|
-
ignoreUnmonitored: true,
|
|
29
|
-
},
|
|
30
|
-
// This is a notification, so we want to send it immediately.
|
|
31
|
-
{ allowableUpdateLatencyMs: 0 });
|
|
32
|
-
},
|
|
33
|
-
unicast: (name, targetAttendee, ...args) => {
|
|
34
|
-
this.datastore.localUpdate(this.key, {
|
|
35
|
-
rev: 0,
|
|
36
|
-
timestamp: 0,
|
|
37
|
-
value: toOpaqueJson({
|
|
38
|
-
name,
|
|
39
|
-
args: [...args],
|
|
40
|
-
}),
|
|
41
|
-
ignoreUnmonitored: true,
|
|
42
|
-
},
|
|
43
|
-
// This is a notification, so we want to send it immediately.
|
|
44
|
-
{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() });
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
// Workaround for types
|
|
48
|
-
this.notificationsInternal = createEmitter();
|
|
49
|
-
this.notifications = this.notificationsInternal;
|
|
50
|
-
// Add event listeners provided at instantiation
|
|
51
|
-
for (const subscriptionName of recordKeys(initialSubscriptions)) {
|
|
52
|
-
// Lingering Event typing issues with Notifications specialization requires
|
|
53
|
-
// this cast. The only thing that really matters is that name is a string.
|
|
54
|
-
const name = subscriptionName;
|
|
55
|
-
const value = initialSubscriptions[subscriptionName];
|
|
56
|
-
// This check should not be needed while using exactOptionalPropertyTypes, but
|
|
57
|
-
// typescript appears to ignore that with Partial<>. Good to be defensive
|
|
58
|
-
// against callers sending `undefined` anyway.
|
|
59
|
-
if (value !== undefined) {
|
|
60
|
-
this.notificationsInternal.on(name, value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
get presence() {
|
|
65
|
-
return this.datastore.presence;
|
|
66
|
-
}
|
|
67
|
-
update(attendee, _received, updateValue) {
|
|
68
|
-
const postUpdateActions = [];
|
|
69
|
-
const value = revealOpaqueJson(updateValue.value);
|
|
70
|
-
const eventName = value.name;
|
|
71
|
-
if (this.notificationsInternal.hasListeners(eventName)) {
|
|
72
|
-
// Without schema validation, we don't know that the args are the correct type.
|
|
73
|
-
// For now we assume the user is sending the correct types and there is no corruption along the way.
|
|
74
|
-
const args = [attendee, ...value.args];
|
|
75
|
-
postUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
postUpdateActions.push(() => this.events.emit("unattendedNotification", value.name, attendee, ...value.args));
|
|
79
|
-
}
|
|
80
|
-
return postUpdateActions;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Factory for creating a {@link NotificationsManager}.
|
|
85
|
-
*
|
|
86
|
-
* @alpha
|
|
87
|
-
*/
|
|
88
|
-
export function Notifications(initialSubscriptions) {
|
|
89
|
-
const factory = (key, datastoreHandle) => ({
|
|
90
|
-
manager: brandIVM(new NotificationsManagerImpl(key, datastoreFromHandle(datastoreHandle), initialSubscriptions)),
|
|
91
|
-
});
|
|
92
|
-
return Object.assign(factory, { instanceBase: NotificationsManagerImpl });
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=notificationsManager.js.map
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AG,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACnF,CAAC;aAAM,CAAC;YACP,iBAAiB,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAC/E,CAAC;QACH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC1B,CAAC;CACD;AAkCD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAM5B,oBAA6C;IAM7C,MAAM,OAAO,GAAG,CACf,GAAQ,EACR,eAGC,EAGA,EAAE,CAAC,CAAC;QACL,OAAO,EAAE,QAAQ,CAKhB,IAAI,wBAAwB,CAC3B,GAAG,EACH,mBAAmB,CAAC,eAAe,CAAC,EACpC,oBAAoB,CACpB,CACD;KACD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { createEmitter } from \"@fluid-internal/client-utils\";\nimport type { Listeners } from \"@fluidframework/core-interfaces\";\nimport type { JsonTypeWith } from \"@fluidframework/core-interfaces/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport { revealOpaqueJson, toOpaqueJson } from \"./internalUtils.js\";\nimport type {\n\tNotificationEmitter,\n\tNotificationListenable,\n\tNotificationsConfiguration,\n\tNotificationsManager,\n\tNotificationsManagerEvents,\n\tNotificationSubscriberSignatures,\n\tNotificationsWithSubscriptionsConfiguration,\n} from \"./notificationsManagerTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport { datastoreFromHandle, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction, ValueManager } from \"./statesManagerTypes.js\";\nimport { brandIVM } from \"./valueManager.js\";\n\n/**\n * Object.keys retyped to support specific records keys and\n * branded string-based keys.\n */\nconst recordKeys = Object.keys as <K extends string>(o: Partial<Record<K, unknown>>) => K[];\n\nclass NotificationsManagerImpl<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string,\n> implements\n\t\tNotificationsManager<T>,\n\t\tValueManager<\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>\n{\n\tpublic readonly events = createEmitter<NotificationsManagerEvents>();\n\n\tpublic readonly emit: NotificationEmitter<T> = {\n\t\tbroadcast: (name: string, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0 },\n\t\t\t);\n\t\t},\n\t\tunicast: (name: string, targetAttendee, ...args) => {\n\t\t\tthis.datastore.localUpdate(\n\t\t\t\tthis.key,\n\t\t\t\t{\n\t\t\t\t\trev: 0,\n\t\t\t\t\ttimestamp: 0,\n\t\t\t\t\tvalue: toOpaqueJson({\n\t\t\t\t\t\tname,\n\t\t\t\t\t\targs: [...(args as JsonTypeWith<never>[])],\n\t\t\t\t\t}),\n\t\t\t\t\tignoreUnmonitored: true,\n\t\t\t\t},\n\t\t\t\t// This is a notification, so we want to send it immediately.\n\t\t\t\t{ allowableUpdateLatencyMs: 0, targetClientId: targetAttendee.getConnectionId() },\n\t\t\t);\n\t\t},\n\t};\n\n\t// Workaround for types\n\tprivate readonly notificationsInternal =\n\t\tcreateEmitter<NotificationSubscriberSignatures<T>>();\n\n\tpublic readonly notifications: NotificationListenable<T> = this.notificationsInternal;\n\n\tpublic constructor(\n\t\tprivate readonly key: Key,\n\t\tprivate readonly datastore: StateDatastore<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t\tinitialSubscriptions: Partial<NotificationSubscriberSignatures<T>>,\n\t) {\n\t\t// Add event listeners provided at instantiation\n\t\tfor (const subscriptionName of recordKeys(initialSubscriptions)) {\n\t\t\t// Lingering Event typing issues with Notifications specialization requires\n\t\t\t// this cast. The only thing that really matters is that name is a string.\n\t\t\tconst name = subscriptionName as keyof Listeners<NotificationSubscriberSignatures<T>>;\n\t\t\tconst value = initialSubscriptions[subscriptionName];\n\t\t\t// This check should not be needed while using exactOptionalPropertyTypes, but\n\t\t\t// typescript appears to ignore that with Partial<>. Good to be defensive\n\t\t\t// against callers sending `undefined` anyway.\n\t\t\tif (value !== undefined) {\n\t\t\t\tthis.notificationsInternal.on(name, value);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.datastore.presence;\n\t}\n\n\tpublic update(\n\t\tattendee: Attendee,\n\t\t_received: number,\n\t\tupdateValue: InternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tconst value = revealOpaqueJson(updateValue.value);\n\t\tconst eventName = value.name as keyof Listeners<NotificationSubscriberSignatures<T>>;\n\t\tif (this.notificationsInternal.hasListeners(eventName)) {\n\t\t\t// Without schema validation, we don't know that the args are the correct type.\n\t\t\t// For now we assume the user is sending the correct types and there is no corruption along the way.\n\t\t\tconst args = [attendee, ...value.args] as Parameters<\n\t\t\t\tNotificationSubscriberSignatures<T>[typeof eventName]\n\t\t\t>;\n\t\t\tpostUpdateActions.push(() => this.notificationsInternal.emit(eventName, ...args));\n\t\t} else {\n\t\t\tpostUpdateActions.push(() =>\n\t\t\t\tthis.events.emit(\"unattendedNotification\", value.name, attendee, ...value.args),\n\t\t\t);\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n *\n * @privateRemarks\n * This overload requires explicit specification of the notification listener\n * types. It is useful when a schema is separately defined.\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<NotificationSubscriberSignatures<T>>,\n): NotificationsConfiguration<T, Key>;\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n *\n * @privateRemarks\n * This overload infers the notification listener types from the provided\n * subscriptions, simplifying usage when a schema is not separately defined.\n */\nexport function Notifications<\n\tTSubscriptions extends\n\t\tInternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>,\n\tKey extends string = string,\n>(\n\tinitialSubscriptions: Partial<TSubscriptions>,\n): NotificationsWithSubscriptionsConfiguration<TSubscriptions, Key>;\n\n/**\n * Factory for creating a {@link NotificationsManager}.\n *\n * @alpha\n */\nexport function Notifications<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tKey extends string = string,\n\tTSubscriptions extends\n\t\tNotificationSubscriberSignatures<T> = NotificationSubscriberSignatures<T>,\n>(\n\tinitialSubscriptions: Partial<TSubscriptions>,\n): InternalTypes.ManagerFactory<\n\tKey,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n> {\n\tconst factory = (\n\t\tkey: Key,\n\t\tdatastoreHandle: InternalTypes.StateDatastoreHandle<\n\t\t\tKey,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>,\n\t): {\n\t\tmanager: InternalTypes.StateValue<NotificationsManager<T>>;\n\t} => ({\n\t\tmanager: brandIVM<\n\t\t\tNotificationsManagerImpl<T, Key>,\n\t\t\tInternalTypes.NotificationType,\n\t\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>\n\t\t>(\n\t\t\tnew NotificationsManagerImpl(\n\t\t\t\tkey,\n\t\t\t\tdatastoreFromHandle(datastoreHandle),\n\t\t\t\tinitialSubscriptions,\n\t\t\t),\n\t\t),\n\t});\n\treturn Object.assign(factory, { instanceBase: NotificationsManagerImpl });\n}\n"]}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { Listenable, Off } from "@fluidframework/core-interfaces";
|
|
6
|
-
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
7
|
-
import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
|
|
8
|
-
import type { Attendee, PresenceWithNotifications as Presence } from "./presence.js";
|
|
9
|
-
/**
|
|
10
|
-
* @sealed
|
|
11
|
-
* @alpha
|
|
12
|
-
*/
|
|
13
|
-
export interface NotificationsManagerEvents {
|
|
14
|
-
/**
|
|
15
|
-
* Raised when notification is received, but no subscribers were found.
|
|
16
|
-
*
|
|
17
|
-
* @eventProperty
|
|
18
|
-
*/
|
|
19
|
-
unattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* An object which allows the registration of listeners so that subscribers can be
|
|
23
|
-
* notified when a notification happens.
|
|
24
|
-
*
|
|
25
|
-
* @sealed
|
|
26
|
-
* @alpha
|
|
27
|
-
*/
|
|
28
|
-
export interface NotificationListenable<TListeners extends InternalUtilityTypes.NotificationListeners<TListeners>> {
|
|
29
|
-
/**
|
|
30
|
-
* Register a notification listener.
|
|
31
|
-
* @param notificationName - the name of the notification
|
|
32
|
-
* @param listener - The listener function to run when the notification is fired.
|
|
33
|
-
* @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.
|
|
34
|
-
* Calling the deregistration function more than once will have no effect.
|
|
35
|
-
*
|
|
36
|
-
* Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.
|
|
37
|
-
* @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.
|
|
38
|
-
* If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.
|
|
39
|
-
*/
|
|
40
|
-
on<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): Off;
|
|
41
|
-
/**
|
|
42
|
-
* Deregister notification listener.
|
|
43
|
-
* @param notificationName - The name of the notification.
|
|
44
|
-
* @param listener - The listener function to remove from the current set of notification listeners.
|
|
45
|
-
* @remarks If `listener` is not currently registered, this method will have no effect.
|
|
46
|
-
*
|
|
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
|
-
*/
|
|
49
|
-
off<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(notificationName: K, listener: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>) => void): void;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Record of notification subscription signatures transformed from listener emit signatures.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* Prepends the `sender: Attendee` parameter to each notification listener signature.
|
|
56
|
-
*
|
|
57
|
-
* @sealed
|
|
58
|
-
* @alpha
|
|
59
|
-
*/
|
|
60
|
-
export type NotificationSubscriberSignatures<E extends InternalUtilityTypes.NotificationListeners<E>> = {
|
|
61
|
-
[K in keyof InternalUtilityTypes.NotificationListeners<E>]: (sender: Attendee, ...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>) => void;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Interface for a notification emitter that can send typed notification to other clients.
|
|
65
|
-
*
|
|
66
|
-
* @sealed
|
|
67
|
-
* @alpha
|
|
68
|
-
*/
|
|
69
|
-
export interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {
|
|
70
|
-
/**
|
|
71
|
-
* Emits a notification with the specified name and arguments, notifying all clients.
|
|
72
|
-
* @param notificationName - the name of the notification to fire
|
|
73
|
-
* @param args - the arguments sent with the notification
|
|
74
|
-
*/
|
|
75
|
-
broadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, ...args: Parameters<E[K]>): void;
|
|
76
|
-
/**
|
|
77
|
-
* Emits a notification with the specified name and arguments, notifying a single attendee.
|
|
78
|
-
* @param notificationName - the name of the notification to fire
|
|
79
|
-
* @param targetAttendee - the single attendee to notify
|
|
80
|
-
* @param args - the arguments sent with the notification
|
|
81
|
-
*/
|
|
82
|
-
unicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(notificationName: K, targetAttendee: Attendee, ...args: Parameters<E[K]>): void;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Provides notifications from this client to others and subscription
|
|
86
|
-
* to their notifications.
|
|
87
|
-
*
|
|
88
|
-
* @remarks Create using {@link (Notifications:1)} registered to
|
|
89
|
-
* {@link NotificationsWorkspace} or {@link StatesWorkspace}.
|
|
90
|
-
*
|
|
91
|
-
* @sealed
|
|
92
|
-
* @alpha
|
|
93
|
-
*/
|
|
94
|
-
export interface NotificationsManager<T extends InternalUtilityTypes.NotificationListeners<T>> {
|
|
95
|
-
/**
|
|
96
|
-
* Containing {@link Presence}
|
|
97
|
-
*/
|
|
98
|
-
readonly presence: Presence;
|
|
99
|
-
/**
|
|
100
|
-
* Events for Notifications manager.
|
|
101
|
-
*/
|
|
102
|
-
readonly events: Listenable<NotificationsManagerEvents>;
|
|
103
|
-
/**
|
|
104
|
-
* Send notifications to other clients.
|
|
105
|
-
*/
|
|
106
|
-
readonly emit: NotificationEmitter<T>;
|
|
107
|
-
/**
|
|
108
|
-
* Provides subscription to notifications from other clients.
|
|
109
|
-
*/
|
|
110
|
-
readonly notifications: NotificationListenable<T>;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Type alias for the return type of {@link (Notifications:1)}.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* Use this type instead of any InternalPresenceTypes that may be revealed from
|
|
117
|
-
* examining factory return type.
|
|
118
|
-
*
|
|
119
|
-
* @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain
|
|
120
|
-
* allowed registration keys for this Notification within a workspace.
|
|
121
|
-
* Specification is recommended to highlight connection between schema and
|
|
122
|
-
* factory when spread across modules.
|
|
123
|
-
*
|
|
124
|
-
* @alpha
|
|
125
|
-
* @sealed
|
|
126
|
-
*/
|
|
127
|
-
export type NotificationsConfiguration<T extends InternalUtilityTypes.NotificationListeners<T>, RegistrationKeyRestrictions extends string = string> = InternalTypes.ManagerFactory<RegistrationKeyRestrictions, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<T>>;
|
|
128
|
-
/**
|
|
129
|
-
* Type alias for the return type of {@link (Notifications:2)}.
|
|
130
|
-
*
|
|
131
|
-
* @remarks
|
|
132
|
-
* Use this type instead of any InternalPresenceTypes that may be revealed from
|
|
133
|
-
* examining factory return type.
|
|
134
|
-
*
|
|
135
|
-
* @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain
|
|
136
|
-
* allowed registration keys for this Notification within a workspace.
|
|
137
|
-
* Specification is recommended to highlight connection between schema and
|
|
138
|
-
* factory when spread across modules.
|
|
139
|
-
*
|
|
140
|
-
* @alpha
|
|
141
|
-
* @sealed
|
|
142
|
-
*/
|
|
143
|
-
export type NotificationsWithSubscriptionsConfiguration<TSubscriptions extends InternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>, RegistrationKeyRestrictions extends string = string> = InternalTypes.ManagerFactory<RegistrationKeyRestrictions, InternalTypes.ValueRequiredState<InternalTypes.NotificationType>, NotificationsManager<InternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>>>;
|
|
144
|
-
//# sourceMappingURL=notificationsManagerTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsManagerTypes.d.ts","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,sBAAsB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACxF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB,CACtC,UAAU,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,UAAU,CAAC;IAEzE;;;;;;;;;;OAUG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,oBAAoB,CAAC,qBAAqB,CAAC,UAAU,CAAC,EACxE,gBAAgB,EAAE,CAAC,EACnB,QAAQ,EAAE,CACT,MAAM,EAAE,QAAQ,EAChB,GAAG,IAAI,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KACnE,IAAI,GACP,GAAG,CAAC;IAEP;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,oBAAoB,CAAC,qBAAqB,CAAC,UAAU,CAAC,EACzE,gBAAgB,EAAE,CAAC,EACnB,QAAQ,EAAE,CACT,MAA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EG;IACH,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,0BAA0B,CACrC,CAAC,SAAS,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,EACvD,2BAA2B,SAAS,MAAM,GAAG,MAAM,IAChD,aAAa,CAAC,cAAc,CAC/B,2BAA2B,EAC3B,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CAAC,CAAC,CAAC,CACvB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,2CAA2C,CACtD,cAAc,SACb,oBAAoB,CAAC,6CAA6C,CAAC,cAAc,CAAC,EACnF,2BAA2B,SAAS,MAAM,GAAG,MAAM,IAChD,aAAa,CAAC,cAAc,CAC/B,2BAA2B,EAC3B,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CACnB,oBAAoB,CAAC,6CAA6C,CAAC,cAAc,CAAC,CAClF,CACD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notificationsManagerTypes.js","sourceRoot":"","sources":["../src/notificationsManagerTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Listenable, Off } from \"@fluidframework/core-interfaces\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\nimport type { Attendee, PresenceWithNotifications as Presence } from \"./presence.js\";\n\n/**\n * @sealed\n * @alpha\n */\nexport interface NotificationsManagerEvents {\n\t/**\n\t * Raised when notification is received, but no subscribers were found.\n\t *\n\t * @eventProperty\n\t */\n\tunattendedNotification: (name: string, sender: Attendee, ...content: unknown[]) => void;\n}\n\n/**\n * An object which allows the registration of listeners so that subscribers can be\n * notified when a notification happens.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationListenable<\n\tTListeners extends InternalUtilityTypes.NotificationListeners<TListeners>,\n> {\n\t/**\n\t * Register a notification listener.\n\t * @param notificationName - the name of the notification\n\t * @param listener - The listener function to run when the notification is fired.\n\t * @returns A {@link @fluidframework/core-interfaces#Off | function} which will deregister the listener when called.\n\t * Calling the deregistration function more than once will have no effect.\n\t *\n\t * Listeners may also be deregistered by passing the listener to {@link NotificationListenable.off | off()}.\n\t * @remarks Registering the exact same `listener` object for the same notification more than once will throw an error.\n\t * If registering the same listener for the same notification multiple times is desired, consider using a wrapper function for the second subscription.\n\t */\n\ton<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): Off;\n\n\t/**\n\t * Deregister notification listener.\n\t * @param notificationName - The name of the notification.\n\t * @param listener - The listener function to remove from the current set of notification listeners.\n\t * @remarks If `listener` is not currently registered, this method will have no effect.\n\t *\n\t * Listeners may also be deregistered by calling the {@link @fluidframework/core-interfaces#Off | deregistration function} returned when they are {@link NotificationListenable.on | registered}.\n\t */\n\toff<K extends keyof InternalUtilityTypes.NotificationListeners<TListeners>>(\n\t\tnotificationName: K,\n\t\tlistener: (\n\t\t\tsender: Attendee,\n\t\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<TListeners[K]>\n\t\t) => void,\n\t): void;\n}\n\n/**\n * Record of notification subscription signatures transformed from listener emit signatures.\n *\n * @remarks\n * Prepends the `sender: Attendee` parameter to each notification listener signature.\n *\n * @sealed\n * @alpha\n */\nexport type NotificationSubscriberSignatures<\n\tE extends InternalUtilityTypes.NotificationListeners<E>,\n> = {\n\t[K in keyof InternalUtilityTypes.NotificationListeners<E>]: (\n\t\tsender: Attendee,\n\t\t...args: InternalUtilityTypes.JsonDeserializedParameters<E[K]>\n\t) => void;\n};\n\n/**\n * Interface for a notification emitter that can send typed notification to other clients.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationEmitter<E extends InternalUtilityTypes.NotificationListeners<E>> {\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying all clients.\n\t * @param notificationName - the name of the notification to fire\n\t * @param args - the arguments sent with the notification\n\t */\n\tbroadcast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\t...args: Parameters<E[K]>\n\t): void;\n\n\t/**\n\t * Emits a notification with the specified name and arguments, notifying a single attendee.\n\t * @param notificationName - the name of the notification to fire\n\t * @param targetAttendee - the single attendee to notify\n\t * @param args - the arguments sent with the notification\n\t */\n\tunicast<K extends keyof InternalUtilityTypes.NotificationListeners<E>>(\n\t\tnotificationName: K,\n\t\ttargetAttendee: Attendee,\n\t\t...args: Parameters<E[K]>\n\t): void;\n}\n\n/**\n * Provides notifications from this client to others and subscription\n * to their notifications.\n *\n * @remarks Create using {@link (Notifications:1)} registered to\n * {@link NotificationsWorkspace} or {@link StatesWorkspace}.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsManager<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n> {\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n\n\t/**\n\t * Events for Notifications manager.\n\t */\n\treadonly events: Listenable<NotificationsManagerEvents>;\n\n\t/**\n\t * Send notifications to other clients.\n\t */\n\treadonly emit: NotificationEmitter<T>;\n\n\t/**\n\t * Provides subscription to notifications from other clients.\n\t */\n\treadonly notifications: NotificationListenable<T>;\n}\n\n/**\n * Type alias for the return type of {@link (Notifications:1)}.\n *\n * @remarks\n * Use this type instead of any InternalPresenceTypes that may be revealed from\n * examining factory return type.\n *\n * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain\n * allowed registration keys for this Notification within a workspace.\n * Specification is recommended to highlight connection between schema and\n * factory when spread across modules.\n *\n * @alpha\n * @sealed\n */\nexport type NotificationsConfiguration<\n\tT extends InternalUtilityTypes.NotificationListeners<T>,\n\tRegistrationKeyRestrictions extends string = string,\n> = InternalTypes.ManagerFactory<\n\tRegistrationKeyRestrictions,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<T>\n>;\n\n/**\n * Type alias for the return type of {@link (Notifications:2)}.\n *\n * @remarks\n * Use this type instead of any InternalPresenceTypes that may be revealed from\n * examining factory return type.\n *\n * @typeparam RegistrationKeyRestrictions - Optional type parameter to constrain\n * allowed registration keys for this Notification within a workspace.\n * Specification is recommended to highlight connection between schema and\n * factory when spread across modules.\n *\n * @alpha\n * @sealed\n */\nexport type NotificationsWithSubscriptionsConfiguration<\n\tTSubscriptions extends\n\t\tInternalUtilityTypes.NotificationListenersWithSubscriberSignatures<TSubscriptions>,\n\tRegistrationKeyRestrictions extends string = string,\n> = InternalTypes.ManagerFactory<\n\tRegistrationKeyRestrictions,\n\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\tNotificationsManager<\n\t\tInternalUtilityTypes.NotificationListenersFromSubscriberSignatures<TSubscriptions>\n\t>\n>;\n"]}
|
package/lib/packageVersion.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
-
*/
|
|
7
|
-
export declare const pkgName = "@fluidframework/presence";
|
|
8
|
-
export declare const pkgVersion = "2.92.0";
|
|
9
|
-
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/lib/packageVersion.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
-
*/
|
|
7
|
-
export const pkgName = "@fluidframework/presence";
|
|
8
|
-
export const pkgVersion = "2.92.0";
|
|
9
|
-
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,0BAA0B,CAAC;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/presence\";\nexport const pkgVersion = \"2.92.0\";\n"]}
|