@fluidframework/shared-object-base 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/api-report/shared-object-base.legacy.beta.api.md +9 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sharedObject.d.ts +1 -27
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +33 -44
- package/dist/sharedObject.js.map +1 -1
- package/dist/sharedObjectKernel.d.ts.map +1 -1
- package/dist/sharedObjectKernel.js +0 -12
- package/dist/sharedObjectKernel.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/sharedObject.d.ts +1 -27
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +33 -44
- package/lib/sharedObject.js.map +1 -1
- package/lib/sharedObjectKernel.d.ts.map +1 -1
- package/lib/sharedObjectKernel.js +0 -12
- package/lib/sharedObjectKernel.js.map +1 -1
- package/package.json +16 -16
- package/src/packageVersion.ts +1 -1
- package/src/sharedObject.ts +37 -55
- package/src/sharedObjectKernel.ts +0 -12
package/src/sharedObject.ts
CHANGED
|
@@ -321,9 +321,6 @@ export abstract class SharedObjectCore<
|
|
|
321
321
|
this.initializeLocalCore();
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
/**
|
|
325
|
-
* {@inheritDoc (ISharedObject:interface).bindToContext}
|
|
326
|
-
*/
|
|
327
324
|
public bindToContext(): void {
|
|
328
325
|
// ensure the method only runs once by removing the implementation
|
|
329
326
|
// without this the method suffers from re-entrancy issues
|
|
@@ -336,9 +333,6 @@ export abstract class SharedObjectCore<
|
|
|
336
333
|
}
|
|
337
334
|
}
|
|
338
335
|
|
|
339
|
-
/**
|
|
340
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}
|
|
341
|
-
*/
|
|
342
336
|
public connect(services: IChannelServices): void {
|
|
343
337
|
// handle the case where load is called
|
|
344
338
|
// before connect; loading detached data stores
|
|
@@ -350,34 +344,22 @@ export abstract class SharedObjectCore<
|
|
|
350
344
|
this.setBoundAndHandleAttach();
|
|
351
345
|
}
|
|
352
346
|
|
|
353
|
-
/**
|
|
354
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}
|
|
355
|
-
*/
|
|
356
347
|
public isAttached(): boolean {
|
|
357
348
|
return this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;
|
|
358
349
|
}
|
|
359
350
|
|
|
360
|
-
/**
|
|
361
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
|
|
362
|
-
*/
|
|
363
351
|
public abstract getAttachSummary(
|
|
364
352
|
fullTree?: boolean,
|
|
365
353
|
trackState?: boolean,
|
|
366
354
|
telemetryContext?: ITelemetryContext,
|
|
367
355
|
): ISummaryTreeWithStats;
|
|
368
356
|
|
|
369
|
-
/**
|
|
370
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
|
|
371
|
-
*/
|
|
372
357
|
public abstract summarize(
|
|
373
358
|
fullTree?: boolean,
|
|
374
359
|
trackState?: boolean,
|
|
375
360
|
telemetryContext?: ITelemetryContext,
|
|
376
361
|
): Promise<ISummaryTreeWithStats>;
|
|
377
362
|
|
|
378
|
-
/**
|
|
379
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}
|
|
380
|
-
*/
|
|
381
363
|
public abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
382
364
|
|
|
383
365
|
/**
|
|
@@ -437,20 +419,27 @@ export abstract class SharedObjectCore<
|
|
|
437
419
|
protected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {
|
|
438
420
|
this.verifyNotClosed();
|
|
439
421
|
if (this.isAttached()) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const onlyBind =
|
|
443
|
-
(this.runtime as IFluidDataStoreRuntimeInternalConfig)
|
|
444
|
-
.submitMessagesWithoutEncodingHandles === true;
|
|
445
|
-
const contentToSubmit = onlyBind
|
|
446
|
-
? bindHandles(content, this.handle)
|
|
447
|
-
: makeHandlesSerializable(content, this.serializer, this.handle);
|
|
448
|
-
|
|
449
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
450
|
-
this.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);
|
|
422
|
+
const contentToSubmit = this.#prepareMessage(content);
|
|
423
|
+
this.#submitMessage(contentToSubmit, localOpMetadata);
|
|
451
424
|
}
|
|
452
425
|
}
|
|
453
426
|
|
|
427
|
+
#prepareMessage(content: unknown): unknown {
|
|
428
|
+
// NOTE: We may also be encoding in the ContainerRuntime layer.
|
|
429
|
+
// Once the layer-compat window passes we can remove the encoding codepath here altogether
|
|
430
|
+
const onlyBind =
|
|
431
|
+
(this.runtime as IFluidDataStoreRuntimeInternalConfig)
|
|
432
|
+
.submitMessagesWithoutEncodingHandles === true;
|
|
433
|
+
return onlyBind
|
|
434
|
+
? bindHandles(content, this.handle)
|
|
435
|
+
: makeHandlesSerializable(content, this.serializer, this.handle);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
#submitMessage(content: unknown, localOpMetadata: unknown): void {
|
|
439
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
440
|
+
this.services!.deltaConnection.submit(content, localOpMetadata);
|
|
441
|
+
}
|
|
442
|
+
|
|
454
443
|
/**
|
|
455
444
|
* Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock
|
|
456
445
|
* that want to be part of summary but does not generate ops.
|
|
@@ -535,6 +524,24 @@ export abstract class SharedObjectCore<
|
|
|
535
524
|
});
|
|
536
525
|
}
|
|
537
526
|
|
|
527
|
+
readonly #deltaHandler: IDeltaHandler = {
|
|
528
|
+
processMessages: (messagesCollection: IRuntimeMessageCollection) => {
|
|
529
|
+
this.processMessages(messagesCollection);
|
|
530
|
+
},
|
|
531
|
+
setConnectionState: (connected: boolean) => {
|
|
532
|
+
this.setConnectionState(connected);
|
|
533
|
+
},
|
|
534
|
+
reSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {
|
|
535
|
+
this.reSubmit(content, localOpMetadata, squash);
|
|
536
|
+
},
|
|
537
|
+
applyStashedOp: (content: unknown): void => {
|
|
538
|
+
this.applyStashedOp(parseHandles(content, this.serializer));
|
|
539
|
+
},
|
|
540
|
+
rollback: (content: unknown, localOpMetadata: unknown) => {
|
|
541
|
+
this.rollback(content, localOpMetadata);
|
|
542
|
+
},
|
|
543
|
+
};
|
|
544
|
+
|
|
538
545
|
private attachDeltaHandler(): void {
|
|
539
546
|
// Services should already be there in case we are attaching delta handler.
|
|
540
547
|
assert(
|
|
@@ -542,23 +549,7 @@ export abstract class SharedObjectCore<
|
|
|
542
549
|
0x07a /* "Services should be there to attach delta handler" */,
|
|
543
550
|
);
|
|
544
551
|
// attachDeltaHandler is only called after services is assigned
|
|
545
|
-
this.services.deltaConnection.attach(
|
|
546
|
-
processMessages: (messagesCollection: IRuntimeMessageCollection) => {
|
|
547
|
-
this.processMessages(messagesCollection);
|
|
548
|
-
},
|
|
549
|
-
setConnectionState: (connected: boolean) => {
|
|
550
|
-
this.setConnectionState(connected);
|
|
551
|
-
},
|
|
552
|
-
reSubmit: (content: unknown, localOpMetadata: unknown, squash: boolean) => {
|
|
553
|
-
this.reSubmit(content, localOpMetadata, squash);
|
|
554
|
-
},
|
|
555
|
-
applyStashedOp: (content: unknown): void => {
|
|
556
|
-
this.applyStashedOp(parseHandles(content, this.serializer));
|
|
557
|
-
},
|
|
558
|
-
rollback: (content: unknown, localOpMetadata: unknown) => {
|
|
559
|
-
this.rollback(content, localOpMetadata);
|
|
560
|
-
},
|
|
561
|
-
} satisfies IDeltaHandler);
|
|
552
|
+
this.services.deltaConnection.attach(this.#deltaHandler);
|
|
562
553
|
}
|
|
563
554
|
|
|
564
555
|
/**
|
|
@@ -783,9 +774,6 @@ export abstract class SharedObject<
|
|
|
783
774
|
this._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);
|
|
784
775
|
}
|
|
785
776
|
|
|
786
|
-
/**
|
|
787
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
|
|
788
|
-
*/
|
|
789
777
|
public getAttachSummary(
|
|
790
778
|
fullTree: boolean = false,
|
|
791
779
|
trackState: boolean = false,
|
|
@@ -810,9 +798,6 @@ export abstract class SharedObject<
|
|
|
810
798
|
return result;
|
|
811
799
|
}
|
|
812
800
|
|
|
813
|
-
/**
|
|
814
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
|
|
815
|
-
*/
|
|
816
801
|
public async summarize(
|
|
817
802
|
fullTree: boolean = false,
|
|
818
803
|
trackState: boolean = false,
|
|
@@ -838,9 +823,6 @@ export abstract class SharedObject<
|
|
|
838
823
|
return result;
|
|
839
824
|
}
|
|
840
825
|
|
|
841
|
-
/**
|
|
842
|
-
* {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getGCData}
|
|
843
|
-
*/
|
|
844
826
|
public getGCData(fullGC: boolean = false): IGarbageCollectionData {
|
|
845
827
|
// Set _isGCing to true. This flag is used to ensure that we only use GCHandleVisitor in this codepath and not when trying to truly serialize.
|
|
846
828
|
assert(
|
|
@@ -432,23 +432,14 @@ function makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {
|
|
|
432
432
|
*/
|
|
433
433
|
public static readonly Attributes: IChannelAttributes = options.attributes;
|
|
434
434
|
|
|
435
|
-
/**
|
|
436
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
437
|
-
*/
|
|
438
435
|
public get type(): string {
|
|
439
436
|
return ChannelFactory.Type;
|
|
440
437
|
}
|
|
441
438
|
|
|
442
|
-
/**
|
|
443
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
444
|
-
*/
|
|
445
439
|
public get attributes(): IChannelAttributes {
|
|
446
440
|
return ChannelFactory.Attributes;
|
|
447
441
|
}
|
|
448
442
|
|
|
449
|
-
/**
|
|
450
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
451
|
-
*/
|
|
452
443
|
public async load(
|
|
453
444
|
runtime: IFluidDataStoreRuntime,
|
|
454
445
|
id: string,
|
|
@@ -466,9 +457,6 @@ function makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {
|
|
|
466
457
|
return shared as unknown as T & IChannel;
|
|
467
458
|
}
|
|
468
459
|
|
|
469
|
-
/**
|
|
470
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
471
|
-
*/
|
|
472
460
|
public create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {
|
|
473
461
|
const shared = new SharedObjectFromKernel(
|
|
474
462
|
id,
|