@fluidframework/container-loader 2.0.0-internal.5.3.2 → 2.0.0-internal.6.0.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 (124) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +6 -3
  3. package/dist/audience.d.ts +1 -0
  4. package/dist/audience.d.ts.map +1 -1
  5. package/dist/audience.js +3 -1
  6. package/dist/audience.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 +30 -36
  10. package/dist/connectionManager.js.map +1 -1
  11. package/dist/connectionStateHandler.d.ts +2 -1
  12. package/dist/connectionStateHandler.d.ts.map +1 -1
  13. package/dist/connectionStateHandler.js +9 -16
  14. package/dist/connectionStateHandler.js.map +1 -1
  15. package/dist/container.d.ts +12 -8
  16. package/dist/container.d.ts.map +1 -1
  17. package/dist/container.js +199 -156
  18. package/dist/container.js.map +1 -1
  19. package/dist/containerContext.d.ts +2 -12
  20. package/dist/containerContext.d.ts.map +1 -1
  21. package/dist/containerContext.js +1 -20
  22. package/dist/containerContext.js.map +1 -1
  23. package/dist/containerStorageAdapter.js +3 -5
  24. package/dist/containerStorageAdapter.js.map +1 -1
  25. package/dist/contracts.d.ts +11 -2
  26. package/dist/contracts.d.ts.map +1 -1
  27. package/dist/contracts.js +3 -3
  28. package/dist/contracts.js.map +1 -1
  29. package/dist/debugLogger.d.ts +30 -0
  30. package/dist/debugLogger.d.ts.map +1 -0
  31. package/dist/debugLogger.js +95 -0
  32. package/dist/debugLogger.js.map +1 -0
  33. package/dist/deltaManager.d.ts +16 -4
  34. package/dist/deltaManager.d.ts.map +1 -1
  35. package/dist/deltaManager.js +79 -33
  36. package/dist/deltaManager.js.map +1 -1
  37. package/dist/deltaQueue.js +1 -2
  38. package/dist/deltaQueue.js.map +1 -1
  39. package/dist/loader.d.ts +12 -0
  40. package/dist/loader.d.ts.map +1 -1
  41. package/dist/loader.js +73 -47
  42. package/dist/loader.js.map +1 -1
  43. package/dist/packageVersion.d.ts +1 -1
  44. package/dist/packageVersion.js +1 -1
  45. package/dist/packageVersion.js.map +1 -1
  46. package/dist/protocol.d.ts.map +1 -1
  47. package/dist/protocol.js +2 -3
  48. package/dist/protocol.js.map +1 -1
  49. package/dist/quorum.d.ts +4 -1
  50. package/dist/quorum.d.ts.map +1 -1
  51. package/dist/quorum.js +1 -13
  52. package/dist/quorum.js.map +1 -1
  53. package/dist/utils.d.ts +8 -1
  54. package/dist/utils.d.ts.map +1 -1
  55. package/dist/utils.js +24 -6
  56. package/dist/utils.js.map +1 -1
  57. package/lib/audience.d.ts +1 -0
  58. package/lib/audience.d.ts.map +1 -1
  59. package/lib/audience.js +3 -1
  60. package/lib/audience.js.map +1 -1
  61. package/lib/connectionManager.d.ts +1 -1
  62. package/lib/connectionManager.d.ts.map +1 -1
  63. package/lib/connectionManager.js +32 -35
  64. package/lib/connectionManager.js.map +1 -1
  65. package/lib/connectionStateHandler.d.ts +2 -1
  66. package/lib/connectionStateHandler.d.ts.map +1 -1
  67. package/lib/connectionStateHandler.js +9 -16
  68. package/lib/connectionStateHandler.js.map +1 -1
  69. package/lib/container.d.ts +12 -8
  70. package/lib/container.d.ts.map +1 -1
  71. package/lib/container.js +200 -157
  72. package/lib/container.js.map +1 -1
  73. package/lib/containerContext.d.ts +2 -12
  74. package/lib/containerContext.d.ts.map +1 -1
  75. package/lib/containerContext.js +1 -20
  76. package/lib/containerContext.js.map +1 -1
  77. package/lib/containerStorageAdapter.js +3 -5
  78. package/lib/containerStorageAdapter.js.map +1 -1
  79. package/lib/contracts.d.ts +11 -2
  80. package/lib/contracts.d.ts.map +1 -1
  81. package/lib/contracts.js +3 -3
  82. package/lib/contracts.js.map +1 -1
  83. package/lib/debugLogger.d.ts +30 -0
  84. package/lib/debugLogger.d.ts.map +1 -0
  85. package/lib/debugLogger.js +91 -0
  86. package/lib/debugLogger.js.map +1 -0
  87. package/lib/deltaManager.d.ts +16 -4
  88. package/lib/deltaManager.d.ts.map +1 -1
  89. package/lib/deltaManager.js +77 -28
  90. package/lib/deltaManager.js.map +1 -1
  91. package/lib/deltaQueue.js +1 -2
  92. package/lib/deltaQueue.js.map +1 -1
  93. package/lib/loader.d.ts +12 -0
  94. package/lib/loader.d.ts.map +1 -1
  95. package/lib/loader.js +73 -47
  96. package/lib/loader.js.map +1 -1
  97. package/lib/packageVersion.d.ts +1 -1
  98. package/lib/packageVersion.js +1 -1
  99. package/lib/packageVersion.js.map +1 -1
  100. package/lib/protocol.d.ts.map +1 -1
  101. package/lib/protocol.js +2 -3
  102. package/lib/protocol.js.map +1 -1
  103. package/lib/quorum.d.ts +4 -1
  104. package/lib/quorum.d.ts.map +1 -1
  105. package/lib/quorum.js +0 -11
  106. package/lib/quorum.js.map +1 -1
  107. package/lib/utils.d.ts +8 -1
  108. package/lib/utils.d.ts.map +1 -1
  109. package/lib/utils.js +22 -5
  110. package/lib/utils.js.map +1 -1
  111. package/package.json +14 -14
  112. package/src/audience.ts +6 -0
  113. package/src/connectionManager.ts +13 -14
  114. package/src/connectionStateHandler.ts +3 -2
  115. package/src/container.ts +178 -120
  116. package/src/containerContext.ts +0 -24
  117. package/src/contracts.ts +16 -5
  118. package/src/debugLogger.ts +113 -0
  119. package/src/deltaManager.ts +50 -9
  120. package/src/loader.ts +53 -30
  121. package/src/packageVersion.ts +1 -1
  122. package/src/protocol.ts +0 -1
  123. package/src/quorum.ts +0 -10
  124. package/src/utils.ts +29 -0
