@fluidframework/container-loader 2.11.0 → 2.12.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.
- package/CHANGELOG.md +55 -0
- package/api-report/container-loader.legacy.alpha.api.md +39 -0
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js.map +1 -1
- package/dist/createAndLoadContainerUtils.d.ts +125 -0
- package/dist/createAndLoadContainerUtils.d.ts.map +1 -0
- package/dist/createAndLoadContainerUtils.js +50 -0
- package/dist/createAndLoadContainerUtils.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +7 -0
- package/dist/loadPaused.d.ts +4 -3
- package/dist/loadPaused.d.ts.map +1 -1
- package/dist/loadPaused.js +12 -8
- package/dist/loadPaused.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js.map +1 -1
- package/lib/createAndLoadContainerUtils.d.ts +125 -0
- package/lib/createAndLoadContainerUtils.d.ts.map +1 -0
- package/lib/createAndLoadContainerUtils.js +44 -0
- package/lib/createAndLoadContainerUtils.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +7 -0
- package/lib/loadPaused.d.ts +4 -3
- package/lib/loadPaused.d.ts.map +1 -1
- package/lib/loadPaused.js +12 -8
- package/lib/loadPaused.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +13 -13
- package/src/container.ts +2 -2
- package/src/createAndLoadContainerUtils.ts +182 -0
- package/src/index.ts +9 -0
- package/src/loadPaused.ts +14 -9
- package/src/packageVersion.ts +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
IContainer,
|
|
8
|
+
ICodeDetailsLoader,
|
|
9
|
+
IFluidCodeDetails,
|
|
10
|
+
type IContainerPolicies,
|
|
11
|
+
} from "@fluidframework/container-definitions/internal";
|
|
12
|
+
import {
|
|
13
|
+
FluidObject,
|
|
14
|
+
IConfigProviderBase,
|
|
15
|
+
IRequest,
|
|
16
|
+
ITelemetryBaseLogger,
|
|
17
|
+
} from "@fluidframework/core-interfaces";
|
|
18
|
+
import { IClientDetails } from "@fluidframework/driver-definitions";
|
|
19
|
+
import {
|
|
20
|
+
IDocumentServiceFactory,
|
|
21
|
+
IUrlResolver,
|
|
22
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
23
|
+
|
|
24
|
+
import { Loader } from "./loader.js";
|
|
25
|
+
import { ProtocolHandlerBuilder } from "./protocol.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Properties necessary for creating and loading a container.
|
|
29
|
+
* @legacy
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export interface ICreateAndLoadContainerProps {
|
|
33
|
+
/**
|
|
34
|
+
* The url resolver used by the loader for resolving external urls
|
|
35
|
+
* into Fluid urls such that the container specified by the
|
|
36
|
+
* external url can be loaded.
|
|
37
|
+
*/
|
|
38
|
+
readonly urlResolver: IUrlResolver;
|
|
39
|
+
/**
|
|
40
|
+
* The document service factory take the Fluid url provided
|
|
41
|
+
* by the resolved url and constructs all the necessary services
|
|
42
|
+
* for communication with the container's server.
|
|
43
|
+
*/
|
|
44
|
+
readonly documentServiceFactory: IDocumentServiceFactory;
|
|
45
|
+
/**
|
|
46
|
+
* The code loader handles loading the necessary code
|
|
47
|
+
* for running a container once it is loaded.
|
|
48
|
+
*/
|
|
49
|
+
readonly codeLoader: ICodeDetailsLoader;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A property bag of options/policies used by various layers
|
|
53
|
+
* to control features
|
|
54
|
+
*/
|
|
55
|
+
readonly options?: IContainerPolicies | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Scope is provided to all container and is a set of shared
|
|
59
|
+
* services for container's to integrate with their host environment.
|
|
60
|
+
*/
|
|
61
|
+
readonly scope?: FluidObject | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The logger that all telemetry should be pushed to.
|
|
65
|
+
*/
|
|
66
|
+
readonly logger?: ITelemetryBaseLogger | undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The configuration provider which may be used to control features.
|
|
70
|
+
*/
|
|
71
|
+
readonly configProvider?: IConfigProviderBase | undefined;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Optional property for allowing the container to use a custom
|
|
75
|
+
* protocol implementation for handling the quorum and/or the audience.
|
|
76
|
+
*/
|
|
77
|
+
readonly protocolHandlerBuilder?: ProtocolHandlerBuilder | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Disables the Container from reconnecting if false, allows reconnect otherwise.
|
|
81
|
+
*/
|
|
82
|
+
readonly allowReconnect?: boolean | undefined;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Client details provided in the override will be merged over the default client.
|
|
86
|
+
*/
|
|
87
|
+
readonly clientDetailsOverride?: IClientDetails | undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Props used to load a container.
|
|
92
|
+
* @legacy
|
|
93
|
+
* @alpha
|
|
94
|
+
*/
|
|
95
|
+
export interface ILoadExistingContainerProps extends ICreateAndLoadContainerProps {
|
|
96
|
+
/**
|
|
97
|
+
* The request to resolve the container.
|
|
98
|
+
*/
|
|
99
|
+
readonly request: IRequest;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Pending local state to be applied to the container.
|
|
103
|
+
*/
|
|
104
|
+
readonly pendingLocalState?: string | undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Props used to create a detached container.
|
|
109
|
+
* @legacy
|
|
110
|
+
* @alpha
|
|
111
|
+
*/
|
|
112
|
+
export interface ICreateDetachedContainerProps extends ICreateAndLoadContainerProps {
|
|
113
|
+
/**
|
|
114
|
+
* The code details for the container to be created.
|
|
115
|
+
*/
|
|
116
|
+
readonly codeDetails: IFluidCodeDetails;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Props used to rehydrate a detached container.
|
|
121
|
+
* @legacy
|
|
122
|
+
* @alpha
|
|
123
|
+
*/
|
|
124
|
+
export interface IRehydrateDetachedContainerProps extends ICreateAndLoadContainerProps {
|
|
125
|
+
/**
|
|
126
|
+
* The serialized state returned by calling serialize on another container
|
|
127
|
+
*/
|
|
128
|
+
readonly serializedState: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Creates a new container using the specified code details but in an unattached state. While unattached, all
|
|
133
|
+
* updates will only be local until the user explicitly attaches the container to a service provider.
|
|
134
|
+
* @param createDetachedContainerProps - Services and properties necessary for creating detached container.
|
|
135
|
+
* @legacy
|
|
136
|
+
* @alpha
|
|
137
|
+
*/
|
|
138
|
+
export async function createDetachedContainer(
|
|
139
|
+
createDetachedContainerProps: ICreateDetachedContainerProps,
|
|
140
|
+
): Promise<IContainer> {
|
|
141
|
+
const loader = new Loader(createDetachedContainerProps);
|
|
142
|
+
return loader.createDetachedContainer(createDetachedContainerProps.codeDetails, {
|
|
143
|
+
canReconnect: createDetachedContainerProps.allowReconnect,
|
|
144
|
+
clientDetailsOverride: createDetachedContainerProps.clientDetailsOverride,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new container using the specified snapshot but in an unattached state. While unattached, all
|
|
150
|
+
* updates will only be local until the user explicitly attaches the container to a service provider.
|
|
151
|
+
* @param rehydrateDetachedContainerProps - Services and properties necessary for rehydrating detached container from a previously serialized container's state.
|
|
152
|
+
* @legacy
|
|
153
|
+
* @alpha
|
|
154
|
+
*/
|
|
155
|
+
export async function rehydrateDetachedContainer(
|
|
156
|
+
rehydrateDetachedContainerProps: IRehydrateDetachedContainerProps,
|
|
157
|
+
): Promise<IContainer> {
|
|
158
|
+
const loader = new Loader(rehydrateDetachedContainerProps);
|
|
159
|
+
return loader.rehydrateDetachedContainerFromSnapshot(
|
|
160
|
+
rehydrateDetachedContainerProps.serializedState,
|
|
161
|
+
{
|
|
162
|
+
canReconnect: rehydrateDetachedContainerProps.allowReconnect,
|
|
163
|
+
clientDetailsOverride: rehydrateDetachedContainerProps.clientDetailsOverride,
|
|
164
|
+
},
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Loads a container with an existing snapshot from the service.
|
|
170
|
+
* @param loadExistingContainerProps - Services and properties necessary for loading an existing container.
|
|
171
|
+
* @legacy
|
|
172
|
+
* @alpha
|
|
173
|
+
*/
|
|
174
|
+
export async function loadExistingContainer(
|
|
175
|
+
loadExistingContainerProps: ILoadExistingContainerProps,
|
|
176
|
+
): Promise<IContainer> {
|
|
177
|
+
const loader = new Loader(loadExistingContainerProps);
|
|
178
|
+
return loader.resolve(
|
|
179
|
+
loadExistingContainerProps.request,
|
|
180
|
+
loadExistingContainerProps.pendingLocalState,
|
|
181
|
+
);
|
|
182
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
export { ConnectionState } from "./connectionState.js";
|
|
7
7
|
export { IContainerExperimental, waitContainerToCatchUp } from "./container.js";
|
|
8
|
+
export {
|
|
9
|
+
createDetachedContainer,
|
|
10
|
+
loadExistingContainer,
|
|
11
|
+
rehydrateDetachedContainer,
|
|
12
|
+
ICreateAndLoadContainerProps,
|
|
13
|
+
ICreateDetachedContainerProps,
|
|
14
|
+
ILoadExistingContainerProps,
|
|
15
|
+
IRehydrateDetachedContainerProps,
|
|
16
|
+
} from "./createAndLoadContainerUtils.js";
|
|
8
17
|
export {
|
|
9
18
|
ICodeDetailsLoader,
|
|
10
19
|
IDetachedBlobStorage,
|
package/src/loadPaused.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
ILoader,
|
|
8
7
|
isIDeltaManagerFull,
|
|
9
8
|
LoaderHeader,
|
|
10
9
|
type IContainer,
|
|
@@ -14,6 +13,9 @@ import type { IErrorBase } from "@fluidframework/core-interfaces";
|
|
|
14
13
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
15
14
|
import { GenericError } from "@fluidframework/telemetry-utils/internal";
|
|
16
15
|
|
|
16
|
+
import { loadExistingContainer } from "./createAndLoadContainerUtils.js";
|
|
17
|
+
import { type ILoaderProps } from "./loader.js";
|
|
18
|
+
|
|
17
19
|
/* eslint-disable jsdoc/check-indentation */
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -35,7 +37,7 @@ import { GenericError } from "@fluidframework/telemetry-utils/internal";
|
|
|
35
37
|
* network connectivity issues / ability to cancel (IContainer.disconnect) or close container (IContainer.close)
|
|
36
38
|
* This flow needs to fetch ops (potentially connecting to delta connection), and any retriable errors on this path result in infinite retry.
|
|
37
39
|
* If you need to cancel that process, consider supplying AbortSignal parameter.
|
|
38
|
-
* @param
|
|
40
|
+
* @param loaderProps - The loader props to use to load the container.
|
|
39
41
|
* @param request - request identifying container instance / load parameters. LoaderHeader.loadMode headers are ignored (see above)
|
|
40
42
|
* @param loadToSequenceNumber - optional sequence number. If provided, ops are processed up to this sequence number.
|
|
41
43
|
* @param signal - optional abort signal that can be used to cancel waiting for the ops.
|
|
@@ -44,17 +46,20 @@ import { GenericError } from "@fluidframework/telemetry-utils/internal";
|
|
|
44
46
|
* @internal
|
|
45
47
|
*/
|
|
46
48
|
export async function loadContainerPaused(
|
|
47
|
-
|
|
49
|
+
loaderProps: ILoaderProps,
|
|
48
50
|
request: IRequest,
|
|
49
51
|
loadToSequenceNumber?: number,
|
|
50
52
|
signal?: AbortSignal,
|
|
51
53
|
): Promise<IContainer> {
|
|
52
|
-
const container = await
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const container = await loadExistingContainer({
|
|
55
|
+
...loaderProps,
|
|
56
|
+
request: {
|
|
57
|
+
url: request.url,
|
|
58
|
+
headers: {
|
|
59
|
+
...request.headers,
|
|
60
|
+
// ensure we do not process any ops, such that we can examine container before ops starts to flow.
|
|
61
|
+
[LoaderHeader.loadMode]: { opsBeforeReturn: undefined, deltaConnection: "none" },
|
|
62
|
+
},
|
|
58
63
|
},
|
|
59
64
|
});
|
|
60
65
|
|
package/src/packageVersion.ts
CHANGED