@fluid-experimental/tree 2.0.0-rc.2.0.6 → 2.0.0-rc.2.0.7
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/api-report/experimental-tree.api.md +1 -1
- package/dist/SharedTree.d.ts +4 -2
- package/dist/SharedTree.d.ts.map +1 -1
- package/dist/SharedTree.js +16 -5
- package/dist/SharedTree.js.map +1 -1
- package/dist/migration-shim/migrationShim.js +1 -1
- package/dist/migration-shim/migrationShim.js.map +1 -1
- package/dist/tree-alpha.d.ts +3 -1
- package/dist/tree-untrimmed.d.ts +3 -1
- package/lib/SharedTree.d.ts +4 -2
- package/lib/SharedTree.d.ts.map +1 -1
- package/lib/SharedTree.js +16 -5
- package/lib/SharedTree.js.map +1 -1
- package/lib/migration-shim/migrationShim.js +1 -1
- package/lib/migration-shim/migrationShim.js.map +1 -1
- package/package.json +21 -21
- package/src/SharedTree.ts +25 -6
- package/src/migration-shim/migrationShim.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationShim.js","sourceRoot":"","sources":["../../src/migration-shim/migrationShim.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,iFAAoE;AAepE,2DAAoD;AACpD,+EAAmG;AAEnG,qEAAqG;AAMrG,qEAA8F;AAC9F,yEAAuE;AACvE,qEAA6F;AAC7F,mDAA6C;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,MAAa,aAAc,SAAQ,+CAA8C;IAChF,YACiB,EAAU,EACT,OAA+B,EAC/B,iBAA0C,EAC1C,cAA+B,EAC/B,yBAAiF;QAElG,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAN9E,OAAE,GAAF,EAAE,CAAQ;QACT,YAAO,GAAP,OAAO,CAAwB;QAC/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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;AA7MD,sCA6MC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport {\n\tIChannelFactory,\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from '@fluidframework/datastore-definitions';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ITelemetryContext,\n\ttype ISummaryTreeWithStats,\n} from '@fluidframework/runtime-definitions';\nimport { type ITree } from '@fluidframework/tree';\nimport { assert } from '@fluidframework/core-utils';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport type { SessionId, IIdCompressorCore } from '@fluidframework/id-compressor';\nimport {\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n\ttype SharedTree as LegacySharedTree,\n} from '../SharedTree.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim, type IOpContents } 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,\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) as ITree;\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: 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(): 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;AACH,iFAAoE;AAepE,2DAAoD;AACpD,+EAAmG;AAEnG,qEAAqG;AAMrG,qEAA8F;AAC9F,yEAAuE;AACvE,qEAA6F;AAC7F,mDAA6C;AAmC7C,MAAM,cAAc,GAAG,sCAAmD,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,MAAa,aAAc,SAAQ,+CAA8C;IAChF,YACiB,EAAU,EACT,OAA+B,EAC/B,iBAA0C,EAC1C,cAA+B,EAC/B,yBAAiF;QAElG,KAAK,CAAC,CAAC,KAA4B,EAAE,CAAU,EAAE,EAAE,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAC,CA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AAG,IAAI,oDAA2B,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;AA7MD,sCA6MC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from '@fluidframework/container-definitions';\nimport { type IEvent, type IFluidHandle, type IFluidLoadable } from '@fluidframework/core-interfaces';\nimport {\n\tIChannelFactory,\n\ttype IChannelAttributes,\n\ttype IChannelServices,\n\ttype IFluidDataStoreRuntime,\n} from '@fluidframework/datastore-definitions';\nimport {\n\ttype IExperimentalIncrementalSummaryContext,\n\ttype IGarbageCollectionData,\n\ttype ITelemetryContext,\n\ttype ISummaryTreeWithStats,\n} from '@fluidframework/runtime-definitions';\nimport { type ITree } from '@fluidframework/tree';\nimport { assert } from '@fluidframework/core-utils';\nimport { MessageType, type ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';\nimport { type EventEmitterEventType } from '@fluid-internal/client-utils';\nimport { DataProcessingError, EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';\nimport type { SessionId, IIdCompressorCore } from '@fluidframework/id-compressor';\nimport {\n\ttype SharedTreeFactory as LegacySharedTreeFactory,\n\ttype SharedTree as LegacySharedTree,\n} from '../SharedTree.js';\nimport { type IShimChannelServices, NoDeltasChannelServices } from './shimChannelServices.js';\nimport { MigrationShimDeltaHandler } from './migrationDeltaHandler.js';\nimport { PreMigrationDeltaConnection, StampDeltaConnection } from './shimDeltaConnection.js';\nimport { ShimHandle } from './shimHandle.js';\nimport { type IShim, type IOpContents } 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,\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) as ITree;\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: 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(): 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)) as LegacySharedTree;\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/dist/tree-alpha.d.ts
CHANGED
|
@@ -1727,6 +1727,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
1727
1727
|
* Parses a sequenced edit. This is only invoked for ops with version matching the current `writeFormat`.
|
|
1728
1728
|
*/
|
|
1729
1729
|
private parseSequencedEdit;
|
|
1730
|
+
private encodeSemiSerializedEdit;
|
|
1730
1731
|
private processSequencedEdit;
|
|
1731
1732
|
/**
|
|
1732
1733
|
* Updates SharedTree to the provided version if the version is a valid write version newer than the current version.
|
|
@@ -1783,6 +1784,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
1783
1784
|
* Submits an edit by the local client to the runtime.
|
|
1784
1785
|
*/
|
|
1785
1786
|
private submitEditOp;
|
|
1787
|
+
private serializeEdit;
|
|
1786
1788
|
/** A type-safe `submitLocalMessage` wrapper to enforce op format */
|
|
1787
1789
|
private submitOp;
|
|
1788
1790
|
getRuntime(): IFluidDataStoreRuntime;
|
|
@@ -1913,7 +1915,7 @@ export declare class SharedTreeFactory implements IChannelFactory {
|
|
|
1913
1915
|
/**
|
|
1914
1916
|
* {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.load}
|
|
1915
1917
|
*/
|
|
1916
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<
|
|
1918
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<IChannel>;
|
|
1917
1919
|
/**
|
|
1918
1920
|
* Create a new SharedTree.
|
|
1919
1921
|
* @param runtime - data store runtime that owns the new SharedTree
|
package/dist/tree-untrimmed.d.ts
CHANGED
|
@@ -2358,6 +2358,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
2358
2358
|
* Parses a sequenced edit. This is only invoked for ops with version matching the current `writeFormat`.
|
|
2359
2359
|
*/
|
|
2360
2360
|
private parseSequencedEdit;
|
|
2361
|
+
private encodeSemiSerializedEdit;
|
|
2361
2362
|
private processSequencedEdit;
|
|
2362
2363
|
/**
|
|
2363
2364
|
* Updates SharedTree to the provided version if the version is a valid write version newer than the current version.
|
|
@@ -2414,6 +2415,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
2414
2415
|
* Submits an edit by the local client to the runtime.
|
|
2415
2416
|
*/
|
|
2416
2417
|
private submitEditOp;
|
|
2418
|
+
private serializeEdit;
|
|
2417
2419
|
/** A type-safe `submitLocalMessage` wrapper to enforce op format */
|
|
2418
2420
|
private submitOp;
|
|
2419
2421
|
getRuntime(): IFluidDataStoreRuntime;
|
|
@@ -2596,7 +2598,7 @@ export declare class SharedTreeFactory implements IChannelFactory {
|
|
|
2596
2598
|
/**
|
|
2597
2599
|
* {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.load}
|
|
2598
2600
|
*/
|
|
2599
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<
|
|
2601
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<IChannel>;
|
|
2600
2602
|
/**
|
|
2601
2603
|
* Create a new SharedTree.
|
|
2602
2604
|
* @param runtime - data store runtime that owns the new SharedTree
|
package/lib/SharedTree.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, IChannelAttributes, IChannelServices } from '@fluidframework/datastore-definitions';
|
|
5
|
+
import { IFluidDataStoreRuntime, IChannelStorageService, IChannelFactory, IChannelAttributes, IChannelServices, IChannel } from '@fluidframework/datastore-definitions';
|
|
6
6
|
import { IFluidSerializer, ISharedObjectEvents, SharedObject } from '@fluidframework/shared-object-base';
|
|
7
7
|
import { ITelemetryBaseProperties } from '@fluidframework/core-interfaces';
|
|
8
8
|
import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
|
|
@@ -126,7 +126,7 @@ export declare class SharedTreeFactory implements IChannelFactory {
|
|
|
126
126
|
/**
|
|
127
127
|
* {@inheritDoc @fluidframework/shared-object-base#ISharedObjectFactory.load}
|
|
128
128
|
*/
|
|
129
|
-
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<
|
|
129
|
+
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, _channelAttributes: Readonly<IChannelAttributes>): Promise<IChannel>;
|
|
130
130
|
/**
|
|
131
131
|
* Create a new SharedTree.
|
|
132
132
|
* @param runtime - data store runtime that owns the new SharedTree
|
|
@@ -437,6 +437,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
437
437
|
* Parses a sequenced edit. This is only invoked for ops with version matching the current `writeFormat`.
|
|
438
438
|
*/
|
|
439
439
|
private parseSequencedEdit;
|
|
440
|
+
private encodeSemiSerializedEdit;
|
|
440
441
|
private processSequencedEdit;
|
|
441
442
|
/**
|
|
442
443
|
* Updates SharedTree to the provided version if the version is a valid write version newer than the current version.
|
|
@@ -493,6 +494,7 @@ export declare class SharedTree extends SharedObject<ISharedTreeEvents> implemen
|
|
|
493
494
|
* Submits an edit by the local client to the runtime.
|
|
494
495
|
*/
|
|
495
496
|
private submitEditOp;
|
|
497
|
+
private serializeEdit;
|
|
496
498
|
/** A type-safe `submitLocalMessage` wrapper to enforce op format */
|
|
497
499
|
private submitOp;
|
|
498
500
|
getRuntime(): IFluidDataStoreRuntime;
|
package/lib/SharedTree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedTree.d.ts","sourceRoot":"","sources":["../src/SharedTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEN,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EACN,mBAAmB,EAMnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE/F,OAAO,EAAuB,cAAc,EAAE,MAAM,cAAc,CAAC;AAC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,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;IAa/G;;;OAGG;IACI,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc;IAmExD,OAAO,CAAC,gBAAgB;IAgBxB;;;;OAIG;IACI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAYjD;;;;;OAKG;IACI,aAAa,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,EAAE,MAAM,EAAE,YAAY,GAAG,cAAc,EAAE,GAAG,SAAS;IAIhH;;OAEG;IACH,OAAO,CAAC,YAAY;IAyBpB,OAAO,CAAC,aAAa;IAIrB,oEAAoE;IACpE,OAAO,CAAC,QAAQ;IAQT,UAAU,IAAI,sBAAsB;IAI3C;;;;;;;;OAQG;IACH,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;IA2F3C,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,sBAAsB,GAAG,IAAI;IAoBnF,OAAO,CAAC,iBAAiB;IAKzB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;CAuB7B"}
|
package/lib/SharedTree.js
CHANGED
|
@@ -607,13 +607,21 @@ export class SharedTree extends SharedObject {
|
|
|
607
607
|
// TODO:Type Safety: Improve type safety around op sending/parsing (e.g. discriminated union over version field somehow)
|
|
608
608
|
switch (op.version) {
|
|
609
609
|
case WriteFormat.v0_0_2:
|
|
610
|
-
return this.encoder_0_0_2.decodeEditOp(op, (
|
|
610
|
+
return this.encoder_0_0_2.decodeEditOp(op, this.encodeSemiSerializedEdit.bind(this), this);
|
|
611
611
|
case WriteFormat.v0_1_1:
|
|
612
|
-
return this.encoder_0_1_1.decodeEditOp(op, (
|
|
612
|
+
return this.encoder_0_1_1.decodeEditOp(op, this.encodeSemiSerializedEdit.bind(this), this.idNormalizer, this.interner);
|
|
613
613
|
default:
|
|
614
614
|
fail('Unknown op version');
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
+
encodeSemiSerializedEdit(semiSerializedEdit) {
|
|
618
|
+
// semiSerializedEdit may have handles which have been replaced by `serializer.encode`.
|
|
619
|
+
// Since there is no API to un-replace them except via parse, re-stringify the edit, then parse it.
|
|
620
|
+
// Stringify using JSON, not IFluidSerializer since OPs use JSON directly.
|
|
621
|
+
// TODO:Performance:#48025: Avoid this serialization round trip.
|
|
622
|
+
const encodedEdit = this.serializer.parse(JSON.stringify(semiSerializedEdit));
|
|
623
|
+
return encodedEdit;
|
|
624
|
+
}
|
|
617
625
|
processSequencedEdit(edit, message) {
|
|
618
626
|
const { id: editId } = edit;
|
|
619
627
|
const wasLocalEdit = this.editLog.isLocalEdit(editId);
|
|
@@ -864,16 +872,19 @@ export class SharedTree extends SharedObject {
|
|
|
864
872
|
if (this.isAttached()) {
|
|
865
873
|
switch (this.writeFormat) {
|
|
866
874
|
case WriteFormat.v0_0_2:
|
|
867
|
-
this.submitOp(this.encoder_0_0_2.encodeEditOp(edit, (
|
|
875
|
+
this.submitOp(this.encoder_0_0_2.encodeEditOp(edit, this.serializeEdit.bind(this), this));
|
|
868
876
|
break;
|
|
869
877
|
case WriteFormat.v0_1_1:
|
|
870
|
-
this.submitOp(this.encoder_0_1_1.encodeEditOp(edit, (
|
|
878
|
+
this.submitOp(this.encoder_0_1_1.encodeEditOp(edit, this.serializeEdit.bind(this), this.idCompressor.takeNextCreationRange(), this.idNormalizer, this.interner));
|
|
871
879
|
break;
|
|
872
880
|
default:
|
|
873
881
|
fail('Unknown version');
|
|
874
882
|
}
|
|
875
883
|
}
|
|
876
884
|
}
|
|
885
|
+
serializeEdit(preparedEdit) {
|
|
886
|
+
return this.serializer.encode(preparedEdit, this.handle);
|
|
887
|
+
}
|
|
877
888
|
/** A type-safe `submitLocalMessage` wrapper to enforce op format */
|
|
878
889
|
submitOp(content, localOpMetadata = undefined) {
|
|
879
890
|
assert(compareSummaryFormatVersions(content.version, this.writeFormat) === 0, 0x631 /* Attempted to submit op of wrong version */);
|
|
@@ -941,7 +952,7 @@ export class SharedTree extends SharedObject {
|
|
|
941
952
|
},
|
|
942
953
|
normalizeToOpSpace: (id) => this.idNormalizer.normalizeToOpSpace(id),
|
|
943
954
|
};
|
|
944
|
-
stashedEdit = this.encoder_0_1_1.decodeEditOp(sharedTreeOp, (
|
|
955
|
+
stashedEdit = this.encoder_0_1_1.decodeEditOp(sharedTreeOp, this.encodeSemiSerializedEdit.bind(this), normalizer, this.interner);
|
|
945
956
|
break;
|
|
946
957
|
}
|
|
947
958
|
default:
|