@fluidframework/container-loader 2.0.0-internal.6.1.1 → 2.0.0-internal.6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +4 -3
  3. package/dist/audience.js +2 -2
  4. package/dist/audience.js.map +1 -1
  5. package/dist/catchUpMonitor.js +2 -2
  6. package/dist/catchUpMonitor.js.map +1 -1
  7. package/dist/connectionManager.d.ts +1 -1
  8. package/dist/connectionManager.d.ts.map +1 -1
  9. package/dist/connectionManager.js +38 -37
  10. package/dist/connectionManager.js.map +1 -1
  11. package/dist/connectionStateHandler.js +24 -24
  12. package/dist/connectionStateHandler.js.map +1 -1
  13. package/dist/container.d.ts +8 -1
  14. package/dist/container.d.ts.map +1 -1
  15. package/dist/container.js +117 -98
  16. package/dist/container.js.map +1 -1
  17. package/dist/containerStorageAdapter.d.ts.map +1 -1
  18. package/dist/containerStorageAdapter.js +10 -9
  19. package/dist/containerStorageAdapter.js.map +1 -1
  20. package/dist/contracts.d.ts +2 -2
  21. package/dist/contracts.d.ts.map +1 -1
  22. package/dist/contracts.js.map +1 -1
  23. package/dist/debugLogger.js +2 -2
  24. package/dist/debugLogger.js.map +1 -1
  25. package/dist/deltaManager.d.ts +3 -4
  26. package/dist/deltaManager.d.ts.map +1 -1
  27. package/dist/deltaManager.js +39 -38
  28. package/dist/deltaManager.js.map +1 -1
  29. package/dist/deltaQueue.d.ts +1 -1
  30. package/dist/deltaQueue.d.ts.map +1 -1
  31. package/dist/deltaQueue.js +9 -8
  32. package/dist/deltaQueue.js.map +1 -1
  33. package/dist/disposal.d.ts +2 -2
  34. package/dist/disposal.d.ts.map +1 -1
  35. package/dist/disposal.js +1 -1
  36. package/dist/disposal.js.map +1 -1
  37. package/dist/error.d.ts +23 -0
  38. package/dist/error.d.ts.map +1 -0
  39. package/dist/error.js +32 -0
  40. package/dist/error.js.map +1 -0
  41. package/dist/loader.d.ts +9 -2
  42. package/dist/loader.d.ts.map +1 -1
  43. package/dist/loader.js +12 -7
  44. package/dist/loader.js.map +1 -1
  45. package/dist/noopHeuristic.d.ts +2 -2
  46. package/dist/noopHeuristic.d.ts.map +1 -1
  47. package/dist/noopHeuristic.js +6 -5
  48. package/dist/noopHeuristic.js.map +1 -1
  49. package/dist/packageVersion.d.ts +1 -1
  50. package/dist/packageVersion.js +1 -1
  51. package/dist/packageVersion.js.map +1 -1
  52. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  53. package/dist/retriableDocumentStorageService.js +4 -4
  54. package/dist/retriableDocumentStorageService.js.map +1 -1
  55. package/dist/utils.d.ts.map +1 -1
  56. package/dist/utils.js +9 -8
  57. package/dist/utils.js.map +1 -1
  58. package/lib/audience.js +1 -1
  59. package/lib/audience.js.map +1 -1
  60. package/lib/catchUpMonitor.js +1 -1
  61. package/lib/catchUpMonitor.js.map +1 -1
  62. package/lib/connectionManager.d.ts +1 -1
  63. package/lib/connectionManager.d.ts.map +1 -1
  64. package/lib/connectionManager.js +10 -9
  65. package/lib/connectionManager.js.map +1 -1
  66. package/lib/connectionStateHandler.js +1 -1
  67. package/lib/connectionStateHandler.js.map +1 -1
  68. package/lib/container.d.ts +8 -1
  69. package/lib/container.d.ts.map +1 -1
  70. package/lib/container.js +73 -54
  71. package/lib/container.js.map +1 -1
  72. package/lib/containerStorageAdapter.d.ts.map +1 -1
  73. package/lib/containerStorageAdapter.js +2 -1
  74. package/lib/containerStorageAdapter.js.map +1 -1
  75. package/lib/contracts.d.ts +2 -2
  76. package/lib/contracts.d.ts.map +1 -1
  77. package/lib/contracts.js.map +1 -1
  78. package/lib/debugLogger.js +1 -1
  79. package/lib/debugLogger.js.map +1 -1
  80. package/lib/deltaManager.d.ts +3 -4
  81. package/lib/deltaManager.d.ts.map +1 -1
  82. package/lib/deltaManager.js +6 -5
  83. package/lib/deltaManager.js.map +1 -1
  84. package/lib/deltaQueue.d.ts +1 -1
  85. package/lib/deltaQueue.d.ts.map +1 -1
  86. package/lib/deltaQueue.js +2 -1
  87. package/lib/deltaQueue.js.map +1 -1
  88. package/lib/disposal.d.ts +2 -2
  89. package/lib/disposal.d.ts.map +1 -1
  90. package/lib/disposal.js +1 -1
  91. package/lib/disposal.js.map +1 -1
  92. package/lib/error.d.ts +23 -0
  93. package/lib/error.d.ts.map +1 -0
  94. package/lib/error.js +28 -0
  95. package/lib/error.js.map +1 -0
  96. package/lib/loader.d.ts +9 -2
  97. package/lib/loader.d.ts.map +1 -1
  98. package/lib/loader.js +11 -6
  99. package/lib/loader.js.map +1 -1
  100. package/lib/noopHeuristic.d.ts +2 -2
  101. package/lib/noopHeuristic.d.ts.map +1 -1
  102. package/lib/noopHeuristic.js +2 -1
  103. package/lib/noopHeuristic.js.map +1 -1
  104. package/lib/packageVersion.d.ts +1 -1
  105. package/lib/packageVersion.js +1 -1
  106. package/lib/packageVersion.js.map +1 -1
  107. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  108. package/lib/retriableDocumentStorageService.js +2 -2
  109. package/lib/retriableDocumentStorageService.js.map +1 -1
  110. package/lib/utils.d.ts.map +1 -1
  111. package/lib/utils.js +4 -3
  112. package/lib/utils.js.map +1 -1
  113. package/package.json +21 -27
  114. package/src/audience.ts +1 -1
  115. package/src/catchUpMonitor.ts +1 -1
  116. package/src/connectionManager.ts +20 -10
  117. package/src/connectionStateHandler.ts +1 -1
  118. package/src/container.ts +120 -79
  119. package/src/containerStorageAdapter.ts +2 -1
  120. package/src/contracts.ts +1 -2
  121. package/src/debugLogger.ts +1 -1
  122. package/src/deltaManager.ts +16 -13
  123. package/src/deltaQueue.ts +2 -1
  124. package/src/disposal.ts +2 -2
  125. package/src/error.ts +44 -0
  126. package/src/loader.ts +30 -5
  127. package/src/noopHeuristic.ts +3 -2
  128. package/src/packageVersion.ts +1 -1
  129. package/src/retriableDocumentStorageService.ts +2 -4
  130. package/src/utils.ts +4 -8
package/dist/loader.d.ts CHANGED
@@ -6,6 +6,7 @@ import { ITelemetryLoggerExt, IConfigProviderBase } from "@fluidframework/teleme
6
6
  import { ITelemetryBaseLogger, FluidObject, IFluidRouter, IRequest, IRequestHeader, IResponse } from "@fluidframework/core-interfaces";
7
7
  import { IContainer, IFluidModule, IHostLoader, ILoader, ILoaderOptions as ILoaderOptions1, IProvideFluidCodeDetailsComparer, IFluidCodeDetails } from "@fluidframework/container-definitions";
8
8
  import { IDocumentServiceFactory, IDocumentStorageService, IUrlResolver } from "@fluidframework/driver-definitions";
9
+ import { IClientDetails } from "@fluidframework/protocol-definitions";
9
10
  import { Container } from "./container";
10
11
  import { ProtocolHandlerBuilder } from "./protocol";
11
12
  /**
@@ -182,8 +183,14 @@ export declare class Loader implements IHostLoader {
182
183
  * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
183
184
  */
184
185
  get IFluidRouter(): IFluidRouter;
185
- createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer>;
186
- rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer>;
186
+ createDetachedContainer(codeDetails: IFluidCodeDetails, createDetachedProps?: {
187
+ canReconnect?: boolean;
188
+ clientDetailsOverride?: IClientDetails;
189
+ }): Promise<IContainer>;
190
+ rehydrateDetachedContainerFromSnapshot(snapshot: string, createDetachedProps?: {
191
+ canReconnect?: boolean;
192
+ clientDetailsOverride?: IClientDetails;
193
+ }): Promise<IContainer>;
187
194
  resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer>;
