@fluid-internal/presence-runtime 2.93.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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/package.json +4 -0
- package/dist/packageVersion.d.ts +9 -0
- package/dist/packageVersion.d.ts.map +1 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/runtime/extension/containerPresence.d.ts +53 -0
- package/dist/runtime/extension/containerPresence.d.ts.map +1 -0
- package/dist/runtime/extension/containerPresence.js +90 -0
- package/dist/runtime/extension/containerPresence.js.map +1 -0
- package/dist/runtime/extension/index.d.ts +6 -0
- package/dist/runtime/extension/index.d.ts.map +1 -0
- package/dist/runtime/extension/index.js +11 -0
- package/dist/runtime/extension/index.js.map +1 -0
- package/dist/runtime/presenceDatastoreManager.d.ts +146 -0
- package/dist/runtime/presenceDatastoreManager.d.ts.map +1 -0
- package/dist/runtime/presenceDatastoreManager.js +666 -0
- package/dist/runtime/presenceDatastoreManager.js.map +1 -0
- package/dist/runtime/presenceManager.d.ts +16 -0
- package/dist/runtime/presenceManager.d.ts.map +1 -0
- package/dist/runtime/presenceManager.js +140 -0
- package/dist/runtime/presenceManager.js.map +1 -0
- package/dist/runtime/protocol.d.ts +126 -0
- package/dist/runtime/protocol.d.ts.map +1 -0
- package/dist/runtime/protocol.js +20 -0
- package/dist/runtime/protocol.js.map +1 -0
- package/dist/runtime/runtimeTypes.d.ts +26 -0
- package/dist/runtime/runtimeTypes.d.ts.map +1 -0
- package/dist/runtime/runtimeTypes.js +7 -0
- package/dist/runtime/runtimeTypes.js.map +1 -0
- package/dist/runtime/systemWorkspace.d.ts +39 -0
- package/dist/runtime/systemWorkspace.d.ts.map +1 -0
- package/dist/runtime/systemWorkspace.js +264 -0
- package/dist/runtime/systemWorkspace.js.map +1 -0
- package/dist/runtime/test/presenceDatastoreManager.spec.js +618 -0
- package/dist/runtime/test/presenceDatastoreManager.spec.js.map +1 -0
- package/dist/runtime/test/presenceManager.spec.js +651 -0
- package/dist/runtime/test/presenceManager.spec.js.map +1 -0
- package/dist/runtime/test.d.ts +12 -0
- package/dist/runtime/test.d.ts.map +1 -0
- package/dist/runtime/test.js +15 -0
- package/dist/runtime/test.js.map +1 -0
- package/dist/states/index.d.ts +7 -0
- package/dist/states/index.d.ts.map +1 -0
- package/dist/states/index.js +12 -0
- package/dist/states/index.js.map +1 -0
- package/dist/states/latestMapValueManager.d.ts +10 -0
- package/dist/states/latestMapValueManager.d.ts.map +1 -0
- package/dist/states/latestMapValueManager.js +248 -0
- package/dist/states/latestMapValueManager.js.map +1 -0
- package/dist/states/latestValueManager.d.ts +10 -0
- package/dist/states/latestValueManager.d.ts.map +1 -0
- package/dist/states/latestValueManager.js +115 -0
- package/dist/states/latestValueManager.js.map +1 -0
- package/dist/states/notificationsManager.d.ts +26 -0
- package/dist/states/notificationsManager.d.ts.map +1 -0
- package/dist/states/notificationsManager.js +97 -0
- package/dist/states/notificationsManager.js.map +1 -0
- package/dist/states/presence.d.ts +11 -0
- package/dist/states/presence.d.ts.map +1 -0
- package/dist/states/presence.js +7 -0
- package/dist/states/presence.js.map +1 -0
- package/dist/states/stateFactory.d.ts +18 -0
- package/dist/states/stateFactory.d.ts.map +1 -0
- package/dist/states/stateFactory.js +23 -0
- package/dist/states/stateFactory.js.map +1 -0
- package/dist/states/test/batching.spec.js +843 -0
- package/dist/states/test/batching.spec.js.map +1 -0
- package/dist/states/test/broadcastControlsTests.js +60 -0
- package/dist/states/test/broadcastControlsTests.js.map +1 -0
- package/dist/states/test/eventing.spec.js +576 -0
- package/dist/states/test/eventing.spec.js.map +1 -0
- package/dist/states/test/latestMapValueManager.spec.js +210 -0
- package/dist/states/test/latestMapValueManager.spec.js.map +1 -0
- package/dist/states/test/latestValueManager.spec.js +193 -0
- package/dist/states/test/latestValueManager.spec.js.map +1 -0
- package/dist/states/test/mockEphemeralRuntime.js +11 -0
- package/dist/states/test/mockEphemeralRuntime.js.map +1 -0
- package/dist/states/test/notificationsManager.spec.js +460 -0
- package/dist/states/test/notificationsManager.spec.js.map +1 -0
- package/dist/states/test/presenceStates.spec.js +73 -0
- package/dist/states/test/presenceStates.spec.js.map +1 -0
- package/dist/states/test/schemaValidation/protocol.spec.js +246 -0
- package/dist/states/test/schemaValidation/protocol.spec.js.map +1 -0
- package/dist/states/test/schemaValidation/valueManagers.spec.js +784 -0
- package/dist/states/test/schemaValidation/valueManagers.spec.js.map +1 -0
- package/dist/states/test/testUtils.js +21 -0
- package/dist/states/test/testUtils.js.map +1 -0
- package/dist/states/validatedGetter.d.ts +18 -0
- package/dist/states/validatedGetter.d.ts.map +1 -0
- package/dist/states/validatedGetter.js +43 -0
- package/dist/states/validatedGetter.js.map +1 -0
- package/dist/test/mockEphemeralRuntime.js +175 -0
- package/dist/test/mockEphemeralRuntime.js.map +1 -0
- package/dist/test/testUtils.js +262 -0
- package/dist/test/testUtils.js.map +1 -0
- package/dist/test/utils/index.js +27 -0
- package/dist/test/utils/index.js.map +1 -0
- package/dist/utils/broadcastControls.d.ts +37 -0
- package/dist/utils/broadcastControls.d.ts.map +1 -0
- package/dist/utils/broadcastControls.js +60 -0
- package/dist/utils/broadcastControls.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +26 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/internalUtils.d.ts +125 -0
- package/dist/utils/internalUtils.d.ts.map +1 -0
- package/dist/utils/internalUtils.js +99 -0
- package/dist/utils/internalUtils.js.map +1 -0
- package/dist/utils/test/timerManager.spec.js +93 -0
- package/dist/utils/test/timerManager.spec.js.map +1 -0
- package/dist/utils/timerManager.d.ts +37 -0
- package/dist/utils/timerManager.d.ts.map +1 -0
- package/dist/utils/timerManager.js +65 -0
- package/dist/utils/timerManager.js.map +1 -0
- package/dist/utils/valueManager.d.ts +14 -0
- package/dist/utils/valueManager.d.ts.map +1 -0
- package/dist/utils/valueManager.js +22 -0
- package/dist/utils/valueManager.js.map +1 -0
- package/dist/workspace/index.d.ts +7 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +14 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/presenceStates.d.ts +61 -0
- package/dist/workspace/presenceStates.d.ts.map +1 -0
- package/dist/workspace/presenceStates.js +235 -0
- package/dist/workspace/presenceStates.js.map +1 -0
- package/dist/workspace/stateDatastore.d.ts +17 -0
- package/dist/workspace/stateDatastore.d.ts.map +1 -0
- package/dist/workspace/stateDatastore.js +24 -0
- package/dist/workspace/stateDatastore.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/lib/runtime/extension/containerPresence.d.ts +53 -0
- package/lib/runtime/extension/containerPresence.d.ts.map +1 -0
- package/lib/runtime/extension/containerPresence.js +87 -0
- package/lib/runtime/extension/containerPresence.js.map +1 -0
- package/lib/runtime/extension/index.d.ts +6 -0
- package/lib/runtime/extension/index.d.ts.map +1 -0
- package/lib/runtime/extension/index.js +6 -0
- package/lib/runtime/extension/index.js.map +1 -0
- package/lib/runtime/presenceDatastoreManager.d.ts +146 -0
- package/lib/runtime/presenceDatastoreManager.d.ts.map +1 -0
- package/lib/runtime/presenceDatastoreManager.js +662 -0
- package/lib/runtime/presenceDatastoreManager.js.map +1 -0
- package/lib/runtime/presenceManager.d.ts +16 -0
- package/lib/runtime/presenceManager.d.ts.map +1 -0
- package/lib/runtime/presenceManager.js +136 -0
- package/lib/runtime/presenceManager.js.map +1 -0
- package/lib/runtime/protocol.d.ts +126 -0
- package/lib/runtime/protocol.d.ts.map +1 -0
- package/lib/runtime/protocol.js +17 -0
- package/lib/runtime/protocol.js.map +1 -0
- package/lib/runtime/runtimeTypes.d.ts +26 -0
- package/lib/runtime/runtimeTypes.d.ts.map +1 -0
- package/lib/runtime/runtimeTypes.js +6 -0
- package/lib/runtime/runtimeTypes.js.map +1 -0
- package/lib/runtime/systemWorkspace.d.ts +39 -0
- package/lib/runtime/systemWorkspace.d.ts.map +1 -0
- package/lib/runtime/systemWorkspace.js +260 -0
- package/lib/runtime/systemWorkspace.js.map +1 -0
- package/lib/runtime/test/presenceDatastoreManager.spec.js +616 -0
- package/lib/runtime/test/presenceDatastoreManager.spec.js.map +1 -0
- package/lib/runtime/test/presenceManager.spec.js +649 -0
- package/lib/runtime/test/presenceManager.spec.js.map +1 -0
- package/lib/runtime/test.d.ts +12 -0
- package/lib/runtime/test.d.ts.map +1 -0
- package/lib/runtime/test.js +10 -0
- package/lib/runtime/test.js.map +1 -0
- package/lib/states/index.d.ts +7 -0
- package/lib/states/index.d.ts.map +1 -0
- package/lib/states/index.js +7 -0
- package/lib/states/index.js.map +1 -0
- package/lib/states/latestMapValueManager.d.ts +10 -0
- package/lib/states/latestMapValueManager.d.ts.map +1 -0
- package/lib/states/latestMapValueManager.js +244 -0
- package/lib/states/latestMapValueManager.js.map +1 -0
- package/lib/states/latestValueManager.d.ts +10 -0
- package/lib/states/latestValueManager.d.ts.map +1 -0
- package/lib/states/latestValueManager.js +111 -0
- package/lib/states/latestValueManager.js.map +1 -0
- package/lib/states/notificationsManager.d.ts +26 -0
- package/lib/states/notificationsManager.d.ts.map +1 -0
- package/lib/states/notificationsManager.js +93 -0
- package/lib/states/notificationsManager.js.map +1 -0
- package/lib/states/presence.d.ts +11 -0
- package/lib/states/presence.d.ts.map +1 -0
- package/lib/states/presence.js +6 -0
- package/lib/states/presence.js.map +1 -0
- package/lib/states/stateFactory.d.ts +18 -0
- package/lib/states/stateFactory.d.ts.map +1 -0
- package/lib/states/stateFactory.js +20 -0
- package/lib/states/stateFactory.js.map +1 -0
- package/lib/states/test/batching.spec.js +841 -0
- package/lib/states/test/batching.spec.js.map +1 -0
- package/lib/states/test/broadcastControlsTests.js +56 -0
- package/lib/states/test/broadcastControlsTests.js.map +1 -0
- package/lib/states/test/eventing.spec.js +574 -0
- package/lib/states/test/eventing.spec.js.map +1 -0
- package/lib/states/test/latestMapValueManager.spec.js +206 -0
- package/lib/states/test/latestMapValueManager.spec.js.map +1 -0
- package/lib/states/test/latestValueManager.spec.js +189 -0
- package/lib/states/test/latestValueManager.spec.js.map +1 -0
- package/lib/states/test/mockEphemeralRuntime.js +6 -0
- package/lib/states/test/mockEphemeralRuntime.js.map +1 -0
- package/lib/states/test/notificationsManager.spec.js +456 -0
- package/lib/states/test/notificationsManager.spec.js.map +1 -0
- package/lib/states/test/presenceStates.spec.js +69 -0
- package/lib/states/test/presenceStates.spec.js.map +1 -0
- package/lib/states/test/schemaValidation/protocol.spec.js +244 -0
- package/lib/states/test/schemaValidation/protocol.spec.js.map +1 -0
- package/lib/states/test/schemaValidation/valueManagers.spec.js +782 -0
- package/lib/states/test/schemaValidation/valueManagers.spec.js.map +1 -0
- package/lib/states/test/testUtils.js +6 -0
- package/lib/states/test/testUtils.js.map +1 -0
- package/lib/states/validatedGetter.d.ts +18 -0
- package/lib/states/validatedGetter.d.ts.map +1 -0
- package/lib/states/validatedGetter.js +39 -0
- package/lib/states/validatedGetter.js.map +1 -0
- package/lib/test/mockEphemeralRuntime.js +171 -0
- package/lib/test/mockEphemeralRuntime.js.map +1 -0
- package/lib/test/testUtils.js +251 -0
- package/lib/test/testUtils.js.map +1 -0
- package/lib/test/utils/index.js +8 -0
- package/lib/test/utils/index.js.map +1 -0
- package/lib/utils/broadcastControls.d.ts +37 -0
- package/lib/utils/broadcastControls.d.ts.map +1 -0
- package/lib/utils/broadcastControls.js +55 -0
- package/lib/utils/broadcastControls.js.map +1 -0
- package/lib/utils/index.d.ts +9 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/internalUtils.d.ts +125 -0
- package/lib/utils/internalUtils.d.ts.map +1 -0
- package/lib/utils/internalUtils.js +90 -0
- package/lib/utils/internalUtils.js.map +1 -0
- package/lib/utils/test/timerManager.spec.js +91 -0
- package/lib/utils/test/timerManager.spec.js.map +1 -0
- package/lib/utils/timerManager.d.ts +37 -0
- package/lib/utils/timerManager.d.ts.map +1 -0
- package/lib/utils/timerManager.js +61 -0
- package/lib/utils/timerManager.js.map +1 -0
- package/lib/utils/valueManager.d.ts +14 -0
- package/lib/utils/valueManager.d.ts.map +1 -0
- package/lib/utils/valueManager.js +17 -0
- package/lib/utils/valueManager.js.map +1 -0
- package/lib/workspace/index.d.ts +7 -0
- package/lib/workspace/index.d.ts.map +1 -0
- package/lib/workspace/index.js +7 -0
- package/lib/workspace/index.js.map +1 -0
- package/lib/workspace/presenceStates.d.ts +61 -0
- package/lib/workspace/presenceStates.d.ts.map +1 -0
- package/lib/workspace/presenceStates.js +229 -0
- package/lib/workspace/presenceStates.js.map +1 -0
- package/lib/workspace/stateDatastore.d.ts +17 -0
- package/lib/workspace/stateDatastore.d.ts.map +1 -0
- package/lib/workspace/stateDatastore.js +19 -0
- package/lib/workspace/stateDatastore.js.map +1 -0
- package/package.json +158 -0
|
@@ -0,0 +1,235 @@
|
|
|
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 utils_1 = require("@fluid-internal/presence-runtime/utils");
|
|
10
|
+
const stateDatastore_js_1 = require("./stateDatastore.js");
|
|
11
|
+
function isValueDirectory(value) {
|
|
12
|
+
return "items" in value;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Merge a value directory.
|
|
16
|
+
*
|
|
17
|
+
* @privateRemarks
|
|
18
|
+
* This implementation uses the InternalTypes set of Value types but it is
|
|
19
|
+
* agnostic so long as the validatable versions don't start requiring
|
|
20
|
+
* properties.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
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
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
function mergeUntrackedDatastore(key, remoteAllKnownState, datastore, timeModifier) {
|
|
71
|
+
const localAllKnownState = (0, utils_1.getOrCreateRecord)(datastore, key, () => ({}));
|
|
72
|
+
for (const [attendeeId, value] of (0, utils_1.objectEntries)(remoteAllKnownState)) {
|
|
73
|
+
if (!("ignoreUnmonitored" in value)) {
|
|
74
|
+
localAllKnownState[attendeeId] = mergeValueDirectory(localAllKnownState[attendeeId], value, timeModifier);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.mergeUntrackedDatastore = mergeUntrackedDatastore;
|
|
79
|
+
/**
|
|
80
|
+
* The default allowable update latency for StatesWorkspace in milliseconds.
|
|
81
|
+
*/
|
|
82
|
+
const defaultAllowableUpdateLatencyMs = 60;
|
|
83
|
+
/**
|
|
84
|
+
* No-runtime-effect helper to protect cast from unknown datastore to specific
|
|
85
|
+
* schema record type. (It is up to consumer to check that record conforms to
|
|
86
|
+
* expectations.)
|
|
87
|
+
*/
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
89
|
+
function castUnknownRecordToSchemaRecord(record) {
|
|
90
|
+
return record;
|
|
91
|
+
}
|
|
92
|
+
class PresenceStatesImpl {
|
|
93
|
+
constructor(runtime, datastore, initialContent, controlsSettings) {
|
|
94
|
+
this.runtime = runtime;
|
|
95
|
+
this.datastore = datastore;
|
|
96
|
+
this.controls = new utils_1.RequiredBroadcastControl(defaultAllowableUpdateLatencyMs);
|
|
97
|
+
if (controlsSettings?.allowableUpdateLatencyMs !== undefined) {
|
|
98
|
+
this.controls.allowableUpdateLatencyMs = controlsSettings.allowableUpdateLatencyMs;
|
|
99
|
+
}
|
|
100
|
+
// Prepare initial map content from initial state
|
|
101
|
+
{
|
|
102
|
+
const attendeeId = this.runtime.attendeeId;
|
|
103
|
+
// Empty record does not satisfy the type, but nodes will post loop.
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
105
|
+
const nodes = {};
|
|
106
|
+
let anyInitialValues = false;
|
|
107
|
+
const newValues = {};
|
|
108
|
+
let cumulativeAllowableUpdateLatencyMs;
|
|
109
|
+
for (const [key, nodeFactory] of Object.entries(initialContent)) {
|
|
110
|
+
const newNodeData = nodeFactory(key, (0, stateDatastore_js_1.handleFromDatastore)(this));
|
|
111
|
+
nodes[key] = newNodeData.manager;
|
|
112
|
+
if ("initialData" in newNodeData) {
|
|
113
|
+
const { value, allowableUpdateLatencyMs } = newNodeData.initialData;
|
|
114
|
+
(datastore[key] ??= {})[attendeeId] = value;
|
|
115
|
+
newValues[key] = value;
|
|
116
|
+
if (allowableUpdateLatencyMs !== undefined) {
|
|
117
|
+
cumulativeAllowableUpdateLatencyMs =
|
|
118
|
+
cumulativeAllowableUpdateLatencyMs === undefined
|
|
119
|
+
? allowableUpdateLatencyMs
|
|
120
|
+
: Math.min(cumulativeAllowableUpdateLatencyMs, allowableUpdateLatencyMs);
|
|
121
|
+
}
|
|
122
|
+
anyInitialValues = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
this.nodes = nodes;
|
|
126
|
+
// states and notifications are the public view of nodes that limits the entries
|
|
127
|
+
// types to the public interface of State objects with an additional type
|
|
128
|
+
// filter that beguiles the type system. So just reinterpret cast.
|
|
129
|
+
const properties = nodes;
|
|
130
|
+
// `AnyWorkspace` support comes from defining both `states` for
|
|
131
|
+
// `StatesWorkspace` and `notifications` for `NotificationsWorkspace`.
|
|
132
|
+
// `notifications` is always a subset of what `states` can be; so the same.
|
|
133
|
+
this.notifications = this.states = properties;
|
|
134
|
+
if (anyInitialValues) {
|
|
135
|
+
this.runtime.localUpdate(newValues, {
|
|
136
|
+
allowableUpdateLatencyMs: cumulativeAllowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
get presence() {
|
|
142
|
+
return this.runtime.presence;
|
|
143
|
+
}
|
|
144
|
+
knownValues(key) {
|
|
145
|
+
return {
|
|
146
|
+
self: this.runtime.attendeeId,
|
|
147
|
+
// Caller must only use `key`s that are part of `this.datastore`.
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
149
|
+
states: castUnknownRecordToSchemaRecord(this.datastore[key]),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
localUpdate(key, value, options) {
|
|
153
|
+
this.runtime.localUpdate({ [key]: value }, {
|
|
154
|
+
...options,
|
|
155
|
+
allowableUpdateLatencyMs: options.allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
update(key, clientId, value) {
|
|
159
|
+
// Callers my only use `key`s that are part of `this.datastore`.
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
161
|
+
const allKnownState = this.datastore[key];
|
|
162
|
+
allKnownState[clientId] = mergeValueDirectory(allKnownState[clientId], value, 0);
|
|
163
|
+
}
|
|
164
|
+
add(key, nodeFactory) {
|
|
165
|
+
(0, internal_1.assert)(!(key in this.nodes), 0xa3c /* Already have entry for key in map */);
|
|
166
|
+
const nodeData = nodeFactory(key, (0, stateDatastore_js_1.handleFromDatastore)(this));
|
|
167
|
+
this.nodes[key] = nodeData.manager;
|
|
168
|
+
if ("initialData" in nodeData) {
|
|
169
|
+
const { value, allowableUpdateLatencyMs } = nodeData.initialData;
|
|
170
|
+
let datastoreValue = this.datastore[key];
|
|
171
|
+
if (datastoreValue === undefined) {
|
|
172
|
+
datastoreValue = this.datastore[key] = {};
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// Already have received state from other clients. Kept in `all`.
|
|
176
|
+
// TODO: Send current `all` state to state manager.
|
|
177
|
+
}
|
|
178
|
+
datastoreValue[this.runtime.attendeeId] = value;
|
|
179
|
+
this.runtime.localUpdate({ [key]: value }, {
|
|
180
|
+
allowableUpdateLatencyMs: allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
ensureContent(content, controls) {
|
|
185
|
+
if (controls?.allowableUpdateLatencyMs !== undefined) {
|
|
186
|
+
this.controls.allowableUpdateLatencyMs = controls.allowableUpdateLatencyMs;
|
|
187
|
+
}
|
|
188
|
+
for (const [key, nodeFactory] of Object.entries(content)) {
|
|
189
|
+
const brandedIVM = this.nodes[key];
|
|
190
|
+
if (brandedIVM === undefined) {
|
|
191
|
+
this.add(key, nodeFactory);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const node = (0, utils_1.unbrandIVM)(brandedIVM);
|
|
195
|
+
if (!(node instanceof nodeFactory.instanceBase)) {
|
|
196
|
+
throw new TypeError(`State "${key}" previously created by different State object.`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
processUpdate(received, timeModifier, remoteDatastore) {
|
|
203
|
+
const postUpdateActions = [];
|
|
204
|
+
for (const [key, remoteAllKnownState] of Object.entries(remoteDatastore)) {
|
|
205
|
+
const brandedIVM = this.nodes[key];
|
|
206
|
+
if (brandedIVM === undefined) {
|
|
207
|
+
// Assume all broadcast state is meant to be kept even if not currently registered.
|
|
208
|
+
mergeUntrackedDatastore(key, remoteAllKnownState, this.datastore, timeModifier);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const node = (0, utils_1.unbrandIVM)(brandedIVM);
|
|
212
|
+
for (const [attendeeId, value] of (0, utils_1.objectEntries)(remoteAllKnownState)) {
|
|
213
|
+
const client = this.runtime.presence.attendees.getAttendee(attendeeId);
|
|
214
|
+
postUpdateActions.push(...node.update(client, received, value));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return postUpdateActions;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Create a new Workspace using the DataStoreRuntime provided.
|
|
223
|
+
* @param initialContent - The initial State objects to register.
|
|
224
|
+
*
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
227
|
+
function createPresenceStates(runtime, datastore, initialContent, controls) {
|
|
228
|
+
const impl = new PresenceStatesImpl(runtime, datastore, initialContent, controls);
|
|
229
|
+
return {
|
|
230
|
+
public: impl,
|
|
231
|
+
internal: impl,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
exports.createPresenceStates = createPresenceStates;
|
|
235
|
+
//# sourceMappingURL=presenceStates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presenceStates.js","sourceRoot":"","sources":["../../src/workspace/presenceStates.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+BH,kEAA6D;AAG7D,kEAKgD;AAEhD,2DAA0D;AAyC1D,SAAS,gBAAgB,CAMxB,KAAoD;IAEpD,OAAO,OAAO,IAAI,KAAK,CAAC;AACzB,CAAC;AA+CD;;;;;;;;;GASG;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,IAAI,CAAC,GAAG,EAAE,CAAC;YACjD,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,SAA0C,CAAC;IAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,SAAS,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,KAA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C1E,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC9B,mFAAmF;gBACnF,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACP,MAAM,IAAI,GAAG,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;gBACpC,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,IAAA,qBAAa,EAAC,mBAAmB,CAAC,EAAE,CAAC;oBACtE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;oBACvE,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;gBACjE,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC1B,CAAC;CACD;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CACnC,OAAwB,EACxB,SAAiD,EACjD,cAAuB,EACvB,QAA8C;IAE9C,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAU,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IAE3F,OAAO;QACN,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,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 type {\n\tAttendeeId,\n\tBroadcastControlSettings,\n\tPresenceWithNotifications as Presence,\n\tStatesWorkspace,\n\tStatesWorkspaceSchema,\n} from \"@fluid-internal/presence-definitions\";\nimport type {\n\tAnyWorkspace,\n\tInternalTypes,\n\tPostUpdateAction,\n\tValidatableOptionalState,\n\tValidatableRequiredState,\n\tValidatableValueDirectory,\n\tValidatableValueDirectoryOrState,\n\tValidatableValueStructure,\n} from \"@fluid-internal/presence-definitions/internal\";\nimport type { ClientRecord } from \"@fluid-internal/presence-definitions/internal/workspace\";\nimport type {\n\tClientUpdateEntry,\n\tPresenceStatesInternal,\n\tRuntimeLocalUpdateOptions,\n\tValueElementMap,\n\tValueUpdateRecord,\n} from \"@fluid-internal/presence-definitions/internal/workspace-runtime\";\nimport type {\n\tLocalStateUpdateOptions,\n\tStateDatastore,\n} from \"@fluid-internal/presence-definitions/internal/workspace-states\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { RecordEntryTypes } from \"@fluid-internal/presence-runtime/utils\";\nimport {\n\tgetOrCreateRecord,\n\tobjectEntries,\n\tRequiredBroadcastControl,\n\tunbrandIVM,\n} from \"@fluid-internal/presence-runtime/utils\";\n\nimport { handleFromDatastore } from \"./stateDatastore.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 */\ntype 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 * Contract for `PresenceDatastoreManager` as required by States Workspaces ({@link PresenceStatesImpl}).\n */\ninterface 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\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/**\n * Non-validatable types\n *\n * @internal\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/**\n * Validatable base type with non-validatable update types\n *\n * @internal\n */\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/**\n * Fully validatable types\n *\n * @internal\n */\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 *\n * @internal\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 *\n * @internal\n */\nexport function mergeUntrackedDatastore(\n\tkey: string,\n\tremoteAllKnownState: ValueUpdateRecord[string],\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 *\n * @internal\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"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { InternalTypes } from "@fluid-internal/presence-definitions/internal";
|
|
6
|
+
import type { StateDatastore } from "@fluid-internal/presence-definitions/internal/workspace-states";
|
|
7
|
+
/**
|
|
8
|
+
* Helper to get a handle from a datastore.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleFromDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(datastore: StateDatastore<TKey, TValue>): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper to get the datastore back from its handle.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function datastoreFromHandle<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue>;
|
|
17
|
+
//# sourceMappingURL=stateDatastore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateDatastore.d.ts","sourceRoot":"","sources":["../../src/workspace/stateDatastore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gEAAgE,CAAC;AAErG;;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;;;;GAIG;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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
function datastoreFromHandle(handle) {
|
|
21
|
+
return handle;
|
|
22
|
+
}
|
|
23
|
+
exports.datastoreFromHandle = datastoreFromHandle;
|
|
24
|
+
//# sourceMappingURL=stateDatastore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateDatastore.js","sourceRoot":"","sources":["../../src/workspace/stateDatastore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;GAEG;AACH,SAAgB,mBAAmB,CAOlC,SAAuC;IAEvC,OAAO,SAGN,CAAC;AACH,CAAC;AAbD,kDAaC;AAED;;;;GAIG;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 { InternalTypes } from \"@fluid-internal/presence-definitions/internal\";\nimport type { StateDatastore } from \"@fluid-internal/presence-definitions/internal/workspace-states\";\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 *\n * @internal\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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export declare const pkgName = "@fluid-internal/presence-runtime";
|
|
8
|
+
export declare const pkgVersion = "2.93.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,qCAAqC,CAAC;AAC1D,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
export const pkgName = "@fluid-internal/presence-runtime";
|
|
8
|
+
export const pkgVersion = "2.93.0";
|
|
9
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,kCAAkC,CAAC;AAC1D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-internal/presence-runtime\";\nexport const pkgVersion = \"2.93.0\";\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { PresenceWithNotifications } from "@fluid-internal/presence-definitions";
|
|
6
|
+
import type { ContainerExtension, ContainerExtensionFactory, ExtensionInstantiationResult, ExtensionRuntimeProperties as GenericExtensionRuntimeProperties, InboundExtensionMessage } from "@fluidframework/container-runtime-definitions/internal";
|
|
7
|
+
import type { ExtensionCompatibilityDetails } from "@fluidframework/runtime-definitions/internal";
|
|
8
|
+
import type { SignalMessages } from "../protocol.js";
|
|
9
|
+
import type { ExtensionHost, ExtensionRuntimeProperties } from "../runtimeTypes.js";
|
|
10
|
+
/**
|
|
11
|
+
* Common Presence manager for a container
|
|
12
|
+
*/
|
|
13
|
+
declare class ContainerPresenceManager implements ContainerExtension<ExtensionRuntimeProperties>, ReturnType<ContainerExtensionFactory<PresenceWithNotifications, ExtensionRuntimeProperties>["instantiateExtension"]> {
|
|
14
|
+
readonly compatibility: {
|
|
15
|
+
readonly generation: 1;
|
|
16
|
+
readonly version: "2.93.0";
|
|
17
|
+
readonly capabilities: Set<never>;
|
|
18
|
+
};
|
|
19
|
+
readonly interface: PresenceWithNotifications;
|
|
20
|
+
readonly extension: this;
|
|
21
|
+
private readonly manager;
|
|
22
|
+
constructor(host: ExtensionHost);
|
|
23
|
+
handleVersionOrCapabilitiesMismatch<_TRequestedInterface>(ourExistingInstantiation: Readonly<ExtensionInstantiationResult<PresenceWithNotifications, ExtensionRuntimeProperties, []>>, newCompatibilityRequest: ExtensionCompatibilityDetails): never;
|
|
24
|
+
onNewUse(): void;
|
|
25
|
+
processSignal(addressChain: string[], message: InboundExtensionMessage<SignalMessages>, local: boolean): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* {@link ContainerExtensionId} for Presence
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const extensionId = "dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a";
|
|
33
|
+
/**
|
|
34
|
+
* {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare const ContainerPresenceFactory: {
|
|
39
|
+
readonly hostRequirements: {
|
|
40
|
+
readonly minSupportedGeneration: 1;
|
|
41
|
+
readonly requiredFeatures: readonly [];
|
|
42
|
+
};
|
|
43
|
+
readonly instanceExpectations: {
|
|
44
|
+
readonly version: "2.71.0";
|
|
45
|
+
readonly generation: 1;
|
|
46
|
+
readonly capabilities: Set<never>;
|
|
47
|
+
};
|
|
48
|
+
readonly resolvePriorInstantiation: (existingInstantiation: ExtensionInstantiationResult<unknown, GenericExtensionRuntimeProperties, unknown[]>) => never;
|
|
49
|
+
readonly instantiateExtension: (host: ExtensionHost) => ContainerPresenceManager;
|
|
50
|
+
readonly [Symbol.hasInstance]: (instance: unknown) => instance is ContainerPresenceManager;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=containerPresence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerPresence.d.ts","sourceRoot":"","sources":["../../../src/runtime/extension/containerPresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,KAAK,EACX,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,IAAI,iCAAiC,EAC/D,uBAAuB,EACvB,MAAM,wDAAwD,CAAC;AAEhE,OAAO,KAAK,EAEX,6BAA6B,EAC7B,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAoCpF;;GAEG;AACH,cAAM,wBACL,YACC,kBAAkB,CAAC,0BAA0B,CAAC,EAC9C,UAAU,CACT,yBAAyB,CACxB,yBAAyB,EACzB,0BAA0B,CAC1B,CAAC,sBAAsB,CAAC,CACzB;IAGF,SAAgB,aAAa;;;;MAAyB;IACtD,SAAgB,SAAS,EAAE,yBAAyB,CAAC;IACrD,SAAgB,SAAS,OAAQ;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;gBAElC,IAAI,EAAE,aAAa;IAS/B,mCAAmC,CAAC,oBAAoB,EAC9D,wBAAwB,EAAE,QAAQ,CACjC,4BAA4B,CAAC,yBAAyB,EAAE,0BAA0B,EAAE,EAAE,CAAC,CACvF,EACD,uBAAuB,EAAE,6BAA6B,GACpD,KAAK;IAWD,QAAQ,IAAI,IAAI;IAIhB,aAAa,CACnB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,uBAAuB,CAAC,cAAc,CAAC,EAChD,KAAK,EAAE,OAAO,GACZ,IAAI;CAGP;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,6CACkD,CAAC;AAE3E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;gEASZ,6BACtB,OAAO,EACP,iCAAiC,EACjC,OAAO,EAAE,CACT,KACC,KAAK;4DAQmC,wBAAwB;8CAIlC,OAAO;CAMxC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
6
|
+
import { pkgVersion } from "../../packageVersion.js";
|
|
7
|
+
import { createPresenceManager } from "../presenceManager.js";
|
|
8
|
+
const presenceCompatibility = {
|
|
9
|
+
generation: 1,
|
|
10
|
+
version: pkgVersion,
|
|
11
|
+
capabilities: new Set([]),
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Minimal compatible package version.
|
|
15
|
+
* If an existing presence extension is registered with this version or higher,
|
|
16
|
+
* it can be used instead of instantiating new instance from this version of
|
|
17
|
+
* the package (assuming also capabilities are compatible).
|
|
18
|
+
*/
|
|
19
|
+
const minimalCompatiblePackageVersion = "2.71.0";
|
|
20
|
+
function assertCompatibilityInvariants(compatibility) {
|
|
21
|
+
assert(compatibility.generation === presenceCompatibility.generation, 0xc97 /* Presence compatibility generation mismatch. */);
|
|
22
|
+
assert(compatibility.version.startsWith("2."), 0xc98 /* Registered version is not major version 2. */);
|
|
23
|
+
assert(Number.parseFloat(compatibility.version.slice(2)) <
|
|
24
|
+
Number.parseFloat(presenceCompatibility.version.slice(2)), 0xc99 /* Registered version is not less than the current version. */);
|
|
25
|
+
assert(presenceCompatibility.capabilities.size === 0, 0xc9a /* Presence capabilities should be empty. */);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Common Presence manager for a container
|
|
29
|
+
*/
|
|
30
|
+
class ContainerPresenceManager {
|
|
31
|
+
constructor(host) {
|
|
32
|
+
// ContainerExtensionFactory return elements
|
|
33
|
+
this.compatibility = presenceCompatibility;
|
|
34
|
+
this.extension = this;
|
|
35
|
+
this.interface = this.manager = createPresenceManager({
|
|
36
|
+
...host,
|
|
37
|
+
submitSignal: (message) => {
|
|
38
|
+
host.submitAddressedSignal([], message);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
handleVersionOrCapabilitiesMismatch(ourExistingInstantiation, newCompatibilityRequest) {
|
|
43
|
+
assert(ourExistingInstantiation.compatibility === presenceCompatibility, 0xc9b /* Presence extension called without own compatibility details */);
|
|
44
|
+
assertCompatibilityInvariants(newCompatibilityRequest);
|
|
45
|
+
// There have not yet been any changes that would require action to upgrade.
|
|
46
|
+
// But also mixed runtime versions are not yet expected.
|
|
47
|
+
fail(0xcb1 /* Presence is only expected to be accessed with a single version. */);
|
|
48
|
+
}
|
|
49
|
+
onNewUse() {
|
|
50
|
+
// No-op
|
|
51
|
+
}
|
|
52
|
+
processSignal(addressChain, message, local) {
|
|
53
|
+
this.manager.processSignal(addressChain, message, local);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* {@link ContainerExtensionId} for Presence
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export const extensionId = "dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a";
|
|
62
|
+
/**
|
|
63
|
+
* {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
export const ContainerPresenceFactory = {
|
|
68
|
+
hostRequirements: {
|
|
69
|
+
minSupportedGeneration: 1,
|
|
70
|
+
requiredFeatures: [],
|
|
71
|
+
},
|
|
72
|
+
instanceExpectations: { ...presenceCompatibility, version: minimalCompatiblePackageVersion },
|
|
73
|
+
resolvePriorInstantiation(existingInstantiation) {
|
|
74
|
+
// Validate assumptions about existing instance
|
|
75
|
+
assertCompatibilityInvariants(existingInstantiation.compatibility);
|
|
76
|
+
// There have not yet been any changes that would require action to upgrade.
|
|
77
|
+
// But also mixed runtime versions are not yet expected.
|
|
78
|
+
fail(0xcb2 /* Presence is only expected to be accessed with a single version. */);
|
|
79
|
+
},
|
|
80
|
+
instantiateExtension(host) {
|
|
81
|
+
return new ContainerPresenceManager(host);
|
|
82
|
+
},
|
|
83
|
+
[Symbol.hasInstance]: (instance) => {
|
|
84
|
+
return instance instanceof ContainerPresenceManager;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=containerPresence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerPresence.js","sourceRoot":"","sources":["../../../src/runtime/extension/containerPresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAMnE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAmC,MAAM,uBAAuB,CAAC;AAI/F,MAAM,qBAAqB,GAAG;IAC7B,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;CACwB,CAAC;AAEnD;;;;;GAKG;A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F,CAAC;IAEM,QAAQ;QACd,QAAQ;IACT,CAAC;IAEM,aAAa,CACnB,YAAsB,EACtB,OAAgD,EAChD,KAAc;QAEd,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GACvB,0CAAyE,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,gBAAgB,EAAE;QACjB,sBAAsB,EAAE,CAAC;QACzB,gBAAgB,EAAE,EAAE;KAC+B;IAEpD,oBAAoB,EAAE,EAAE,GAAG,qBAAqB,EAAE,OAAO,EAAE,+BAA+B,EAAE;IAE5F,yBAAyB,CACxB,qBAIC;QAED,+CAA+C;QAC/C,6BAA6B,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QACnE,4EAA4E;QAC5E,wDAAwD;QACxD,IAAI,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACnF,CAAC;IAED,oBAAoB,CAAC,IAAmB;QACvC,OAAO,IAAI,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,QAAiB,EAAwC,EAAE;QACjF,OAAO,QAAQ,YAAY,wBAAwB,CAAC;IACrD,CAAC;CAID,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ILayerCompatSupportRequirements } from \"@fluid-internal/client-utils\";\nimport type { PresenceWithNotifications } from \"@fluid-internal/presence-definitions\";\nimport type {\n\tContainerExtension,\n\tContainerExtensionFactory,\n\tExtensionInstantiationResult,\n\tExtensionRuntimeProperties as GenericExtensionRuntimeProperties,\n\tInboundExtensionMessage,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tContainerExtensionId,\n\tExtensionCompatibilityDetails,\n} from \"@fluidframework/runtime-definitions/internal\";\n\nimport { pkgVersion } from \"../../packageVersion.js\";\nimport { createPresenceManager, type PresenceExtensionInterface } from \"../presenceManager.js\";\nimport type { SignalMessages } from \"../protocol.js\";\nimport type { ExtensionHost, ExtensionRuntimeProperties } from \"../runtimeTypes.js\";\n\nconst presenceCompatibility = {\n\tgeneration: 1,\n\tversion: pkgVersion,\n\tcapabilities: new Set([]),\n} as const satisfies ExtensionCompatibilityDetails;\n\n/**\n * Minimal compatible package version.\n * If an existing presence extension is registered with this version or higher,\n * it can be used instead of instantiating new instance from this version of\n * the package (assuming also capabilities are compatible).\n */\nconst minimalCompatiblePackageVersion = \"2.71.0\";\n\nfunction assertCompatibilityInvariants(compatibility: ExtensionCompatibilityDetails): void {\n\tassert(\n\t\tcompatibility.generation === presenceCompatibility.generation,\n\t\t0xc97 /* Presence compatibility generation mismatch. */,\n\t);\n\tassert(\n\t\tcompatibility.version.startsWith(\"2.\"),\n\t\t0xc98 /* Registered version is not major version 2. */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(compatibility.version.slice(2)) <\n\t\t\tNumber.parseFloat(presenceCompatibility.version.slice(2)),\n\t\t0xc99 /* Registered version is not less than the current version. */,\n\t);\n\tassert(\n\t\tpresenceCompatibility.capabilities.size === 0,\n\t\t0xc9a /* Presence capabilities should be empty. */,\n\t);\n}\n\n/**\n * Common Presence manager for a container\n */\nclass ContainerPresenceManager\n\timplements\n\t\tContainerExtension<ExtensionRuntimeProperties>,\n\t\tReturnType<\n\t\t\tContainerExtensionFactory<\n\t\t\t\tPresenceWithNotifications,\n\t\t\t\tExtensionRuntimeProperties\n\t\t\t>[\"instantiateExtension\"]\n\t\t>\n{\n\t// ContainerExtensionFactory return elements\n\tpublic readonly compatibility = presenceCompatibility;\n\tpublic readonly interface: PresenceWithNotifications;\n\tpublic readonly extension = this;\n\n\tprivate readonly manager: PresenceExtensionInterface;\n\n\tpublic constructor(host: ExtensionHost) {\n\t\tthis.interface = this.manager = createPresenceManager({\n\t\t\t...host,\n\t\t\tsubmitSignal: (message) => {\n\t\t\t\thost.submitAddressedSignal([], message);\n\t\t\t},\n\t\t});\n\t}\n\n\tpublic handleVersionOrCapabilitiesMismatch<_TRequestedInterface>(\n\t\tourExistingInstantiation: Readonly<\n\t\t\tExtensionInstantiationResult<PresenceWithNotifications, ExtensionRuntimeProperties, []>\n\t\t>,\n\t\tnewCompatibilityRequest: ExtensionCompatibilityDetails,\n\t): never {\n\t\tassert(\n\t\t\tourExistingInstantiation.compatibility === presenceCompatibility,\n\t\t\t0xc9b /* Presence extension called without own compatibility details */,\n\t\t);\n\t\tassertCompatibilityInvariants(newCompatibilityRequest);\n\t\t// There have not yet been any changes that would require action to upgrade.\n\t\t// But also mixed runtime versions are not yet expected.\n\t\tfail(0xcb1 /* Presence is only expected to be accessed with a single version. */);\n\t}\n\n\tpublic onNewUse(): void {\n\t\t// No-op\n\t}\n\n\tpublic processSignal(\n\t\taddressChain: string[],\n\t\tmessage: InboundExtensionMessage<SignalMessages>,\n\t\tlocal: boolean,\n\t): void {\n\t\tthis.manager.processSignal(addressChain, message, local);\n\t}\n}\n\n/**\n * {@link ContainerExtensionId} for Presence\n *\n * @internal\n */\nexport const extensionId =\n\t\"dis:bb89f4c0-80fd-4f0c-8469-4f2848ee7f4a\" satisfies ContainerExtensionId;\n\n/**\n * {@link ContainerExtensionFactory|Factory} for Presence as {@link ContainerExtension}\n *\n * @internal\n */\nexport const ContainerPresenceFactory = {\n\thostRequirements: {\n\t\tminSupportedGeneration: 1,\n\t\trequiredFeatures: [],\n\t} as const satisfies ILayerCompatSupportRequirements,\n\n\tinstanceExpectations: { ...presenceCompatibility, version: minimalCompatiblePackageVersion },\n\n\tresolvePriorInstantiation(\n\t\texistingInstantiation: ExtensionInstantiationResult<\n\t\t\tunknown,\n\t\t\tGenericExtensionRuntimeProperties,\n\t\t\tunknown[]\n\t\t>,\n\t): never {\n\t\t// Validate assumptions about existing instance\n\t\tassertCompatibilityInvariants(existingInstantiation.compatibility);\n\t\t// There have not yet been any changes that would require action to upgrade.\n\t\t// But also mixed runtime versions are not yet expected.\n\t\tfail(0xcb2 /* Presence is only expected to be accessed with a single version. */);\n\t},\n\n\tinstantiateExtension(host: ExtensionHost): ContainerPresenceManager {\n\t\treturn new ContainerPresenceManager(host);\n\t},\n\n\t[Symbol.hasInstance]: (instance: unknown): instance is ContainerPresenceManager => {\n\t\treturn instance instanceof ContainerPresenceManager;\n\t},\n} as const satisfies ContainerExtensionFactory<\n\tPresenceWithNotifications,\n\tExtensionRuntimeProperties\n>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/extension/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/extension/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ContainerPresenceFactory, extensionId } from \"./containerPresence.js\";\n"]}
|