@fluidframework/shared-object-base 2.0.0-dev.7.4.0.216897 → 2.0.0-dev.7.4.0.217884

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 (39) hide show
  1. package/api-report/shared-object-base.api.md +7 -7
  2. package/dist/packageVersion.cjs +1 -1
  3. package/dist/packageVersion.cjs.map +1 -1
  4. package/dist/packageVersion.d.ts +1 -1
  5. package/dist/serializer.cjs +1 -1
  6. package/dist/serializer.cjs.map +1 -1
  7. package/dist/serializer.d.ts +2 -2
  8. package/dist/shared-object-base-alpha.d.ts +423 -45
  9. package/dist/shared-object-base-untrimmed.d.ts +7 -7
  10. package/dist/sharedObject.cjs +2 -2
  11. package/dist/sharedObject.cjs.map +1 -1
  12. package/dist/sharedObject.d.ts +2 -2
  13. package/dist/summarySerializer.cjs +1 -1
  14. package/dist/summarySerializer.cjs.map +1 -1
  15. package/dist/summarySerializer.d.ts +1 -1
  16. package/dist/types.cjs.map +1 -1
  17. package/dist/types.d.ts +2 -2
  18. package/lib/packageVersion.d.ts +1 -1
  19. package/lib/packageVersion.mjs +1 -1
  20. package/lib/packageVersion.mjs.map +1 -1
  21. package/lib/serializer.d.ts +2 -2
  22. package/lib/serializer.mjs +1 -1
  23. package/lib/serializer.mjs.map +1 -1
  24. package/lib/shared-object-base-alpha.d.ts +423 -45
  25. package/lib/shared-object-base-untrimmed.d.ts +7 -7
  26. package/lib/sharedObject.d.ts +2 -2
  27. package/lib/sharedObject.mjs +2 -2
  28. package/lib/sharedObject.mjs.map +1 -1
  29. package/lib/summarySerializer.d.ts +1 -1
  30. package/lib/summarySerializer.mjs +1 -1
  31. package/lib/summarySerializer.mjs.map +1 -1
  32. package/lib/types.d.ts +2 -2
  33. package/lib/types.mjs.map +1 -1
  34. package/package.json +14 -14
  35. package/src/packageVersion.ts +1 -1
  36. package/src/serializer.ts +2 -2
  37. package/src/sharedObject.ts +2 -2
  38. package/src/summarySerializer.ts +1 -1
  39. package/src/types.ts +2 -2
@@ -26,7 +26,7 @@ import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
26
26
  // @internal
27
27
  export function createSingleBlobSummary(key: string, content: string | Uint8Array): ISummaryTreeWithStats;
28
28
 
29
- // @internal
29
+ // @alpha
30
30
  export class FluidSerializer implements IFluidSerializer {
31
31
  constructor(context: IFluidHandleContext, handleParsedCb: (handle: IFluidHandle) => void);
32
32
  decode(input: any): any;
@@ -44,7 +44,7 @@ export class FluidSerializer implements IFluidSerializer {
44
44
  stringify(input: any, bind: IFluidHandle): string;
45
45
  }
46
46
 
47
- // @internal (undocumented)
47
+ // @alpha (undocumented)
48
48
  export interface IFluidSerializer {
49
49
  decode(input: any): any;
50
50
  encode(value: any, bind: IFluidHandle): any;
@@ -60,13 +60,13 @@ export interface ISerializedHandle {
60
60
  url: string;
61
61
  }
62
62
 
63
- // @internal
63
+ // @alpha
64
64
  export interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
65
65
  bindToContext(): void;
66
66
  getGCData(fullGC?: boolean): IGarbageCollectionData;
67
67
  }
68
68
 
69
- // @internal
69
+ // @alpha
70
70
  export interface ISharedObjectEvents extends IErrorEvent {
71
71
  // @eventProperty
72
72
  (event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
@@ -86,7 +86,7 @@ export function parseHandles(value: any, serializer: IFluidSerializer): any;
86
86
  // @internal
87
87
  export function serializeHandles(value: any, serializer: IFluidSerializer, bind: IFluidHandle): string | undefined;
88
88
 
89
- // @internal
89
+ // @alpha
90
90
  export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
91
91
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string);
92
92
  // (undocumented)
@@ -100,7 +100,7 @@ export abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedO
100
100
  protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
101
101
  }
102
102
 
103
- // @internal
103
+ // @alpha
104
104
  export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
105
105
  constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
106
106
  protected abstract applyStashedOp(content: any): unknown;
@@ -142,7 +142,7 @@ export abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISha
142
142
  abstract summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
143
143
  }