188
195
  /**
189
196
  * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EAMnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACN,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,QAA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CAAC,CAepB;AAED;;GAEG;AACH,qBAAa,MAAO,YAAW,WAAW;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyC;IACpE,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAE3B,WAAW,EAAE,YAAY;IA2CrC;;OAEG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAEY,uBAAuB,CACnC,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,CAAC,EAAE;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,qBAAqB,CAAC,EAAE,cAAc,CAAC;KACvC,GACC,OAAO,CAAC,UAAU,CAAC;IAsBT,sCAAsC,CAClD,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE;QACrB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,qBAAqB,CAAC,EAAE,cAAc,CAAC;KACvC,GACC,OAAO,CAAC,UAAU,CAAC;IAUT,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAWxF;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAc3D,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,mBAAmB;YAuBb,WAAW;IAsEzB,OAAO,KAAK,cAAc,GAEzB;YAEa,aAAa;CAoB3B"}
package/dist/loader.js CHANGED
@@ -8,7 +8,6 @@ exports.Loader = exports.requestResolvedObjectFromContainer = exports.RelativeLo
8
8
  const uuid_1 = require("uuid");
9
9
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
10
  const container_definitions_1 = require("@fluidframework/container-definitions");
11
- const container_utils_1 = require("@fluidframework/container-utils");
12
11
  const container_1 = require("./container");
13
12
  const utils_1 = require("./utils");
14
13
  const packageVersion_1 = require("./packageVersion");
@@ -131,8 +130,11 @@ class Loader {
131
130
  get IFluidRouter() {
132
131
  return this;
133
132
  }
134
- async createDetachedContainer(codeDetails) {
135
- const container = await container_1.Container.createDetached(this.services, codeDetails);
133
+ async createDetachedContainer(codeDetails, createDetachedProps) {
134
+ const container = await container_1.Container.createDetached({
135
+ ...createDetachedProps,
136
+ ...this.services,
137
+ }, codeDetails);
136
138
  if (this.cachingEnabled) {
137
139
  container.once("attached", () => {
138
140
  ensureResolvedUrlDefined(container.resolvedUrl);
@@ -144,8 +146,11 @@ class Loader {
144
146
  }
145
147
  return container;
146
148
  }
147
- async rehydrateDetachedContainerFromSnapshot(snapshot) {
148
- return container_1.Container.rehydrateDetachedFromSnapshot(this.services, snapshot);
149
+ async rehydrateDetachedContainerFromSnapshot(snapshot, createDetachedProps) {
150
+ return container_1.Container.rehydrateDetachedFromSnapshot({
151
+ ...createDetachedProps,
152
+ ...this.services,
153
+ }, snapshot);
149
154
  }
150
155
  async resolve(request, pendingLocalState) {
151
156
  const eventName = pendingLocalState === undefined ? "Resolve" : "ResolveWithPendingState";
@@ -225,12 +230,12 @@ class Loader {
225
230
  if (opsBeforeReturn === "sequenceNumber" &&
226
231
  (fromSequenceNumber === undefined || fromSequenceNumber < 0)) {
227
232
  // If opsBeforeReturn is set to "sequenceNumber", then fromSequenceNumber should be set to a non-negative integer.
228
- throw new container_utils_1.UsageError("sequenceNumber must be set to a non-negative integer");
233
+ throw new telemetry_utils_1.UsageError("sequenceNumber must be set to a non-negative integer");
229
234
  }
230
235
  else if (opsBeforeReturn !== "sequenceNumber" && fromSequenceNumber !== undefined) {
231
236
  // If opsBeforeReturn is not set to "sequenceNumber", then fromSequenceNumber should be undefined (default value).
232
237
  // In this case, we should throw an error since opsBeforeReturn is not explicitly set to "sequenceNumber".
233
- throw new container_utils_1.UsageError('opsBeforeReturn must be set to "sequenceNumber"');
238
+ throw new telemetry_utils_1.UsageError('opsBeforeReturn must be set to "sequenceNumber"');
234
239
  }
235
240
  let container;
236
241
  if (canCache) {
@@ -1 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ACD;AApOD,wBAoOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tIConfigProviderBase,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIFluidRouter,\n\tIRequest,\n\tIRequestHeader,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\nimport { DebugLogger } from \"./debugLogger\";\n\nfunction canUseCache(request: IRequest): boolean {\n\treturn request.headers?.[LoaderHeader.cache] === true;\n}\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tif (canUseCache(request)) {\n\t\t\t\treturn this.container;\n\t\t\t} else {\n\t\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\t\tconst container = await this.container.clone(\n\t\t\t\t\t{\n\t\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn container;\n\t\t\t}\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tconst container = await this.resolve(request);\n\t\t\treturn container.request(request);\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 404,\n\t\t\t\tvalue: \"Cannot request external containers\",\n\t\t\t\tmimeType: \"plain/text\",\n\t\t\t};\n\t\t}\n\t\treturn this.loader.request(request);\n\t}\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns - Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * With an already-resolved container, we can request a component directly, without loading the container again\n * @param container - a resolved container\n * @returns component on the container\n */\nexport async function requestResolvedObjectFromContainer(\n\tcontainer: IContainer,\n\theaders?: IRequestHeader,\n): Promise<IResponse> {\n\tensureResolvedUrlDefined(container.resolvedUrl);\n\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\n\tif (parsedUrl === undefined) {\n\t\tthrow new Error(`Invalid URL ${container.resolvedUrl.url}`);\n\t}\n\n\tconst entryPoint: FluidObject<IFluidRouter> | undefined = await container.getEntryPoint?.();\n\tconst router = entryPoint?.IFluidRouter ?? container.IFluidRouter;\n\n\treturn router.request({\n\t\turl: `${parsedUrl.path}${parsedUrl.query}`,\n\t\theaders,\n\t});\n}\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n\tprivate readonly containers = new Map<string, Promise<Container>>();\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.services.subLogger,\n\t\t\tnamespace: \"Loader\",\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async createDetachedContainer(codeDetails: IFluidCodeDetails): Promise<IContainer> {\n\t\tconst container = await Container.createDetached(this.services, codeDetails);\n\n\t\tif (this.cachingEnabled) {\n\t\t\tcontainer.once(\"attached\", () => {\n\t\t\t\tensureResolvedUrlDefined(container.resolvedUrl);\n\t\t\t\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\t\t\t\tif (parsedUrl !== undefined) {\n\t\t\t\t\tthis.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn container;\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(snapshot: string): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(this.services, snapshot);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => {\n\t\t\t\tconst resolved = await this.resolveCore(request);\n\t\t\t\treturn resolved.container.request({\n\t\t\t\t\t...request,\n\t\t\t\t\turl: `${resolved.parsed.path}${resolved.parsed.query}`,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n\t\tconst key =\n\t\t\trequest.headers?.[LoaderHeader.version] !== undefined\n\t\t\t\t? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n\t\t\t\t: parsedUrl.id;\n\t\treturn key;\n\t}\n\n\tprivate addToContainerCache(key: string, containerP: Promise<Container>) {\n\t\tthis.containers.set(key, containerP);\n\t\tcontainerP\n\t\t\t.then((container) => {\n\t\t\t\t// If the container is closed/disposed or becomes closed/disposed after we resolve it,\n\t\t\t\t// remove it from the cache.\n\t\t\t\tif (container.closed || container.disposed) {\n\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.once(\"closed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t\tcontainer.once(\"disposed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If an error occured while resolving the container request, then remove it from the cache.\n\t\t\t\tthis.containers.delete(key);\n\t\t\t});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = parseUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = parseUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst cacheHeader = request.headers[LoaderHeader.cache];\n\t\tconst canCache =\n\t\t\t// Take header value if present, else use ILoaderOptions.cache value\n\t\t\t(cacheHeader !== undefined ? cacheHeader === true : this.cachingEnabled) &&\n\t\t\tpendingLocalState === undefined;\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as\n\t\t\t| number\n\t\t\t| undefined;\n\t\tconst opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as\n\t\t\t| string\n\t\t\t| undefined;\n\n\t\tif (\n\t\t\topsBeforeReturn === \"sequenceNumber\" &&\n\t\t\t(fromSequenceNumber === undefined || fromSequenceNumber < 0)\n\t\t) {\n\t\t\t// If opsBeforeReturn is set to \"sequenceNumber\", then fromSequenceNumber should be set to a non-negative integer.\n\t\t\tthrow new UsageError(\"sequenceNumber must be set to a non-negative integer\");\n\t\t} else if (opsBeforeReturn !== \"sequenceNumber\" && fromSequenceNumber !== undefined) {\n\t\t\t// If opsBeforeReturn is not set to \"sequenceNumber\", then fromSequenceNumber should be undefined (default value).\n\t\t\t// In this case, we should throw an error since opsBeforeReturn is not explicitly set to \"sequenceNumber\".\n\t\t\tthrow new UsageError('opsBeforeReturn must be set to \"sequenceNumber\"');\n\t\t}\n\n\t\tlet container: Container;\n\t\tif (canCache) {\n\t\t\tconst key = this.getKeyForContainerCache(request, parsed);\n\t\t\tconst maybeContainer = await this.containers.get(key);\n\t\t\tif (maybeContainer !== undefined) {\n\t\t\t\tcontainer = maybeContainer;\n\t\t\t} else {\n\t\t\t\tconst containerP = this.loadContainer(request, resolvedAsFluid);\n\t\t\t\tthis.addToContainerCache(key, containerP);\n\t\t\t\tcontainer = await containerP;\n\t\t\t}\n\t\t} else {\n\t\t\tcontainer = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t\t}\n\n\t\treturn { container, parsed };\n\t}\n\n\tprivate get cachingEnabled() {\n\t\treturn this.services.options.cache === true;\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t\tloadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,qEASyC;AASzC,iFAS+C;AAQ/C,2CAAgE;AAChE,mCAA+C;AAC/C,qDAA8C;AAE9C,+CAA4C;AAE5C,SAAS,WAAW,CAAC,OAAiB;IACrC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AACvD,CAAC;AAED,SAAS,wBAAwB,CAChC,QAAkC;IAElC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,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AM,UAAU,CAAC;aAC7B;SACD;aAAM;YACN,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC;SAClF;QAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;IAED,IAAY,cAAc;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,aAAa,CAC1B,OAAiB,EACjB,WAAyB,EACzB,iBAA0C;QAE1C,OAAO,qBAAS,CAAC,IAAI,CACpB;YACC,WAAW;YACX,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,OAAO,CAAC,IAAI,SAAS;YAC7D,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,QAAQ,CAAC;YAClD,iBAAiB;YACjB,oBAAoB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,cAAc,CAAC;SACpE,EACD;YACC,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,SAAS,CAAC;YACvD,qBAAqB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,oCAAY,CAAC,aAAa,CAAC;YACpE,GAAG,IAAI,CAAC,QAAQ;SAChB,CACD,CAAC;IACH,CAAC;CACD;AA5PD,wBA4PC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tIConfigProviderBase,\n\tmixinMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tsessionStorageConfigProvider,\n\tcreateChildMonitoringContext,\n\tUsageError,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tFluidObject,\n\tIFluidRouter,\n\tIRequest,\n\tIRequestHeader,\n\tIResponse,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tIContainer,\n\tIFluidModule,\n\tIHostLoader,\n\tILoader,\n\tILoaderOptions as ILoaderOptions1,\n\tLoaderHeader,\n\tIProvideFluidCodeDetailsComparer,\n\tIFluidCodeDetails,\n} from \"@fluidframework/container-definitions\";\nimport {\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions\";\nimport { IClientDetails } from \"@fluidframework/protocol-definitions\";\nimport { Container, IPendingContainerState } from \"./container\";\nimport { IParsedUrl, parseUrl } from \"./utils\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { ProtocolHandlerBuilder } from \"./protocol\";\nimport { DebugLogger } from \"./debugLogger\";\n\nfunction canUseCache(request: IRequest): boolean {\n\treturn request.headers?.[LoaderHeader.cache] === true;\n}\n\nfunction ensureResolvedUrlDefined(\n\tresolved: IResolvedUrl | undefined,\n): asserts resolved is IResolvedUrl {\n\tif (resolved === undefined) {\n\t\tthrow new Error(`Object is not a IResolveUrl.`);\n\t}\n}\n/**\n * @internal\n */\nexport class RelativeLoader implements ILoader {\n\tconstructor(\n\t\tprivate readonly container: Container,\n\t\tprivate readonly loader: ILoader | undefined,\n\t) {}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async resolve(request: IRequest): Promise<IContainer> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tif (canUseCache(request)) {\n\t\t\t\treturn this.container;\n\t\t\t} else {\n\t\t\t\tensureResolvedUrlDefined(this.container.resolvedUrl);\n\t\t\t\tconst container = await this.container.clone(\n\t\t\t\t\t{\n\t\t\t\t\t\tresolvedUrl: { ...this.container.resolvedUrl },\n\t\t\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn container;\n\t\t\t}\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\tthrow new Error(\"Cannot resolve external containers\");\n\t\t}\n\t\treturn this.loader.resolve(request);\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\tif (request.url.startsWith(\"/\")) {\n\t\t\tconst container = await this.resolve(request);\n\t\t\treturn container.request(request);\n\t\t}\n\n\t\tif (this.loader === undefined) {\n\t\t\treturn {\n\t\t\t\tstatus: 404,\n\t\t\t\tvalue: \"Cannot request external containers\",\n\t\t\t\tmimeType: \"plain/text\",\n\t\t\t};\n\t\t}\n\t\treturn this.loader.request(request);\n\t}\n}\n\nexport interface ILoaderOptions extends ILoaderOptions1 {\n\tsummarizeProtocolTree?: boolean;\n}\n\n/**\n * @deprecated IFluidModuleWithDetails interface is moved to\n * {@link @fluidframework/container-definitions#IFluidModuleWithDetails}\n * to have all the code loading modules in one package. #8193\n * Encapsulates a module entry point with corresponding code details.\n */\nexport interface IFluidModuleWithDetails {\n\t/** Fluid code module that implements the runtime factory needed to instantiate the container runtime. */\n\tmodule: IFluidModule;\n\t/**\n\t * Code details associated with the module. Represents a document schema this module supports.\n\t * If the code loader implements the {@link @fluidframework/core-interfaces#IFluidCodeDetailsComparer} interface,\n\t * it'll be called to determine whether the module code details satisfy the new code proposal in the quorum.\n\t */\n\tdetails: IFluidCodeDetails;\n}\n\n/**\n * @deprecated ICodeDetailsLoader interface is moved to {@link @fluidframework/container-definition#ICodeDetailsLoader}\n * to have code loading modules in one package. #8193\n * Fluid code loader resolves a code module matching the document schema, i.e. code details, such as\n * a package name and package version range.\n */\nexport interface ICodeDetailsLoader extends Partial<IProvideFluidCodeDetailsComparer> {\n\t/**\n\t * Load the code module (package) that is capable to interact with the document.\n\t *\n\t * @param source - Code proposal that articulates the current schema the document is written in.\n\t * @returns - Code module entry point along with the code details associated with it.\n\t */\n\tload(source: IFluidCodeDetails): Promise<IFluidModuleWithDetails>;\n}\n\n/**\n * Services and properties necessary for creating a loader\n */\nexport interface ILoaderProps {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options?: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope?: FluidObject;\n\n\t/**\n\t * The logger that all telemetry should be pushed to.\n\t */\n\treadonly logger?: ITelemetryBaseLogger;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * The configuration provider which may be used to control features.\n\t */\n\treadonly configProvider?: IConfigProviderBase;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Services and properties used by and exposed by the loader\n */\nexport interface ILoaderServices {\n\t/**\n\t * The url resolver used by the loader for resolving external urls\n\t * into Fluid urls such that the container specified by the\n\t * external url can be loaded.\n\t */\n\treadonly urlResolver: IUrlResolver;\n\t/**\n\t * The document service factory take the Fluid url provided\n\t * by the resolved url and constructs all the necessary services\n\t * for communication with the container's server.\n\t */\n\treadonly documentServiceFactory: IDocumentServiceFactory;\n\t/**\n\t * The code loader handles loading the necessary code\n\t * for running a container once it is loaded.\n\t */\n\treadonly codeLoader: ICodeDetailsLoader;\n\n\t/**\n\t * A property bag of options used by various layers\n\t * to control features\n\t */\n\treadonly options: ILoaderOptions;\n\n\t/**\n\t * Scope is provided to all container and is a set of shared\n\t * services for container's to integrate with their host environment.\n\t */\n\treadonly scope: FluidObject;\n\n\t/**\n\t * The logger downstream consumers should construct their loggers from\n\t */\n\treadonly subLogger: ITelemetryLoggerExt;\n\n\t/**\n\t * Blobs storage for detached containers.\n\t */\n\treadonly detachedBlobStorage?: IDetachedBlobStorage;\n\n\t/**\n\t * Optional property for allowing the container to use a custom\n\t * protocol implementation for handling the quorum and/or the audience.\n\t */\n\treadonly protocolHandlerBuilder?: ProtocolHandlerBuilder;\n}\n\n/**\n * Subset of IDocumentStorageService which only supports createBlob() and readBlob(). This is used to support\n * blobs in detached containers.\n */\nexport type IDetachedBlobStorage = Pick<IDocumentStorageService, \"createBlob\" | \"readBlob\"> & {\n\tsize: number;\n\t/**\n\t * Return an array of all blob IDs present in storage\n\t */\n\tgetBlobIds(): string[];\n};\n\n/**\n * With an already-resolved container, we can request a component directly, without loading the container again\n * @param container - a resolved container\n * @returns component on the container\n */\nexport async function requestResolvedObjectFromContainer(\n\tcontainer: IContainer,\n\theaders?: IRequestHeader,\n): Promise<IResponse> {\n\tensureResolvedUrlDefined(container.resolvedUrl);\n\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\n\tif (parsedUrl === undefined) {\n\t\tthrow new Error(`Invalid URL ${container.resolvedUrl.url}`);\n\t}\n\n\tconst entryPoint: FluidObject<IFluidRouter> | undefined = await container.getEntryPoint?.();\n\tconst router = entryPoint?.IFluidRouter ?? container.IFluidRouter;\n\n\treturn router.request({\n\t\turl: `${parsedUrl.path}${parsedUrl.query}`,\n\t\theaders,\n\t});\n}\n\n/**\n * Manages Fluid resource loading\n */\nexport class Loader implements IHostLoader {\n\tprivate readonly containers = new Map<string, Promise<Container>>();\n\tpublic readonly services: ILoaderServices;\n\tprivate readonly mc: MonitoringContext;\n\n\tconstructor(loaderProps: ILoaderProps) {\n\t\tconst {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions,\n\t\t\tscope,\n\t\t\tlogger,\n\t\t\tdetachedBlobStorage,\n\t\t\tconfigProvider,\n\t\t\tprotocolHandlerBuilder,\n\t\t} = loaderProps;\n\n\t\tconst telemetryProps = {\n\t\t\tloaderId: uuid(),\n\t\t\tloaderVersion: pkgVersion,\n\t\t};\n\n\t\tconst subMc = mixinMonitoringContext(\n\t\t\tDebugLogger.mixinDebugLogger(\"fluid:telemetry\", logger, {\n\t\t\t\tall: telemetryProps,\n\t\t\t}),\n\t\t\tsessionStorageConfigProvider.value,\n\t\t\tconfigProvider,\n\t\t);\n\n\t\tthis.services = {\n\t\t\turlResolver,\n\t\t\tdocumentServiceFactory,\n\t\t\tcodeLoader,\n\t\t\toptions: options ?? {},\n\t\t\tscope:\n\t\t\t\toptions?.provideScopeLoader !== false ? { ...scope, ILoader: this } : { ...scope },\n\t\t\tdetachedBlobStorage,\n\t\t\tprotocolHandlerBuilder,\n\t\t\tsubLogger: subMc.logger,\n\t\t};\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: this.services.subLogger,\n\t\t\tnamespace: \"Loader\",\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic get IFluidRouter(): IFluidRouter {\n\t\treturn this;\n\t}\n\n\tpublic async createDetachedContainer(\n\t\tcodeDetails: IFluidCodeDetails,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\tconst container = await Container.createDetached(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tcodeDetails,\n\t\t);\n\n\t\tif (this.cachingEnabled) {\n\t\t\tcontainer.once(\"attached\", () => {\n\t\t\t\tensureResolvedUrlDefined(container.resolvedUrl);\n\t\t\t\tconst parsedUrl = parseUrl(container.resolvedUrl.url);\n\t\t\t\tif (parsedUrl !== undefined) {\n\t\t\t\t\tthis.addToContainerCache(parsedUrl.id, Promise.resolve(container));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\treturn container;\n\t}\n\n\tpublic async rehydrateDetachedContainerFromSnapshot(\n\t\tsnapshot: string,\n\t\tcreateDetachedProps?: {\n\t\t\tcanReconnect?: boolean;\n\t\t\tclientDetailsOverride?: IClientDetails;\n\t\t},\n\t): Promise<IContainer> {\n\t\treturn Container.rehydrateDetachedFromSnapshot(\n\t\t\t{\n\t\t\t\t...createDetachedProps,\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t\tsnapshot,\n\t\t);\n\t}\n\n\tpublic async resolve(request: IRequest, pendingLocalState?: string): Promise<IContainer> {\n\t\tconst eventName = pendingLocalState === undefined ? \"Resolve\" : \"ResolveWithPendingState\";\n\t\treturn PerformanceEvent.timedExecAsync(this.mc.logger, { eventName }, async () => {\n\t\t\tconst resolved = await this.resolveCore(\n\t\t\t\trequest,\n\t\t\t\tpendingLocalState !== undefined ? JSON.parse(pendingLocalState) : undefined,\n\t\t\t);\n\t\t\treturn resolved.container;\n\t\t});\n\t}\n\n\t/**\n\t * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the Container's IFluidRouter/request.\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.mc.logger,\n\t\t\t{ eventName: \"Request\" },\n\t\t\tasync () => {\n\t\t\t\tconst resolved = await this.resolveCore(request);\n\t\t\t\treturn resolved.container.request({\n\t\t\t\t\t...request,\n\t\t\t\t\turl: `${resolved.parsed.path}${resolved.parsed.query}`,\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate getKeyForContainerCache(request: IRequest, parsedUrl: IParsedUrl): string {\n\t\tconst key =\n\t\t\trequest.headers?.[LoaderHeader.version] !== undefined\n\t\t\t\t? `${parsedUrl.id}@${request.headers[LoaderHeader.version]}`\n\t\t\t\t: parsedUrl.id;\n\t\treturn key;\n\t}\n\n\tprivate addToContainerCache(key: string, containerP: Promise<Container>) {\n\t\tthis.containers.set(key, containerP);\n\t\tcontainerP\n\t\t\t.then((container) => {\n\t\t\t\t// If the container is closed/disposed or becomes closed/disposed after we resolve it,\n\t\t\t\t// remove it from the cache.\n\t\t\t\tif (container.closed || container.disposed) {\n\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tcontainer.once(\"closed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t\tcontainer.once(\"disposed\", () => {\n\t\t\t\t\t\tthis.containers.delete(key);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If an error occured while resolving the container request, then remove it from the cache.\n\t\t\t\tthis.containers.delete(key);\n\t\t\t});\n\t}\n\n\tprivate async resolveCore(\n\t\trequest: IRequest,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<{ container: Container; parsed: IParsedUrl }> {\n\t\tconst resolvedAsFluid = await this.services.urlResolver.resolve(request);\n\t\tensureResolvedUrlDefined(resolvedAsFluid);\n\n\t\t// Parse URL into data stores\n\t\tconst parsed = parseUrl(resolvedAsFluid.url);\n\t\tif (parsed === undefined) {\n\t\t\tthrow new Error(`Invalid URL ${resolvedAsFluid.url}`);\n\t\t}\n\n\t\tif (pendingLocalState !== undefined) {\n\t\t\tconst parsedPendingUrl = parseUrl(pendingLocalState.url);\n\t\t\tif (\n\t\t\t\tparsedPendingUrl?.id !== parsed.id ||\n\t\t\t\tparsedPendingUrl?.path.replace(/\\/$/, \"\") !== parsed.path.replace(/\\/$/, \"\")\n\t\t\t) {\n\t\t\t\tconst message = `URL ${resolvedAsFluid.url} does not match pending state URL ${pendingLocalState.url}`;\n\t\t\t\tthrow new Error(message);\n\t\t\t}\n\t\t}\n\n\t\trequest.headers ??= {};\n\t\t// If set in both query string and headers, use query string. Also write the value from the query string into the header either way.\n\t\trequest.headers[LoaderHeader.version] =\n\t\t\tparsed.version ?? request.headers[LoaderHeader.version];\n\t\tconst cacheHeader = request.headers[LoaderHeader.cache];\n\t\tconst canCache =\n\t\t\t// Take header value if present, else use ILoaderOptions.cache value\n\t\t\t(cacheHeader !== undefined ? cacheHeader === true : this.cachingEnabled) &&\n\t\t\tpendingLocalState === undefined;\n\t\tconst fromSequenceNumber = request.headers[LoaderHeader.sequenceNumber] as\n\t\t\t| number\n\t\t\t| undefined;\n\t\tconst opsBeforeReturn = request.headers[LoaderHeader.loadMode]?.opsBeforeReturn as\n\t\t\t| string\n\t\t\t| undefined;\n\n\t\tif (\n\t\t\topsBeforeReturn === \"sequenceNumber\" &&\n\t\t\t(fromSequenceNumber === undefined || fromSequenceNumber < 0)\n\t\t) {\n\t\t\t// If opsBeforeReturn is set to \"sequenceNumber\", then fromSequenceNumber should be set to a non-negative integer.\n\t\t\tthrow new UsageError(\"sequenceNumber must be set to a non-negative integer\");\n\t\t} else if (opsBeforeReturn !== \"sequenceNumber\" && fromSequenceNumber !== undefined) {\n\t\t\t// If opsBeforeReturn is not set to \"sequenceNumber\", then fromSequenceNumber should be undefined (default value).\n\t\t\t// In this case, we should throw an error since opsBeforeReturn is not explicitly set to \"sequenceNumber\".\n\t\t\tthrow new UsageError('opsBeforeReturn must be set to \"sequenceNumber\"');\n\t\t}\n\n\t\tlet container: Container;\n\t\tif (canCache) {\n\t\t\tconst key = this.getKeyForContainerCache(request, parsed);\n\t\t\tconst maybeContainer = await this.containers.get(key);\n\t\t\tif (maybeContainer !== undefined) {\n\t\t\t\tcontainer = maybeContainer;\n\t\t\t} else {\n\t\t\t\tconst containerP = this.loadContainer(request, resolvedAsFluid);\n\t\t\t\tthis.addToContainerCache(key, containerP);\n\t\t\t\tcontainer = await containerP;\n\t\t\t}\n\t\t} else {\n\t\t\tcontainer = await this.loadContainer(request, resolvedAsFluid, pendingLocalState);\n\t\t}\n\n\t\treturn { container, parsed };\n\t}\n\n\tprivate get cachingEnabled() {\n\t\treturn this.services.options.cache === true;\n\t}\n\n\tprivate async loadContainer(\n\t\trequest: IRequest,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tpendingLocalState?: IPendingContainerState,\n\t): Promise<Container> {\n\t\treturn Container.load(\n\t\t\t{\n\t\t\t\tresolvedUrl,\n\t\t\t\tversion: request.headers?.[LoaderHeader.version] ?? undefined,\n\t\t\t\tloadMode: request.headers?.[LoaderHeader.loadMode],\n\t\t\t\tpendingLocalState,\n\t\t\t\tloadToSequenceNumber: request.headers?.[LoaderHeader.sequenceNumber],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcanReconnect: request.headers?.[LoaderHeader.reconnect],\n\t\t\t\tclientDetailsOverride: request.headers?.[LoaderHeader.clientDetails],\n\t\t\t\t...this.services,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TypedEventEmitter } from "@fluidframework/common-utils";
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
- import { IEvent } from "@fluidframework/common-definitions";
7
+ import { IEvent } from "@fluidframework/core-interfaces";
8
8
  export interface INoopSenderEvents extends IEvent {
9
9
  (event: "wantsNoop", listener: () => void): any;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"noopHeuristic.d.ts","sourceRoot":"","s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AGzC,iBAAiB,GAAE,MAAiC,EACnC,kBAAkB,GAAE,MAAkC;IAcxE;;OAEG;IACI,sBAAsB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI;IAqChE,gBAAgB,IAAI,IAAI;IAKxB,iBAAiB,IAAI,IAAI;CAIhC"}
