@fluidframework/datastore 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (145) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +273 -0
  4. package/README.md +41 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/datastore.api.md +168 -0
  8. package/dist/channelContext.cjs +86 -0
  9. package/dist/channelContext.cjs.map +1 -0
  10. package/dist/channelContext.d.ts +15 -9
  11. package/dist/channelContext.d.ts.map +1 -1
  12. package/dist/{channelDeltaConnection.js → channelDeltaConnection.cjs} +14 -15
  13. package/dist/channelDeltaConnection.cjs.map +1 -0
  14. package/dist/channelDeltaConnection.d.ts +4 -5
  15. package/dist/channelDeltaConnection.d.ts.map +1 -1
  16. package/dist/{channelStorageService.js → channelStorageService.cjs} +13 -16
  17. package/dist/channelStorageService.cjs.map +1 -0
  18. package/dist/channelStorageService.d.ts +2 -2
  19. package/dist/channelStorageService.d.ts.map +1 -1
  20. package/dist/{dataStoreRuntime.js → dataStoreRuntime.cjs} +302 -225
  21. package/dist/dataStoreRuntime.cjs.map +1 -0
  22. package/dist/dataStoreRuntime.d.ts +81 -37
  23. package/dist/dataStoreRuntime.d.ts.map +1 -1
  24. package/dist/datastore-alpha.d.ts +317 -0
  25. package/dist/datastore-beta.d.ts +47 -0
  26. package/dist/datastore-public.d.ts +47 -0
  27. package/dist/datastore-untrimmed.d.ts +324 -0
  28. package/dist/{fluidHandle.js → fluidHandle.cjs} +44 -16
  29. package/dist/fluidHandle.cjs.map +1 -0
  30. package/dist/fluidHandle.d.ts +33 -6
  31. package/dist/fluidHandle.d.ts.map +1 -1
  32. package/dist/index.cjs +15 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/localChannelContext.cjs +190 -0
  37. package/dist/localChannelContext.cjs.map +1 -0
  38. package/dist/localChannelContext.d.ts +12 -21
  39. package/dist/localChannelContext.d.ts.map +1 -1
  40. package/dist/{localChannelStorageService.js → localChannelStorageService.cjs} +3 -3
  41. package/dist/localChannelStorageService.cjs.map +1 -0
  42. package/dist/localChannelStorageService.d.ts.map +1 -1
  43. package/dist/remoteChannelContext.cjs +124 -0
  44. package/dist/remoteChannelContext.cjs.map +1 -0
  45. package/dist/remoteChannelContext.d.ts +5 -10
  46. package/dist/remoteChannelContext.d.ts.map +1 -1
  47. package/dist/tsdoc-metadata.json +11 -0
  48. package/lib/{channelContext.d.ts → channelContext.d.mts} +16 -10
  49. package/lib/channelContext.d.mts.map +1 -0
  50. package/lib/channelContext.mjs +78 -0
  51. package/lib/channelContext.mjs.map +1 -0
  52. package/lib/{channelDeltaConnection.d.ts → channelDeltaConnection.d.mts} +4 -5
  53. package/lib/channelDeltaConnection.d.mts.map +1 -0
  54. package/lib/{channelDeltaConnection.js → channelDeltaConnection.mjs} +11 -12
  55. package/lib/channelDeltaConnection.mjs.map +1 -0
  56. package/lib/{channelStorageService.d.ts → channelStorageService.d.mts} +2 -2
  57. package/lib/channelStorageService.d.mts.map +1 -0
  58. package/lib/{channelStorageService.js → channelStorageService.mjs} +13 -16
  59. package/lib/channelStorageService.mjs.map +1 -0
  60. package/lib/{dataStoreRuntime.d.ts → dataStoreRuntime.d.mts} +81 -37
  61. package/lib/dataStoreRuntime.d.mts.map +1 -0
  62. package/lib/{dataStoreRuntime.js → dataStoreRuntime.mjs} +286 -209
  63. package/lib/dataStoreRuntime.mjs.map +1 -0
  64. package/lib/datastore-alpha.d.mts +317 -0
  65. package/lib/datastore-beta.d.mts +47 -0
  66. package/lib/datastore-public.d.mts +47 -0
  67. package/lib/datastore-untrimmed.d.mts +324 -0
  68. package/lib/fluidHandle.d.mts +57 -0
  69. package/lib/fluidHandle.d.mts.map +1 -0
  70. package/lib/{fluidHandle.js → fluidHandle.mjs} +44 -16
  71. package/lib/fluidHandle.mjs.map +1 -0
  72. package/lib/index.d.mts +7 -0
  73. package/lib/index.d.mts.map +1 -0
  74. package/lib/index.mjs +7 -0
  75. package/lib/index.mjs.map +1 -0
  76. package/lib/{localChannelContext.d.ts → localChannelContext.d.mts} +13 -22
  77. package/lib/localChannelContext.d.mts.map +1 -0
  78. package/lib/{localChannelContext.js → localChannelContext.mjs} +73 -85
  79. package/lib/localChannelContext.mjs.map +1 -0
  80. package/lib/localChannelStorageService.d.mts.map +1 -0
  81. package/lib/{localChannelStorageService.js → localChannelStorageService.mjs} +2 -2
  82. package/lib/localChannelStorageService.mjs.map +1 -0
  83. package/lib/{remoteChannelContext.d.ts → remoteChannelContext.d.mts} +7 -12
  84. package/lib/remoteChannelContext.d.mts.map +1 -0
  85. package/lib/remoteChannelContext.mjs +120 -0
  86. package/lib/remoteChannelContext.mjs.map +1 -0
  87. package/package.json +107 -72
  88. package/{lib/index.js → prettier.config.cjs} +4 -3
  89. package/src/channelContext.ts +168 -71
  90. package/src/channelDeltaConnection.ts +52 -47
  91. package/src/channelStorageService.ts +59 -55
  92. package/src/dataStoreRuntime.ts +1158 -983
  93. package/src/fluidHandle.ts +92 -64
  94. package/src/index.ts +8 -2
  95. package/src/localChannelContext.ts +278 -272
  96. package/src/localChannelStorageService.ts +48 -46
  97. package/src/remoteChannelContext.ts +237 -300
  98. package/tsc-multi.test.json +4 -0
  99. package/tsconfig.json +11 -13
  100. package/dist/channelContext.js +0 -35
  101. package/dist/channelContext.js.map +0 -1
  102. package/dist/channelDeltaConnection.js.map +0 -1
  103. package/dist/channelStorageService.js.map +0 -1
  104. package/dist/dataStoreRuntime.js.map +0 -1
  105. package/dist/fluidHandle.js.map +0 -1
  106. package/dist/index.js +0 -19
  107. package/dist/index.js.map +0 -1
  108. package/dist/localChannelContext.js +0 -202
  109. package/dist/localChannelContext.js.map +0 -1
  110. package/dist/localChannelStorageService.js.map +0 -1
  111. package/dist/packageVersion.d.ts +0 -9
  112. package/dist/packageVersion.d.ts.map +0 -1
  113. package/dist/packageVersion.js +0 -12
  114. package/dist/packageVersion.js.map +0 -1
  115. package/dist/remoteChannelContext.js +0 -207
  116. package/dist/remoteChannelContext.js.map +0 -1
  117. package/lib/channelContext.d.ts.map +0 -1
  118. package/lib/channelContext.js +0 -29
  119. package/lib/channelContext.js.map +0 -1
  120. package/lib/channelDeltaConnection.d.ts.map +0 -1
  121. package/lib/channelDeltaConnection.js.map +0 -1
  122. package/lib/channelStorageService.d.ts.map +0 -1
  123. package/lib/channelStorageService.js.map +0 -1
  124. package/lib/dataStoreRuntime.d.ts.map +0 -1
  125. package/lib/dataStoreRuntime.js.map +0 -1
  126. package/lib/fluidHandle.d.ts +0 -30
  127. package/lib/fluidHandle.d.ts.map +0 -1
  128. package/lib/fluidHandle.js.map +0 -1
  129. package/lib/index.d.ts +0 -7
  130. package/lib/index.d.ts.map +0 -1
  131. package/lib/index.js.map +0 -1
  132. package/lib/localChannelContext.d.ts.map +0 -1
  133. package/lib/localChannelContext.js.map +0 -1
  134. package/lib/localChannelStorageService.d.ts.map +0 -1
  135. package/lib/localChannelStorageService.js.map +0 -1
  136. package/lib/packageVersion.d.ts +0 -9
  137. package/lib/packageVersion.d.ts.map +0 -1
  138. package/lib/packageVersion.js +0 -9
  139. package/lib/packageVersion.js.map +0 -1
  140. package/lib/remoteChannelContext.d.ts.map +0 -1
  141. package/lib/remoteChannelContext.js +0 -203
  142. package/lib/remoteChannelContext.js.map +0 -1
  143. package/src/packageVersion.ts +0 -9
  144. package/tsconfig.esnext.json +0 -7
  145. /package/lib/{localChannelStorageService.d.ts → localChannelStorageService.d.mts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"channelDeltaConnection.js","sourceRoot":"","sources":["../src/channelDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAGtD,qEAAsE;AAGtE,MAAa,sBAAsB;IAW/B,YACW,QAAgB,EACf,UAAmB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I,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACvD;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,OAAkC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACJ;AArDD,wDAqDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltaConnection, IDeltaHandler } from \"@fluidframework/datastore-definitions\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nexport class ChannelDeltaConnection implements IDeltaConnection {\n private _handler: IDeltaHandler | undefined;\n\n private get handler(): IDeltaHandler {\n assert(!!this._handler, 0x177 /* \"Missing delta handler\" */);\n return this._handler;\n }\n public get connected(): boolean {\n return this._connected;\n }\n\n constructor(\n public objectId: string,\n private _connected: boolean,\n public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,\n public readonly dirty: () => void,\n public readonly addedGCOutboundReference: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void) {\n }\n\n public attach(handler: IDeltaHandler) {\n assert(this._handler === undefined, 0x178 /* \"Missing delta handler on attach\" */);\n this._handler = handler;\n }\n\n public setConnectionState(connected: boolean) {\n this._connected = connected;\n this.handler.setConnectionState(connected);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n try {\n // catches as data processing error whether or not they come from async pending queues\n this.handler.process(message, local, localOpMetadata);\n } catch (error) {\n throw DataProcessingError.wrapIfUnrecognized(\n error, \"channelDeltaConnectionFailedToProcessMessage\", message);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n this.handler.reSubmit(content, localOpMetadata);\n }\n\n public rollback(content: any, localOpMetadata: unknown) {\n if (this.handler.rollback === undefined) {\n throw new Error(\"Handler doesn't support rollback\");\n }\n this.handler.rollback(content, localOpMetadata);\n }\n\n public applyStashedOp(message: ISequencedDocumentMessage): unknown {\n return this.handler.applyStashedOp(message);\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"channelStorageService.js","sourceRoot":"","sources":["../src/channelStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,iEAAoF;AAGpF,MAAa,qBAAqB;IAe9B,YACqB,IAA+B,EAC/B,OAAkD,EAClD,MAAwB,EACxB,UAAyC;QAHzC,SAAI,GAAJ,IAAI,CAA2B;QAC/B,YAAO,GAAP,OAAO,CAA2C;QAClD,WAAM,GAAN,MAAM,CAAkB;QACxB,eAAU,GAAV,UAAU,CAA+B;QAE1D,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,mCAAmC;QACnC,IAAI,IAAI,KAAK,SAAS,EAAE;YACnB,qBAAqB,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;SACpE;IACL,CAAC;IAzBO,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,IAAmB,EAAE,OAAoC;QAC9F,8DAA8D;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC3B,qBAAqB,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;SACnF;QAED,8DAA8D;QAC9D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC3B,OAAO,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,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AC1C;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,mCAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY;QACnC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACJ;AAjED,sDAiEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { getNormalizedObjectStoragePathParts } from \"@fluidframework/runtime-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\n\nexport class ChannelStorageService implements IChannelStorageService {\n private static flattenTree(base: string, tree: ISnapshotTree, results: { [path: string]: string; }) {\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const path in tree.trees) {\n ChannelStorageService.flattenTree(`${base}${path}/`, tree.trees[path], results);\n }\n\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const blob in tree.blobs) {\n results[`${base}${blob}`] = tree.blobs[blob];\n }\n }\n\n private readonly flattenedTree: { [path: string]: string; };\n\n constructor(\n private readonly tree: ISnapshotTree | undefined,\n private readonly storage: Pick<IDocumentStorageService, \"readBlob\">,\n private readonly logger: ITelemetryLogger,\n private readonly extraBlobs?: Map<string, ArrayBufferLike>,\n ) {\n this.flattenedTree = {};\n // Create a map from paths to blobs\n if (tree !== undefined) {\n ChannelStorageService.flattenTree(\"\", tree, this.flattenedTree);\n }\n }\n\n public async contains(path: string): Promise<boolean> {\n return this.flattenedTree[path] !== undefined;\n }\n\n public async readBlob(path: string): Promise<ArrayBufferLike> {\n const id = await this.getIdForPath(path);\n const blob = this.extraBlobs !== undefined\n ? this.extraBlobs.get(id)\n : undefined;\n\n if (blob !== undefined) {\n return blob;\n }\n const blobP = this.storage.readBlob(id);\n blobP.catch((error) => this.logger.sendErrorEvent({ eventName: \"ChannelStorageBlobError\" }, error));\n\n return blobP;\n }\n\n public async list(path: string): Promise<string[]> {\n let tree = this.tree;\n const pathParts = getNormalizedObjectStoragePathParts(path);\n while (tree !== undefined && pathParts.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const part = pathParts.shift()!;\n tree = tree.trees[part];\n }\n if (tree === undefined || pathParts.length !== 0) {\n throw new Error(\"path does not exist\");\n }\n\n return Object.keys(tree?.blobs ?? {});\n }\n\n private async getIdForPath(path: string): Promise<string> {\n return this.flattenedTree[path];\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataStoreRuntime.js","sourceRoot":"","sources":["../src/dataStoreRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,iFAM+C;AAC/C,qEAAkF;AAClF,+DAMsC;AACtC,qEAIyC;AACzC,+DAAiE;AACjE,+EAQ8C;AAC9C,6EAY6C;AAC7C,iEASuC;AAOvC,yEAK2C;AAC3C,+BAAkC;AAClC,qDAAqE;AACrE,+DAAoH;AACpH,iEAA8D;AAE9D,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,wBAAwB;IACxB,yCAAiB,CAAA;IACjB,wCAAgB,CAAA;AACpB,CAAC,EAJW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAI/B;AAQD;;GAEG;AACH,MAAa,qBAAsB,SACnC,gCAA+C;IAgF3C,YACqB,gBAAwC,EACxC,oBAA2C,EAC5D,QAAiB;QAEjB,KAAK,EAAE,CAAC;QAJS,qBAAgB,GAAhB,gBAAgB,CAAwB;QACxC,yBAAoB,GAApB,oBAAoB,CAAuB;QA9BxD,cAAS,GAAG,KAAK,CAAC;QAGT,aAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC9C,qBAAgB,GAAG,IAAI,GAAG,EAAqC,CAAC;Q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AC;QACF,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;QAE9C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE;YAC/B,IAAI,GAAG;gBACH,IAAI,EAAE,kCAAW,CAAC,IAAI;gBACtB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;aACzB,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;SACjC;QACD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAG,IAAW;QAC1B,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;SACxD;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CAC4B,CAAC;AAnCzB,QAAA,mBAAmB,uBAmCM","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IFluidHandle,\n IFluidHandleContext,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IDeltaManager,\n BindState,\n AttachState,\n ILoaderOptions,\n} from \"@fluidframework/container-definitions\";\nimport { DataProcessingError, UsageError } from \"@fluidframework/container-utils\";\nimport {\n assert,\n Deferred,\n LazyPromise,\n TypedEventEmitter,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport {\n ChildLogger,\n LoggingError,\n raiseConnectedEvent,\n} from \"@fluidframework/telemetry-utils\";\nimport { buildSnapshotTree } from \"@fluidframework/driver-utils\";\nimport {\n IClientDetails,\n IDocumentMessage,\n ISequencedDocumentMessage,\n SummaryType,\n ISummaryBlob,\n ISummaryTree,\n IQuorumClients,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n CreateSummarizerNodeSource,\n IAttachMessage,\n IEnvelope,\n IFluidDataStoreContext,\n IFluidDataStoreChannel,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n IInboundSignalMessage,\n ISummaryTreeWithStats,\n VisibilityState,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n convertSnapshotTreeToSummaryTree,\n convertSummaryTreeToITree,\n generateHandleContextPath,\n RequestParser,\n SummaryTreeBuilder,\n create404Response,\n createResponseError,\n exceptionToResponse,\n} from \"@fluidframework/runtime-utils\";\nimport {\n IChannel,\n IFluidDataStoreRuntime,\n IFluidDataStoreRuntimeEvents,\n IChannelFactory,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n GCDataBuilder,\n removeRouteFromAllNodes,\n unpackChildNodesGCDetails,\n unpackChildNodesUsedRoutes,\n} from \"@fluidframework/garbage-collector\";\nimport { v4 as uuid } from \"uuid\";\nimport { IChannelContext, summarizeChannel } from \"./channelContext\";\nimport { LocalChannelContext, LocalChannelContextBase, RehydratedLocalChannelContext } from \"./localChannelContext\";\nimport { RemoteChannelContext } from \"./remoteChannelContext\";\n\nexport enum DataStoreMessageType {\n // Creates a new channel\n Attach = \"attach\",\n ChannelOp = \"op\",\n}\n\nexport interface ISharedObjectRegistry {\n // TODO consider making this async. A consequence is that either the creation of a distributed data type\n // is async or we need a new API to split the synchronous vs. asynchronous creation.\n get(name: string): IChannelFactory | undefined;\n}\n\n/**\n * Base data store class\n */\nexport class FluidDataStoreRuntime extends\nTypedEventEmitter<IFluidDataStoreRuntimeEvents> implements\nIFluidDataStoreChannel, IFluidDataStoreRuntime, IFluidHandleContext {\n /**\n * Loads the data store runtime\n * @param context - The data store context\n * @param sharedObjectRegistry - The registry of shared objects used by this data store\n * @param existing - If loading from an existing file.\n */\n public static load(\n context: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n existing: boolean,\n ): FluidDataStoreRuntime {\n return new FluidDataStoreRuntime(context, sharedObjectRegistry, existing);\n }\n\n public get IFluidRouter() { return this; }\n\n public get connected(): boolean {\n return this.dataStoreContext.connected;\n }\n\n public get clientId(): string | undefined {\n return this.dataStoreContext.clientId;\n }\n\n public get clientDetails(): IClientDetails {\n return this.dataStoreContext.clientDetails;\n }\n\n public get isAttached(): boolean {\n return this.attachState !== AttachState.Detached;\n }\n\n public get attachState(): AttachState {\n return this._attachState;\n }\n\n public get absolutePath(): string {\n return generateHandleContextPath(this.id, this.routeContext);\n }\n\n public get routeContext(): IFluidHandleContext {\n return this.dataStoreContext.IFluidHandleContext;\n }\n\n public get IFluidHandleContext() { return this; }\n\n public get rootRoutingContext() { return this; }\n public get channelsRoutingContext() { return this; }\n public get objectsRoutingContext() { return this; }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n\n private readonly contexts = new Map<string, IChannelContext>();\n private readonly contextsDeferred = new Map<string, Deferred<IChannelContext>>();\n private readonly pendingAttach = new Map<string, IAttachMessage>();\n\n private bindState: BindState;\n private readonly deferredAttached = new Deferred<void>();\n private readonly localChannelContextQueue = new Map<string, LocalChannelContextBase>();\n private readonly notBoundedChannelContextSet = new Set<string>();\n private _attachState: AttachState;\n public visibilityState: VisibilityState;\n // A list of handles that are bound when the data store is not visible. We have to make them visible when the data\n // store becomes visible.\n private readonly pendingHandlesToMakeVisible: Set<IFluidHandle> = new Set();\n\n public readonly id: string;\n public readonly options: ILoaderOptions;\n public readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>;\n private readonly quorum: IQuorumClients;\n private readonly audience: IAudience;\n public readonly logger: ITelemetryLogger;\n\n // A map of child channel context ids to the their base GC details. This is used to initialize the GC state of the\n // channel contexts.\n private readonly channelsBaseGCDetails: LazyPromise<Map<string, IGarbageCollectionDetailsBase>>;\n\n public constructor(\n private readonly dataStoreContext: IFluidDataStoreContext,\n private readonly sharedObjectRegistry: ISharedObjectRegistry,\n existing: boolean,\n ) {\n super();\n\n assert(!dataStoreContext.id.includes(\"/\"),\n 0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */);\n\n this.logger = ChildLogger.create(\n dataStoreContext.logger,\n \"FluidDataStoreRuntime\",\n { all: { dataStoreId: uuid() } },\n );\n\n this.id = dataStoreContext.id;\n this.options = dataStoreContext.options;\n this.deltaManager = dataStoreContext.deltaManager;\n this.quorum = dataStoreContext.getQuorum();\n this.audience = dataStoreContext.getAudience();\n\n const tree = dataStoreContext.baseSnapshot;\n\n this.channelsBaseGCDetails = new LazyPromise(async () => {\n const baseGCDetails = await\n (this.dataStoreContext.getBaseGCDetails?.() ?? this.dataStoreContext.getInitialGCSummaryDetails());\n return unpackChildNodesGCDetails(baseGCDetails);\n });\n\n // Must always receive the data store type inside of the attributes\n if (tree?.trees !== undefined) {\n Object.keys(tree.trees).forEach((path) => {\n // Issue #4414\n if (path === \"_search\") { return; }\n\n let channelContext: IChannelContext;\n // If already exists on storage, then create a remote channel. However, if it is case of rehydrating a\n // container from snapshot where we load detached container from a snapshot, isLocalDataStore would be\n // true. In this case create a RehydratedLocalChannelContext.\n if (dataStoreContext.isLocalDataStore) {\n channelContext = new RehydratedLocalChannelContext(\n path,\n this.sharedObjectRegistry,\n this,\n this.dataStoreContext,\n this.dataStoreContext.storage,\n this.logger,\n (content, localOpMetadata) => this.submitChannelOp(path, content, localOpMetadata),\n (address: string) => this.setChannelDirty(address),\n (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) =>\n this.addedGCOutboundReference(srcHandle, outboundHandle),\n tree.trees[path]);\n // This is the case of rehydrating a detached container from snapshot. Now due to delay loading of\n // data store, if the data store is loaded after the container is attached, then we missed making\n // the channel visible. So do it now. Otherwise, add it to local channel context queue, so\n // that it can be make it visible later with the data store.\n if (dataStoreContext.attachState !== AttachState.Detached) {\n (channelContext as LocalChannelContextBase).makeVisible();\n } else {\n this.localChannelContextQueue.set(path, channelContext as LocalChannelContextBase);\n }\n } else {\n channelContext = new RemoteChannelContext(\n this,\n dataStoreContext,\n dataStoreContext.storage,\n (content, localOpMetadata) => this.submitChannelOp(path, content, localOpMetadata),\n (address: string) => this.setChannelDirty(address),\n (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) =>\n this.addedGCOutboundReference(srcHandle, outboundHandle),\n path,\n tree.trees[path],\n this.sharedObjectRegistry,\n undefined /* extraBlobs */,\n this.dataStoreContext.getCreateChildSummarizerNodeFn(\n path,\n { type: CreateSummarizerNodeSource.FromSummary },\n ),\n async () => this.getChannelBaseGCDetails(path));\n }\n const deferred = new Deferred<IChannelContext>();\n deferred.resolve(channelContext);\n\n this.contexts.set(path, channelContext);\n this.contextsDeferred.set(path, deferred);\n });\n }\n\n this.attachListener();\n // If exists on storage or loaded from a snapshot, it should already be bound.\n this.bindState = existing ? BindState.Bound : BindState.NotBound;\n this._attachState = dataStoreContext.attachState;\n\n /**\n * If existing flag is false, this is a new data store and is not visible. The existing flag can be true in two\n * conditions:\n * 1. It's a local data store that is created when a detached container is rehydrated. In this case, the data\n * store is locally visible because the snapshot it is loaded from contains locally visible data stores only.\n * 2. It's a remote data store that is created when an attached container is loaded is loaded from snapshot or\n * when an attach op comes in. In both these cases, the data store is already globally visible.\n */\n if (existing) {\n this.visibilityState = dataStoreContext.attachState === AttachState.Detached\n ? VisibilityState.LocallyVisible : VisibilityState.GloballyVisible;\n } else {\n this.visibilityState = VisibilityState.NotVisible;\n }\n\n // If it's existing we know it has been attached.\n if (existing) {\n this.deferredAttached.resolve();\n }\n }\n\n public dispose(): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.emit(\"dispose\");\n this.removeAllListeners();\n }\n\n public async resolveHandle(request: IRequest): Promise<IResponse> {\n return this.request(request);\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n try {\n const parser = RequestParser.create(request);\n const id = parser.pathParts[0];\n\n if (id === \"_channels\" || id === \"_custom\") {\n return this.request(parser.createSubRequest(1));\n }\n\n // Check for a data type reference first\n if (this.contextsDeferred.has(id) && parser.isLeaf(1)) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = await this.contextsDeferred.get(id)!.promise;\n const channel = await value.getChannel();\n\n return { mimeType: \"fluid/object\", status: 200, value: channel };\n } catch (error) {\n this.logger.sendErrorEvent({ eventName: \"GetChannelFailedInRequest\" }, error);\n\n return createResponseError(500, `Failed to get Channel: ${error}`, request);\n }\n }\n\n // Otherwise defer to an attached request handler\n return create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n\n public async getChannel(id: string): Promise<IChannel> {\n this.verifyNotClosed();\n\n // TODO we don't assume any channels (even root) in the runtime. If you request a channel that doesn't exist\n // we will never resolve the promise. May want a flag to getChannel that doesn't wait for the promise if\n // it doesn't exist\n if (!this.contextsDeferred.has(id)) {\n this.contextsDeferred.set(id, new Deferred<IChannelContext>());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const context = await this.contextsDeferred.get(id)!.promise;\n const channel = await context.getChannel();\n\n return channel;\n }\n\n public createChannel(id: string = uuid(), type: string): IChannel {\n if (id.includes(\"/\")) {\n throw new UsageError(`Id cannot contain slashes: ${id}`);\n }\n\n this.verifyNotClosed();\n\n assert(!this.contexts.has(id), 0x179 /* \"createChannel() with existing ID\" */);\n this.notBoundedChannelContextSet.add(id);\n const context = new LocalChannelContext(\n id,\n this.sharedObjectRegistry,\n type,\n this,\n this.dataStoreContext,\n this.dataStoreContext.storage,\n this.logger,\n (content, localOpMetadata) => this.submitChannelOp(id, content, localOpMetadata),\n (address: string) => this.setChannelDirty(address),\n (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) =>\n this.addedGCOutboundReference(srcHandle, outboundHandle));\n this.contexts.set(id, context);\n\n if (this.contextsDeferred.has(id)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.contextsDeferred.get(id)!.resolve(context);\n } else {\n const deferred = new Deferred<IChannelContext>();\n deferred.resolve(context);\n this.contextsDeferred.set(id, deferred);\n }\n\n assert(!!context.channel, 0x17a /* \"Channel should be loaded when created!!\" */);\n return context.channel;\n }\n\n /**\n * Binds a channel with the runtime. If the runtime is attached we will attach the channel right away.\n * If the runtime is not attached we will defer the attach until the runtime attaches.\n * @param channel - channel to be registered.\n */\n public bindChannel(channel: IChannel): void {\n assert(this.notBoundedChannelContextSet.has(channel.id),\n 0x17b /* \"Channel to be binded should be in not bounded set\" */);\n this.notBoundedChannelContextSet.delete(channel.id);\n // If our data store is attached, then attach the channel.\n if (this.isAttached) {\n this.attachChannel(channel);\n return;\n }\n\n /**\n * If this channel is already waiting to be made visible, do nothing. This can happen during attachGraph() when\n * a channel's graph is attached. It calls bindToContext on the shared object which will end up back here.\n */\n if (this.pendingHandlesToMakeVisible.has(channel.handle)) {\n return;\n }\n\n this.bind(channel.handle);\n\n // If our data store is local then add the channel to the queue\n if (!this.localChannelContextQueue.has(channel.id)) {\n this.localChannelContextQueue.set(channel.id, this.contexts.get(channel.id) as LocalChannelContextBase);\n }\n }\n\n /**\n * This function is called when a data store becomes root. It does the following:\n * 1. Marks the data store locally visible in the container.\n * 2. Attaches the graph of all the handles bound to it.\n * 3. Calls into the data store context to mark it visible in the container too. If the container is globally\n * visible, it will mark us globally visible. Otherwise, it will mark us globally visible when it becomes\n * globally visible.\n */\n public makeVisibleAndAttachGraph() {\n if (this.visibilityState !== VisibilityState.NotVisible) {\n return;\n }\n this.visibilityState = VisibilityState.LocallyVisible;\n\n this.pendingHandlesToMakeVisible.forEach((handle) => {\n handle.attachGraph();\n });\n this.pendingHandlesToMakeVisible.clear();\n this.bindToContext();\n }\n\n /**\n * This function is called when a handle to this data store is added to a visible DDS.\n */\n public attachGraph() {\n this.makeVisibleAndAttachGraph();\n }\n\n /**\n * Binds this runtime to the container\n * This includes the following:\n * 1. Sending an Attach op that includes all existing state\n * 2. Attaching the graph if the data store becomes attached.\n */\n public bindToContext() {\n if (this.bindState !== BindState.NotBound) {\n return;\n }\n this.bindState = BindState.Binding;\n this.dataStoreContext.bindToContext();\n this.bindState = BindState.Bound;\n }\n\n public bind(handle: IFluidHandle): void {\n // If visible, attach the incoming handle's graph. Else, this will be done when we become visible.\n if (this.visibilityState !== VisibilityState.NotVisible) {\n handle.attachGraph();\n return;\n }\n this.pendingHandlesToMakeVisible.add(handle);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n this.verifyNotClosed();\n\n for (const [, object] of this.contexts) {\n object.setConnectionState(connected, clientId);\n }\n\n raiseConnectedEvent(this.logger, this, connected, clientId);\n }\n\n public getQuorum(): IQuorumClients {\n return this.quorum;\n }\n\n public getAudience(): IAudience {\n return this.audience;\n }\n\n public async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n this.verifyNotClosed();\n\n return this.dataStoreContext.uploadBlob(blob);\n }\n\n public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed();\n\n try {\n // catches as data processing error whether or not they come from async pending queues\n switch (message.type) {\n case DataStoreMessageType.Attach: {\n const attachMessage = message.contents as IAttachMessage;\n const id = attachMessage.id;\n\n // If a non-local operation then go and create the object\n // Otherwise mark it as officially attached.\n if (local) {\n assert(this.pendingAttach.has(id), 0x17c /* \"Unexpected attach (local) channel OP\" */);\n this.pendingAttach.delete(id);\n } else {\n assert(!this.contexts.has(id),\n 0x17d, /* `Unexpected attach channel OP,\n is in pendingAttach set: ${this.pendingAttach.has(id)},\n is local channel contexts: ${this.contexts.get(id) instanceof LocalChannelContextBase}` */);\n\n const flatBlobs = new Map<string, ArrayBufferLike>();\n const snapshotTree = buildSnapshotTree(attachMessage.snapshot.entries, flatBlobs);\n\n const remoteChannelContext = new RemoteChannelContext(\n this,\n this.dataStoreContext,\n this.dataStoreContext.storage,\n (content, localContentMetadata) => this.submitChannelOp(id, content, localContentMetadata),\n (address: string) => this.setChannelDirty(address),\n (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) =>\n this.addedGCOutboundReference(srcHandle, outboundHandle),\n id,\n snapshotTree,\n this.sharedObjectRegistry,\n flatBlobs,\n this.dataStoreContext.getCreateChildSummarizerNodeFn(\n id,\n {\n type: CreateSummarizerNodeSource.FromAttach,\n sequenceNumber: message.sequenceNumber,\n snapshot: attachMessage.snapshot,\n },\n ),\n async () => this.getChannelBaseGCDetails(id),\n attachMessage.type);\n\n this.contexts.set(id, remoteChannelContext);\n if (this.contextsDeferred.has(id)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.contextsDeferred.get(id)!.resolve(remoteChannelContext);\n } else {\n const deferred = new Deferred<IChannelContext>();\n deferred.resolve(remoteChannelContext);\n this.contextsDeferred.set(id, deferred);\n }\n }\n break;\n }\n\n case DataStoreMessageType.ChannelOp:\n this.processChannelOp(message, local, localOpMetadata);\n break;\n default:\n }\n\n this.emit(\"op\", message);\n } catch (error) {\n throw DataProcessingError.wrapIfUnrecognized(error, \"fluidDataStoreRuntimeFailedToProcessMessage\", message);\n }\n }\n\n public processSignal(message: IInboundSignalMessage, local: boolean) {\n this.emit(\"signal\", message, local);\n }\n\n private isChannelAttached(id: string): boolean {\n return (\n // Added in createChannel\n // Removed when bindChannel is called\n !this.notBoundedChannelContextSet.has(id)\n // Added in bindChannel only if this is not attached yet\n // Removed when this is attached by calling attachGraph\n && !this.localChannelContextQueue.has(id)\n // Added in attachChannel called by bindChannel\n // Removed when attach op is broadcast\n && !this.pendingAttach.has(id)\n );\n }\n\n /**\n * Returns the outbound routes of this channel. Currently, all contexts in this channel are considered\n * referenced and are hence outbound. This will change when we have root and non-root channel contexts.\n * The only root contexts will be considered as referenced.\n */\n private getOutboundRoutes(): string[] {\n const outboundRoutes: string[] = [];\n for (const [contextId] of this.contexts) {\n outboundRoutes.push(`${this.absolutePath}/${contextId}`);\n }\n return outboundRoutes;\n }\n\n /**\n * Updates the GC nodes of this channel. It does the following:\n * - Adds a back route to self to all its child GC nodes.\n * - Adds a node for this channel.\n * @param builder - The builder that contains the GC nodes for this channel's children.\n */\n private updateGCNodes(builder: GCDataBuilder) {\n // Add a back route to self in each child's GC nodes. If any child is referenced, then its parent should\n // be considered referenced as well.\n builder.addRouteToAllNodes(this.absolutePath);\n\n // Get the outbound routes and add a GC node for this channel.\n builder.addNode(\"/\", this.getOutboundRoutes());\n }\n\n /**\n * Generates data used for garbage collection. This includes a list of GC nodes that represent this channel\n * including any of its child channel contexts. Each node has a set of outbound routes to other GC nodes in the\n * document. It does the following:\n * 1. Calls into each child context to get its GC data.\n * 2. Prefixes the child context's id to the GC nodes in the child's GC data. This makes sure that the node can be\n * identified as belonging to the child.\n * 3. Adds a GC node for this channel to the nodes received from the children. All these nodes together represent\n * the GC data of this channel.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n const builder = new GCDataBuilder();\n // Iterate over each channel context and get their GC data.\n await Promise.all(Array.from(this.contexts)\n .filter(([contextId, _]) => {\n // Get GC data only for attached contexts. Detached contexts are not connected in the GC reference\n // graph so any references they might have won't be connected as well.\n return this.isChannelAttached(contextId);\n }).map(async ([contextId, context]) => {\n const contextGCData = await context.getGCData(fullGC);\n // Prefix the child's id to the ids of its GC nodes so they can be identified as belonging to the child.\n // This also gradually builds the id of each node to be a path from the root.\n builder.prefixAndAddNodes(contextId, contextGCData.gcNodes);\n }));\n\n this.updateGCNodes(builder);\n return builder.getGCData();\n }\n\n /**\n * After GC has run, called to notify this channel of routes that are used in it. It calls the child contexts to\n * update their used routes.\n * @param usedRoutes - The routes that are used in all contexts in this channel.\n * @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced\n * as part of this GC run, this should be used to update the time when it happens.\n */\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Get a map of channel ids to routes used in it.\n const usedContextRoutes = unpackChildNodesUsedRoutes(usedRoutes);\n\n // Verify that the used routes are correct.\n for (const [id] of usedContextRoutes) {\n assert(this.contexts.has(id), 0x17e /* \"Used route does not belong to any known context\" */);\n }\n\n // Update the used routes in each context. Used routes is empty for unused context.\n for (const [contextId, context] of this.contexts) {\n context.updateUsedRoutes(usedContextRoutes.get(contextId) ?? [], gcTimestamp);\n }\n }\n\n /**\n * Called when a new outbound reference is added to another node. This is used by garbage collection to identify\n * all references added in the system.\n * @param srcHandle - The handle of the node that added the reference.\n * @param outboundHandle - The handle of the outbound node that is referenced.\n */\n private addedGCOutboundReference(srcHandle: IFluidHandle, outboundHandle: IFluidHandle) {\n this.dataStoreContext.addedGCOutboundReference?.(srcHandle, outboundHandle);\n }\n\n /**\n * Returns the base GC details for the channel with the given id. This is used to initialize its GC state.\n * @param channelId - The id of the channel context that is asked for the initial GC details.\n * @returns the requested channel's base GC details.\n */\n private async getChannelBaseGCDetails(channelId: string): Promise<IGarbageCollectionDetailsBase> {\n let channelBaseGCDetails = (await this.channelsBaseGCDetails).get(channelId);\n if (channelBaseGCDetails === undefined) {\n channelBaseGCDetails = {};\n } else if (channelBaseGCDetails.gcData?.gcNodes !== undefined) {\n // Note: if the child channel has an explicit handle route to its parent, it will be removed here and\n // expected to be added back by the parent when getGCData is called.\n removeRouteFromAllNodes(channelBaseGCDetails.gcData.gcNodes, this.absolutePath);\n }\n\n // Currently, channel context's are always considered used. So, it there are no used routes for it, we still\n // need to mark it as used. Add self-route (empty string) to the channel context's used routes.\n if (channelBaseGCDetails.usedRoutes === undefined || channelBaseGCDetails.usedRoutes.length === 0) {\n channelBaseGCDetails.usedRoutes = [\"\"];\n }\n return channelBaseGCDetails;\n }\n\n /**\n * Returns a summary at the current sequence number.\n * @param fullTree - true to bypass optimizations and force a full summary tree\n * @param trackState - This tells whether we should track state from this summary.\n * @param telemetryContext - summary data passed through the layers for telemetry purposes\n */\n public async summarize(\n fullTree: boolean = false,\n trackState: boolean = true,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats> {\n const summaryBuilder = new SummaryTreeBuilder();\n\n // Iterate over each data store and ask it to summarize\n await Promise.all(Array.from(this.contexts)\n .filter(([contextId, _]) => {\n const isAttached = this.isChannelAttached(contextId);\n // We are not expecting local dds! Summary may not capture local state.\n assert(isAttached, 0x17f /* \"Not expecting detached channels during summarize\" */);\n // If the object is registered - and we have received the sequenced op creating the object\n // (i.e. it has a base mapping) - then we go ahead and summarize\n return isAttached;\n }).map(async ([contextId, context]) => {\n const contextSummary = await context.summarize(fullTree, trackState, telemetryContext);\n summaryBuilder.addWithStats(contextId, contextSummary);\n }));\n\n return summaryBuilder.getSummaryTree();\n }\n\n public getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n /**\n * back-compat 0.59.1000 - getAttachSummary() is called when making a data store globally visible (previously\n * attaching state). Ideally, attachGraph() should have already be called making it locally visible. However,\n * before visibility state was added, this may not have been the case and getAttachSummary() could be called:\n * 1) Before attaching the data store - When a detached container is attached.\n * 2) After attaching the data store - When a data store is created and bound in an attached container.\n *\n * The basic idea is that all local object should become locally visible before they are globally visible.\n */\n this.attachGraph();\n\n /**\n * This assert cannot be added now due to back-compat. To be uncommented when the following issue is fixed -\n * https://github.com/microsoft/FluidFramework/issues/9688.\n *\n * assert(this.visibilityState === VisibilityState.LocallyVisible,\n * \"The data store should be locally visible when generating attach summary\",\n * );\n */\n\n const summaryBuilder = new SummaryTreeBuilder();\n\n // Craft the .attributes file for each shared object\n for (const [contextId, context] of this.contexts) {\n if (!(context instanceof LocalChannelContextBase)) {\n throw new LoggingError(\"Should only be called with local channel handles\");\n }\n\n if (!this.notBoundedChannelContextSet.has(contextId)) {\n let summaryTree: ISummaryTreeWithStats;\n if (context.isLoaded) {\n const contextSummary = context.getAttachSummary(telemetryContext);\n assert(\n contextSummary.summary.type === SummaryType.Tree,\n 0x180 /* \"getAttachSummary should always return a tree\" */);\n summaryTree = { stats: contextSummary.stats, summary: contextSummary.summary };\n } else {\n // If this channel is not yet loaded, then there should be no changes in the snapshot from which\n // it was created as it is detached container. So just use the previous snapshot.\n assert(!!this.dataStoreContext.baseSnapshot,\n 0x181 /* \"BaseSnapshot should be there as detached container loaded from snapshot\" */);\n summaryTree = convertSnapshotTreeToSummaryTree(this.dataStoreContext.baseSnapshot.trees[contextId]);\n }\n summaryBuilder.addWithStats(contextId, summaryTree);\n }\n }\n\n return summaryBuilder.getSummaryTree();\n }\n\n public submitMessage(type: DataStoreMessageType, content: any, localOpMetadata: unknown) {\n this.submit(type, content, localOpMetadata);\n }\n\n public submitSignal(type: string, content: any) {\n this.verifyNotClosed();\n return this.dataStoreContext.submitSignal(type, content);\n }\n\n /**\n * Will return when the data store is attached.\n */\n public async waitAttached(): Promise<void> {\n return this.deferredAttached.promise;\n }\n\n /**\n * Attach channel should only be called after the data store has been attached\n */\n private attachChannel(channel: IChannel): void {\n this.verifyNotClosed();\n // If this handle is already attached no need to attach again.\n if (channel.handle.isAttached) {\n return;\n }\n\n channel.handle.attachGraph();\n\n assert(this.isAttached, 0x182 /* \"Data store should be attached to attach the channel.\" */);\n assert(this.visibilityState === VisibilityState.GloballyVisible,\n 0x2d0 /* \"Data store should be globally visible to attach channels.\" */);\n\n const summarizeResult = summarizeChannel(channel, true /* fullTree */, false /* trackState */);\n // Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.\n const snapshot = convertSummaryTreeToITree(summarizeResult.summary);\n\n const message: IAttachMessage = {\n id: channel.id,\n snapshot,\n type: channel.attributes.type,\n };\n this.pendingAttach.set(channel.id, message);\n this.submit(DataStoreMessageType.Attach, message);\n\n const context = this.contexts.get(channel.id) as LocalChannelContextBase;\n context.makeVisible();\n }\n\n private submitChannelOp(address: string, contents: any, localOpMetadata: unknown) {\n const envelope: IEnvelope = { address, contents };\n this.submit(DataStoreMessageType.ChannelOp, envelope, localOpMetadata);\n }\n\n private submit(\n type: DataStoreMessageType,\n content: any,\n localOpMetadata: unknown = undefined): void {\n this.verifyNotClosed();\n this.dataStoreContext.submitMessage(type, content, localOpMetadata);\n }\n\n /**\n * For messages of type MessageType.Operation, finds the right channel and asks it to resubmit the message.\n * For all other messages, just submit it again.\n * This typically happens when we reconnect and there are unacked messages.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n public reSubmit(type: DataStoreMessageType, content: any, localOpMetadata: unknown) {\n this.verifyNotClosed();\n\n switch (type) {\n case DataStoreMessageType.ChannelOp:\n {\n // For Operations, find the right channel and trigger resubmission on it.\n const envelope = content as IEnvelope;\n const channelContext = this.contexts.get(envelope.address);\n assert(!!channelContext, 0x183 /* \"There should be a channel context for the op\" */);\n channelContext.reSubmit(envelope.contents, localOpMetadata);\n break;\n }\n case DataStoreMessageType.Attach:\n // For Attach messages, just submit them again.\n this.submit(type, content, localOpMetadata);\n break;\n default:\n unreachableCase(type);\n }\n }\n\n /**\n * Revert a local op.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n public rollback?(type: DataStoreMessageType, content: any, localOpMetadata: unknown) {\n this.verifyNotClosed();\n\n switch (type) {\n case DataStoreMessageType.ChannelOp:\n {\n // For Operations, find the right channel and trigger resubmission on it.\n const envelope = content as IEnvelope;\n const channelContext = this.contexts.get(envelope.address);\n assert(!!channelContext, 0x2ed /* \"There should be a channel context for the op\" */);\n channelContext.rollback(envelope.contents, localOpMetadata);\n break;\n }\n default:\n throw new LoggingError(`Can't rollback ${type} message`);\n }\n }\n\n public async applyStashedOp(content: any): Promise<unknown> {\n const envelope = content as IEnvelope;\n const channelContext = this.contexts.get(envelope.address);\n assert(!!channelContext, 0x184 /* \"There should be a channel context for the op\" */);\n await channelContext.getChannel();\n return channelContext.applyStashedOp(envelope.contents);\n }\n\n private setChannelDirty(address: string): void {\n this.verifyNotClosed();\n this.dataStoreContext.setChannelDirty(address);\n }\n\n private processChannelOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {\n this.verifyNotClosed();\n\n const envelope = message.contents as IEnvelope;\n\n const transformed: ISequencedDocumentMessage = {\n ...message,\n contents: envelope.contents,\n };\n\n const channelContext = this.contexts.get(envelope.address);\n assert(!!channelContext, 0x185 /* \"Channel not found\" */);\n channelContext.processOp(transformed, local, localOpMetadata);\n\n return channelContext;\n }\n\n private attachListener() {\n this.setMaxListeners(Number.MAX_SAFE_INTEGER);\n this.dataStoreContext.once(\"attaching\", () => {\n /**\n * back-compat 0.59.1000 - Ideally, attachGraph() should have already been called making the data store\n * locally visible. However, before visibility state was added, this may not have been the case and data\n * store can move to \"attaching\" state in 2 scenarios:\n * 1) Before attachGraph() is called - When a data store is created and bound in an attached container.\n * 2) After attachGraph() is called - When a detached container is attached.\n *\n * The basic idea is that all local object should become locally visible before they are globally visible.\n */\n this.attachGraph();\n\n this._attachState = AttachState.Attaching;\n\n assert(this.visibilityState === VisibilityState.LocallyVisible,\n 0x2d1 /* \"Data store should be locally visible before it can become globally visible.\" */);\n\n // Mark the data store globally visible and make its child channels visible as well.\n this.visibilityState = VisibilityState.GloballyVisible;\n this.localChannelContextQueue.forEach((channel) => {\n channel.makeVisible();\n });\n this.localChannelContextQueue.clear();\n\n // This promise resolution will be moved to attached event once we fix the scheduler.\n this.deferredAttached.resolve();\n this.emit(\"attaching\");\n });\n this.dataStoreContext.once(\"attached\", () => {\n assert(this.visibilityState === VisibilityState.GloballyVisible,\n 0x2d2 /* \"Data store should be globally visible when its attached.\" */);\n this._attachState = AttachState.Attached;\n this.emit(\"attached\");\n });\n }\n\n private verifyNotClosed() {\n if (this._disposed) {\n throw new LoggingError(\"Runtime is closed\");\n }\n }\n}\n\n/**\n * Mixin class that adds request handler to FluidDataStoreRuntime\n * Request handler is only called when data store can't resolve request, i.e. for custom requests.\n * @param Base - base class, inherits from FluidDataStoreRuntime\n * @param requestHandler - request handler to mix in\n */\nexport const mixinRequestHandler = (\n requestHandler: (request: IRequest, runtime: FluidDataStoreRuntime) => Promise<IResponse>,\n Base: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n) => class RuntimeWithRequestHandler extends Base {\n public async request(request: IRequest) {\n const response = await super.request(request);\n if (response.status === 404) {\n return requestHandler(request, this);\n }\n return response;\n }\n } as typeof FluidDataStoreRuntime;\n\n/**\n * Mixin class that adds await for DataObject to finish initialization before we proceed to summary.\n * @param handler - handler that returns info about blob to be added to summary.\n * Or undefined not to add anything to summary.\n * @param Base - base class, inherits from FluidDataStoreRuntime\n */\nexport const mixinSummaryHandler = (\n handler: (runtime: FluidDataStoreRuntime) => Promise<{ path: string[]; content: string; } | undefined >,\n Base: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n) => class RuntimeWithSummarizerHandler extends Base {\n private addBlob(summary: ISummaryTreeWithStats, path: string[], content: string) {\n const firstName = path.shift();\n if (firstName === undefined) {\n throw new LoggingError(\"Path can't be empty\");\n }\n\n let blob: ISummaryTree | ISummaryBlob = {\n type: SummaryType.Blob,\n content,\n };\n summary.stats.blobNodeCount++;\n summary.stats.totalBlobSize += content.length;\n\n for (const name of path.reverse()) {\n blob = {\n type: SummaryType.Tree,\n tree: { [name]: blob },\n };\n summary.stats.treeNodeCount++;\n }\n summary.summary.tree[firstName] = blob;\n }\n\n async summarize(...args: any[]) {\n const summary = await super.summarize(...args);\n const content = await handler(this);\n if (content !== undefined) {\n this.addBlob(summary, content.path, content.content);\n }\n return summary;\n }\n } as typeof FluidDataStoreRuntime;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fluidHandle.js","sourceRoot":"","sources":["../src/fluidHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,iEAA0E;AAE1E,MAAa,iBAAiB;IA8B1B;;;;;OAKG;IACH,YACuB,KAAQ,EACX,IAAY,EACZ,YAAiC;QAF9B,UAAK,GAAL,KAAK,CAAG;QACX,SAAI,GAAJ,IAAI,CAAQ;QACZ,iBAAY,GAAZ,YAAY,CAAqB;QAtCpC,gCAA2B,GAAsB,IAAI,GAAG,EAAE,CAAC;QA0B5E,kEAAkE;QAC1D,mBAAc,GAAY,KAAK,CAAC;QAapC,IAAI,CAAC,YAAY,GAAG,IAAA,yCAAyB,EAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3E,CAAC;IAtCD,IAAW,YAAY,KAAmB,OAAO,IAAI,CAAC,CAAC,CAAC;IAExD,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAY,OAAO;QACf;;;;;;;;;WASG;QACH,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,cAAc,CAAC;IAClD,CAAC;IAmBM,KAAK,CAAC,GAAG;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAEM,WAAW;QACd,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,OAAO;SACV;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAChD,MAAM,CAAC,WAAW,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC5B,8EAA8E;QAC9E,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;SACV;QACD,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;CACJ;AArED,8CAqEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidHandle,\n IFluidHandleContext,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { generateHandleContextPath } from \"@fluidframework/runtime-utils\";\n\nexport class FluidObjectHandle<T extends FluidObject = FluidObject> implements IFluidHandle {\n private readonly pendingHandlesToMakeVisible: Set<IFluidHandle> = new Set();\n public readonly absolutePath: string;\n\n public get IFluidHandle(): IFluidHandle { return this; }\n\n public get isAttached(): boolean {\n return this.routeContext.isAttached;\n }\n\n /**\n * Tells whether the object of this handle is visible in the container locally or globally.\n */\n private get visible(): boolean {\n /**\n * If the object of this handle is attached, it is visible in the container. Ideally, checking local visibility\n * should be enough for a handle. However, there are scenarios where the object becomes locally visible but the\n * handle does not know this - This will happen is attachGraph is never called on the handle. Couple of examples\n * where this can happen:\n * 1. Handles to DDS other than the default handle won't know if the DDS becomes visible after the handle was\n * created.\n * 2. Handles to root data stores will never know that it was visible because the handle will not be stores in\n * another DDS and so, attachGraph will never be called on it.\n */\n return this.isAttached || this.locallyVisible;\n }\n\n // Tracks whether this handle is locally visible in the container.\n private locallyVisible: boolean = false;\n\n /**\n * Creates a new FluidObjectHandle.\n * @param value - The FluidObject object this handle is for.\n * @param path - The path to this handle relative to the routeContext.\n * @param routeContext - The parent IFluidHandleContext that has a route to this handle.\n */\n constructor(\n protected readonly value: T,\n public readonly path: string,\n public readonly routeContext: IFluidHandleContext,\n ) {\n this.absolutePath = generateHandleContextPath(path, this.routeContext);\n }\n\n public async get(): Promise<any> {\n return this.value;\n }\n\n public attachGraph(): void {\n if (this.visible) {\n return;\n }\n\n this.locallyVisible = true;\n this.pendingHandlesToMakeVisible.forEach((handle) => {\n handle.attachGraph();\n });\n this.pendingHandlesToMakeVisible.clear();\n this.routeContext.attachGraph();\n }\n\n public bind(handle: IFluidHandle) {\n // If this handle is visible, attach the graph of the incoming handle as well.\n if (this.visible) {\n handle.attachGraph();\n return;\n }\n this.pendingHandlesToMakeVisible.add(handle);\n }\n}\n"]}
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./dataStoreRuntime"), exports);
18
- __exportStar(require("./fluidHandle"), exports);
19
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,gDAA8B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./dataStoreRuntime\";\nexport * from \"./fluidHandle\";\n"]}
@@ -1,202 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.LocalChannelContext = exports.RehydratedLocalChannelContext = exports.LocalChannelContextBase = void 0;
11
- // eslint-disable-next-line import/no-internal-modules
12
- const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
13
- const driver_utils_1 = require("@fluidframework/driver-utils");
14
- const container_utils_1 = require("@fluidframework/container-utils");
15
- const common_utils_1 = require("@fluidframework/common-utils");
16
- const channelContext_1 = require("./channelContext");
17
- /**
18
- * Channel context for a locally created channel
19
- */
20
- class LocalChannelContextBase {
21
- constructor(id, registry, runtime, servicesGetter) {
22
- this.id = id;
23
- this.registry = registry;
24
- this.runtime = runtime;
25
- this.servicesGetter = servicesGetter;
26
- this.globallyVisible = false;
27
- this.pending = [];
28
- (0, common_utils_1.assert)(!this.id.includes("/"), 0x30f /* Channel context ID cannot contain slashes */);
29
- }
30
- async getChannel() {
31
- (0, common_utils_1.assert)(this.channel !== undefined, 0x207 /* "Channel should be defined" */);
32
- return this.channel;
33
- }
34
- get isLoaded() {
35
- return this.channel !== undefined;
36
- }
37
- setConnectionState(connected, clientId) {
38
- // Connection events are ignored if the data store is not yet globallyVisible or loaded
39
- if (this.globallyVisible && this.isLoaded) {
40
- this.servicesGetter().value.deltaConnection.setConnectionState(connected);
41
- }
42
- }
43
- processOp(message, local, localOpMetadata) {
44
- (0, common_utils_1.assert)(this.globallyVisible, 0x2d3 /* "Local channel must be globally visible when processing op" */);
45
- // A local channel may not be loaded in case where we rehydrate the container from a snapshot because of
46
- // delay loading. So after the container is attached and some other client joins which start generating
47
- // ops for this channel. So not loaded local channel can still receive ops and we store them to process later.
48
- if (this.isLoaded) {
49
- this.servicesGetter().value.deltaConnection.process(message, local, localOpMetadata);
50
- }
51
- else {
52
- (0, common_utils_1.assert)(local === false, 0x189 /* "Should always be remote because a local dds shouldn't generate ops before loading" */);
53
- this.pending.push(message);
54
- }
55
- }
56
- reSubmit(content, localOpMetadata) {
57
- (0, common_utils_1.assert)(this.isLoaded, 0x18a /* "Channel should be loaded to resubmit ops" */);
58
- (0, common_utils_1.assert)(this.globallyVisible, 0x2d4 /* "Local channel must be globally visible when resubmitting op" */);
59
- this.servicesGetter().value.deltaConnection.reSubmit(content, localOpMetadata);
60
- }
61
- rollback(content, localOpMetadata) {
62
- (0, common_utils_1.assert)(this.isLoaded, 0x2ee /* "Channel should be loaded to rollback ops" */);
63
- (0, common_utils_1.assert)(this.globallyVisible, 0x2ef /* "Local channel must be globally visible when rolling back op" */);
64
- this.servicesGetter().value.deltaConnection.rollback(content, localOpMetadata);
65
- }
66
- applyStashedOp() {
67
- throw new Error("no stashed ops on local channel");
68
- }
69
- /**
70
- * Returns a summary at the current sequence number.
71
- * @param fullTree - true to bypass optimizations and force a full summary tree
72
- * @param trackState - This tells whether we should track state from this summary.
73
- * @param telemetryContext - summary data passed through the layers for telemetry purposes
74
- */
75
- async summarize(fullTree = false, trackState = false, telemetryContext) {
76
- (0, common_utils_1.assert)(this.isLoaded && this.channel !== undefined, 0x18c /* "Channel should be loaded to summarize" */);
77
- return (0, channelContext_1.summarizeChannelAsync)(this.channel, fullTree, trackState, telemetryContext);
78
- }
79
- getAttachSummary(telemetryContext) {
80
- (0, common_utils_1.assert)(this.isLoaded && this.channel !== undefined, 0x18d /* "Channel should be loaded to take snapshot" */);
81
- return (0, channelContext_1.summarizeChannel)(this.channel, true /* fullTree */, false /* trackState */, telemetryContext);
82
- }
83
- makeVisible() {
84
- if (this.globallyVisible) {
85
- throw new Error("Channel is already globally visible");
86
- }
87
- if (this.isLoaded) {
88
- (0, common_utils_1.assert)(!!this.channel, 0x192 /* "Channel should be there if loaded!!" */);
89
- this.channel.connect(this.servicesGetter().value);
90
- }
91
- this.globallyVisible = true;
92
- }
93
- /**
94
- * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.
95
- * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after
96
- * the context has loaded.
97
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
98
- */
99
- async getGCData(fullGC = false) {
100
- (0, common_utils_1.assert)(this.isLoaded && this.channel !== undefined, 0x193 /* "Channel should be loaded to run GC" */);
101
- return this.channel.getGCData(fullGC);
102
- }
103
- updateUsedRoutes(usedRoutes, gcTimestamp) {
104
- /**
105
- * Currently, DDSes are always considered referenced and are not garbage collected.
106
- * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed
107
- * value. See - https://github.com/microsoft/FluidFramework/issues/4611
108
- */
109
- }
110
- }
111
- exports.LocalChannelContextBase = LocalChannelContextBase;
112
- class RehydratedLocalChannelContext extends LocalChannelContextBase {
113
- constructor(id, registry, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn, snapshotTree) {
114
- super(id, registry, runtime, () => this.services);
115
- this.snapshotTree = snapshotTree;
116
- const blobMap = new Map();
117
- const clonedSnapshotTree = (0, cloneDeep_1.default)(this.snapshotTree);
118
- // 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.
119
- // This is for older snapshot which is generated by loader <=0.47 version which still contains
120
- // the contents within blobs. After a couple of revisions we can remove it.
121
- if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {
122
- this.sanitizeSnapshot(clonedSnapshotTree);
123
- }
124
- this.services = new common_utils_1.Lazy(() => {
125
- return (0, channelContext_1.createServiceEndpoints)(this.id, dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger, clonedSnapshotTree, blobMap);
126
- });
127
- this.dirtyFn = () => { dirtyFn(id); };
128
- }
129
- async getChannel() {
130
- if (this.channel === undefined) {
131
- this.channel = await this.loadChannel()
132
- .catch((err) => {
133
- throw container_utils_1.DataProcessingError.wrapIfUnrecognized(err, "rehydratedLocalChannelContextFailedToLoadChannel", undefined);
134
- });
135
- }
136
- return this.channel;
137
- }
138
- async loadChannel() {
139
- (0, common_utils_1.assert)(!this.isLoaded, 0x18e /* "Channel must not already be loaded when loading" */);
140
- (0, common_utils_1.assert)(await this.services.value.objectStorage.contains(".attributes"), 0x190 /* ".attributes blob should be present" */);
141
- const attributes = await (0, driver_utils_1.readAndParse)(this.services.value.objectStorage, ".attributes");
142
- (0, common_utils_1.assert)(this.factory === undefined, 0x208 /* "Factory should be undefined before loading" */);
143
- this.factory = this.registry.get(attributes.type);
144
- if (this.factory === undefined) {
145
- throw new Error(`Channel Factory ${attributes.type} not registered`);
146
- }
147
- // Services will be assigned during this load.
148
- const channel = await this.factory.load(this.runtime, this.id, this.services.value, attributes);
149
- // Commit changes.
150
- this.channel = channel;
151
- // Send all pending messages to the channel
152
- for (const message of this.pending) {
153
- this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);
154
- }
155
- return this.channel;
156
- }
157
- isSnapshotInOldFormatAndCollectBlobs(snapshotTree, blobMap) {
158
- let sanitize = false;
159
- const blobsContents = snapshotTree.blobsContents;
160
- Object.entries(blobsContents).forEach(([key, value]) => {
161
- blobMap.set(key, value);
162
- if (snapshotTree.blobs[key] !== undefined) {
163
- sanitize = true;
164
- }
165
- });
166
- for (const value of Object.values(snapshotTree.trees)) {
167
- sanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);
168
- }
169
- return sanitize;
170
- }
171
- sanitizeSnapshot(snapshotTree) {
172
- const blobMapInitial = new Map(Object.entries(snapshotTree.blobs));
173
- for (const [blobName, blobId] of blobMapInitial.entries()) {
174
- const blobValue = blobMapInitial.get(blobId);
175
- if (blobValue === undefined) {
176
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
177
- delete snapshotTree.blobs[blobName];
178
- }
179
- }
180
- for (const value of Object.values(snapshotTree.trees)) {
181
- this.sanitizeSnapshot(value);
182
- }
183
- }
184
- }
185
- exports.RehydratedLocalChannelContext = RehydratedLocalChannelContext;
186
- class LocalChannelContext extends LocalChannelContextBase {
187
- constructor(id, registry, type, runtime, dataStoreContext, storageService, logger, submitFn, dirtyFn, addedGCOutboundReferenceFn) {
188
- super(id, registry, runtime, () => this.services);
189
- (0, common_utils_1.assert)(type !== undefined, 0x209 /* "Factory Type should be defined" */);
190
- this.factory = registry.get(type);
191
- if (this.factory === undefined) {
192
- throw new Error(`Channel Factory ${type} not registered`);
193
- }
194
- this.channel = this.factory.create(runtime, id);
195
- this.services = new common_utils_1.Lazy(() => {
196
- return (0, channelContext_1.createServiceEndpoints)(this.id, dataStoreContext.connected, submitFn, this.dirtyFn, addedGCOutboundReferenceFn, storageService, logger);
197
- });
198
- this.dirtyFn = () => { dirtyFn(id); };
199
- }
200
- }
201
- exports.LocalChannelContext = LocalChannelContext;
202
- //# sourceMappingURL=localChannelContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localChannelContext.js","sourceRoot":"","sources":["../src/localChannelContext.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,sDAAsD;AACtD,iEAAyC;AAgBzC,+DAA4D;AAC5D,qEAAsE;AACtE,+DAA4D;AAE5D,qDAK0B;AAK1B;;GAEG;AACH,MAAsB,uBAAuB;IAKzC,YACuB,EAAU,EACV,QAA+B,EAC/B,OAA+B,EACjC,cAGX;QANa,OAAE,GAAF,EAAE,CAAQ;QACV,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,YAAO,GAAP,OAAO,CAAwB;QACjC,mBAAc,GAAd,cAAc,CAGzB;QAVF,oBAAe,GAAG,KAAK,CAAC;QACb,YAAO,GAAgC,EAAE,CAAC;QAWzD,IAAA,qBAAM,EAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC1F,CAAC;IAEM,KAAK,CAAC,UAAU;QACnB,IAAA,qBAAM,EAAC,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC;IACtC,CAAC;IAEM,kBAAkB,CAAC,SAAkB,EAAE,QAAiB;QAC3D,uFAAuF;QACvF,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,EAAE;YACvC,IAAI,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;SAC7E;IACL,CAAC;IAEM,SAAS,CAAC,OAAkC,EAAE,KAAc,EAAE,eAAwB;QACzF,IAA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ACnD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;SAChC;IACL,CAAC;CACJ;AAtHD,sEAsHC;AAED,MAAa,mBAAoB,SAAQ,uBAAuB;IAM5D,YACI,EAAU,EACV,QAA+B,EAC/B,IAAY,EACZ,OAA+B,EAC/B,gBAAwC,EACxC,cAAuC,EACvC,MAAwB,EACxB,QAA0D,EAC1D,OAAkC,EAClC,0BAA2F;QAE3F,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAA,qBAAM,EAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QACzE,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,iBAAiB,CAAC,CAAC;SAC7D;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAI,CAAC,GAAG,EAAE;YAC1B,OAAO,IAAA,uCAAsB,EACzB,IAAI,CAAC,EAAE,EACP,gBAAgB,CAAC,SAAS,EAC1B,QAAQ,EACR,IAAI,CAAC,OAAO,EACZ,0BAA0B,EAC1B,cAAc,EACd,MAAM,CACT,CAAC;QACN,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;CACJ;AAtCD,kDAsCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-internal-modules\nimport cloneDeep from \"lodash/cloneDeep\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n IChannel,\n IFluidDataStoreRuntime,\n IChannelFactory,\n IChannelAttributes,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n IFluidDataStoreContext,\n IGarbageCollectionData,\n ISummarizeResult,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport { assert, Lazy } from \"@fluidframework/common-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n createServiceEndpoints,\n IChannelContext,\n summarizeChannel,\n summarizeChannelAsync,\n} from \"./channelContext\";\nimport { ChannelDeltaConnection } from \"./channelDeltaConnection\";\nimport { ISharedObjectRegistry } from \"./dataStoreRuntime\";\nimport { ChannelStorageService } from \"./channelStorageService\";\n\n/**\n * Channel context for a locally created channel\n */\nexport abstract class LocalChannelContextBase implements IChannelContext {\n public channel: IChannel | undefined;\n private globallyVisible = false;\n protected readonly pending: ISequencedDocumentMessage[] = [];\n protected factory: IChannelFactory | undefined;\n constructor(\n protected readonly id: string,\n protected readonly registry: ISharedObjectRegistry,\n protected readonly runtime: IFluidDataStoreRuntime,\n private readonly servicesGetter: () => Lazy<{\n readonly deltaConnection: ChannelDeltaConnection;\n readonly objectStorage: ChannelStorageService;\n }>,\n ) {\n assert(!this.id.includes(\"/\"), 0x30f /* Channel context ID cannot contain slashes */);\n }\n\n public async getChannel(): Promise<IChannel> {\n assert(this.channel !== undefined, 0x207 /* \"Channel should be defined\" */);\n return this.channel;\n }\n\n public get isLoaded(): boolean {\n return this.channel !== undefined;\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n // Connection events are ignored if the data store is not yet globallyVisible or loaded\n if (this.globallyVisible && this.isLoaded) {\n this.servicesGetter().value.deltaConnection.setConnectionState(connected);\n }\n }\n\n public processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void {\n assert(this.globallyVisible, 0x2d3 /* \"Local channel must be globally visible when processing op\" */);\n\n // A local channel may not be loaded in case where we rehydrate the container from a snapshot because of\n // delay loading. So after the container is attached and some other client joins which start generating\n // ops for this channel. So not loaded local channel can still receive ops and we store them to process later.\n if (this.isLoaded) {\n this.servicesGetter().value.deltaConnection.process(message, local, localOpMetadata);\n } else {\n assert(local === false,\n 0x189 /* \"Should always be remote because a local dds shouldn't generate ops before loading\" */);\n this.pending.push(message);\n }\n }\n\n public reSubmit(content: any, localOpMetadata: unknown) {\n assert(this.isLoaded, 0x18a /* \"Channel should be loaded to resubmit ops\" */);\n assert(this.globallyVisible, 0x2d4 /* \"Local channel must be globally visible when resubmitting op\" */);\n this.servicesGetter().value.deltaConnection.reSubmit(content, localOpMetadata);\n }\n public rollback(content: any, localOpMetadata: unknown) {\n assert(this.isLoaded, 0x2ee /* \"Channel should be loaded to rollback ops\" */);\n assert(this.globallyVisible, 0x2ef /* \"Local channel must be globally visible when rolling back op\" */);\n this.servicesGetter().value.deltaConnection.rollback(content, localOpMetadata);\n }\n\n public applyStashedOp() {\n throw new Error(\"no stashed ops on local channel\");\n }\n\n /**\n * Returns a summary at the current sequence number.\n * @param fullTree - true to bypass optimizations and force a full summary tree\n * @param trackState - This tells whether we should track state from this summary.\n * @param telemetryContext - summary data passed through the layers for telemetry purposes\n */\n public async summarize(\n fullTree: boolean = false,\n trackState: boolean = false,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummarizeResult> {\n assert(this.isLoaded && this.channel !== undefined, 0x18c /* \"Channel should be loaded to summarize\" */);\n return summarizeChannelAsync(this.channel, fullTree, trackState, telemetryContext);\n }\n\n public getAttachSummary(telemetryContext?: ITelemetryContext): ISummarizeResult {\n assert(this.isLoaded && this.channel !== undefined, 0x18d /* \"Channel should be loaded to take snapshot\" */);\n return summarizeChannel(this.channel, true /* fullTree */, false /* trackState */, telemetryContext);\n }\n\n public makeVisible(): void {\n if (this.globallyVisible) {\n throw new Error(\"Channel is already globally visible\");\n }\n\n if (this.isLoaded) {\n assert(!!this.channel, 0x192 /* \"Channel should be there if loaded!!\" */);\n this.channel.connect(this.servicesGetter().value);\n }\n this.globallyVisible = true;\n }\n\n /**\n * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context.\n * Each node has a set of outbound routes to other GC nodes in the document. This should be called only after\n * the context has loaded.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(this.isLoaded && this.channel !== undefined, 0x193 /* \"Channel should be loaded to run GC\" */);\n return this.channel.getGCData(fullGC);\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n /**\n * Currently, DDSes are always considered referenced and are not garbage collected.\n * Once we have GC at DDS level, this channel context's used routes will be updated as per the passed\n * value. See - https://github.com/microsoft/FluidFramework/issues/4611\n */\n }\n}\n\nexport class RehydratedLocalChannelContext extends LocalChannelContextBase {\n private readonly services: Lazy<{\n readonly deltaConnection: ChannelDeltaConnection;\n readonly objectStorage: ChannelStorageService;\n }>;\n\n private readonly dirtyFn: () => void;\n\n constructor(\n id: string,\n registry: ISharedObjectRegistry,\n runtime: IFluidDataStoreRuntime,\n dataStoreContext: IFluidDataStoreContext,\n storageService: IDocumentStorageService,\n logger: ITelemetryLogger,\n submitFn: (content: any, localOpMetadata: unknown) => void,\n dirtyFn: (address: string) => void,\n addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n private readonly snapshotTree: ISnapshotTree,\n ) {\n super(id, registry, runtime, () => this.services);\n const blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>();\n const clonedSnapshotTree = cloneDeep(this.snapshotTree);\n // 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.\n // This is for older snapshot which is generated by loader <=0.47 version which still contains\n // the contents within blobs. After a couple of revisions we can remove it.\n if (this.isSnapshotInOldFormatAndCollectBlobs(clonedSnapshotTree, blobMap)) {\n this.sanitizeSnapshot(clonedSnapshotTree);\n }\n\n this.services = new Lazy(() => {\n return createServiceEndpoints(\n this.id,\n dataStoreContext.connected,\n submitFn,\n this.dirtyFn,\n addedGCOutboundReferenceFn,\n storageService,\n logger,\n clonedSnapshotTree,\n blobMap,\n );\n });\n this.dirtyFn = () => { dirtyFn(id); };\n }\n\n public async getChannel(): Promise<IChannel> {\n if (this.channel === undefined) {\n this.channel = await this.loadChannel()\n .catch((err) => {\n throw DataProcessingError.wrapIfUnrecognized(\n err, \"rehydratedLocalChannelContextFailedToLoadChannel\", undefined);\n });\n }\n return this.channel;\n }\n\n private async loadChannel(): Promise<IChannel> {\n assert(!this.isLoaded, 0x18e /* \"Channel must not already be loaded when loading\" */);\n assert(await this.services.value.objectStorage.contains(\".attributes\"),\n 0x190 /* \".attributes blob should be present\" */);\n const attributes = await readAndParse<IChannelAttributes>(\n this.services.value.objectStorage,\n \".attributes\");\n\n assert(this.factory === undefined, 0x208 /* \"Factory should be undefined before loading\" */);\n this.factory = this.registry.get(attributes.type);\n if (this.factory === undefined) {\n throw new Error(`Channel Factory ${attributes.type} not registered`);\n }\n // Services will be assigned during this load.\n const channel = await this.factory.load(\n this.runtime,\n this.id,\n this.services.value,\n attributes);\n\n // Commit changes.\n this.channel = channel;\n\n // Send all pending messages to the channel\n for (const message of this.pending) {\n this.services.value.deltaConnection.process(message, false, undefined /* localOpMetadata */);\n }\n return this.channel;\n }\n\n private isSnapshotInOldFormatAndCollectBlobs(\n snapshotTree: ISnapshotTree,\n blobMap: Map<string, ArrayBufferLike>,\n ): boolean {\n let sanitize = false;\n const blobsContents: { [path: string]: ArrayBufferLike; } = (snapshotTree as any).blobsContents;\n Object.entries(blobsContents).forEach(([key, value]) => {\n blobMap.set(key, value);\n if (snapshotTree.blobs[key] !== undefined) {\n sanitize = true;\n }\n });\n for (const value of Object.values(snapshotTree.trees)) {\n sanitize = sanitize || this.isSnapshotInOldFormatAndCollectBlobs(value, blobMap);\n }\n return sanitize;\n }\n\n private sanitizeSnapshot(snapshotTree: ISnapshotTree) {\n const blobMapInitial = new Map(Object.entries(snapshotTree.blobs));\n for (const [blobName, blobId] of blobMapInitial.entries()) {\n const blobValue = blobMapInitial.get(blobId);\n if (blobValue === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete snapshotTree.blobs[blobName];\n }\n }\n for (const value of Object.values(snapshotTree.trees)) {\n this.sanitizeSnapshot(value);\n }\n }\n}\n\nexport class LocalChannelContext extends LocalChannelContextBase {\n private readonly services: Lazy<{\n readonly deltaConnection: ChannelDeltaConnection;\n readonly objectStorage: ChannelStorageService;\n }>;\n private readonly dirtyFn: () => void;\n constructor(\n id: string,\n registry: ISharedObjectRegistry,\n type: string,\n runtime: IFluidDataStoreRuntime,\n dataStoreContext: IFluidDataStoreContext,\n storageService: IDocumentStorageService,\n logger: ITelemetryLogger,\n submitFn: (content: any, localOpMetadata: unknown) => void,\n dirtyFn: (address: string) => void,\n addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,\n ) {\n super(id, registry, runtime, () => this.services);\n assert(type !== undefined, 0x209 /* \"Factory Type should be defined\" */);\n this.factory = registry.get(type);\n if (this.factory === undefined) {\n throw new Error(`Channel Factory ${type} not registered`);\n }\n this.channel = this.factory.create(runtime, id);\n this.services = new Lazy(() => {\n return createServiceEndpoints(\n this.id,\n dataStoreContext.connected,\n submitFn,\n this.dirtyFn,\n addedGCOutboundReferenceFn,\n storageService,\n logger,\n );\n });\n this.dirtyFn = () => { dirtyFn(id); };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"localChannelStorageService.js","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA8D;AAC9D,+EAA+E;AAC/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B,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;qBACrF;oBACD,MAAM;gBAEV,QAAQ;aACX;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ;AA9CD,gEA8CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelStorageService } from \"@fluidframework/datastore-definitions\";\nimport { stringToBuffer } from \"@fluidframework/common-utils\";\nimport { IBlob, ITree, TreeEntry } from \"@fluidframework/protocol-definitions\";\nimport { listBlobsAtTreePath } from \"@fluidframework/runtime-utils\";\n\nexport class LocalChannelStorageService implements IChannelStorageService {\n constructor(private readonly tree: ITree) {\n }\n\n public async readBlob(path: string): Promise<ArrayBufferLike> {\n const blob = this.readBlobSync(path);\n if (blob === undefined) {\n throw new Error(\"Blob Not Found\");\n }\n return stringToBuffer(blob.contents, blob.encoding);\n }\n\n public async contains(path: string): Promise<boolean> {\n const blob = this.readBlobSync(path);\n return blob !== undefined ? blob.contents !== undefined : false;\n }\n\n public async list(path: string): Promise<string[]> {\n return listBlobsAtTreePath(this.tree, path);\n }\n\n private readBlobSync(path: string): IBlob | undefined {\n return this.readBlobSyncInternal(path, this.tree);\n }\n\n private readBlobSyncInternal(path: string, tree: ITree): IBlob | undefined {\n for (const entry of tree.entries) {\n switch (entry.type) {\n case TreeEntry.Blob:\n if (path === entry.path) {\n return entry.value;\n }\n break;\n\n case TreeEntry.Tree:\n if (path.startsWith(entry.path)) {\n return this.readBlobSyncInternal(path.substr(entry.path.length + 1), entry.value);\n }\n break;\n\n default:\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- *
5
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
- */
7
- export declare const pkgName = "@fluidframework/datastore";
8
- export declare const pkgVersion = "1.4.0-121020";
9
- //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,8BAA8B,CAAC;AACnD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- *
6
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.pkgVersion = exports.pkgName = void 0;
10
- exports.pkgName = "@fluidframework/datastore";
11
- exports.pkgVersion = "1.4.0-121020";
12
- //# sourceMappingURL=packageVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,2BAA2B,CAAC;AACtC,QAAA,UAAU,GAAG,cAAc,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/datastore\";\nexport const pkgVersion = \"1.4.0-121020\";\n"]}