@fluidframework/shared-object-base 2.11.0 → 2.12.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.
Files changed (54) hide show
  1. package/.eslintrc.cjs +1 -4
  2. package/CHANGELOG.md +4 -0
  3. package/api-report/shared-object-base.legacy.alpha.api.md +2 -2
  4. package/dist/packageVersion.d.ts +1 -1
  5. package/dist/packageVersion.js +1 -1
  6. package/dist/packageVersion.js.map +1 -1
  7. package/dist/remoteObjectHandle.d.ts +0 -1
  8. package/dist/remoteObjectHandle.d.ts.map +1 -1
  9. package/dist/remoteObjectHandle.js +0 -3
  10. package/dist/remoteObjectHandle.js.map +1 -1
  11. package/dist/serializer.d.ts +6 -8
  12. package/dist/serializer.d.ts.map +1 -1
  13. package/dist/serializer.js +16 -10
  14. package/dist/serializer.js.map +1 -1
  15. package/dist/sharedObject.d.ts.map +1 -1
  16. package/dist/sharedObject.js +11 -6
  17. package/dist/sharedObject.js.map +1 -1
  18. package/dist/summarySerializer.d.ts +2 -4
  19. package/dist/summarySerializer.d.ts.map +1 -1
  20. package/dist/summarySerializer.js +1 -1
  21. package/dist/summarySerializer.js.map +1 -1
  22. package/dist/utils.d.ts +4 -4
  23. package/dist/utils.d.ts.map +1 -1
  24. package/dist/utils.js +2 -4
  25. package/dist/utils.js.map +1 -1
  26. package/lib/packageVersion.d.ts +1 -1
  27. package/lib/packageVersion.js +1 -1
  28. package/lib/packageVersion.js.map +1 -1
  29. package/lib/remoteObjectHandle.d.ts +0 -1
  30. package/lib/remoteObjectHandle.d.ts.map +1 -1
  31. package/lib/remoteObjectHandle.js +0 -3
  32. package/lib/remoteObjectHandle.js.map +1 -1
  33. package/lib/serializer.d.ts +6 -8
  34. package/lib/serializer.d.ts.map +1 -1
  35. package/lib/serializer.js +11 -5
  36. package/lib/serializer.js.map +1 -1
  37. package/lib/sharedObject.d.ts.map +1 -1
  38. package/lib/sharedObject.js +11 -6
  39. package/lib/sharedObject.js.map +1 -1
  40. package/lib/summarySerializer.d.ts +2 -4
  41. package/lib/summarySerializer.d.ts.map +1 -1
  42. package/lib/summarySerializer.js +1 -1
  43. package/lib/summarySerializer.js.map +1 -1
  44. package/lib/utils.d.ts +4 -4
  45. package/lib/utils.d.ts.map +1 -1
  46. package/lib/utils.js +2 -4
  47. package/lib/utils.js.map +1 -1
  48. package/package.json +17 -17
  49. package/src/packageVersion.ts +1 -1
  50. package/src/remoteObjectHandle.ts +1 -5
  51. package/src/serializer.ts +34 -23
  52. package/src/sharedObject.ts +44 -31
  53. package/src/summarySerializer.ts +6 -2
  54. package/src/utils.ts +8 -9
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,GACrB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAuClE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QAyDhE,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA0B,EAAE,EAAE;YAC7E,yDAAyD;YACzD,OAAO,aAAa,CAAC,KAAK,CAAC;gBAC1B,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;gBAC1D,CAAC,CAAC,KAAK,CAAC;QACV,CAAC,CAAC;QAEF,qFAAqF;QACrF,6EAA6E;QAC5D,gBAAW,GAAG,CAAC,KAAU,EAAE,EAAE;YAC7C,0EAA0E;YAC1E,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,kGAAkG;gBAClG,4FAA4F;gBAC5F,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU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AqF;oBACrF,KAAK,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;oBAEpE,+EAA+E;oBAC/E,oEAAoE;oBACpE,KAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACxB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAA4B,EAAE,IAA0B;QACjF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// RATIONALE: Many methods consume and return 'any' by necessity.\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\tencode(value: any, bind: IFluidHandle): any;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\tstringify(value: any, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\tparse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\tpublic encode(input: any, bind: IFluidHandle) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\tpublic decode(input: any) {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: unknown, bind: IFluidHandle) {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string) {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\tprivate readonly encodeValue = (value: unknown, bind: IFluidHandleInternal) => {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn isFluidHandle(value)\n\t\t\t? this.serializeHandle(toFluidHandleInternal(value), bind)\n\t\t\t: value;\n\t};\n\n\t// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\tprivate readonly decodeValue = (value: any) => {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\treturn new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\n\t// Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t// Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,\n\t// returns the original `input`.\n\tprivate recursivelyReplace(\n\t\tinput: any,\n\t\treplacer: (input: any, context: any) => any,\n\t\tcontext?: any,\n\t) {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tclone![key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\tprotected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal) {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,GAErB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AA2ClE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAG3B,YAAoC,OAA4B;QAA5B,YAAO,GAAP,OAAO,CAAqB;QA4DhE,6EAA6E;QAC7E,iFAAiF;QAChE,gBAAW,GAAG,CAAC,KAAc,EAAE,IAA2B,EAAW,EAAE;YACvF,yDAAyD;YACzD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,mDAAmD,CAAC,CAAC;gBACtF,OAAO,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,KAAK,CAAC;QACd,CAAC,CAAC;QAEF,qFAAqF;QACrF,6EAA6E;QAC5D,gBAAW,GAAG,CAAC,KAAc,EAAW,EAAE;YAC1D,0EAA0E;YAC1E,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,kGAAkG;gBAClG,4FAA4F;gBAC5F,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;oBAC7C,CAAC,CAAC,KAAK,CAAC,GAAG;oBACX,CAAC,CAAC,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AK,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;oBAEpE,+EAA+E;oBAC/E,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;gBACvB,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CACxB,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tgenerateHandleContextPath,\n\tisSerializedHandle,\n\tisFluidHandle,\n\ttoFluidHandleInternal,\n\ttype ISerializedHandle,\n} from \"@fluidframework/runtime-utils/internal\";\n\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle.js\";\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IFluidSerializer {\n\t/**\n\t * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n\t * where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tencode(value: any, bind: IFluidHandle): any;\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tdecode(input: any): any;\n\n\t/**\n\t * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tstringify(value: any, bind: IFluidHandle): string;\n\n\t/**\n\t * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid\n\t * handles will be realized as part of the parse\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tparse(value: string): any;\n}\n\n/**\n * Data Store serializer implementation\n * @internal\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(private readonly context: IFluidHandleContext) {\n\t\tthis.root = this.context;\n\t\twhile (this.root.routeContext !== undefined) {\n\t\t\tthis.root = this.root.routeContext;\n\t\t}\n\t}\n\n\tpublic get IFluidSerializer(): IFluidSerializer {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a\n\t * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * Any unbound handles encountered are bound to the provided IFluidHandle.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\tpublic encode(input: any, bind: IFluidHandleInternal): any {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\t\t\t\tthis.recursivelyReplace(input, this.encodeValue, bind)\n\t\t\t: input;\n\t}\n\n\t/**\n\t * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an\n\t * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.\n\t *\n\t * The original `input` object is not mutated. This method will shallowly clone all objects in the path from\n\t * the root to any replaced handles. (If no handles are found, returns the original object.)\n\t *\n\t * The decoded handles are implicitly bound to the handle context of this serializer.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 ddsFuzzHarness breaks when we update any->unknown\n\tpublic decode(input: unknown): any {\n\t\t// If the given 'input' cannot contain handles, return it immediately. Otherwise,\n\t\t// return the result of 'recursivelyReplace()'.\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\treturn !!input && typeof input === \"object\"\n\t\t\t? this.recursivelyReplace(input, this.decodeValue)\n\t\t\t: input;\n\t}\n\n\tpublic stringify(input: unknown, bind: IFluidHandle): string {\n\t\tconst bindInternal = toFluidHandleInternal(bind);\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));\n\t}\n\n\t// Parses the serialized data - context must match the context with which the JSON was stringified\n\tpublic parse(input: string): unknown {\n\t\treturn JSON.parse(input, (key, value) => this.decodeValue(value));\n\t}\n\n\t// If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.\n\tprivate readonly encodeValue = (value: unknown, bind?: IFluidHandleInternal): unknown => {\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\tif (isFluidHandle(value)) {\n\t\t\tassert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);\n\t\t\treturn this.serializeHandle(toFluidHandleInternal(value), bind);\n\t\t}\n\t\treturn value;\n\t};\n\n\t// If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.\n\t// Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.\n\tprivate readonly decodeValue = (value: unknown): unknown => {\n\t\t// If 'value' is a serialized IFluidHandle return the deserialized result.\n\t\tif (isSerializedHandle(value)) {\n\t\t\t// Old documents may have handles with relative path in their summaries. Convert these to absolute\n\t\t\t// paths. This will ensure that future summaries will have absolute paths for these handles.\n\t\t\tconst absolutePath = value.url.startsWith(\"/\")\n\t\t\t\t? value.url\n\t\t\t\t: generateHandleContextPath(value.url, this.context);\n\n\t\t\treturn new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t};\n\n\t// Invoked for non-null objects to recursively replace references to IFluidHandles.\n\t// Clones as-needed to avoid mutating the `input` object. If no IFluidHandes are present,\n\t// returns the original `input`.\n\tprivate recursivelyReplace<TContext = unknown>(\n\t\tinput: object,\n\t\treplacer: (input: unknown, context?: TContext) => unknown,\n\t\tcontext?: TContext,\n\t): unknown {\n\t\t// Note: Caller is responsible for ensuring that `input` is defined / non-null.\n\t\t// (Required for Object.keys() below.)\n\n\t\t// Execute the `replace` on the current input. Note that Caller is responsible for ensuring that `input`\n\t\t// is a non-null object.\n\t\tconst maybeReplaced = replacer(input, context);\n\n\t\t// If either input or the replaced result is a Fluid Handle, there is no need to descend further.\n\t\t// IFluidHandles are always leaves in the object graph, and the code below cannot deal with IFluidHandle's structure.\n\t\tif (isFluidHandle(input) || isFluidHandle(maybeReplaced)) {\n\t\t\treturn maybeReplaced;\n\t\t}\n\n\t\t// Otherwise descend into the object graph looking for IFluidHandle instances.\n\t\tlet clone: object | undefined;\n\t\tfor (const key of Object.keys(input)) {\n\t\t\tconst value: unknown = input[key];\n\t\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\t\tif (!!value && typeof value === \"object\") {\n\t\t\t\t// Note: Except for IFluidHandle, `input` must not contain circular references (as object must\n\t\t\t\t// be JSON serializable.) Therefore, guarding against infinite recursion here would only\n\t\t\t\t// lead to a later error when attempting to stringify().\n\t\t\t\tconst replaced = this.recursivelyReplace(value, replacer, context);\n\n\t\t\t\t// If the `replaced` object is different than the original `value` then the subgraph contained one\n\t\t\t\t// or more handles. If this happens, we need to return a clone of the `input` object where the\n\t\t\t\t// current property is replaced by the `replaced` value.\n\t\t\t\tif (replaced !== value) {\n\t\t\t\t\t// Lazily create a shallow clone of the `input` object if we haven't done so already.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- TODO: not sure if there's a good solution\n\t\t\t\t\tclone = clone ?? (Array.isArray(input) ? [...input] : { ...input });\n\n\t\t\t\t\t// Overwrite the current property `key` in the clone with the `replaced` value.\n\t\t\t\t\tclone[key] = replaced;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clone ?? input;\n\t}\n\n\tprotected serializeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tbind.bind(handle);\n\t\treturn {\n\t\t\ttype: \"__fluid_handle__\",\n\t\t\turl: handle.absolutePath,\n\t\t};\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAC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;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB,CAAC,GAAG,CAAC,aAAa,GAAG,OAAO,CAC5D,SAAQ,UAAU,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAChE;;;OAGG;IACH,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,cAAc,GAAG,aAAa,CAAC;CACnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EACnD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7E,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAiBpE"}
@@ -135,6 +135,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
135
135
  // always propagate connection state
