@fluidframework/container-loader 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -21
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +364 -0
- package/README.md +152 -56
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/container-loader.api.md +143 -0
- package/dist/{audience.js → audience.cjs} +15 -13
- package/dist/audience.cjs.map +1 -0
- package/dist/audience.d.ts +3 -6
- package/dist/audience.d.ts.map +1 -1
- package/dist/catchUpMonitor.cjs +43 -0
- package/dist/catchUpMonitor.cjs.map +1 -0
- package/dist/catchUpMonitor.d.ts +29 -0
- package/dist/catchUpMonitor.d.ts.map +1 -0
- package/dist/{connectionManager.js → connectionManager.cjs} +397 -240
- package/dist/connectionManager.cjs.map +1 -0
- package/dist/connectionManager.d.ts +23 -33
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/{connectionState.js → connectionState.cjs} +5 -7
- package/dist/connectionState.cjs.map +1 -0
- package/dist/connectionState.d.ts +3 -5
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionStateHandler.cjs +474 -0
- package/dist/connectionStateHandler.cjs.map +1 -0
- package/dist/connectionStateHandler.d.ts +127 -29
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/container-loader-alpha.d.ts +274 -0
- package/dist/container-loader-beta.d.ts +75 -0
- package/dist/container-loader-public.d.ts +75 -0
- package/dist/container-loader-untrimmed.d.ts +331 -0
- package/dist/container.cjs +1585 -0
- package/dist/container.cjs.map +1 -0
- package/dist/container.d.ts +227 -83
- package/dist/container.d.ts.map +1 -1
- package/dist/containerContext.cjs +74 -0
- package/dist/containerContext.cjs.map +1 -0
- package/dist/containerContext.d.ts +33 -59
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerStorageAdapter.cjs +234 -0
- package/dist/containerStorageAdapter.cjs.map +1 -0
- package/dist/containerStorageAdapter.d.ts +48 -23
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/{contracts.js → contracts.cjs} +5 -5
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.ts +45 -17
- package/dist/contracts.d.ts.map +1 -1
- package/dist/debugLogger.cjs +101 -0
- package/dist/debugLogger.cjs.map +1 -0
- package/dist/debugLogger.d.ts +30 -0
- package/dist/debugLogger.d.ts.map +1 -0
- package/dist/{deltaManager.js → deltaManager.cjs} +379 -186
- package/dist/deltaManager.cjs.map +1 -0
- package/dist/deltaManager.d.ts +54 -18
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/{deltaQueue.js → deltaQueue.cjs} +29 -28
- package/dist/deltaQueue.cjs.map +1 -0
- package/dist/deltaQueue.d.ts +3 -4
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/disposal.cjs +25 -0
- package/dist/disposal.cjs.map +1 -0
- package/dist/disposal.d.ts +13 -0
- package/dist/disposal.d.ts.map +1 -0
- package/dist/error.cjs +32 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +23 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/loader.cjs +148 -0
- package/dist/loader.cjs.map +1 -0
- package/dist/loader.d.ts +38 -19
- package/dist/loader.d.ts.map +1 -1
- package/dist/location-redirection-utilities/index.cjs +11 -0
- package/dist/location-redirection-utilities/index.cjs.map +1 -0
- package/dist/location-redirection-utilities/index.d.ts +6 -0
- package/dist/location-redirection-utilities/index.d.ts.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs +53 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.cjs.map +1 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +24 -0
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/dist/{collabWindowTracker.js → noopHeuristic.cjs} +37 -39
- package/dist/noopHeuristic.cjs.map +1 -0
- package/dist/noopHeuristic.d.ts +23 -0
- package/dist/noopHeuristic.d.ts.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/protocol.cjs +99 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.ts +38 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.cjs} +8 -5
- package/dist/protocolTreeDocumentStorageService.cjs.map +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts +8 -4
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/quorum.cjs +16 -0
- package/dist/quorum.cjs.map +1 -0
- package/dist/quorum.d.ts +1 -14
- package/dist/quorum.d.ts.map +1 -1
- package/dist/{retriableDocumentStorageService.js → retriableDocumentStorageService.cjs} +36 -21
- package/dist/retriableDocumentStorageService.cjs.map +1 -0
- package/dist/retriableDocumentStorageService.d.ts +7 -5
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/{utils.js → utils.cjs} +52 -14
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +34 -1
- package/dist/utils.d.ts.map +1 -1
- package/lib/{audience.d.ts → audience.d.mts} +3 -10
- package/lib/audience.d.mts.map +1 -0
- package/lib/{audience.js → audience.mjs} +15 -17
- package/lib/audience.mjs.map +1 -0
- package/lib/catchUpMonitor.d.mts +29 -0
- package/lib/catchUpMonitor.d.mts.map +1 -0
- package/lib/catchUpMonitor.mjs +39 -0
- package/lib/catchUpMonitor.mjs.map +1 -0
- package/lib/{connectionManager.d.ts → connectionManager.d.mts} +23 -33
- package/lib/connectionManager.d.mts.map +1 -0
- package/lib/{connectionManager.js → connectionManager.mjs} +378 -218
- package/lib/connectionManager.mjs.map +1 -0
- package/lib/{connectionState.d.ts → connectionState.d.mts} +3 -5
- package/lib/connectionState.d.mts.map +1 -0
- package/lib/{connectionState.js → connectionState.mjs} +4 -6
- package/lib/connectionState.mjs.map +1 -0
- package/lib/connectionStateHandler.d.mts +179 -0
- package/lib/connectionStateHandler.d.mts.map +1 -0
- package/lib/connectionStateHandler.mjs +469 -0
- package/lib/connectionStateHandler.mjs.map +1 -0
- package/lib/container-loader-alpha.d.mts +274 -0
- package/lib/container-loader-beta.d.mts +75 -0
- package/lib/container-loader-public.d.mts +75 -0
- package/lib/container-loader-untrimmed.d.mts +331 -0
- package/lib/container.d.mts +382 -0
- package/lib/container.d.mts.map +1 -0
- package/lib/container.mjs +1579 -0
- package/lib/container.mjs.map +1 -0
- package/lib/containerContext.d.mts +58 -0
- package/lib/containerContext.d.mts.map +1 -0
- package/lib/containerContext.mjs +70 -0
- package/lib/containerContext.mjs.map +1 -0
- package/lib/containerStorageAdapter.d.mts +73 -0
- package/lib/containerStorageAdapter.d.mts.map +1 -0
- package/lib/containerStorageAdapter.mjs +228 -0
- package/lib/containerStorageAdapter.mjs.map +1 -0
- package/lib/{contracts.d.ts → contracts.d.mts} +45 -17
- package/lib/contracts.d.mts.map +1 -0
- package/lib/{contracts.js → contracts.mjs} +4 -4
- package/lib/contracts.mjs.map +1 -0
- package/lib/debugLogger.d.mts +30 -0
- package/lib/debugLogger.d.mts.map +1 -0
- package/lib/debugLogger.mjs +93 -0
- package/lib/debugLogger.mjs.map +1 -0
- package/lib/{deltaManager.d.ts → deltaManager.d.mts} +54 -18
- package/lib/deltaManager.d.mts.map +1 -0
- package/lib/{deltaManager.js → deltaManager.mjs} +361 -165
- package/lib/deltaManager.mjs.map +1 -0
- package/lib/{deltaQueue.d.ts → deltaQueue.d.mts} +3 -4
- package/lib/deltaQueue.d.mts.map +1 -0
- package/lib/{deltaQueue.js → deltaQueue.mjs} +25 -24
- package/lib/deltaQueue.mjs.map +1 -0
- package/lib/disposal.d.mts +13 -0
- package/lib/disposal.d.mts.map +1 -0
- package/lib/disposal.mjs +21 -0
- package/lib/disposal.mjs.map +1 -0
- package/lib/error.d.mts +23 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +28 -0
- package/lib/error.mjs.map +1 -0
- package/lib/index.d.mts +11 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +10 -0
- package/lib/index.mjs.map +1 -0
- package/lib/{loader.d.ts → loader.d.mts} +39 -20
- package/lib/loader.d.mts.map +1 -0
- package/lib/loader.mjs +143 -0
- package/lib/loader.mjs.map +1 -0
- package/lib/location-redirection-utilities/index.d.mts +6 -0
- package/lib/location-redirection-utilities/index.d.mts.map +1 -0
- package/lib/location-redirection-utilities/index.mjs +6 -0
- package/lib/location-redirection-utilities/index.mjs.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts +24 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +1 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs +48 -0
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +1 -0
- package/lib/noopHeuristic.d.mts +23 -0
- package/lib/noopHeuristic.d.mts.map +1 -0
- package/lib/{collabWindowTracker.js → noopHeuristic.mjs} +33 -35
- package/lib/noopHeuristic.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/protocol.d.mts +38 -0
- package/lib/protocol.d.mts.map +1 -0
- package/lib/protocol.mjs +94 -0
- package/lib/protocol.mjs.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.d.ts → protocolTreeDocumentStorageService.d.mts} +8 -4
- package/lib/protocolTreeDocumentStorageService.d.mts.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.js → protocolTreeDocumentStorageService.mjs} +8 -5
- package/lib/protocolTreeDocumentStorageService.mjs.map +1 -0
- package/lib/quorum.d.mts +4 -0
- package/lib/quorum.d.mts.map +1 -0
- package/lib/quorum.mjs +12 -0
- package/lib/quorum.mjs.map +1 -0
- package/lib/{retriableDocumentStorageService.d.ts → retriableDocumentStorageService.d.mts} +7 -5
- package/lib/retriableDocumentStorageService.d.mts.map +1 -0
- package/lib/{retriableDocumentStorageService.js → retriableDocumentStorageService.mjs} +35 -20
- package/lib/retriableDocumentStorageService.mjs.map +1 -0
- package/lib/utils.d.mts +67 -0
- package/lib/utils.d.mts.map +1 -0
- package/lib/{utils.js → utils.mjs} +47 -11
- package/lib/utils.mjs.map +1 -0
- package/package.json +163 -70
- package/prettier.config.cjs +8 -0
- package/src/audience.ts +59 -49
- package/src/catchUpMonitor.ts +61 -0
- package/src/connectionManager.ts +1154 -910
- package/src/connectionState.ts +22 -25
- package/src/connectionStateHandler.ts +689 -319
- package/src/container.ts +2476 -1792
- package/src/containerContext.ts +98 -330
- package/src/containerStorageAdapter.ts +301 -105
- package/src/contracts.ts +184 -146
- package/src/debugLogger.ts +123 -0
- package/src/deltaManager.ts +1165 -900
- package/src/deltaQueue.ts +156 -152
- package/src/disposal.ts +25 -0
- package/src/error.ts +44 -0
- package/src/index.ts +14 -15
- package/src/loader.ts +356 -427
- package/src/location-redirection-utilities/index.ts +9 -0
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +61 -0
- package/src/noopHeuristic.ts +107 -0
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +150 -0
- package/src/protocolTreeDocumentStorageService.ts +35 -35
- package/src/quorum.ts +11 -50
- package/src/retriableDocumentStorageService.ts +135 -95
- package/src/utils.ts +159 -86
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +10 -12
- package/dist/audience.js.map +0 -1
- package/dist/collabWindowTracker.d.ts +0 -19
- package/dist/collabWindowTracker.d.ts.map +0 -1
- package/dist/collabWindowTracker.js.map +0 -1
- package/dist/connectionManager.js.map +0 -1
- package/dist/connectionState.js.map +0 -1
- package/dist/connectionStateHandler.js +0 -280
- package/dist/connectionStateHandler.js.map +0 -1
- package/dist/container.js +0 -1284
- package/dist/container.js.map +0 -1
- package/dist/containerContext.js +0 -217
- package/dist/containerContext.js.map +0 -1
- package/dist/containerStorageAdapter.js +0 -104
- package/dist/containerStorageAdapter.js.map +0 -1
- package/dist/contracts.js.map +0 -1
- package/dist/deltaManager.js.map +0 -1
- package/dist/deltaManagerProxy.d.ts +0 -54
- package/dist/deltaManagerProxy.d.ts.map +0 -1
- package/dist/deltaManagerProxy.js +0 -115
- package/dist/deltaManagerProxy.js.map +0 -1
- package/dist/deltaQueue.js.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/loader.js +0 -241
- package/dist/loader.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/protocolTreeDocumentStorageService.js.map +0 -1
- package/dist/quorum.js +0 -44
- package/dist/quorum.js.map +0 -1
- package/dist/retriableDocumentStorageService.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/lib/audience.d.ts.map +0 -1
- package/lib/audience.js.map +0 -1
- package/lib/collabWindowTracker.d.ts +0 -19
- package/lib/collabWindowTracker.d.ts.map +0 -1
- package/lib/collabWindowTracker.js.map +0 -1
- package/lib/connectionManager.d.ts.map +0 -1
- package/lib/connectionManager.js.map +0 -1
- package/lib/connectionState.d.ts.map +0 -1
- package/lib/connectionState.js.map +0 -1
- package/lib/connectionStateHandler.d.ts +0 -81
- package/lib/connectionStateHandler.d.ts.map +0 -1
- package/lib/connectionStateHandler.js +0 -276
- package/lib/connectionStateHandler.js.map +0 -1
- package/lib/container.d.ts +0 -238
- package/lib/container.d.ts.map +0 -1
- package/lib/container.js +0 -1276
- package/lib/container.js.map +0 -1
- package/lib/containerContext.d.ts +0 -84
- package/lib/containerContext.d.ts.map +0 -1
- package/lib/containerContext.js +0 -213
- package/lib/containerContext.js.map +0 -1
- package/lib/containerStorageAdapter.d.ts +0 -48
- package/lib/containerStorageAdapter.d.ts.map +0 -1
- package/lib/containerStorageAdapter.js +0 -99
- package/lib/containerStorageAdapter.js.map +0 -1
- package/lib/contracts.d.ts.map +0 -1
- package/lib/contracts.js.map +0 -1
- package/lib/deltaManager.d.ts.map +0 -1
- package/lib/deltaManager.js.map +0 -1
- package/lib/deltaManagerProxy.d.ts +0 -54
- package/lib/deltaManagerProxy.d.ts.map +0 -1
- package/lib/deltaManagerProxy.js +0 -110
- package/lib/deltaManagerProxy.js.map +0 -1
- package/lib/deltaQueue.d.ts.map +0 -1
- package/lib/deltaQueue.js.map +0 -1
- package/lib/index.d.ts +0 -8
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/loader.d.ts.map +0 -1
- package/lib/loader.js +0 -236
- package/lib/loader.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +0 -1
- package/lib/protocolTreeDocumentStorageService.js.map +0 -1
- package/lib/quorum.d.ts +0 -21
- package/lib/quorum.d.ts.map +0 -1
- package/lib/quorum.js +0 -38
- package/lib/quorum.js.map +0 -1
- package/lib/retriableDocumentStorageService.d.ts.map +0 -1
- package/lib/retriableDocumentStorageService.js.map +0 -1
- package/lib/utils.d.ts +0 -34
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
- package/src/collabWindowTracker.ts +0 -102
- package/src/deltaManagerProxy.ts +0 -158
- package/tsconfig.esnext.json +0 -7
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
6
6
|
import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { IDisposable
|
|
7
|
+
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
8
9
|
export declare class RetriableDocumentStorageService implements IDocumentStorageService, IDisposable {
|
|
9
|
-
private readonly
|
|
10
|
+
private readonly internalStorageServiceP;
|
|
10
11
|
private readonly logger;
|
|
11
12
|
private _disposed;
|
|
12
|
-
|
|
13
|
+
private internalStorageService;
|
|
14
|
+
constructor(internalStorageServiceP: Promise<IDocumentStorageService>, logger: ITelemetryLoggerExt);
|
|
13
15
|
get policies(): IDocumentStorageServicePolicies | undefined;
|
|
14
16
|
get disposed(): boolean;
|
|
15
17
|
dispose(): void;
|
|
16
18
|
get repositoryUrl(): string;
|
|
17
19
|
getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null>;
|
|
18
20
|
readBlob(id: string): Promise<ArrayBufferLike>;
|
|
19
|
-
getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]>;
|
|
21
|
+
getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
|
|
20
22
|
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
21
23
|
downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
|
|
22
24
|
createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"retriableDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/retriableDocumentStorageService.ts"],"names":[],"mappings":"A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AC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO5E,OAAO,CAAC,oBAAoB;YAiBd,YAAY;CAM1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.38.3"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -4,26 +4,56 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getProtocolSnapshotTree = exports.getSnapshotTreeFromSerializedContainer = exports.convertProtocolAndAppSummaryToSnapshotTree = exports.
|
|
7
|
+
exports.isDeltaStreamConnectionForbiddenError = exports.getProtocolSnapshotTree = exports.getSnapshotTreeFromSerializedContainer = exports.convertProtocolAndAppSummaryToSnapshotTree = exports.combineAppAndProtocolSummary = exports.tryParseCompatibleResolvedUrl = void 0;
|
|
8
8
|
const url_1 = require("url");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
|
-
const
|
|
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
|
-
|
|
14
|
+
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
15
|
+
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
16
|
+
/**
|
|
17
|
+
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
18
|
+
* deep link info etc.
|
|
19
|
+
* Warning - This function may not be compatible with any Url Resolver's resolved url. It works
|
|
20
|
+
* with urls of type: protocol://<string>/.../..?<querystring>
|
|
21
|
+
* @param url - This is the IResolvedUrl.url part of the resolved url.
|
|
22
|
+
* @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function tryParseCompatibleResolvedUrl(url) {
|
|
15
26
|
const parsed = (0, url_1.parse)(url, true);
|
|
16
27
|
if (typeof parsed.pathname !== "string") {
|
|
17
28
|
throw new telemetry_utils_1.LoggingError("Failed to parse pathname");
|
|
18
29
|
}
|
|
19
|
-
const query =
|
|
30
|
+
const query = parsed.search ?? "";
|
|
20
31
|
const regex = /^\/([^/]*\/[^/]*)(\/?.*)$/;
|
|
21
32
|
const match = regex.exec(parsed.pathname);
|
|
22
|
-
return
|
|
33
|
+
return match?.length === 3
|
|
23
34
|
? { id: match[1], path: match[2], query, version: parsed.query.version }
|
|
24
35
|
: undefined;
|
|
25
36
|
}
|
|
26
|
-
exports.
|
|
37
|
+
exports.tryParseCompatibleResolvedUrl = tryParseCompatibleResolvedUrl;
|
|
38
|
+
/**
|
|
39
|
+
* Combine the app summary and protocol summary in 1 tree.
|
|
40
|
+
* @param appSummary - Summary of the app.
|
|
41
|
+
* @param protocolSummary - Summary of the protocol.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
function combineAppAndProtocolSummary(appSummary, protocolSummary) {
|
|
45
|
+
(0, core_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(appSummary), 0x5a8 /* app summary is already a combined tree! */);
|
|
46
|
+
(0, core_utils_1.assert)(!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
|
|
47
|
+
const createNewSummary = {
|
|
48
|
+
type: protocol_definitions_1.SummaryType.Tree,
|
|
49
|
+
tree: {
|
|
50
|
+
".protocol": protocolSummary,
|
|
51
|
+
".app": appSummary,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
return createNewSummary;
|
|
55
|
+
}
|
|
56
|
+
exports.combineAppAndProtocolSummary = combineAppAndProtocolSummary;
|
|
27
57
|
/**
|
|
28
58
|
* Converts summary tree (for upload) to snapshot tree (for download).
|
|
29
59
|
* Summary tree blobs contain contents, but snapshot tree blobs normally
|
|
@@ -47,7 +77,8 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
47
77
|
const summaryObject = summary.tree[key];
|
|
48
78
|
switch (summaryObject.type) {
|
|
49
79
|
case protocol_definitions_1.SummaryType.Tree: {
|
|
50
|
-
treeNode.trees[key] =
|
|
80
|
+
treeNode.trees[key] =
|
|
81
|
+
convertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);
|
|
51
82
|
break;
|
|
52
83
|
}
|
|
53
84
|
case protocol_definitions_1.SummaryType.Attachment:
|
|
@@ -56,8 +87,9 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
56
87
|
case protocol_definitions_1.SummaryType.Blob: {
|
|
57
88
|
const blobId = (0, uuid_1.v4)();
|
|
58
89
|
treeNode.blobs[key] = blobId;
|
|
59
|
-
const contentBuffer = typeof summaryObject.content === "string"
|
|
60
|
-
(0,
|
|
90
|
+
const contentBuffer = typeof summaryObject.content === "string"
|
|
91
|
+
? (0, client_utils_1.stringToBuffer)(summaryObject.content, "utf8")
|
|
92
|
+
: (0, client_utils_1.Uint8ArrayToArrayBuffer)(summaryObject.content);
|
|
61
93
|
treeNode.blobsContents[blobId] = contentBuffer;
|
|
62
94
|
break;
|
|
63
95
|
}
|
|
@@ -65,7 +97,7 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
65
97
|
throw new telemetry_utils_1.LoggingError("No handles should be there in summary in detached container!!");
|
|
66
98
|
break;
|
|
67
99
|
default: {
|
|
68
|
-
(0,
|
|
100
|
+
(0, core_utils_1.unreachableCase)(summaryObject, `Unknown tree type ${summaryObject.type}`);
|
|
69
101
|
}
|
|
70
102
|
}
|
|
71
103
|
}
|
|
@@ -80,7 +112,7 @@ function convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree, appSumm
|
|
|
80
112
|
// Shallow copy is fine, since we are doing a deep clone below.
|
|
81
113
|
const combinedSummary = {
|
|
82
114
|
type: protocol_definitions_1.SummaryType.Tree,
|
|
83
|
-
tree:
|
|
115
|
+
tree: { ...appSummaryTree.tree },
|
|
84
116
|
};
|
|
85
117
|
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
86
118
|
const snapshotTreeWithBlobContents = convertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);
|
|
@@ -90,9 +122,9 @@ exports.convertProtocolAndAppSummaryToSnapshotTree = convertProtocolAndAppSummar
|
|
|
90
122
|
// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which
|
|
91
123
|
// a detached container can be rehydrated.
|
|
92
124
|
const getSnapshotTreeFromSerializedContainer = (detachedContainerSnapshot) => {
|
|
125
|
+
(0, core_utils_1.assert)((0, driver_utils_1.isCombinedAppAndProtocolSummary)(detachedContainerSnapshot), 0x1e0 /* "Protocol and App summary trees should be present" */);
|
|
93
126
|
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
|
|
94
127
|
const appSummaryTree = detachedContainerSnapshot.tree[".app"];
|
|
95
|
-
(0, common_utils_1.assert)(protocolSummaryTree !== undefined && appSummaryTree !== undefined, 0x1e0 /* "Protocol and App summary trees should be present" */);
|
|
96
128
|
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree, appSummaryTree);
|
|
97
129
|
return snapshotTreeWithBlobContents;
|
|
98
130
|
};
|
|
@@ -101,4 +133,10 @@ function getProtocolSnapshotTree(snapshot) {
|
|
|
101
133
|
return ".protocol" in snapshot.trees ? snapshot.trees[".protocol"] : snapshot;
|
|
102
134
|
}
|
|
103
135
|
exports.getProtocolSnapshotTree = getProtocolSnapshotTree;
|
|
104
|
-
|
|
136
|
+
function isDeltaStreamConnectionForbiddenError(error) {
|
|
137
|
+
return (typeof error === "object" &&
|
|
138
|
+
error !== null &&
|
|
139
|
+
error?.errorType === driver_definitions_1.DriverErrorTypes.deltaStreamConnectionForbidden);
|
|
140
|
+
}
|
|
141
|
+
exports.isDeltaStreamConnectionForbiddenError = isDeltaStreamConnectionForbiddenError;
|
|
142
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","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;AAoCtE;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAAC,GAAW;IACxD,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,KAAK,EAAE,MAAM,KAAK,CAAC;QACzB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAiB,EAAE;QAClF,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAXD,sEAWC;AAED;;;;;GAKG;AACH,S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,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\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @internal\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\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\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @internal\n */\nexport function tryParseCompatibleResolvedUrl(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/dist/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISummaryTree, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { CombinedAppAndProtocolSummary, DeltaStreamConnectionForbiddenError } from "@fluidframework/driver-utils";
|
|
6
7
|
export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
7
8
|
blobsContents: {
|
|
8
9
|
[path: string]: ArrayBufferLike;
|
|
@@ -11,9 +12,24 @@ export interface ISnapshotTreeWithBlobContents extends ISnapshotTree {
|
|
|
11
12
|
[path: string]: ISnapshotTreeWithBlobContents;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface to represent the parsed parts of IResolvedUrl.url to help
|
|
17
|
+
* in getting info about different parts of the url.
|
|
18
|
+
* May not be compatible or relevant for any Url Resolver
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
14
21
|
export interface IParsedUrl {
|
|
22
|
+
/**
|
|
23
|
+
* It is combination of tenantid/docId part of the url.
|
|
24
|
+
*/
|
|
15
25
|
id: string;
|
|
26
|
+
/**
|
|
27
|
+
* It is the deep link path in the url.
|
|
28
|
+
*/
|
|
16
29
|
path: string;
|
|
30
|
+
/**
|
|
31
|
+
* Query string part of the url.
|
|
32
|
+
*/
|
|
17
33
|
query: string;
|
|
18
34
|
/**
|
|
19
35
|
* Null means do not use snapshots, undefined means load latest snapshot
|
|
@@ -22,7 +38,23 @@ export interface IParsedUrl {
|
|
|
22
38
|
*/
|
|
23
39
|
version: string | null | undefined;
|
|
24
40
|
}
|
|
25
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get
|
|
43
|
+
* deep link info etc.
|
|
44
|
+
* Warning - This function may not be compatible with any Url Resolver's resolved url. It works
|
|
45
|
+
* with urls of type: protocol://<string>/.../..?<querystring>
|
|
46
|
+
* @param url - This is the IResolvedUrl.url part of the resolved url.
|
|
47
|
+
* @returns The IParsedUrl representing the input URL, or undefined if the format was not supported
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Combine the app summary and protocol summary in 1 tree.
|
|
53
|
+
* @param appSummary - Summary of the app.
|
|
54
|
+
* @param protocolSummary - Summary of the protocol.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export declare function combineAppAndProtocolSummary(appSummary: ISummaryTree, protocolSummary: ISummaryTree): CombinedAppAndProtocolSummary;
|
|
26
58
|
/**
|
|
27
59
|
* Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.
|
|
28
60
|
* @param protocolSummaryTree - Protocol Summary Tree
|
|
@@ -31,4 +63,5 @@ export declare function parseUrl(url: string): IParsedUrl | undefined;
|
|
|
31
63
|
export declare function convertProtocolAndAppSummaryToSnapshotTree(protocolSummaryTree: ISummaryTree, appSummaryTree: ISummaryTree): ISnapshotTreeWithBlobContents;
|
|
32
64
|
export declare const getSnapshotTreeFromSerializedContainer: (detachedContainerSnapshot: ISummaryTree) => ISnapshotTreeWithBlobContents;
|
|
33
65
|
export declare function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree;
|
|
66
|
+
export declare function isDeltaStreamConnectionForbiddenError(error: any): error is DeltaStreamConnectionForbiddenError;
|
|
34
67
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
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;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAWjF;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,16 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
2
|
import { EventEmitter } from "events";
|
|
7
|
-
import {
|
|
3
|
+
import { IAudienceOwner } from "@fluidframework/container-definitions";
|
|
8
4
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
9
5
|
/**
|
|
10
6
|
* Audience represents all clients connected to the op stream.
|
|
11
7
|
*/
|
|
12
|
-
export declare class Audience extends EventEmitter implements
|
|
8
|
+
export declare class Audience extends EventEmitter implements IAudienceOwner {
|
|
13
9
|
private readonly members;
|
|
10
|
+
constructor();
|
|
14
11
|
on(event: "addMember" | "removeMember", listener: (clientId: string, client: IClient) => void): this;
|
|
15
12
|
/**
|
|
16
13
|
* Adds a new client to the audience
|
|
@@ -29,9 +26,5 @@ export declare class Audience extends EventEmitter implements IAudience {
|
|
|
29
26
|
* Retrieves a specific member of the audience
|
|
30
27
|
*/
|
|
31
28
|
getMember(clientId: string): IClient | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Clears the audience
|
|
34
|
-
*/
|
|
35
|
-
clear(): void;
|
|
36
29
|
}
|
|
37
30
|
//# sourceMappingURL=audience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";OAIO,EAAE,YAAY,EAAE,MAAM,QAAQ;OAE9B,EAAE,cAAc,EAAE,MAAM,uCAAuC;OAC/D,EAAE,OAAO,EAAE,MAAM,sCAAsC;AAE9D;;GAEG;AACH,qBAAa,QAAS,SAAQ,YAAa,YAAW,cAAc;IACnE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;;IAQ/C,EAAE,CACR,KAAK,EAAE,WAAW,GAAG,cAAc,EACnC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GACnD,IAAI;IAKP;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAenD;;;OAGG;IACI,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAW9C;;OAEG;IACI,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAIzC;;OAEG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;CAGvD"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
1
|
import { EventEmitter } from "events";
|
|
2
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
3
|
/**
|
|
7
4
|
* Audience represents all clients connected to the op stream.
|
|
8
5
|
*/
|
|
9
6
|
export class Audience extends EventEmitter {
|
|
10
7
|
constructor() {
|
|
11
|
-
super(
|
|
8
|
+
super();
|
|
12
9
|
this.members = new Map();
|
|
10
|
+
// We are expecting this class to have many listeners, so we suppress noisy "MaxListenersExceededWarning" logging.
|
|
11
|
+
super.setMaxListeners(0);
|
|
13
12
|
}
|
|
14
13
|
on(event, listener) {
|
|
15
14
|
return super.on(event, listener);
|
|
@@ -18,8 +17,16 @@ export class Audience extends EventEmitter {
|
|
|
18
17
|
* Adds a new client to the audience
|
|
19
18
|
*/
|
|
20
19
|
addMember(clientId, details) {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// Given that signal delivery is unreliable process, we might observe same client being added twice
|
|
21
|
+
// In such case we should see exactly same payload (IClient), and should not raise event twice!
|
|
22
|
+
if (this.members.has(clientId)) {
|
|
23
|
+
const client = this.members.get(clientId);
|
|
24
|
+
assert(JSON.stringify(client) === JSON.stringify(details), 0x4b2 /* new client has different payload from existing one */);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.members.set(clientId, details);
|
|
28
|
+
this.emit("addMember", clientId, details);
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
/**
|
|
25
32
|
* Removes a client from the audience. Only emits an event if a client is actually removed
|
|
@@ -48,14 +55,5 @@ export class Audience extends EventEmitter {
|
|
|
48
55
|
getMember(clientId) {
|
|
49
56
|
return this.members.get(clientId);
|
|
50
57
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Clears the audience
|
|
53
|
-
*/
|
|
54
|
-
clear() {
|
|
55
|
-
const clientIds = this.members.keys();
|
|
56
|
-
for (const clientId of clientIds) {
|
|
57
|
-
this.removeMember(clientId);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
58
|
}
|
|
61
|
-
//# sourceMappingURL=audience.
|
|
59
|
+
//# sourceMappingURL=audience.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audience.mjs","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":"OAIO,EAAE,YAAY,EAAE,MAAM,QAAQ;OAC9B,EAAE,MAAM,EAAE,MAAM,4BAA4B;AAInD;;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/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"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IDeltaManager } from "@fluidframework/container-definitions";
|
|
7
|
+
/** @see CatchUpMonitor for usage */
|
|
8
|
+
type CaughtUpListener = () => void;
|
|
9
|
+
/** Monitor that emits an event when a Container has caught up to a given point in the op stream */
|
|
10
|
+
export type ICatchUpMonitor = IDisposable;
|
|
11
|
+
/**
|
|
12
|
+
* Monitors a Container's DeltaManager, notifying listeners when all ops have been processed
|
|
13
|
+
* that were known at the time the monitor was created.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CatchUpMonitor implements ICatchUpMonitor {
|
|
16
|
+
private readonly deltaManager;
|
|
17
|
+
private readonly listener;
|
|
18
|
+
private readonly targetSeqNumber;
|
|
19
|
+
private caughtUp;
|
|
20
|
+
private readonly opHandler;
|
|
21
|
+
/**
|
|
22
|
+
* Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.
|
|
23
|
+
*/
|
|
24
|
+
constructor(deltaManager: IDeltaManager<any, any>, listener: CaughtUpListener);
|
|
25
|
+
disposed: boolean;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=catchUpMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catchUpMonitor.d.ts","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,WAAW,EAAE,MAAM,iCAAiC;OAEtD,EAAE,aAAa,EAAE,MAAM,uCAAuC;AAGrE,oCAAoC;AACpC,KAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAEnC,mGAAmG;AACnG,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC;AAE1C;;;GAGG;AACH,qBAAa,cAAe,YAAW,eAAe;IAepD,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAf1B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAkB;IAElC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAKxB;IAEF;;OAEG;gBAEe,YAAY,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EACrC,QAAQ,EAAE,gBAAgB;IAerC,QAAQ,EAAE,OAAO,CAAS;IAC1B,OAAO;CAQd"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
|
+
/**
|
|
7
|
+
* Monitors a Container's DeltaManager, notifying listeners when all ops have been processed
|
|
8
|
+
* that were known at the time the monitor was created.
|
|
9
|
+
*/
|
|
10
|
+
export class CatchUpMonitor {
|
|
11
|
+
/**
|
|
12
|
+
* Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.
|
|
13
|
+
*/
|
|
14
|
+
constructor(deltaManager, listener) {
|
|
15
|
+
this.deltaManager = deltaManager;
|
|
16
|
+
this.listener = listener;
|
|
17
|
+
this.caughtUp = false;
|
|
18
|
+
this.opHandler = (message) => {
|
|
19
|
+
if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
|
|
20
|
+
this.caughtUp = true;
|
|
21
|
+
this.listener();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
this.disposed = false;
|
|
25
|
+
this.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;
|
|
26
|
+
assert(this.targetSeqNumber >= this.deltaManager.lastSequenceNumber, 0x37c /* Cannot wait for seqNumber below last processed sequence number */);
|
|
27
|
+
this.deltaManager.on("op", this.opHandler);
|
|
28
|
+
// Simulate the last processed op to set caughtUp in case we already are
|
|
29
|
+
this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });
|
|
30
|
+
}
|
|
31
|
+
dispose() {
|
|
32
|
+
if (this.disposed) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.disposed = true;
|
|
36
|
+
this.deltaManager.off("op", this.opHandler);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=catchUpMonitor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catchUpMonitor.mjs","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,MAAM,EAAE,MAAM,4BAA4B;AAUnD;;;GAGG;AACH,MAAM,OAAO,cAAc;IAW1B;;OAEG;IACH,YACkB,YAAqC,EACrC,QAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAyB;QACrC,aAAQ,GAAR,QAAQ,CAAkB;QAdpC,aAAQ,GAAY,KAAK,CAAC;QAEjB,cAAS,GAAG,CAAC,OAA0D,EAAE,EAAE;YAC3F,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE;gBACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;aAChB;QACF,CAAC,CAAC;QAsBK,aAAQ,GAAY,KAAK,CAAC;QAbhC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAE5D,MAAM,CACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAC5D,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,wEAAwE;QACxE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAGM,OAAO;QACb,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\n\n/** @see CatchUpMonitor for usage */\ntype CaughtUpListener = () => void;\n\n/** Monitor that emits an event when a Container has caught up to a given point in the op stream */\nexport type ICatchUpMonitor = IDisposable;\n\n/**\n * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed\n * that were known at the time the monitor was created.\n */\nexport class CatchUpMonitor implements ICatchUpMonitor {\n\tprivate readonly targetSeqNumber: number;\n\tprivate caughtUp: boolean = false;\n\n\tprivate readonly opHandler = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n\t\tif (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {\n\t\t\tthis.caughtUp = true;\n\t\t\tthis.listener();\n\t\t}\n\t};\n\n\t/**\n\t * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.\n\t */\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t\tprivate readonly listener: CaughtUpListener,\n\t) {\n\t\tthis.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\n\t\tassert(\n\t\t\tthis.targetSeqNumber >= this.deltaManager.lastSequenceNumber,\n\t\t\t0x37c /* Cannot wait for seqNumber below last processed sequence number */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"op\", this.opHandler);\n\n\t\t// Simulate the last processed op to set caughtUp in case we already are\n\t\tthis.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });\n\t}\n\n\tpublic disposed: boolean = false;\n\tpublic dispose() {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\n\t\tthis.deltaManager.off(\"op\", this.opHandler);\n\t}\n}\n"]}
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { IDeltaQueue, ReadOnlyInfo
|
|
5
|
+
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ICriticalContainerError, IDeltaQueue, ReadOnlyInfo } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IDocumentService } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { ConnectionMode, IClient, IClientConfiguration, IClientDetails, IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
|
-
import {
|
|
9
|
+
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
10
|
+
import { ReconnectMode, IConnectionManager, IConnectionManagerFactoryArgs, IConnectionStateChangeReason } from "./contracts.mjs";
|
|
10
11
|
/**
|
|
11
12
|
* Implementation of IConnectionManager, used by Container class
|
|
12
|
-
* Implements constant connectivity to relay service, by reconnecting in case of
|
|
13
|
-
* Exposes various controls to
|
|
13
|
+
* Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.
|
|
14
|
+
* Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.
|
|
14
15
|
*/
|
|
15
16
|
export declare class ConnectionManager implements IConnectionManager {
|
|
16
17
|
private readonly serviceProvider;
|
|
17
|
-
|
|
18
|
+
readonly containerDirty: () => boolean;
|
|
19
|
+
private readonly client;
|
|
18
20
|
private readonly logger;
|
|
19
21
|
private readonly props;
|
|
20
22
|
/** Connection mode used when reconnecting on error or disconnect. */
|
|
@@ -38,14 +40,14 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
38
40
|
private pendingReconnect;
|
|
39
41
|
private clientSequenceNumber;
|
|
40
42
|
private clientSequenceNumberObserved;
|
|
41
|
-
/** Counts the number of
|
|
42
|
-
private
|
|
43
|
+
/** Counts the number of non-runtime ops sent by the client which may not be acked. */
|
|
44
|
+
private localOpsToIgnore;
|
|
43
45
|
/** track clientId used last time when we sent any ops */
|
|
44
46
|
private lastSubmittedClientId;
|
|
45
47
|
private connectFirstConnection;
|
|
46
48
|
private _connectionVerboseProps;
|
|
47
49
|
private _connectionProps;
|
|
48
|
-
private
|
|
50
|
+
private _disposed;
|
|
49
51
|
private readonly _outbound;
|
|
50
52
|
get connectionVerboseProps(): Record<string, string | number>;
|
|
51
53
|
readonly clientDetails: IClientDetails;
|
|
@@ -68,7 +70,7 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
68
70
|
/**
|
|
69
71
|
* Returns set of props that can be logged in telemetry that provide some insights / statistics
|
|
70
72
|
* about current or last connection (if there is no connection at the moment)
|
|
71
|
-
|
|
73
|
+
*/
|
|
72
74
|
get connectionProps(): ITelemetryProperties;
|
|
73
75
|
shouldJoinWrite(): boolean;
|
|
74
76
|
/**
|
|
@@ -83,43 +85,30 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
83
85
|
private get readonly();
|
|
84
86
|
get readOnlyInfo(): ReadOnlyInfo;
|
|
85
87
|
private static detailsFromConnection;
|
|
86
|
-
constructor(serviceProvider: () => IDocumentService | undefined, client: IClient, reconnectAllowed: boolean, logger:
|
|
87
|
-
dispose(error?: ICriticalContainerError): void;
|
|
88
|
+
constructor(serviceProvider: () => IDocumentService | undefined, containerDirty: () => boolean, client: IClient, reconnectAllowed: boolean, logger: ITelemetryLoggerExt, props: IConnectionManagerFactoryArgs);
|
|
89
|
+
dispose(error?: ICriticalContainerError, switchToReadonly?: boolean): void;
|
|
88
90
|
/**
|
|
89
91
|
* Enables or disables automatic reconnecting.
|
|
90
92
|
* Will throw an error if reconnectMode set to Never.
|
|
91
|
-
|
|
92
|
-
setAutoReconnect(mode: ReconnectMode): void;
|
|
93
|
+
*/
|
|
94
|
+
setAutoReconnect(mode: ReconnectMode, reason: IConnectionStateChangeReason): void;
|
|
93
95
|
/**
|
|
94
|
-
*
|
|
95
|
-
* Hosts may have read only views, indicating to data stores that no edits are allowed.
|
|
96
|
-
* This is independent from this._readonlyPermissions (permissions) and this.connectionMode
|
|
97
|
-
* (server can return "write" mode even when asked for "read")
|
|
98
|
-
* Leveraging same "readonly" event as runtime & data stores should behave the same in such case
|
|
99
|
-
* as in read-only permissions.
|
|
100
|
-
* But this.active can be used by some DDSes to figure out if ops can be sent
|
|
101
|
-
* (for example, read-only view still participates in code proposals / upgrades decisions)
|
|
102
|
-
*
|
|
103
|
-
* Forcing Readonly does not prevent DDS from generating ops. It is up to user code to honour
|
|
104
|
-
* the readonly flag. If ops are generated, they will accumulate locally and not be sent. If
|
|
105
|
-
* there are pending in the outbound queue, it will stop sending until force readonly is
|
|
106
|
-
* cleared.
|
|
107
|
-
*
|
|
108
|
-
* @param readonly - set or clear force readonly.
|
|
96
|
+
* {@inheritDoc Container.forceReadonly}
|
|
109
97
|
*/
|
|
110
98
|
forceReadonly(readonly: boolean): void;
|
|
111
99
|
private set_readonlyPermissions;
|
|
112
|
-
connect(connectionMode?: ConnectionMode): void;
|
|
100
|
+
connect(reason: IConnectionStateChangeReason, connectionMode?: ConnectionMode): void;
|
|
113
101
|
private connectCore;
|
|
114
102
|
/**
|
|
115
|
-
* Start the connection. Any error should result in container being
|
|
116
|
-
* And report the error if it
|
|
103
|
+
* Start the connection. Any error should result in container being closed.
|
|
104
|
+
* And report the error if it escapes for any reason.
|
|
117
105
|
* @param args - The connection arguments
|
|
118
106
|
*/
|
|
119
107
|
private triggerConnect;
|
|
120
108
|
/**
|
|
121
109
|
* Disconnect the current connection.
|
|
122
110
|
* @param reason - Text description of disconnect reason to emit with disconnect event
|
|
111
|
+
* @param error - Error causing the disconnect if any.
|
|
123
112
|
* @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect
|
|
124
113
|
*/
|
|
125
114
|
private disconnectFromDeltaStream;
|
|
@@ -150,10 +139,11 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
150
139
|
*/
|
|
151
140
|
private reconnect;
|
|
152
141
|
prepareMessageToSend(message: Omit<IDocumentMessage, "clientSequenceNumber">): IDocumentMessage | undefined;
|
|
153
|
-
submitSignal(content: any): void;
|
|
142
|
+
submitSignal(content: any, targetClientId?: string): void;
|
|
154
143
|
sendMessages(messages: IDocumentMessage[]): void;
|
|
155
144
|
beforeProcessingIncomingOp(message: ISequencedDocumentMessage): void;
|
|
156
145
|
private readonly opHandler;
|
|
146
|
+
private readonly signalHandler;
|
|
157
147
|
private readonly nackHandler;
|
|
158
148
|
private readonly disconnectHandlerInternal;
|
|
159
149
|
private readonly errorHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAe,oBAAoB,EAAY,MAAM,iCAAiC;OAGtF,EACN,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,MAAM,uCAAuC;OACvC,EAEN,gBAAgB,EAKhB,MAAM,oCAAoC;OAUpC,EACN,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAOzB,MAAM,sCAAsC;OACtC,EAIN,mBAAmB,EAGnB,MAAM,iCAAiC;OACjC,EACN,aAAa,EACb,kBAAkB,EAClB,6BAA6B,EAE7B,4BAA4B,EAC5B;AAiID;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAoL1D,OAAO,CAAC,QAAQ,CAAC,eAAe;aAChB,cAAc,EAAE,MAAM,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAEvB,OAA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