@fluidframework/shared-object-base 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
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/.eslintrc.js +5 -7
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +148 -0
- package/README.md +22 -1
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/shared-object-base.api.md +165 -0
- package/dist/{handle.js → handle.cjs} +13 -8
- package/dist/handle.cjs.map +1 -0
- package/dist/handle.d.ts +12 -7
- package/dist/handle.d.ts.map +1 -1
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/{remoteObjectHandle.js → remoteObjectHandle.cjs} +15 -20
- package/dist/remoteObjectHandle.cjs.map +1 -0
- package/dist/remoteObjectHandle.d.ts +1 -3
- package/dist/remoteObjectHandle.d.ts.map +1 -1
- package/dist/{serializer.js → serializer.cjs} +14 -12
- package/dist/serializer.cjs.map +1 -0
- package/dist/serializer.d.ts +8 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/shared-object-base-alpha.d.ts +415 -0
- package/dist/shared-object-base-beta.d.ts +393 -0
- package/dist/shared-object-base-public.d.ts +393 -0
- package/dist/shared-object-base-untrimmed.d.ts +506 -0
- package/dist/{sharedObject.js → sharedObject.cjs} +71 -56
- package/dist/sharedObject.cjs.map +1 -0
- package/dist/sharedObject.d.ts +10 -13
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/{summarySerializer.js → summarySerializer.cjs} +3 -2
- package/dist/summarySerializer.cjs.map +1 -0
- package/dist/summarySerializer.d.ts +1 -0
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{types.js → types.cjs} +1 -1
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +24 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/{utils.js → utils.cjs} +6 -4
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/{valueType.js → valueType.cjs} +3 -2
- package/dist/valueType.cjs.map +1 -0
- package/dist/valueType.d.ts +1 -0
- package/dist/valueType.d.ts.map +1 -1
- package/lib/{handle.d.ts → handle.d.mts} +13 -8
- package/lib/handle.d.mts.map +1 -0
- package/lib/{handle.js → handle.mjs} +13 -8
- package/lib/handle.mjs.map +1 -0
- package/lib/index.d.mts +11 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +10 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{remoteObjectHandle.d.ts → remoteObjectHandle.d.mts} +1 -3
- package/lib/remoteObjectHandle.d.mts.map +1 -0
- package/lib/{remoteObjectHandle.js → remoteObjectHandle.mjs} +15 -20
- package/lib/remoteObjectHandle.mjs.map +1 -0
- package/lib/{serializer.d.ts → serializer.d.mts} +8 -0
- package/lib/serializer.d.mts.map +1 -0
- package/lib/{serializer.js → serializer.mjs} +14 -14
- package/lib/serializer.mjs.map +1 -0
- package/lib/shared-object-base-alpha.d.mts +415 -0
- package/lib/shared-object-base-beta.d.mts +393 -0
- package/lib/shared-object-base-public.d.mts +393 -0
- package/lib/shared-object-base-untrimmed.d.mts +506 -0
- package/lib/{sharedObject.d.ts → sharedObject.d.mts} +12 -15
- package/lib/sharedObject.d.mts.map +1 -0
- package/lib/{sharedObject.js → sharedObject.mjs} +66 -51
- package/lib/sharedObject.mjs.map +1 -0
- package/lib/{summarySerializer.d.ts → summarySerializer.d.mts} +2 -1
- package/lib/summarySerializer.d.mts.map +1 -0
- package/lib/{summarySerializer.js → summarySerializer.mjs} +3 -2
- package/lib/summarySerializer.mjs.map +1 -0
- package/lib/{types.d.ts → types.d.mts} +24 -2
- package/lib/types.d.mts.map +1 -0
- package/lib/{types.js → types.mjs} +1 -1
- package/lib/types.mjs.map +1 -0
- package/lib/{utils.d.ts → utils.d.mts} +5 -1
- package/lib/utils.d.mts.map +1 -0
- package/lib/{utils.js → utils.mjs} +6 -4
- package/lib/utils.mjs.map +1 -0
- package/lib/{valueType.d.ts → valueType.d.mts} +1 -0
- package/lib/{valueType.d.ts.map → valueType.d.mts.map} +1 -1
- package/lib/{valueType.js → valueType.mjs} +2 -1
- package/lib/valueType.mjs.map +1 -0
- package/package.json +102 -69
- package/prettier.config.cjs +8 -0
- package/src/handle.ts +38 -36
- package/src/index.ts +16 -6
- package/src/packageVersion.ts +1 -1
- package/src/remoteObjectHandle.ts +53 -58
- package/src/serializer.ts +190 -187
- package/src/sharedObject.ts +718 -642
- package/src/summarySerializer.ts +9 -8
- package/src/types.ts +56 -15
- package/src/utils.ts +24 -26
- package/src/valueType.ts +10 -9
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -12
- package/bench/src/index.ts +0 -68
- package/bench/src/util.ts +0 -56
- package/dist/handle.js.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/remoteObjectHandle.js.map +0 -1
- package/dist/serializer.js.map +0 -1
- package/dist/sharedObject.js.map +0 -1
- package/dist/summarySerializer.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/valueType.js.map +0 -1
- package/lib/handle.d.ts.map +0 -1
- package/lib/handle.js.map +0 -1
- package/lib/index.d.ts +0 -11
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -11
- package/lib/index.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/remoteObjectHandle.d.ts.map +0 -1
- package/lib/remoteObjectHandle.js.map +0 -1
- package/lib/serializer.d.ts.map +0 -1
- package/lib/serializer.js.map +0 -1
- package/lib/sharedObject.d.ts.map +0 -1
- package/lib/sharedObject.js.map +0 -1
- package/lib/summarySerializer.d.ts.map +0 -1
- package/lib/summarySerializer.js.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/valueType.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
|
@@ -6,18 +6,28 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SharedObject = exports.SharedObjectCore = void 0;
|
|
8
8
|
const uuid_1 = require("uuid");
|
|
9
|
-
const
|
|
9
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
10
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
11
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
11
12
|
const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const handle_1 = require("./handle");
|
|
16
|
-
const summarySerializer_1 = require("./summarySerializer");
|
|
13
|
+
const serializer_1 = require("./serializer.cjs");
|
|
14
|
+
const handle_1 = require("./handle.cjs");
|
|
15
|
+
const summarySerializer_1 = require("./summarySerializer.cjs");
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Base class from which all shared objects derive.
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
21
|
+
get IFluidLoadable() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Gets the connection state
|
|
26
|
+
* @returns The state of the connection
|
|
27
|
+
*/
|
|
28
|
+
get connected() {
|
|
29
|
+
return this._connected;
|
|
30
|
+
}
|
|
21
31
|
/**
|
|
22
32
|
* @param id - The id of the shared object
|
|
23
33
|
* @param runtime - The IFluidDataStoreRuntime which contains the shared object
|
|
@@ -36,14 +46,16 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
36
46
|
* True if the dds is bound to its parent.
|
|
37
47
|
*/
|
|
38
48
|
this._isBoundToContext = false;
|
|
39
|
-
(0,
|
|
49
|
+
(0, core_utils_1.assert)(!id.includes("/"), 0x304 /* Id cannot contain slashes */);
|
|
40
50
|
this.handle = new handle_1.SharedObjectHandle(this, id, runtime.IFluidHandleContext);
|
|
41
|
-
this.logger = telemetry_utils_1.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
this.logger = (0, telemetry_utils_1.createChildLogger)({
|
|
52
|
+
logger: runtime.logger,
|
|
53
|
+
properties: {
|
|
54
|
+
all: {
|
|
55
|
+
sharedObjectId: (0, uuid_1.v4)(),
|
|
56
|
+
...(0, telemetry_utils_1.tagCodeArtifacts)({
|
|
57
|
+
ddsType: this.attributes.type,
|
|
58
|
+
}),
|
|
47
59
|
},
|
|
48
60
|
},
|
|
49
61
|
});
|
|
@@ -51,14 +63,6 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
51
63
|
[this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();
|
|
52
64
|
this.attachListeners();
|
|
53
65
|
}
|
|
54
|
-
get IFluidLoadable() { return this; }
|
|
55
|
-
/**
|
|
56
|
-
* Gets the connection state
|
|
57
|
-
* @returns The state of the connection
|
|
58
|
-
*/
|
|
59
|
-
get connected() {
|
|
60
|
-
return this._connected;
|
|
61
|
-
}
|
|
62
66
|
/**
|
|
63
67
|
* This function is only supposed to be called from SharedObjectCore's constructor and
|
|
64
68
|
* depends on a few things being set already. assert() calls make sure of it.
|
|
@@ -66,19 +70,18 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
66
70
|
* to variables to avoid complaints from TypeScript.
|
|
67
71
|
*/
|
|
68
72
|
setUpSampledTelemetryHelpers() {
|
|
69
|
-
|
|
70
|
-
(0, common_utils_1.assert)(this.mc !== undefined && this.logger !== undefined, "this.mc and/or this.logger has not been set");
|
|
73
|
+
(0, core_utils_1.assert)(this.mc !== undefined && this.logger !== undefined, 0x349 /* this.mc and/or this.logger has not been set */);
|
|
71
74
|
const opProcessingHelper = new telemetry_utils_1.SampledTelemetryHelper({
|
|
72
75
|
eventName: "ddsOpProcessing",
|
|
73
76
|
category: "performance",
|
|
74
|
-
}, this.logger,
|
|
77
|
+
}, this.logger, this.mc.config.getNumber("Fluid.SharedObject.OpProcessingTelemetrySampling") ?? 1000, true, new Map([
|
|
75
78
|
["local", { localOp: true }],
|
|
76
79
|
["remote", { localOp: false }],
|
|
77
80
|
]));
|
|
78
81
|
const callbacksHelper = new telemetry_utils_1.SampledTelemetryHelper({
|
|
79
82
|
eventName: "ddsEventCallbacks",
|
|
80
83
|
category: "performance",
|
|
81
|
-
}, this.logger,
|
|
84
|
+
}, this.logger, this.mc.config.getNumber("Fluid.SharedObject.DdsCallbacksTelemetrySampling") ?? 1000, true);
|
|
82
85
|
this.runtime.once("dispose", () => {
|
|
83
86
|
this.callbacksHelper.dispose();
|
|
84
87
|
this.opProcessingHelper.dispose();
|
|
@@ -114,7 +117,7 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
114
117
|
* allow processing of ops or local changes, which very quickly results in container closure.
|
|
115
118
|
*/
|
|
116
119
|
eventListenerErrorHandler(event, e) {
|
|
117
|
-
const error =
|
|
120
|
+
const error = telemetry_utils_1.DataProcessingError.wrapIfUnrecognized(e, "SharedObjectEventListenerException");
|
|
118
121
|
error.addTelemetryProperties({ emittedEventName: String(event) });
|
|
119
122
|
this.closeWithError(error);
|
|
120
123
|
throw error;
|
|
@@ -179,10 +182,9 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
179
182
|
* @param decodedHandle - The handle of the Fluid object that is decoded.
|
|
180
183
|
*/
|
|
181
184
|
handleDecoded(decodedHandle) {
|
|
182
|
-
var _a, _b, _c;
|
|
183
185
|
if (this.isAttached()) {
|
|
184
186
|
// This represents an outbound reference from this object to the node represented by decodedHandle.
|
|
185
|
-
|
|
187
|
+
this.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
/**
|
|
@@ -248,8 +250,7 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
248
250
|
async newAckBasedPromise(executor) {
|
|
249
251
|
let rejectBecauseDispose;
|
|
250
252
|
return new Promise((resolve, reject) => {
|
|
251
|
-
rejectBecauseDispose =
|
|
252
|
-
() => reject(new Error("FluidDataStoreRuntime disposed while this ack-based Promise was pending"));
|
|
253
|
+
rejectBecauseDispose = () => reject(new Error("FluidDataStoreRuntime disposed while this ack-based Promise was pending"));
|
|
253
254
|
if (this.runtime.disposed) {
|
|
254
255
|
rejectBecauseDispose();
|
|
255
256
|
return;
|
|
@@ -263,7 +264,7 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
263
264
|
}
|
|
264
265
|
attachDeltaHandler() {
|
|
265
266
|
// Services should already be there in case we are attaching delta handler.
|
|
266
|
-
(0,
|
|
267
|
+
(0, core_utils_1.assert)(this.services !== undefined, 0x07a /* "Services should be there to attach delta handler" */);
|
|
267
268
|
this._isBoundToContext = true;
|
|
268
269
|
// Allows objects to do any custom processing if it is attached.
|
|
269
270
|
this.didAttach();
|
|
@@ -324,7 +325,9 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
324
325
|
process(message, local, localOpMetadata) {
|
|
325
326
|
this.verifyNotClosed(); // This will result in container closure.
|
|
326
327
|
this.emitInternal("pre-op", message, local, this);
|
|
327
|
-
this.opProcessingHelper.measure(() => {
|
|
328
|
+
this.opProcessingHelper.measure(() => {
|
|
329
|
+
this.processCore(message, local, localOpMetadata);
|
|
330
|
+
}, local ? "local" : "remote");
|
|
328
331
|
this.emitInternal("op", message, local, this);
|
|
329
332
|
}
|
|
330
333
|
/**
|
|
@@ -348,15 +351,26 @@ class SharedObjectCore extends telemetry_utils_1.EventEmitterWithErrorHandling {
|
|
|
348
351
|
* attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events
|
|
349
352
|
* which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the
|
|
350
353
|
* future.
|
|
351
|
-
*
|
|
352
|
-
* @internal
|
|
353
|
-
*
|
|
354
354
|
* @param event - The event to emit.
|
|
355
355
|
* @param args - Arguments to pass to the event listeners.
|
|
356
356
|
* @returns `true` if the event had listeners, `false` otherwise.
|
|
357
357
|
*/
|
|
358
358
|
emit(event, ...args) {
|
|
359
|
-
return this.callbacksHelper.measure(() =>
|
|
359
|
+
return this.callbacksHelper.measure(() => {
|
|
360
|
+
// Creating ops while handling a DDS event can lead
|
|
361
|
+
// to undefined behavior and events observed in the wrong order.
|
|
362
|
+
// For example, we have two callbacks registered for a DDS, A and B.
|
|
363
|
+
// Then if on change #1 callback A creates change #2, the invocation flow will be:
|
|
364
|
+
//
|
|
365
|
+
// A because of #1
|
|
366
|
+
// A because of #2
|
|
367
|
+
// B because of #2
|
|
368
|
+
// B because of #1
|
|
369
|
+
//
|
|
370
|
+
// The runtime must enforce op coherence by not allowing any ops to be created during
|
|
371
|
+
// the event handler
|
|
372
|
+
return this.runtime.ensureNoDataModelChanges(() => super.emit(event, ...args));
|
|
373
|
+
});
|
|
360
374
|
}
|
|
361
375
|
/**
|
|
362
376
|
* Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement
|
|
@@ -373,8 +387,20 @@ exports.SharedObjectCore = SharedObjectCore;
|
|
|
373
387
|
/**
|
|
374
388
|
* SharedObject with simplified, synchronous summarization and GC.
|
|
375
389
|
* DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.
|
|
390
|
+
* @public
|
|
376
391
|
*/
|
|
377
392
|
class SharedObject extends SharedObjectCore {
|
|
393
|
+
get serializer() {
|
|
394
|
+
/**
|
|
395
|
+
* During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These
|
|
396
|
+
* handles represent references to other Fluid objects.
|
|
397
|
+
*
|
|
398
|
+
* This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content
|
|
399
|
+
* in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.
|
|
400
|
+
*/
|
|
401
|
+
(0, core_utils_1.assert)(!this._isGCing, 0x075 /* "SummarySerializer should be used for serializing data during summary." */);
|
|
402
|
+
return this._serializer;
|
|
403
|
+
}
|
|
378
404
|
/**
|
|
379
405
|
* @param id - The id of the shared object
|
|
380
406
|
* @param runtime - The IFluidDataStoreRuntime which contains the shared object
|
|
@@ -389,17 +415,6 @@ class SharedObject extends SharedObjectCore {
|
|
|
389
415
|
this._isGCing = false;
|
|
390
416
|
this._serializer = new serializer_1.FluidSerializer(this.runtime.channelsRoutingContext, (handle) => this.handleDecoded(handle));
|
|
391
417
|
}
|
|
392
|
-
get serializer() {
|
|
393
|
-
/**
|
|
394
|
-
* During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These
|
|
395
|
-
* handles represent references to other Fluid objects.
|
|
396
|
-
*
|
|
397
|
-
* This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content
|
|
398
|
-
* in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.
|
|
399
|
-
*/
|
|
400
|
-
(0, common_utils_1.assert)(!this._isGCing, 0x075 /* "SummarySerializer should be used for serializing data during summary." */);
|
|
401
|
-
return this._serializer;
|
|
402
|
-
}
|
|
403
418
|
/**
|
|
404
419
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
|
|
405
420
|
*/
|
|
@@ -412,8 +427,8 @@ class SharedObject extends SharedObjectCore {
|
|
|
412
427
|
/**
|
|
413
428
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
|
|
414
429
|
*/
|
|
415
|
-
async summarize(fullTree = false, trackState = false, telemetryContext) {
|
|
416
|
-
const result = this.summarizeCore(this.serializer, telemetryContext);
|
|
430
|
+
async summarize(fullTree = false, trackState = false, telemetryContext, incrementalSummaryContext) {
|
|
431
|
+
const result = this.summarizeCore(this.serializer, telemetryContext, incrementalSummaryContext);
|
|
417
432
|
this.incrementTelemetryMetric(runtime_definitions_1.blobCountPropertyName, result.stats.blobNodeCount, telemetryContext);
|
|
418
433
|
this.incrementTelemetryMetric(runtime_definitions_1.totalBlobSizePropertyName, result.stats.totalBlobSize, telemetryContext);
|
|
419
434
|
return result;
|
|
@@ -424,7 +439,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
424
439
|
getGCData(fullGC = false) {
|
|
425
440
|
// Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles
|
|
426
441
|
// in this object's data.
|
|
427
|
-
(0,
|
|
442
|
+
(0, core_utils_1.assert)(!this._isGCing, 0x078 /* "Possible re-entrancy! Summary should not already be in progress." */);
|
|
428
443
|
this._isGCing = true;
|
|
429
444
|
let gcData;
|
|
430
445
|
try {
|
|
@@ -433,7 +448,7 @@ class SharedObject extends SharedObjectCore {
|
|
|
433
448
|
// The GC data for this shared object contains a single GC node. The outbound routes of this node are the
|
|
434
449
|
// routes of handles serialized during summarization.
|
|
435
450
|
gcData = { gcNodes: { "/": serializer.getSerializedRoutes() } };
|
|
436
|
-
(0,
|
|
451
|
+
(0, core_utils_1.assert)(this._isGCing, 0x079 /* "Possible re-entrancy! Summary should have been in progress." */);
|
|
437
452
|
}
|
|
438
453
|
finally {
|
|
439
454
|
this._isGCing = false;
|
|
@@ -451,10 +466,10 @@ class SharedObject extends SharedObjectCore {
|
|
|
451
466
|
this.summarizeCore(serializer);
|
|
452
467
|
}
|
|
453
468
|
incrementTelemetryMetric(propertyName, incrementBy, telemetryContext) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
telemetryContext
|
|
469
|
+
const prevTotal = (telemetryContext?.get(this.telemetryContextPrefix, propertyName) ??
|
|
470
|
+
0);
|
|
471
|
+
telemetryContext?.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);
|
|
457
472
|
}
|
|
458
473
|
}
|
|
459
474
|
exports.SharedObject = SharedObject;
|
|
460
|
-
//# sourceMappingURL=sharedObject.
|
|
475
|
+
//# sourceMappingURL=sharedObject.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharedObject.cjs","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAElC,qEASyC;AACzC,2DAAoD;AAEpD,iFAAoE;AAQpE,6EAO6C;AAC7C,iDAAiE;AACjE,yCAA8C;AAC9C,+DAAwD;AAGxD;;;GAGG;AACH,MAAsB,gBACrB,SAAQ,+CAAqC;IAG7C,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;IAoCD;;;OAGG;IACH,IAAW,SAAS;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,YACQ,EAAU,EACP,OAA+B,EACzB,UAA8B;QAE9C,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAJnF,OAAE,GAAF,EAAE,CAAQ;QACP,YAAO,GAAP,OAAO,CAAwB;QACzB,eAAU,GAAV,UAAU,CAAoB;QApC/C;;WAEG;QACK,eAAU,GAAG,KAAK,CAAC;QAO3B;;WAEG;QACK,sBAAiB,GAAY,KAAK,CAAC;QA2B1C,IAAA,mBAAM,EAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAA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E,EAAE,GAAG,EAAE,UAAU,CAAC,mBAAmB,EAAE,EAAE,EAAE,CAAC;YAChE,IAAA,mBAAM,EACL,IAAI,CAAC,QAAQ,EACb,KAAK,CAAC,mEAAmE,CACzE,CAAC;SACF;gBAAS;YACT,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACtB;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;OAGG;IACO,iBAAiB,CAAC,UAA4B;QACvD,wGAAwG;QACxG,2GAA2G;QAC3G,+DAA+D;QAC/D,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAYO,wBAAwB,CAC/B,YAAoB,EACpB,WAAmB,EACnB,gBAAoC;QAEpC,MAAM,SAAS,GAAG,CAAC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC;YAClF,CAAC,CAAW,CAAC;QACd,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;IAC3F,CAAC;CACD;AA/JD,oCA+JC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { IFluidHandle, ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport {\n\tITelemetryLoggerExt,\n\tcreateChildLogger,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tSampledTelemetryHelper,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIGarbageCollectionData,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\tIExperimentalIncrementalSummaryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { FluidSerializer, IFluidSerializer } from \"./serializer\";\nimport { SharedObjectHandle } from \"./handle\";\nimport { SummarySerializer } from \"./summarySerializer\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types\";\n\n/**\n * Base class from which all shared objects derive.\n * @public\n */\nexport abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandle;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tpublic id: string,\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime.IFluidHandleContext);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\t[this.opProcessingHelper, this.callbacksHelper] = this.setUpSampledTelemetryHelpers();\n\n\t\tthis.attachListeners();\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): SampledTelemetryHelper[] {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn [opProcessingHelper, callbacksHelper];\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: any) {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed() {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate attachListeners() {\n\t\t// Only listen to these events if not attached.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.runtime.once(\"attaching\", () => {\n\t\t\t\t// Calling this will let the dds to do any custom processing based on attached\n\t\t\t\t// like starting generating ops.\n\t\t\t\tthis.didAttach();\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\tthis.services = services;\n\t\t}\n\t\tawait this.loadCore(services.objectStorage);\n\t\tif (this.runtime.attachState !== AttachState.Detached) {\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\tif (this._isBoundToContext) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._isBoundToContext = true;\n\n\t\tthis.runtime.bindChannel(this);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices) {\n\t\tthis.services = services;\n\t\tthis.attachDeltaHandler();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this.services !== undefined && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference\n\t * to another object in the container.\n\t * @param decodedHandle - The handle of the Fluid object that is decoded.\n\t */\n\tprotected handleDecoded(decodedHandle: IFluidHandle) {\n\t\tif (this.isAttached()) {\n\t\t\t// This represents an outbound reference from this object to the node represented by decodedHandle.\n\t\t\tthis.services?.deltaConnection.addedGCOutboundReference?.(this.handle, decodedHandle);\n\t\t}\n\t}\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore() {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach() {\n\t\treturn;\n\t}\n\n\t/**\n\t * Derived classes must override this to do custom processing on a remote message.\n\t * @param message - The message to process\n\t * @param local - True if the shared object is local\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected abstract processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t);\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected abstract onDisconnect();\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(content, localOpMetadata);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect() {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\",\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler() {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\tthis._isBoundToContext = true;\n\t\t// Allows objects to do any custom processing if it is attached.\n\t\tthis.didAttach();\n\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocess: (\n\t\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: unknown,\n\t\t\t) => {\n\t\t\t\tthis.process(message, local, localOpMetadata);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: any): unknown => {\n\t\t\t\treturn this.applyStashedOp(content);\n\t\t\t},\n\t\t\trollback: (content: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t});\n\n\t\t// Trigger initial state\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.setConnectionState(this.services.deltaConnection.connected);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean) {\n\t\tif (this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (!connected) {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t} else {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t}\n\t}\n\n\t/**\n\t * Handles a message being received from the remote delta server.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprivate process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\t\tthis.emitInternal(\"pre-op\", message, local, this);\n\n\t\tthis.opProcessingHelper.measure(\n\t\t\t() => {\n\t\t\t\tthis.processCore(message, local, localOpMetadata);\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\n\t\tthis.emitInternal(\"op\", message, local, this);\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprivate reSubmit(content: any, localOpMetadata: unknown) {\n\t\tthis.reSubmitCore(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown) {\n\t\tthrow new Error(\"rollback not supported\");\n\t}\n\n\t/**\n\t * Apply changes from an op. Used when rehydrating an attached container\n\t * with pending changes. This prepares the SharedObject for seeing an ACK\n\t * for the op or resubmitting the op upon reconnection.\n\t * @param content - Contents of a stashed op.\n\t * @returns localMetadata of the op, to be passed to process() or resubmit()\n\t * when the op is ACKed or resubmitted, respectively\n\t */\n\tprotected abstract applyStashedOp(content: any): unknown;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// Creating ops while handling a DDS event can lead\n\t\t\t// to undefined behavior and events observed in the wrong order.\n\t\t\t// For example, we have two callbacks registered for a DDS, A and B.\n\t\t\t// Then if on change #1 callback A creates change #2, the invocation flow will be:\n\t\t\t//\n\t\t\t// A because of #1\n\t\t\t// A because of #2\n\t\t\t// B because of #2\n\t\t\t// B because of #1\n\t\t\t//\n\t\t\t// The runtime must enforce op coherence by not allowing any ops to be created during\n\t\t\t// the event handler\n\t\t\treturn this.runtime.ensureNoDataModelChanges(() => super.emit(event, ...args));\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n}\n\n/**\n * SharedObject with simplified, synchronous summarization and GC.\n * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.\n * @public\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(\n\t\t\tthis.runtime.channelsRoutingContext,\n\t\t\t(handle: IFluidHandle) => this.handleDecoded(handle),\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(this.serializer, telemetryContext);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles\n\t\t// in this object's data.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst serializer = new SummarySerializer(\n\t\t\t\tthis.runtime.channelsRoutingContext,\n\t\t\t\t(handle: IFluidHandle) => this.handleDecoded(handle),\n\t\t\t);\n\t\t\tthis.processGCDataCore(serializer);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": serializer.getSerializedRoutes() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer) {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t) {\n\t\tconst prevTotal = (telemetryContext?.get(this.telemetryContextPrefix, propertyName) ??\n\t\t\t0) as number;\n\t\ttelemetryContext?.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t}\n}\n"]}
|
package/dist/sharedObject.d.ts
CHANGED
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
6
|
-
import { EventEmitterEventType } from "@fluidframework/common-utils";
|
|
7
5
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ITelemetryLoggerExt, EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils";
|
|
7
|
+
import { EventEmitterEventType } from "@fluid-internal/client-utils";
|
|
8
8
|
import { IChannelAttributes, IFluidDataStoreRuntime, IChannelStorageService, IChannelServices } from "@fluidframework/datastore-definitions";
|
|
9
9
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
10
|
-
import { IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
11
|
-
import { EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils";
|
|
10
|
+
import { IGarbageCollectionData, ISummaryTreeWithStats, ITelemetryContext, IExperimentalIncrementalSummaryContext } from "@fluidframework/runtime-definitions";
|
|
12
11
|
import { IFluidSerializer } from "./serializer";
|
|
13
|
-
import { SummarySerializer } from "./summarySerializer";
|
|
14
12
|
import { ISharedObject, ISharedObjectEvents } from "./types";
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
14
|
+
* Base class from which all shared objects derive.
|
|
15
|
+
* @public
|
|
17
16
|
*/
|
|
18
17
|
export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
|
|
19
18
|
id: string;
|
|
@@ -29,7 +28,7 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
29
28
|
/**
|
|
30
29
|
* Telemetry logger for the shared object
|
|
31
30
|
*/
|
|
32
|
-
protected readonly logger:
|
|
31
|
+
protected readonly logger: ITelemetryLoggerExt;
|
|
33
32
|
private readonly mc;
|
|
34
33
|
/**
|
|
35
34
|
* Connection state
|
|
@@ -228,9 +227,6 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
228
227
|
* attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events
|
|
229
228
|
* which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the
|
|
230
229
|
* future.
|
|
231
|
-
*
|
|
232
|
-
* @internal
|
|
233
|
-
*
|
|
234
230
|
* @param event - The event to emit.
|
|
235
231
|
* @param args - Arguments to pass to the event listeners.
|
|
236
232
|
* @returns `true` if the event had listeners, `false` otherwise.
|
|
@@ -248,6 +244,7 @@ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvent
|
|
|
248
244
|
/**
|
|
249
245
|
* SharedObject with simplified, synchronous summarization and GC.
|
|
250
246
|
* DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.
|
|
247
|
+
* @public
|
|
251
248
|
*/
|
|
252
249
|
export declare abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
|
|
253
250
|
private readonly telemetryContextPrefix;
|
|
@@ -273,7 +270,7 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
273
270
|
/**
|
|
274
271
|
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
|
|
275
272
|
*/
|
|
276
|
-
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
|
|
273
|
+
summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;
|
|
277
274
|
/**
|
|
278
275
|
* {@inheritDoc (ISharedObject:interface).getGCData}
|
|
279
276
|
*/
|
|
@@ -282,12 +279,12 @@ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents =
|
|
|
282
279
|
* Calls the serializer over all data in this object that reference other GC nodes.
|
|
283
280
|
* Derived classes must override this to provide custom list of references to other GC nodes.
|
|
284
281
|
*/
|
|
285
|
-
protected processGCDataCore(serializer:
|
|
282
|
+
protected processGCDataCore(serializer: IFluidSerializer): void;
|
|
286
283
|
/**
|
|
287
284
|
* Gets a form of the object that can be serialized.
|
|
288
285
|
* @returns A tree representing the snapshot of the shared object.
|
|
289
286
|
*/
|
|
290
|
-
protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
287
|
+
protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
|
|
291
288
|
private incrementTelemetryMetric;
|
|
292
289
|
}
|
|
293
290
|
//# sourceMappingURL=sharedObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAwB,MAAM,iCAAiC,CAAC;AACrF,OAAO,EACN,mBAAmB,EAGnB,6BAA6B,EAK7B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EAGjB,sCAAsC,EACtC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAmB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE7D;;;GAGG;AACH,8BAAsB,gBAAgB,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,CAC9F,SAAQ,6BAA6B,CAAC,MAAM,CAC5C,YAAW,aAAa,CAAC,MAAM,CAAC;IAsDxB,EAAE,EAAE,MAAM;IACjB,SAAS,CAAC,OAAO,EAAE,sBAAsB;aACzB,UAAU,EAAE,kBAAkB;IAtD/C,IAAW,cAAc,SAExB;IAED,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAyB;IAC5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IAEzD;;OAEG;IACH,SAAgB,MAAM,EAAE,YA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EACpC,yBAAyB,CAAC,EAAE,sCAAsC,GAChE,qBAAqB;IAExB,OAAO,CAAC,wBAAwB;CAShC"}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.SummarySerializer = void 0;
|
|
8
|
-
const serializer_1 = require("./serializer");
|
|
8
|
+
const serializer_1 = require("./serializer.cjs");
|
|
9
9
|
/**
|
|
10
10
|
* Serializer implementation for serializing handles during summary.
|
|
11
|
+
* @internal
|
|
11
12
|
*/
|
|
12
13
|
class SummarySerializer extends serializer_1.FluidSerializer {
|
|
13
14
|
constructor() {
|
|
@@ -23,4 +24,4 @@ class SummarySerializer extends serializer_1.FluidSerializer {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
exports.SummarySerializer = SummarySerializer;
|
|
26
|
-
//# sourceMappingURL=summarySerializer.
|
|
27
|
+
//# sourceMappingURL=summarySerializer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summarySerializer.cjs","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,iDAA+C;AAE/C;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,4BAAe;IAAtD;;QACkB,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAS5D,CAAC;IARO,mBAAmB;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC1C,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD;AAVD,8CAUC","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 { FluidSerializer } from \"./serializer\";\n\n/**\n * Serializer implementation for serializing handles during summary.\n * @internal\n */\nexport class SummarySerializer extends FluidSerializer {\n\tprivate readonly serializedRoutes: Set<string> = new Set();\n\tpublic getSerializedRoutes(): string[] {\n\t\treturn Array.from(this.serializedRoutes);\n\t}\n\n\tprotected serializeHandle(handle: IFluidHandle, bind: IFluidHandle) {\n\t\tthis.serializedRoutes.add(handle.absolutePath);\n\t\treturn super.serializeHandle(handle, bind);\n\t}\n}\n"]}
|
|
@@ -6,6 +6,7 @@ import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
|
6
6
|
import { FluidSerializer } from "./serializer";
|
|
7
7
|
/**
|
|
8
8
|
* Serializer implementation for serializing handles during summary.
|
|
9
|
+
* @internal
|
|
9
10
|
*/
|
|
10
11
|
export declare class SummarySerializer extends FluidSerializer {
|
|
11
12
|
private readonly serializedRoutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IACpD,mBAAmB,IAAI,MAAM,EAAE;IAItC,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;;;;CAIlE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.38.3"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIErrorEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n} from \"@fluidframework/core-interfaces\";\nimport { IChannel } from \"@fluidframework/datastore-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\n\n/**\n * Events emitted by {@link ISharedObject}.\n * @public\n */\nexport interface ISharedObjectEvents extends IErrorEvent {\n\t/**\n\t * Fires before an incoming operation (op) is applied to the shared object.\n\t *\n\t * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external\n\t * use.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"pre-op\",\n\t\tlistener: (\n\t\t\top: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t);\n\n\t/**\n\t * Fires after an incoming op is applied to the shared object.\n\t *\n\t * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external\n\t * use.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"op\",\n\t\tlistener: (\n\t\t\top: ISequencedDocumentMessage,\n\t\t\tlocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t);\n}\n\n/**\n * Base interface for shared objects from which other interfaces derive. Implemented by SharedObject\n * @public\n */\nexport interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents>\n\textends IChannel,\n\t\tIEventProvider<TEvent> {\n\t/**\n\t * Binds the given shared object to its containing data store runtime, causing it to attach once\n\t * the runtime attaches.\n\t */\n\tbindToContext(): void;\n\n\t/**\n\t * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to\n\t * other GC nodes.\n\t * @param fullGC - true to bypass optimizations and force full generation of GC data.\n\t */\n\tgetGCData(fullGC?: boolean): IGarbageCollectionData;\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,15 +2,37 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IErrorEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/
|
|
5
|
+
import { IErrorEvent, IEventProvider, IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IChannel } from "@fluidframework/datastore-definitions";
|
|
7
7
|
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { IGarbageCollectionData } from "@fluidframework/runtime-definitions";
|
|
9
|
+
/**
|
|
10
|
+
* Events emitted by {@link ISharedObject}.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
9
13
|
export interface ISharedObjectEvents extends IErrorEvent {
|
|
10
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Fires before an incoming operation (op) is applied to the shared object.
|
|
16
|
+
*
|
|
17
|
+
* @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
|
|
18
|
+
* use.
|
|
19
|
+
*
|
|
20
|
+
* @eventProperty
|
|
21
|
+
*/
|
|
22
|
+
(event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
23
|
+
/**
|
|
24
|
+
* Fires after an incoming op is applied to the shared object.
|
|
25
|
+
*
|
|
26
|
+
* @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
|
|
27
|
+
* use.
|
|
28
|
+
*
|
|
29
|
+
* @eventProperty
|
|
30
|
+
*/
|
|
31
|
+
(event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
|
|
11
32
|
}
|
|
12
33
|
/**
|
|
13
34
|
* Base interface for shared objects from which other interfaces derive. Implemented by SharedObject
|
|
35
|
+
* @public
|
|
14
36
|
*/
|
|
15
37
|
export interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
|
|
16
38
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACvD;;;;;;;OAOG;IACH,CACC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CACT,EAAE,EAAE,yBAAyB,EAC7B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,KACzB,IAAI,OACR;IAEF;;;;;;;OAOG;IACH,CACC,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CACT,EAAE,EAAE,yBAAyB,EAC7B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,qBAAqB,KACzB,IAAI,OACR;CACF;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,mBAAmB,GAAG,mBAAmB,CACtF,SAAQ,QAAQ,EACf,cAAc,CAAC,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;OAIG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAC;CACpD"}
|
|
@@ -14,12 +14,11 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
|
14
14
|
* @param context - The handle context for the container
|
|
15
15
|
* @param bind - Bind any other handles we find in the object against this given handle.
|
|
16
16
|
* @returns Result of strigifying an object
|
|
17
|
+
* @internal
|
|
17
18
|
*/
|
|
18
19
|
function serializeHandles(value, serializer, bind) {
|
|
19
20
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
20
|
-
return value !== undefined
|
|
21
|
-
? serializer.stringify(value, bind)
|
|
22
|
-
: value;
|
|
21
|
+
return value !== undefined ? serializer.stringify(value, bind) : value;
|
|
23
22
|
}
|
|
24
23
|
exports.serializeHandles = serializeHandles;
|
|
25
24
|
/**
|
|
@@ -33,6 +32,7 @@ exports.serializeHandles = serializeHandles;
|
|
|
33
32
|
* @param context - The handle context for the container
|
|
34
33
|
* @param bind - Bind any other handles we find in the object against this given handle.
|
|
35
34
|
* @returns The fully-plain object
|
|
35
|
+
* @alpha
|
|
36
36
|
*/
|
|
37
37
|
function makeHandlesSerializable(value, serializer, bind) {
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -46,6 +46,7 @@ exports.makeHandlesSerializable = makeHandlesSerializable;
|
|
|
46
46
|
* @param serializer - The serializer that knows how to convert serializable-form handles into handle objects
|
|
47
47
|
* @param context - The handle context for the container
|
|
48
48
|
* @returns The mostly-plain object with handle objects within
|
|
49
|
+
* @alpha
|
|
49
50
|
*/
|
|
50
51
|
function parseHandles(value, serializer) {
|
|
51
52
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -57,6 +58,7 @@ exports.parseHandles = parseHandles;
|
|
|
57
58
|
* @param key - the key for the blob in the summary
|
|
58
59
|
* @param content - blob content
|
|
59
60
|
* @returns The summary containing the blob
|
|
61
|
+
* @internal
|
|
60
62
|
*/
|
|
61
63
|
function createSingleBlobSummary(key, content) {
|
|
62
64
|
const builder = new runtime_utils_1.SummaryTreeBuilder();
|
|
@@ -64,4 +66,4 @@ function createSingleBlobSummary(key, content) {
|
|
|
64
66
|
return builder.getSummaryTree();
|
|
65
67
|
}
|
|
66
68
|
exports.createSingleBlobSummary = createSingleBlobSummary;
|
|
67
|
-
//# sourceMappingURL=utils.
|
|
69
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iEAAmE;AAGnE;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAC/B,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxE,CAAC;AAPD,4CAOC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,uBAAuB,CACtC,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAPD,0DAOC;AAED;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,KAAU,EAAE,UAA4B;IACpE,+DAA+D;IAC/D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9E,CAAC;AAHD,oCAGC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACtC,GAAW,EACX,OAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,kCAAkB,EAAE,CAAC;IACzC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC;AAPD,0DAOC","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 { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils\";\nimport { IFluidSerializer } from \"./serializer\";\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, return a string representation of an object\n * where the handle objects have been replaced with a serializable form.\n * @param value - The mostly-plain object\n * @param serializer - The serializer that knows how to convert handles into serializable format\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns Result of strigifying an object\n * @internal\n */\nexport function serializeHandles(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string | undefined {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn value !== undefined ? serializer.stringify(value, bind) : value;\n}\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n * where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * @param input - The mostly-plain object\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns The fully-plain object\n * @alpha\n */\nexport function makeHandlesSerializable(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn serializer.encode(value, bind);\n}\n\n/**\n * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object\n * with handle objects created instead.\n * @param value - The fully-plain object\n * @param serializer - The serializer that knows how to convert serializable-form handles into handle objects\n * @param context - The handle context for the container\n * @returns The mostly-plain object with handle objects within\n * @alpha\n */\nexport function parseHandles(value: any, serializer: IFluidSerializer) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn value !== undefined ? serializer.parse(JSON.stringify(value)) : value;\n}\n\n/**\n * Create a new summary containing one blob\n * @param key - the key for the blob in the summary\n * @param content - blob content\n * @returns The summary containing the blob\n * @internal\n */\nexport function createSingleBlobSummary(\n\tkey: string,\n\tcontent: string | Uint8Array,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tbuilder.addBlob(key, content);\n\treturn builder.getSummaryTree();\n}\n"]}
|