136
136
  this.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);
137
137
  this._isBoundToContext = true;
138
+ // eslint-disable-next-line unicorn/consistent-function-scoping
138
139
  const runDidAttach = () => {
139
140
  // Allows objects to do any custom processing if it is attached.
140
141
  this.didAttach();
@@ -221,6 +222,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
221
222
  * and not sent to the server. This will be sent back when this message is received back from the server. This is
222
223
  * also sent if we are asked to resubmit the message.
223
224
  */
225
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
224
226
  submitLocalMessage(content, localOpMetadata = undefined) {
225
227
  this.verifyNotClosed();
226
228
  if (this.isAttached()) {
@@ -252,6 +254,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
252
254
  * @param content - The content of the original message.
253
255
  * @param localOpMetadata - The local metadata associated with the original message.
254
256
  */
257
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
255
258
  reSubmitCore(content, localOpMetadata) {
256
259
  this.submitLocalMessage(content, localOpMetadata);
257
260
  }
@@ -315,7 +318,12 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
315
318
  }
316
319
  // Should I change the state at the end? So that we *can't* send new stuff before we send old?
317
320
  this._connected = connected;
318
- if (!connected) {
321
+ if (connected) {
322
+ // Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending
323
+ // messages will work.
324
+ this.onConnect();
325
+ }
326
+ else {
319
327
  // Things that are true now...
320
328
  // - if we had a connection we can no longer send messages over it
321
329
  // - if we had outbound messages some may or may not be ACK'd. Won't know until next message
@@ -323,11 +331,6 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
323
331
  // - nack could get a new msn - but might as well do it in the join?
324
332
  this.onDisconnect();
325
333
  }
326
- else {
327
- // Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending
328
- // messages will work.
329
- this.onConnect();
330
- }
331
334
  }
332
335
  /**
333
336
  * Handles a message being received from the remote delta server.
@@ -376,6 +379,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
376
379
  /**
377
380
  * Revert an op
378
381
  */
382
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
379
383
  rollback(content, localOpMetadata) {
380
384
  throw new Error("rollback not supported");
381
385
  }
@@ -391,6 +395,7 @@ export class SharedObjectCore extends EventEmitterWithErrorHandling {
391
395
  */
392
396
  emit(event, ...args) {
393
397
  return this.callbacksHelper.measure(() => {
398
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
394
399
  return super.emit(event, ...args);
395
400
  });
396
401
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAOpE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;IAYO,wBAAwB,CAC/B,YAAoB,EACpB,WAAmB,EACnB,gBAAoC;QAEpC,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACpC,oDAAoD;YACpD,MAAM,CACL,KAAK,IAAI,gBAAgB,IAAI,OAAO,gBAAgB,CAAC,GAAG,KAAK,UAAU,EACvE,KAAK,CAAC,+CAA+C,CACrD,CAAC;YAEF,MAAM,SAAS,GAAG,CAAE,gBAAqC,CAAC,GAAG,CAC5D,IAAI,CAAC,sBAAsB,EAC3B,YAAY,CACZ,IAAI,CAAC,CAAW,CAAC;YAClB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;QAC1F,CAAC;IACF,CAAC;CACD;AA0ED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAA+E;IAE/E,MAAM,MAAM,GACsC;QACjD,UAAU;YACT,OAAO,IAAI,OAAO,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,OAA+B,EAAE,EAAW;YAClD,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAkB,CAAC;QACjE,CAAC;QAED,EAAE,CAAC,KAAqB;YACvB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { ITelemetryBaseProperties, type ErasedType } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype IFluidHandleInternal,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelServices,\n\tIChannelStorageService,\n\ttype IChannel,\n\tIChannelAttributes,\n\ttype IChannelFactory,\n\tIFluidDataStoreRuntime,\n\ttype IDeltaHandler,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\ttype IDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\tTelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\tMonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, IFluidSerializer } from \"./serializer.js\";\nimport { SummarySerializer } from \"./summarySerializer.js\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all shared objects derive.\n * @legacy\n * @alpha\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tpublic id: string,\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: any) => this.eventListenerErrorHandler(event, e));\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime.IFluidHandleContext);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: any) {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed() {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: any) {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach() {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\tconst runDidAttach = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices) {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore() {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach() {\n\t\treturn;\n\t}\n\n\t/**\n\t * Derived classes must override this to do custom processing on a remote message.\n\t * @param message - The message to process\n\t * @param local - True if the shared object is local\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected abstract processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t);\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\tprotected abstract onDisconnect();\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\tprotected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(\n\t\t\t\tmakeHandlesSerializable(content, this.serializer, this.handle),\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect() {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown) {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler() {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocess: (\n\t\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: unknown,\n\t\t\t) => {\n\t\t\t\tthis.process(\n\t\t\t\t\t{ ...message, contents: parseHandles(message.contents, this.serializer) },\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t);\n\t\t\t},\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: any): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: any, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean) {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (!connected) {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t} else {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t}\n\t}\n\n\t/**\n\t * Handles a message being received from the remote delta server.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprivate process(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t) {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\t\tthis.emitInternal(\"pre-op\", message, local, this);\n\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tthis.processCore(message, local, localOpMetadata);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: message.sequenceNumber - message.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\n\t\tthis.emitInternal(\"op\", message, local, this);\n\t}\n\n\t/**\n\t * Process messages for this shared object. The messages here are contiguous messages for this object in a batch.\n\t * @param messageCollection - The collection of messages to process.\n\t */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection) {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process(\n\t\t\t\t{\n\t\t\t\t\t...envelope,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\t},\n\t\t\t\tlocal,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprivate reSubmit(content: any, localOpMetadata: unknown) {\n\t\tthis.reSubmitCore(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\tprotected rollback(content: any, localOpMetadata: unknown) {\n\t\tthrow new Error(\"rollback not supported\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\tprotected abstract applyStashedOp(content: any): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n}\n\n/**\n * SharedObject with simplified, synchronous summarization and GC.\n * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.\n * @legacy\n * @alpha\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(this.serializer, telemetryContext);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles\n\t\t// in this object's data.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(serializer);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": serializer.getSerializedRoutes() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer) {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t) {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy\n * @alpha\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the APi entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
1
+ {"version":3,"file":"sharedObject.js","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAOpE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAc7D,OAAO,EAKN,qBAAqB,EACrB,yBAAyB,GAEzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,sBAAsB,GAEtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEN,mBAAmB,EACnB,6BAA6B,EAE7B,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,GAGhB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,EAAE,IAAI,I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S,GAAG,CAAE,gBAAqC,CAAC,GAAG,CAC5D,IAAI,CAAC,sBAAsB,EAC3B,YAAY,CACZ,IAAI,CAAC,CAAW,CAAC;YAClB,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,CAAC;QAC1F,CAAC;IACF,CAAC;CACD;AA0ED;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACrC,OAA+E;IAE/E,MAAM,MAAM,GACsC;QACjD,UAAU;YACT,OAAO,IAAI,OAAO,EAAE,CAAC;QACtB,CAAC;QAED,MAAM,CAAC,OAA+B,EAAE,EAAW;YAClD,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAkB,CAAC;QACjE,CAAC;QAED,EAAE,CAAC,KAAqB;YACvB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QACnE,CAAC;KACD,CAAC;IAEF,OAAO,MAAyD,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,QAAwB;IAC1C,oGAAoG;IACpG,OAAQ,QAAqB,CAAC,UAAU,KAAK,SAAS,CAAC;AACxD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitterEventType } from \"@fluid-internal/client-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport type { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { ITelemetryBaseProperties, type ErasedType } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype IFluidHandleInternal,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIChannelServices,\n\tIChannelStorageService,\n\ttype IChannel,\n\tIChannelAttributes,\n\ttype IChannelFactory,\n\tIFluidDataStoreRuntime,\n\ttype IDeltaHandler,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\ttype IDocumentMessage,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIExperimentalIncrementalSummaryContext,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n\tblobCountPropertyName,\n\ttotalBlobSizePropertyName,\n\ttype IRuntimeMessageCollection,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttoDeltaManagerInternal,\n\tTelemetryContext,\n} from \"@fluidframework/runtime-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tDataProcessingError,\n\tEventEmitterWithErrorHandling,\n\tMonitoringContext,\n\tSampledTelemetryHelper,\n\tcreateChildLogger,\n\tloggerToMonitoringContext,\n\ttagCodeArtifacts,\n\ttype ICustomData,\n\ttype IFluidErrorBase,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { SharedObjectHandle } from \"./handle.js\";\nimport { FluidSerializer, IFluidSerializer } from \"./serializer.js\";\nimport { SummarySerializer } from \"./summarySerializer.js\";\nimport { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nimport { makeHandlesSerializable, parseHandles } from \"./utils.js\";\n\n/**\n * Custom telemetry properties used in {@link SharedObjectCore} to instantiate {@link TelemetryEventBatcher} class.\n * This interface is used to define the properties that will be passed to the {@link TelemetryEventBatcher.measure} function\n * which is called in the {@link SharedObjectCore.process} method.\n */\ninterface ProcessTelemetryProperties {\n\tsequenceDifference: number;\n}\n\n/**\n * Base class from which all shared objects derive.\n * @legacy\n * @alpha\n */\nexport abstract class SharedObjectCore<\n\t\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n\t>\n\textends EventEmitterWithErrorHandling<TEvent>\n\timplements ISharedObject<TEvent>\n{\n\tpublic get IFluidLoadable(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly opProcessingHelper: SampledTelemetryHelper<\n\t\tvoid,\n\t\tProcessTelemetryProperties\n\t>;\n\tprivate readonly callbacksHelper: SampledTelemetryHelper<boolean>;\n\n\t/**\n\t * The handle referring to this SharedObject\n\t */\n\tpublic readonly handle: IFluidHandleInternal;\n\n\t/**\n\t * Telemetry logger for the shared object\n\t */\n\tprotected readonly logger: ITelemetryLoggerExt;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Connection state\n\t */\n\tprivate _connected = false;\n\n\t/**\n\t * Services used by the shared object\n\t */\n\tprivate services: IChannelServices | undefined;\n\n\t/**\n\t * True if the dds is bound to its parent.\n\t */\n\tprivate _isBoundToContext: boolean = false;\n\n\t/**\n\t * Tracks error that closed this object.\n\t */\n\tprivate closeError?: ReturnType<typeof DataProcessingError.wrapIfUnrecognized>;\n\n\t/**\n\t * Gets the connection state\n\t * @returns The state of the connection\n\t */\n\tpublic get connected(): boolean {\n\t\treturn this._connected;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tpublic id: string,\n\t\tprotected runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly attributes: IChannelAttributes,\n\t) {\n\t\tsuper((event: EventEmitterEventType, e: unknown) =>\n\t\t\tthis.eventListenerErrorHandler(event, e),\n\t\t);\n\n\t\tassert(!id.includes(\"/\"), 0x304 /* Id cannot contain slashes */);\n\n\t\tthis.handle = new SharedObjectHandle(this, id, runtime.IFluidHandleContext);\n\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: runtime.logger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\tsharedObjectId: uuid(),\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tddsType: this.attributes.type,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tthis.mc = loggerToMonitoringContext(this.logger);\n\n\t\tconst { opProcessingHelper, callbacksHelper } = this.setUpSampledTelemetryHelpers();\n\t\tthis.opProcessingHelper = opProcessingHelper;\n\t\tthis.callbacksHelper = callbacksHelper;\n\t}\n\n\t/**\n\t * Accessor for `this.runtime`'s {@link @fluidframework/datastore-definitions#IFluidDataStoreRuntime.deltaManager} as a {@link @fluidframework/container-definitions/internal#IDeltaManager}\n\t */\n\tprotected get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n\t\treturn toDeltaManagerInternal(this.runtime.deltaManager);\n\t}\n\n\t/**\n\t * This function is only supposed to be called from SharedObjectCore's constructor and\n\t * depends on a few things being set already. assert() calls make sure of it.\n\t * @returns The telemetry sampling helpers, so the constructor can be the one to assign them\n\t * to variables to avoid complaints from TypeScript.\n\t */\n\tprivate setUpSampledTelemetryHelpers(): {\n\t\topProcessingHelper: SampledTelemetryHelper<void, ProcessTelemetryProperties>;\n\t\tcallbacksHelper: SampledTelemetryHelper<boolean>;\n\t} {\n\t\tassert(\n\t\t\tthis.mc !== undefined && this.logger !== undefined,\n\t\t\t0x349 /* this.mc and/or this.logger has not been set */,\n\t\t);\n\t\tconst opProcessingHelper = new SampledTelemetryHelper<void, ProcessTelemetryProperties>(\n\t\t\t{\n\t\t\t\teventName: \"ddsOpProcessing\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.OpProcessingTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t\tnew Map<string, ITelemetryBaseProperties>([\n\t\t\t\t[\"local\", { localOp: true }],\n\t\t\t\t[\"remote\", { localOp: false }],\n\t\t\t]),\n\t\t);\n\t\tconst callbacksHelper = new SampledTelemetryHelper<boolean>(\n\t\t\t{\n\t\t\t\teventName: \"ddsEventCallbacks\",\n\t\t\t\tcategory: \"performance\",\n\t\t\t},\n\t\t\tthis.logger,\n\t\t\tthis.mc.config.getNumber(\"Fluid.SharedObject.DdsCallbacksTelemetrySampling\") ?? 1000,\n\t\t\ttrue,\n\t\t);\n\n\t\tthis.runtime.once(\"dispose\", () => {\n\t\t\tthis.callbacksHelper.dispose();\n\t\t\tthis.opProcessingHelper.dispose();\n\t\t});\n\n\t\treturn { opProcessingHelper, callbacksHelper };\n\t}\n\n\t/**\n\t * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)\n\t * would result in same error thrown. If called multiple times, only first error is remembered.\n\t * @param error - error object that is thrown whenever an attempt is made to modify this object\n\t */\n\tprivate closeWithError(error: IFluidErrorBase | undefined): void {\n\t\tif (this.closeError === undefined) {\n\t\t\tthis.closeError = error;\n\t\t}\n\t}\n\n\t/**\n\t * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.\n\t */\n\tprivate verifyNotClosed(): void {\n\t\tif (this.closeError !== undefined) {\n\t\t\tthrow this.closeError;\n\t\t}\n\t}\n\n\t/**\n\t * Event listener handler helper that can be used to react to exceptions thrown from event listeners\n\t * It wraps error with DataProcessingError, closes this object and throws resulting error.\n\t * See closeWithError() for more details\n\t * Ideally such situation never happens, as consumers of DDS should never throw exceptions\n\t * in event listeners (i.e. catch any of the issues and make determination on how to handle it).\n\t * When such exceptions propagate through, most likely data model is no longer consistent, i.e.\n\t * DDS state does not match what user sees. Because of it DDS moves to \"corrupted state\" and does not\n\t * allow processing of ops or local changes, which very quickly results in container closure.\n\t */\n\tprivate eventListenerErrorHandler(event: EventEmitterEventType, e: unknown): void {\n\t\tconst error = DataProcessingError.wrapIfUnrecognized(\n\t\t\te,\n\t\t\t\"SharedObjectEventListenerException\",\n\t\t);\n\t\terror.addTelemetryProperties({ emittedEventName: String(event) });\n\n\t\tthis.closeWithError(error);\n\t\tthrow error;\n\t}\n\n\tprivate setBoundAndHandleAttach(): void {\n\t\t// Ensure didAttach is only called once, and we only register a single event\n\t\t// but we still call setConnectionState as our existing mocks don't\n\t\t// always propagate connection state\n\t\tthis.setBoundAndHandleAttach = () => this.setConnectionState(this.runtime.connected);\n\t\tthis._isBoundToContext = true;\n\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\tconst runDidAttach: () => void = () => {\n\t\t\t// Allows objects to do any custom processing if it is attached.\n\t\t\tthis.didAttach();\n\t\t\tthis.setConnectionState(this.runtime.connected);\n\t\t};\n\t\tif (this.isAttached()) {\n\t\t\trunDidAttach();\n\t\t} else {\n\t\t\tthis.runtime.once(\"attaching\", runDidAttach);\n\t\t}\n\t}\n\n\t/**\n\t * A shared object, after construction, can either be loaded in the case that it is already part of\n\t * a shared document. Or later attached if it is being newly added.\n\t * @param services - Services used by the shared object\n\t */\n\tpublic async load(services: IChannelServices): Promise<void> {\n\t\tthis.services = services;\n\t\t// set this before load so that isAttached is true\n\t\t// for attached runtimes when load core is running\n\t\tthis._isBoundToContext = true;\n\t\tawait this.loadCore(services.objectStorage);\n\t\tthis.attachDeltaHandler();\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * Initializes the object as a local, non-shared object. This object can become shared after\n\t * it is attached to the document.\n\t */\n\tpublic initializeLocal(): void {\n\t\tthis.initializeLocalCore();\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).bindToContext}\n\t */\n\tpublic bindToContext(): void {\n\t\t// ensure the method only runs once by removing the implementation\n\t\t// without this the method suffers from re-entrancy issues\n\t\tthis.bindToContext = () => {};\n\t\tif (!this._isBoundToContext) {\n\t\t\tthis.runtime.bindChannel(this);\n\t\t\t// must set after bind channel so isAttached doesn't report true\n\t\t\t// before binding is complete\n\t\t\tthis.setBoundAndHandleAttach();\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}\n\t */\n\tpublic connect(services: IChannelServices): void {\n\t\t// handle the case where load is called\n\t\t// before connect; loading detached data stores\n\t\tif (this.services === undefined) {\n\t\t\tthis.services = services;\n\t\t\tthis.attachDeltaHandler();\n\t\t}\n\n\t\tthis.setBoundAndHandleAttach();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}\n\t */\n\tpublic isAttached(): boolean {\n\t\treturn this._isBoundToContext && this.runtime.attachState !== AttachState.Detached;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic abstract getAttachSummary(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats;\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic abstract summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats>;\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic abstract getGCData(fullGC?: boolean): IGarbageCollectionData;\n\n\t/**\n\t * Allows the distributed data type to perform custom loading\n\t * @param services - Storage used by the shared object\n\t */\n\tprotected abstract loadCore(services: IChannelStorageService): Promise<void>;\n\n\t/**\n\t * Allows the distributed data type to perform custom local loading.\n\t */\n\tprotected initializeLocalCore(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Allows the distributive data type the ability to perform custom processing once an attach has happened.\n\t * Also called after non-local data type get loaded.\n\t */\n\tprotected didAttach(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Derived classes must override this to do custom processing on a remote message.\n\t * @param message - The message to process\n\t * @param local - True if the shared object is local\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprotected abstract processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use void instead of any (legacy breaking)\n\t): any;\n\n\t/**\n\t * Called when the object has disconnected from the delta stream.\n\t */\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 change return type to void (legacy breaking)\n\tprotected abstract onDisconnect(): any;\n\n\t/**\n\t * The serializer to serialize / parse handles.\n\t */\n\tprotected abstract get serializer(): IFluidSerializer;\n\n\t/**\n\t * Submits a message by the local client to the runtime.\n\t * @param content - Content of the message. Note: handles contained in the\n\t * message object should not be encoded in any way\n\t * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tprotected submitLocalMessage(content: any, localOpMetadata: unknown = undefined): void {\n\t\tthis.verifyNotClosed();\n\t\tif (this.isAttached()) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.services!.deltaConnection.submit(\n\t\t\t\tmakeHandlesSerializable(content, this.serializer, this.handle),\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock\n\t * that want to be part of summary but does not generate ops.\n\t */\n\tprotected dirty(): void {\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.services!.deltaConnection.dirty();\n\t}\n\n\t/**\n\t * Called when the object has fully connected to the delta stream\n\t * Default implementation for DDS, override if different behavior is required.\n\t */\n\tprotected onConnect(): void {}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.\n\t * The default implementation here is to resubmit the same message. The client can override if different behavior\n\t * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit\n\t * anything at all.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tprotected reSubmitCore(content: any, localOpMetadata: unknown): void {\n\t\tthis.submitLocalMessage(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.\n\t * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),\n\t * the Promise will reject.\n\t * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.\n\t */\n\tprotected async newAckBasedPromise<T>(\n\t\texecutor: (\n\t\t\tresolve: (value: T | PromiseLike<T>) => void,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\t\t\treject: (reason?: any) => void,\n\t\t) => void,\n\t): Promise<T> {\n\t\tlet rejectBecauseDispose: () => void;\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\trejectBecauseDispose = () =>\n\t\t\t\treject(\n\t\t\t\t\tnew Error(\"FluidDataStoreRuntime disposed while this ack-based Promise was pending\"),\n\t\t\t\t);\n\n\t\t\tif (this.runtime.disposed) {\n\t\t\t\trejectBecauseDispose();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.runtime.on(\"dispose\", rejectBecauseDispose);\n\t\t\texecutor(resolve, reject);\n\t\t}).finally(() => {\n\t\t\t// Note: rejectBecauseDispose will never be undefined here\n\t\t\tthis.runtime.off(\"dispose\", rejectBecauseDispose);\n\t\t});\n\t}\n\n\tprivate attachDeltaHandler(): void {\n\t\t// Services should already be there in case we are attaching delta handler.\n\t\tassert(\n\t\t\tthis.services !== undefined,\n\t\t\t0x07a /* \"Services should be there to attach delta handler\" */,\n\t\t);\n\t\t// attachDeltaHandler is only called after services is assigned\n\t\tthis.services.deltaConnection.attach({\n\t\t\tprocess: (\n\t\t\t\tmessage: ISequencedDocumentMessage,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: unknown,\n\t\t\t) => {\n\t\t\t\tthis.process(\n\t\t\t\t\t{ ...message, contents: parseHandles(message.contents, this.serializer) },\n\t\t\t\t\tlocal,\n\t\t\t\t\tlocalOpMetadata,\n\t\t\t\t);\n\t\t\t},\n\t\t\tprocessMessages: (messagesCollection: IRuntimeMessageCollection) => {\n\t\t\t\tthis.processMessages(messagesCollection);\n\t\t\t},\n\t\t\tsetConnectionState: (connected: boolean) => {\n\t\t\t\tthis.setConnectionState(connected);\n\t\t\t},\n\t\t\treSubmit: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.reSubmit(content, localOpMetadata);\n\t\t\t},\n\t\t\tapplyStashedOp: (content: unknown): void => {\n\t\t\t\tthis.applyStashedOp(parseHandles(content, this.serializer));\n\t\t\t},\n\t\t\trollback: (content: unknown, localOpMetadata: unknown) => {\n\t\t\t\tthis.rollback(content, localOpMetadata);\n\t\t\t},\n\t\t} satisfies IDeltaHandler);\n\t}\n\n\t/**\n\t * Set the state of connection to services.\n\t * @param connected - true if connected, false otherwise.\n\t */\n\tprivate setConnectionState(connected: boolean): void {\n\t\t// only an attached shared object can transition its\n\t\t// connected state. This is defensive, as some\n\t\t// of our test harnesses don't handle this correctly\n\t\tif (!this.isAttached() || this._connected === connected) {\n\t\t\t// Not changing state, nothing the same.\n\t\t\treturn;\n\t\t}\n\n\t\t// Should I change the state at the end? So that we *can't* send new stuff before we send old?\n\t\tthis._connected = connected;\n\n\t\tif (connected) {\n\t\t\t// Call this for now so that DDSes like ConsensusOrderedCollection that maintain their own pending\n\t\t\t// messages will work.\n\t\t\tthis.onConnect();\n\t\t} else {\n\t\t\t// Things that are true now...\n\t\t\t// - if we had a connection we can no longer send messages over it\n\t\t\t// - if we had outbound messages some may or may not be ACK'd. Won't know until next message\n\t\t\t//\n\t\t\t// - nack could get a new msn - but might as well do it in the join?\n\t\t\tthis.onDisconnect();\n\t\t}\n\t}\n\n\t/**\n\t * Handles a message being received from the remote delta server.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprivate process(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthis.verifyNotClosed(); // This will result in container closure.\n\t\tthis.emitInternal(\"pre-op\", message, local, this);\n\n\t\tthis.opProcessingHelper.measure(\n\t\t\t(): ICustomData<ProcessTelemetryProperties> => {\n\t\t\t\tthis.processCore(message, local, localOpMetadata);\n\t\t\t\tconst telemetryProperties: ProcessTelemetryProperties = {\n\t\t\t\t\tsequenceDifference: message.sequenceNumber - message.referenceSequenceNumber,\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tcustomData: telemetryProperties,\n\t\t\t\t};\n\t\t\t},\n\t\t\tlocal ? \"local\" : \"remote\",\n\t\t);\n\n\t\tthis.emitInternal(\"op\", message, local, this);\n\t}\n\n\t/**\n\t * Process messages for this shared object. The messages here are contiguous messages for this object in a batch.\n\t * @param messageCollection - The collection of messages to process.\n\t */\n\tprivate processMessages(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, messagesContent, local } = messagesCollection;\n\t\tfor (const { contents, localOpMetadata, clientSequenceNumber } of messagesContent) {\n\t\t\tthis.process(\n\t\t\t\t{\n\t\t\t\t\t...envelope,\n\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t\tcontents: parseHandles(contents, this.serializer),\n\t\t\t\t},\n\t\t\t\tlocal,\n\t\t\t\tlocalOpMetadata,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a message has to be resubmitted. This typically happens for unacked messages after a\n\t * reconnection.\n\t * @param content - The content of the original message.\n\t * @param localOpMetadata - The local metadata associated with the original message.\n\t */\n\tprivate reSubmit(content: unknown, localOpMetadata: unknown): void {\n\t\tthis.reSubmitCore(content, localOpMetadata);\n\t}\n\n\t/**\n\t * Revert an op\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tprotected rollback(content: any, localOpMetadata: unknown): void {\n\t\tthrow new Error(\"rollback not supported\");\n\t}\n\n\t/**\n\t * Apply changes from the provided op content just as if a local client has made the change,\n\t * including submitting the op. Used when rehydrating an attached container\n\t * with pending changes. The rehydration process replays all remote ops\n\t * and applies stashed ops after the remote op with a sequence number\n\t * that matches that of the stashed op is applied. This ensures\n\t * stashed ops are applied at the same state they were originally created.\n\t *\n\t * It is possible that stashed ops have been sent in the past, and will be found when\n\t * the shared object catches up with remotes ops.\n\t * So this prepares the SharedObject for seeing potentially seeing the ACK.\n\t * If no matching remote op is found, all the applied stashed ops will go\n\t * through the normal resubmit flow upon reconnection, which allows the dds\n\t * to rebase them to the latest state, and then resubmit them.\n\t *\n\t * @param content - Contents of a stashed op.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n\tprotected abstract applyStashedOp(content: any): void;\n\n\t/**\n\t * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,\n\t * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners\n\t * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events\n\t * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the\n\t * future.\n\t * @param event - The event to emit.\n\t * @param args - Arguments to pass to the event listeners.\n\t * @returns `true` if the event had listeners, `false` otherwise.\n\t */\n\tpublic emit(event: EventEmitterEventType, ...args: any[]): boolean {\n\t\treturn this.callbacksHelper.measure(() => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn super.emit(event, ...args);\n\t\t});\n\t}\n\n\t/**\n\t * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement\n\t * done on the duration of the callbacks. Simply calls `super.emit()`.\n\t * @param event - Event to emit\n\t * @param args - Arguments for the event\n\t * @returns Whatever `super.emit()` returns.\n\t */\n\tprivate emitInternal(event: EventEmitterEventType, ...args: unknown[]): boolean {\n\t\treturn super.emit(event, ...args);\n\t}\n}\n\n/**\n * SharedObject with simplified, synchronous summarization and GC.\n * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.\n * @legacy\n * @alpha\n */\nexport abstract class SharedObject<\n\tTEvent extends ISharedObjectEvents = ISharedObjectEvents,\n> extends SharedObjectCore<TEvent> {\n\t/**\n\t * True while we are garbage collecting this object's data.\n\t */\n\tprivate _isGCing: boolean = false;\n\n\t/**\n\t * The serializer to use to serialize / parse handles, if any.\n\t */\n\tprivate readonly _serializer: IFluidSerializer;\n\n\tprotected get serializer(): IFluidSerializer {\n\t\t/**\n\t\t * During garbage collection, the SummarySerializer keeps track of IFluidHandles that are serialized. These\n\t\t * handles represent references to other Fluid objects.\n\t\t *\n\t\t * This is fine for now. However, if we implement delay loading in DDss, they may load and de-serialize content\n\t\t * in summarize. When that happens, they may incorrectly hit this assert and we will have to change this.\n\t\t */\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x075 /* \"SummarySerializer should be used for serializing data during summary.\" */,\n\t\t);\n\t\treturn this._serializer;\n\t}\n\n\t/**\n\t * @param id - The id of the shared object\n\t * @param runtime - The IFluidDataStoreRuntime which contains the shared object\n\t * @param attributes - Attributes of the shared object\n\t */\n\tconstructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t\tprivate readonly telemetryContextPrefix: string,\n\t) {\n\t\tsuper(id, runtime, attributes);\n\n\t\tthis._serializer = new FluidSerializer(this.runtime.channelsRoutingContext);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}\n\t */\n\tpublic getAttachSummary(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummaryTreeWithStats {\n\t\tconst result = this.summarizeCore(this.serializer, telemetryContext);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree: boolean = false,\n\t\ttrackState: boolean = false,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\tconst result = this.summarizeCore(\n\t\t\tthis.serializer,\n\t\t\ttelemetryContext,\n\t\t\tincrementalSummaryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\tblobCountPropertyName,\n\t\t\tresult.stats.blobNodeCount,\n\t\t\ttelemetryContext,\n\t\t);\n\t\tthis.incrementTelemetryMetric(\n\t\t\ttotalBlobSizePropertyName,\n\t\t\tresult.stats.totalBlobSize,\n\t\t\ttelemetryContext,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/**\n\t * {@inheritDoc (ISharedObject:interface).getGCData}\n\t */\n\tpublic getGCData(fullGC: boolean = false): IGarbageCollectionData {\n\t\t// Set _isGCing to true. This flag is used to ensure that we only use SummarySerializer to serialize handles\n\t\t// in this object's data.\n\t\tassert(\n\t\t\t!this._isGCing,\n\t\t\t0x078 /* \"Possible re-entrancy! Summary should not already be in progress.\" */,\n\t\t);\n\t\tthis._isGCing = true;\n\n\t\tlet gcData: IGarbageCollectionData;\n\t\ttry {\n\t\t\tconst serializer = new SummarySerializer(this.runtime.channelsRoutingContext);\n\t\t\tthis.processGCDataCore(serializer);\n\t\t\t// The GC data for this shared object contains a single GC node. The outbound routes of this node are the\n\t\t\t// routes of handles serialized during summarization.\n\t\t\tgcData = { gcNodes: { \"/\": serializer.getSerializedRoutes() } };\n\t\t\tassert(\n\t\t\t\tthis._isGCing,\n\t\t\t\t0x079 /* \"Possible re-entrancy! Summary should have been in progress.\" */,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis._isGCing = false;\n\t\t}\n\n\t\treturn gcData;\n\t}\n\n\t/**\n\t * Calls the serializer over all data in this object that reference other GC nodes.\n\t * Derived classes must override this to provide custom list of references to other GC nodes.\n\t */\n\tprotected processGCDataCore(serializer: IFluidSerializer): void {\n\t\t// We run the full summarize logic to get the list of outbound routes from this object. This is a little\n\t\t// expensive but its okay for now. It will be updated to not use full summarize and make it more efficient.\n\t\t// See: https://github.com/microsoft/FluidFramework/issues/4547\n\t\tthis.summarizeCore(serializer);\n\t}\n\n\t/**\n\t * Gets a form of the object that can be serialized.\n\t * @returns A tree representing the snapshot of the shared object.\n\t */\n\tprotected abstract summarizeCore(\n\t\tserializer: IFluidSerializer,\n\t\ttelemetryContext?: ITelemetryContext,\n\t\tincrementalSummaryContext?: IExperimentalIncrementalSummaryContext,\n\t): ISummaryTreeWithStats;\n\n\tprivate incrementTelemetryMetric(\n\t\tpropertyName: string,\n\t\tincrementBy: number,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): void {\n\t\tif (telemetryContext !== undefined) {\n\t\t\t// TelemetryContext needs to implment a get function\n\t\t\tassert(\n\t\t\t\t\"get\" in telemetryContext && typeof telemetryContext.get === \"function\",\n\t\t\t\t0x97e /* received context must have a get function */,\n\t\t\t);\n\n\t\t\tconst prevTotal = ((telemetryContext as TelemetryContext).get(\n\t\t\t\tthis.telemetryContextPrefix,\n\t\t\t\tpropertyName,\n\t\t\t) ?? 0) as number;\n\t\t\ttelemetryContext.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);\n\t\t}\n\t}\n}\n\n/**\n * Defines a kind of shared object.\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n *\n * @remarks\n * For use internally and in the \"encapsulated API\".\n * See {@link SharedObjectKind} for the type erased version for use in the public declarative API.\n *\n * @privateRemarks\n * This does not extend {@link SharedObjectKind} since doing so would prevent implementing this interface in type safe code.\n * Any implementation of this can safely be used as a {@link SharedObjectKind} with an explicit type conversion,\n * but doing so is typically not needed as {@link createSharedObjectKind} is used to produce values that are both types simultaneously.\n * @legacy\n * @alpha\n */\nexport interface ISharedObjectKind<TSharedObject> {\n\t/**\n\t * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.\n\t * @remarks\n\t * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.\n\t * To create new shared objects use:\n\t *\n\t * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.\n\t *\n\t * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).\n\t */\n\tgetFactory(): IChannelFactory<TSharedObject>;\n\n\t/**\n\t * Create a shared object.\n\t * @param runtime - The data store runtime that the new shared object belongs to.\n\t * @param id - Optional name of the shared object.\n\t * @returns Newly created shared object.\n\t *\n\t * @example\n\t * To create a `SharedTree`, call the static create method:\n\t *\n\t * ```typescript\n\t * const myTree = SharedTree.create(this.runtime, id);\n\t * ```\n\t * @remarks\n\t * The created object is local (detached): insert a handle to it into an attached object to share (attach) it.\n\t * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.\n\t *\n\t * @privateRemarks\n\t * This can only be used with a `MockFluidDataStoreRuntime` when that mock is created with a `registry` containing a factory for this shared object.\n\t */\n\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;\n}\n\n/**\n * Defines a kind of shared object.\n * @remarks\n * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.\n * See {@link @fluidframework/fluid-static#IFluidContainer.create} and {@link @fluidframework/fluid-static#ContainerSchema} for details.\n * @privateRemarks\n * Part of the \"declarative API\".\n * Type erased reference to an {@link ISharedObjectKind} or a DataObject class in for use in\n * `fluid-static`'s `IFluidContainer` and `ContainerSchema`.\n * Use {@link createSharedObjectKind} to creating an instance of this type.\n * @sealed\n * @public\n */\nexport interface SharedObjectKind<out TSharedObject = unknown>\n\textends ErasedType<readonly [\"SharedObjectKind\", TSharedObject]> {\n\t/**\n\t * Check whether an {@link @fluidframework/core-interfaces#IFluidLoadable} is an instance of this shared object kind.\n\t * @remarks This should be used in place of `instanceof` checks for shared objects, as their actual classes are not exported in Fluid's public API.\n\t */\n\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;\n}\n\n/**\n * Utility for creating ISharedObjectKind instances.\n * @remarks\n * This takes in a class which implements IChannelFactory,\n * and uses it to return a a single value which is intended to be used as the APi entry point for the corresponding shared object type.\n * The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.\n * See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.\n * @internal\n */\nexport function createSharedObjectKind<TSharedObject>(\n\tfactory: (new () => IChannelFactory<TSharedObject>) & { readonly Type: string },\n): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject> {\n\tconst result: ISharedObjectKind<TSharedObject> &\n\t\tOmit<SharedObjectKind<TSharedObject>, \"brand\"> = {\n\t\tgetFactory(): IChannelFactory<TSharedObject> {\n\t\t\treturn new factory();\n\t\t},\n\n\t\tcreate(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject {\n\t\t\treturn runtime.createChannel(id, factory.Type) as TSharedObject;\n\t\t},\n\n\t\tis(value: IFluidLoadable): value is IFluidLoadable & TSharedObject {\n\t\t\treturn isChannel(value) && value.attributes.type === factory.Type;\n\t\t},\n\t};\n\n\treturn result as typeof result & SharedObjectKind<TSharedObject>;\n}\n\nfunction isChannel(loadable: IFluidLoadable): loadable is IChannel {\n\t// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.\n\treturn (loadable as IChannel).attributes !== undefined;\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
6
+ import type { ISerializedHandle } from "@fluidframework/runtime-utils/internal";
6
7
  import { FluidSerializer } from "./serializer.js";
7
8
  /**
8
9
  * Serializer implementation for serializing handles during summary.
@@ -11,9 +12,6 @@ import { FluidSerializer } from "./serializer.js";
11
12
  export declare class SummarySerializer extends FluidSerializer {
12
13
  private readonly serializedRoutes;
13
14
  getSerializedRoutes(): string[];
14
- protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): {
15
- type: string;
16
- url: string;
17
- };
15
+ protected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal): ISerializedHandle;
18
16
  }
19
17
  //# sourceMappingURL=summarySerializer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IACpD,mBAAmB,IAAI,MAAM,EAAE;IAItC,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB;;;;CAIlF"}
1
+ {"version":3,"file":"summarySerializer.d.ts","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA0B;IACpD,mBAAmB,IAAI,MAAM,EAAE;IAItC,SAAS,CAAC,eAAe,CACxB,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,oBAAoB,GACxB,iBAAiB;CAIpB"}
@@ -13,7 +13,7 @@ export class SummarySerializer extends FluidSerializer {
13
13
  this.serializedRoutes = new Set();
14
14
  }
15
15
  getSerializedRoutes() {
16
- return Array.from(this.serializedRoutes);
16
+ return [...this.serializedRoutes];
17
17
  }
18
18
  serializeHandle(handle, bind) {
19
19
  this.serializedRoutes.add(handle.absolutePath);
@@ -1 +1 @@
1
- {"version":3,"file":"summarySerializer.js","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IAAtD;;QACkB,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAS5D,CAAC;IARO,mBAAmB;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC1C,CAAC;IAES,eAAe,CAAC,MAA4B,EAAE,IAA0B;QACjF,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\n\nimport { FluidSerializer } from \"./serializer.js\";\n\n/**\n * Serializer implementation for serializing handles during summary.\n * @internal\n */\nexport class SummarySerializer extends FluidSerializer {\n\tprivate readonly serializedRoutes: Set<string> = new Set();\n\tpublic getSerializedRoutes(): string[] {\n\t\treturn Array.from(this.serializedRoutes);\n\t}\n\n\tprotected serializeHandle(handle: IFluidHandleInternal, bind: IFluidHandleInternal) {\n\t\tthis.serializedRoutes.add(handle.absolutePath);\n\t\treturn super.serializeHandle(handle, bind);\n\t}\n}\n"]}
1
+ {"version":3,"file":"summarySerializer.js","sourceRoot":"","sources":["../src/summarySerializer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,eAAe;IAAtD;;QACkB,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAC;IAY5D,CAAC;IAXO,mBAAmB;QACzB,OAAO,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACnC,CAAC;IAES,eAAe,CACxB,MAA4B,EAC5B,IAA0B;QAE1B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport type { ISerializedHandle } from \"@fluidframework/runtime-utils/internal\";\n\nimport { FluidSerializer } from \"./serializer.js\";\n\n/**\n * Serializer implementation for serializing handles during summary.\n * @internal\n */\nexport class SummarySerializer extends FluidSerializer {\n\tprivate readonly serializedRoutes: Set<string> = new Set();\n\tpublic getSerializedRoutes(): string[] {\n\t\treturn [...this.serializedRoutes];\n\t}\n\n\tprotected serializeHandle(\n\t\thandle: IFluidHandleInternal,\n\t\tbind: IFluidHandleInternal,\n\t): ISerializedHandle {\n\t\tthis.serializedRoutes.add(handle.absolutePath);\n\t\treturn super.serializeHandle(handle, bind);\n\t}\n}\n"]}
package/lib/utils.d.ts CHANGED
@@ -15,7 +15,7 @@ import { IFluidSerializer } from "./serializer.js";
15
15
  * @returns Result of strigifying an object
16
16
  * @internal
17
17
  */
18
- export declare function serializeHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): string | undefined;
18
+ export declare function serializeHandles(value: unknown, serializer: IFluidSerializer, bind: IFluidHandle): string | undefined;
19
19
  /**
20
20
  * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
21
21
  * where any embedded IFluidHandles have been replaced with a serializable form.
@@ -30,7 +30,7 @@ export declare function serializeHandles(value: any, serializer: IFluidSerialize
30
30
  * @legacy
31
31
  * @alpha
32
32
  */
33
- export declare function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle): any;
33
+ export declare function makeHandlesSerializable(value: unknown, serializer: IFluidSerializer, bind: IFluidHandle): any;
34
34
  /**
35
35
  * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object
36
36
  * with handle objects created instead.
@@ -42,7 +42,7 @@ export declare function makeHandlesSerializable(value: any, serializer: IFluidSe
42
42
  * @legacy
43
43
  * @alpha
44
44
  */
45
- export declare function parseHandles(value: any, serializer: IFluidSerializer): any;
45
+ export declare function parseHandles(value: unknown, serializer: IFluidSerializer): any;
46
46
  /**
47
47
  * Create a new summary containing one blob
48
48
  * @param key - the key for the blob in the summary
@@ -56,5 +56,5 @@ export declare function createSingleBlobSummary(key: string, content: string | U
56
56
  *
57
57
  * @internal
58
58
  */
59
- export declare function bindHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): void;
59
+ export declare function bindHandles(value: unknown, serializer: IFluidSerializer, bind: IFluidHandle): void;
60
60
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG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KAAK,EAAE,OAAO,EACd,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAEhB,GAAG,CAEL;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,GAAG,GAAG,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,qBAAqB,CAIvB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,YAAY,GAChB,IAAI,CAMN"}
package/lib/utils.js CHANGED
@@ -14,8 +14,7 @@ import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
14
14
  * @internal
15
15
  */
16
16
  export function serializeHandles(value, serializer, bind) {
17
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
18
- return value !== undefined ? serializer.stringify(value, bind) : value;
17
+ return value === undefined ? value : serializer.stringify(value, bind);
19
18
  }
20
19
  /**
21
20
  * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
@@ -32,7 +31,6 @@ export function serializeHandles(value, serializer, bind) {
32
31
  * @alpha
33
32
  */
34
33
  export function makeHandlesSerializable(value, serializer, bind) {
35
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
36
34
  return serializer.encode(value, bind);
37
35
  }
38
36
  /**
@@ -46,8 +44,8 @@ export function makeHandlesSerializable(value, serializer, bind) {
46
44
  * @legacy
47
45
  * @alpha
48
46
  */
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)
49
48
  export function parseHandles(value, serializer) {
50
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
51
49
  return serializer.decode(value);
52
50
  }