144
144
 
145
- // @internal
145
+ // @alpha
146
146
  export class SummarySerializer extends FluidSerializer {
147
147
  // (undocumented)
148
148
  getSerializedRoutes(): string[];
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/shared-object-base";
11
- exports.pkgVersion = "2.0.0-dev.7.4.0.216897";
11
+ exports.pkgVersion = "2.0.0-dev.7.4.0.217884";
12
12
  //# sourceMappingURL=packageVersion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.cjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"2.0.0-dev.7.4.0.216897\";\n"]}
1
+ {"version":3,"file":"packageVersion.cjs","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,oCAAoC,CAAC;AAC/C,QAAA,UAAU,GAAG,wBAAwB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"2.0.0-dev.7.4.0.217884\";\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/shared-object-base";
8
- export declare const pkgVersion = "2.0.0-dev.7.4.0.216897";
8
+ export declare const pkgVersion = "2.0.0-dev.7.4.0.217884";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -16,7 +16,7 @@ const isSerializedHandle = (value) => value?.type === "__fluid_handle__";
16
16
  exports.isSerializedHandle = isSerializedHandle;
17
17
  /**
18
18
  * Data Store serializer implementation
19
- * @internal
19
+ * @alpha
20
20
  */
21
21
  class FluidSerializer {
22
22
  constructor(context,
@@ -1 +1 @@
1
- {"version":3,"file":"serializer.cjs","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iEAAiE;AACjE,wDAAwD;AAExD,iEAA0E;AAE1E,iEAA+D;AAc/D;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA8B,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,kBAAkB,CAAC;AADvB,QAAA,kBAAkB,sBACK;AAsCpC;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,cAA8C;QAF9C,YAAO,GAAP,OAAO,CAAqB;QAE5B,mBAAc,GAAd,cAAc,CAAgC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8E;QAC9E,IAAI,KAAyB,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,yEAAyE;YACzE,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBACzC,8FAA8F;gBAC9F,+FAA+F;gBAC/F,8DAA8D;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEnE,kGAAkG;gBAClG,+FAA+F;gBAC/F,wDAAwD;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE;oBACvB,qFAAqF;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;iBACvB;aACD;SACD;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD;AAnJD,0CAmJC","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 { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle\";\n\n/**\n * JSON serialized form of an IFluidHandle\n * @internal\n */\nexport interface ISerializedHandle {\n\t// Marker to indicate to JSON.parse that the object is a Fluid handle\n\ttype: \"__fluid_handle__\";\n\n\t// URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n\turl: string;\n}\n\n/**\n * @internal\n */\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n\tvalue?.type === \"__fluid_handle__\";\n\n/**\n * @internal\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(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void,\n\t) {\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: any, bind: IFluidHandle) {\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\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: any, bind: IFluidHandle) => {\n\t\t// Detect if 'value' is an IFluidHandle.\n\t\tconst handle = value?.IFluidHandle;\n\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn handle !== undefined ? this.serializeHandle(handle, bind) : 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\tconst parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t\tthis.handleParsedCb(parsedHandle);\n\t\t\treturn parsedHandle;\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 the replacer made a substitution there is no need to decscend further. IFluidHandles are always\n\t\t// leaves in the object graph.\n\t\tif (maybeReplaced !== input) {\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: IFluidHandle, bind: IFluidHandle) {\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.cjs","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iEAAiE;AACjE,wDAAwD;AAExD,iEAA0E;AAE1E,iEAA+D;AAc/D;;GAEG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA8B,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,kBAAkB,CAAC;AADvB,QAAA,kBAAkB,sBACK;AAsCpC;;;GAGG;AACH,MAAa,eAAe;IAG3B,YACkB,OAA4B;IAC7C,+DAA+D;IAC9C,cAA8C;QAF9C,YAAO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KAAK,EAAE;YAC5B,OAAO,aAAa,CAAC;SACrB;QAED,8EAA8E;QAC9E,IAAI,KAAyB,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACzB,yEAAyE;YACzE,IAAI,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;gBACzC,8FAA8F;gBAC9F,+FAA+F;gBAC/F,8DAA8D;gBAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;gBAEnE,kGAAkG;gBAClG,+FAA+F;gBAC/F,wDAAwD;gBACxD,IAAI,QAAQ,KAAK,KAAK,EAAE;oBACvB,qFAAqF;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;iBACvB;aACD;SACD;QACD,OAAO,KAAK,IAAI,KAAK,CAAC;IACvB,CAAC;IAES,eAAe,CAAC,MAAoB,EAAE,IAAkB;QACjE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;YACN,IAAI,EAAE,kBAAkB;YACxB,GAAG,EAAE,MAAM,CAAC,YAAY;SACxB,CAAC;IACH,CAAC;CACD;AAnJD,0CAmJC","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 { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\nimport { IFluidHandle, IFluidHandleContext } from \"@fluidframework/core-interfaces\";\nimport { RemoteFluidObjectHandle } from \"./remoteObjectHandle\";\n\n/**\n * JSON serialized form of an IFluidHandle\n * @internal\n */\nexport interface ISerializedHandle {\n\t// Marker to indicate to JSON.parse that the object is a Fluid handle\n\ttype: \"__fluid_handle__\";\n\n\t// URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n\turl: string;\n}\n\n/**\n * @internal\n */\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n\tvalue?.type === \"__fluid_handle__\";\n\n/**\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 * @alpha\n */\nexport class FluidSerializer implements IFluidSerializer {\n\tprivate readonly root: IFluidHandleContext;\n\n\tpublic constructor(\n\t\tprivate readonly context: IFluidHandleContext,\n\t\t// To be called whenever a handle is parsed by this serializer.\n\t\tprivate readonly handleParsedCb: (handle: IFluidHandle) => void,\n\t) {\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: any, bind: IFluidHandle) {\n\t\treturn JSON.stringify(input, (key, value) => this.encodeValue(value, bind));\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: any, bind: IFluidHandle) => {\n\t\t// Detect if 'value' is an IFluidHandle.\n\t\tconst handle = value?.IFluidHandle;\n\n\t\t// If 'value' is an IFluidHandle return its encoded form.\n\t\treturn handle !== undefined ? this.serializeHandle(handle, bind) : 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\tconst parsedHandle = new RemoteFluidObjectHandle(absolutePath, this.root);\n\t\t\tthis.handleParsedCb(parsedHandle);\n\t\t\treturn parsedHandle;\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 the replacer made a substitution there is no need to decscend further. IFluidHandles are always\n\t\t// leaves in the object graph.\n\t\tif (maybeReplaced !== input) {\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: IFluidHandle, bind: IFluidHandle) {\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"]}
@@ -16,7 +16,7 @@ export interface ISerializedHandle {
16
16
  */
17
17
  export declare const isSerializedHandle: (value: any) => value is ISerializedHandle;
18
18
  /**
19
- * @internal
19
+ * @alpha
20
20
  */
21
21
  export interface IFluidSerializer {
22
22
  /**
@@ -49,7 +49,7 @@ export interface IFluidSerializer {
49
49
  }
50
50
  /**
51
51
  * Data Store serializer implementation
52
- * @internal
52
+ * @alpha
53
53
  */
54
54
  export declare class FluidSerializer implements IFluidSerializer {
55
55
  private readonly context;
@@ -1,64 +1,442 @@
1
+ import { EventEmitterEventType } from '@fluid-internal/client-utils';
2
+ import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';
3
+ import { IChannel } from '@fluidframework/datastore-definitions';
4
+ import { IChannelAttributes } from '@fluidframework/datastore-definitions';
5
+ import { IChannelServices } from '@fluidframework/datastore-definitions';
6
+ import { IChannelStorageService } from '@fluidframework/datastore-definitions';
7
+ import { IErrorEvent } from '@fluidframework/core-interfaces';
8
+ import { IEventProvider } from '@fluidframework/core-interfaces';
9
+ import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
10
+ import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-definitions';
11
+ import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
+ import { IFluidHandle } from '@fluidframework/core-interfaces';
13
+ import { IFluidHandleContext } from '@fluidframework/core-interfaces';
14
+ import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
1
15
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
16
+ import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
+ import { ITelemetryContext } from '@fluidframework/runtime-definitions';
18
+ import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
2
19
 
3
20
  /* Excluded from this release type: createSingleBlobSummary */
4
21
 
5
- /* Excluded from this release type: EventEmitterEventType */
6
-
7
- /* Excluded from this release type: EventEmitterWithErrorHandling */
8
-
9
- /* Excluded from this release type: FluidSerializer */
10
-
11
- /* Excluded from this release type: IChannel */
12
-
13
- /* Excluded from this release type: IChannelAttributes */
14
-
15
- /* Excluded from this release type: IChannelServices */
16
-
17
- /* Excluded from this release type: IChannelStorageService */
18
-
19
- /* Excluded from this release type: IErrorEvent */
20
-
21
- /* Excluded from this release type: IEventProvider */
22
-
23
- /* Excluded from this release type: IEventThisPlaceHolder */
24
-
25
- /* Excluded from this release type: IExperimentalIncrementalSummaryContext */
26
-
27
- /* Excluded from this release type: IFluidDataStoreRuntime */
28
-
29
- /* Excluded from this release type: IFluidHandle */
30
-
31
- /* Excluded from this release type: IFluidHandleContext */
32
-
33
- /* Excluded from this release type: IFluidSerializer */
34
-
35
- /* Excluded from this release type: IGarbageCollectionData */
22
+ /**
23
+ * Data Store serializer implementation
24
+ * @alpha
25
+ */
26
+ export declare class FluidSerializer implements IFluidSerializer {
27
+ private readonly context;
28
+ private readonly handleParsedCb;
29
+ private readonly root;
30
+ constructor(context: IFluidHandleContext, handleParsedCb: (handle: IFluidHandle) => void);
31
+ get IFluidSerializer(): this;
32
+ /**
33
+ * Given a mostly-jsonable object tree that may have handle objects embedded within, will return a
34
+ * fully-jsonable object tree where any embedded IFluidHandles have been replaced with a serializable form.
35
+ *
36
+ * The original `input` object is not mutated. This method will shallowly clone all objects in the path from
37
+ * the root to any replaced handles. (If no handles are found, returns the original object.)
38
+ *
39
+ * Any unbound handles encountered are bound to the provided IFluidHandle.
40
+ */
41
+ encode(input: any, bind: IFluidHandle): any;
42
+ /**
43
+ * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an
44
+ * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.
45
+ *
46
+ * The original `input` object is not mutated. This method will shallowly clone all objects in the path from
47
+ * the root to any replaced handles. (If no handles are found, returns the original object.)
48
+ *
49
+ * The decoded handles are implicitly bound to the handle context of this serializer.
50
+ */
51
+ decode(input: any): any;
52
+ stringify(input: any, bind: IFluidHandle): string;
53
+ parse(input: string): any;
54
+ private readonly encodeValue;
55
+ private readonly decodeValue;
56
+ private recursivelyReplace;
57
+ protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
58
+ type: string;
59
+ url: string;
60
+ };
61
+ }
62
+
63
+ /**
64
+ * @alpha
65
+ */
66
+ export declare interface IFluidSerializer {
67
+ /**
68
+ * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
69
+ * where any embedded IFluidHandles have been replaced with a serializable form.
70
+ *
71
+ * The original `input` object is not mutated. This method will shallowly clones all objects in the path from
72
+ * the root to any replaced handles. (If no handles are found, returns the original object.)
73
+ */
74
+ encode(value: any, bind: IFluidHandle): any;
75
+ /**
76
+ * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an
77
+ * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.
78
+ *
79
+ * The original `input` object is not mutated. This method will shallowly clone all objects in the path from
80
+ * the root to any replaced handles. (If no handles are found, returns the original object.)
81
+ *
82
+ * The decoded handles are implicitly bound to the handle context of this serializer.
83
+ */
84
+ decode(input: any): any;
85
+ /**
86
+ * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.
87
+ */
88
+ stringify(value: any, bind: IFluidHandle): string;
89
+ /**
90
+ * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid
91
+ * handles will be realized as part of the parse
92
+ */
93
+ parse(value: string): any;
94
+ }
36
95
 
37
96
  /* Excluded from this release type: ISerializedHandle */
38
97
 
39
- /* Excluded from this release type: ISharedObject */
40
-
41
- /* Excluded from this release type: ISharedObjectEvents */
98
+ /**
99
+ * Base interface for shared objects from which other interfaces derive. Implemented by SharedObject
100
+ * @alpha
101
+ */
102
+ export declare interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
103
+ /**
104
+ * Binds the given shared object to its containing data store runtime, causing it to attach once
105
+ * the runtime attaches.
106
+ */
107
+ bindToContext(): void;
108
+ /**
109
+ * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to
110
+ * other GC nodes.
111
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
112
+ */
113
+ getGCData(fullGC?: boolean): IGarbageCollectionData;
114
+ }
115
+
116
+ /**
117
+ * Events emitted by {@link ISharedObject}.
118
+ * @alpha
119
+ */
120
+ export declare interface ISharedObjectEvents extends IErrorEvent {
121
+ /**
122
+ * Fires before an incoming operation (op) is applied to the shared object.
123
+ *
124
+ * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
125
+ * use.
126
+ *
127
+ * @eventProperty
128
+ */
129
+ (event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
130
+ /**
131
+ * Fires after an incoming op is applied to the shared object.
132
+ *
133
+ * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
134
+ * use.
135
+ *
136
+ * @eventProperty
137
+ */
138
+ (event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
139
+ }
42
140
 
43
141
  /* Excluded from this release type: isSerializedHandle */
44
142
 
45
- /* Excluded from this release type: ISummaryTreeWithStats */
46
-
47
- /* Excluded from this release type: ITelemetryContext */
48
-
49
- /* Excluded from this release type: ITelemetryLoggerExt */
50
-
51
143
  /* Excluded from this release type: makeHandlesSerializable */
52
144
 
53
145
  /* Excluded from this release type: parseHandles */
54
146
 
55
147
  /* Excluded from this release type: serializeHandles */
56
148
 
57
- /* Excluded from this release type: SharedObject */
58
-
59
- /* Excluded from this release type: SharedObjectCore */
60
-
61
- /* Excluded from this release type: SummarySerializer */
149
+ /**
150
+ * SharedObject with simplified, synchronous summarization and GC.
151
+ * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.
152
+ * @alpha
153
+ */
154
+ export declare abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
155
+ private readonly telemetryContextPrefix;
156
+ /**
157
+ * True while we are garbage collecting this object's data.
158
+ */
159
+ private _isGCing;
160
+ /**
161
+ * The serializer to use to serialize / parse handles, if any.
162
+ */
163
+ private readonly _serializer;
164
+ protected get serializer(): IFluidSerializer;
165
+ /**
166
+ * @param id - The id of the shared object
167
+ * @param runtime - The IFluidDataStoreRuntime which contains the shared object
168
+ * @param attributes - Attributes of the shared object
169
+ */
170
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string);
171
+ /**
172
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
173
+ */
174
+ getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
175
+ /**
176
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
177
+ */
178
+ summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;
179
+ /**
180
+ * {@inheritDoc (ISharedObject:interface).getGCData}
181
+ */
182
+ getGCData(fullGC?: boolean): IGarbageCollectionData;
183
+ /**
184
+ * Calls the serializer over all data in this object that reference other GC nodes.
185
+ * Derived classes must override this to provide custom list of references to other GC nodes.
186
+ */
187
+ protected processGCDataCore(serializer: SummarySerializer): void;
188
+ /**
189
+ * Gets a form of the object that can be serialized.
190
+ * @returns A tree representing the snapshot of the shared object.
191
+ */
192
+ protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
193
+ private incrementTelemetryMetric;
194
+ }
195
+
196
+ /**
197
+ * Base class from which all shared objects derive.
198
+ * @alpha
199
+ */
200
+ export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
201
+ id: string;
202
+ protected runtime: IFluidDataStoreRuntime;
203
+ readonly attributes: IChannelAttributes;
204
+ get IFluidLoadable(): this;
205
+ private readonly opProcessingHelper;
206
+ private readonly callbacksHelper;
207
+ /**
208
+ * The handle referring to this SharedObject
209
+ */
210
+ readonly handle: IFluidHandle;
211
+ /**
212
+ * Telemetry logger for the shared object
213
+ */
214
+ protected readonly logger: ITelemetryLoggerExt;
215
+ private readonly mc;
216
+ /**
217
+ * Connection state
218
+ */
219
+ private _connected;
220
+ /**
221
+ * Services used by the shared object
222
+ */
223
+ private services;
224
+ /**
225
+ * True if the dds is bound to its parent.
226
+ */
227
+ private _isBoundToContext;
228
+ /**
229
+ * Tracks error that closed this object.
230
+ */
231
+ private closeError?;
232
+ /**
233
+ * Gets the connection state
234
+ * @returns The state of the connection
235
+ */
236
+ get connected(): boolean;
237
+ /**
238
+ * @param id - The id of the shared object
239
+ * @param runtime - The IFluidDataStoreRuntime which contains the shared object
240
+ * @param attributes - Attributes of the shared object
241
+ */
242
+ constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
243
+ /**
244
+ * This function is only supposed to be called from SharedObjectCore's constructor and
245
+ * depends on a few things being set already. assert() calls make sure of it.
246
+ * @returns The telemetry sampling helpers, so the constructor can be the one to assign them
247
+ * to variables to avoid complaints from TypeScript.
248
+ */
249
+ private setUpSampledTelemetryHelpers;
250
+ /**
251
+ * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)
252
+ * would result in same error thrown. If called multiple times, only first error is remembered.
253
+ * @param error - error object that is thrown whenever an attempt is made to modify this object
254
+ */
255
+ private closeWithError;
256
+ /**
257
+ * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.
258
+ */
259
+ private verifyNotClosed;
260
+ /**
261
+ * Event listener handler helper that can be used to react to exceptions thrown from event listeners
262
+ * It wraps error with DataProcessingError, closes this object and throws resulting error.
263
+ * See closeWithError() for more details
264
+ * Ideally such situation never happens, as consumers of DDS should never throw exceptions
265
+ * in event listeners (i.e. catch any of the issues and make determination on how to handle it).
266
+ * When such exceptions propagate through, most likely data model is no longer consistent, i.e.
267
+ * DDS state does not match what user sees. Because of it DDS moves to "corrupted state" and does not
268
+ * allow processing of ops or local changes, which very quickly results in container closure.
269
+ */
270
+ private eventListenerErrorHandler;
271
+ private attachListeners;
272
+ /**
273
+ * A shared object, after construction, can either be loaded in the case that it is already part of
274
+ * a shared document. Or later attached if it is being newly added.
275
+ * @param services - Services used by the shared object
276
+ */
277
+ load(services: IChannelServices): Promise<void>;
278
+ /**
279
+ * Initializes the object as a local, non-shared object. This object can become shared after
280
+ * it is attached to the document.
281
+ */
282
+ initializeLocal(): void;
283
+ /**
284
+ * {@inheritDoc (ISharedObject:interface).bindToContext}
285
+ */
286
+ bindToContext(): void;
287
+ /**
288
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}
289
+ */
290
+ connect(services: IChannelServices): void;
291
+ /**
292
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}
293
+ */
294
+ isAttached(): boolean;
295
+ /**
296
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
297
+ */
298
+ abstract getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
299
+ /**
300
+ * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
301
+ */
302
+ abstract summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
303
+ /**
304
+ * {@inheritDoc (ISharedObject:interface).getGCData}
305
+ */
306
+ abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
307
+ /**
308
+ * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
309
+ * to another object in the container.
310
+ * @param decodedHandle - The handle of the Fluid object that is decoded.
311
+ */
312
+ protected handleDecoded(decodedHandle: IFluidHandle): void;
313
+ /**
314
+ * Allows the distributed data type to perform custom loading
315
+ * @param services - Storage used by the shared object
316
+ */
317
+ protected abstract loadCore(services: IChannelStorageService): Promise<void>;
318
+ /**
319
+ * Allows the distributed data type to perform custom local loading.
320
+ */
321
+ protected initializeLocalCore(): void;
322
+ /**
323
+ * Allows the distributive data type the ability to perform custom processing once an attach has happened.
324
+ * Also called after non-local data type get loaded.
325
+ */
326
+ protected didAttach(): void;
327
+ /**
328
+ * Derived classes must override this to do custom processing on a remote message.
329
+ * @param message - The message to process
330
+ * @param local - True if the shared object is local
331
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
332
+ * For messages from a remote client, this will be undefined.
333
+ */
334
+ protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): any;
335
+ /**
336
+ * Called when the object has disconnected from the delta stream.
337
+ */
338
+ protected abstract onDisconnect(): any;
339
+ /**
340
+ * Submits a message by the local client to the runtime.
341
+ * @param content - Content of the message
342
+ * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime
343
+ * and not sent to the server. This will be sent back when this message is received back from the server. This is
344
+ * also sent if we are asked to resubmit the message.
345
+ */
346
+ protected submitLocalMessage(content: any, localOpMetadata?: unknown): void;
347
+ /**
348
+ * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock
349
+ * that want to be part of summary but does not generate ops.
350
+ */
351
+ protected dirty(): void;
352
+ /**
353
+ * Called when the object has fully connected to the delta stream
354
+ * Default implementation for DDS, override if different behavior is required.
355
+ */
356
+ protected onConnect(): void;
357
+ /**
358
+ * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.
359
+ * The default implementation here is to resubmit the same message. The client can override if different behavior
360
+ * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit
361
+ * anything at all.
362
+ * @param content - The content of the original message.
363
+ * @param localOpMetadata - The local metadata associated with the original message.
364
+ */
365
+ protected reSubmitCore(content: any, localOpMetadata: unknown): void;
366
+ /**
367
+ * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.
368
+ * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),
369
+ * the Promise will reject.
370
+ * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.
371
+ */
372
+ protected newAckBasedPromise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
373
+ private attachDeltaHandler;
374
+ /**
375
+ * Set the state of connection to services.
376
+ * @param connected - true if connected, false otherwise.
377
+ */
378
+ private setConnectionState;
379
+ /**
380
+ * Handles a message being received from the remote delta server.
381
+ * @param message - The message to process
382
+ * @param local - Whether the message originated from the local client
383
+ * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
384
+ * For messages from a remote client, this will be undefined.
385
+ */
386
+ private process;
387
+ /**
388
+ * Called when a message has to be resubmitted. This typically happens for unacked messages after a
389
+ * reconnection.
390
+ * @param content - The content of the original message.
391
+ * @param localOpMetadata - The local metadata associated with the original message.
392
+ */
393
+ private reSubmit;
394
+ /**
395
+ * Revert an op
396
+ */
397
+ protected rollback(content: any, localOpMetadata: unknown): void;
398
+ /**
399
+ * Apply changes from an op. Used when rehydrating an attached container
400
+ * with pending changes. This prepares the SharedObject for seeing an ACK
401
+ * for the op or resubmitting the op upon reconnection.
402
+ * @param content - Contents of a stashed op.
403
+ * @returns localMetadata of the op, to be passed to process() or resubmit()
404
+ * when the op is ACKed or resubmitted, respectively
405
+ */
406
+ protected abstract applyStashedOp(content: any): unknown;
407
+ /**
408
+ * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,
409
+ * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners
410
+ * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events
411
+ * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the
412
+ * future.
413
+ * @param event - The event to emit.
414
+ * @param args - Arguments to pass to the event listeners.
415
+ * @returns `true` if the event had listeners, `false` otherwise.
416
+ */
417
+ emit(event: EventEmitterEventType, ...args: any[]): boolean;
418
+ /**
419
+ * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement
420
+ * done on the duration of the callbacks. Simply calls `super.emit()`.
421
+ * @param event - Event to emit
422
+ * @param args - Arguments for the event
423
+ * @returns Whatever `super.emit()` returns.
424
+ */
425
+ private emitInternal;
426
+ }
427
+
428
+ /**
429
+ * Serializer implementation for serializing handles during summary.
430
+ * @alpha
431
+ */
432
+ export declare class SummarySerializer extends FluidSerializer {
433
+ private readonly serializedRoutes;
434
+ getSerializedRoutes(): string[];
435
+ protected serializeHandle(handle: IFluidHandle, bind: IFluidHandle): {
436
+ type: string;
437
+ url: string;
438
+ };
439
+ }
62
440
 
63
441
  /* Excluded from this release type: ValueType */
64
442