@fluidframework/presence 2.92.0 → 2.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/alpha.d.ts +6 -4
- package/dist/beta.d.ts +5 -2
- package/dist/getPresence.d.ts +4 -9
- package/dist/getPresence.d.ts.map +1 -1
- package/dist/getPresence.js +6 -86
- package/dist/getPresence.js.map +1 -1
- package/dist/index.d.ts +4 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/legacy.alpha.d.ts +6 -4
- package/dist/package.json +1 -15
- package/dist/public.d.ts +69 -0
- package/lib/alpha.d.ts +6 -4
- package/lib/beta.d.ts +5 -2
- package/lib/getPresence.d.ts +4 -9
- package/lib/getPresence.d.ts.map +1 -1
- package/lib/getPresence.js +6 -85
- package/lib/getPresence.js.map +1 -1
- package/lib/index.d.ts +4 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/legacy.alpha.d.ts +6 -4
- package/lib/public.d.ts +69 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/package.json +32 -78
- package/dist/baseTypes.d.ts +0 -24
- package/dist/baseTypes.d.ts.map +0 -1
- package/dist/baseTypes.js +0 -7
- package/dist/baseTypes.js.map +0 -1
- package/dist/broadcastControls.d.ts +0 -37
- package/dist/broadcastControls.d.ts.map +0 -1
- package/dist/broadcastControls.js +0 -60
- package/dist/broadcastControls.js.map +0 -1
- package/dist/broadcastControlsTypes.d.ts +0 -38
- package/dist/broadcastControlsTypes.d.ts.map +0 -1
- package/dist/broadcastControlsTypes.js +0 -7
- package/dist/broadcastControlsTypes.js.map +0 -1
- package/dist/exposedInternalTypes.d.ts +0 -138
- package/dist/exposedInternalTypes.d.ts.map +0 -1
- package/dist/exposedInternalTypes.js +0 -19
- package/dist/exposedInternalTypes.js.map +0 -1
- package/dist/exposedUtilityTypes.d.ts +0 -108
- package/dist/exposedUtilityTypes.d.ts.map +0 -1
- package/dist/exposedUtilityTypes.js +0 -7
- package/dist/exposedUtilityTypes.js.map +0 -1
- package/dist/internalUtils.d.ts +0 -125
- package/dist/internalUtils.d.ts.map +0 -1
- package/dist/internalUtils.js +0 -99
- package/dist/internalUtils.js.map +0 -1
- package/dist/latestMapTypes.d.ts +0 -343
- package/dist/latestMapTypes.d.ts.map +0 -1
- package/dist/latestMapTypes.js +0 -7
- package/dist/latestMapTypes.js.map +0 -1
- package/dist/latestMapValueManager.d.ts +0 -52
- package/dist/latestMapValueManager.d.ts.map +0 -1
- package/dist/latestMapValueManager.js +0 -250
- package/dist/latestMapValueManager.js.map +0 -1
- package/dist/latestTypes.d.ts +0 -183
- package/dist/latestTypes.d.ts.map +0 -1
- package/dist/latestTypes.js +0 -7
- package/dist/latestTypes.js.map +0 -1
- package/dist/latestValueManager.d.ts +0 -10
- package/dist/latestValueManager.d.ts.map +0 -1
- package/dist/latestValueManager.js +0 -117
- package/dist/latestValueManager.js.map +0 -1
- package/dist/latestValueTypes.d.ts +0 -108
- package/dist/latestValueTypes.d.ts.map +0 -1
- package/dist/latestValueTypes.js +0 -7
- package/dist/latestValueTypes.js.map +0 -1
- package/dist/notificationsManager.d.ts +0 -27
- package/dist/notificationsManager.d.ts.map +0 -1
- package/dist/notificationsManager.js +0 -98
- package/dist/notificationsManager.js.map +0 -1
- package/dist/notificationsManagerTypes.d.ts +0 -144
- package/dist/notificationsManagerTypes.d.ts.map +0 -1
- package/dist/notificationsManagerTypes.js +0 -7
- package/dist/notificationsManagerTypes.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/presence.d.ts +0 -229
- package/dist/presence.d.ts.map +0 -1
- package/dist/presence.js +0 -23
- package/dist/presence.js.map +0 -1
- package/dist/presenceDatastoreManager.d.ts +0 -149
- package/dist/presenceDatastoreManager.d.ts.map +0 -1
- package/dist/presenceDatastoreManager.js +0 -667
- package/dist/presenceDatastoreManager.js.map +0 -1
- package/dist/presenceManager.d.ts +0 -16
- package/dist/presenceManager.d.ts.map +0 -1
- package/dist/presenceManager.js +0 -140
- package/dist/presenceManager.js.map +0 -1
- package/dist/presenceStates.d.ts +0 -102
- package/dist/presenceStates.d.ts.map +0 -1
- package/dist/presenceStates.js +0 -231
- package/dist/presenceStates.js.map +0 -1
- package/dist/protocol.d.ts +0 -111
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -20
- package/dist/protocol.js.map +0 -1
- package/dist/runtimeTypes.d.ts +0 -26
- package/dist/runtimeTypes.d.ts.map +0 -1
- package/dist/runtimeTypes.js +0 -7
- package/dist/runtimeTypes.js.map +0 -1
- package/dist/stateDatastore.d.ts +0 -56
- package/dist/stateDatastore.d.ts.map +0 -1
- package/dist/stateDatastore.js +0 -22
- package/dist/stateDatastore.js.map +0 -1
- package/dist/stateFactory.d.ts +0 -18
- package/dist/stateFactory.d.ts.map +0 -1
- package/dist/stateFactory.js +0 -23
- package/dist/stateFactory.js.map +0 -1
- package/dist/statesManagerTypes.d.ts +0 -27
- package/dist/statesManagerTypes.d.ts.map +0 -1
- package/dist/statesManagerTypes.js +0 -7
- package/dist/statesManagerTypes.js.map +0 -1
- package/dist/systemWorkspace.d.ts +0 -58
- package/dist/systemWorkspace.d.ts.map +0 -1
- package/dist/systemWorkspace.js +0 -265
- package/dist/systemWorkspace.js.map +0 -1
- package/dist/timerManager.d.ts +0 -37
- package/dist/timerManager.d.ts.map +0 -1
- package/dist/timerManager.js +0 -65
- package/dist/timerManager.js.map +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
- package/dist/validatableTypes.d.ts +0 -69
- package/dist/validatableTypes.d.ts.map +0 -1
- package/dist/validatableTypes.js +0 -7
- package/dist/validatableTypes.js.map +0 -1
- package/dist/validatedGetter.d.ts +0 -18
- package/dist/validatedGetter.d.ts.map +0 -1
- package/dist/validatedGetter.js +0 -43
- package/dist/validatedGetter.js.map +0 -1
- package/dist/valueManager.d.ts +0 -15
- package/dist/valueManager.d.ts.map +0 -1
- package/dist/valueManager.js +0 -22
- package/dist/valueManager.js.map +0 -1
- package/lib/baseTypes.d.ts +0 -24
- package/lib/baseTypes.d.ts.map +0 -1
- package/lib/baseTypes.js +0 -6
- package/lib/baseTypes.js.map +0 -1
- package/lib/broadcastControls.d.ts +0 -37
- package/lib/broadcastControls.d.ts.map +0 -1
- package/lib/broadcastControls.js +0 -55
- package/lib/broadcastControls.js.map +0 -1
- package/lib/broadcastControlsTypes.d.ts +0 -38
- package/lib/broadcastControlsTypes.d.ts.map +0 -1
- package/lib/broadcastControlsTypes.js +0 -6
- package/lib/broadcastControlsTypes.js.map +0 -1
- package/lib/exposedInternalTypes.d.ts +0 -138
- package/lib/exposedInternalTypes.d.ts.map +0 -1
- package/lib/exposedInternalTypes.js +0 -16
- package/lib/exposedInternalTypes.js.map +0 -1
- package/lib/exposedUtilityTypes.d.ts +0 -108
- package/lib/exposedUtilityTypes.d.ts.map +0 -1
- package/lib/exposedUtilityTypes.js +0 -6
- package/lib/exposedUtilityTypes.js.map +0 -1
- package/lib/internalUtils.d.ts +0 -125
- package/lib/internalUtils.d.ts.map +0 -1
- package/lib/internalUtils.js +0 -90
- package/lib/internalUtils.js.map +0 -1
- package/lib/latestMapTypes.d.ts +0 -343
- package/lib/latestMapTypes.d.ts.map +0 -1
- package/lib/latestMapTypes.js +0 -6
- package/lib/latestMapTypes.js.map +0 -1
- package/lib/latestMapValueManager.d.ts +0 -52
- package/lib/latestMapValueManager.d.ts.map +0 -1
- package/lib/latestMapValueManager.js +0 -246
- package/lib/latestMapValueManager.js.map +0 -1
- package/lib/latestTypes.d.ts +0 -183
- package/lib/latestTypes.d.ts.map +0 -1
- package/lib/latestTypes.js +0 -6
- package/lib/latestTypes.js.map +0 -1
- package/lib/latestValueManager.d.ts +0 -10
- package/lib/latestValueManager.d.ts.map +0 -1
- package/lib/latestValueManager.js +0 -113
- package/lib/latestValueManager.js.map +0 -1
- package/lib/latestValueTypes.d.ts +0 -108
- package/lib/latestValueTypes.d.ts.map +0 -1
- package/lib/latestValueTypes.js +0 -6
- package/lib/latestValueTypes.js.map +0 -1
- package/lib/notificationsManager.d.ts +0 -27
- package/lib/notificationsManager.d.ts.map +0 -1
- package/lib/notificationsManager.js +0 -94
- package/lib/notificationsManager.js.map +0 -1
- package/lib/notificationsManagerTypes.d.ts +0 -144
- package/lib/notificationsManagerTypes.d.ts.map +0 -1
- package/lib/notificationsManagerTypes.js +0 -6
- package/lib/notificationsManagerTypes.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/lib/presence.d.ts +0 -229
- package/lib/presence.d.ts.map +0 -1
- package/lib/presence.js +0 -20
- package/lib/presence.js.map +0 -1
- package/lib/presenceDatastoreManager.d.ts +0 -149
- package/lib/presenceDatastoreManager.d.ts.map +0 -1
- package/lib/presenceDatastoreManager.js +0 -663
- package/lib/presenceDatastoreManager.js.map +0 -1
- package/lib/presenceManager.d.ts +0 -16
- package/lib/presenceManager.d.ts.map +0 -1
- package/lib/presenceManager.js +0 -136
- package/lib/presenceManager.js.map +0 -1
- package/lib/presenceStates.d.ts +0 -102
- package/lib/presenceStates.d.ts.map +0 -1
- package/lib/presenceStates.js +0 -225
- package/lib/presenceStates.js.map +0 -1
- package/lib/protocol.d.ts +0 -111
- package/lib/protocol.d.ts.map +0 -1
- package/lib/protocol.js +0 -17
- package/lib/protocol.js.map +0 -1
- package/lib/runtimeTypes.d.ts +0 -26
- package/lib/runtimeTypes.d.ts.map +0 -1
- package/lib/runtimeTypes.js +0 -6
- package/lib/runtimeTypes.js.map +0 -1
- package/lib/stateDatastore.d.ts +0 -56
- package/lib/stateDatastore.d.ts.map +0 -1
- package/lib/stateDatastore.js +0 -17
- package/lib/stateDatastore.js.map +0 -1
- package/lib/stateFactory.d.ts +0 -18
- package/lib/stateFactory.d.ts.map +0 -1
- package/lib/stateFactory.js +0 -20
- package/lib/stateFactory.js.map +0 -1
- package/lib/statesManagerTypes.d.ts +0 -27
- package/lib/statesManagerTypes.d.ts.map +0 -1
- package/lib/statesManagerTypes.js +0 -6
- package/lib/statesManagerTypes.js.map +0 -1
- package/lib/systemWorkspace.d.ts +0 -58
- package/lib/systemWorkspace.d.ts.map +0 -1
- package/lib/systemWorkspace.js +0 -261
- package/lib/systemWorkspace.js.map +0 -1
- package/lib/timerManager.d.ts +0 -37
- package/lib/timerManager.d.ts.map +0 -1
- package/lib/timerManager.js +0 -61
- package/lib/timerManager.js.map +0 -1
- package/lib/types.d.ts +0 -132
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/lib/validatableTypes.d.ts +0 -69
- package/lib/validatableTypes.d.ts.map +0 -1
- package/lib/validatableTypes.js +0 -6
- package/lib/validatableTypes.js.map +0 -1
- package/lib/validatedGetter.d.ts +0 -18
- package/lib/validatedGetter.d.ts.map +0 -1
- package/lib/validatedGetter.js +0 -39
- package/lib/validatedGetter.js.map +0 -1
- package/lib/valueManager.d.ts +0 -15
- package/lib/valueManager.d.ts.map +0 -1
- package/lib/valueManager.js +0 -17
- package/lib/valueManager.js.map +0 -1
package/dist/presenceStates.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createPresenceStates = exports.mergeUntrackedDatastore = exports.mergeValueDirectory = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
-
const broadcastControls_js_1 = require("./broadcastControls.js");
|
|
10
|
-
const internalUtils_js_1 = require("./internalUtils.js");
|
|
11
|
-
const stateDatastore_js_1 = require("./stateDatastore.js");
|
|
12
|
-
const valueManager_js_1 = require("./valueManager.js");
|
|
13
|
-
function isValueDirectory(value) {
|
|
14
|
-
return "items" in value;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Merge a value directory.
|
|
18
|
-
*
|
|
19
|
-
* @privateRemarks
|
|
20
|
-
* This implementation uses the InternalTypes set of Value types but it is
|
|
21
|
-
* agnostic so long as the validatable versions don't start requiring
|
|
22
|
-
* properties.
|
|
23
|
-
*/
|
|
24
|
-
function mergeValueDirectory(base, update, timeDelta) {
|
|
25
|
-
if (!isValueDirectory(update)) {
|
|
26
|
-
if (base === undefined || update.rev > base.rev) {
|
|
27
|
-
return { ...update, timestamp: update.timestamp + timeDelta };
|
|
28
|
-
}
|
|
29
|
-
return base;
|
|
30
|
-
}
|
|
31
|
-
let mergeBase;
|
|
32
|
-
if (base === undefined) {
|
|
33
|
-
mergeBase = { rev: update.rev, items: {} };
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const baseIsDirectory = isValueDirectory(base);
|
|
37
|
-
if (base.rev >= update.rev) {
|
|
38
|
-
if (!baseIsDirectory) {
|
|
39
|
-
// base is leaf value that is more recent - nothing to do
|
|
40
|
-
return base;
|
|
41
|
-
}
|
|
42
|
-
// While base has more advanced revision, assume mis-ordering or
|
|
43
|
-
// missed and catchup update needs merged in.
|
|
44
|
-
mergeBase = base;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
mergeBase = { rev: update.rev, items: baseIsDirectory ? base.items : {} };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
for (const [key, value] of Object.entries(update.items)) {
|
|
51
|
-
const baseElement = mergeBase.items[key];
|
|
52
|
-
mergeBase.items[key] = mergeValueDirectory(baseElement, value, timeDelta);
|
|
53
|
-
}
|
|
54
|
-
return mergeBase;
|
|
55
|
-
}
|
|
56
|
-
exports.mergeValueDirectory = mergeValueDirectory;
|
|
57
|
-
/**
|
|
58
|
-
* Updates remote state into the local [untracked] datastore.
|
|
59
|
-
*
|
|
60
|
-
* @param key - The key of the datastore to merge the untracked data into.
|
|
61
|
-
* @param remoteAllKnownState - The remote state to merge into the datastore.
|
|
62
|
-
* @param datastore - The datastore to merge the untracked data into.
|
|
63
|
-
*
|
|
64
|
-
* @remarks
|
|
65
|
-
* In the case of ignored unmonitored data, the client entries are not stored,
|
|
66
|
-
* though the value keys will be populated and often remain empty.
|
|
67
|
-
*/
|
|
68
|
-
function mergeUntrackedDatastore(key, remoteAllKnownState, datastore, timeModifier) {
|
|
69
|
-
const localAllKnownState = (0, internalUtils_js_1.getOrCreateRecord)(datastore, key, () => ({}));
|
|
70
|
-
for (const [attendeeId, value] of (0, internalUtils_js_1.objectEntries)(remoteAllKnownState)) {
|
|
71
|
-
if (!("ignoreUnmonitored" in value)) {
|
|
72
|
-
localAllKnownState[attendeeId] = mergeValueDirectory(localAllKnownState[attendeeId], value, timeModifier);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.mergeUntrackedDatastore = mergeUntrackedDatastore;
|
|
77
|
-
/**
|
|
78
|
-
* The default allowable update latency for StatesWorkspace in milliseconds.
|
|
79
|
-
*/
|
|
80
|
-
const defaultAllowableUpdateLatencyMs = 60;
|
|
81
|
-
/**
|
|
82
|
-
* No-runtime-effect helper to protect cast from unknown datastore to specific
|
|
83
|
-
* schema record type. (It is up to consumer to check that record conforms to
|
|
84
|
-
* expectations.)
|
|
85
|
-
*/
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
87
|
-
function castUnknownRecordToSchemaRecord(record) {
|
|
88
|
-
return record;
|
|
89
|
-
}
|
|
90
|
-
class PresenceStatesImpl {
|
|
91
|
-
constructor(runtime, datastore, initialContent, controlsSettings) {
|
|
92
|
-
this.runtime = runtime;
|
|
93
|
-
this.datastore = datastore;
|
|
94
|
-
this.controls = new broadcastControls_js_1.RequiredBroadcastControl(defaultAllowableUpdateLatencyMs);
|
|
95
|
-
if (controlsSettings?.allowableUpdateLatencyMs !== undefined) {
|
|
96
|
-
this.controls.allowableUpdateLatencyMs = controlsSettings.allowableUpdateLatencyMs;
|
|
97
|
-
}
|
|
98
|
-
// Prepare initial map content from initial state
|
|
99
|
-
{
|
|
100
|
-
const attendeeId = this.runtime.attendeeId;
|
|
101
|
-
// Empty record does not satisfy the type, but nodes will post loop.
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
103
|
-
const nodes = {};
|
|
104
|
-
let anyInitialValues = false;
|
|
105
|
-
const newValues = {};
|
|
106
|
-
let cumulativeAllowableUpdateLatencyMs;
|
|
107
|
-
for (const [key, nodeFactory] of Object.entries(initialContent)) {
|
|
108
|
-
const newNodeData = nodeFactory(key, (0, stateDatastore_js_1.handleFromDatastore)(this));
|
|
109
|
-
nodes[key] = newNodeData.manager;
|
|
110
|
-
if ("initialData" in newNodeData) {
|
|
111
|
-
const { value, allowableUpdateLatencyMs } = newNodeData.initialData;
|
|
112
|
-
(datastore[key] ??= {})[attendeeId] = value;
|
|
113
|
-
newValues[key] = value;
|
|
114
|
-
if (allowableUpdateLatencyMs !== undefined) {
|
|
115
|
-
cumulativeAllowableUpdateLatencyMs =
|
|
116
|
-
cumulativeAllowableUpdateLatencyMs === undefined
|
|
117
|
-
? allowableUpdateLatencyMs
|
|
118
|
-
: Math.min(cumulativeAllowableUpdateLatencyMs, allowableUpdateLatencyMs);
|
|
119
|
-
}
|
|
120
|
-
anyInitialValues = true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
this.nodes = nodes;
|
|
124
|
-
// states and notifications are the public view of nodes that limits the entries
|
|
125
|
-
// types to the public interface of State objects with an additional type
|
|
126
|
-
// filter that beguiles the type system. So just reinterpret cast.
|
|
127
|
-
const properties = nodes;
|
|
128
|
-
// `AnyWorkspace` support comes from defining both `states` for
|
|
129
|
-
// `StatesWorkspace` and `notifications` for `NotificationsWorkspace`.
|
|
130
|
-
// `notifications` is always a subset of what `states` can be; so the same.
|
|
131
|
-
this.notifications = this.states = properties;
|
|
132
|
-
if (anyInitialValues) {
|
|
133
|
-
this.runtime.localUpdate(newValues, {
|
|
134
|
-
allowableUpdateLatencyMs: cumulativeAllowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
get presence() {
|
|
140
|
-
return this.runtime.presence;
|
|
141
|
-
}
|
|
142
|
-
knownValues(key) {
|
|
143
|
-
return {
|
|
144
|
-
self: this.runtime.attendeeId,
|
|
145
|
-
// Caller must only use `key`s that are part of `this.datastore`.
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
|
-
states: castUnknownRecordToSchemaRecord(this.datastore[key]),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
localUpdate(key, value, options) {
|
|
151
|
-
this.runtime.localUpdate({ [key]: value }, {
|
|
152
|
-
...options,
|
|
153
|
-
allowableUpdateLatencyMs: options.allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
update(key, clientId, value) {
|
|
157
|
-
// Callers my only use `key`s that are part of `this.datastore`.
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
159
|
-
const allKnownState = this.datastore[key];
|
|
160
|
-
allKnownState[clientId] = mergeValueDirectory(allKnownState[clientId], value, 0);
|
|
161
|
-
}
|
|
162
|
-
add(key, nodeFactory) {
|
|
163
|
-
(0, internal_1.assert)(!(key in this.nodes), 0xa3c /* Already have entry for key in map */);
|
|
164
|
-
const nodeData = nodeFactory(key, (0, stateDatastore_js_1.handleFromDatastore)(this));
|
|
165
|
-
this.nodes[key] = nodeData.manager;
|
|
166
|
-
if ("initialData" in nodeData) {
|
|
167
|
-
const { value, allowableUpdateLatencyMs } = nodeData.initialData;
|
|
168
|
-
let datastoreValue = this.datastore[key];
|
|
169
|
-
if (datastoreValue === undefined) {
|
|
170
|
-
datastoreValue = this.datastore[key] = {};
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
// Already have received state from other clients. Kept in `all`.
|
|
174
|
-
// TODO: Send current `all` state to state manager.
|
|
175
|
-
}
|
|
176
|
-
datastoreValue[this.runtime.attendeeId] = value;
|
|
177
|
-
this.runtime.localUpdate({ [key]: value }, {
|
|
178
|
-
allowableUpdateLatencyMs: allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
ensureContent(content, controls) {
|
|
183
|
-
if (controls?.allowableUpdateLatencyMs !== undefined) {
|
|
184
|
-
this.controls.allowableUpdateLatencyMs = controls.allowableUpdateLatencyMs;
|
|
185
|
-
}
|
|
186
|
-
for (const [key, nodeFactory] of Object.entries(content)) {
|
|
187
|
-
const brandedIVM = this.nodes[key];
|
|
188
|
-
if (brandedIVM === undefined) {
|
|
189
|
-
this.add(key, nodeFactory);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
const node = (0, valueManager_js_1.unbrandIVM)(brandedIVM);
|
|
193
|
-
if (!(node instanceof nodeFactory.instanceBase)) {
|
|
194
|
-
throw new TypeError(`State "${key}" previously created by different State object.`);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
processUpdate(received, timeModifier, remoteDatastore) {
|
|
201
|
-
const postUpdateActions = [];
|
|
202
|
-
for (const [key, remoteAllKnownState] of Object.entries(remoteDatastore)) {
|
|
203
|
-
const brandedIVM = this.nodes[key];
|
|
204
|
-
if (brandedIVM === undefined) {
|
|
205
|
-
// Assume all broadcast state is meant to be kept even if not currently registered.
|
|
206
|
-
mergeUntrackedDatastore(key, remoteAllKnownState, this.datastore, timeModifier);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
const node = (0, valueManager_js_1.unbrandIVM)(brandedIVM);
|
|
210
|
-
for (const [attendeeId, value] of (0, internalUtils_js_1.objectEntries)(remoteAllKnownState)) {
|
|
211
|
-
const client = this.runtime.presence.attendees.getAttendee(attendeeId);
|
|
212
|
-
postUpdateActions.push(...node.update(client, received, value));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return postUpdateActions;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Create a new Workspace using the DataStoreRuntime provided.
|
|
221
|
-
* @param initialContent - The initial State objects to register.
|
|
222
|
-
*/
|
|
223
|
-
function createPresenceStates(runtime, datastore, initialContent, controls) {
|
|
224
|
-
const impl = new PresenceStatesImpl(runtime, datastore, initialContent, controls);
|
|
225
|
-
return {
|
|
226
|
-
public: impl,
|
|
227
|
-
internal: impl,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
exports.createPresenceStates = createPresenceStates;
|
|
231
|
-
//# sourceMappingURL=presenceStates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presenceStates.js","sourceRoot":"","sources":["../src/presenceStates.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAG7D,iEAAkE;AAIlE,yDAAsE;AAOtE,2DAA0D;AAU1D,uDAA+C;AA0H/C,SAAS,gBAAgB,CAMxB,KAAoD;IAEpD,OAAO,OAAO,IAAI,KAAK,CAAC;AACzB,CAAC;AAmCD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAMlC,IAA+D,EAC/D,MAAqD,EACrD,SAAiB;IAEjB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,GAAG,I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E,IAAI;KACd,CAAC;AACH,CAAC;AAZD,oDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport { RequiredBroadcastControl } from \"./broadcastControls.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControlsTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { RecordEntryTypes } from \"./internalUtils.js\";\nimport { getOrCreateRecord, objectEntries } from \"./internalUtils.js\";\nimport type { AttendeeId, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport type {\n\tClientRecord,\n\tLocalStateUpdateOptions,\n\tStateDatastore,\n} from \"./stateDatastore.js\";\nimport { handleFromDatastore } from \"./stateDatastore.js\";\nimport type { PostUpdateAction } from \"./statesManagerTypes.js\";\nimport type { AnyWorkspace, StatesWorkspace, StatesWorkspaceSchema } from \"./types.js\";\nimport type {\n\tValidatableOptionalState,\n\tValidatableRequiredState,\n\tValidatableValueDirectory,\n\tValidatableValueDirectoryOrState,\n\tValidatableValueStructure,\n} from \"./validatableTypes.js\";\nimport { unbrandIVM } from \"./valueManager.js\";\n\n/**\n * Extracts `Part` from {@link InternalTypes.ManagerFactory} return type\n * matching the {@link StatesWorkspaceSchema} `Keys` given.\n *\n * @remarks\n * If the `Part` is an optional property, undefined will be included in the\n * result. Applying `Required` to the return type prior to extracting `Part`\n * does not work as expected. Exclude\\<, undefined\\> can be used as needed.\n */\nexport type MapSchemaElement<\n\tTSchema extends StatesWorkspaceSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n\tKeys extends keyof TSchema = keyof TSchema,\n> = ReturnType<TSchema[Keys]>[Part];\n\n/**\n * Miscellaneous options for local state updates\n */\nexport interface RuntimeLocalUpdateOptions {\n\t/**\n\t * The maximum time in milliseconds that this update is allowed to be\n\t * delayed before it must be sent to the service.\n\t */\n\tallowableUpdateLatencyMs: number;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * Contract for `PresenceDatastoreManager` as required by States Workspaces ({@link PresenceStatesImpl}).\n */\nexport interface PresenceRuntime {\n\treadonly presence: Presence;\n\treadonly attendeeId: AttendeeId;\n\tlocalUpdate(\n\t\tstates: { [key: string]: ClientUpdateEntry },\n\t\toptions: RuntimeLocalUpdateOptions,\n\t): void;\n}\n\ntype PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema extends StatesWorkspaceSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n> = {\n\t[Key in keyof TSchema]: MapSchemaElement<TSchema, Part, Key>;\n};\n\ntype MapEntries<TSchema extends StatesWorkspaceSchema> = PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema,\n\t\"manager\"\n>;\n\n/**\n * ValueElementMap is a map of key to a map of clientId to ValueState.\n * It is not restricted to the schema of the map as it may receive updates from other clients\n * with managers that have not been registered locally. Each map node is responsible for keeping\n * all session's state to be able to pick arbitrary client to rebroadcast to others.\n *\n * This generic aspect makes some typing difficult. The loose typing is not broadcast to the\n * consumers that are expected to maintain their schema over multiple versions of clients.\n */\nexport interface ValueElementMap<_TSchema extends StatesWorkspaceSchema> {\n\t[key: string]: ClientRecord<ValidatableValueDirectoryOrState<unknown>>;\n}\n\n// An attempt to make the type more precise, but it is not working.\n// If the casting in support code is too much we could keep two references to the same\n// complete datastore, but with the respective types desired.\n// type ValueElementMap<TSchema extends PresenceStatesNodeSchema> =\n// \t| {\n// \t\t\t[Key in keyof TSchema & string]?: {\n// \t\t\t\t[AttendeeId: AttendeeId]: InternalTypes.ValueDirectoryOrState<MapSchemaElement<TSchema,\"value\",Key>>;\n// \t\t\t};\n// \t }\n// \t| {\n// \t\t\t[key: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<unknown>>;\n// \t };\n// interface ValueElementMap<TValue> {\n// \t[Id: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// Version with local packed in is convenient for map, but not for join broadcast to serialize simply.\n// \t// [Id: string]: {\n// \t// \tlocal: InternalTypes.ValueDirectoryOrState<TValue>;\n// \t// \tall: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// };\n// }\n\n/**\n * Data content of a datastore entry in update messages\n */\nexport type ClientUpdateEntry = InternalTypes.ValueDirectoryOrState<unknown> & {\n\tignoreUnmonitored?: true;\n};\n\ninterface ClientUpdateRecord {\n\t[AttendeeId: AttendeeId]: ClientUpdateEntry;\n}\n\ninterface ValueUpdateRecord {\n\t[valueKey: string]: ClientUpdateRecord;\n}\n\n/**\n * Contract for Workspaces as required by `PresenceDatastoreManager`\n */\nexport interface PresenceStatesInternal {\n\tensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\tcontent: TSchemaAdditional,\n\t\tcontrols: BroadcastControlSettings | undefined,\n\t): AnyWorkspace<TSchemaAdditional>;\n\tprocessUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t\tsenderConnectionId: ClientConnectionId,\n\t): PostUpdateAction[];\n}\n\nfunction isValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tvalue: InternalTypes.ValueDirectory<T> | TValueState,\n): value is InternalTypes.ValueDirectory<T> {\n\treturn \"items\" in value;\n}\n\n// function overloads\n// Non-validatable types\nexport function mergeValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tbase: TValueState | InternalTypes.ValueDirectory<T> | undefined,\n\tupdate: TValueState | InternalTypes.ValueDirectory<T>,\n\ttimeDelta: number,\n): TValueState | InternalTypes.ValueDirectory<T>;\n// Validatable base type with non-validatable update types\nexport function mergeValueDirectory<\n\tT,\n\tTBaseState extends ValidatableRequiredState<T> | ValidatableOptionalState<T>,\n\tTUpdateState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tbase: TBaseState | ValidatableValueDirectory<T> | undefined,\n\tupdate: TUpdateState | InternalTypes.ValueDirectory<T>,\n\ttimeDelta: number,\n): TBaseState | ValidatableValueDirectory<T>;\n// Fully validatable types\nexport function mergeValueDirectory<\n\tT,\n\tTValueState extends ValidatableRequiredState<T> | ValidatableOptionalState<T>,\n>(\n\tbase: TValueState | ValidatableValueDirectory<T> | undefined,\n\tupdate: TValueState | ValidatableValueDirectory<T>,\n\ttimeDelta: number,\n): TValueState | ValidatableValueDirectory<T>;\n/**\n * Merge a value directory.\n *\n * @privateRemarks\n * This implementation uses the InternalTypes set of Value types but it is\n * agnostic so long as the validatable versions don't start requiring\n * properties.\n */\nexport function mergeValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tbase: TValueState | InternalTypes.ValueDirectory<T> | undefined,\n\tupdate: TValueState | InternalTypes.ValueDirectory<T>,\n\ttimeDelta: number,\n): TValueState | InternalTypes.ValueDirectory<T> {\n\tif (!isValueDirectory(update)) {\n\t\tif (base === undefined || update.rev > base.rev) {\n\t\t\treturn { ...update, timestamp: update.timestamp + timeDelta };\n\t\t}\n\t\treturn base;\n\t}\n\n\tlet mergeBase: InternalTypes.ValueDirectory<T>;\n\tif (base === undefined) {\n\t\tmergeBase = { rev: update.rev, items: {} };\n\t} else {\n\t\tconst baseIsDirectory = isValueDirectory(base);\n\t\tif (base.rev >= update.rev) {\n\t\t\tif (!baseIsDirectory) {\n\t\t\t\t// base is leaf value that is more recent - nothing to do\n\t\t\t\treturn base;\n\t\t\t}\n\t\t\t// While base has more advanced revision, assume mis-ordering or\n\t\t\t// missed and catchup update needs merged in.\n\t\t\tmergeBase = base;\n\t\t} else {\n\t\t\tmergeBase = { rev: update.rev, items: baseIsDirectory ? base.items : {} };\n\t\t}\n\t}\n\tfor (const [key, value] of Object.entries(update.items)) {\n\t\tconst baseElement = mergeBase.items[key];\n\t\tmergeBase.items[key] = mergeValueDirectory(baseElement, value, timeDelta);\n\t}\n\treturn mergeBase;\n}\n\n/**\n * Updates remote state into the local [untracked] datastore.\n *\n * @param key - The key of the datastore to merge the untracked data into.\n * @param remoteAllKnownState - The remote state to merge into the datastore.\n * @param datastore - The datastore to merge the untracked data into.\n *\n * @remarks\n * In the case of ignored unmonitored data, the client entries are not stored,\n * though the value keys will be populated and often remain empty.\n */\nexport function mergeUntrackedDatastore(\n\tkey: string,\n\tremoteAllKnownState: ClientUpdateRecord,\n\tdatastore: ValueElementMap<StatesWorkspaceSchema>,\n\ttimeModifier: number,\n): void {\n\tconst localAllKnownState = getOrCreateRecord(\n\t\tdatastore,\n\t\tkey,\n\t\t(): RecordEntryTypes<typeof datastore> => ({}),\n\t);\n\tfor (const [attendeeId, value] of objectEntries(remoteAllKnownState)) {\n\t\tif (!(\"ignoreUnmonitored\" in value)) {\n\t\t\tlocalAllKnownState[attendeeId] = mergeValueDirectory(\n\t\t\t\tlocalAllKnownState[attendeeId],\n\t\t\t\tvalue,\n\t\t\t\ttimeModifier,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * The default allowable update latency for StatesWorkspace in milliseconds.\n */\nconst defaultAllowableUpdateLatencyMs = 60;\n\n/**\n * Produces the value type of a schema element or set of elements.\n */\ntype SchemaElementValueType<\n\tTSchema extends StatesWorkspaceSchema,\n\tKeys extends keyof TSchema,\n> = Exclude<MapSchemaElement<TSchema, \"initialData\", Keys>, undefined>[\"value\"];\n\n/**\n * No-runtime-effect helper to protect cast from unknown datastore to specific\n * schema record type. (It is up to consumer to check that record conforms to\n * expectations.)\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction castUnknownRecordToSchemaRecord<\n\tTSchema extends StatesWorkspaceSchema,\n\tKey extends keyof TSchema & string,\n>(record: ClientRecord<ValidatableValueDirectoryOrState<unknown>>) {\n\treturn record as ClientRecord<\n\t\tValidatableValueStructure<SchemaElementValueType<TSchema, Key>>\n\t>;\n}\n\nclass PresenceStatesImpl<TSchema extends StatesWorkspaceSchema>\n\timplements\n\t\tPresenceStatesInternal,\n\t\tAnyWorkspace<TSchema>,\n\t\tStateDatastore<\n\t\t\tkeyof TSchema & string,\n\t\t\tSchemaElementValueType<TSchema, keyof TSchema & string>\n\t\t>\n{\n\tprivate readonly nodes: MapEntries<TSchema>;\n\tpublic readonly states: StatesWorkspace<TSchema>[\"states\"];\n\tpublic readonly notifications: AnyWorkspace<TSchema>[\"notifications\"];\n\n\tpublic readonly controls: RequiredBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly runtime: PresenceRuntime,\n\t\tprivate readonly datastore: ValueElementMap<TSchema>,\n\t\tinitialContent: TSchema,\n\t\tcontrolsSettings: BroadcastControlSettings | undefined,\n\t) {\n\t\tthis.controls = new RequiredBroadcastControl(defaultAllowableUpdateLatencyMs);\n\t\tif (controlsSettings?.allowableUpdateLatencyMs !== undefined) {\n\t\t\tthis.controls.allowableUpdateLatencyMs = controlsSettings.allowableUpdateLatencyMs;\n\t\t}\n\n\t\t// Prepare initial map content from initial state\n\t\t{\n\t\t\tconst attendeeId = this.runtime.attendeeId;\n\t\t\t// Empty record does not satisfy the type, but nodes will post loop.\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tconst nodes = {} as MapEntries<TSchema>;\n\t\t\tlet anyInitialValues = false;\n\t\t\tconst newValues: { [key: string]: InternalTypes.ValueDirectoryOrState<unknown> } = {};\n\t\t\tlet cumulativeAllowableUpdateLatencyMs: number | undefined;\n\t\t\tfor (const [key, nodeFactory] of Object.entries(initialContent)) {\n\t\t\t\tconst newNodeData = nodeFactory(key, handleFromDatastore(this));\n\t\t\t\tnodes[key as keyof TSchema] = newNodeData.manager;\n\t\t\t\tif (\"initialData\" in newNodeData) {\n\t\t\t\t\tconst { value, allowableUpdateLatencyMs } = newNodeData.initialData;\n\t\t\t\t\t(datastore[key] ??= {})[attendeeId] = value;\n\t\t\t\t\tnewValues[key] = value;\n\t\t\t\t\tif (allowableUpdateLatencyMs !== undefined) {\n\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs =\n\t\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs === undefined\n\t\t\t\t\t\t\t\t? allowableUpdateLatencyMs\n\t\t\t\t\t\t\t\t: Math.min(cumulativeAllowableUpdateLatencyMs, allowableUpdateLatencyMs);\n\t\t\t\t\t}\n\t\t\t\t\tanyInitialValues = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.nodes = nodes;\n\t\t\t// states and notifications are the public view of nodes that limits the entries\n\t\t\t// types to the public interface of State objects with an additional type\n\t\t\t// filter that beguiles the type system. So just reinterpret cast.\n\t\t\tconst properties = nodes as unknown as AnyWorkspace<TSchema>[\"states\"];\n\t\t\t// `AnyWorkspace` support comes from defining both `states` for\n\t\t\t// `StatesWorkspace` and `notifications` for `NotificationsWorkspace`.\n\t\t\t// `notifications` is always a subset of what `states` can be; so the same.\n\t\t\tthis.notifications = this.states = properties;\n\n\t\t\tif (anyInitialValues) {\n\t\t\t\tthis.runtime.localUpdate(newValues, {\n\t\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get presence(): Presence {\n\t\treturn this.runtime.presence;\n\t}\n\n\tpublic knownValues<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t): {\n\t\tself: AttendeeId | undefined;\n\t\tstates: ClientRecord<ValidatableValueStructure<SchemaElementValueType<TSchema, Key>>>;\n\t} {\n\t\treturn {\n\t\t\tself: this.runtime.attendeeId,\n\t\t\t// Caller must only use `key`s that are part of `this.datastore`.\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tstates: castUnknownRecordToSchemaRecord(this.datastore[key]!),\n\t\t};\n\t}\n\n\tpublic localUpdate<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tvalue: SchemaElementValueType<TSchema, Key> & ClientUpdateEntry,\n\t\toptions: LocalStateUpdateOptions,\n\t): void {\n\t\tthis.runtime.localUpdate(\n\t\t\t{ [key]: value },\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\toptions.allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic update<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tclientId: AttendeeId,\n\t\tvalue: ValidatableValueDirectoryOrState<unknown>,\n\t): void {\n\t\t// Callers my only use `key`s that are part of `this.datastore`.\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst allKnownState = this.datastore[key]!;\n\t\tallKnownState[clientId] = mergeValueDirectory<unknown, ValidatableRequiredState<unknown>>(\n\t\t\tallKnownState[clientId],\n\t\t\tvalue,\n\t\t\t0,\n\t\t);\n\t}\n\n\tpublic add<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\t\tTValueManager,\n\t>(\n\t\tkey: TKey,\n\t\tnodeFactory: InternalTypes.ManagerFactory<TKey, TValue, TValueManager>,\n\t): asserts this is StatesWorkspace<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TValueManager>>\n\t> {\n\t\tassert(!(key in this.nodes), 0xa3c /* Already have entry for key in map */);\n\t\tconst nodeData = nodeFactory(key, handleFromDatastore(this));\n\t\tthis.nodes[key] = nodeData.manager;\n\t\tif (\"initialData\" in nodeData) {\n\t\t\tconst { value, allowableUpdateLatencyMs } = nodeData.initialData;\n\t\t\tlet datastoreValue = this.datastore[key];\n\t\t\tif (datastoreValue === undefined) {\n\t\t\t\tdatastoreValue = this.datastore[key] = {};\n\t\t\t} else {\n\t\t\t\t// Already have received state from other clients. Kept in `all`.\n\t\t\t\t// TODO: Send current `all` state to state manager.\n\t\t\t}\n\t\t\tdatastoreValue[this.runtime.attendeeId] = value;\n\t\t\tthis.runtime.localUpdate(\n\t\t\t\t{ [key]: value },\n\t\t\t\t{\n\t\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\t\tallowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends StatesWorkspaceSchema>(\n\t\tcontent: TSchemaAdditional,\n\t\tcontrols: BroadcastControlSettings | undefined,\n\t): AnyWorkspace<TSchema & TSchemaAdditional> {\n\t\tif (controls?.allowableUpdateLatencyMs !== undefined) {\n\t\t\tthis.controls.allowableUpdateLatencyMs = controls.allowableUpdateLatencyMs;\n\t\t}\n\t\tfor (const [key, nodeFactory] of Object.entries(content)) {\n\t\t\tconst brandedIVM = this.nodes[key];\n\t\t\tif (brandedIVM === undefined) {\n\t\t\t\tthis.add(key, nodeFactory);\n\t\t\t} else {\n\t\t\t\tconst node = unbrandIVM(brandedIVM);\n\t\t\t\tif (!(node instanceof nodeFactory.instanceBase)) {\n\t\t\t\t\tthrow new TypeError(`State \"${key}\" previously created by different State object.`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this as AnyWorkspace<TSchema & TSchemaAdditional>;\n\t}\n\n\tpublic processUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t): PostUpdateAction[] {\n\t\tconst postUpdateActions: PostUpdateAction[] = [];\n\t\tfor (const [key, remoteAllKnownState] of Object.entries(remoteDatastore)) {\n\t\t\tconst brandedIVM = this.nodes[key];\n\t\t\tif (brandedIVM === undefined) {\n\t\t\t\t// Assume all broadcast state is meant to be kept even if not currently registered.\n\t\t\t\tmergeUntrackedDatastore(key, remoteAllKnownState, this.datastore, timeModifier);\n\t\t\t} else {\n\t\t\t\tconst node = unbrandIVM(brandedIVM);\n\t\t\t\tfor (const [attendeeId, value] of objectEntries(remoteAllKnownState)) {\n\t\t\t\t\tconst client = this.runtime.presence.attendees.getAttendee(attendeeId);\n\t\t\t\t\tpostUpdateActions.push(...node.update(client, received, value));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn postUpdateActions;\n\t}\n}\n\n/**\n * Create a new Workspace using the DataStoreRuntime provided.\n * @param initialContent - The initial State objects to register.\n */\nexport function createPresenceStates<TSchema extends StatesWorkspaceSchema>(\n\truntime: PresenceRuntime,\n\tdatastore: ValueElementMap<StatesWorkspaceSchema>,\n\tinitialContent: TSchema,\n\tcontrols: BroadcastControlSettings | undefined,\n): { public: AnyWorkspace<TSchema>; internal: PresenceStatesInternal } {\n\tconst impl = new PresenceStatesImpl<TSchema>(runtime, datastore, initialContent, controls);\n\n\treturn {\n\t\tpublic: impl,\n\t\tinternal: impl,\n\t};\n}\n"]}
|
package/dist/protocol.d.ts
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { OutboundExtensionMessage, VerifiedInboundExtensionMessage } from "@fluidframework/container-runtime-definitions/internal";
|
|
6
|
-
import type { ClientConnectionId } from "./baseTypes.js";
|
|
7
|
-
import type { AttendeeId } from "./presence.js";
|
|
8
|
-
import type { ClientUpdateEntry } from "./presenceStates.js";
|
|
9
|
-
import type { SystemWorkspaceDatastore } from "./systemWorkspace.js";
|
|
10
|
-
import type { WorkspaceAddress } from "./types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Datastore that contains system workspace data
|
|
13
|
-
*/
|
|
14
|
-
export interface SystemDatastore {
|
|
15
|
-
"system:presence": SystemWorkspaceDatastore;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Expected address format for general workspaces in the presence protocol.
|
|
19
|
-
*/
|
|
20
|
-
export type InternalWorkspaceAddress = `${"s" | "n"}:${WorkspaceAddress}`;
|
|
21
|
-
/**
|
|
22
|
-
* General datastore (and message) structure.
|
|
23
|
-
*/
|
|
24
|
-
export interface GeneralDatastoreMessageContent {
|
|
25
|
-
[WorkspaceAddress: InternalWorkspaceAddress]: {
|
|
26
|
-
[StateValueManagerKey: string]: {
|
|
27
|
-
[AttendeeId: AttendeeId]: ClientUpdateEntry;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Combined datastore structure for messages.
|
|
33
|
-
*/
|
|
34
|
-
export type DatastoreMessageContent = SystemDatastore & GeneralDatastoreMessageContent;
|
|
35
|
-
type AcknowledgmentId = string;
|
|
36
|
-
/**
|
|
37
|
-
* Datastore update message type.
|
|
38
|
-
*/
|
|
39
|
-
export declare const datastoreUpdateMessageType = "Pres:DatastoreUpdate";
|
|
40
|
-
interface DatastoreUpdateMessage {
|
|
41
|
-
type: typeof datastoreUpdateMessageType;
|
|
42
|
-
content: {
|
|
43
|
-
sendTimestamp: number;
|
|
44
|
-
avgLatency: number;
|
|
45
|
-
acknowledgementId?: AcknowledgmentId;
|
|
46
|
-
/**
|
|
47
|
-
* When present (always true), this message contains complete data
|
|
48
|
-
* for all attendees in the system.
|
|
49
|
-
*/
|
|
50
|
-
isComplete?: true;
|
|
51
|
-
/**
|
|
52
|
-
* List of client connection ids for which this message will satisfy
|
|
53
|
-
* their join catch up responses.
|
|
54
|
-
*/
|
|
55
|
-
joinResponseFor?: ClientConnectionId[];
|
|
56
|
-
data: DatastoreMessageContent;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Outbound datastore update message
|
|
61
|
-
*/
|
|
62
|
-
export type OutboundDatastoreUpdateMessage = OutboundExtensionMessage<DatastoreUpdateMessage>;
|
|
63
|
-
/**
|
|
64
|
-
* Inbound and verified datastore update message
|
|
65
|
-
*/
|
|
66
|
-
export type InboundDatastoreUpdateMessage = VerifiedInboundExtensionMessage<DatastoreUpdateMessage>;
|
|
67
|
-
/**
|
|
68
|
-
* Client join message type.
|
|
69
|
-
*/
|
|
70
|
-
export declare const joinMessageType = "Pres:ClientJoin";
|
|
71
|
-
interface ClientJoinMessage {
|
|
72
|
-
type: typeof joinMessageType;
|
|
73
|
-
content: {
|
|
74
|
-
updateProviders: ClientConnectionId[];
|
|
75
|
-
sendTimestamp: number;
|
|
76
|
-
avgLatency: number;
|
|
77
|
-
data: DatastoreMessageContent;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Acknowledgement message type.
|
|
82
|
-
*/
|
|
83
|
-
export declare const acknowledgementMessageType = "Pres:Ack";
|
|
84
|
-
interface AcknowledgementMessage {
|
|
85
|
-
type: typeof acknowledgementMessageType;
|
|
86
|
-
content: {
|
|
87
|
-
id: AcknowledgmentId;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Outbound acknowledgement message.
|
|
92
|
-
*/
|
|
93
|
-
export type OutboundAcknowledgementMessage = OutboundExtensionMessage<AcknowledgementMessage>;
|
|
94
|
-
/**
|
|
95
|
-
* Outbound client join message
|
|
96
|
-
*/
|
|
97
|
-
export type OutboundClientJoinMessage = OutboundExtensionMessage<ClientJoinMessage>;
|
|
98
|
-
/**
|
|
99
|
-
* Inbound and verified client join message
|
|
100
|
-
*/
|
|
101
|
-
export type InboundClientJoinMessage = VerifiedInboundExtensionMessage<ClientJoinMessage>;
|
|
102
|
-
/**
|
|
103
|
-
* Outbound presence message.
|
|
104
|
-
*/
|
|
105
|
-
export type OutboundPresenceMessage = OutboundAcknowledgementMessage | OutboundClientJoinMessage | OutboundDatastoreUpdateMessage;
|
|
106
|
-
/**
|
|
107
|
-
* Messages structures that can be sent and received as understood in the presence protocol
|
|
108
|
-
*/
|
|
109
|
-
export type SignalMessages = AcknowledgementMessage | ClientJoinMessage | DatastoreUpdateMessage;
|
|
110
|
-
export {};
|
|
111
|
-
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,wBAAwB,EACxB,+BAA+B,EAC/B,MAAM,wDAAwD,CAAC;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,iBAAiB,EAAE,wBAAwB,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C,CAAC,gBAAgB,EAAE,wBAAwB,GAAG;QAC7C,CAAC,oBAAoB,EAAE,MAAM,GAAG;YAC/B,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAAC;SAC5C,CAAC;KACF,CAAC;CACF;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,eAAe,GAAG,8BAA8B,CAAC;AAEvF,KAAK,gBAAgB,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AACjE,UAAU,sBAAsB;IAC/B,IAAI,EAAE,OAAO,0BAA0B,CAAC;IACxC,OAAO,EAAE;QACR,aA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,sBAAsB,GACtB,iBAAiB,GACjB,sBAAsB,CAAC"}
|
package/dist/protocol.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.acknowledgementMessageType = exports.joinMessageType = exports.datastoreUpdateMessageType = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Datastore update message type.
|
|
10
|
-
*/
|
|
11
|
-
exports.datastoreUpdateMessageType = "Pres:DatastoreUpdate";
|
|
12
|
-
/**
|
|
13
|
-
* Client join message type.
|
|
14
|
-
*/
|
|
15
|
-
exports.joinMessageType = "Pres:ClientJoin";
|
|
16
|
-
/**
|
|
17
|
-
* Acknowledgement message type.
|
|
18
|
-
*/
|
|
19
|
-
exports.acknowledgementMessageType = "Pres:Ack";
|
|
20
|
-
//# sourceMappingURL=protocol.js.map
|
package/dist/protocol.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2CH;;GAEG;AACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC;AAgCjE;;GAEG;AACU,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAWjD;;GAEG;AACU,QAAA,0BAA0B,GAAG,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tOutboundExtensionMessage,\n\tVerifiedInboundExtensionMessage,\n} from \"@fluidframework/container-runtime-definitions/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { AttendeeId } from \"./presence.js\";\nimport type { ClientUpdateEntry } from \"./presenceStates.js\";\nimport type { SystemWorkspaceDatastore } from \"./systemWorkspace.js\";\nimport type { WorkspaceAddress } from \"./types.js\";\n\n/**\n * Datastore that contains system workspace data\n */\nexport interface SystemDatastore {\n\t\"system:presence\": SystemWorkspaceDatastore;\n}\n\n/**\n * Expected address format for general workspaces in the presence protocol.\n */\nexport type InternalWorkspaceAddress = `${\"s\" | \"n\"}:${WorkspaceAddress}`;\n\n/**\n * General datastore (and message) structure.\n */\nexport interface GeneralDatastoreMessageContent {\n\t[WorkspaceAddress: InternalWorkspaceAddress]: {\n\t\t[StateValueManagerKey: string]: {\n\t\t\t[AttendeeId: AttendeeId]: ClientUpdateEntry;\n\t\t};\n\t};\n}\n\n/**\n * Combined datastore structure for messages.\n */\nexport type DatastoreMessageContent = SystemDatastore & GeneralDatastoreMessageContent;\n\ntype AcknowledgmentId = string;\n\n/**\n * Datastore update message type.\n */\nexport const datastoreUpdateMessageType = \"Pres:DatastoreUpdate\";\ninterface DatastoreUpdateMessage {\n\ttype: typeof datastoreUpdateMessageType;\n\tcontent: {\n\t\tsendTimestamp: number;\n\t\tavgLatency: number;\n\t\tacknowledgementId?: AcknowledgmentId;\n\t\t/**\n\t\t * When present (always true), this message contains complete data\n\t\t * for all attendees in the system.\n\t\t */\n\t\tisComplete?: true;\n\t\t/**\n\t\t * List of client connection ids for which this message will satisfy\n\t\t * their join catch up responses.\n\t\t */\n\t\tjoinResponseFor?: ClientConnectionId[];\n\t\tdata: DatastoreMessageContent;\n\t};\n}\n\n/**\n * Outbound datastore update message\n */\nexport type OutboundDatastoreUpdateMessage = OutboundExtensionMessage<DatastoreUpdateMessage>;\n\n/**\n * Inbound and verified datastore update message\n */\nexport type InboundDatastoreUpdateMessage =\n\tVerifiedInboundExtensionMessage<DatastoreUpdateMessage>;\n\n/**\n * Client join message type.\n */\nexport const joinMessageType = \"Pres:ClientJoin\";\ninterface ClientJoinMessage {\n\ttype: typeof joinMessageType;\n\tcontent: {\n\t\tupdateProviders: ClientConnectionId[];\n\t\tsendTimestamp: number;\n\t\tavgLatency: number;\n\t\tdata: DatastoreMessageContent;\n\t};\n}\n\n/**\n * Acknowledgement message type.\n */\nexport const acknowledgementMessageType = \"Pres:Ack\";\n\ninterface AcknowledgementMessage {\n\ttype: typeof acknowledgementMessageType;\n\tcontent: {\n\t\tid: AcknowledgmentId;\n\t};\n}\n\n/**\n * Outbound acknowledgement message.\n */\nexport type OutboundAcknowledgementMessage = OutboundExtensionMessage<AcknowledgementMessage>;\n\n/**\n * Outbound client join message\n */\nexport type OutboundClientJoinMessage = OutboundExtensionMessage<ClientJoinMessage>;\n\n/**\n * Inbound and verified client join message\n */\nexport type InboundClientJoinMessage = VerifiedInboundExtensionMessage<ClientJoinMessage>;\n\n/**\n * Outbound presence message.\n */\nexport type OutboundPresenceMessage =\n\t| OutboundAcknowledgementMessage\n\t| OutboundClientJoinMessage\n\t| OutboundDatastoreUpdateMessage;\n\n/**\n * Messages structures that can be sent and received as understood in the presence protocol\n */\nexport type SignalMessages =\n\t| AcknowledgementMessage\n\t| ClientJoinMessage\n\t| DatastoreUpdateMessage;\n"]}
|
package/dist/runtimeTypes.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { ExtensionHost as ContainerExtensionHost } from "@fluidframework/container-runtime-definitions/internal";
|
|
6
|
-
import type { OutboundPresenceMessage, SignalMessages } from "./protocol.js";
|
|
7
|
-
/**
|
|
8
|
-
* Presence {@link ContainerExtension} version of {@link @fluidframework/container-runtime-definitions#ExtensionRuntimeProperties}
|
|
9
|
-
*/
|
|
10
|
-
export interface ExtensionRuntimeProperties {
|
|
11
|
-
SignalMessages: SignalMessages;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Presence specific ExtensionHost
|
|
15
|
-
*/
|
|
16
|
-
export type ExtensionHost = ContainerExtensionHost<ExtensionRuntimeProperties>;
|
|
17
|
-
/**
|
|
18
|
-
* This interface is a subset of ExtensionHost that is needed by the Presence States.
|
|
19
|
-
*/
|
|
20
|
-
export type IEphemeralRuntime = Omit<ExtensionHost, "submitAddressedSignal"> & {
|
|
21
|
-
/**
|
|
22
|
-
* Submits the signal to be sent to other clients.
|
|
23
|
-
*/
|
|
24
|
-
submitSignal: (message: OutboundPresenceMessage) => void;
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=runtimeTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeTypes.d.ts","sourceRoot":"","sources":["../src/runtimeTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,IAAI,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAEtH,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,cAAc,EAAE,cAAc,CAAC;CAC/B;AACD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,uBAAuB,CAAC,GAAG;IAC9E;;OAEG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;CACzD,CAAC"}
|
package/dist/runtimeTypes.js
DELETED
package/dist/runtimeTypes.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeTypes.js","sourceRoot":"","sources":["../src/runtimeTypes.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 { ExtensionHost as ContainerExtensionHost } from \"@fluidframework/container-runtime-definitions/internal\";\n\nimport type { OutboundPresenceMessage, SignalMessages } from \"./protocol.js\";\n\n/**\n * Presence {@link ContainerExtension} version of {@link @fluidframework/container-runtime-definitions#ExtensionRuntimeProperties}\n */\nexport interface ExtensionRuntimeProperties {\n\tSignalMessages: SignalMessages;\n}\n/**\n * Presence specific ExtensionHost\n */\nexport type ExtensionHost = ContainerExtensionHost<ExtensionRuntimeProperties>;\n\n/**\n * This interface is a subset of ExtensionHost that is needed by the Presence States.\n */\nexport type IEphemeralRuntime = Omit<ExtensionHost, \"submitAddressedSignal\"> & {\n\t/**\n\t * Submits the signal to be sent to other clients.\n\t */\n\tsubmitSignal: (message: OutboundPresenceMessage) => void;\n};\n"]}
|
package/dist/stateDatastore.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { ClientConnectionId } from "./baseTypes.js";
|
|
6
|
-
import type { InternalTypes } from "./exposedInternalTypes.js";
|
|
7
|
-
import type { AttendeeId, PresenceWithNotifications as Presence } from "./presence.js";
|
|
8
|
-
import type { ValidatableValueDirectoryOrState, ValidatableValueStructure } from "./validatableTypes.js";
|
|
9
|
-
/**
|
|
10
|
-
* Basic structure of set of {@link Attendee} records within Presence datastore
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* This is commonly exists per named state in State Managers.
|
|
14
|
-
*/
|
|
15
|
-
export interface ClientRecord<TValue extends ValidatableValueDirectoryOrState<unknown>> {
|
|
16
|
-
[AttendeeId: AttendeeId]: TValue;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Miscellaneous options for local state updates
|
|
20
|
-
*/
|
|
21
|
-
export interface LocalStateUpdateOptions {
|
|
22
|
-
/**
|
|
23
|
-
* When defined, this is the maximum time in milliseconds that this
|
|
24
|
-
* update is allowed to be delayed before it must be sent to service.
|
|
25
|
-
* When `undefined`, the callee may determine maximum delay.
|
|
26
|
-
*/
|
|
27
|
-
allowableUpdateLatencyMs: number | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Special option allowed for unicast notifications.
|
|
30
|
-
*/
|
|
31
|
-
targetClientId?: ClientConnectionId;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Contract for States Workspace to support State Manager access to
|
|
35
|
-
* datastore and general internal presence knowledge.
|
|
36
|
-
*/
|
|
37
|
-
export interface StateDatastore<TKey extends string, TLocalUpdateValue extends InternalTypes.ValueDirectoryOrState<unknown>, TStoredValue extends ValidatableValueDirectoryOrState<unknown> = ValidatableValueStructure<TLocalUpdateValue>> {
|
|
38
|
-
readonly presence: Presence;
|
|
39
|
-
localUpdate(key: TKey, value: TLocalUpdateValue & {
|
|
40
|
-
ignoreUnmonitored?: true;
|
|
41
|
-
}, options: LocalStateUpdateOptions): void;
|
|
42
|
-
update(key: TKey, attendeeId: AttendeeId, value: TStoredValue): void;
|
|
43
|
-
knownValues(key: TKey): {
|
|
44
|
-
self: AttendeeId | undefined;
|
|
45
|
-
states: ClientRecord<TStoredValue>;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Helper to get a handle from a datastore.
|
|
50
|
-
*/
|
|
51
|
-
export declare function handleFromDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(datastore: StateDatastore<TKey, TValue>): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>>;
|
|
52
|
-
/**
|
|
53
|
-
* Helper to get the datastore back from its handle.
|
|
54
|
-
*/
|
|
55
|
-
export declare function datastoreFromHandle<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue>;
|
|
56
|
-
//# sourceMappingURL=stateDatastore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateDatastore.d.ts","sourceRoot":"","sources":["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AAY,CAAC,CAAC;KACnC,CAAC;CACF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAIlC,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAE3D,SAAS,EAAE,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,GACrC,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAKtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAC1D,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAExF"}
|
package/dist/stateDatastore.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.datastoreFromHandle = exports.handleFromDatastore = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Helper to get a handle from a datastore.
|
|
10
|
-
*/
|
|
11
|
-
function handleFromDatastore(datastore) {
|
|
12
|
-
return datastore;
|
|
13
|
-
}
|
|
14
|
-
exports.handleFromDatastore = handleFromDatastore;
|
|
15
|
-
/**
|
|
16
|
-
* Helper to get the datastore back from its handle.
|
|
17
|
-
*/
|
|
18
|
-
function datastoreFromHandle(handle) {
|
|
19
|
-
return handle;
|
|
20
|
-
}
|
|
21
|
-
exports.datastoreFromHandle = datastoreFromHandle;
|
|
22
|
-
//# sourceMappingURL=stateDatastore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateDatastore.js","sourceRoot":"","sources":["../src/stateDatastore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6EH;;GAEG;AACH,SAAgB,mBAAmB,CAOlC,SAAuC;IAEvC,OAAO,SAGN,CAAC;AACH,CAAC;AAbD,kDAaC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAGjC,MAAwD;IACzD,OAAO,MAAiD,CAAC;AAC1D,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { AttendeeId, PresenceWithNotifications as Presence } from \"./presence.js\";\nimport type {\n\tValidatableValueDirectoryOrState,\n\tValidatableValueStructure,\n} from \"./validatableTypes.js\";\n\n/**\n * Basic structure of set of {@link Attendee} records within Presence datastore\n *\n * @remarks\n * This is commonly exists per named state in State Managers.\n */\nexport interface ClientRecord<TValue extends ValidatableValueDirectoryOrState<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// type StateDatastoreSchemaNode<\n// \tTValue extends InternalTypes.ValueDirectoryOrState<any> = InternalTypes.ValueDirectoryOrState<unknown>,\n// > = TValue extends InternalTypes.ValueDirectoryOrState<infer T> ? InternalTypes.ValueDirectoryOrState<T> : never;\n\n// export interface StateDatastoreSchema {\n// \t// This type is not precise. It may\n// \t// need to be replaced with StatesWorkspace schema pattern\n// \t// similar to what is commented out.\n// \t[key: string]: InternalTypes.ValueDirectoryOrState<unknown>;\n// \t// [key: string]: StateDatastoreSchemaNode;\n// }\n\n/**\n * Miscellaneous options for local state updates\n */\nexport interface LocalStateUpdateOptions {\n\t/**\n\t * When defined, this is the maximum time in milliseconds that this\n\t * update is allowed to be delayed before it must be sent to service.\n\t * When `undefined`, the callee may determine maximum delay.\n\t */\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * Contract for States Workspace to support State Manager access to\n * datastore and general internal presence knowledge.\n */\nexport interface StateDatastore<\n\tTKey extends string,\n\tTLocalUpdateValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTStoredValue extends\n\t\tValidatableValueDirectoryOrState<unknown> = ValidatableValueStructure<TLocalUpdateValue>,\n> {\n\treadonly presence: Presence;\n\tlocalUpdate(\n\t\tkey: TKey,\n\t\tvalue: TLocalUpdateValue & {\n\t\t\tignoreUnmonitored?: true;\n\t\t},\n\t\toptions: LocalStateUpdateOptions,\n\t): void;\n\tupdate(key: TKey, attendeeId: AttendeeId, value: TStoredValue): void;\n\tknownValues(key: TKey): {\n\t\tself: AttendeeId | undefined;\n\t\tstates: ClientRecord<TStoredValue>;\n\t};\n}\n\n/**\n * Helper to get a handle from a datastore.\n */\nexport function handleFromDatastore<\n\t// Constraining TSchema would be great, but it seems nested types (at least with undefined) cause trouble.\n\t// TSchema as `unknown` still provides some type safety.\n\t// TSchema extends StateDatastoreSchema,\n\tTKey extends string /* & keyof TSchema */,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(\n\tdatastore: StateDatastore<TKey, TValue>,\n): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>> {\n\treturn datastore as unknown as InternalTypes.StateDatastoreHandle<\n\t\tTKey,\n\t\tExclude<TValue, undefined>\n\t>;\n}\n\n/**\n * Helper to get the datastore back from its handle.\n */\nexport function datastoreFromHandle<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue> {\n\treturn handle as unknown as StateDatastore<TKey, TValue>;\n}\n"]}
|
package/dist/stateFactory.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Factory for creating presence State objects.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Use `latest` to create a {@link LatestRaw} State object.
|
|
10
|
-
* Use `latestMap` to create a {@link LatestMapRaw} State object.
|
|
11
|
-
*
|
|
12
|
-
* @beta
|
|
13
|
-
*/
|
|
14
|
-
export declare const StateFactory: {
|
|
15
|
-
readonly latest: import("./latestTypes.js").LatestFactory;
|
|
16
|
-
readonly latestMap: import("./latestMapTypes.js").LatestMapFactory;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=stateFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateFactory.d.ts","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;CAGf,CAAC"}
|
package/dist/stateFactory.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.StateFactory = void 0;
|
|
8
|
-
const latestMapValueManager_js_1 = require("./latestMapValueManager.js");
|
|
9
|
-
const latestValueManager_js_1 = require("./latestValueManager.js");
|
|
10
|
-
/**
|
|
11
|
-
* Factory for creating presence State objects.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* Use `latest` to create a {@link LatestRaw} State object.
|
|
15
|
-
* Use `latestMap` to create a {@link LatestMapRaw} State object.
|
|
16
|
-
*
|
|
17
|
-
* @beta
|
|
18
|
-
*/
|
|
19
|
-
exports.StateFactory = {
|
|
20
|
-
latest: latestValueManager_js_1.latest,
|
|
21
|
-
latestMap: latestMapValueManager_js_1.latestMap,
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=stateFactory.js.map
|
package/dist/stateFactory.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateFactory.js","sourceRoot":"","sources":["../src/stateFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,yEAAuD;AAMvD,mEAAiD;AAEjD;;;;;;;;GAQG;AACU,QAAA,YAAY,GAAG;IAC3B,MAAM,EAAN,8BAAM;IACN,SAAS,EAAT,oCAAS;CACA,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// These \"unused\" imports are specified to workaround an api-extractor limitation.\n// @ts-expect-error -- Unused import is for type only\nimport type {\n\t// eslint-disable-next-line unused-imports/no-unused-imports\n\tLatestMap,\n} from \"./latestMapTypes.js\";\nimport { latestMap } from \"./latestMapValueManager.js\";\n// @ts-expect-error -- Unused import is for type only\nimport type {\n\t// eslint-disable-next-line unused-imports/no-unused-imports\n\tLatest,\n} from \"./latestTypes.js\";\nimport { latest } from \"./latestValueManager.js\";\n\n/**\n * Factory for creating presence State objects.\n *\n * @remarks\n * Use `latest` to create a {@link LatestRaw} State object.\n * Use `latestMap` to create a {@link LatestMapRaw} State object.\n *\n * @beta\n */\nexport const StateFactory = {\n\tlatest,\n\tlatestMap,\n} as const;\n"]}
|