53
51
  /**
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAI5E;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACtC,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,+DAA+D;IAC/D,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,UAA4B;IACpE,+DAA+D;IAC/D,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAW,EACX,OAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACzC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAU,EACV,UAA4B,EAC5B,IAAkB;IAElB,sEAAsE;IACtE,0EAA0E;IAC1E,4EAA4E;IAC5E,sEAAsE;IACtE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { IFluidSerializer } from \"./serializer.js\";\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, return a string representation of an object\n * where the handle objects have been replaced with a serializable form.\n * @param value - The mostly-plain object\n * @param serializer - The serializer that knows how to convert handles into serializable format\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns Result of strigifying an object\n * @internal\n */\nexport function serializeHandles(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string | undefined {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn value !== undefined ? serializer.stringify(value, bind) : value;\n}\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n * where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * @param input - The mostly-plain object\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns The fully-plain object\n * @legacy\n * @alpha\n */\nexport function makeHandlesSerializable(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn serializer.encode(value, bind);\n}\n\n/**\n * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object\n * with handle objects created instead.\n * @remarks Idempotent when called multiple times.\n * @param value - The fully-plain object\n * @param serializer - The serializer that knows how to convert serializable-form handles into handle objects\n * @param context - The handle context for the container\n * @returns The mostly-plain object with handle objects within\n * @legacy\n * @alpha\n */\nexport function parseHandles(value: any, serializer: IFluidSerializer) {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn serializer.decode(value);\n}\n\n/**\n * Create a new summary containing one blob\n * @param key - the key for the blob in the summary\n * @param content - blob content\n * @returns The summary containing the blob\n * @internal\n */\nexport function createSingleBlobSummary(\n\tkey: string,\n\tcontent: string | Uint8Array,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tbuilder.addBlob(key, content);\n\treturn builder.getSummaryTree();\n}\n\n/**\n * Binds all handles found in `value` to `bind`. Does not modify original input.\n *\n * @internal\n */\nexport function bindHandles(\n\tvalue: any,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): void {\n\t// N.B. AB#7316 this could be made more efficient by writing an ad hoc\n\t// implementation that doesn't clone at all. Today the distinction between\n\t// this function and `encode` is purely semantic -- encoding both serializes\n\t// handles and binds them, but sometimes we only wish to do the latter\n\tserializer.encode(value, bind);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAI5E;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAAc,EACd,UAA4B,EAC5B,IAAkB;IAElB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACtC,KAAc,EACd,UAA4B,EAC5B,IAAkB;IAGlB,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,6HAA6H;AAC7H,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,UAA4B;IACxE,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAW,EACX,OAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACzC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAc,EACd,UAA4B,EAC5B,IAAkB;IAElB,sEAAsE;IACtE,0EAA0E;IAC1E,4EAA4E;IAC5E,sEAAsE;IACtE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { IFluidSerializer } from \"./serializer.js\";\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, return a string representation of an object\n * where the handle objects have been replaced with a serializable form.\n * @param value - The mostly-plain object\n * @param serializer - The serializer that knows how to convert handles into serializable format\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns Result of strigifying an object\n * @internal\n */\nexport function serializeHandles(\n\tvalue: unknown,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): string | undefined {\n\treturn value === undefined ? value : serializer.stringify(value, bind);\n}\n\n/**\n * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object\n * where any embedded IFluidHandles have been replaced with a serializable form.\n *\n * The original `input` object is not mutated. This method will shallowly clones all objects in the path from\n * the root to any replaced handles. (If no handles are found, returns the original object.)\n *\n * @param input - The mostly-plain object\n * @param context - The handle context for the container\n * @param bind - Bind any other handles we find in the object against this given handle.\n * @returns The fully-plain object\n * @legacy\n * @alpha\n */\nexport function makeHandlesSerializable(\n\tvalue: unknown,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\n): any {\n\treturn serializer.encode(value, bind);\n}\n\n/**\n * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object\n * with handle objects created instead.\n * @remarks Idempotent when called multiple times.\n * @param value - The fully-plain object\n * @param serializer - The serializer that knows how to convert serializable-form handles into handle objects\n * @param context - The handle context for the container\n * @returns The mostly-plain object with handle objects within\n * @legacy\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: AB#26129 use unknown instead of any (legacy breaking)\nexport function parseHandles(value: unknown, serializer: IFluidSerializer): any {\n\treturn serializer.decode(value);\n}\n\n/**\n * Create a new summary containing one blob\n * @param key - the key for the blob in the summary\n * @param content - blob content\n * @returns The summary containing the blob\n * @internal\n */\nexport function createSingleBlobSummary(\n\tkey: string,\n\tcontent: string | Uint8Array,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tbuilder.addBlob(key, content);\n\treturn builder.getSummaryTree();\n}\n\n/**\n * Binds all handles found in `value` to `bind`. Does not modify original input.\n *\n * @internal\n */\nexport function bindHandles(\n\tvalue: unknown,\n\tserializer: IFluidSerializer,\n\tbind: IFluidHandle,\n): void {\n\t// N.B. AB#7316 this could be made more efficient by writing an ad hoc\n\t// implementation that doesn't clone at all. Today the distinction between\n\t// this function and `encode` is purely semantic -- encoding both serializes\n\t// handles and binds them, but sometimes we only wish to do the latter\n\tserializer.encode(value, bind);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/shared-object-base",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Fluid base class for shared distributed data structures",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,30 +69,30 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.11.0",
73
- "@fluidframework/container-definitions": "~2.11.0",
74
- "@fluidframework/container-runtime": "~2.11.0",
75
- "@fluidframework/core-interfaces": "~2.11.0",
76
- "@fluidframework/core-utils": "~2.11.0",
77
- "@fluidframework/datastore": "~2.11.0",
78
- "@fluidframework/datastore-definitions": "~2.11.0",
79
- "@fluidframework/driver-definitions": "~2.11.0",
80
- "@fluidframework/runtime-definitions": "~2.11.0",
81
- "@fluidframework/runtime-utils": "~2.11.0",
82
- "@fluidframework/telemetry-utils": "~2.11.0",
72
+ "@fluid-internal/client-utils": "~2.12.0",
73
+ "@fluidframework/container-definitions": "~2.12.0",
74
+ "@fluidframework/container-runtime": "~2.12.0",
75
+ "@fluidframework/core-interfaces": "~2.12.0",
76
+ "@fluidframework/core-utils": "~2.12.0",
77
+ "@fluidframework/datastore": "~2.12.0",
78
+ "@fluidframework/datastore-definitions": "~2.12.0",
79
+ "@fluidframework/driver-definitions": "~2.12.0",
80
+ "@fluidframework/runtime-definitions": "~2.12.0",
81
+ "@fluidframework/runtime-utils": "~2.12.0",
82
+ "@fluidframework/telemetry-utils": "~2.12.0",
83
83
  "uuid": "^9.0.0"
84
84
  },
85
85
  "devDependencies": {
86
- "@arethetypeswrong/cli": "^0.16.4",
86
+ "@arethetypeswrong/cli": "^0.17.1",
87
87
  "@biomejs/biome": "~1.9.3",
88
- "@fluid-internal/mocha-test-setup": "~2.11.0",
89
- "@fluid-private/test-pairwise-generator": "~2.11.0",
88
+ "@fluid-internal/mocha-test-setup": "~2.12.0",
89
+ "@fluid-private/test-pairwise-generator": "~2.12.0",
90
90
  "@fluid-tools/build-cli": "^0.51.0",
91
91
  "@fluidframework/build-common": "^2.0.3",
92
92
  "@fluidframework/build-tools": "^0.51.0",
93
93
  "@fluidframework/eslint-config-fluid": "^5.6.0",
94
- "@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.10.0",
95
- "@fluidframework/test-runtime-utils": "~2.11.0",
94
+ "@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.11.0",
95
+ "@fluidframework/test-runtime-utils": "~2.12.0",
96
96
  "@microsoft/api-extractor": "7.47.8",
97
97
  "@types/benchmark": "^2.1.0",
98
98
  "@types/mocha": "^9.1.1",
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/shared-object-base";
9
- export const pkgVersion = "2.11.0";
9
+ export const pkgVersion = "2.12.0";