@fluidframework/sequence 0.59.3003 → 0.59.4000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{mapKernel.d.ts → defaultMap.d.ts} +21 -145
- package/dist/defaultMap.d.ts.map +1 -0
- package/dist/defaultMap.js +317 -0
- package/dist/defaultMap.js.map +1 -0
- package/dist/{mapKernelInterfaces.d.ts → defaultMapInterfaces.d.ts} +9 -51
- package/dist/defaultMapInterfaces.d.ts.map +1 -0
- package/dist/{mapKernelInterfaces.js → defaultMapInterfaces.js} +1 -1
- package/dist/defaultMapInterfaces.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/intervalCollection.d.ts +12 -3
- package/dist/intervalCollection.d.ts.map +1 -1
- package/dist/intervalCollection.js +44 -39
- package/dist/intervalCollection.js.map +1 -1
- package/dist/localValues.d.ts +7 -86
- package/dist/localValues.d.ts.map +1 -1
- package/dist/localValues.js +1 -131
- package/dist/localValues.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sequence.d.ts +5 -1
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +23 -23
- package/dist/sequence.js.map +1 -1
- package/dist/sharedIntervalCollection.d.ts +13 -5
- package/dist/sharedIntervalCollection.d.ts.map +1 -1
- package/dist/sharedIntervalCollection.js +16 -12
- package/dist/sharedIntervalCollection.js.map +1 -1
- package/lib/{mapKernel.d.ts → defaultMap.d.ts} +21 -145
- package/lib/defaultMap.d.ts.map +1 -0
- package/lib/defaultMap.js +313 -0
- package/lib/defaultMap.js.map +1 -0
- package/lib/{mapKernelInterfaces.d.ts → defaultMapInterfaces.d.ts} +9 -51
- package/lib/defaultMapInterfaces.d.ts.map +1 -0
- package/lib/{mapKernelInterfaces.js → defaultMapInterfaces.js} +1 -1
- package/lib/defaultMapInterfaces.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/intervalCollection.d.ts +12 -3
- package/lib/intervalCollection.d.ts.map +1 -1
- package/lib/intervalCollection.js +44 -39
- package/lib/intervalCollection.js.map +1 -1
- package/lib/localValues.d.ts +7 -86
- package/lib/localValues.d.ts.map +1 -1
- package/lib/localValues.js +1 -129
- package/lib/localValues.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sequence.d.ts +5 -1
- package/lib/sequence.d.ts.map +1 -1
- package/lib/sequence.js +23 -23
- package/lib/sequence.js.map +1 -1
- package/lib/sharedIntervalCollection.d.ts +13 -5
- package/lib/sharedIntervalCollection.d.ts.map +1 -1
- package/lib/sharedIntervalCollection.js +16 -12
- package/lib/sharedIntervalCollection.js.map +1 -1
- package/package.json +23 -18
- package/src/defaultMap.ts +453 -0
- package/src/{mapKernelInterfaces.ts → defaultMapInterfaces.ts} +14 -59
- package/src/index.ts +1 -1
- package/src/intervalCollection.ts +58 -43
- package/src/localValues.ts +6 -154
- package/src/packageVersion.ts +1 -1
- package/src/sequence.ts +32 -33
- package/src/sharedIntervalCollection.ts +22 -25
- package/dist/mapKernel.d.ts.map +0 -1
- package/dist/mapKernel.js +0 -599
- package/dist/mapKernel.js.map +0 -1
- package/dist/mapKernelInterfaces.d.ts.map +0 -1
- package/dist/mapKernelInterfaces.js.map +0 -1
- package/lib/mapKernel.d.ts.map +0 -1
- package/lib/mapKernel.js +0 -595
- package/lib/mapKernel.js.map +0 -1
- package/lib/mapKernelInterfaces.d.ts.map +0 -1
- package/lib/mapKernelInterfaces.js.map +0 -1
- package/src/mapKernel.ts +0 -850
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { makeHandlesSerializable, parseHandles, ValueType, } from "@fluidframework/shared-object-base";
|
|
6
|
+
import { assert, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
7
|
+
import { makeSerializable, ValueTypeLocalValue, } from "./localValues";
|
|
8
|
+
/**
|
|
9
|
+
* A DefaultMap is a map-like distributed data structure, supporting operations on values stored by
|
|
10
|
+
* string key locations.
|
|
11
|
+
*
|
|
12
|
+
* Creation of values is implicit on access (either via `get` or a remote op application referring to
|
|
13
|
+
* a collection that wasn't previously known)
|
|
14
|
+
*/
|
|
15
|
+
export class DefaultMap {
|
|
16
|
+
/**
|
|
17
|
+
* Create a new default map.
|
|
18
|
+
* @param serializer - The serializer to serialize / parse handles
|
|
19
|
+
* @param handle - The handle of the shared object using the kernel
|
|
20
|
+
* @param submitMessage - A callback to submit a message through the shared object
|
|
21
|
+
* @param type - The value type to create at values of this map
|
|
22
|
+
* @param eventEmitter - The object that will emit map events
|
|
23
|
+
*/
|
|
24
|
+
constructor(serializer, handle, submitMessage, type, eventEmitter = new TypedEventEmitter()) {
|
|
25
|
+
this.serializer = serializer;
|
|
26
|
+
this.handle = handle;
|
|
27
|
+
this.submitMessage = submitMessage;
|
|
28
|
+
this.type = type;
|
|
29
|
+
this.eventEmitter = eventEmitter;
|
|
30
|
+
/**
|
|
31
|
+
* Mapping of op types to message handlers.
|
|
32
|
+
*/
|
|
33
|
+
this.messageHandlers = new Map();
|
|
34
|
+
/**
|
|
35
|
+
* The in-memory data the map is storing.
|
|
36
|
+
*/
|
|
37
|
+
this.data = new Map();
|
|
38
|
+
this.lastProcessedSeq = -1;
|
|
39
|
+
this.messageHandlers = this.getMessageHandlers();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The number of key/value pairs stored in the map.
|
|
43
|
+
*/
|
|
44
|
+
get size() {
|
|
45
|
+
return this.data.size;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get an iterator over the keys in this map.
|
|
49
|
+
* @returns The iterator
|
|
50
|
+
*/
|
|
51
|
+
keys() {
|
|
52
|
+
return this.data.keys();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get an iterator over the entries in this map.
|
|
56
|
+
* @returns The iterator
|
|
57
|
+
*/
|
|
58
|
+
entries() {
|
|
59
|
+
const localEntriesIterator = this.data.entries();
|
|
60
|
+
const iterator = {
|
|
61
|
+
next() {
|
|
62
|
+
const nextVal = localEntriesIterator.next();
|
|
63
|
+
if (nextVal.done) {
|
|
64
|
+
return { value: undefined, done: true };
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Unpack the stored value
|
|
68
|
+
return { value: [nextVal.value[0], nextVal.value[1].value], done: false };
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[Symbol.iterator]() {
|
|
72
|
+
return this;
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
return iterator;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get an iterator over the values in this map.
|
|
79
|
+
* @returns The iterator
|
|
80
|
+
*/
|
|
81
|
+
values() {
|
|
82
|
+
const localValuesIterator = this.data.values();
|
|
83
|
+
const iterator = {
|
|
84
|
+
next() {
|
|
85
|
+
const nextVal = localValuesIterator.next();
|
|
86
|
+
if (nextVal.done) {
|
|
87
|
+
return { value: undefined, done: true };
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Unpack the stored value
|
|
91
|
+
return { value: nextVal.value.value, done: false };
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
[Symbol.iterator]() {
|
|
95
|
+
return this;
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
return iterator;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get an iterator over the entries in this map.
|
|
102
|
+
* @returns The iterator
|
|
103
|
+
*/
|
|
104
|
+
[Symbol.iterator]() {
|
|
105
|
+
return this.entries();
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Executes the given callback on each entry in the map.
|
|
109
|
+
* @param callbackFn - Callback function
|
|
110
|
+
*/
|
|
111
|
+
forEach(callbackFn) {
|
|
112
|
+
this.data.forEach((localValue, key, m) => {
|
|
113
|
+
callbackFn(localValue.value, key, m);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* {@inheritDoc ISharedMap.get}
|
|
118
|
+
*/
|
|
119
|
+
get(key) {
|
|
120
|
+
let localValue = this.data.get(key);
|
|
121
|
+
if (!this.data.has(key)) {
|
|
122
|
+
localValue = this.createCore(key, true);
|
|
123
|
+
}
|
|
124
|
+
return localValue.value;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if a key exists in the map.
|
|
128
|
+
* @param key - The key to check
|
|
129
|
+
* @returns True if the key exists, false otherwise
|
|
130
|
+
*/
|
|
131
|
+
has(key) {
|
|
132
|
+
return this.data.has(key);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Serializes the data stored in the shared map to a JSON string
|
|
136
|
+
* @param serializer - The serializer to use to serialize handles in its values.
|
|
137
|
+
* @returns A JSON string containing serialized map data
|
|
138
|
+
*/
|
|
139
|
+
getSerializedStorage(serializer) {
|
|
140
|
+
const serializableMapData = {};
|
|
141
|
+
this.data.forEach((localValue, key) => {
|
|
142
|
+
serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);
|
|
143
|
+
});
|
|
144
|
+
return serializableMapData;
|
|
145
|
+
}
|
|
146
|
+
getSerializableStorage(serializer) {
|
|
147
|
+
const serializableMapData = {};
|
|
148
|
+
this.data.forEach((localValue, key) => {
|
|
149
|
+
serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);
|
|
150
|
+
});
|
|
151
|
+
return serializableMapData;
|
|
152
|
+
}
|
|
153
|
+
serialize(serializer) {
|
|
154
|
+
return JSON.stringify(this.getSerializableStorage(serializer));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Populate the kernel with the given map data.
|
|
158
|
+
* @param data - A JSON string containing serialized map data
|
|
159
|
+
*/
|
|
160
|
+
populateFromSerializable(json) {
|
|
161
|
+
for (const [key, serializable] of Object.entries(json)) {
|
|
162
|
+
// Back-compat: legacy documents may have handles to an intervalCollection map kernel.
|
|
163
|
+
// These collections should be empty, and ValueTypes are no longer supported.
|
|
164
|
+
if (serializable.type === ValueType[ValueType.Plain]
|
|
165
|
+
|| serializable.type === ValueType[ValueType.Shared]) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const localValue = {
|
|
169
|
+
key,
|
|
170
|
+
value: this.makeLocal(key, serializable),
|
|
171
|
+
};
|
|
172
|
+
this.data.set(localValue.key, localValue.value);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
populate(json) {
|
|
176
|
+
this.populateFromSerializable(JSON.parse(json));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Submit the given op if a handler is registered.
|
|
180
|
+
* @param op - The operation to attempt to submit
|
|
181
|
+
* @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime
|
|
182
|
+
* and not sent to the server. This will be sent back when this message is received back from the server. This is
|
|
183
|
+
* also sent if we are asked to resubmit the message.
|
|
184
|
+
* @returns True if the operation was submitted, false otherwise.
|
|
185
|
+
*/
|
|
186
|
+
trySubmitMessage(op, localOpMetadata) {
|
|
187
|
+
const type = op.type;
|
|
188
|
+
const handler = this.messageHandlers.get(type);
|
|
189
|
+
if (handler !== undefined) {
|
|
190
|
+
const mapLocalMetadata = localOpMetadata;
|
|
191
|
+
// we don't know how to rebase these operations, so if any other op has come in
|
|
192
|
+
// we will fail.
|
|
193
|
+
if (this.lastProcessedSeq !== (mapLocalMetadata === null || mapLocalMetadata === void 0 ? void 0 : mapLocalMetadata.lastProcessedSeq)) {
|
|
194
|
+
throw new Error("SharedInterval does not support reconnect in presence of external changes");
|
|
195
|
+
}
|
|
196
|
+
handler.submit(op);
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
tryGetStashedOpLocalMetadata(op) {
|
|
202
|
+
const type = op.type;
|
|
203
|
+
if (this.messageHandlers.has(type)) {
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
205
|
+
return this.messageHandlers.get(type).getStashedOpLocalMetadata(op);
|
|
206
|
+
}
|
|
207
|
+
throw new Error("no apply stashed op handler");
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Process the given op if a handler is registered.
|
|
211
|
+
* @param message - The message to process
|
|
212
|
+
* @param local - Whether the message originated from the local client
|
|
213
|
+
* @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
|
|
214
|
+
* For messages from a remote client, this will be undefined.
|
|
215
|
+
* @returns True if the operation was processed, false otherwise.
|
|
216
|
+
*/
|
|
217
|
+
tryProcessMessage(op, local, message, localOpMetadata) {
|
|
218
|
+
// track the seq of every incoming message, so we can detect if any
|
|
219
|
+
// changes happened during a resubmit
|
|
220
|
+
this.lastProcessedSeq = message.sequenceNumber;
|
|
221
|
+
const handler = this.messageHandlers.get(op.type);
|
|
222
|
+
if (handler !== undefined) {
|
|
223
|
+
handler.process(op, local, message, localOpMetadata);
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Initializes a default ValueType at the provided key.
|
|
230
|
+
* Should be used when a map operation incurs creation.
|
|
231
|
+
* @param key - The key being initialized
|
|
232
|
+
* @param local - Whether the message originated from the local client
|
|
233
|
+
*/
|
|
234
|
+
createCore(key, local) {
|
|
235
|
+
const localValue = new ValueTypeLocalValue(this.type.factory.load(this.makeMapValueOpEmitter(key), undefined), this.type);
|
|
236
|
+
const previousValue = this.data.get(key);
|
|
237
|
+
this.data.set(key, localValue);
|
|
238
|
+
const event = { key, previousValue };
|
|
239
|
+
this.eventEmitter.emit("create", event, local, this.eventEmitter);
|
|
240
|
+
return localValue;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will
|
|
244
|
+
* have the information we need to create a real object, but will not be the real object yet. For example,
|
|
245
|
+
* we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's
|
|
246
|
+
* job is to convert that information into a real object for local usage.
|
|
247
|
+
* @param key - The key that the caller intends to store the local value into (used for ops later). But
|
|
248
|
+
* doesn't actually store the local value into that key. So better not lie!
|
|
249
|
+
* @param serializable - The remote information that we can convert into a real object
|
|
250
|
+
* @returns The local value that was produced
|
|
251
|
+
*/
|
|
252
|
+
makeLocal(key, serializable) {
|
|
253
|
+
assert(serializable.type !== ValueType[ValueType.Plain] && serializable.type !== ValueType[ValueType.Shared], 0x2e1 /* "Support for plain value types removed." */);
|
|
254
|
+
serializable.value = parseHandles(serializable.value, this.serializer);
|
|
255
|
+
const localValue = this.type.factory.load(this.makeMapValueOpEmitter(key), serializable.value);
|
|
256
|
+
return new ValueTypeLocalValue(localValue, this.type);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the message handlers for the map.
|
|
260
|
+
* @returns A map of string op names to IMapMessageHandlers for those ops
|
|
261
|
+
*/
|
|
262
|
+
getMessageHandlers() {
|
|
263
|
+
const messageHandlers = new Map();
|
|
264
|
+
// Ops with type "act" describe actions taken by custom value type handlers of whatever item is
|
|
265
|
+
// being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has
|
|
266
|
+
// stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone
|
|
267
|
+
// watching for manipulations of that item.
|
|
268
|
+
messageHandlers.set("act", {
|
|
269
|
+
process: (op, local, message, localOpMetadata) => {
|
|
270
|
+
var _a;
|
|
271
|
+
const localValue = (_a = this.data.get(op.key)) !== null && _a !== void 0 ? _a : this.createCore(op.key, local);
|
|
272
|
+
const handler = localValue.getOpHandler(op.value.opName);
|
|
273
|
+
const previousValue = localValue.value;
|
|
274
|
+
const translatedValue = parseHandles(op.value.value, this.serializer);
|
|
275
|
+
handler.process(previousValue, translatedValue, local, message);
|
|
276
|
+
const event = { key: op.key, previousValue };
|
|
277
|
+
this.eventEmitter.emit("valueChanged", event, local, message, this.eventEmitter);
|
|
278
|
+
},
|
|
279
|
+
submit: (op) => {
|
|
280
|
+
this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });
|
|
281
|
+
},
|
|
282
|
+
getStashedOpLocalMetadata: (op) => {
|
|
283
|
+
assert(false, 0x016 /* "apply stashed op not implemented for custom value type ops" */);
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
return messageHandlers;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Create an emitter for a value type to emit ops from the given key.
|
|
290
|
+
* @alpha
|
|
291
|
+
* @param key - The key of the map that the value type will be stored on
|
|
292
|
+
* @returns A value op emitter for the given key
|
|
293
|
+
*/
|
|
294
|
+
makeMapValueOpEmitter(key) {
|
|
295
|
+
const emit = (opName, previousValue, params) => {
|
|
296
|
+
const translatedParams = makeHandlesSerializable(params, this.serializer, this.handle);
|
|
297
|
+
const op = {
|
|
298
|
+
key,
|
|
299
|
+
type: "act",
|
|
300
|
+
value: {
|
|
301
|
+
opName,
|
|
302
|
+
value: translatedParams,
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
// Send the localOpMetadata as undefined because we don't care about the ack.
|
|
306
|
+
this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });
|
|
307
|
+
const event = { key, previousValue };
|
|
308
|
+
this.eventEmitter.emit("valueChanged", event, true, null, this.eventEmitter);
|
|
309
|
+
};
|
|
310
|
+
return { emit };
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=defaultMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMap.js","sourceRoot":"","sources":["../src/defaultMap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,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AAC,CAAC;YAEpE,MAAM,KAAK,GAAkB,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;YACpD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACjF,CAAC,CAAC;QAEF,OAAO,EAAE,IAAI,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n IFluidSerializer,\n makeHandlesSerializable,\n parseHandles,\n ValueType,\n} from \"@fluidframework/shared-object-base\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport {\n makeSerializable,\n ValueTypeLocalValue,\n} from \"./localValues\";\nimport {\n ISerializableValue,\n ISerializedValue,\n IValueChanged,\n IValueOpEmitter,\n IValueType,\n IValueTypeOperationValue,\n ISharedDefaultMapEvents,\n} from \"./defaultMapInterfaces\";\n\n/**\n * Defines the means to process and submit a given op on a map.\n */\ninterface IMapMessageHandler {\n /**\n * Apply the given operation.\n * @param op - The map operation to apply\n * @param local - Whether the message originated from the local client\n * @param message - The full message. Not provided for stashed ops.\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n */\n process(\n op: IMapOperation,\n local: boolean,\n message: ISequencedDocumentMessage | undefined,\n localOpMetadata: IMapMessageLocalMetadata,\n ): void;\n\n /**\n * Communicate the operation to remote clients.\n * @param op - The map operation to submit\n */\n submit(op: IMapOperation): void;\n\n getStashedOpLocalMetadata(op: IMapOperation): unknown;\n}\n\nexport interface IMapMessageLocalMetadata {\n lastProcessedSeq: number;\n}\n\n/**\n * Describes an operation specific to a value type.\n */\nexport interface IMapValueTypeOperation {\n /**\n * String identifier of the operation type.\n */\n type: \"act\";\n\n /**\n * Map key being modified.\n */\n key: string;\n\n /**\n * Value of the operation, specific to the value type.\n * @alpha\n */\n value: IValueTypeOperationValue;\n}\n\n/**\n * Description of a map delta operation\n */\nexport type IMapOperation = IMapValueTypeOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n * Directly used in JSON.stringify, direct result from JSON.parse\n */\nexport interface IMapDataObjectSerializable {\n [key: string]: ISerializableValue;\n}\n\nexport interface IMapDataObjectSerialized {\n [key: string]: ISerializedValue;\n}\n\n/**\n * A DefaultMap is a map-like distributed data structure, supporting operations on values stored by\n * string key locations.\n *\n * Creation of values is implicit on access (either via `get` or a remote op application referring to\n * a collection that wasn't previously known)\n */\nexport class DefaultMap<T> {\n /**\n * The number of key/value pairs stored in the map.\n */\n public get size(): number {\n return this.data.size;\n }\n\n /**\n * Mapping of op types to message handlers.\n */\n private readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n /**\n * The in-memory data the map is storing.\n */\n private readonly data = new Map<string, ValueTypeLocalValue<T>>();\n\n private lastProcessedSeq: number = -1;\n\n /**\n * Create a new default map.\n * @param serializer - The serializer to serialize / parse handles\n * @param handle - The handle of the shared object using the kernel\n * @param submitMessage - A callback to submit a message through the shared object\n * @param type - The value type to create at values of this map\n * @param eventEmitter - The object that will emit map events\n */\n constructor(\n private readonly serializer: IFluidSerializer,\n private readonly handle: IFluidHandle,\n private readonly submitMessage: (op: any, localOpMetadata: IMapMessageLocalMetadata) => void,\n private readonly type: IValueType<T>,\n public readonly eventEmitter = new TypedEventEmitter<ISharedDefaultMapEvents>(),\n ) {\n this.messageHandlers = this.getMessageHandlers();\n }\n\n /**\n * Get an iterator over the keys in this map.\n * @returns The iterator\n */\n public keys(): IterableIterator<string> {\n return this.data.keys();\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public entries(): IterableIterator<[string, any]> {\n const localEntriesIterator = this.data.entries();\n const iterator = {\n next(): IteratorResult<[string, any]> {\n const nextVal = localEntriesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: [nextVal.value[0], nextVal.value[1].value], done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the values in this map.\n * @returns The iterator\n */\n public values(): IterableIterator<any> {\n const localValuesIterator = this.data.values();\n const iterator = {\n next(): IteratorResult<any> {\n const nextVal = localValuesIterator.next();\n if (nextVal.done) {\n return { value: undefined, done: true };\n } else {\n // Unpack the stored value\n return { value: nextVal.value.value, done: false };\n }\n },\n [Symbol.iterator]() {\n return this;\n },\n };\n return iterator;\n }\n\n /**\n * Get an iterator over the entries in this map.\n * @returns The iterator\n */\n public [Symbol.iterator](): IterableIterator<[string, any]> {\n return this.entries();\n }\n\n /**\n * Executes the given callback on each entry in the map.\n * @param callbackFn - Callback function\n */\n public forEach(callbackFn: (value: any, key: string, map: Map<string, any>) => void): void {\n this.data.forEach((localValue, key, m) => {\n callbackFn(localValue.value, key, m);\n });\n }\n\n /**\n * {@inheritDoc ISharedMap.get}\n */\n public get(key: string): T {\n let localValue = this.data.get(key);\n if (!this.data.has(key)) {\n localValue = this.createCore(key, true);\n }\n return localValue.value;\n }\n\n /**\n * Check if a key exists in the map.\n * @param key - The key to check\n * @returns True if the key exists, false otherwise\n */\n public has(key: string): boolean {\n return this.data.has(key);\n }\n\n /**\n * Serializes the data stored in the shared map to a JSON string\n * @param serializer - The serializer to use to serialize handles in its values.\n * @returns A JSON string containing serialized map data\n */\n public getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n const serializableMapData: IMapDataObjectSerialized = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = localValue.makeSerialized(serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public getSerializableStorage(serializer: IFluidSerializer): IMapDataObjectSerializable {\n const serializableMapData: IMapDataObjectSerializable = {};\n this.data.forEach((localValue, key) => {\n serializableMapData[key] = makeSerializable(localValue, serializer, this.handle);\n });\n return serializableMapData;\n }\n\n public serialize(serializer: IFluidSerializer): string {\n return JSON.stringify(this.getSerializableStorage(serializer));\n }\n\n /**\n * Populate the kernel with the given map data.\n * @param data - A JSON string containing serialized map data\n */\n public populateFromSerializable(json: IMapDataObjectSerializable): void {\n for (const [key, serializable] of Object.entries(json)) {\n // Back-compat: legacy documents may have handles to an intervalCollection map kernel.\n // These collections should be empty, and ValueTypes are no longer supported.\n if (serializable.type === ValueType[ValueType.Plain]\n || serializable.type === ValueType[ValueType.Shared]) {\n continue;\n }\n\n const localValue = {\n key,\n value: this.makeLocal(key, serializable),\n };\n\n this.data.set(localValue.key, localValue.value);\n }\n }\n\n public populate(json: string): void {\n this.populateFromSerializable(JSON.parse(json) as IMapDataObjectSerializable);\n }\n\n /**\n * Submit the given op if a handler is registered.\n * @param op - The operation to attempt to submit\n * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n * and not sent to the server. This will be sent back when this message is received back from the server. This is\n * also sent if we are asked to resubmit the message.\n * @returns True if the operation was submitted, false otherwise.\n */\n public trySubmitMessage(op: any, localOpMetadata: IMapMessageLocalMetadata): boolean {\n const type: string = op.type;\n const handler = this.messageHandlers.get(type);\n if (handler !== undefined) {\n const mapLocalMetadata: Partial<IMapMessageLocalMetadata> = localOpMetadata;\n // we don't know how to rebase these operations, so if any other op has come in\n // we will fail.\n if (this.lastProcessedSeq !== mapLocalMetadata?.lastProcessedSeq) {\n throw new Error(\"SharedInterval does not support reconnect in presence of external changes\");\n }\n handler.submit(op as IMapOperation);\n return true;\n }\n return false;\n }\n\n public tryGetStashedOpLocalMetadata(op: any): unknown {\n const type: string = op.type;\n if (this.messageHandlers.has(type)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.messageHandlers.get(type)!.getStashedOpLocalMetadata(op as IMapOperation);\n }\n throw new Error(\"no apply stashed op handler\");\n }\n\n /**\n * Process the given op if a handler is registered.\n * @param message - The message to process\n * @param local - Whether the message originated from the local client\n * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n * For messages from a remote client, this will be undefined.\n * @returns True if the operation was processed, false otherwise.\n */\n public tryProcessMessage(\n op: IMapOperation,\n local: boolean,\n message: ISequencedDocumentMessage | undefined,\n localOpMetadata: unknown,\n ): boolean {\n // track the seq of every incoming message, so we can detect if any\n // changes happened during a resubmit\n this.lastProcessedSeq = message.sequenceNumber;\n const handler = this.messageHandlers.get(op.type);\n if (handler !== undefined) {\n handler.process(op, local, message, localOpMetadata as IMapMessageLocalMetadata);\n return true;\n }\n return false;\n }\n\n /**\n * Initializes a default ValueType at the provided key.\n * Should be used when a map operation incurs creation.\n * @param key - The key being initialized\n * @param local - Whether the message originated from the local client\n */\n private createCore(key: string, local: boolean): ValueTypeLocalValue<T> {\n const localValue = new ValueTypeLocalValue(\n this.type.factory.load(this.makeMapValueOpEmitter(key), undefined),\n this.type,\n );\n const previousValue = this.data.get(key);\n this.data.set(key, localValue);\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"create\", event, local, this.eventEmitter);\n return localValue;\n }\n\n /**\n * The remote ISerializableValue we're receiving (either as a result of a load or an incoming set op) will\n * have the information we need to create a real object, but will not be the real object yet. For example,\n * we might know it's a map and the map's ID but not have the actual map or its data yet. makeLocal's\n * job is to convert that information into a real object for local usage.\n * @param key - The key that the caller intends to store the local value into (used for ops later). But\n * doesn't actually store the local value into that key. So better not lie!\n * @param serializable - The remote information that we can convert into a real object\n * @returns The local value that was produced\n */\n private makeLocal(key: string, serializable: ISerializableValue): ValueTypeLocalValue<T> {\n assert(serializable.type !== ValueType[ValueType.Plain] && serializable.type !== ValueType[ValueType.Shared],\n 0x2e1 /* \"Support for plain value types removed.\" */);\n\n serializable.value = parseHandles(serializable.value, this.serializer);\n const localValue = this.type.factory.load(\n this.makeMapValueOpEmitter(key),\n serializable.value,\n );\n return new ValueTypeLocalValue(localValue, this.type);\n }\n\n /**\n * Get the message handlers for the map.\n * @returns A map of string op names to IMapMessageHandlers for those ops\n */\n private getMessageHandlers() {\n const messageHandlers = new Map<string, IMapMessageHandler>();\n // Ops with type \"act\" describe actions taken by custom value type handlers of whatever item is\n // being addressed. These custom handlers can be retrieved from the ValueTypeLocalValue which has\n // stashed its valueType (and therefore its handlers). We also emit a valueChanged for anyone\n // watching for manipulations of that item.\n messageHandlers.set(\n \"act\",\n {\n process: (op: IMapValueTypeOperation, local, message, localOpMetadata) => {\n const localValue = this.data.get(op.key) ?? this.createCore(op.key, local);\n const handler = localValue.getOpHandler(op.value.opName);\n const previousValue = localValue.value;\n const translatedValue = parseHandles(\n op.value.value,\n this.serializer);\n handler.process(previousValue, translatedValue, local, message);\n const event: IValueChanged = { key: op.key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, local, message, this.eventEmitter);\n },\n submit: (op: IMapValueTypeOperation) => {\n this.submitMessage(\n op,\n { lastProcessedSeq: this.lastProcessedSeq },\n );\n },\n getStashedOpLocalMetadata: (op: IMapValueTypeOperation) => {\n assert(false, 0x016 /* \"apply stashed op not implemented for custom value type ops\" */);\n },\n });\n\n return messageHandlers;\n }\n\n /**\n * Create an emitter for a value type to emit ops from the given key.\n * @alpha\n * @param key - The key of the map that the value type will be stored on\n * @returns A value op emitter for the given key\n */\n private makeMapValueOpEmitter(key: string): IValueOpEmitter {\n const emit = (opName: string, previousValue: any, params: any) => {\n const translatedParams = makeHandlesSerializable(\n params,\n this.serializer,\n this.handle);\n\n const op: IMapValueTypeOperation = {\n key,\n type: \"act\",\n value: {\n opName,\n value: translatedParams,\n },\n };\n // Send the localOpMetadata as undefined because we don't care about the ack.\n this.submitMessage(op, { lastProcessedSeq: this.lastProcessedSeq });\n\n const event: IValueChanged = { key, previousValue };\n this.eventEmitter.emit(\"valueChanged\", event, true, null, this.eventEmitter);\n };\n\n return { emit };\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import {
|
|
6
|
+
import { ISharedObjectEvents } from "@fluidframework/shared-object-base";
|
|
7
7
|
import { IEventThisPlaceHolder } from "@fluidframework/common-definitions";
|
|
8
8
|
/**
|
|
9
9
|
* Type of "valueChanged" event parameter.
|
|
@@ -89,61 +89,19 @@ export interface IValueType<T> {
|
|
|
89
89
|
*/
|
|
90
90
|
ops: Map<string, IValueOperation<T>>;
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
* Container types that are able to create value types as contained values.
|
|
94
|
-
*/
|
|
95
|
-
export interface IValueTypeCreator {
|
|
96
|
-
/**
|
|
97
|
-
* Create a new value type at the given key.
|
|
98
|
-
* @param key - Key to create the value type at
|
|
99
|
-
* @param type - Type of the value type to create
|
|
100
|
-
* @param params - Initialization params for the value type
|
|
101
|
-
* @alpha
|
|
102
|
-
*/
|
|
103
|
-
createValueType(key: string, type: string, params: any): this;
|
|
104
|
-
}
|
|
105
|
-
export interface ISharedMapEvents extends ISharedObjectEvents {
|
|
92
|
+
export interface ISharedDefaultMapEvents extends ISharedObjectEvents {
|
|
106
93
|
(event: "valueChanged" | "create", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
107
|
-
(event: "clear", listener: (local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Shared map interface
|
|
111
|
-
*/
|
|
112
|
-
export interface ISharedMap extends ISharedObject<ISharedMapEvents>, Map<string, any> {
|
|
113
|
-
/**
|
|
114
|
-
* Retrieves the given key from the map.
|
|
115
|
-
* @param key - Key to retrieve from
|
|
116
|
-
* @returns The stored value, or undefined if the key is not set
|
|
117
|
-
*/
|
|
118
|
-
get<T = any>(key: string): T | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* A form of get except it will only resolve the promise once the key exists in the map.
|
|
121
|
-
* @param key - Key to retrieve from
|
|
122
|
-
* @returns The stored value once available
|
|
123
|
-
*/
|
|
124
|
-
wait<T = any>(key: string): Promise<T>;
|
|
125
|
-
/**
|
|
126
|
-
* Sets the value stored at key to the provided value.
|
|
127
|
-
* @param key - Key to set at
|
|
128
|
-
* @param value - Value to set
|
|
129
|
-
* @returns The ISharedMap itself
|
|
130
|
-
*/
|
|
131
|
-
set<T = any>(key: string, value: T): this;
|
|
132
94
|
}
|
|
133
95
|
/**
|
|
134
|
-
* The _ready-for-serialization_ format of values contained in DDS contents.
|
|
96
|
+
* The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use
|
|
135
97
|
* ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.
|
|
136
98
|
* Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with
|
|
137
|
-
* the _in-memory representation_ of the value instead).
|
|
138
|
-
* JSON.stringify and comes out of JSON.parse.
|
|
99
|
+
* the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to
|
|
100
|
+
* JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)
|
|
139
101
|
* and ops (set).
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* If type is a value type then it must be amongst the types registered via registerValueType or we won't know how
|
|
144
|
-
* to serialize/deserialize it (we rely on its factory via .load() and .store()). Its value will be type-dependent.
|
|
145
|
-
* If type is Shared, then the in-memory value will just be a reference to the SharedObject. Its value will be a
|
|
146
|
-
* channel ID. This type is legacy and deprecated.
|
|
102
|
+
*
|
|
103
|
+
* The DefaultMap impelmentation for sequence has been specialized to only support a single ValueType, which serializes
|
|
104
|
+
* and deserializes via .store() and .load().
|
|
147
105
|
*/
|
|
148
106
|
export interface ISerializableValue {
|
|
149
107
|
/**
|
|
@@ -184,4 +142,4 @@ export interface IValueTypeOperationValue {
|
|
|
184
142
|
*/
|
|
185
143
|
value: any;
|
|
186
144
|
}
|
|
187
|
-
//# sourceMappingURL=
|
|
145
|
+
//# sourceMappingURL=default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Ae,CAAC,CAAC,CAAC,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAChE,CAAC,KAAK,EAAE,cAAc,GAAG,QAAQ,EAAE,QAAQ,EAAE,CACzC,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,KAAK,IAAI,OAAE;CAC/C;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,GAAG,CAAC;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMapInterfaces.js","sourceRoot":"","sources":["../src/defaultMapInterfaces.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 { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ISharedObjectEvents } from \"@fluidframework/shared-object-base\";\nimport { IEventThisPlaceHolder } from \"@fluidframework/common-definitions\";\n\n/**\n * Type of \"valueChanged\" event parameter.\n */\nexport interface IValueChanged {\n /**\n * The key storing the value that changed.\n */\n key: string;\n\n /**\n * The value that was stored at the key prior to the change.\n */\n previousValue: any;\n}\n\n/**\n * Value types are given an IValueOpEmitter to emit their ops through the container type that holds them.\n */\nexport interface IValueOpEmitter {\n /**\n * Called by the value type to emit a value type operation through the container type holding it.\n * @param opName - Name of the emitted operation\n * @param previousValue - JSONable previous value as defined by the value type\n * @param params - JSONable params for the operation as defined by the value type\n * @alpha\n */\n emit(opName: string, previousValue: any, params: any): void;\n}\n\n/**\n * A value factory is used to serialize/deserialize value types to a map\n * @alpha\n */\nexport interface IValueFactory<T> {\n /**\n * Create a new value type. Used both in creation of new value types, as well as in loading existing ones\n * from remote.\n * @param emitter - Emitter object that the created value type will use to emit operations\n * @param raw - Initialization parameters as defined by the value type\n * @returns The new value type\n * @alpha\n */\n load(emitter: IValueOpEmitter, raw: any): T;\n\n /**\n * Given a value type, provides a JSONable form of its data to be used for snapshotting. This data must be\n * loadable using the load method of its factory.\n * @param value - The value type to serialize\n * @returns The JSONable form of the value type\n * @alpha\n */\n store(value: T): any;\n}\n\n/**\n * Defines an operation that a value type is able to handle.\n * @alpha\n */\nexport interface IValueOperation<T> {\n /**\n * Performs the actual processing on the incoming operation.\n * @param value - The current value stored at the given key, which should be the value type\n * @param params - The params on the incoming operation\n * @param local - Whether the operation originated from this client\n * @param message - The operation itself\n * @alpha\n */\n process(\n value: T,\n params: any,\n local: boolean,\n message: ISequencedDocumentMessage | undefined\n );\n}\n\n/**\n * Defines a value type that can be registered on a container type.\n */\nexport interface IValueType<T> {\n /**\n * Name of the value type.\n * @alpha\n */\n name: string;\n\n /**\n * Factory method used to convert to/from a JSON form of the type.\n * @alpha\n */\n factory: IValueFactory<T>;\n\n /**\n * Operations that can be applied to the value type.\n * @alpha\n */\n ops: Map<string, IValueOperation<T>>;\n}\n\nexport interface ISharedDefaultMapEvents extends ISharedObjectEvents {\n (event: \"valueChanged\" | \"create\", listener: (\n changed: IValueChanged,\n local: boolean,\n target: IEventThisPlaceHolder) => void);\n}\n\n/**\n * The _ready-for-serialization_ format of values contained in DDS contents. This allows us to use\n * ISerializableValue.type to understand whether they're storing a Plain JS object, a SharedObject, or a value type.\n * Note that the in-memory equivalent of ISerializableValue is ILocalValue (similarly holding a type, but with\n * the _in-memory representation_ of the value instead). An ISerializableValue is what gets passed to\n * JSON.stringify and comes out of JSON.parse. This format is used both for snapshots (loadCore/populate)\n * and ops (set).\n *\n * The DefaultMap impelmentation for sequence has been specialized to only support a single ValueType, which serializes\n * and deserializes via .store() and .load().\n */\nexport interface ISerializableValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * The JSONable representation of the value.\n */\n value: any;\n}\n\nexport interface ISerializedValue {\n /**\n * A type annotation to help indicate how the value serializes.\n */\n type: string;\n\n /**\n * String representation of the value.\n */\n value: string | undefined;\n}\n\n/**\n * ValueTypes handle ops slightly differently from SharedObjects or plain JS objects. Since the Map/Directory doesn't\n * know how to handle the ValueType's ops, those ops are instead passed along to the ValueType for processing.\n * IValueTypeOperationValue is that passed-along op. The opName on it is the ValueType-specific operation and the\n * value is whatever params the ValueType needs to complete that operation. Similar to ISerializableValue, it is\n * serializable via JSON.stringify/parse but differs in that it has no equivalency with an in-memory value - rather\n * it just describes an operation to be applied to an already-in-memory value.\n * @alpha\n */\nexport interface IValueTypeOperationValue {\n /**\n * The name of the operation.\n */\n opName: string;\n\n /**\n * The payload that is submitted along with the operation.\n */\n value: any;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export { DeserializeCallback, IIntervalCollectionEvent, IIntervalHelpers, Interval, IntervalCollection, IntervalCollectionIterator, IntervalType, ISerializableInterval, ISerializedInterval, SequenceInterval, } from "./intervalCollection";
|
|
6
|
-
export { IValueOpEmitter, } from "./
|
|
6
|
+
export { IValueOpEmitter, } from "./defaultMapInterfaces";
|
|
7
7
|
export * from "./sharedString";
|
|
8
8
|
export * from "./sequence";
|
|
9
9
|
export * from "./sequenceFactory";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,eAAe,GAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,eAAe,GAClB,MAAM,wBAAwB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIH,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EAGZ,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAI9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n} from \"./intervalCollection\";\nexport {\n IValueOpEmitter,\n} from \"./
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIH,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EAGZ,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAI9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n DeserializeCallback,\n IIntervalCollectionEvent,\n IIntervalHelpers,\n Interval,\n IntervalCollection,\n IntervalCollectionIterator,\n IntervalType,\n ISerializableInterval,\n ISerializedInterval,\n SequenceInterval,\n} from \"./intervalCollection\";\nexport {\n IValueOpEmitter,\n} from \"./defaultMapInterfaces\";\nexport * from \"./sharedString\";\nexport * from \"./sequence\";\nexport * from \"./sequenceFactory\";\nexport * from \"./sequenceDeltaEvent\";\nexport * from \"./sharedSequence\";\nexport * from \"./sharedObjectSequence\";\nexport * from \"./sharedNumberSequence\";\nexport * from \"./sparsematrix\";\nexport * from \"./sharedIntervalCollection\";\n"]}
|
|
@@ -6,7 +6,7 @@ import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
|
6
6
|
import { IEvent } from "@fluidframework/common-definitions";
|
|
7
7
|
import { Client, ICombiningOp, IInterval, IntervalConflictResolver, LocalReference, PropertiesManager, PropertySet } from "@fluidframework/merge-tree";
|
|
8
8
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./
|
|
9
|
+
import { IValueFactory, IValueOpEmitter, IValueOperation, IValueType } from "./defaultMapInterfaces";
|
|
10
10
|
export declare enum IntervalType {
|
|
11
11
|
Simple = 0,
|
|
12
12
|
Nest = 1,
|
|
@@ -139,8 +139,8 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
139
139
|
private localCollection;
|
|
140
140
|
private onDeserialize;
|
|
141
141
|
private client;
|
|
142
|
-
private
|
|
143
|
-
private
|
|
142
|
+
private pendingChangesStart;
|
|
143
|
+
private pendingChangesEnd;
|
|
144
144
|
get attached(): boolean;
|
|
145
145
|
constructor(helpers: IIntervalHelpers<TInterval>, requiresClient: boolean, emitter: IValueOpEmitter, serializedIntervals: ISerializedInterval[]);
|
|
146
146
|
attachGraph(client: Client, label: string): void;
|
|
@@ -156,11 +156,20 @@ export declare class IntervalCollection<TInterval extends ISerializableInterval>
|
|
|
156
156
|
private removePendingChangeHelper;
|
|
157
157
|
private hasPendingChangeStart;
|
|
158
158
|
private hasPendingChangeEnd;
|
|
159
|
+
/** @deprecated - use ackChange */
|
|
159
160
|
changeInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
161
|
+
/** @internal */
|
|
162
|
+
ackChange(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
160
163
|
addConflictResolver(conflictResolver: IntervalConflictResolver<TInterval>): void;
|
|
161
164
|
attachDeserializer(onDeserialize: DeserializeCallback): void;
|
|
165
|
+
/** @deprecated - use ackAdd */
|
|
162
166
|
addInternal(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
167
|
+
/** @internal */
|
|
168
|
+
ackAdd(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): TInterval;
|
|
169
|
+
/** @deprecated - use ackDelete */
|
|
163
170
|
deleteInterval(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
171
|
+
/** @internal */
|
|
172
|
+
ackDelete(serializedInterval: ISerializedInterval, local: boolean, op: ISequencedDocumentMessage): void;
|
|
164
173
|
serializeInternal(): ISerializedInterval[];
|
|
165
174
|
[Symbol.iterator](): IntervalCollectionIterator<TInterval>;
|
|
166
175
|
CreateForwardIteratorWithStartPosition(startPosition: number): IntervalCollectionIterator<TInterval>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAEH,MAAM,EAGN,YAAY,EACZ,SAAS,EACT,wBAAwB,EAGxB,cAAc,EAEd,iBAAiB,EACjB,WAAW,EAKd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"intervalCollection.d.ts","sourceRoot":"","sources":["../src/intervalCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAEH,MAAM,EAGN,YAAY,EACZ,SAAS,EACT,wBAAwB,EAGxB,cAAc,EAEd,iBAAiB,EACjB,WAAW,EAKd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