@fluidframework/presence 2.33.0-333010 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/dist/alpha.d.ts +29 -25
- package/dist/baseTypes.d.ts +3 -3
- package/dist/baseTypes.js.map +1 -1
- package/dist/broadcastControls.d.ts +1 -1
- package/dist/broadcastControls.js.map +1 -1
- package/dist/datastorePresenceManagerFactory.d.ts +5 -5
- package/dist/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/dist/datastorePresenceManagerFactory.js +6 -6
- package/dist/datastorePresenceManagerFactory.js.map +1 -1
- package/dist/experimentalAccess.d.ts +4 -4
- package/dist/experimentalAccess.d.ts.map +1 -1
- package/dist/experimentalAccess.js +6 -6
- package/dist/experimentalAccess.js.map +1 -1
- package/dist/exposedInternalTypes.d.ts +1 -1
- package/dist/exposedInternalTypes.js.map +1 -1
- package/dist/exposedUtilityTypes.d.ts +0 -8
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/internalTypes.d.ts +3 -3
- package/dist/internalTypes.d.ts.map +1 -1
- package/dist/internalTypes.js.map +1 -1
- package/dist/internalUtils.d.ts +5 -0
- package/dist/internalUtils.d.ts.map +1 -1
- package/dist/internalUtils.js +8 -1
- package/dist/internalUtils.js.map +1 -1
- package/dist/latestMapValueManager.d.ts +57 -39
- package/dist/latestMapValueManager.d.ts.map +1 -1
- package/dist/latestMapValueManager.js +48 -39
- package/dist/latestMapValueManager.js.map +1 -1
- package/dist/latestValueManager.d.ts +38 -20
- package/dist/latestValueManager.d.ts.map +1 -1
- package/dist/latestValueManager.js +32 -28
- package/dist/latestValueManager.js.map +1 -1
- package/dist/latestValueTypes.d.ts +9 -10
- package/dist/latestValueTypes.d.ts.map +1 -1
- package/dist/latestValueTypes.js.map +1 -1
- package/dist/notificationsManager.d.ts +15 -10
- package/dist/notificationsManager.d.ts.map +1 -1
- package/dist/notificationsManager.js +8 -5
- package/dist/notificationsManager.js.map +1 -1
- package/dist/presence.d.ts +82 -66
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +5 -5
- package/dist/presence.js.map +1 -1
- package/dist/presenceDatastoreManager.d.ts +12 -10
- package/dist/presenceDatastoreManager.d.ts.map +1 -1
- package/dist/presenceDatastoreManager.js +10 -8
- package/dist/presenceDatastoreManager.js.map +1 -1
- package/dist/presenceManager.d.ts +2 -2
- package/dist/presenceManager.d.ts.map +1 -1
- package/dist/presenceManager.js +14 -22
- package/dist/presenceManager.js.map +1 -1
- package/dist/presenceStates.d.ts +14 -13
- package/dist/presenceStates.d.ts.map +1 -1
- package/dist/presenceStates.js +22 -15
- package/dist/presenceStates.js.map +1 -1
- package/dist/stateDatastore.d.ts +5 -4
- package/dist/stateDatastore.d.ts.map +1 -1
- package/dist/stateDatastore.js.map +1 -1
- package/dist/stateFactory.d.ts +22 -0
- package/dist/stateFactory.d.ts.map +1 -0
- package/dist/stateFactory.js +25 -0
- package/dist/stateFactory.js.map +1 -0
- package/dist/systemWorkspace.d.ts +7 -7
- package/dist/systemWorkspace.d.ts.map +1 -1
- package/dist/systemWorkspace.js +23 -23
- package/dist/systemWorkspace.js.map +1 -1
- package/dist/types.d.ts +50 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/lib/alpha.d.ts +29 -25
- package/lib/baseTypes.d.ts +3 -3
- package/lib/baseTypes.js.map +1 -1
- package/lib/broadcastControls.d.ts +1 -1
- package/lib/broadcastControls.js.map +1 -1
- package/lib/datastorePresenceManagerFactory.d.ts +5 -5
- package/lib/datastorePresenceManagerFactory.d.ts.map +1 -1
- package/lib/datastorePresenceManagerFactory.js +4 -4
- package/lib/datastorePresenceManagerFactory.js.map +1 -1
- package/lib/experimentalAccess.d.ts +4 -4
- package/lib/experimentalAccess.d.ts.map +1 -1
- package/lib/experimentalAccess.js +4 -4
- package/lib/experimentalAccess.js.map +1 -1
- package/lib/exposedInternalTypes.d.ts +1 -1
- package/lib/exposedInternalTypes.js.map +1 -1
- package/lib/exposedUtilityTypes.d.ts +0 -8
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/index.d.ts +8 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -5
- package/lib/index.js.map +1 -1
- package/lib/internalTypes.d.ts +3 -3
- package/lib/internalTypes.d.ts.map +1 -1
- package/lib/internalTypes.js.map +1 -1
- package/lib/internalUtils.d.ts +5 -0
- package/lib/internalUtils.d.ts.map +1 -1
- package/lib/internalUtils.js +6 -0
- package/lib/internalUtils.js.map +1 -1
- package/lib/latestMapValueManager.d.ts +57 -39
- package/lib/latestMapValueManager.d.ts.map +1 -1
- package/lib/latestMapValueManager.js +47 -38
- package/lib/latestMapValueManager.js.map +1 -1
- package/lib/latestValueManager.d.ts +38 -20
- package/lib/latestValueManager.d.ts.map +1 -1
- package/lib/latestValueManager.js +31 -27
- package/lib/latestValueManager.js.map +1 -1
- package/lib/latestValueTypes.d.ts +9 -10
- package/lib/latestValueTypes.d.ts.map +1 -1
- package/lib/latestValueTypes.js.map +1 -1
- package/lib/notificationsManager.d.ts +15 -10
- package/lib/notificationsManager.d.ts.map +1 -1
- package/lib/notificationsManager.js +8 -5
- package/lib/notificationsManager.js.map +1 -1
- package/lib/presence.d.ts +82 -66
- package/lib/presence.d.ts.map +1 -1
- package/lib/presence.js +4 -4
- package/lib/presence.js.map +1 -1
- package/lib/presenceDatastoreManager.d.ts +12 -10
- package/lib/presenceDatastoreManager.d.ts.map +1 -1
- package/lib/presenceDatastoreManager.js +10 -8
- package/lib/presenceDatastoreManager.js.map +1 -1
- package/lib/presenceManager.d.ts +2 -2
- package/lib/presenceManager.d.ts.map +1 -1
- package/lib/presenceManager.js +14 -22
- package/lib/presenceManager.js.map +1 -1
- package/lib/presenceStates.d.ts +14 -13
- package/lib/presenceStates.d.ts.map +1 -1
- package/lib/presenceStates.js +22 -15
- package/lib/presenceStates.js.map +1 -1
- package/lib/stateDatastore.d.ts +5 -4
- package/lib/stateDatastore.d.ts.map +1 -1
- package/lib/stateDatastore.js.map +1 -1
- package/lib/stateFactory.d.ts +22 -0
- package/lib/stateFactory.d.ts.map +1 -0
- package/lib/stateFactory.js +22 -0
- package/lib/stateFactory.js.map +1 -0
- package/lib/systemWorkspace.d.ts +7 -7
- package/lib/systemWorkspace.d.ts.map +1 -1
- package/lib/systemWorkspace.js +24 -24
- package/lib/systemWorkspace.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types.d.ts +50 -33
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/package.json +19 -19
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsBH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsBH,6CAOuB;AAHtB,6GAAA,cAAc,OAAA;AAUf,iEAAsD;AAA7C,oHAAA,WAAW,OAAA;AAEpB,2FAI8C;AAH7C,8IAAA,wBAAwB,OAAA;AAExB,iJAAA,2BAA2B,OAAA;AAyB5B,qEAOmC;AAHlC,wHAAA,aAAa,OAAA;AAKd,qDAAiD;AAAxC,+GAAA,YAAY,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Package for client presence within a connected session.\n *\n * See {@link https://github.com/microsoft/FluidFramework/tree/main/packages/framework/presence#readme | README.md } for an overview of the package.\n *\n * @packageDocumentation\n */\n\nexport type { ClientConnectionId } from \"./baseTypes.js\";\n\nexport type {\n\tNotificationsWorkspace,\n\tNotificationsWorkspaceSchema,\n\tStatesWorkspace,\n\tStatesWorkspaceEntries,\n\tStatesWorkspaceSchema,\n\tStatesWorkspaceEntry,\n\tWorkspaceAddress,\n} from \"./types.js\";\n\nexport {\n\ttype Attendee,\n\ttype AttendeesEvents,\n\ttype AttendeeId,\n\tAttendeeStatus,\n\ttype Presence,\n\ttype PresenceEvents,\n} from \"./presence.js\";\n\nexport type {\n\tBroadcastControls,\n\tBroadcastControlSettings,\n} from \"./broadcastControls.js\";\n\nexport { getPresence } from \"./experimentalAccess.js\";\n\nexport {\n\tgetPresenceViaDataObject,\n\ttype ExperimentalPresenceDO,\n\tExperimentalPresenceManager,\n} from \"./datastorePresenceManagerFactory.js\";\n\nexport type {\n\tlatestMap,\n\tLatestMapArguments,\n\tLatestMapRaw,\n\tLatestMapClientData,\n\tLatestMapRawEvents,\n\tLatestMapItemRemovedClientData,\n\tLatestMapItemUpdatedClientData,\n\tStateMap,\n} from \"./latestMapValueManager.js\";\nexport type {\n\tlatest,\n\tLatestArguments,\n\tLatestRaw,\n\tLatestRawEvents,\n} from \"./latestValueManager.js\";\nexport type {\n\tLatestClientData,\n\tLatestData,\n\tLatestMetadata,\n} from \"./latestValueTypes.js\";\n\nexport {\n\ttype NotificationEmitter,\n\ttype NotificationListenable,\n\ttype NotificationSubscriptions,\n\tNotifications,\n\ttype NotificationsManager,\n\ttype NotificationsManagerEvents,\n} from \"./notificationsManager.js\";\n\nexport { StateFactory } from \"./stateFactory.js\";\n\nexport type { InternalTypes } from \"./exposedInternalTypes.js\";\nexport type { InternalUtilityTypes } from \"./exposedUtilityTypes.js\";\n"]}
|
package/dist/internalTypes.d.ts
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
6
6
|
import type { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
7
7
|
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
8
|
-
import type {
|
|
8
|
+
import type { AttendeeId, Attendee } from "./presence.js";
|
|
9
9
|
import type { IRuntimeInternal } from "@fluidframework/presence/internal/container-definitions/internal";
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
export interface ClientRecord<TValue extends InternalTypes.ValueDirectoryOrState<unknown>> {
|
|
14
|
-
[
|
|
14
|
+
[AttendeeId: AttendeeId]: TValue;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* This interface is a subset of (IContainerRuntime & IRuntimeInternal) and
|
|
@@ -28,7 +28,7 @@ export type IEphemeralRuntime = Pick<(IContainerRuntime & IRuntimeInternal) | IF
|
|
|
28
28
|
*/
|
|
29
29
|
export interface ValueManager<TValue, TValueState extends InternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>> {
|
|
30
30
|
readonly value?: TValueState;
|
|
31
|
-
update(
|
|
31
|
+
update(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTypes.d.ts","sourceRoot":"","sources":["../src/internalTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"internalTypes.d.ts","sourceRoot":"","sources":["../src/internalTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAE7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kEAAkE,CAAC;AAEzG;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC;IAIxF,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CACnC,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,GAAG,sBAAsB,EAC/D,UAAU,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,KAAK,GAAG,IAAI,GAAG,cAAc,CACtF,GACA,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,YAAY,CAC5B,MAAM,EACN,WAAW,SACV,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAG1F,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAAC;CACrF;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTypes.js","sourceRoot":"","sources":["../src/internalTypes.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 { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"internalTypes.js","sourceRoot":"","sources":["../src/internalTypes.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 { IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\n\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { AttendeeId, Attendee } from \"./presence.js\";\n\nimport type { IRuntimeInternal } from \"@fluidframework/presence/internal/container-definitions/internal\";\n\n/**\n * @internal\n */\nexport interface ClientRecord<TValue extends InternalTypes.ValueDirectoryOrState<unknown>> {\n\t// Caution: any particular item may or may not exist\n\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t[AttendeeId: AttendeeId]: TValue;\n}\n\n/**\n * This interface is a subset of (IContainerRuntime & IRuntimeInternal) and\n * (IFluidDataStoreRuntime) that is needed by the Presence States.\n *\n * @privateRemarks\n * Replace with non-DataStore based interface.\n *\n * @internal\n */\nexport type IEphemeralRuntime = Pick<\n\t(IContainerRuntime & IRuntimeInternal) | IFluidDataStoreRuntime,\n\t\"clientId\" | \"connected\" | \"getAudience\" | \"getQuorum\" | \"off\" | \"on\" | \"submitSignal\"\n> &\n\tPartial<Pick<IFluidDataStoreRuntime, \"logger\">>;\n\n/**\n * @internal\n */\nexport interface ValueManager<\n\tTValue,\n\tTValueState extends\n\t\tInternalTypes.ValueDirectoryOrState<TValue> = InternalTypes.ValueDirectoryOrState<TValue>,\n> {\n\t// State objects should provide value - implement Required<ValueManager<...>>\n\treadonly value?: TValueState;\n\tupdate(attendee: Attendee, received: number, value: TValueState): PostUpdateAction[];\n}\n\n/**\n * @internal\n */\nexport type PostUpdateAction = () => void;\n"]}
|
package/dist/internalUtils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import type { DeepReadonly } from "@fluidframework/core-interfaces/internal";
|
|
5
6
|
/**
|
|
6
7
|
* Returns union of types of values in a record.
|
|
7
8
|
*/
|
|
@@ -51,5 +52,9 @@ export declare const objectKeys: <T>(o: T) => (keyof MapNumberIndicesToStrings<T
|
|
|
51
52
|
* value (the result of `defaultValue`)
|
|
52
53
|
*/
|
|
53
54
|
export declare function getOrCreateRecord<K extends string | number | symbol, V>(record: Record<K, V>, key: K, defaultValue: (key: K) => V): V;
|
|
55
|
+
/**
|
|
56
|
+
* Do nothing helper to apply deep immutability to a value's type.
|
|
57
|
+
*/
|
|
58
|
+
export declare function asDeeplyReadonly<T>(value: T): DeepReadonly<T>;
|
|
54
59
|
export {};
|
|
55
60
|
//# sourceMappingURL=internalUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalUtils.d.ts","sourceRoot":"","sources":["../src/internalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7C,KAAK,yBAAyB,CAAC,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,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AAa,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACxE,CAAC,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAElD,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAA4B,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,SACtC,CAAC,KACA,cAAc,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,UAAU,SAAyB,CAAC,KAAK,CAAC,MAAM,0BAA0B,CAAC,CAAC,CAAC,EAAE,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACtE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,GAAG,EAAE,CAAC,EACN,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GACzB,CAAC,CAKH;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAE7D"}
|
package/dist/internalUtils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getOrCreateRecord = exports.objectKeys = exports.objectEntriesWithoutUndefined = exports.objectEntries = void 0;
|
|
7
|
+
exports.asDeeplyReadonly = exports.getOrCreateRecord = exports.objectKeys = exports.objectEntriesWithoutUndefined = exports.objectEntries = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* Object.entries retyped to preserve known keys and their types.
|
|
10
10
|
*
|
|
@@ -47,4 +47,11 @@ function getOrCreateRecord(record, key, defaultValue) {
|
|
|
47
47
|
return record[key];
|
|
48
48
|
}
|
|
49
49
|
exports.getOrCreateRecord = getOrCreateRecord;
|
|
50
|
+
/**
|
|
51
|
+
* Do nothing helper to apply deep immutability to a value's type.
|
|
52
|
+
*/
|
|
53
|
+
function asDeeplyReadonly(value) {
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
exports.asDeeplyReadonly = asDeeplyReadonly;
|
|
50
57
|
//# sourceMappingURL=internalUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalUtils.js","sourceRoot":"","sources":["../src/internalUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"internalUtils.js","sourceRoot":"","sources":["../src/internalUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAqBH;;;;GAIG;AACU,QAAA,aAAa,GAAG,MAAM,CAAC,OAAwC,CAAC;AAE7E;;;;;;;;;GASG;AACU,QAAA,6BAA6B,GAAG,MAAM,CAAC,OAEN,CAAC;AAE/C;;;;GAIG;AACU,QAAA,UAAU,GAAG,MAAM,CAAC,IAA2D,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAChC,MAAoB,EACpB,GAAM,EACN,YAA2B;IAE3B,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;AATD,8CASC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAI,KAAQ;IAC3C,OAAO,KAAwB,CAAC;AACjC,CAAC;AAFD,4CAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DeepReadonly } from \"@fluidframework/core-interfaces/internal\";\n\n/**\n * Returns union of types of values in a record.\n */\nexport type RecordEntryTypes<T> = T[keyof T];\n\ntype MapNumberIndicesToStrings<T> = {\n\t[K in keyof T as K extends number ? `${K}` : K]: T[K];\n};\n\ntype KeyValuePairs<T> = {\n\t[K in keyof MapNumberIndicesToStrings<Required<T>>]: [K, Required<T>[K]];\n}[keyof MapNumberIndicesToStrings<Required<T>>][];\n\ntype RequiredAndNotUndefined<T> = {\n\t[K in keyof T]-?: Exclude<T[K], undefined>;\n};\n\n/**\n * Object.entries retyped to preserve known keys and their types.\n *\n * @internal\n */\nexport const objectEntries = Object.entries as <T>(o: T) => KeyValuePairs<T>;\n\n/**\n * Object.entries retyped to preserve known keys and their types.\n *\n * @remarks\n * Given `T` should not contain `undefined` values. If it does, use\n * {@link objectEntries} instead. Without `undefined` values, this\n * typing provides best handling of objects with optional properties.\n *\n * @internal\n */\nexport const objectEntriesWithoutUndefined = Object.entries as <T>(\n\to: T,\n) => KeyValuePairs<RequiredAndNotUndefined<T>>;\n\n/**\n * Object.keys retyped to preserve known keys and their types.\n *\n * @internal\n */\nexport const objectKeys = Object.keys as <T>(o: T) => (keyof MapNumberIndicesToStrings<T>)[];\n\n/**\n * Retrieve a value from a record with the given key, or create a new entry if\n * the key is not in the record.\n *\n * @param record - The record to index/update\n * @param key - The key to lookup in the record\n * @param defaultValue - a function which returns a default value. This is\n * called and used to set an initial value for the given key in the record if\n * none exists.\n * @returns either the existing value for the given key, or the newly-created\n * value (the result of `defaultValue`)\n */\nexport function getOrCreateRecord<K extends string | number | symbol, V>(\n\trecord: Record<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tif (!(key in record)) {\n\t\trecord[key] = defaultValue(key);\n\t}\n\treturn record[key];\n}\n\n/**\n * Do nothing helper to apply deep immutability to a value's type.\n */\nexport function asDeeplyReadonly<T>(value: T): DeepReadonly<T> {\n\treturn value as DeepReadonly<T>;\n}\n"]}
|
|
@@ -3,28 +3,27 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { Listenable } from "@fluidframework/core-interfaces";
|
|
6
|
-
import type { JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
+
import type { DeepReadonly, JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
7
7
|
import type { BroadcastControls, BroadcastControlSettings } from "./broadcastControls.js";
|
|
8
8
|
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type { ClientSessionId, ISessionClient } from "./presence.js";
|
|
9
|
+
import type { LatestClientData, LatestData, LatestMetadata } from "./latestValueTypes.js";
|
|
10
|
+
import type { AttendeeId, Attendee, Presence } from "./presence.js";
|
|
12
11
|
/**
|
|
13
12
|
* Collection of latest known values for a specific client.
|
|
14
13
|
*
|
|
15
14
|
* @sealed
|
|
16
15
|
* @alpha
|
|
17
16
|
*/
|
|
18
|
-
export interface
|
|
17
|
+
export interface LatestMapClientData<T, Keys extends string | number, SpecificAttendeeId extends AttendeeId = AttendeeId> {
|
|
19
18
|
/**
|
|
20
|
-
* Associated
|
|
19
|
+
* Associated attendee.
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
attendee: Attendee<SpecificAttendeeId>;
|
|
23
22
|
/**
|
|
24
23
|
* @privateRemarks This could be regular map currently as no Map is
|
|
25
24
|
* stored internally and a new instance is created for every request.
|
|
26
25
|
*/
|
|
27
|
-
items: ReadonlyMap<Keys,
|
|
26
|
+
items: ReadonlyMap<Keys, LatestData<T>>;
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* State of a single item value, its key, and its metadata.
|
|
@@ -32,7 +31,7 @@ export interface LatestMapValueClientData<T, Keys extends string | number, Speci
|
|
|
32
31
|
* @sealed
|
|
33
32
|
* @alpha
|
|
34
33
|
*/
|
|
35
|
-
export interface
|
|
34
|
+
export interface LatestMapItemUpdatedClientData<T, K extends string | number> extends LatestClientData<T> {
|
|
36
35
|
key: K;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
@@ -42,15 +41,15 @@ export interface LatestMapItemValueClientData<T, K extends string | number> exte
|
|
|
42
41
|
* @alpha
|
|
43
42
|
*/
|
|
44
43
|
export interface LatestMapItemRemovedClientData<K extends string | number> {
|
|
45
|
-
|
|
44
|
+
attendee: Attendee;
|
|
46
45
|
key: K;
|
|
47
|
-
metadata:
|
|
46
|
+
metadata: LatestMetadata;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* @sealed
|
|
51
50
|
* @alpha
|
|
52
51
|
*/
|
|
53
|
-
export interface
|
|
52
|
+
export interface LatestMapRawEvents<T, K extends string | number> {
|
|
54
53
|
/**
|
|
55
54
|
* Raised when any item's value for remote client is updated.
|
|
56
55
|
* @param updates - Map of one or more values updated.
|
|
@@ -59,21 +58,21 @@ export interface LatestMapValueManagerEvents<T, K extends string | number> {
|
|
|
59
58
|
*
|
|
60
59
|
* @eventProperty
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
remoteUpdated: (updates: LatestMapClientData<T, K>) => void;
|
|
63
62
|
/**
|
|
64
63
|
* Raised when specific item's value of remote client is updated.
|
|
65
64
|
* @param updatedItem - Updated item value.
|
|
66
65
|
*
|
|
67
66
|
* @eventProperty
|
|
68
67
|
*/
|
|
69
|
-
|
|
68
|
+
remoteItemUpdated: (updatedItem: LatestMapItemUpdatedClientData<T, K>) => void;
|
|
70
69
|
/**
|
|
71
70
|
* Raised when specific item of remote client is removed.
|
|
72
71
|
* @param removedItem - Removed item.
|
|
73
72
|
*
|
|
74
73
|
* @eventProperty
|
|
75
74
|
*/
|
|
76
|
-
|
|
75
|
+
remoteItemRemoved: (removedItem: LatestMapItemRemovedClientData<K>) => void;
|
|
77
76
|
/**
|
|
78
77
|
* Raised when specific local item's value is updated.
|
|
79
78
|
* @param updatedItem - Updated item value.
|
|
@@ -81,7 +80,7 @@ export interface LatestMapValueManagerEvents<T, K extends string | number> {
|
|
|
81
80
|
* @eventProperty
|
|
82
81
|
*/
|
|
83
82
|
localItemUpdated: (updatedItem: {
|
|
84
|
-
value:
|
|
83
|
+
value: DeepReadonly<JsonSerializable<T> & JsonDeserialized<T>>;
|
|
85
84
|
key: K;
|
|
86
85
|
}) => void;
|
|
87
86
|
/**
|
|
@@ -100,14 +99,14 @@ export interface LatestMapValueManagerEvents<T, K extends string | number> {
|
|
|
100
99
|
* @sealed
|
|
101
100
|
* @alpha
|
|
102
101
|
*/
|
|
103
|
-
export interface
|
|
102
|
+
export interface StateMap<K extends string | number, V> {
|
|
104
103
|
/**
|
|
105
|
-
* ${@link
|
|
104
|
+
* ${@link StateMap.delete}s all elements in the StateMap.
|
|
106
105
|
* @remarks This is not yet implemented.
|
|
107
106
|
*/
|
|
108
107
|
clear(): void;
|
|
109
108
|
/**
|
|
110
|
-
* @returns true if an element in the
|
|
109
|
+
* @returns true if an element in the StateMap existed and has been removed, or false if
|
|
111
110
|
* the element does not exist.
|
|
112
111
|
* @remarks No entry is fully removed. Instead an undefined placeholder is locally and
|
|
113
112
|
* transmitted to all other clients. For better performance limit the number of deleted
|
|
@@ -117,20 +116,20 @@ export interface ValueMap<K extends string | number, V> {
|
|
|
117
116
|
*/
|
|
118
117
|
delete(key: K): boolean;
|
|
119
118
|
/**
|
|
120
|
-
* Executes a provided function once per each key/value pair in the
|
|
119
|
+
* Executes a provided function once per each key/value pair in the StateMap, in arbitrary order.
|
|
121
120
|
*/
|
|
122
|
-
forEach(callbackfn: (value:
|
|
121
|
+
forEach(callbackfn: (value: DeepReadonly<JsonDeserialized<V>>, key: K, map: StateMap<K, V>) => void, thisArg?: unknown): void;
|
|
123
122
|
/**
|
|
124
|
-
* Returns a specified element from the
|
|
123
|
+
* Returns a specified element from the StateMap object.
|
|
125
124
|
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
|
|
126
125
|
*/
|
|
127
|
-
get(key: K):
|
|
126
|
+
get(key: K): DeepReadonly<JsonDeserialized<V>> | undefined;
|
|
128
127
|
/**
|
|
129
128
|
* @returns boolean indicating whether an element with the specified key exists or not.
|
|
130
129
|
*/
|
|
131
130
|
has(key: K): boolean;
|
|
132
131
|
/**
|
|
133
|
-
* Adds a new element with a specified key and value to the
|
|
132
|
+
* Adds a new element with a specified key and value to the StateMap. If an element with the same key already exists, the element will be updated.
|
|
134
133
|
* The value will be transmitted to all other connected clients.
|
|
135
134
|
*
|
|
136
135
|
* @remarks Manager assumes ownership of the value and its references.
|
|
@@ -139,7 +138,7 @@ export interface ValueMap<K extends string | number, V> {
|
|
|
139
138
|
*/
|
|
140
139
|
set(key: K, value: JsonSerializable<V> & JsonDeserialized<V>): this;
|
|
141
140
|
/**
|
|
142
|
-
* @returns the number of elements in the
|
|
141
|
+
* @returns the number of elements in the StateMap.
|
|
143
142
|
*/
|
|
144
143
|
readonly size: number;
|
|
145
144
|
/**
|
|
@@ -154,21 +153,25 @@ export interface ValueMap<K extends string | number, V> {
|
|
|
154
153
|
keys(): IterableIterator<K>;
|
|
155
154
|
}
|
|
156
155
|
/**
|
|
157
|
-
*
|
|
156
|
+
* State that provides a `Map` of latest known values from this client to
|
|
158
157
|
* others and read access to their values.
|
|
159
158
|
* Entries in the map may vary over time and by client, but all values are expected to
|
|
160
159
|
* be of the same type, which may be a union type.
|
|
161
160
|
*
|
|
162
|
-
* @remarks Create using {@link
|
|
161
|
+
* @remarks Create using {@link StateFactory.latestMap} registered to {@link StatesWorkspace}.
|
|
163
162
|
*
|
|
164
163
|
* @sealed
|
|
165
164
|
* @alpha
|
|
166
165
|
*/
|
|
167
|
-
export interface
|
|
166
|
+
export interface LatestMapRaw<T, Keys extends string | number = string | number> {
|
|
168
167
|
/**
|
|
169
|
-
*
|
|
168
|
+
* Containing {@link Presence}
|
|
170
169
|
*/
|
|
171
|
-
readonly
|
|
170
|
+
readonly presence: Presence;
|
|
171
|
+
/**
|
|
172
|
+
* Events for LatestMapRaw.
|
|
173
|
+
*/
|
|
174
|
+
readonly events: Listenable<LatestMapRawEvents<T, Keys>>;
|
|
172
175
|
/**
|
|
173
176
|
* Controls for management of sending updates.
|
|
174
177
|
*/
|
|
@@ -176,26 +179,41 @@ export interface LatestMapValueManager<T, Keys extends string | number = string
|
|
|
176
179
|
/**
|
|
177
180
|
* Current value map for this client.
|
|
178
181
|
*/
|
|
179
|
-
readonly local:
|
|
182
|
+
readonly local: StateMap<Keys, T>;
|
|
180
183
|
/**
|
|
181
184
|
* Iterable access to remote clients' map of values.
|
|
182
185
|
*/
|
|
183
|
-
|
|
186
|
+
getRemotes(): IterableIterator<LatestMapClientData<T, Keys>>;
|
|
184
187
|
/**
|
|
185
|
-
* Array of
|
|
188
|
+
* Array of {@link Attendee}s that have provided states.
|
|
186
189
|
*/
|
|
187
|
-
|
|
190
|
+
getStateAttendees(): Attendee[];
|
|
188
191
|
/**
|
|
189
192
|
* Access to a specific client's map of values.
|
|
190
193
|
*/
|
|
191
|
-
|
|
194
|
+
getRemote(attendee: Attendee): ReadonlyMap<Keys, LatestData<T>>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Arguments that are passed to the {@link StateFactory.latestMap} function.
|
|
198
|
+
*
|
|
199
|
+
* @alpha
|
|
200
|
+
*/
|
|
201
|
+
export interface LatestMapArguments<T, Keys extends string | number = string | number> {
|
|
202
|
+
/**
|
|
203
|
+
* The initial value of the local state.
|
|
204
|
+
*/
|
|
205
|
+
local?: {
|
|
206
|
+
[K in Keys]: JsonSerializable<T> & JsonDeserialized<T>;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* See {@link BroadcastControlSettings}.
|
|
210
|
+
*/
|
|
211
|
+
settings?: BroadcastControlSettings | undefined;
|
|
192
212
|
}
|
|
193
213
|
/**
|
|
194
|
-
* Factory for creating a {@link
|
|
214
|
+
* Factory for creating a {@link LatestMapRaw} State object.
|
|
195
215
|
*
|
|
196
216
|
* @alpha
|
|
197
217
|
*/
|
|
198
|
-
export declare function
|
|
199
|
-
[K in Keys]: JsonSerializable<T> & JsonDeserialized<T>;
|
|
200
|
-
}, controls?: BroadcastControlSettings): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapValueManager<T, Keys>>;
|
|
218
|
+
export declare function latestMap<T, Keys extends string | number = string | number, RegistrationKey extends string = string>(args?: LatestMapArguments<T, Keys>): InternalTypes.ManagerFactory<RegistrationKey, InternalTypes.MapValueState<T, Keys>, LatestMapRaw<T, Keys>>;
|
|
201
219
|
//# sourceMappingURL=latestMapValueManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latestMapValueManager.d.ts","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EACX,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAE1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"latestMapValueManager.d.ts","sourceRoot":"","sources":["../src/latestMapValueManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EACX,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,8DAA8D,CA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G,MAAM,GAAG,MAAM,GAAG,MAAM,EAC9C,eAAe,SAAS,MAAM,GAAG,MAAM,EAEvC,IAAI,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,GAChC,aAAa,CAAC,cAAc,CAC9B,eAAe,EACf,aAAa,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,EACpC,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CACrB,CA6CA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.latestMap = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const broadcastControls_js_1 = require("./broadcastControls.js");
|
|
10
10
|
const internalUtils_js_1 = require("./internalUtils.js");
|
|
@@ -54,12 +54,12 @@ class ValueMapImpl {
|
|
|
54
54
|
forEach(callbackfn, thisArg) {
|
|
55
55
|
for (const [key, item] of (0, internalUtils_js_1.objectEntries)(this.value.items)) {
|
|
56
56
|
if (item.value !== undefined) {
|
|
57
|
-
callbackfn(item.value, key, this);
|
|
57
|
+
callbackfn((0, internalUtils_js_1.asDeeplyReadonly)(item.value), key, this);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
get(key) {
|
|
62
|
-
return this.value.items[key]?.value;
|
|
62
|
+
return (0, internalUtils_js_1.asDeeplyReadonly)(this.value.items[key]?.value);
|
|
63
63
|
}
|
|
64
64
|
has(key) {
|
|
65
65
|
return this.value.items[key]?.value !== undefined;
|
|
@@ -70,7 +70,7 @@ class ValueMapImpl {
|
|
|
70
70
|
this.value.items[key] = { rev: 0, timestamp: 0, value };
|
|
71
71
|
}
|
|
72
72
|
this.updateItem(key, value);
|
|
73
|
-
this.emitter.emit("localItemUpdated", { key, value });
|
|
73
|
+
this.emitter.emit("localItemUpdated", { key, value: (0, internalUtils_js_1.asDeeplyReadonly)(value) });
|
|
74
74
|
return this;
|
|
75
75
|
}
|
|
76
76
|
get size() {
|
|
@@ -86,7 +86,7 @@ class ValueMapImpl {
|
|
|
86
86
|
return keys[Symbol.iterator]();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
class
|
|
89
|
+
class LatestMapRawValueManagerImpl {
|
|
90
90
|
constructor(key, datastore, value, controlSettings) {
|
|
91
91
|
this.key = key;
|
|
92
92
|
this.datastore = datastore;
|
|
@@ -99,46 +99,49 @@ class LatestMapValueManagerImpl {
|
|
|
99
99
|
});
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
get presence() {
|
|
103
|
+
return this.datastore.presence;
|
|
104
|
+
}
|
|
105
|
+
*getRemotes() {
|
|
103
106
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
104
|
-
for (const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
const items = this.
|
|
108
|
-
yield {
|
|
107
|
+
for (const attendeeId of (0, internalUtils_js_1.objectKeys)(allKnownStates.states)) {
|
|
108
|
+
if (attendeeId !== allKnownStates.self) {
|
|
109
|
+
const attendee = this.datastore.lookupClient(attendeeId);
|
|
110
|
+
const items = this.getRemote(attendee);
|
|
111
|
+
yield { attendee, items };
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
getStateAttendees() {
|
|
113
116
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
114
117
|
return (0, internalUtils_js_1.objectKeys)(allKnownStates.states)
|
|
115
|
-
.filter((
|
|
116
|
-
.map((
|
|
118
|
+
.filter((attendeeId) => attendeeId !== allKnownStates.self)
|
|
119
|
+
.map((attendeeId) => this.datastore.lookupClient(attendeeId));
|
|
117
120
|
}
|
|
118
|
-
|
|
121
|
+
getRemote(attendee) {
|
|
119
122
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
120
|
-
const
|
|
121
|
-
const clientStateMap = allKnownStates.states[
|
|
123
|
+
const attendeeId = attendee.attendeeId;
|
|
124
|
+
const clientStateMap = allKnownStates.states[attendeeId];
|
|
122
125
|
if (clientStateMap === undefined) {
|
|
123
|
-
throw new Error("No entry for
|
|
126
|
+
throw new Error("No entry for attendee");
|
|
124
127
|
}
|
|
125
128
|
const items = new Map();
|
|
126
129
|
for (const [key, item] of (0, internalUtils_js_1.objectEntries)(clientStateMap.items)) {
|
|
127
130
|
const value = item.value;
|
|
128
131
|
if (value !== undefined) {
|
|
129
132
|
items.set(key, {
|
|
130
|
-
value,
|
|
133
|
+
value: (0, internalUtils_js_1.asDeeplyReadonly)(value),
|
|
131
134
|
metadata: { revision: item.rev, timestamp: item.timestamp },
|
|
132
135
|
});
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
return items;
|
|
136
139
|
}
|
|
137
|
-
update(
|
|
140
|
+
update(attendee, _received, value) {
|
|
138
141
|
const allKnownStates = this.datastore.knownValues(this.key);
|
|
139
|
-
const
|
|
140
|
-
const currentState = (allKnownStates.states[
|
|
141
|
-
// New
|
|
142
|
+
const attendeeId = attendee.attendeeId;
|
|
143
|
+
const currentState = (allKnownStates.states[attendeeId] ??=
|
|
144
|
+
// New attendee - prepare new attendee state directory
|
|
142
145
|
{
|
|
143
146
|
rev: value.rev,
|
|
144
147
|
items: {},
|
|
@@ -160,7 +163,7 @@ class LatestMapValueManagerImpl {
|
|
|
160
163
|
currentState.rev = value.rev;
|
|
161
164
|
}
|
|
162
165
|
const allUpdates = {
|
|
163
|
-
|
|
166
|
+
attendee,
|
|
164
167
|
items: new Map(),
|
|
165
168
|
};
|
|
166
169
|
const postUpdateActions = [];
|
|
@@ -171,48 +174,54 @@ class LatestMapValueManagerImpl {
|
|
|
171
174
|
currentState.items[key] = item;
|
|
172
175
|
const metadata = { revision: item.rev, timestamp: item.timestamp };
|
|
173
176
|
if (item.value !== undefined) {
|
|
174
|
-
const itemValue = item.value;
|
|
177
|
+
const itemValue = (0, internalUtils_js_1.asDeeplyReadonly)(item.value);
|
|
175
178
|
const updatedItem = {
|
|
176
|
-
|
|
179
|
+
attendee,
|
|
177
180
|
key,
|
|
178
181
|
value: itemValue,
|
|
179
182
|
metadata,
|
|
180
183
|
};
|
|
181
|
-
postUpdateActions.push(() => this.events.emit("
|
|
184
|
+
postUpdateActions.push(() => this.events.emit("remoteItemUpdated", updatedItem));
|
|
182
185
|
allUpdates.items.set(key, { value: itemValue, metadata });
|
|
183
186
|
}
|
|
184
187
|
else if (hadPriorValue !== undefined) {
|
|
185
|
-
postUpdateActions.push(() => this.events.emit("
|
|
186
|
-
|
|
188
|
+
postUpdateActions.push(() => this.events.emit("remoteItemRemoved", {
|
|
189
|
+
attendee,
|
|
187
190
|
key,
|
|
188
191
|
metadata,
|
|
189
192
|
}));
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
|
-
this.datastore.update(this.key,
|
|
193
|
-
postUpdateActions.push(() => this.events.emit("
|
|
195
|
+
this.datastore.update(this.key, attendeeId, currentState);
|
|
196
|
+
postUpdateActions.push(() => this.events.emit("remoteUpdated", allUpdates));
|
|
194
197
|
return postUpdateActions;
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
/**
|
|
198
|
-
* Factory for creating a {@link
|
|
201
|
+
* Factory for creating a {@link LatestMapRaw} State object.
|
|
199
202
|
*
|
|
200
203
|
* @alpha
|
|
201
204
|
*/
|
|
202
|
-
function
|
|
205
|
+
function latestMap(args) {
|
|
206
|
+
const settings = args?.settings;
|
|
207
|
+
const initialValues = args?.local;
|
|
203
208
|
const timestamp = Date.now();
|
|
204
209
|
const value = { rev: 0, items: {} };
|
|
205
|
-
//
|
|
210
|
+
// LatestMapRaw takes ownership of values within initialValues.
|
|
206
211
|
if (initialValues !== undefined) {
|
|
207
212
|
for (const key of (0, internalUtils_js_1.objectKeys)(initialValues)) {
|
|
208
|
-
value.items[key] = {
|
|
213
|
+
value.items[key] = {
|
|
214
|
+
rev: 0,
|
|
215
|
+
timestamp,
|
|
216
|
+
value: initialValues[key],
|
|
217
|
+
};
|
|
209
218
|
}
|
|
210
219
|
}
|
|
211
220
|
const factory = (key, datastoreHandle) => ({
|
|
212
|
-
initialData: { value, allowableUpdateLatencyMs:
|
|
213
|
-
manager: (0, valueManager_js_1.brandIVM)(new
|
|
221
|
+
initialData: { value, allowableUpdateLatencyMs: settings?.allowableUpdateLatencyMs },
|
|
222
|
+
manager: (0, valueManager_js_1.brandIVM)(new LatestMapRawValueManagerImpl(key, (0, stateDatastore_js_1.datastoreFromHandle)(datastoreHandle), value, settings)),
|
|
214
223
|
});
|
|
215
|
-
return Object.assign(factory, { instanceBase:
|
|
224
|
+
return Object.assign(factory, { instanceBase: LatestMapRawValueManagerImpl });
|
|
216
225
|
}
|
|
217
|
-
exports.
|
|
226
|
+
exports.latestMap = latestMap;
|
|
218
227
|
//# sourceMappingURL=latestMapValueManager.js.map
|