@fluidframework/shared-object-base 2.92.0 → 2.100.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 +32 -0
- package/README.md +1 -1
- package/dist/handle.js +1 -1
- package/dist/handle.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sharedObject.d.ts +2 -1
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +5 -4
- package/dist/sharedObject.js.map +1 -1
- package/dist/sharedObjectKernel.d.ts +3 -3
- package/dist/sharedObjectKernel.d.ts.map +1 -1
- package/dist/sharedObjectKernel.js +10 -8
- package/dist/sharedObjectKernel.js.map +1 -1
- package/eslint.config.mts +1 -1
- package/lib/handle.js +2 -2
- package/lib/handle.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sharedObject.d.ts +2 -1
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +6 -5
- package/lib/sharedObject.js.map +1 -1
- package/lib/sharedObjectKernel.d.ts +3 -3
- package/lib/sharedObjectKernel.d.ts.map +1 -1
- package/lib/sharedObjectKernel.js +10 -8
- package/lib/sharedObjectKernel.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +23 -24
- package/src/handle.ts +2 -2
- package/src/packageVersion.ts +1 -1
- package/src/sharedObject.ts +8 -5
- package/src/sharedObjectKernel.ts +17 -12
|
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
15
15
|
};
|
|
16
16
|
var _SharedObjectFromKernel_instances, _SharedObjectFromKernel_lazyData, _SharedObjectFromKernel_kernelArgs, _SharedObjectFromKernel_initializeData, _SharedObjectFromKernel_kernel_get;
|
|
17
17
|
import { assert, fail } from "@fluidframework/core-utils/internal";
|
|
18
|
+
import { extractTelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
18
19
|
import { createSharedObjectKind, SharedObject, } from "./sharedObject.js";
|
|
19
20
|
/**
|
|
20
21
|
* SharedObject implementation that delegates to a SharedKernel.
|
|
@@ -41,22 +42,23 @@ class SharedObjectFromKernel extends SharedObject {
|
|
|
41
42
|
*/
|
|
42
43
|
_SharedObjectFromKernel_lazyData.set(this, undefined);
|
|
43
44
|
_SharedObjectFromKernel_kernelArgs.set(this, void 0);
|
|
45
|
+
// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern
|
|
46
|
+
// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes
|
|
47
|
+
// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the
|
|
48
|
+
// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler
|
|
49
|
+
// would emit an error.
|
|
50
|
+
const minVersionForCollab = runtime.minVersionForCollab;
|
|
51
|
+
assert(minVersionForCollab !== undefined, 0xcee /* minVersionForCollab must be defined */);
|
|
44
52
|
__classPrivateFieldSet(this, _SharedObjectFromKernel_kernelArgs, {
|
|
45
53
|
sharedObject: this,
|
|
46
54
|
serializer: this.serializer,
|
|
47
55
|
submitLocalMessage: (op, localOpMetadata) => this.submitLocalMessage(op, localOpMetadata),
|
|
48
56
|
eventEmitter: this,
|
|
49
|
-
logger: this.logger,
|
|
57
|
+
logger: extractTelemetryLoggerExt(this.logger),
|
|
50
58
|
idCompressor: runtime.idCompressor,
|
|
51
59
|
lastSequenceNumber: () => this.deltaManager.lastSequenceNumber,
|
|
52
60
|
initialSequenceNumber: this.deltaManager.initialSequenceNumber,
|
|
53
|
-
|
|
54
|
-
// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes
|
|
55
|
-
// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the
|
|
56
|
-
// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler
|
|
57
|
-
// would emit an error.
|
|
58
|
-
minVersionForCollab: runtime
|
|
59
|
-
.minVersionForCollab,
|
|
61
|
+
minVersionForCollab,
|
|
60
62
|
}, "f");
|
|
61
63
|
}
|
|
62
64
|
summarizeCore(serializer, telemetryContext, incrementalSummaryContext, fullTree) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObjectKernel.js","sourceRoot":"","sources":["../src/sharedObjectKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAIH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,qCAAqC,CAAC;AAqBnE,OAAO,EACN,sBAAsB,EACtB,YAAY,GAGZ,MAAM,mBAAmB,CAAC;AAmE3B;;;;;;;;;;;GAWG;AACH,MAAM,sBAGJ,SAAQ,YAAoB;IAW7B,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B,EACd,OAAkC,EAClD,sBAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;;QAHvC,YAAO,GAAP,OAAO,CAA2B;QAdnD;;;;;WAKG;QACH,2CAA0C,SAAS,EAAC;QAE3C,qDAAwB;QAWhC,uBAAA,IAAI,sCAAe;YAClB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,kBAAkB,EAAE,CAAC,EAAE,EAAE,eAAe,EAAE,EAAE,CAC3C,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,eAAe,CAAC;YAC7C,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,k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I,CAAC;QAC5B,CAAC;QAED;;WAEG;QACH,IAAW,UAAU;YACpB,OAAO,cAAc,CAAC,UAAU,CAAC;QAClC,CAAC;QAED;;WAEG;QACI,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;YAE9B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,UAAU,EACV,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,MAAiC,CAAC;QAC1C,CAAC;QAED;;WAEG;QACI,MAAM,CAAC,OAA+B,EAAE,EAAU;YACxD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,sBAAsB,CAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: this.logger,\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\n\t\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t\t// would emit an error.\n\t\t\tminVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)\n\t\t\t\t.minVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(0xcb0 /* must initializeData first */)).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: ITelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab | undefined;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]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AA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;YAE9B,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,UAAU,EACV,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,MAAiC,CAAC;QAC1C,CAAC;QAED;;WAEG;QACI,MAAM,CAAC,OAA+B,EAAE,EAAU;YACxD,MAAM,MAAM,GAAG,IAAI,sBAAsB,CACxC,EAAE,EACF,OAAO,EACP,cAAc,CAAC,UAAU,EACzB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,sBAAsB,CAC9B,CAAC;YAEF,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,OAAO,MAAiC,CAAC;QAC1C,CAAC;;IA3DD;;OAEG;IACoB,mBAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACoB,yBAAU,GAAuB,OAAO,CAAC,UAAU,CAAC;IAsD5E,OAAO,cAAc,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAA+B;IAE/B,OAAO,sBAAsB,CAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { assert, fail } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelStorageService,\n\tIChannel,\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIChannelServices,\n\tIFluidDataStoreRuntime,\n\tIFluidDataStoreRuntimeInternalConfig,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { IIdCompressor } from \"@fluidframework/id-compressor/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIExperimentalIncrementalSummaryContext,\n\tIRuntimeMessageCollection,\n\tMinimumVersionForCollab,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { TelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport { extractTelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidSerializer } from \"./serializer.js\";\nimport {\n\tcreateSharedObjectKind,\n\tSharedObject,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n} from \"./sharedObject.js\";\nimport type { ISharedObjectEvents, ISharedObject } from \"./types.js\";\nimport type { IChannelView } from \"./utils.js\";\n\n/**\n * Functionality specific to a particular kind of {@link ISharedObject}.\n * @remarks\n * Shared objects expose APIs for two consumers:\n *\n * 1. The runtime, which uses {@link @fluidframework/datastore-definitions#IChannel} to summarize and apply ops and {@link @fluidframework/datastore-definitions#IChannelFactory} to create the load summaries.\n *\n * 2. The app, which uses shared object kind specific APIs to read and write data.\n *\n * There is some common functionality all shared objects use, provided by {@link SharedObject} and {@link SharedObjectCore}.\n * SharedKernel describes the portion of the behavior required by the runtime which\n * differs between different kinds of shared objects.\n *\n * {@link makeSharedObjectKind} is then used to wrap up the kernel into a full {@link ISharedObject} implementation.\n * The runtime specific APIs are then type erased into a {@link SharedObjectKind}.\n * @privateRemarks\n * Unlike the `SharedObject` class, this interface is internal, and thus can be adjusted more easily.\n * Therefore this interface is not intended to address all needs, and will likely need small changes as it gets more adoption.\n *\n * @internal\n */\nexport interface SharedKernel {\n\t/**\n\t * {@inheritDoc SharedObject.summarizeCore}\n\t */\n\tsummarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext: ITelemetryContext | undefined,\n\t\tincrementalSummaryContext: IExperimentalIncrementalSummaryContext | undefined,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.onDisconnect}\n\t */\n\tonDisconnect(): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.reSubmitCore}\n\t */\n\treSubmitCore(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.applyStashedOp}\n\t */\n\tapplyStashedOp(content: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.processMessagesCore}\n\t */\n\tprocessMessagesCore(messagesCollection: IRuntimeMessageCollection): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.rollback}\n\t */\n\trollback?(content: unknown, localOpMetadata: unknown): void;\n\n\t/**\n\t * {@inheritDoc SharedObjectCore.didAttach}\n\t */\n\tdidAttach?(): void;\n}\n\n/**\n * SharedObject implementation that delegates to a SharedKernel.\n * @typeParam TOut - The type of the object exposed to the app.\n * Once initialized, instances of this class forward properties to the `TOut` value provided by the factory.\n * See {@link mergeAPIs} for more limitations.\n *\n * @remarks\n * The App facing API (TOut) needs to be implemented by this object which also has to implement the runtime facing API (ISharedObject).\n *\n * Requiring both of these to be implemented by the same object adds some otherwise unnecessary coupling.\n * This class is a workaround for that, which takes separate implementations of the two APIs and merges them into one using {@link mergeAPIs}.\n */\nclass SharedObjectFromKernel<\n\tTOut extends object,\n\tTEvent extends ISharedObjectEvents,\n> extends SharedObject<TEvent> {\n\t/**\n\t * Lazy init here so kernel can be constructed in loadCore when loading from existing data.\n\t *\n\t * Explicit initialization to undefined is done so Proxy knows this property is from this class (via `Reflect.has`),\n\t * not from the grafted APIs.\n\t */\n\t#lazyData: FactoryOut<TOut> | undefined = undefined;\n\n\treadonly #kernelArgs: KernelArgs;\n\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tpublic readonly factory: SharedKernelFactory<TOut>,\n\t\ttelemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes, telemetryContextPrefix);\n\n\t\t// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern\n\t\t// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes\n\t\t// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the\n\t\t// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler\n\t\t// would emit an error.\n\t\tconst minVersionForCollab: MinimumVersionForCollab | undefined = (\n\t\t\truntime as IFluidDataStoreRuntimeInternalConfig\n\t\t).minVersionForCollab;\n\n\t\tassert(minVersionForCollab !== undefined, 0xcee /* minVersionForCollab must be defined */);\n\n\t\tthis.#kernelArgs = {\n\t\t\tsharedObject: this,\n\t\t\tserializer: this.serializer,\n\t\t\tsubmitLocalMessage: (op, localOpMetadata) =>\n\t\t\t\tthis.submitLocalMessage(op, localOpMetadata),\n\t\t\teventEmitter: this,\n\t\t\tlogger: extractTelemetryLoggerExt(this.logger),\n\t\t\tidCompressor: runtime.idCompressor,\n\t\t\tlastSequenceNumber: () => this.deltaManager.lastSequenceNumber,\n\t\t\tinitialSequenceNumber: this.deltaManager.initialSequenceNumber,\n\t\t\tminVersionForCollab,\n\t\t};\n\t}\n\n\tprotected override summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t\tfullTree?: boolean,\n\t): ISummaryTreeWithStats {\n\t\treturn this.#kernel.summarizeCore(\n\t\t\tserializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t\tfullTree,\n\t\t);\n\t}\n\n\tprotected override initializeLocalCore(): void {\n\t\tthis.#initializeData(this.factory.create(this.#kernelArgs));\n\t}\n\n\t#initializeData(data: FactoryOut<TOut>): void {\n\t\tassert(\n\t\t\tthis.#lazyData === undefined,\n\t\t\t0xb99 /* initializeData must be called first and only once */,\n\t\t);\n\t\tthis.#lazyData = data;\n\n\t\t// Make `this` implement TOut.\n\t\tmergeAPIs(this, data.view);\n\t}\n\n\tget #kernel(): SharedKernel {\n\t\treturn (this.#lazyData ?? fail(0xcb0 /* must initializeData first */)).kernel;\n\t}\n\n\tprotected override async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tthis.#initializeData(await this.factory.loadCore(this.#kernelArgs, storage));\n\t}\n\n\tprotected override onDisconnect(): void {\n\t\tthis.#kernel.onDisconnect();\n\t}\n\n\tprotected override reSubmitCore(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.#kernel.reSubmitCore(content, localOpMetadata);\n\t}\n\n\tprotected override applyStashedOp(content: unknown): void {\n\t\tthis.#kernel.applyStashedOp(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tthis.#kernel.processMessagesCore(messagesCollection);\n\t}\n\n\tprotected override rollback(content: unknown, localOpMetadata: unknown): void {\n\t\tif (this.#kernel.rollback === undefined) {\n\t\t\tsuper.rollback(content, localOpMetadata);\n\t\t} else {\n\t\t\tthis.#kernel.rollback(content, localOpMetadata);\n\t\t}\n\t}\n\n\tprotected override didAttach(): void {\n\t\tthis.#kernel.didAttach?.();\n\t}\n}\n\n/**\n * When present on a method, it indicates the methods return value should be replaced with `this` (the wrapper)\n * when wrapping the object with the method.\n * @remarks\n * This is useful when using {@link mergeAPIs} with methods where the return type is `this`, like `Map.set`.\n * @internal\n */\nexport const thisWrap: unique symbol = Symbol(\"selfWrap\");\n\n/**\n * A {@link SharedKernel} providing the implementation of some distributed data structure (DDS) and the needed runtime facing APIs,\n * and a separate view object which exposes the app facing APIs (`T`)\n * for reading and writing data which are specific to this particular data structure.\n * @remarks\n * Output from {@link SharedKernelFactory}.\n * This is an alternative to defining DDSs by sub-classing {@link SharedObject}.\n * @internal\n */\nexport interface FactoryOut<T extends object> {\n\treadonly kernel: SharedKernel;\n\treadonly view: T;\n}\n\n/**\n * A factory for creating DDSs.\n * @remarks\n * Outputs {@link FactoryOut}.\n * This is an alternative to directly implementing {@link @fluidframework/datastore-definitions#IChannelFactory}.\n * Use with {@link makeSharedObjectKind} to create a {@link SharedObjectKind}.\n * @internal\n */\nexport interface SharedKernelFactory<T extends object> {\n\tcreate(args: KernelArgs): FactoryOut<T>;\n\n\t/**\n\t * Create combined with {@link SharedObjectCore.loadCore}.\n\t */\n\tloadCore(args: KernelArgs, storage: IChannelStorageService): Promise<FactoryOut<T>>;\n}\n\n/**\n * Inputs for building a {@link SharedKernel} via {@link SharedKernelFactory}.\n * @internal\n */\nexport interface KernelArgs {\n\t/**\n\t * The shared object whose behavior is being implemented.\n\t */\n\treadonly sharedObject: IChannelView & IFluidLoadable;\n\t/**\n\t * {@inheritdoc SharedObject.serializer}\n\t */\n\treadonly serializer: IFluidSerializer;\n\t/**\n\t * {@inheritdoc SharedObjectCore.submitLocalMessage}\n\t */\n\treadonly submitLocalMessage: (op: unknown, localOpMetadata: unknown) => void;\n\t/**\n\t * Top level emitter for events for this object.\n\t * @remarks\n\t * This is needed since the separate kernel and view from {@link FactoryOut} currently have to be recombined,\n\t * and having this as its own thing helps accomplish that.\n\t */\n\treadonly eventEmitter: TypedEventEmitter<ISharedObjectEvents>;\n\t/**\n\t * {@inheritdoc SharedObjectCore.logger}\n\t */\n\treadonly logger: TelemetryLoggerExt;\n\t/**\n\t * {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}\n\t */\n\treadonly idCompressor: IIdCompressor | undefined;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.lastSequenceNumber}\n\t */\n\treadonly lastSequenceNumber: () => number;\n\t/**\n\t * {@inheritdoc @fluidframework/container-definitions#IDeltaManager.initialSequenceNumber}\n\t */\n\treadonly initialSequenceNumber: number;\n\t/**\n\t * Minimum version of the FF runtime that is required to collaborate on new documents. Used so that a\n\t * compatible set of feature flags and formats can be enabled in the SharedObject implementation.\n\t * See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.\n\t */\n\treadonly minVersionForCollab: MinimumVersionForCollab;\n}\n\n/**\n * Add getters to `base` which forward own properties from `extra`.\n * @remarks\n * This only handles use of \"get\" and \"has\".\n * Therefore, APIs involving setting properties should not be used as `Extra`.\n *\n * Functions from `extra` are bound to the `extra` object and support {@link thisWrap}.\n *\n * Asserts when properties collide.\n * @internal\n */\nexport function mergeAPIs<const Base extends object, const Extra extends object>(\n\tbase: Base,\n\textra: Extra,\n): asserts base is Base & Extra {\n\tfor (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(extra))) {\n\t\tassert(!Reflect.has(base, key), 0xb9a /* colliding properties */);\n\n\t\t// Detect and special case functions.\n\t\t// Currently this is done eagerly (when mergeAPIs is called) rather than lazily (when the property is read):\n\t\t// this eager approach should result in slightly better performance,\n\t\t// but if functions on `extra` are reassigned over time it will produce incorrect behavior.\n\t\t// If this functionality is required, the design can be changed.\n\t\tlet getter: () => unknown;\n\t\t// Bind functions to the extra object and handle thisWrap.\n\t\tif (typeof descriptor.value === \"function\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tconst fromExtra: () => Extra | Base = descriptor.value;\n\t\t\tgetter = () => forwardMethod(fromExtra, extra, base);\n\t\t\t// To catch (and error on) cases where the function is reassigned and this eager binding approach is not appropriate, make it non-writable.\n\t\t\tObject.defineProperty(extra, key, { ...descriptor, writable: false });\n\t\t} else {\n\t\t\tgetter = () => extra[key];\n\t\t}\n\n\t\tObject.defineProperty(base, key, {\n\t\t\tconfigurable: false,\n\t\t\tenumerable: descriptor.enumerable,\n\t\t\tget: getter,\n\t\t\t// If setters become required, support them here.\n\t\t});\n\t}\n}\n\n/**\n * Wrap a method `f` of `oldThis` to be a method of `newThis`.\n * @remarks\n * The wrapped function will be called with `oldThis` as the `this` parameter.\n * It also accounts for when `f` is marked with {@link thisWrap}.\n */\nfunction forwardMethod<TArgs extends [], TReturn>(\n\tf: (...args: TArgs) => TReturn,\n\toldThis: TReturn,\n\tnewThis: TReturn,\n): (...args: TArgs) => TReturn {\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (thisWrap in f) {\n\t\treturn (...args: TArgs) => {\n\t\t\tconst result = f.call(oldThis, ...args);\n\t\t\tassert(result === oldThis, 0xb9b /* methods returning thisWrap should return this */);\n\t\t\treturn newThis;\n\t\t};\n\t} else {\n\t\treturn f.bind(oldThis);\n\t}\n}\n\n/**\n * Options for creating a {@link SharedObjectKind} via {@link makeSharedObjectKind}.\n * @typeParam T - The type of the object exposed to the app.\n * This can optionally include members from {@link ISharedObject} which will be provided automatically.\n * @internal\n */\nexport interface SharedObjectOptions<T extends object> {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\treadonly type: string;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\treadonly attributes: IChannelAttributes;\n\n\t/**\n\t * The factory used to create the kernel and its view.\n\t * @remarks\n\t * The view produced by this factory will be grafted onto the {@link SharedObject} using {@link mergeAPIs}.\n\t * See {@link mergeAPIs} for more information on limitations that apply.\n\t */\n\treadonly factory: SharedKernelFactory<Omit<T, keyof ISharedObject>>;\n\n\t/**\n\t * {@inheritDoc SharedObject.telemetryContextPrefix}\n\t */\n\treadonly telemetryContextPrefix: string;\n}\n\n/**\n * Utility to create a {@link @fluidframework/datastore-definitions#IChannelFactory} classes.\n * @remarks\n * Use {@link makeSharedObjectKind} instead unless exposing the factory is required for legacy API compatibility.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction makeChannelFactory<T extends object>(options: SharedObjectOptions<T>) {\n\tclass ChannelFactory implements IChannelFactory<T> {\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic static readonly Type = options.type;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic static readonly Attributes: IChannelAttributes = options.attributes;\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t\t */\n\t\tpublic get type(): string {\n\t\t\treturn ChannelFactory.Type;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t\t */\n\t\tpublic get attributes(): IChannelAttributes {\n\t\t\treturn ChannelFactory.Attributes;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}\n\t\t */\n\t\tpublic async load(\n\t\t\truntime: IFluidDataStoreRuntime,\n\t\t\tid: string,\n\t\t\tservices: IChannelServices,\n\t\t\tattributes: IChannelAttributes,\n\t\t): Promise<T & IChannel> {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tattributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\t\t\tawait shared.load(services);\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}\n\t\t */\n\t\tpublic create(runtime: IFluidDataStoreRuntime, id: string): T & IChannel {\n\t\t\tconst shared = new SharedObjectFromKernel(\n\t\t\t\tid,\n\t\t\t\truntime,\n\t\t\t\tChannelFactory.Attributes,\n\t\t\t\toptions.factory,\n\t\t\t\toptions.telemetryContextPrefix,\n\t\t\t);\n\n\t\t\tshared.initializeLocal();\n\n\t\t\treturn shared as unknown as T & IChannel;\n\t\t}\n\t}\n\n\treturn ChannelFactory;\n}\n\n/**\n * Utility to create a {@link SharedObjectKind}.\n * @privateRemarks\n * Using this API avoids having to subclasses any Fluid Framework types,\n * reducing the coupling between the framework and the SharedObject implementation.\n * @internal\n */\nexport function makeSharedObjectKind<T extends object>(\n\toptions: SharedObjectOptions<T>,\n): ISharedObjectKind<T> & SharedObjectKind<T> {\n\treturn createSharedObjectKind<T>(makeChannelFactory(options));\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/shared-object-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.100.0",
|
|
4
4
|
"description": "Fluid base class for shared distributed data structures",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,34 +69,34 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/core-interfaces": "~2.
|
|
75
|
-
"@fluidframework/core-utils": "~2.
|
|
76
|
-
"@fluidframework/datastore": "~2.
|
|
77
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/id-compressor": "~2.
|
|
80
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
81
|
-
"@fluidframework/runtime-utils": "~2.
|
|
82
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.100.0",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.100.0",
|
|
74
|
+
"@fluidframework/core-interfaces": "~2.100.0",
|
|
75
|
+
"@fluidframework/core-utils": "~2.100.0",
|
|
76
|
+
"@fluidframework/datastore": "~2.100.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": "~2.100.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.100.0",
|
|
79
|
+
"@fluidframework/id-compressor": "~2.100.0",
|
|
80
|
+
"@fluidframework/runtime-definitions": "~2.100.0",
|
|
81
|
+
"@fluidframework/runtime-utils": "~2.100.0",
|
|
82
|
+
"@fluidframework/telemetry-utils": "~2.100.0",
|
|
83
83
|
"uuid": "^11.1.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
87
87
|
"@biomejs/biome": "~2.4.5",
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
89
|
-
"@fluid-private/test-pairwise-generator": "~2.
|
|
90
|
-
"@fluid-tools/benchmark": "^0.
|
|
91
|
-
"@fluid-tools/build-cli": "^0.
|
|
88
|
+
"@fluid-internal/mocha-test-setup": "~2.100.0",
|
|
89
|
+
"@fluid-private/test-pairwise-generator": "~2.100.0",
|
|
90
|
+
"@fluid-tools/benchmark": "^0.58.0",
|
|
91
|
+
"@fluid-tools/build-cli": "^0.65.0",
|
|
92
92
|
"@fluidframework/build-common": "^2.0.3",
|
|
93
|
-
"@fluidframework/build-tools": "^0.
|
|
93
|
+
"@fluidframework/build-tools": "^0.65.0",
|
|
94
94
|
"@fluidframework/eslint-config-fluid": "^9.0.0",
|
|
95
|
-
"@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.
|
|
96
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
97
|
-
"@microsoft/api-extractor": "7.
|
|
95
|
+
"@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.92.0",
|
|
96
|
+
"@fluidframework/test-runtime-utils": "~2.100.0",
|
|
97
|
+
"@microsoft/api-extractor": "7.58.1",
|
|
98
98
|
"@types/mocha": "^10.0.10",
|
|
99
|
-
"@types/node": "~
|
|
99
|
+
"@types/node": "~22.19.17",
|
|
100
100
|
"@types/sinon": "^17.0.3",
|
|
101
101
|
"c8": "^10.1.3",
|
|
102
102
|
"concurrently": "^9.2.1",
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
"api": "fluid-build . --task api",
|
|
120
120
|
"api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
|
|
121
121
|
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
|
|
122
|
+
"bench": "cross-env FLUID_TEST_PERF_MODE=1 mocha --parentProcess",
|
|
122
123
|
"build": "fluid-build . --task build",
|
|
123
124
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
124
125
|
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
@@ -151,7 +152,6 @@
|
|
|
151
152
|
"format:biome": "biome check . --write",
|
|
152
153
|
"lint": "fluid-build . --task lint",
|
|
153
154
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
154
|
-
"perf": "cross-env FLUID_TEST_VERBOSE=1 mocha --perfMode --fgrep @Benchmark --reporter @fluid-tools/benchmark/dist/MochaReporter.js --timeout 30000",
|
|
155
155
|
"test": "npm run test:mocha",
|
|
156
156
|
"test:coverage": "c8 npm test",
|
|
157
157
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
@@ -159,7 +159,6 @@
|
|
|
159
159
|
"test:mocha:esm": "mocha",
|
|
160
160
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
161
161
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
162
|
-
"typetests:gen": "flub generate typetests --dir . -v"
|
|
163
|
-
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
162
|
+
"typetests:gen": "flub generate typetests --dir . -v"
|
|
164
163
|
}
|
|
165
164
|
}
|
package/src/handle.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
7
7
|
import { FluidObjectHandle } from "@fluidframework/datastore/internal";
|
|
8
8
|
import type { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
9
|
-
import { isFluidHandle
|
|
9
|
+
import { isFluidHandle } from "@fluidframework/runtime-utils/internal";
|
|
10
10
|
|
|
11
11
|
import type { ISharedObject } from "./types.js";
|
|
12
12
|
|
|
@@ -123,7 +123,7 @@ export class SharedObjectHandle
|
|
|
123
123
|
// We don't bind handles in staging mode to defer the attachment of any new objects
|
|
124
124
|
// until we've exited staging mode. This way if we discard changes or a new handle is not present in the final
|
|
125
125
|
// committed state, we will never end up attaching the discarded object.
|
|
126
|
-
if (
|
|
126
|
+
if (this.runtime.inStagingMode === true) {
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
|
package/src/packageVersion.ts
CHANGED
package/src/sharedObject.ts
CHANGED
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
type TelemetryContext,
|
|
42
42
|
} from "@fluidframework/runtime-utils/internal";
|
|
43
43
|
import {
|
|
44
|
-
type ITelemetryLoggerExt,
|
|
45
44
|
DataProcessingError,
|
|
46
45
|
EventEmitterWithErrorHandling,
|
|
47
46
|
type MonitoringContext,
|
|
@@ -52,7 +51,10 @@ import {
|
|
|
52
51
|
type ICustomData,
|
|
53
52
|
type IFluidErrorBase,
|
|
54
53
|
LoggingError,
|
|
54
|
+
extractTelemetryLoggerExt,
|
|
55
55
|
} from "@fluidframework/telemetry-utils/internal";
|
|
56
|
+
// eslint-disable-next-line import-x/no-internal-modules -- Needed to avoid specialized /internal ITelemetryLoggerExt
|
|
57
|
+
import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/legacy";
|
|
56
58
|
import { v4 as uuid } from "uuid";
|
|
57
59
|
|
|
58
60
|
import { GCHandleVisitor } from "./gcHandleVisitor.js";
|
|
@@ -162,7 +164,7 @@ export abstract class SharedObjectCore<
|
|
|
162
164
|
|
|
163
165
|
this.handle = new SharedObjectHandle(this, id, runtime);
|
|
164
166
|
|
|
165
|
-
|
|
167
|
+
const internalLogger = createChildLogger({
|
|
166
168
|
logger: runtime.logger,
|
|
167
169
|
properties: {
|
|
168
170
|
all: {
|
|
@@ -173,7 +175,8 @@ export abstract class SharedObjectCore<
|
|
|
173
175
|
},
|
|
174
176
|
},
|
|
175
177
|
});
|
|
176
|
-
this.
|
|
178
|
+
this.logger = internalLogger;
|
|
179
|
+
this.mc = loggerToMonitoringContext(internalLogger);
|
|
177
180
|
|
|
178
181
|
const { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();
|
|
179
182
|
this.opProcessingHelper = opProcessingHelper;
|
|
@@ -206,7 +209,7 @@ export abstract class SharedObjectCore<
|
|
|
206
209
|
eventName: "ddsOpProcessing",
|
|
207
210
|
category: "performance",
|
|
208
211
|
},
|
|
209
|
-
this.logger,
|
|
212
|
+
extractTelemetryLoggerExt(this.logger),
|
|
210
213
|
this.mc.config.getNumber("Fluid.SharedObject.OpProcessingTelemetrySampling") ?? 1000,
|
|
211
214
|
true,
|
|
212
215
|
new Map<string, ITelemetryBaseProperties>([
|
|
@@ -219,7 +222,7 @@ export abstract class SharedObjectCore<
|
|
|
219
222
|
eventName: "ddsEventCallbacks",
|
|
220
223
|
category: "performance",
|
|
221
224
|
},
|
|
222
|
-
this.logger,
|
|
225
|
+
extractTelemetryLoggerExt(this.logger),
|
|
223
226
|
this.mc.config.getNumber("Fluid.SharedObject.DdsCallbacksTelemetrySampling") ?? 1000,
|
|
224
227
|
true,
|
|
225
228
|
);
|
|
@@ -23,7 +23,8 @@ import type {
|
|
|
23
23
|
IRuntimeMessageCollection,
|
|
24
24
|
MinimumVersionForCollab,
|
|
25
25
|
} from "@fluidframework/runtime-definitions/internal";
|
|
26
|
-
import type {
|
|
26
|
+
import type { TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
27
|
+
import { extractTelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
27
28
|
|
|
28
29
|
import type { IFluidSerializer } from "./serializer.js";
|
|
29
30
|
import {
|
|
@@ -133,24 +134,28 @@ class SharedObjectFromKernel<
|
|
|
133
134
|
) {
|
|
134
135
|
super(id, runtime, attributes, telemetryContextPrefix);
|
|
135
136
|
|
|
137
|
+
// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern
|
|
138
|
+
// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes
|
|
139
|
+
// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the
|
|
140
|
+
// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler
|
|
141
|
+
// would emit an error.
|
|
142
|
+
const minVersionForCollab: MinimumVersionForCollab | undefined = (
|
|
143
|
+
runtime as IFluidDataStoreRuntimeInternalConfig
|
|
144
|
+
).minVersionForCollab;
|
|
145
|
+
|
|
146
|
+
assert(minVersionForCollab !== undefined, 0xcee /* minVersionForCollab must be defined */);
|
|
147
|
+
|
|
136
148
|
this.#kernelArgs = {
|
|
137
149
|
sharedObject: this,
|
|
138
150
|
serializer: this.serializer,
|
|
139
151
|
submitLocalMessage: (op, localOpMetadata) =>
|
|
140
152
|
this.submitLocalMessage(op, localOpMetadata),
|
|
141
153
|
eventEmitter: this,
|
|
142
|
-
logger: this.logger,
|
|
154
|
+
logger: extractTelemetryLoggerExt(this.logger),
|
|
143
155
|
idCompressor: runtime.idCompressor,
|
|
144
156
|
lastSequenceNumber: () => this.deltaManager.lastSequenceNumber,
|
|
145
157
|
initialSequenceNumber: this.deltaManager.initialSequenceNumber,
|
|
146
|
-
|
|
147
|
-
// This cast is needed since IFluidDataStoreRuntimeInternalConfig does not extend IFluidDataStoreRuntime directly. This pattern
|
|
148
|
-
// allows us to avoid breaking changes to IFluidDataStoreRuntime by hiding internal members in a separate interface, but comes
|
|
149
|
-
// at the cost of less compile-time enforcement. For example, if the runtime did not implement `minVersionForCollab` and the
|
|
150
|
-
// member was still optional (e.g., during the deprecation window where backwards-compatibility is maintained), the compiler
|
|
151
|
-
// would emit an error.
|
|
152
|
-
minVersionForCollab: (runtime as IFluidDataStoreRuntimeInternalConfig)
|
|
153
|
-
.minVersionForCollab,
|
|
158
|
+
minVersionForCollab,
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
|
|
@@ -287,7 +292,7 @@ export interface KernelArgs {
|
|
|
287
292
|
/**
|
|
288
293
|
* {@inheritdoc SharedObjectCore.logger}
|
|
289
294
|
*/
|
|
290
|
-
readonly logger:
|
|
295
|
+
readonly logger: TelemetryLoggerExt;
|
|
291
296
|
/**
|
|
292
297
|
* {@inheritdoc @fluidframework/datastore-definitions#IFluidDataStoreRuntime.idCompressor}
|
|
293
298
|
*/
|
|
@@ -305,7 +310,7 @@ export interface KernelArgs {
|
|
|
305
310
|
* compatible set of feature flags and formats can be enabled in the SharedObject implementation.
|
|
306
311
|
* See {@link @fluidframework/container-runtime#LoadContainerRuntimeParams.minVersionForCollab} for more details.
|
|
307
312
|
*/
|
|
308
|
-
readonly minVersionForCollab: MinimumVersionForCollab
|
|
313
|
+
readonly minVersionForCollab: MinimumVersionForCollab;
|
|
309
314
|
}
|
|
310
315
|
|
|
311
316
|
/**
|