@fluidframework/container-loader 2.10.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/api-report/container-loader.legacy.alpha.api.md +39 -0
  3. package/dist/container.d.ts +6 -1
  4. package/dist/container.d.ts.map +1 -1
  5. package/dist/container.js +7 -0
  6. package/dist/container.js.map +1 -1
  7. package/dist/createAndLoadContainerUtils.d.ts +125 -0
  8. package/dist/createAndLoadContainerUtils.d.ts.map +1 -0
  9. package/dist/createAndLoadContainerUtils.js +50 -0
  10. package/dist/createAndLoadContainerUtils.js.map +1 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +5 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/legacy.d.ts +7 -0
  16. package/dist/loadPaused.d.ts +4 -3
  17. package/dist/loadPaused.d.ts.map +1 -1
  18. package/dist/loadPaused.js +12 -8
  19. package/dist/loadPaused.js.map +1 -1
  20. package/dist/packageVersion.d.ts +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/lib/container.d.ts +6 -1
  24. package/lib/container.d.ts.map +1 -1
  25. package/lib/container.js +7 -0
  26. package/lib/container.js.map +1 -1
  27. package/lib/createAndLoadContainerUtils.d.ts +125 -0
  28. package/lib/createAndLoadContainerUtils.d.ts.map +1 -0
  29. package/lib/createAndLoadContainerUtils.js +44 -0
  30. package/lib/createAndLoadContainerUtils.js.map +1 -0
  31. package/lib/index.d.ts +1 -0
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/index.js +1 -0
  34. package/lib/index.js.map +1 -1
  35. package/lib/legacy.d.ts +7 -0
  36. package/lib/loadPaused.d.ts +4 -3
  37. package/lib/loadPaused.d.ts.map +1 -1
  38. package/lib/loadPaused.js +12 -8
  39. package/lib/loadPaused.js.map +1 -1
  40. package/lib/packageVersion.d.ts +1 -1
  41. package/lib/packageVersion.js +1 -1
  42. package/lib/packageVersion.js.map +1 -1
  43. package/package.json +15 -19
  44. package/src/container.ts +11 -2
  45. package/src/createAndLoadContainerUtils.ts +182 -0
  46. package/src/index.ts +9 -0
  47. package/src/loadPaused.ts +14 -9
  48. 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 loader - loader instance to use to load container
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
- loader: ILoader,
49
+ loaderProps: ILoaderProps,
48
50
  request: IRequest,
49
51
  loadToSequenceNumber?: number,
50
52
  signal?: AbortSignal,
51
53
  ): Promise<IContainer> {
52
- const container = await loader.resolve({
53
- url: request.url,
54
- headers: {
55
- ...request.headers,
56
- // ensure we do not process any ops, such that we can examine container before ops starts to flow.
57
- [LoaderHeader.loadMode]: { opsBeforeReturn: undefined, deltaConnection: "none" },
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
 
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-loader";
9
- export const pkgVersion = "2.10.0";
9
+ export const pkgVersion = "2.12.0";