@fluid-experimental/tree 2.70.0-360753 → 2.70.0-361248
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/SharedTree.d.ts +6 -6
- package/dist/SharedTree.js +3 -3
- package/dist/SharedTree.js.map +1 -1
- package/dist/migration-shim/migrationShim.d.ts +1 -1
- package/dist/migration-shim/migrationShim.js +1 -1
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/lib/SharedTree.d.ts +6 -6
- package/lib/SharedTree.js +3 -3
- package/lib/SharedTree.js.map +1 -1
- package/lib/migration-shim/migrationShim.d.ts +1 -1
- package/lib/migration-shim/migrationShim.js +1 -1
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/package.json +26 -26
- package/src/SharedTree.ts +6 -6
- package/src/migration-shim/migrationShim.ts +1 -1
|
@@ -104,7 +104,7 @@ export declare class MigrationShim extends EventEmitterWithErrorHandling<IMigrat
|
|
|
104
104
|
* twice, we will be in a "v2" state even though we really are in a "v1" state. We will encounter unexpected op
|
|
105
105
|
* dropping behavior or lack thereof and may corrupt the document.
|
|
106
106
|
* @param services - the services to generate the shim services from
|
|
107
|
-
* @returns
|
|
107
|
+
* @returns shim services
|
|
108
108
|
*/
|
|
109
109
|
private generateShimServicesOnce;
|
|
110
110
|
getGCData(fullGC?: boolean | undefined): IGarbageCollectionData;
|
|
@@ -152,7 +152,7 @@ export class MigrationShim extends EventEmitterWithErrorHandling {
|
|
|
152
152
|
* twice, we will be in a "v2" state even though we really are in a "v1" state. We will encounter unexpected op
|
|
153
153
|
* dropping behavior or lack thereof and may corrupt the document.
|
|
154
154
|
* @param services - the services to generate the shim services from
|
|
155
|
-
* @returns
|
|
155
|
+
* @returns shim services
|
|
156
156
|
*/
|
|
157
157
|
generateShimServicesOnce(services) {
|
|
158
158
|
assert(this.services === undefined && this.preMigrationDeltaConnection === undefined, 0x7e9 /* Already connected */);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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O,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport {\n\ttype IChannelAttributes,\n\tIChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannel,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { SessionId } from '@fluidframework/id-compressor';\nimport type { IIdCompressorCore } from '@fluidframework/id-compressor/internal';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';\nimport { type ITree } from '@fluidframework/tree';\n\nimport {\n\ttype SharedTree as LegacySharedTree,\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n} from '../SharedTree.js';\n\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IOpContents, type IShim } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\nconst ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee' as SessionId;\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (message.type !== MessageType.Operation || (message.contents as Partial<IMigrationOp>).type !== 'barrier') {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id);\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tconst { idCompressor } = this.runtime;\n\t\tif (idCompressor !== undefined) {\n\t\t\t(idCompressor as unknown as IIdCompressorCore).beginGhostSession(ghostSessionId, () =>\n\t\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\t}\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: (IChannel & ITree) | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\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(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): IChannel & (LegacySharedTree | ITree) {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t);\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns - shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAQ7D,OAAO,EAAE,WAAW,EAAkC,MAAM,6CAA6C,CAAC;AAS1G,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAQ9G,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAA6B,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,aAAc,SAAQ,6BAA8C;IAChF,YACiB,EAAU,EACT,OAA+B,EAC/B,iBAA0C,EAC1C,cAAsC,EACtC,yBAA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AK,SAAS,EAC7E,KAAK,CAAC,uBAAuB,CAC7B,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,2BAA2B,GAAG,IAAI,2BAA2B,CACjE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAC7B,IAAI,CAAC,qBAAqB,CAC1B,CAAC;QACF,MAAM,YAAY,GAAyB;YAC1C,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,eAAe,EAAE,IAAI,CAAC,2BAA2B;SACjD,CAAC;QACF,OAAO,YAAY,CAAC;IACrB,CAAC;IAEM,SAAS,CAAC,MAA4B;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport { assert } from '@fluidframework/core-utils/internal';\nimport {\n\ttype IChannelAttributes,\n\tIChannelFactory,\n\ttype IFluidDataStoreRuntime,\n\ttype IChannel,\n\ttype IChannelServices,\n} from '@fluidframework/datastore-definitions/internal';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/driver-definitions/internal';\nimport type { SessionId } from '@fluidframework/id-compressor';\nimport type { IIdCompressorCore } from '@fluidframework/id-compressor/internal';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n} from '@fluidframework/runtime-definitions/internal';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils/internal';\nimport { type ITree } from '@fluidframework/tree';\n\nimport {\n\ttype SharedTree as LegacySharedTree,\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n} from '../SharedTree.js';\n\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IOpContents, type IShim } from './types.js';\n\n/**\n * Interface for migration events to indicate the stage of the migration. There really is two stages: before, and after.\n *\n * @internal\n */\nexport interface IMigrationEvent extends IEvent {\n\t/**\n\t * Event that is emitted when the migration is complete.\n\t */\n\t(event: 'migrated', listener: () => void);\n}\n\n/**\n * Interface for migration operation.\n */\nexport interface IMigrationOp {\n\t/**\n\t * Type of the migration operation.\n\t */\n\ttype: 'barrier';\n\t/**\n\t * Old channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what state of the document was before the migration op initiated at.\n\t */\n\toldAttributes: IChannelAttributes;\n\t/**\n\t * New channel attributes so we can do verification and understand what changed. This will allow future clients to\n\t * accurately reason about what the migration state of the new container is expected to be.\n\t */\n\tnewAttributes: IChannelAttributes;\n}\n\nconst ghostSessionId = '3692b242-46c0-4076-abea-c2ac1e896dee' as SessionId;\n\n/**\n * The MigrationShim loads in place of the legacy SharedTree. It provides API surface for migrating it to the new SharedTree, while also providing access to the current SharedTree for usage.\n *\n * @remarks\n *\n * This MigrationShim is responsible for submitting a migration op, processing the migrate op, swapping from the old\n * tree to the new tree, loading an old tree snapshot and creating an old tree.\n *\n * The MigrationShim expects to always load from a legacy SharedTree snapshot, though by the time it catches up in\n * processing all ops, it may find that the migration has already occurred. After migration occurs, it modifies its\n * attributes to point at the SharedTreeShimFactory. This will cause future clients to load with a SharedTreeShim and\n * the new SharedTree snapshot instead after the next summarization.\n *\n * @internal\n */\nexport class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent> implements IShim {\n\tpublic constructor(\n\t\tpublic readonly id: string,\n\t\tprivate readonly runtime: IFluidDataStoreRuntime,\n\t\tprivate readonly legacyTreeFactory: LegacySharedTreeFactory,\n\t\tprivate readonly newTreeFactory: IChannelFactory<ITree>,\n\t\tprivate readonly populateNewSharedObjectFn: (legacyTree: LegacySharedTree, newTree: ITree) => void\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) => this.eventListenerErrorHandler(event, e));\n\t\t// TODO: consider flattening this class\n\t\tthis.migrationDeltaHandler = new MigrationShimDeltaHandler(\n\t\t\tthis.processMigrateOp,\n\t\t\tthis.submitLocalMessage,\n\t\t\tthis.newTreeFactory.attributes\n\t\t);\n\t\tthis.handle = new ShimHandle<MigrationShim>(this);\n\t}\n\n\tprivate readonly processMigrateOp = (message: ISequencedDocumentMessage): boolean => {\n\t\tif (message.type !== MessageType.Operation || (message.contents as Partial<IMigrationOp>).type !== 'barrier') {\n\t\t\treturn false;\n\t\t}\n\t\tconst newTree = this.newTreeFactory.create(this.runtime, this.id);\n\t\tassert(this.preMigrationDeltaConnection !== undefined, 0x82f /* Should be in v1 state */);\n\t\tthis.preMigrationDeltaConnection.disableSubmit();\n\t\tconst { idCompressor } = this.runtime;\n\t\tif (idCompressor !== undefined) {\n\t\t\t(idCompressor as unknown as IIdCompressorCore).beginGhostSession(ghostSessionId, () =>\n\t\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree)\n\t\t\t);\n\t\t} else {\n\t\t\tthis.populateNewSharedObjectFn(this.legacyTree, newTree);\n\t\t}\n\t\tthis.newTree = newTree;\n\t\tthis.reconnect();\n\t\tthis.emit('migrated');\n\t\treturn true;\n\t};\n\n\tprivate readonly migrationDeltaHandler: MigrationShimDeltaHandler;\n\tprivate services?: IChannelServices;\n\tprivate preMigrationDeltaConnection?: PreMigrationDeltaConnection;\n\tprivate postMigrationServices?: IShimChannelServices;\n\n\tprivate _legacyTree: LegacySharedTree | undefined;\n\tprivate get legacyTree(): LegacySharedTree {\n\t\tassert(this._legacyTree !== undefined, 0x7e6 /* Old tree not initialized */);\n\t\treturn this._legacyTree;\n\t}\n\n\tprivate newTree: (IChannel & ITree) | undefined;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeError}\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.eventListenerErrorHandler}\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(e, 'SharedObjectEventListenerException');\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.closeWithError}\n\t */\n\tprivate closeWithError(error: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.verifyNotClosed}\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.submitLocalMessage}\n\t */\n\tprivate readonly submitLocalMessage = (message: IOpContents): void => {\n\t\tthis.verifyNotClosed();\n\t\t// This is a copy of submit local message from SharedObject\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(message, undefined);\n\t\t}\n\t};\n\n\t// Migration occurs once this op is read.\n\tpublic submitMigrateOp(): void {\n\t\tconst migrateOp: IMigrationOp = {\n\t\t\ttype: 'barrier',\n\t\t\toldAttributes: this.legacyTreeFactory.attributes,\n\t\t\tnewAttributes: this.newTreeFactory.attributes,\n\t\t};\n\n\t\tthis.submitLocalMessage(migrateOp);\n\t}\n\n\tpublic get currentTree(): IChannel & (LegacySharedTree | ITree) {\n\t\treturn this.newTree ?? this.legacyTree;\n\t}\n\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tconst shimServices =\n\t\t\tthis.runtime.attachState === AttachState.Detached\n\t\t\t\t? new NoDeltasChannelServices(services)\n\t\t\t\t: this.generateShimServicesOnce(services);\n\t\tthis._legacyTree = await this.legacyTreeFactory.load(\n\t\t\tthis.runtime,\n\t\t\tthis.id,\n\t\t\tshimServices,\n\t\t\tthis.legacyTreeFactory.attributes\n\t\t);\n\t}\n\tpublic create(): void {\n\t\tthis._legacyTree = this.legacyTreeFactory.create(this.runtime, this.id);\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn this.currentTree.attributes;\n\t}\n\tpublic getAttachSummary(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined\n\t): ISummaryTreeWithStats {\n\t\treturn this.currentTree.getAttachSummary(fullTree, trackState, telemetryContext);\n\t}\n\tpublic async summarize(\n\t\tfullTree?: boolean | undefined,\n\t\ttrackState?: boolean | undefined,\n\t\ttelemetryContext?: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext | undefined\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.currentTree.summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext);\n\t}\n\tpublic isAttached(): boolean {\n\t\treturn this.currentTree.isAttached();\n\t}\n\n\t// Only connect to the legacy shared tree\n\tpublic connect(services: IChannelServices): void {\n\t\tconst shimServices = this.generateShimServicesOnce(services);\n\t\tthis.legacyTree.connect(shimServices);\n\t}\n\n\t// Only reconnect to the new shared tree this limits us to only migrating\n\tprivate reconnect(): void {\n\t\tassert(this.services !== undefined, 0x7e7 /* Not connected */);\n\t\tassert(this.newTree !== undefined, 0x7e8 /* New tree not initialized */);\n\t\tassert(this.postMigrationServices === undefined, 0x830 /* Already reconnected! */);\n\t\t// This method attaches the newTree's delta handler to the MigrationShimDeltaHandler\n\t\tthis.postMigrationServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: new StampDeltaConnection(\n\t\t\t\tthis.services.deltaConnection,\n\t\t\t\tthis.migrationDeltaHandler,\n\t\t\t\tthis.newTree.attributes\n\t\t\t),\n\t\t};\n\t\tthis.newTree.connect(this.postMigrationServices);\n\t}\n\n\t/**\n\t * Only generate the ShimServices once as the underlying DeltaHandler can only be connected to once. If we connect\n\t * twice, we will be in a \"v2\" state even though we really are in a \"v1\" state. We will encounter unexpected op\n\t * dropping behavior or lack thereof and may corrupt the document.\n\t * @param services - the services to generate the shim services from\n\t * @returns shim services\n\t */\n\tprivate generateShimServicesOnce(services: IChannelServices): IShimChannelServices {\n\t\tassert(\n\t\t\tthis.services === undefined && this.preMigrationDeltaConnection === undefined,\n\t\t\t0x7e9 /* Already connected */\n\t\t);\n\t\tthis.services = services;\n\t\tthis.preMigrationDeltaConnection = new PreMigrationDeltaConnection(\n\t\t\tthis.services.deltaConnection,\n\t\t\tthis.migrationDeltaHandler\n\t\t);\n\t\tconst shimServices: IShimChannelServices = {\n\t\t\tobjectStorage: this.services.objectStorage,\n\t\t\tdeltaConnection: this.preMigrationDeltaConnection,\n\t\t};\n\t\treturn shimServices;\n\t}\n\n\tpublic getGCData(fullGC?: boolean | undefined): IGarbageCollectionData {\n\t\treturn this.currentTree.getGCData(fullGC);\n\t}\n\tpublic handle: IFluidHandle<MigrationShim>;\n\tpublic get IFluidLoadable(): IFluidLoadable {\n\t\treturn this;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/tree",
|
|
3
|
-
"version": "2.70.0-
|
|
3
|
+
"version": "2.70.0-361248",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"main": "lib/index.js",
|
|
28
28
|
"types": "lib/index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@fluid-internal/client-utils": "2.70.0-
|
|
31
|
-
"@fluidframework/container-definitions": "2.70.0-
|
|
32
|
-
"@fluidframework/core-interfaces": "2.70.0-
|
|
33
|
-
"@fluidframework/core-utils": "2.70.0-
|
|
34
|
-
"@fluidframework/datastore-definitions": "2.70.0-
|
|
35
|
-
"@fluidframework/driver-definitions": "2.70.0-
|
|
36
|
-
"@fluidframework/id-compressor": "2.70.0-
|
|
37
|
-
"@fluidframework/runtime-definitions": "2.70.0-
|
|
38
|
-
"@fluidframework/runtime-utils": "2.70.0-
|
|
39
|
-
"@fluidframework/shared-object-base": "2.70.0-
|
|
40
|
-
"@fluidframework/telemetry-utils": "2.70.0-
|
|
41
|
-
"@fluidframework/tree": "2.70.0-
|
|
30
|
+
"@fluid-internal/client-utils": "2.70.0-361248",
|
|
31
|
+
"@fluidframework/container-definitions": "2.70.0-361248",
|
|
32
|
+
"@fluidframework/core-interfaces": "2.70.0-361248",
|
|
33
|
+
"@fluidframework/core-utils": "2.70.0-361248",
|
|
34
|
+
"@fluidframework/datastore-definitions": "2.70.0-361248",
|
|
35
|
+
"@fluidframework/driver-definitions": "2.70.0-361248",
|
|
36
|
+
"@fluidframework/id-compressor": "2.70.0-361248",
|
|
37
|
+
"@fluidframework/runtime-definitions": "2.70.0-361248",
|
|
38
|
+
"@fluidframework/runtime-utils": "2.70.0-361248",
|
|
39
|
+
"@fluidframework/shared-object-base": "2.70.0-361248",
|
|
40
|
+
"@fluidframework/telemetry-utils": "2.70.0-361248",
|
|
41
|
+
"@fluidframework/tree": "2.70.0-361248",
|
|
42
42
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
43
43
|
"buffer": "^6.0.3",
|
|
44
44
|
"denque": "^1.5.1",
|
|
@@ -48,20 +48,20 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
50
50
|
"@biomejs/biome": "~1.9.3",
|
|
51
|
-
"@fluid-internal/mocha-test-setup": "2.70.0-
|
|
52
|
-
"@fluid-private/stochastic-test-utils": "2.70.0-
|
|
53
|
-
"@fluid-private/test-drivers": "2.70.0-
|
|
51
|
+
"@fluid-internal/mocha-test-setup": "2.70.0-361248",
|
|
52
|
+
"@fluid-private/stochastic-test-utils": "2.70.0-361248",
|
|
53
|
+
"@fluid-private/test-drivers": "2.70.0-361248",
|
|
54
54
|
"@fluid-tools/benchmark": "^0.51.0",
|
|
55
55
|
"@fluidframework/build-common": "^2.0.3",
|
|
56
56
|
"@fluidframework/build-tools": "^0.58.3",
|
|
57
|
-
"@fluidframework/container-definitions": "2.70.0-
|
|
58
|
-
"@fluidframework/container-loader": "2.70.0-
|
|
59
|
-
"@fluidframework/container-runtime": "2.70.0-
|
|
60
|
-
"@fluidframework/eslint-config-fluid": "^6.
|
|
61
|
-
"@fluidframework/runtime-utils": "2.70.0-
|
|
62
|
-
"@fluidframework/test-runtime-utils": "2.70.0-
|
|
63
|
-
"@fluidframework/test-utils": "2.70.0-
|
|
64
|
-
"@fluidframework/undo-redo": "2.70.0-
|
|
57
|
+
"@fluidframework/container-definitions": "2.70.0-361248",
|
|
58
|
+
"@fluidframework/container-loader": "2.70.0-361248",
|
|
59
|
+
"@fluidframework/container-runtime": "2.70.0-361248",
|
|
60
|
+
"@fluidframework/eslint-config-fluid": "^6.1.0",
|
|
61
|
+
"@fluidframework/runtime-utils": "2.70.0-361248",
|
|
62
|
+
"@fluidframework/test-runtime-utils": "2.70.0-361248",
|
|
63
|
+
"@fluidframework/test-utils": "2.70.0-361248",
|
|
64
|
+
"@fluidframework/undo-redo": "2.70.0-361248",
|
|
65
65
|
"@microsoft/api-extractor": "7.52.11",
|
|
66
66
|
"@types/chai": "^4.0.0",
|
|
67
67
|
"@types/lru-cache": "^5.1.0",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"cross-env": "^7.0.3",
|
|
74
74
|
"easy-table": "^1.1.1",
|
|
75
75
|
"env-cmd": "^10.1.0",
|
|
76
|
-
"eslint": "~8.
|
|
77
|
-
"eslint-config-prettier": "~
|
|
76
|
+
"eslint": "~8.57.1",
|
|
77
|
+
"eslint-config-prettier": "~10.1.8",
|
|
78
78
|
"mocha": "^10.8.2",
|
|
79
79
|
"mocha-multi-reporters": "^1.5.1",
|
|
80
80
|
"rimraf": "^4.4.0",
|
package/src/SharedTree.ts
CHANGED
|
@@ -212,8 +212,8 @@ export class SharedTreeFactory implements IChannelFactory {
|
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
214
|
* Get a factory for SharedTree to register with the data store.
|
|
215
|
-
* @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See
|
|
216
|
-
* documentation
|
|
215
|
+
* @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See {@link https://github.com/microsoft/FluidFramework/blob/main/experimental/dds/tree/docs/Write-Format.md | the write format
|
|
216
|
+
* documentation} for more information.
|
|
217
217
|
* @param options - Configuration options for this tree
|
|
218
218
|
* @returns A factory that creates `SharedTree`s and loads them from storage.
|
|
219
219
|
*/
|
|
@@ -379,7 +379,7 @@ export interface StashedLocalOpMetadata {
|
|
|
379
379
|
const stashedSessionId = '8477b8d5-cf6c-4673-8345-8f076a8f9bc6' as SessionId;
|
|
380
380
|
|
|
381
381
|
/**
|
|
382
|
-
* A
|
|
382
|
+
* A {@link https://github.com/microsoft/FluidFramework/blob/main/experimental/dds/tree/README.md | distributed tree}.
|
|
383
383
|
* @alpha
|
|
384
384
|
*/
|
|
385
385
|
export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeIdContext {
|
|
@@ -397,7 +397,7 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
397
397
|
* that was initialized with a newer write version connects to the session. Care must be taken when changing this value,
|
|
398
398
|
* as a staged rollout must of occurred such that all collaborating clients must have the code to read at least the version
|
|
399
399
|
* written.
|
|
400
|
-
* See
|
|
400
|
+
* See {@link https://github.com/microsoft/FluidFramework/blob/main/experimental/dds/tree/docs/Write-Format.md | the write format documentation} for more information.
|
|
401
401
|
* @param options - Configuration options for this tree
|
|
402
402
|
* @returns A factory that creates `SharedTree`s and loads them from storage.
|
|
403
403
|
*/
|
|
@@ -530,8 +530,8 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
|
|
|
530
530
|
* Create a new SharedTree.
|
|
531
531
|
* @param runtime - The runtime the SharedTree will be associated with
|
|
532
532
|
* @param id - Unique ID for the SharedTree
|
|
533
|
-
* @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See
|
|
534
|
-
* documentation
|
|
533
|
+
* @param writeFormat - Determines the format version the SharedTree will write ops and summaries in. See {@link https://github.com/microsoft/FluidFramework/blob/main/experimental/dds/tree/docs/Write-Format.md | the write format
|
|
534
|
+
* documentation} for more information.
|
|
535
535
|
* @param options - Configuration options for this tree
|
|
536
536
|
*/
|
|
537
537
|
public constructor(runtime: IFluidDataStoreRuntime, id: string, ...args: SharedTreeArgs<WriteFormat.v0_0_2>);
|
|
@@ -265,7 +265,7 @@ export class MigrationShim extends EventEmitterWithErrorHandling<IMigrationEvent
|
|
|
265
265
|
* twice, we will be in a "v2" state even though we really are in a "v1" state. We will encounter unexpected op
|
|
266
266
|
* dropping behavior or lack thereof and may corrupt the document.
|
|
267
267
|
* @param services - the services to generate the shim services from
|
|
268
|
-
* @returns
|
|
268
|
+
* @returns shim services
|
|
269
269
|
*/
|
|
270
270
|
private generateShimServicesOnce(services: IChannelServices): IShimChannelServices {
|
|
271
271
|
assert(
|