@@ -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,mCAAmC,EAEnC,MAAM,8BAA8B,CAAC;AAKtC,MAAM,WAAW,6BAA8B,SAAQ,aAAa;IACnE,aAAa,EAAE;QAAE,CAAC,I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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/lib/utils.js CHANGED
@@ -10,18 +10,35 @@ import { LoggingError } from "@fluidframework/telemetry-utils";
10
10
  import { isCombinedAppAndProtocolSummary, } from "@fluidframework/driver-utils";
11
11
  import { DriverErrorType } from "@fluidframework/driver-definitions";
12
12
  export function parseUrl(url) {
13
- var _a;
14
13
  const parsed = parse(url, true);
15
14
  if (typeof parsed.pathname !== "string") {
16
15
  throw new LoggingError("Failed to parse pathname");
17
16
  }
18
- const query = (_a = parsed.search) !== null && _a !== void 0 ? _a : "";
17
+ const query = parsed.search ?? "";
19
18
  const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
20
19
  const match = regex.exec(parsed.pathname);
21
- return (match === null || match === void 0 ? void 0 : match.length) === 3
20
+ return match?.length === 3
22
21
  ? { id: match[1], path: match[2], query, version: parsed.query.version }
23
22
  : undefined;
24
23
  }
24
+ /**
25
+ * Combine the app summary and protocol summary in 1 tree.
26
+ * @param appSummary - Summary of the app.
27
+ * @param protocolSummary - Summary of the protocol.
28
+ * @internal
29
+ */
30
+ export function combineAppAndProtocolSummary(appSummary, protocolSummary) {
31
+ assert(!isCombinedAppAndProtocolSummary(appSummary), 0x5a8 /* app summary is already a combined tree! */);
32
+ assert(!isCombinedAppAndProtocolSummary(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
33
+ const createNewSummary = {
34
+ type: SummaryType.Tree,
35
+ tree: {
36
+ ".protocol": protocolSummary,
37
+ ".app": appSummary,
38
+ },
39
+ };
40
+ return createNewSummary;
41
+ }
25
42
  /**
26
43
  * Converts summary tree (for upload) to snapshot tree (for download).
27
44
  * Summary tree blobs contain contents, but snapshot tree blobs normally
@@ -80,7 +97,7 @@ export function convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree,
80
97
  // Shallow copy is fine, since we are doing a deep clone below.
81
98
  const combinedSummary = {
82
99
  type: SummaryType.Tree,
83
- tree: Object.assign({}, appSummaryTree.tree),
100
+ tree: { ...appSummaryTree.tree },
84
101
  };
85
102
  combinedSummary.tree[".protocol"] = protocolSummaryTree;
86
103
  const snapshotTreeWithBlobContents = convertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);
@@ -101,6 +118,6 @@ export function getProtocolSnapshotTree(snapshot) {
101
118
  export function isDeltaStreamConnectionForbiddenError(error) {
102
119
  return (typeof error === "object" &&
103
120
  error !== null &&
104
- (error === null || error === void 0 ? void 0 : error.errorType) === DriverErrorType.deltaStreamConnectionForbidden);
121
+ error?.errorType === DriverErrorType.deltaStreamConnectionForbidden);
105
122
  }
106
123
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,MAAM,EACN,cAAc,EACd,uBAAuB,EACvB,eAAe,GACf,MAA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Ac,CAAC,IAAI,CAAE;KAChC,CAAC;IAEF,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,mBAAmB,CAAC;IACxD,MAAM,4BAA4B,GACjC,gDAAgD,CAAC,eAAe,CAAC,CAAC;IACnE,OAAO,4BAA4B,CAAC;AACrC,CAAC;AAED,+GAA+G;AAC/G,0CAA0C;AAC1C,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACrD,yBAAuC,EACP,EAAE;IAClC,MAAM,CACL,+BAA+B,CAAC,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;AAEF,MAAM,UAAU,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;AAED,MAAM,UAAU,qCAAqC,CACpD,KAAU;IAEV,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,MAAK,eAAe,CAAC,8BAA8B,CACnE,CAAC;AACH,CAAC","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\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 * 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,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAC5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EACN,MAAM,EACN,cAAc,EACd,uBAAuB,EACvB,eAAe,GACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAA+B,WAAW,EAAE,MAAM,sCAAsC,CAAC;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AAK,KAAK,IAAI;QACd,KAAK,EAAE,SAAS,KAAK,eAAe,CAAC,8BAA8B,CACnE,CAAC;AACH,CAAC","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-loader",
3
- "version": "2.0.0-internal.5.3.2",
3
+ "version": "2.0.0-internal.6.0.0",
4
4
  "description": "Fluid container loader",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,15 +37,15 @@
37
37
  "dependencies": {
38
38
  "@fluidframework/common-definitions": "^0.20.1",
39
39
  "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/container-definitions": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
41
- "@fluidframework/container-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
42
- "@fluidframework/core-interfaces": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
43
- "@fluidframework/driver-definitions": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
44
- "@fluidframework/driver-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
45
- "@fluidframework/protocol-base": "^0.1039.1000",
40
+ "@fluidframework/container-definitions": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
41
+ "@fluidframework/container-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
42
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
43
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
44
+ "@fluidframework/driver-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
45
+ "@fluidframework/protocol-base": "^1.0.0",
46
46
  "@fluidframework/protocol-definitions": "^1.1.0",
47
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
48
- "abort-controller": "^3.0.0",
47
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
48
+ "debug": "^4.1.1",
49
49
  "double-ended-queue": "^2.1.0-0",
50
50
  "events": "^3.1.0",
51
51
  "lodash": "^4.17.21",
@@ -53,19 +53,19 @@
53
53
  "uuid": "^8.3.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@fluid-internal/test-loader-utils": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
56
+ "@fluid-internal/test-loader-utils": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
57
57
  "@fluid-tools/build-cli": "^0.21.0",
58
- "@fluidframework/build-common": "^1.2.0",
58
+ "@fluidframework/build-common": "^2.0.0",
59
59
  "@fluidframework/build-tools": "^0.21.0",
60
60
  "@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@2.0.0-internal.5.2.0",
61
61
  "@fluidframework/eslint-config-fluid": "^2.0.0",
62
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.3.2 <2.0.0-internal.5.4.0",
62
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.0.0 <2.0.0-internal.6.1.0",
63
63
  "@microsoft/api-extractor": "^7.34.4",
64
64
  "@types/double-ended-queue": "^2.1.0",
65
65
  "@types/events": "^3.0.0",
66
66
  "@types/lodash": "^4.14.118",
67
67
  "@types/mocha": "^9.1.1",
68
- "@types/node": "^14.18.38",
68
+ "@types/node": "^16.18.38",
69
69
  "@types/sinon": "^7.0.13",
70
70
  "concurrently": "^7.6.0",
71
71
  "copyfiles": "^2.4.1",
@@ -97,7 +97,7 @@
97
97
  "build:genver": "gen-version",
98
98
  "build:test": "tsc --project ./src/test/tsconfig.json",
99
99
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
100
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
100
+ "clean": "rimraf --glob \"dist\" \"lib\" \"*.tsbuildinfo\" \"*.build.log\"",
101
101
  "eslint": "eslint --format stylish src",
102
102
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
103
103
  "format": "npm run prettier:fix",
package/src/audience.ts CHANGED
@@ -13,6 +13,12 @@ import { IClient } from "@fluidframework/protocol-definitions";
13
13
  export class Audience extends EventEmitter implements IAudienceOwner {
14
14
  private readonly members = new Map<string, IClient>();
15
15
 
16
+ constructor() {
17
+ super();
18
+ // We are expecting this class to have many listeners, so we suppress noisy "MaxListenersExceededWarning" logging.
19
+ super.setMaxListeners(0);
20
+ }
21
+
16
22
  public on(
17
23
  event: "addMember" | "removeMember",
18
24
  listener: (clientId: string, client: IClient) => void,
@@ -3,14 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { default as AbortController } from "abort-controller";
7
6
  import { IDisposable, ITelemetryProperties } from "@fluidframework/core-interfaces";
8
7
  import { assert, performance, TypedEventEmitter } from "@fluidframework/common-utils";
9
8
  import {
9
+ ICriticalContainerError,
10
10
  IDeltaQueue,
11
11
  ReadOnlyInfo,
12
- IConnectionDetailsInternal,
13
- ICriticalContainerError,
14
12
  } from "@fluidframework/container-definitions";
15
13
  import { GenericError, UsageError } from "@fluidframework/container-utils";
16
14
  import {
@@ -26,6 +24,7 @@ import {
26
24
  getRetryDelayFromError,
27
25
  logNetworkFailure,
28
26
  isRuntimeMessage,
27
+ calculateMaxWaitTime,
29
28
  } from "@fluidframework/driver-utils";
30
29
  import {
31
30
  ConnectionMode,
@@ -43,17 +42,17 @@ import {
43
42
  ScopeType,
44
43
  ISequencedDocumentSystemMessage,
45
44
  } from "@fluidframework/protocol-definitions";
45
+ import { ITelemetryLoggerExt, formatTick, normalizeError } from "@fluidframework/telemetry-utils";
46
46
  import {
47
- ITelemetryLoggerExt,
48
- TelemetryLogger,
49
- normalizeError,
50
- } from "@fluidframework/telemetry-utils";
51
- import { ReconnectMode, IConnectionManager, IConnectionManagerFactoryArgs } from "./contracts";
47
+ ReconnectMode,
48
+ IConnectionManager,
49
+ IConnectionManagerFactoryArgs,
50
+ IConnectionDetailsInternal,
51
+ } from "./contracts";
52
52
  import { DeltaQueue } from "./deltaQueue";
53
53
  import { SignalType } from "./protocol";
54
54
  import { isDeltaStreamConnectionForbiddenError } from "./utils";
55
55
 
56
- const MaxReconnectDelayInMs = 8000;
57
56
  const InitialReconnectDelayInMs = 1000;
58
57
  const DefaultChunkSize = 16 * 1024;
59
58
 
@@ -553,7 +552,7 @@ export class ConnectionManager implements IConnectionManager {
553
552
  this.logger.sendTelemetryEvent({
554
553
  eventName: "ConnectionAttemptCancelled",
555
554
  attempts: connectRepeatCount,
556
- duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),
555
+ duration: formatTick(performance.now() - connectStartTime),
557
556
  connectionEstablished: false,
558
557
  });
559
558
  return;
@@ -593,7 +592,7 @@ export class ConnectionManager implements IConnectionManager {
593
592
  attempts: connectRepeatCount,
594
593
  delay: delayMs, // milliseconds
595
594
  eventName: "DeltaConnectionFailureToConnect",
596
- duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),
595
+ duration: formatTick(performance.now() - connectStartTime),
597
596
  },
598
597
  origError,
599
598
  );
@@ -613,7 +612,7 @@ export class ConnectionManager implements IConnectionManager {
613
612
  // We skip this delay if we're confident we're offline, because we probably just need to wait to come back online.
614
613
  await new Promise<void>((resolve) => {
615
614
  setTimeout(resolve, delayMs);
616
- delayMs = Math.min(delayMs * 2, MaxReconnectDelayInMs);
615
+ delayMs = Math.min(delayMs * 2, calculateMaxWaitTime(origError));
617
616
  });
618
617
  }
619
618
 
@@ -639,7 +638,7 @@ export class ConnectionManager implements IConnectionManager {
639
638
  {
640
639
  eventName: "MultipleDeltaConnectionFailures",
641
640
  attempts: connectRepeatCount,
642
- duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),
641
+ duration: formatTick(performance.now() - connectStartTime),
643
642
  },
644
643
  lastError,
645
644
  );
@@ -651,7 +650,7 @@ export class ConnectionManager implements IConnectionManager {
651
650
  this.logger.sendTelemetryEvent({
652
651
  eventName: "ConnectionAttemptCancelled",
653
652
  attempts: connectRepeatCount,
654
- duration: TelemetryLogger.formatTick(performance.now() - connectStartTime),
653
+ duration: formatTick(performance.now() - connectStartTime),
655
654
  connectionEstablished: true,
656
655
  });
657
656
  return;
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { ITelemetryProperties, TelemetryEventCategory } from "@fluidframework/core-interfaces";
7
7
  import { assert, Timer } from "@fluidframework/common-utils";
8
- import { IConnectionDetailsInternal, IDeltaManager } from "@fluidframework/container-definitions";
8
+ import { IDeltaManager } from "@fluidframework/container-definitions";
9
9
  import { IAnyDriverError } from "@fluidframework/driver-definitions";
10
10
  import { ISequencedClient, IClient } from "@fluidframework/protocol-definitions";
11
11
  import {
@@ -13,8 +13,9 @@ import {
13
13
  PerformanceEvent,
14
14
  loggerToMonitoringContext,
15
15
  } from "@fluidframework/telemetry-utils";
16
- import { ConnectionState } from "./connectionState";
17
16
  import { CatchUpMonitor, ICatchUpMonitor } from "./catchUpMonitor";
17
+ import { ConnectionState } from "./connectionState";
18
+ import { IConnectionDetailsInternal } from "./contracts";
18
19
  import { IProtocolHandler } from "./protocol";
19
20
 
20
21
  // Based on recent data, it looks like majority of cases where we get stuck are due to really slow or