@@ -5,7 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.NoopHeuristic = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
+ const core_utils_1 = require("@fluidframework/core-utils");
9
10
  const driver_utils_1 = require("@fluidframework/driver-utils");
10
11
  const defaultNoopTimeFrequency = 2000;
11
12
  const defaultNoopCountFrequency = 50;
@@ -28,13 +29,13 @@ const defaultNoopCountFrequency = 50;
28
29
  // server timeout of 2000ms should be reconsidered to be increased.
29
30
  // 2. If there are more than 50 ops received without sending any ops, send noop to keep collab window small.
30
31
  // Note that system ops (including noops themselves) are excluded, so it's 1 noop per 50 real ops.
31
- class NoopHeuristic extends common_utils_1.TypedEventEmitter {
32
+ class NoopHeuristic extends client_utils_1.TypedEventEmitter {
32
33
  constructor(NoopTimeFrequency = defaultNoopTimeFrequency, NoopCountFrequency = defaultNoopCountFrequency) {
33
34
  super();
34
35
  this.NoopCountFrequency = NoopCountFrequency;
35
36
  this.opsProcessedSinceOpSent = 0;
36
37
  if (NoopTimeFrequency !== Infinity) {
37
- this.timer = new common_utils_1.Timer(NoopTimeFrequency, () => {
38
+ this.timer = new core_utils_1.Timer(NoopTimeFrequency, () => {
38
39
  // We allow the timer to expire even if an op is sent or we disconnect.
39
40
  // This condition is to guard against trying to send a noop anyway in that case.
40
41
  if (this.opsProcessedSinceOpSent !== 0) {
@@ -62,7 +63,7 @@ class NoopHeuristic extends common_utils_1.TypedEventEmitter {
62
63
  queueMicrotask(() => {
63
64
  if (this.opsProcessedSinceOpSent >= this.NoopCountFrequency) {
64
65
  this.emit("wantsNoop");
65
- (0, common_utils_1.assert)(this.opsProcessedSinceOpSent === 0, 0x243 /* "Expected a noop to be synchronously sent" */);
66
+ (0, core_utils_1.assert)(this.opsProcessedSinceOpSent === 0, 0x243 /* "Expected a noop to be synchronously sent" */);
66
67
  }
67
68
  return;
68
69
  });
@@ -73,7 +74,7 @@ class NoopHeuristic extends common_utils_1.TypedEventEmitter {
73
74
  if (this.opsProcessedSinceOpSent === 1) {
74
75
  this.timer.restart();
75
76
  }
76
- (0, common_utils_1.assert)(this.timer.hasTimer, 0x242 /* "has timer" */);
77
+ (0, core_utils_1.assert)(this.timer.hasTimer, 0x242 /* "has timer" */);
77
78
  }
78
79
  }
79
80
  notifyDisconnect() {
@@ -1 +1 @@
1
- {"version":3,"file":"noopHeuristic.js","sourceRoot":"","sources":["../src/noopHeuristic.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgF;AAEhF,+DAAgE;AAGhE,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAMrC,6FAA6F;AAC7F,4GAA4G;AAC5G,yGAAyG;AACzG,2CAA2C;AAC3C,oHAAoH;AACpH,2FAA2F;AAC3F,kHAAkH;AAClH,+CAA+C;AAC/C,gHAAgH;AAChH,yFAAyF;AACzF,qHAAqH;AACrH,oDAAoD;AACpD,EAAE;AACF,kDAAkD;AAClD,oGAAoG;AACpG,iHAAiH;AACjH,sEAAsE;AACtE,4GAA4G;AAC5G,qGAAqG;AACrG,MAAa,aAAc,SAAQ,gCAAoC;IAItE,YACC,oBAA4B,wBAAwB,EACnC,qBAA6B,yBAAyB;QAEvE,KAAK,EAAE,CAAC;QAFS,uBAAkB,GAAlB,kBAAkB,CAAoC;QALhE,4BAAuB,GAAG,CAAC,CAAC;QAQnC,IAAI,iBAAiB,KAAK,QAAQ,EAAE;YACnC,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAK,CAAC,iBAAiB,EAAE,GAAG,EAAE;gBAC9C,uEA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AAC;IAClC,CAAC;CACD;AArED,sCAqEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Timer, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\n\nconst defaultNoopTimeFrequency = 2000;\nconst defaultNoopCountFrequency = 50;\n\nexport interface INoopSenderEvents extends IEvent {\n\t(event: \"wantsNoop\", listener: () => void);\n}\n\n// Here are key considerations when deciding conditions for when to send non-immediate noops:\n// 1. Sending them too often results in increase in file size and bandwidth, as well as catch up performance\n// 2. Sending too infrequently ensures that collab window is large, and as result Sequence DDS would have\n// large catchUp blobs - see Issue #6364\n// 3. Similarly, processes that rely on \"core\" snapshot (and can't parse trailing ops, including above), like search\n// parser in SPO, will result in non-accurate results due to presence of catch up blobs.\n// 4. Ordering service used 250ms timeout to coalesce non-immediate noops. It was changed to 2000 ms to allow more\n// aggressive noop sending from client side.\n// 5. Number of ops sent by all clients is proportional to number of \"write\" clients (every client sends noops),\n// but number of sequenced noops is a function of time (one op per 2 seconds at most).\n// We should consider impact to both outbound traffic (might be huge, depends on number of clients) and file size.\n// Please also see Issue #5629 for more discussions.\n//\n// With that, the current algorithm is as follows:\n// 1. Sent noop 2000 ms of receiving an op if no ops were sent by this client within this timeframe.\n// This will ensure that MSN moves forward with reasonable speed. If that results in too many sequenced noops,\n// server timeout of 2000ms should be reconsidered to be increased.\n// 2. If there are more than 50 ops received without sending any ops, send noop to keep collab window small.\n// Note that system ops (including noops themselves) are excluded, so it's 1 noop per 50 real ops.\nexport class NoopHeuristic extends TypedEventEmitter<INoopSenderEvents> {\n\tprivate opsProcessedSinceOpSent = 0;\n\tprivate readonly timer: Timer | undefined;\n\n\tconstructor(\n\t\tNoopTimeFrequency: number = defaultNoopTimeFrequency,\n\t\tprivate readonly NoopCountFrequency: number = defaultNoopCountFrequency,\n\t) {\n\t\tsuper();\n\t\tif (NoopTimeFrequency !== Infinity) {\n\t\t\tthis.timer = new Timer(NoopTimeFrequency, () => {\n\t\t\t\t// We allow the timer to expire even if an op is sent or we disconnect.\n\t\t\t\t// This condition is to guard against trying to send a noop anyway in that case.\n\t\t\t\tif (this.opsProcessedSinceOpSent !== 0) {\n\t\t\t\t\tthis.emit(\"wantsNoop\");\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Schedules as ack to the server to update the reference sequence number\n\t */\n\tpublic notifyMessageProcessed(message: ISequencedDocumentMessage): void {\n\t\t// We don't acknowledge no-ops to avoid acknowledgement cycles (i.e. ack the MSN\n\t\t// update, which updates the MSN, then ack the update, etc...).\n\t\t// Intent here is for runtime (and DDSes) not to keep too much tracking state / memory\n\t\t// due to runtime ops from other clients.\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsProcessedSinceOpSent++;\n\t\tif (this.opsProcessedSinceOpSent === this.NoopCountFrequency) {\n\t\t\t// Wait to send a noop if we are still synchronously processing ops. This guards against two things:\n\t\t\t// 1. If we're processing many ops, we may pass the frequency threshold many times. We only need to send one noop at the very end in this case.\n\t\t\t// 2. We may send another (non-noop) op in response to processing those ops, e.g. an Accept op.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (this.opsProcessedSinceOpSent >= this.NoopCountFrequency) {\n\t\t\t\t\tthis.emit(\"wantsNoop\");\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.opsProcessedSinceOpSent === 0,\n\t\t\t\t\t\t0x243 /* \"Expected a noop to be synchronously sent\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t});\n\t\t}\n\n\t\tif (this.timer !== undefined) {\n\t\t\t// Start the timer if we newly have ops that want a noop.\n\t\t\t// If the timer was already running (e.g. we surpassed the op count and sent a noop) this will reset it to its full duration.\n\t\t\tif (this.opsProcessedSinceOpSent === 1) {\n\t\t\t\tthis.timer.restart();\n\t\t\t}\n\n\t\t\tassert(this.timer.hasTimer, 0x242 /* \"has timer\" */);\n\t\t}\n\t}\n\n\tpublic notifyDisconnect(): void {\n\t\t// No need to noop for any ops processed prior to disconnect - we are already removed from MSN calculation.\n\t\tthis.opsProcessedSinceOpSent = 0;\n\t}\n\n\tpublic notifyMessageSent(): void {\n\t\t// Sending any message is as good as a noop for updating MSN.\n\t\tthis.opsProcessedSinceOpSent = 0;\n\t}\n}\n"]}
1
+ {"version":3,"file":"noopHeuristic.js","sourceRoot":"","sources":["../src/noopHeuristic.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,2DAA2D;AAE3D,+DAAgE;AAGhE,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAMrC,6FAA6F;AAC7F,4GAA4G;AAC5G,yGAAyG;AACzG,2CAA2C;AAC3C,oHAAoH;AACpH,2FAA2F;AAC3F,kHAAkH;AAClH,+CAA+C;AAC/C,gHAAgH;AAChH,yFAAyF;AACzF,qHAAqH;AACrH,oDAAoD;AACpD,EAAE;AACF,kDAAkD;AAClD,oGAAoG;AACpG,iHAAiH;AACjH,sEAAsE;AACtE,4GAA4G;AAC5G,qGAAqG;AACrG,MAAa,aAAc,SAAQ,gCAAoC;IAItE,YACC,oBAA4B,wBAAwB,EACnC,qBAA6B,yBAAyB;QAEvE,KAAK,EAAE,CAAC;QAFS,uBAAkB,GAAlB,kBAAkB,CAAoC;QALhE,4BAAuB,GAAG,CAAC,CAAC;QAQnC,IAAI,iBAAiB,KAAK,QAAQ,EAAE;YACnC,IAAI,CAAC,KAAK,GAAG,IAAI,kBAAK,CAAC,iBAAiB,EAAE,GAAG,EAAE;gBAC9C,uEAAuE;gBACvE,gFAAgF;gBAChF,IAAI,IAAI,CAAC,uBAAuB,KAAK,CAAC,EAAE;oBACvC,IA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served.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert, Timer } from \"@fluidframework/core-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { isRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\n\nconst defaultNoopTimeFrequency = 2000;\nconst defaultNoopCountFrequency = 50;\n\nexport interface INoopSenderEvents extends IEvent {\n\t(event: \"wantsNoop\", listener: () => void);\n}\n\n// Here are key considerations when deciding conditions for when to send non-immediate noops:\n// 1. Sending them too often results in increase in file size and bandwidth, as well as catch up performance\n// 2. Sending too infrequently ensures that collab window is large, and as result Sequence DDS would have\n// large catchUp blobs - see Issue #6364\n// 3. Similarly, processes that rely on \"core\" snapshot (and can't parse trailing ops, including above), like search\n// parser in SPO, will result in non-accurate results due to presence of catch up blobs.\n// 4. Ordering service used 250ms timeout to coalesce non-immediate noops. It was changed to 2000 ms to allow more\n// aggressive noop sending from client side.\n// 5. Number of ops sent by all clients is proportional to number of \"write\" clients (every client sends noops),\n// but number of sequenced noops is a function of time (one op per 2 seconds at most).\n// We should consider impact to both outbound traffic (might be huge, depends on number of clients) and file size.\n// Please also see Issue #5629 for more discussions.\n//\n// With that, the current algorithm is as follows:\n// 1. Sent noop 2000 ms of receiving an op if no ops were sent by this client within this timeframe.\n// This will ensure that MSN moves forward with reasonable speed. If that results in too many sequenced noops,\n// server timeout of 2000ms should be reconsidered to be increased.\n// 2. If there are more than 50 ops received without sending any ops, send noop to keep collab window small.\n// Note that system ops (including noops themselves) are excluded, so it's 1 noop per 50 real ops.\nexport class NoopHeuristic extends TypedEventEmitter<INoopSenderEvents> {\n\tprivate opsProcessedSinceOpSent = 0;\n\tprivate readonly timer: Timer | undefined;\n\n\tconstructor(\n\t\tNoopTimeFrequency: number = defaultNoopTimeFrequency,\n\t\tprivate readonly NoopCountFrequency: number = defaultNoopCountFrequency,\n\t) {\n\t\tsuper();\n\t\tif (NoopTimeFrequency !== Infinity) {\n\t\t\tthis.timer = new Timer(NoopTimeFrequency, () => {\n\t\t\t\t// We allow the timer to expire even if an op is sent or we disconnect.\n\t\t\t\t// This condition is to guard against trying to send a noop anyway in that case.\n\t\t\t\tif (this.opsProcessedSinceOpSent !== 0) {\n\t\t\t\t\tthis.emit(\"wantsNoop\");\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Schedules as ack to the server to update the reference sequence number\n\t */\n\tpublic notifyMessageProcessed(message: ISequencedDocumentMessage): void {\n\t\t// We don't acknowledge no-ops to avoid acknowledgement cycles (i.e. ack the MSN\n\t\t// update, which updates the MSN, then ack the update, etc...).\n\t\t// Intent here is for runtime (and DDSes) not to keep too much tracking state / memory\n\t\t// due to runtime ops from other clients.\n\t\tif (!isRuntimeMessage(message)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsProcessedSinceOpSent++;\n\t\tif (this.opsProcessedSinceOpSent === this.NoopCountFrequency) {\n\t\t\t// Wait to send a noop if we are still synchronously processing ops. This guards against two things:\n\t\t\t// 1. If we're processing many ops, we may pass the frequency threshold many times. We only need to send one noop at the very end in this case.\n\t\t\t// 2. We may send another (non-noop) op in response to processing those ops, e.g. an Accept op.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (this.opsProcessedSinceOpSent >= this.NoopCountFrequency) {\n\t\t\t\t\tthis.emit(\"wantsNoop\");\n\t\t\t\t\tassert(\n\t\t\t\t\t\tthis.opsProcessedSinceOpSent === 0,\n\t\t\t\t\t\t0x243 /* \"Expected a noop to be synchronously sent\" */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t});\n\t\t}\n\n\t\tif (this.timer !== undefined) {\n\t\t\t// Start the timer if we newly have ops that want a noop.\n\t\t\t// If the timer was already running (e.g. we surpassed the op count and sent a noop) this will reset it to its full duration.\n\t\t\tif (this.opsProcessedSinceOpSent === 1) {\n\t\t\t\tthis.timer.restart();\n\t\t\t}\n\n\t\t\tassert(this.timer.hasTimer, 0x242 /* \"has timer\" */);\n\t\t}\n\t}\n\n\tpublic notifyDisconnect(): void {\n\t\t// No need to noop for any ops processed prior to disconnect - we are already removed from MSN calculation.\n\t\tthis.opsProcessedSinceOpSent = 0;\n\t}\n\n\tpublic notifyMessageSent(): void {\n\t\t// Sending any message is as good as a noop for updating MSN.\n\t\tthis.opsProcessedSinceOpSent = 0;\n\t}\n}\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/container-loader";
8
- export declare const pkgVersion = "2.0.0-internal.6.1.1";
8
+ export declare const pkgVersion = "2.0.0-internal.6.3.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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/container-loader";
11
- exports.pkgVersion = "2.0.0-internal.6.1.1";
11
+ exports.pkgVersion = "2.0.0-internal.6.3.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,sBAAsB,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/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.6.1.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,kCAAkC,CAAC;AAC7C,QAAA,UAAU,GAAG,sBAAsB,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/container-loader\";\nexport const pkgVersion = \"2.0.0-internal.6.3.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,WAAW,EACX,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,qBAAa,+BAAgC,YAAW,uBAAuB,EAAE,WAAW;IAG1F,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHxB,OAAO,CAAC,SAAS,CAAS;gBAER,sBAAsB,EAAE,uBAAuB,EAC/C,MAAM,EAAE,mBAAmB;IAG7C,IAAW,QAAQ,IAAI,+BAA+B,GAAG,SAAS,CAEjE;IACD,IAAW,QAAQ,YAElB;IACM,OAAO;IAId,IAAW,aAAa,IAAI,MAAM,CAEjC;IAEY,eAAe,CAC3B,OAAO,CAAC,EAAE,QAAQ,EAClB,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOnB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACvB,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EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOnB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAO9C,WAAW,CACvB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,KAAK,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;IAaT,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAyBL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAO9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
@@ -5,8 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RetriableDocumentStorageService = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
9
- const container_utils_1 = require("@fluidframework/container-utils");
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
10
10
  const driver_utils_1 = require("@fluidframework/driver-utils");
11
11
  class RetriableDocumentStorageService {
12
12
  constructor(internalStorageService, logger) {
@@ -45,7 +45,7 @@ class RetriableDocumentStorageService {
45
45
  // upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take
46
46
  // retryAfter into account!
47
47
  // But retry loop is required for creation flow (Container.attach)
48
- (0, common_utils_1.assert)((context.referenceSequenceNumber === 0) === (context.ackHandle === undefined), 0x251 /* "creation summary has to have seq=0 && handle === undefined" */);
48
+ (0, core_utils_1.assert)((context.referenceSequenceNumber === 0) === (context.ackHandle === undefined), 0x251 /* "creation summary has to have seq=0 && handle === undefined" */);
49
49
  if (context.referenceSequenceNumber !== 0) {
50
50
  return this.internalStorageService.uploadSummaryWithContext(summary, context);
51
51
  }
@@ -65,7 +65,7 @@ class RetriableDocumentStorageService {
65
65
  fetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts
66
66
  }, error);
67
67
  // pre-0.58 error message: storageServiceDisposedCannotRetry
68
- throw new container_utils_1.GenericError("Storage Service is disposed. Cannot retry", {
68
+ throw new telemetry_utils_1.GenericError("Storage Service is disposed. Cannot retry", {
69
69
  canRetry: false,
70
70
  });
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AACtD,qEAA+D;AAiB/D,+DAA4D;AAE5D,MAAa,+BAA+B;IAE3C,YACkB,sBAA+C,EAC/C,MAA2B;QAD3B,2BAAsB,GAAtB,sBAAsB,CAAyB;QAC/C,WAAM,GAAN,MAAM,CAAqB;QAHrC,cAAS,GAAG,KAAK,CAAC;IAIvB,CAAC;IAEJ,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACM,OAAO;QACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,OAAkB,EAClB,YAAqB;QAErB,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,EAC9E,yBAAyB,CACzB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,OAAO,IAAI,CAAC,YAAY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AK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,EACxD,oBAAoB,CACpB,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,QAAgB,EAAE,KAAc;QAC5D,IAAI,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAC7B;gBACC,SAAS,EAAE,GAAG,QAAQ,yBAAyB;gBAC/C,aAAa,EAAE,QAAQ,EAAE,gDAAgD;aACzE,EACD,KAAK,CACL,CAAC;YACF,4DAA4D;YAC5D,MAAM,IAAI,8BAAY,CAAC,2CAA2C,EAAE;gBACnE,QAAQ,EAAE,KAAK;aACf,CAAC,CAAC;SACH;QACD,OAAO;IACR,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACpE,OAAO,IAAA,2BAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AAzHD,0EAyHC","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 { GenericError } from \"@fluidframework/container-utils\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\n\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.getSnapshotTree(version, scenarioName),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.readBlob(id),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageService.getVersions(\n\t\t\t\t\tversionId,\n\t\t\t\t\tcount,\n\t\t\t\t\tscenarioName,\n\t\t\t\t\tfetchSource,\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.downloadSummary(handle),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.createBlob(file),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"retriableDocumentStorageService.js","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAepD,qEAAoF;AACpF,+DAA4D;AAE5D,MAAa,+BAA+B;IAE3C,YACkB,sBAA+C,EAC/C,MAA2B;QAD3B,2BAAsB,GAAtB,sBAAsB,CAAyB;QAC/C,WAAM,GAAN,MAAM,CAAqB;QAHrC,cAAS,GAAG,KAAK,CAAC;IAIvB,CAAC;IAEJ,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAC7C,CAAC;IACD,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACM,OAAO;QACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,eAAe,CAC3B,OAAkB,EAClB,YAAqB;QAErB,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,EAC9E,yBAAyB,CACzB,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC/B,OAAO,IAAI,CAAC,YAAY,CACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,EAAE,CAAC,EACpD,kBAAkB,CAClB,CAAC;IACH,CAAC;IAEM,KAA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AAI,CAAC,EACxD,oBAAoB,CACpB,CAAC;IACH,CAAC;IAEO,oBAAoB,CAAC,QAAgB,EAAE,KAAc;QAC5D,IAAI,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAC7B;gBACC,SAAS,EAAE,GAAG,QAAQ,yBAAyB;gBAC/C,aAAa,EAAE,QAAQ,EAAE,gDAAgD;aACzE,EACD,KAAK,CACL,CAAC;YACF,4DAA4D;YAC5D,MAAM,IAAI,8BAAY,CAAC,2CAA2C,EAAE;gBACnE,QAAQ,EAAE,KAAK;aACf,CAAC,CAAC;SACH;QACD,OAAO;IACR,CAAC;IAEO,KAAK,CAAC,YAAY,CAAI,GAAqB,EAAE,QAAgB;QACpE,OAAO,IAAA,2BAAY,EAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE;YAC/C,OAAO,EAAE,CAAC,UAAkB,EAAE,KAAc,EAAE,EAAE,CAC/C,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC3C,CAAC,CAAC;IACJ,CAAC;CACD;AAzHD,0EAyHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\tFetchSource,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { GenericError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { runWithRetry } from \"@fluidframework/driver-utils\";\n\nexport class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {\n\tprivate _disposed = false;\n\tconstructor(\n\t\tprivate readonly internalStorageService: IDocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\treturn this.internalStorageService.policies;\n\t}\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n\n\tpublic get repositoryUrl(): string {\n\t\treturn this.internalStorageService.repositoryUrl;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | null> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.getSnapshotTree(version, scenarioName),\n\t\t\t\"storage_getSnapshotTree\",\n\t\t);\n\t}\n\n\tpublic async readBlob(id: string): Promise<ArrayBufferLike> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.readBlob(id),\n\t\t\t\"storage_readBlob\",\n\t\t);\n\t}\n\n\tpublic async getVersions(\n\t\tversionId: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () =>\n\t\t\t\tthis.internalStorageService.getVersions(\n\t\t\t\t\tversionId,\n\t\t\t\t\tcount,\n\t\t\t\t\tscenarioName,\n\t\t\t\t\tfetchSource,\n\t\t\t\t),\n\t\t\t\"storage_getVersions\",\n\t\t);\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\t// Not using retry loop here. Couple reasons:\n\t\t// 1. If client lost connectivity, then retry loop will result in uploading stale summary\n\t\t// by stale summarizer after connectivity comes back. It will cause failures for this client and for\n\t\t// real (new) summarizer. This problem in particular should be solved in future by supplying abort handle\n\t\t// on all APIs and caller (ContainerRuntime.submitSummary) aborting call on loss of connectivity\n\t\t// 2. Similar, if we get 429 with retryAfter = 10 minutes, it's likely not the right call to retry summary\n\t\t// upload in 10 minutes - it's better to keep processing ops and retry later. Though caller needs to take\n\t\t// retryAfter into account!\n\t\t// But retry loop is required for creation flow (Container.attach)\n\t\tassert(\n\t\t\t(context.referenceSequenceNumber === 0) === (context.ackHandle === undefined),\n\t\t\t0x251 /* \"creation summary has to have seq=0 && handle === undefined\" */,\n\t\t);\n\t\tif (context.referenceSequenceNumber !== 0) {\n\t\t\treturn this.internalStorageService.uploadSummaryWithContext(summary, context);\n\t\t}\n\n\t\t// Creation flow with attachment blobs - need to do retries!\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.uploadSummaryWithContext(summary, context),\n\t\t\t\"storage_uploadSummaryWithContext\",\n\t\t);\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.downloadSummary(handle),\n\t\t\t\"storage_downloadSummary\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\treturn this.runWithRetry(\n\t\t\tasync () => this.internalStorageService.createBlob(file),\n\t\t\t\"storage_createBlob\",\n\t\t);\n\t}\n\n\tprivate checkStorageDisposed(callName: string, error: unknown) {\n\t\tif (this._disposed) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: `${callName}_abortedStorageDisposed`,\n\t\t\t\t\tfetchCallName: callName, // fetchCallName matches logs in runWithRetry.ts\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\t// pre-0.58 error message: storageServiceDisposedCannotRetry\n\t\t\tthrow new GenericError(\"Storage Service is disposed. Cannot retry\", {\n\t\t\t\tcanRetry: false,\n\t\t\t});\n\t\t}\n\t\treturn;\n\t}\n\n\tprivate async runWithRetry<T>(api: () => Promise<T>, callName: string): Promise<T> {\n\t\treturn runWithRetry(api, callName, this.logger, {\n\t\t\tonRetry: (_delayInMs: number, error: unknown) =>\n\t\t\t\tthis.checkStorageDisposed(callName, error),\n\t\t});\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,EAEnC,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IACnE,aAAa,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IACnD,KAAK,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC;CACzD;AAED,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAW5D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,6BAA6B,CAiB/B;AA0DD;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,mBAAmB,EAAE,YAAY,EACjC,cAAc,EAAE,YAAY,GAC1B,6BAA6B,CAW/B;AAID,eAAO,MAAM,sCAAsC,8BACvB,YAAY,KACrC,6BAYF,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAE9E;AAED,wBAAgB,qCAAqC,CACpD,KAAK,EAAE,GAAG,GACR,KAAK,IAAI,mCAAmC,CAM9C"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAEhG,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,EAEnC,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IACnE,aAAa,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAC;IACnD,KAAK,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,CAAA;KAAE,CAAC;CACzD;AAED,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAW5D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,6BAA6B,CAiB/B;AA0DD;;;;GAIG;AACH,wBAAgB,0CAA0C,CACzD,mBAAmB,EAAE,YAAY,EACjC,cAAc,EAAE,YAAY,GAC1B,6BAA6B,CAW/B;AAID,eAAO,MAAM,sCAAsC,8BACvB,YAAY,KACrC,6BAYF,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAE9E;AAED,wBAAgB,qCAAqC,CACpD,KAAK,EAAE,GAAG,GACR,KAAK,IAAI,mCAAmC,CAM9C"}
package/dist/utils.js CHANGED
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.isDeltaStreamConnectionForbiddenError = exports.getProtocolSnapshotTree = exports.getSnapshotTreeFromSerializedContainer = exports.convertProtocolAndAppSummaryToSnapshotTree = exports.combineAppAndProtocolSummary = exports.parseUrl = void 0;
8
8
  const url_1 = require("url");
9
9
  const uuid_1 = require("uuid");
10
- const common_utils_1 = require("@fluidframework/common-utils");
10
+ const client_utils_1 = require("@fluid-internal/client-utils");
11
+ const core_utils_1 = require("@fluidframework/core-utils");
11
12
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
12
13
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
13
14
  const driver_utils_1 = require("@fluidframework/driver-utils");
@@ -32,8 +33,8 @@ exports.parseUrl = parseUrl;
32
33
  * @internal
33
34
  */
34
35
  function combineAppAndProtocolSummary(appSummary, protocolSummary) {
35
- (0, common_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(appSummary), 0x5a8 /* app summary is already a combined tree! */);
36
- (0, common_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
36
+ (0, core_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(appSummary), 0x5a8 /* app summary is already a combined tree! */);
37
+ (0, core_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
37
38
  const createNewSummary = {
38
39
  type: protocol_definitions_1.SummaryType.Tree,
39
40
  tree: {
@@ -78,8 +79,8 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
78
79
  const blobId = (0, uuid_1.v4)();
79
80
  treeNode.blobs[key] = blobId;
80
81
  const contentBuffer = typeof summaryObject.content === "string"
81
- ? (0, common_utils_1.stringToBuffer)(summaryObject.content, "utf8")
82
- : (0, common_utils_1.Uint8ArrayToArrayBuffer)(summaryObject.content);
82
+ ? (0, client_utils_1.stringToBuffer)(summaryObject.content, "utf8")
83
+ : (0, client_utils_1.Uint8ArrayToArrayBuffer)(summaryObject.content);
83
84
  treeNode.blobsContents[blobId] = contentBuffer;
84
85
  break;
85
86
  }
@@ -87,7 +88,7 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
87
88
  throw new telemetry_utils_1.LoggingError("No handles should be there in summary in detached container!!");
88
89
  break;
89
90
  default: {
90
- (0, common_utils_1.unreachableCase)(summaryObject, `Unknown tree type ${summaryObject.type}`);
91
+ (0, core_utils_1.unreachableCase)(summaryObject, `Unknown tree type ${summaryObject.type}`);
91
92
  }
92
93
  }
93
94
  }
@@ -112,7 +113,7 @@ exports.convertProtocolAndAppSummaryToSnapshotTree = convertProtocolAndAppSummar
112
113
  // This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which
113
114
  // a detached container can be rehydrated.
114
115
  const getSnapshotTreeFromSerializedContainer = (detachedContainerSnapshot) => {
115
- (0, common_utils_1.assert)((0, driver_utils_1.isCombinedAppAndProtocolSummary)(detachedContainerSnapshot), 0x1e0 /* "Protocol and App summary trees should be present" */);
116
+ (0, core_utils_1.assert)((0, driver_utils_1.isCombinedAppAndProtocolSummary)(detachedContainerSnapshot), 0x1e0 /* "Protocol and App summary trees should be present" */);
116
117
  const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
117
118
  const appSummaryTree = detachedContainerSnapshot.tree[".app"];
118
119
  const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree, appSummaryTree);
@@ -126,7 +127,7 @@ exports.getProtocolSnapshotTree = getProtocolSnapshotTree;
126
127
  function isDeltaStreamConnectionForbiddenError(error) {
127
128
  return (typeof error === "object" &&
128
129
  error !== null &&
129
- error?.errorType === driver_definitions_1.DriverErrorType.deltaStreamConnectionForbidden);
130
+ error?.errorType === driver_definitions_1.DriverErrorTypes.deltaStreamConnectionForbidden);
130
131
  }
131
132
  exports.isDeltaStreamConnectionForbiddenError = isDeltaStreamConnectionForbiddenError;
132
133
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"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E,CAAC;AAFD,0DAEC;AAED,SAAgB,qCAAqC,CACpD,KAAU;IAEV,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,EAAE,SAAS,KAAK,oCAAe,CAAC,8BAA8B,CACnE,CAAC;AACH,CAAC;AARD,sFAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tassert,\n\tstringToBuffer,\n\tUint8ArrayToArrayBuffer,\n\tunreachableCase,\n} from \"@fluidframework/common-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\nexport interface IParsedUrl {\n\tid: string;\n\tpath: string;\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\nexport function parseUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): ISnapshotTreeWithBlobContents => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorType.deltaStreamConnectionForbidden\n\t);\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAC5B,+BAAkC;AAClC,+DAAuF;AACvF,2DAAqE;AACrE,+EAAgG;AAChG,qEAA+D;AAC/D,+DAIsC;AACtC,2EAAsE;AAqBtE,SAAgB,QAAQ,CAAC,GAAW;IACnC,MAAM,MAAM,GAAG,IAAA,WAAK,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACxC,MAAM,IAAI,8BAAY,CAAC,0BAA0B,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,K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AC;IACnE,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAdD,gGAcC;AAED,+GAA+G;AAC/G,0CAA0C;AACnC,MAAM,sCAAsC,GAAG,CACrD,yBAAuC,EACP,EAAE;IAClC,IAAA,mBAAM,EACL,IAAA,8CAA+B,EAAC,yBAAyB,CAAC,EAC1D,KAAK,CAAC,wDAAwD,CAC9D,CAAC;IACF,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,4BAA4B,GAAG,0CAA0C,CAC9E,mBAAmB,EACnB,cAAc,CACd,CAAC;IACF,OAAO,4BAA4B,CAAC;AACrC,CAAC,CAAC;AAdW,QAAA,sCAAsC,0CAcjD;AAEF,SAAgB,uBAAuB,CAAC,QAAuB;IAC9D,OAAO,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC;AAFD,0DAEC;AAED,SAAgB,qCAAqC,CACpD,KAAU;IAEV,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,EAAE,SAAS,KAAK,qCAAgB,CAAC,8BAA8B,CACpE,CAAC;AACH,CAAC;AARD,sFAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport { stringToBuffer, Uint8ArrayToArrayBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\nexport interface IParsedUrl {\n\tid: string;\n\tpath: string;\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\nexport function parseUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): ISnapshotTreeWithBlobContents => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n"]}
package/lib/audience.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { EventEmitter } from "events";
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
  /**
8
8
  * Audience represents all clients connected to the op stream.
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAGzC;QACC,KAAK,EAAE,CAAC;QAHQ,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAIrD,kHAAkH;QAClH,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAMM,EAAE,CAAC,KAAa,EAAE,QAAkC;QAC1D,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB,EAAE,OAAgB;QAClD,mGAAmG;QACnG,+FAA+F;QAC/F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1C,MAAM,CACL,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;SACF;aAAM;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SAC1C;IACF,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,QAAgB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;SACZ;aAAM;YACN,OAAO,KAAK,CAAC;SACb;IACF,CAAC;IAED;;OAEG;IACI,UAAU;QAChB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends EventEmitter implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic on(\n\t\tevent: \"addMember\" | \"removeMember\",\n\t\tlistener: (clientId: string, client: IClient) => void,\n\t): this;\n\tpublic on(event: string, listener: (...args: any[]) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
1
+ {"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAIpD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAGzC;QACC,KAAK,EAAE,CAAC;QAHQ,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAIrD,kHAAkH;QAClH,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAMM,EAAE,CAAC,KAAa,EAAE,Q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soft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends EventEmitter implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic on(\n\t\tevent: \"addMember\" | \"removeMember\",\n\t\tlistener: (clientId: string, client: IClient) => void,\n\t): this;\n\tpublic on(event: string, listener: (...args: any[]) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/common-utils";
5
+ import { assert } from "@fluidframework/core-utils";
6
6
  /**
7
7
  * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed
8
8
  * that were known at the time the monitor was created.