@fluidframework/presence 2.41.0 → 2.42.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/dist/broadcastControls.d.ts +2 -3
- package/dist/broadcastControls.d.ts.map +1 -1
- package/dist/broadcastControls.js +2 -3
- package/dist/broadcastControls.js.map +1 -1
- package/dist/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/dist/datastorePresenceManagerFactory.js +1 -0
- package/dist/datastorePresenceManagerFactory.js.map +1 -1
- package/dist/datastoreSupport.d.ts +7 -2
- package/dist/datastoreSupport.d.ts.map +1 -1
- package/dist/datastoreSupport.js +6 -4
- package/dist/datastoreSupport.js.map +1 -1
- package/dist/exposedInternalTypes.d.ts +22 -4
- package/dist/exposedInternalTypes.d.ts.map +1 -1
- package/dist/exposedInternalTypes.js.map +1 -1
- package/dist/exposedUtilityTypes.d.ts +6 -5
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/internalTypes.d.ts +11 -9
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/internalUtils.d.ts +26 -8
- package/dist/internalUtils.d.ts.map +1 -1
- package/dist/internalUtils.js +35 -8
- package/dist/internalUtils.js.map +1 -1
- package/dist/latestMapValueManager.d.ts +28 -7
- package/dist/latestMapValueManager.d.ts.map +1 -1
- package/dist/latestMapValueManager.js +10 -9
- package/dist/latestMapValueManager.js.map +1 -1
- package/dist/latestValueManager.d.ts +17 -3
- package/dist/latestValueManager.d.ts.map +1 -1
- package/dist/latestValueManager.js +20 -9
- package/dist/latestValueManager.js.map +1 -1
- package/dist/latestValueTypes.d.ts +11 -1
- package/dist/latestValueTypes.d.ts.map +1 -1
- package/dist/latestValueTypes.js.map +1 -1
- package/dist/notificationsManager.d.ts +2 -2
- package/dist/notificationsManager.d.ts.map +1 -1
- package/dist/notificationsManager.js +14 -7
- package/dist/notificationsManager.js.map +1 -1
- package/dist/presence.d.ts +7 -5
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js.map +1 -1
- package/dist/presenceDatastoreManager.d.ts +5 -6
- package/dist/presenceDatastoreManager.d.ts.map +1 -1
- package/dist/presenceDatastoreManager.js +19 -7
- package/dist/presenceDatastoreManager.js.map +1 -1
- package/dist/presenceManager.d.ts +0 -4
- package/dist/presenceManager.d.ts.map +1 -1
- package/dist/presenceManager.js +1 -3
- package/dist/presenceManager.js.map +1 -1
- package/dist/presenceStates.d.ts +9 -14
- package/dist/presenceStates.d.ts.map +1 -1
- package/dist/presenceStates.js +1 -8
- package/dist/presenceStates.js.map +1 -1
- package/dist/protocol.d.ts +37 -12
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +7 -3
- package/dist/protocol.js.map +1 -1
- package/dist/stateDatastore.d.ts +9 -8
- package/dist/stateDatastore.d.ts.map +1 -1
- package/dist/stateDatastore.js +0 -4
- package/dist/stateDatastore.js.map +1 -1
- package/dist/systemWorkspace.d.ts +12 -6
- package/dist/systemWorkspace.d.ts.map +1 -1
- package/dist/systemWorkspace.js +14 -4
- package/dist/systemWorkspace.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/valueManager.d.ts +0 -4
- package/dist/valueManager.d.ts.map +1 -1
- package/dist/valueManager.js +0 -4
- package/dist/valueManager.js.map +1 -1
- package/lib/broadcastControls.d.ts +2 -3
- package/lib/broadcastControls.d.ts.map +1 -1
- package/lib/broadcastControls.js +2 -3
- package/lib/broadcastControls.js.map +1 -1
- package/lib/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/lib/datastorePresenceManagerFactory.js +1 -0
- package/lib/datastorePresenceManagerFactory.js.map +1 -1
- package/lib/datastoreSupport.d.ts +7 -2
- package/lib/datastoreSupport.d.ts.map +1 -1
- package/lib/datastoreSupport.js +6 -4
- package/lib/datastoreSupport.js.map +1 -1
- package/lib/exposedInternalTypes.d.ts +22 -4
- package/lib/exposedInternalTypes.d.ts.map +1 -1
- package/lib/exposedInternalTypes.js.map +1 -1
- package/lib/exposedUtilityTypes.d.ts +6 -5
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/internalTypes.d.ts +11 -9
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/internalUtils.d.ts +26 -8
- package/lib/internalUtils.d.ts.map +1 -1
- package/lib/internalUtils.js +31 -7
- package/lib/internalUtils.js.map +1 -1
- package/lib/latestMapValueManager.d.ts +28 -7
- package/lib/latestMapValueManager.d.ts.map +1 -1
- package/lib/latestMapValueManager.js +11 -10
- package/lib/latestMapValueManager.js.map +1 -1
- package/lib/latestValueManager.d.ts +17 -3
- package/lib/latestValueManager.d.ts.map +1 -1
- package/lib/latestValueManager.js +19 -9
- package/lib/latestValueManager.js.map +1 -1
- package/lib/latestValueTypes.d.ts +11 -1
- package/lib/latestValueTypes.d.ts.map +1 -1
- package/lib/latestValueTypes.js.map +1 -1
- package/lib/notificationsManager.d.ts +2 -2
- package/lib/notificationsManager.d.ts.map +1 -1
- package/lib/notificationsManager.js +14 -7
- package/lib/notificationsManager.js.map +1 -1
- package/lib/presence.d.ts +7 -5
- package/lib/presence.d.ts.map +1 -1
- package/lib/presence.js.map +1 -1
- package/lib/presenceDatastoreManager.d.ts +5 -6
- package/lib/presenceDatastoreManager.d.ts.map +1 -1
- package/lib/presenceDatastoreManager.js +20 -8
- package/lib/presenceDatastoreManager.js.map +1 -1
- package/lib/presenceManager.d.ts +0 -4
- package/lib/presenceManager.d.ts.map +1 -1
- package/lib/presenceManager.js +1 -3
- package/lib/presenceManager.js.map +1 -1
- package/lib/presenceStates.d.ts +9 -14
- package/lib/presenceStates.d.ts.map +1 -1
- package/lib/presenceStates.js +1 -8
- package/lib/presenceStates.js.map +1 -1
- package/lib/protocol.d.ts +37 -12
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +6 -2
- package/lib/protocol.js.map +1 -1
- package/lib/stateDatastore.d.ts +9 -8
- package/lib/stateDatastore.d.ts.map +1 -1
- package/lib/stateDatastore.js +0 -4
- package/lib/stateDatastore.js.map +1 -1
- package/lib/systemWorkspace.d.ts +12 -6
- package/lib/systemWorkspace.d.ts.map +1 -1
- package/lib/systemWorkspace.js +14 -4
- package/lib/systemWorkspace.js.map +1 -1
- package/lib/types.d.ts +3 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/valueManager.d.ts +0 -4
- package/lib/valueManager.d.ts.map +1 -1
- package/lib/valueManager.js +0 -4
- package/lib/valueManager.js.map +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemWorkspace.js","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcjD,MAAM,aAAa;IASlB,YACiB,UAAsB,EAC/B,eAA+C,SAAS;QAD/C,eAAU,GAAV,UAAU,CAAY;QAC/B,iBAAY,GAAZ,YAAY,CAA4C;QAVhE;;;WAGG;QACI,UAAK,GAAW,CAAC,CAAC;QAEjB,qBAAgB,GAAmB,cAAc,CAAC,YAAY,CAAC;IAKpE,CAAC;IAEG,eAAe;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,mBAAmB;QACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,gBAAgB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,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnC,uDAAuD;YACvD,8CAA8C;YAC9C,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;YACvB,2EAA2E;YAC3E,IAAI,QAAQ,CAAC,mBAAmB,EAAE,KAAK,cAAc,CAAC,YAAY,IAAI,WAAW,EAAE,CAAC;gBACnF,QAAQ,CAAC,YAAY,EAAE,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YAClB,CAAC;YACD,QAAQ,CAAC,YAAY,GAAG,kBAAkB,CAAC;QAC5C,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACjB,0EAA0E;YAC1E,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAED,oEAAoE;QACpE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACpC,UAAsB,EACtB,SAAmC,EACnC,MAA+D,EAC/D,QAAmB;IAQnB,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnF,OAAO;QACN,SAAS;QACT,WAAW,EAAE;YACZ,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,SAA2D;SACnE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IEmitter, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { PostUpdateAction } from \"./internalTypes.js\";\nimport type { Attendee, AttendeesEvents, AttendeeId, Presence } from \"./presence.js\";\nimport { AttendeeStatus } from \"./presence.js\";\nimport type { PresenceStatesInternal } from \"./presenceStates.js\";\nimport { TimerManager } from \"./timerManager.js\";\nimport type { AnyWorkspace, StatesWorkspaceSchema } from \"./types.js\";\n\n/**\n * The system workspace's datastore structure.\n *\n * @internal\n */\nexport interface SystemWorkspaceDatastore {\n\tclientToSessionId: {\n\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<AttendeeId>;\n\t};\n}\n\nclass SessionClient implements Attendee {\n\t/**\n\t * Order is used to track the most recent client connection\n\t * during a session.\n\t */\n\tpublic order: number = 0;\n\n\tprivate connectionStatus: AttendeeStatus = AttendeeStatus.Disconnected;\n\n\tpublic constructor(\n\t\tpublic readonly attendeeId: AttendeeId,\n\t\tpublic connectionId: ClientConnectionId | undefined = undefined,\n\t) {}\n\n\tpublic getConnectionId(): ClientConnectionId {\n\t\tif (this.connectionId === undefined) {\n\t\t\tthrow new Error(\"Client has never been connected\");\n\t\t}\n\t\treturn this.connectionId;\n\t}\n\n\tpublic getConnectionStatus(): AttendeeStatus {\n\t\treturn this.connectionStatus;\n\t}\n\n\tpublic setConnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Connected;\n\t}\n\n\tpublic setDisconnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Disconnected;\n\t}\n}\n\n/**\n * @internal\n */\nexport interface SystemWorkspace\n\t// Portion of Presence that is handled by SystemWorkspace along with\n\t// responsibility for emitting \"attendeeConnected\" events.\n\textends Exclude<Presence[\"attendees\"], never> {\n\t/**\n\t * Must be called when the current client acquires a new connection.\n\t *\n\t * @param clientConnectionId - The new client connection ID.\n\t */\n\tonConnectionAdded(clientConnectionId: ClientConnectionId): void;\n\n\t/**\n\t * Removes the client connection ID from the system workspace.\n\t *\n\t * @param clientConnectionId - The client connection ID to remove.\n\t */\n\tremoveClientConnectionId(clientConnectionId: ClientConnectionId): void;\n}\n\nclass SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {\n\tprivate readonly selfAttendee: SessionClient;\n\t/**\n\t * `attendees` is this client's understanding of the attendees in the\n\t * session. The map covers entries for both session ids and connection\n\t * ids, which are never expected to collide, but if they did for same\n\t * client that would be fine.\n\t * An entry is for session ID if the value's `attendeeId` matches the key.\n\t */\n\tprivate readonly attendees = new Map<ClientConnectionId | AttendeeId, SessionClient>();\n\n\t// When local client disconnects, we lose the connectivity status updates for remote attendees in the session.\n\t// Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.\n\tprivate readonly staleConnectionClients = new Set<SessionClient>();\n\n\tprivate readonly staleConnectionTimer = new TimerManager();\n\n\tpublic constructor(\n\t\tattendeeId: AttendeeId,\n\t\tprivate readonly datastore: SystemWorkspaceDatastore,\n\t\tpublic readonly events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\t\tprivate readonly audience: IAudience,\n\t) {\n\t\tthis.selfAttendee = new SessionClient(attendeeId);\n\t\tthis.attendees.set(attendeeId, this.selfAttendee);\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\t_content: TSchemaAdditional,\n\t): never {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tpublic processUpdate(\n\t\t_received: number,\n\t\t_timeModifier: number,\n\t\tremoteDatastore: {\n\t\t\tclientToSessionId: {\n\t\t\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<AttendeeId> & {\n\t\t\t\t\tignoreUnmonitored?: true;\n\t\t\t\t};\n\t\t\t};\n\t\t},\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[] {\n\t\tconst audienceMembers = this.audience.getMembers();\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [clientConnectionId, value] of Object.entries(\n\t\t\tremoteDatastore.clientToSessionId,\n\t\t)) {\n\t\t\tconst attendeeId = value.value;\n\t\t\tconst { attendee, isJoining } = this.ensureAttendee(\n\t\t\t\tattendeeId,\n\t\t\t\tclientConnectionId,\n\t\t\t\t/* order */ value.rev,\n\t\t\t\t// If the attendee is present in audience OR if the attendee update is from the sending remote client itself,\n\t\t\t\t// then the attendee is considered connected.\n\t\t\t\t/* isConnected */ senderConnectionId === clientConnectionId ||\n\t\t\t\t\taudienceMembers.has(clientConnectionId),\n\t\t\t);\n\t\t\t// If the attendee is joining the session, add them to the list of joining attendees to be announced later.\n\t\t\tif (isJoining) {\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"attendeeConnected\", attendee));\n\t\t\t}\n\n\t\t\tconst knownSessionId: InternalTypes.ValueRequiredState<AttendeeId> | undefined =\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId];\n\t\t\tif (knownSessionId === undefined) {\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = value;\n\t\t\t} else {\n\t\t\t\tassert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);\n\t\t\t}\n\t\t}\n\n\t\treturn postUpdateActions;\n\t}\n\n\tpublic onConnectionAdded(clientConnectionId: ClientConnectionId): void {\n\t\tassert(\n\t\t\tthis.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected,\n\t\t\t0xaad /* Local client should be 'Disconnected' before adding new connection. */,\n\t\t);\n\n\t\tthis.datastore.clientToSessionId[clientConnectionId] = {\n\t\t\trev: this.selfAttendee.order++,\n\t\t\ttimestamp: Date.now(),\n\t\t\tvalue: this.selfAttendee.attendeeId,\n\t\t};\n\n\t\t// Mark 'Connected' remote attendees connections as stale\n\t\tfor (const staleConnectionClient of this.attendees.values()) {\n\t\t\tif (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {\n\t\t\t\tthis.staleConnectionClients.add(staleConnectionClient);\n\t\t\t}\n\t\t}\n\n\t\t// Update the self attendee\n\t\tthis.selfAttendee.connectionId = clientConnectionId;\n\t\tthis.selfAttendee.setConnected();\n\t\tthis.attendees.set(clientConnectionId, this.selfAttendee);\n\n\t\tthis.staleConnectionTimer.setTimeout(() => {\n\t\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t\tclient.setDisconnected();\n\t\t\t}\n\t\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t\tthis.events.emit(\"attendeeDisconnected\", client);\n\t\t\t}\n\t\t\tthis.staleConnectionClients.clear();\n\t\t}, 30_000);\n\t}\n\n\tpublic removeClientConnectionId(clientConnectionId: ClientConnectionId): void {\n\t\tconst attendee = this.attendees.get(clientConnectionId);\n\t\tif (!attendee) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the local connection is being removed, clear the stale connection timer\n\t\tif (attendee === this.selfAttendee) {\n\t\t\tthis.staleConnectionTimer.clearTimeout();\n\t\t}\n\n\t\t// If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,\n\t\t// therefore we should not change the attendee connection status or emit a disconnect event.\n\t\tconst attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;\n\t\tconst connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;\n\t\tif (!attendeeReconnected && connected) {\n\t\t\tattendee.setDisconnected();\n\t\t\tthis.events.emit(\"attendeeDisconnected\", attendee);\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\t}\n\n\tpublic getAttendees(): ReadonlySet<Attendee> {\n\t\treturn new Set(this.attendees.values());\n\t}\n\n\tpublic getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee {\n\t\tconst attendee = this.attendees.get(clientId);\n\t\tif (attendee) {\n\t\t\treturn attendee;\n\t\t}\n\n\t\t// TODO: Restore option to add attendee on demand to handle internal\n\t\t// lookup cases that must come from internal data.\n\t\t// There aren't any resiliency mechanisms in place to handle a missed\n\t\t// ClientJoin right now.\n\t\tthrow new Error(\"Attendee not found\");\n\t}\n\n\tpublic getMyself(): Attendee {\n\t\treturn this.selfAttendee;\n\t}\n\n\t/**\n\t * Make sure the given client session and connection ID pair are represented\n\t * in the attendee map. If not present, SessionClient is created and added\n\t * to map. If present, make sure the current connection ID is updated.\n\t */\n\tprivate ensureAttendee(\n\t\tattendeeId: AttendeeId,\n\t\tclientConnectionId: ClientConnectionId,\n\t\torder: number,\n\t\tisConnected: boolean,\n\t): { attendee: SessionClient; isJoining: boolean } {\n\t\tlet attendee = this.attendees.get(attendeeId);\n\t\tlet isJoining = false;\n\n\t\tif (attendee === undefined) {\n\t\t\t// New attendee. Create SessionClient and add session ID based\n\t\t\t// entry to map.\n\t\t\tattendee = new SessionClient(attendeeId, clientConnectionId);\n\t\t\tthis.attendees.set(attendeeId, attendee);\n\t\t\tif (isConnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t} else if (order > attendee.order) {\n\t\t\t// The given association is newer than the one we have.\n\t\t\t// Update the order and current connection ID.\n\t\t\tattendee.order = order;\n\t\t\t// Known attendee is joining the session if they are currently disconnected\n\t\t\tif (attendee.getConnectionStatus() === AttendeeStatus.Disconnected && isConnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t\tattendee.connectionId = clientConnectionId;\n\t\t}\n\n\t\tif (isConnected) {\n\t\t\t// If the attendee is connected, remove them from the stale connection set\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\n\t\t// Always update entry for the connection ID. (Okay if already set.)\n\t\tthis.attendees.set(clientConnectionId, attendee);\n\n\t\treturn { attendee, isJoining };\n\t}\n}\n\n/**\n * Instantiates the system workspace.\n *\n * @internal\n */\nexport function createSystemWorkspace(\n\tattendeeId: AttendeeId,\n\tdatastore: SystemWorkspaceDatastore,\n\tevents: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\taudience: IAudience,\n): {\n\tworkspace: SystemWorkspace;\n\tstatesEntry: {\n\t\tinternal: PresenceStatesInternal;\n\t\tpublic: AnyWorkspace<StatesWorkspaceSchema>;\n\t};\n} {\n\tconst workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);\n\treturn {\n\t\tworkspace,\n\t\tstatesEntry: {\n\t\t\tinternal: workspace,\n\t\t\tpublic: undefined as unknown as AnyWorkspace<StatesWorkspaceSchema>,\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"systemWorkspace.js","sourceRoot":"","sources":["../src/systemWorkspace.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAsBjD,MAAM,aAAa;IASlB,YACiB,UAAsB,EAC/B,eAA+C,SAAS;QAD/C,eAAU,GAAV,UAAU,CAAY;QAC/B,iBAAY,GAAZ,YAAY,CAA4C;QAVhE;;;WAGG;QACI,UAAK,GAAW,CAAC,CAAC;QAEjB,qBAAgB,GAAmB,cAAc,CAAC,YAAY,CAAC;IAKpE,CAAC;IAEG,eAAe;QACrB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,mBAAmB;QACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAEM,YAAY;QAClB,IAAI,CAAC,gBAAgB,GAAG,cAAc,CAAC,SAAS,CAAC;IAClD,CAAC;IAEM,eAAe;QACrB,IAAI,CAAC,gBAAgB,GAAG,cAAc,CAAC,YAAY,CAAC;IACrD,CAAC;CACD;AAwBD,MAAM,mBAAmB;IAiBxB,YACC,UAAsB,EACL,SAAmC,EACpC,MAA+D,EAC9D,QAAmB;QAFnB,cAAS,GAAT,SAAS,CAA0B;QACpC,WAAM,GAAN,MAAM,CAAyD;QAC9D,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,YAAY,EAAE,CAAC;gBACxB,SAAS,GAAG,IAAI,CAAC;YAClB,CAAC;YACD,QAAQ,CAAC,YAAY,GAAG,kBAAkB,CAAC;QAC5C,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACjB,0EAA0E;YAC1E,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9C,CAAC;QAED,oEAAoE;QACpE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,UAAsB,EACtB,SAAmC,EACnC,MAA+D,EAC/D,QAAmB;IAQnB,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnF,OAAO;QACN,SAAS;QACT,WAAW,EAAE;YACZ,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,SAA2D;SACnE;KACD,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IAudience } from \"@fluidframework/container-definitions\";\nimport type { IEmitter, Listenable } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { PostUpdateAction } from \"./internalTypes.js\";\nimport { revealOpaqueJson } from \"./internalUtils.js\";\nimport type { Attendee, AttendeesEvents, AttendeeId, Presence } from \"./presence.js\";\nimport { AttendeeStatus } from \"./presence.js\";\nimport type { PresenceStatesInternal } from \"./presenceStates.js\";\nimport { TimerManager } from \"./timerManager.js\";\nimport type { AnyWorkspace, StatesWorkspaceSchema } from \"./types.js\";\n\n/**\n * `ConnectionValueState` is known value state for `clientToSessionId` data.\n *\n * @remarks\n * It is {@link InternalTypes.ValueRequiredState} with a known value type.\n */\ninterface ConnectionValueState extends InternalTypes.ValueStateMetadata {\n\tvalue: AttendeeId;\n}\n\n/**\n * The system workspace's datastore structure.\n */\nexport interface SystemWorkspaceDatastore {\n\tclientToSessionId: {\n\t\t[ConnectionId: ClientConnectionId]: ConnectionValueState;\n\t};\n}\n\nclass SessionClient implements Attendee {\n\t/**\n\t * Order is used to track the most recent client connection\n\t * during a session.\n\t */\n\tpublic order: number = 0;\n\n\tprivate connectionStatus: AttendeeStatus = AttendeeStatus.Disconnected;\n\n\tpublic constructor(\n\t\tpublic readonly attendeeId: AttendeeId,\n\t\tpublic connectionId: ClientConnectionId | undefined = undefined,\n\t) {}\n\n\tpublic getConnectionId(): ClientConnectionId {\n\t\tif (this.connectionId === undefined) {\n\t\t\tthrow new Error(\"Client has never been connected\");\n\t\t}\n\t\treturn this.connectionId;\n\t}\n\n\tpublic getConnectionStatus(): AttendeeStatus {\n\t\treturn this.connectionStatus;\n\t}\n\n\tpublic setConnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Connected;\n\t}\n\n\tpublic setDisconnected(): void {\n\t\tthis.connectionStatus = AttendeeStatus.Disconnected;\n\t}\n}\n\n/**\n * Internal workspace that manages metadata for session attendees.\n */\nexport interface SystemWorkspace\n\t// Portion of Presence that is handled by SystemWorkspace along with\n\t// responsibility for emitting \"attendeeConnected\" events.\n\textends Exclude<Presence[\"attendees\"], never> {\n\t/**\n\t * Must be called when the current client acquires a new connection.\n\t *\n\t * @param clientConnectionId - The new client connection ID.\n\t */\n\tonConnectionAdded(clientConnectionId: ClientConnectionId): void;\n\n\t/**\n\t * Removes the client connection ID from the system workspace.\n\t *\n\t * @param clientConnectionId - The client connection ID to remove.\n\t */\n\tremoveClientConnectionId(clientConnectionId: ClientConnectionId): void;\n}\n\nclass SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {\n\tprivate readonly selfAttendee: SessionClient;\n\t/**\n\t * `attendees` is this client's understanding of the attendees in the\n\t * session. The map covers entries for both session ids and connection\n\t * ids, which are never expected to collide, but if they did for same\n\t * client that would be fine.\n\t * An entry is for session ID if the value's `attendeeId` matches the key.\n\t */\n\tprivate readonly attendees = new Map<ClientConnectionId | AttendeeId, SessionClient>();\n\n\t// When local client disconnects, we lose the connectivity status updates for remote attendees in the session.\n\t// Upon reconnect, we mark all other attendees connections as stale and update their status to disconnected after 30 seconds of inactivity.\n\tprivate readonly staleConnectionClients = new Set<SessionClient>();\n\n\tprivate readonly staleConnectionTimer = new TimerManager();\n\n\tpublic constructor(\n\t\tattendeeId: AttendeeId,\n\t\tprivate readonly datastore: SystemWorkspaceDatastore,\n\t\tpublic readonly events: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\t\tprivate readonly audience: IAudience,\n\t) {\n\t\tthis.selfAttendee = new SessionClient(attendeeId);\n\t\tthis.attendees.set(attendeeId, this.selfAttendee);\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\t_content: TSchemaAdditional,\n\t): never {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\tpublic processUpdate(\n\t\t_received: number,\n\t\t_timeModifier: number,\n\t\t/**\n\t\t * Remote datastore typed to match {@link PresenceStatesInternal.processUpdate}'s\n\t\t * `ValueUpdateRecord` type that uses {@link InternalTypes.ValueRequiredState}\n\t\t * and expects an Opaque JSON type. (We get away with a non-`unknown` value type\n\t\t * per TypeScript's method parameter bivariance.) Proper type would be\n\t\t * {@link ConnectionValueState} directly.\n\t\t * {@link ClientConnectionId} use for index is also a deviation, but conveniently\n\t\t * the accurate {@link AttendeeId} type is just a branded string, and\n\t\t * {@link ClientConnectionId} is just `string`.\n\t\t */\n\t\tremoteDatastore: {\n\t\t\tclientToSessionId: {\n\t\t\t\t[ConnectionId: ClientConnectionId]: InternalTypes.ValueRequiredState<\n\t\t\t\t\tConnectionValueState[\"value\"]\n\t\t\t\t>;\n\t\t\t};\n\t\t},\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[] {\n\t\tconst audienceMembers = this.audience.getMembers();\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [clientConnectionId, value] of Object.entries(\n\t\t\trevealOpaqueJson(remoteDatastore.clientToSessionId),\n\t\t)) {\n\t\t\tconst attendeeId = value.value;\n\t\t\tconst { attendee, isJoining } = this.ensureAttendee(\n\t\t\t\tattendeeId,\n\t\t\t\tclientConnectionId,\n\t\t\t\t/* order */ value.rev,\n\t\t\t\t// If the attendee is present in audience OR if the attendee update is from the sending remote client itself,\n\t\t\t\t// then the attendee is considered connected.\n\t\t\t\t/* isConnected */ senderConnectionId === clientConnectionId ||\n\t\t\t\t\taudienceMembers.has(clientConnectionId),\n\t\t\t);\n\t\t\t// If the attendee is joining the session, add them to the list of joining attendees to be announced later.\n\t\t\tif (isJoining) {\n\t\t\t\tpostUpdateActions.push(() => this.events.emit(\"attendeeConnected\", attendee));\n\t\t\t}\n\n\t\t\tconst knownSessionId = this.datastore.clientToSessionId[clientConnectionId];\n\t\t\tif (knownSessionId === undefined) {\n\t\t\t\tthis.datastore.clientToSessionId[clientConnectionId] = value;\n\t\t\t} else {\n\t\t\t\tassert(knownSessionId.value === value.value, 0xa5a /* Mismatched SessionId */);\n\t\t\t}\n\t\t}\n\n\t\treturn postUpdateActions;\n\t}\n\n\tpublic onConnectionAdded(clientConnectionId: ClientConnectionId): void {\n\t\tassert(\n\t\t\tthis.selfAttendee.getConnectionStatus() === AttendeeStatus.Disconnected,\n\t\t\t0xaad /* Local client should be 'Disconnected' before adding new connection. */,\n\t\t);\n\n\t\tthis.datastore.clientToSessionId[clientConnectionId] = {\n\t\t\trev: this.selfAttendee.order++,\n\t\t\ttimestamp: Date.now(),\n\t\t\tvalue: this.selfAttendee.attendeeId,\n\t\t};\n\n\t\t// Mark 'Connected' remote attendees connections as stale\n\t\tfor (const staleConnectionClient of this.attendees.values()) {\n\t\t\tif (staleConnectionClient.getConnectionStatus() === AttendeeStatus.Connected) {\n\t\t\t\tthis.staleConnectionClients.add(staleConnectionClient);\n\t\t\t}\n\t\t}\n\n\t\t// Update the self attendee\n\t\tthis.selfAttendee.connectionId = clientConnectionId;\n\t\tthis.selfAttendee.setConnected();\n\t\tthis.attendees.set(clientConnectionId, this.selfAttendee);\n\n\t\tthis.staleConnectionTimer.setTimeout(() => {\n\t\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t\tclient.setDisconnected();\n\t\t\t}\n\t\t\tfor (const client of this.staleConnectionClients) {\n\t\t\t\tthis.events.emit(\"attendeeDisconnected\", client);\n\t\t\t}\n\t\t\tthis.staleConnectionClients.clear();\n\t\t}, 30_000);\n\t}\n\n\tpublic removeClientConnectionId(clientConnectionId: ClientConnectionId): void {\n\t\tconst attendee = this.attendees.get(clientConnectionId);\n\t\tif (!attendee) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the local connection is being removed, clear the stale connection timer\n\t\tif (attendee === this.selfAttendee) {\n\t\t\tthis.staleConnectionTimer.clearTimeout();\n\t\t}\n\n\t\t// If the last known connectionID is different from the connection ID being removed, the attendee has reconnected,\n\t\t// therefore we should not change the attendee connection status or emit a disconnect event.\n\t\tconst attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;\n\t\tconst connected = attendee.getConnectionStatus() === AttendeeStatus.Connected;\n\t\tif (!attendeeReconnected && connected) {\n\t\t\tattendee.setDisconnected();\n\t\t\tthis.events.emit(\"attendeeDisconnected\", attendee);\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\t}\n\n\tpublic getAttendees(): ReadonlySet<Attendee> {\n\t\treturn new Set(this.attendees.values());\n\t}\n\n\tpublic getAttendee(clientId: ClientConnectionId | AttendeeId): Attendee {\n\t\tconst attendee = this.attendees.get(clientId);\n\t\tif (attendee) {\n\t\t\treturn attendee;\n\t\t}\n\n\t\t// TODO: Restore option to add attendee on demand to handle internal\n\t\t// lookup cases that must come from internal data.\n\t\t// There aren't any resiliency mechanisms in place to handle a missed\n\t\t// ClientJoin right now.\n\t\tthrow new Error(\"Attendee not found\");\n\t}\n\n\tpublic getMyself(): Attendee {\n\t\treturn this.selfAttendee;\n\t}\n\n\t/**\n\t * Make sure the given client session and connection ID pair are represented\n\t * in the attendee map. If not present, SessionClient is created and added\n\t * to map. If present, make sure the current connection ID is updated.\n\t */\n\tprivate ensureAttendee(\n\t\tattendeeId: AttendeeId,\n\t\tclientConnectionId: ClientConnectionId,\n\t\torder: number,\n\t\tisConnected: boolean,\n\t): { attendee: SessionClient; isJoining: boolean } {\n\t\tlet attendee = this.attendees.get(attendeeId);\n\t\tlet isJoining = false;\n\n\t\tif (attendee === undefined) {\n\t\t\t// New attendee. Create SessionClient and add session ID based\n\t\t\t// entry to map.\n\t\t\tattendee = new SessionClient(attendeeId, clientConnectionId);\n\t\t\tthis.attendees.set(attendeeId, attendee);\n\t\t\tif (isConnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t} else if (order > attendee.order) {\n\t\t\t// The given association is newer than the one we have.\n\t\t\t// Update the order and current connection ID.\n\t\t\tattendee.order = order;\n\t\t\t// Known attendee is joining the session if they are currently disconnected\n\t\t\tif (attendee.getConnectionStatus() === AttendeeStatus.Disconnected && isConnected) {\n\t\t\t\tattendee.setConnected();\n\t\t\t\tisJoining = true;\n\t\t\t}\n\t\t\tattendee.connectionId = clientConnectionId;\n\t\t}\n\n\t\tif (isConnected) {\n\t\t\t// If the attendee is connected, remove them from the stale connection set\n\t\t\tthis.staleConnectionClients.delete(attendee);\n\t\t}\n\n\t\t// Always update entry for the connection ID. (Okay if already set.)\n\t\tthis.attendees.set(clientConnectionId, attendee);\n\n\t\treturn { attendee, isJoining };\n\t}\n}\n\n/**\n * Instantiates the system workspace.\n */\nexport function createSystemWorkspace(\n\tattendeeId: AttendeeId,\n\tdatastore: SystemWorkspaceDatastore,\n\tevents: Listenable<AttendeesEvents> & IEmitter<AttendeesEvents>,\n\taudience: IAudience,\n): {\n\tworkspace: SystemWorkspace;\n\tstatesEntry: {\n\t\tinternal: PresenceStatesInternal;\n\t\tpublic: AnyWorkspace<StatesWorkspaceSchema>;\n\t};\n} {\n\tconst workspace = new SystemWorkspaceImpl(attendeeId, datastore, events, audience);\n\treturn {\n\t\tworkspace,\n\t\tstatesEntry: {\n\t\t\tinternal: workspace,\n\t\t\tpublic: undefined as unknown as AnyWorkspace<StatesWorkspaceSchema>,\n\t\t},\n\t};\n}\n"]}
|
package/lib/types.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ export type StatesWorkspaceEntry<TKey extends string, TValue extends InternalTyp
|
|
|
37
37
|
* @beta
|
|
38
38
|
*/
|
|
39
39
|
export interface StatesWorkspaceSchema {
|
|
40
|
+
/**
|
|
41
|
+
* Key-value pairs of State objects registered with the {@link StatesWorkspace}.
|
|
42
|
+
*/
|
|
40
43
|
[key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
@@ -122,8 +125,6 @@ export interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSc
|
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
127
|
* `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}.
|
|
125
|
-
*
|
|
126
|
-
* @internal
|
|
127
128
|
*/
|
|
128
129
|
export interface AnyWorkspace<TSchema extends StatesWorkspaceSchema, TManagerConstraints = unknown> extends StatesWorkspace<TSchema, TManagerConstraints> {
|
|
129
130
|
readonly notifications: StatesWorkspaceEntries<TSchema>;
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAA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IAAI,IAAI,sBAAsB,CACxC,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAC5E,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;CAC7C;AAID;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,OAAO,SAAS,qBAAqB,EACrC,mBAAmB,GAAG,OAAO,CAC5B,SAAQ,eAAe,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAExD,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;CAC7C"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { BroadcastControls } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { NotificationsManager } from \"./notificationsManager.js\";\nimport type { Presence, PresenceWithNotifications } from \"./presence.js\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @beta\n */\nexport type WorkspaceAddress = `${string}:${string}`;\n\n/**\n * Single entry in {@link StatesWorkspaceSchema} or {@link NotificationsWorkspaceSchema}.\n *\n * @beta\n */\nexport type StatesWorkspaceEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n// #region StatesWorkspace\n\n/**\n * Schema for a {@link StatesWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link StatesWorkspace} providing access to State objects.\n *\n * @beta\n */\nexport interface StatesWorkspaceSchema {\n\t[key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;\n}\n\n/**\n * Map of State objects registered with {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type StatesWorkspaceEntries<TSchema extends StatesWorkspaceSchema> = {\n\t/**\n\t * Registered State objects.\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `StatesWorkspace` maintains a registry of State objects that all share and provide access to\n * presence state values across client members in a session.\n *\n * State objects offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @beta\n */\nexport interface StatesWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new State object with the {@link StatesWorkspace}.\n\t * @param key - new unique key for the State object within the workspace\n\t * @param manager - factory for creating a State object\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is StatesWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of State objects.\n\t */\n\treadonly states: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Default controls for management of broadcast updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n}\n\n// #endregion StatesWorkspace\n\n// #region NotificationsWorkspace\n\n/**\n * Schema for a {@link NotificationsWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link NotificationsWorkspace} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface NotificationsWorkspaceSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<any>\n\t>;\n}\n\n/**\n * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @privateRemarks\n * This should be kept mostly in sync with {@link StatesWorkspace}. Notably the\n * return type of `add` is limited here and the `controls` property is omitted.\n * The `PresenceStatesImpl` class implements `AnyWorkspace` and therefore\n * `NotificationsWorkspace`, so long as this is proper subset.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSchema> {\n\t/**\n\t * Registers a new `NotificationsManager` with the {@link NotificationsWorkspace}.\n\t * @param key - new unique key for the `NotificationsManager` within the workspace\n\t * @param manager - factory for creating a `NotificationsManager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends NotificationsManager<any>,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is NotificationsWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>\n\t>;\n\n\t/**\n\t * Registry of `NotificationsManager`s.\n\t */\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Containing {@link PresenceWithNotifications}\n\t */\n\treadonly presence: PresenceWithNotifications;\n}\n\n// #endregion NotificationsWorkspace\n\n/**\n * `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}.\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { BroadcastControls } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { NotificationsManager } from \"./notificationsManager.js\";\nimport type { Presence, PresenceWithNotifications } from \"./presence.js\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @beta\n */\nexport type WorkspaceAddress = `${string}:${string}`;\n\n/**\n * Single entry in {@link StatesWorkspaceSchema} or {@link NotificationsWorkspaceSchema}.\n *\n * @beta\n */\nexport type StatesWorkspaceEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n// #region StatesWorkspace\n\n/**\n * Schema for a {@link StatesWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link StatesWorkspace} providing access to State objects.\n *\n * @beta\n */\nexport interface StatesWorkspaceSchema {\n\t/**\n\t * Key-value pairs of State objects registered with the {@link StatesWorkspace}.\n\t */\n\t[key: string]: StatesWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;\n}\n\n/**\n * Map of State objects registered with {@link StatesWorkspace}.\n *\n * @sealed\n * @beta\n */\nexport type StatesWorkspaceEntries<TSchema extends StatesWorkspaceSchema> = {\n\t/**\n\t * Registered State objects.\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `StatesWorkspace` maintains a registry of State objects that all share and provide access to\n * presence state values across client members in a session.\n *\n * State objects offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @beta\n */\nexport interface StatesWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new State object with the {@link StatesWorkspace}.\n\t * @param key - new unique key for the State object within the workspace\n\t * @param manager - factory for creating a State object\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is StatesWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of State objects.\n\t */\n\treadonly states: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Default controls for management of broadcast updates.\n\t */\n\treadonly controls: BroadcastControls;\n\n\t/**\n\t * Containing {@link Presence}\n\t */\n\treadonly presence: Presence;\n}\n\n// #endregion StatesWorkspace\n\n// #region NotificationsWorkspace\n\n/**\n * Schema for a {@link NotificationsWorkspace} workspace.\n *\n * Keys of schema are the keys of the {@link NotificationsWorkspace} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface NotificationsWorkspaceSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<any>\n\t>;\n}\n\n/**\n * `NotificationsWorkspace` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @privateRemarks\n * This should be kept mostly in sync with {@link StatesWorkspace}. Notably the\n * return type of `add` is limited here and the `controls` property is omitted.\n * The `PresenceStatesImpl` class implements `AnyWorkspace` and therefore\n * `NotificationsWorkspace`, so long as this is proper subset.\n *\n * @sealed\n * @alpha\n */\nexport interface NotificationsWorkspace<TSchema extends NotificationsWorkspaceSchema> {\n\t/**\n\t * Registers a new `NotificationsManager` with the {@link NotificationsWorkspace}.\n\t * @param key - new unique key for the `NotificationsManager` within the workspace\n\t * @param manager - factory for creating a `NotificationsManager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends NotificationsManager<any>,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is NotificationsWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>\n\t>;\n\n\t/**\n\t * Registry of `NotificationsManager`s.\n\t */\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\n\t/**\n\t * Containing {@link PresenceWithNotifications}\n\t */\n\treadonly presence: PresenceWithNotifications;\n}\n\n// #endregion NotificationsWorkspace\n\n/**\n * `AnyWorkspace` is a superset of {@link StatesWorkspace} and {@link NotificationsWorkspace}.\n */\nexport interface AnyWorkspace<\n\tTSchema extends StatesWorkspaceSchema,\n\tTManagerConstraints = unknown,\n> extends StatesWorkspace<TSchema, TManagerConstraints> {\n\treadonly notifications: StatesWorkspaceEntries<TSchema>;\n\t// TO be removed if/when notifications are fully supported\n\treadonly presence: PresenceWithNotifications;\n}\n"]}
|
package/lib/valueManager.d.ts
CHANGED
|
@@ -6,14 +6,10 @@ import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
|
6
6
|
import type { ValueManager } from "./internalTypes.js";
|
|
7
7
|
/**
|
|
8
8
|
* Given a value manager, return opaque InternalTypes.StateValue.
|
|
9
|
-
*
|
|
10
|
-
* @internal
|
|
11
9
|
*/
|
|
12
10
|
export declare function brandIVM<TManagerInterface, TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue>>(manager: TManagerInterface & ValueManager<TValue, TValueState>): InternalTypes.StateValue<TManagerInterface>;
|
|
13
11
|
/**
|
|
14
12
|
* Extract the value manager from an opaque InternalTypes.StateValue.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
13
|
*/
|
|
18
14
|
export declare function unbrandIVM<TManagerInterface, TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue>>(branded: InternalTypes.StateValue<TManagerInterface>): ValueManager<TValue, TValueState>;
|
|
19
15
|
//# sourceMappingURL=valueManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueManager.d.ts","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"valueManager.d.ts","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,QAAQ,CACvB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAE/D,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,GAC5D,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAE7C;AAED;;GAEG;AACH,wBAAgB,UAAU,CACzB,iBAAiB,EACjB,MAAM,EACN,WAAW,SAAS,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAC9D,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAEzF"}
|
package/lib/valueManager.js
CHANGED
|
@@ -4,16 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Given a value manager, return opaque InternalTypes.StateValue.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
7
|
*/
|
|
10
8
|
export function brandIVM(manager) {
|
|
11
9
|
return manager;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
12
|
* Extract the value manager from an opaque InternalTypes.StateValue.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
13
|
*/
|
|
18
14
|
export function unbrandIVM(branded) {
|
|
19
15
|
return branded;
|
package/lib/valueManager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueManager.js","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH
|
|
1
|
+
{"version":3,"file":"valueManager.js","sourceRoot":"","sources":["../src/valueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,UAAU,QAAQ,CAKvB,OAA8D;IAE9D,OAAO,OAA2E,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAIxB,OAAoD;IACrD,OAAO,OAAuD,CAAC;AAChE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ValueManager } from \"./internalTypes.js\";\n\n/**\n * Given a value manager, return opaque InternalTypes.StateValue.\n */\nexport function brandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(\n\tmanager: TManagerInterface & ValueManager<TValue, TValueState>,\n): InternalTypes.StateValue<TManagerInterface> {\n\treturn manager as TManagerInterface as InternalTypes.StateValue<TManagerInterface>;\n}\n\n/**\n * Extract the value manager from an opaque InternalTypes.StateValue.\n */\nexport function unbrandIVM<\n\tTManagerInterface,\n\tTValue,\n\tTValueState extends InternalTypes.ValueDirectoryOrState<TValue>,\n>(branded: InternalTypes.StateValue<TManagerInterface>): ValueManager<TValue, TValueState> {\n\treturn branded as unknown as ValueManager<TValue, TValueState>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/presence",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.0",
|
|
4
4
|
"description": "A component for lightweight data sharing within a single session",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"temp-directory": "nyc/.nyc_output"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@fluid-internal/client-utils": "~2.
|
|
67
|
-
"@fluidframework/container-definitions": "~2.
|
|
68
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
69
|
-
"@fluidframework/core-interfaces": "~2.
|
|
70
|
-
"@fluidframework/core-utils": "~2.
|
|
71
|
-
"@fluidframework/datastore": "~2.
|
|
72
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
73
|
-
"@fluidframework/fluid-static": "~2.
|
|
74
|
-
"@fluidframework/id-compressor": "~2.
|
|
75
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
76
|
-
"@fluidframework/runtime-utils": "~2.
|
|
77
|
-
"@fluidframework/shared-object-base": "~2.
|
|
78
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
66
|
+
"@fluid-internal/client-utils": "~2.42.0",
|
|
67
|
+
"@fluidframework/container-definitions": "~2.42.0",
|
|
68
|
+
"@fluidframework/container-runtime-definitions": "~2.42.0",
|
|
69
|
+
"@fluidframework/core-interfaces": "~2.42.0",
|
|
70
|
+
"@fluidframework/core-utils": "~2.42.0",
|
|
71
|
+
"@fluidframework/datastore": "~2.42.0",
|
|
72
|
+
"@fluidframework/datastore-definitions": "~2.42.0",
|
|
73
|
+
"@fluidframework/fluid-static": "~2.42.0",
|
|
74
|
+
"@fluidframework/id-compressor": "~2.42.0",
|
|
75
|
+
"@fluidframework/runtime-definitions": "~2.42.0",
|
|
76
|
+
"@fluidframework/runtime-utils": "~2.42.0",
|
|
77
|
+
"@fluidframework/shared-object-base": "~2.42.0",
|
|
78
|
+
"@fluidframework/telemetry-utils": "~2.42.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"@fluid-tools/build-cli": "^0.55.0",
|
|
84
84
|
"@fluidframework/build-common": "^2.0.3",
|
|
85
85
|
"@fluidframework/build-tools": "^0.55.0",
|
|
86
|
-
"@fluidframework/driver-definitions": "~2.
|
|
86
|
+
"@fluidframework/driver-definitions": "~2.42.0",
|
|
87
87
|
"@fluidframework/eslint-config-fluid": "^5.7.4",
|
|
88
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
89
|
-
"@fluidframework/test-utils": "~2.
|
|
88
|
+
"@fluidframework/test-runtime-utils": "~2.42.0",
|
|
89
|
+
"@fluidframework/test-utils": "~2.42.0",
|
|
90
90
|
"@microsoft/api-extractor": "7.52.8",
|
|
91
91
|
"@types/mocha": "^10.0.10",
|
|
92
92
|
"@types/node": "^18.19.0",
|