@fluidframework/fluid-static 2.0.0-dev.1.4.5.105745 → 2.0.0-dev.2.2.0.111723
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 +1 -1
- package/dist/fluidContainer.d.ts +85 -70
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +13 -4
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +17 -15
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +16 -14
- package/dist/rootDataObject.js.map +1 -1
- package/dist/serviceAudience.d.ts +27 -15
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/serviceAudience.js +29 -13
- package/dist/serviceAudience.js.map +1 -1
- package/dist/types.d.ts +100 -70
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +85 -70
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +13 -4
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +17 -15
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +16 -14
- package/lib/rootDataObject.js.map +1 -1
- package/lib/serviceAudience.d.ts +27 -15
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.js +29 -13
- package/lib/serviceAudience.js.map +1 -1
- package/lib/types.d.ts +100 -70
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +49 -25
- package/prettier.config.cjs +8 -0
- package/src/fluidContainer.ts +103 -74
- package/src/index.ts +19 -4
- package/src/rootDataObject.ts +20 -17
- package/src/serviceAudience.ts +36 -16
- package/src/types.ts +108 -71
package/lib/fluidContainer.d.ts
CHANGED
|
@@ -5,69 +5,61 @@
|
|
|
5
5
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
6
6
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
|
|
8
|
-
import { AttachState, IContainer, ConnectionState } from "@fluidframework/container-definitions";
|
|
9
|
-
import { LoadableObjectClass, LoadableObjectRecord } from "./types";
|
|
10
|
-
import { RootDataObject } from "./rootDataObject";
|
|
8
|
+
import { AttachState, IContainer, ICriticalContainerError, ConnectionState } from "@fluidframework/container-definitions";
|
|
9
|
+
import type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from "./types";
|
|
11
10
|
/**
|
|
12
11
|
* Events emitted from {@link IFluidContainer}.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
*
|
|
16
|
-
* The following is the list of events emitted.
|
|
17
|
-
*
|
|
18
|
-
* ### "connected"
|
|
19
|
-
*
|
|
20
|
-
* The "connected" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
|
|
21
|
-
*
|
|
22
|
-
* #### Listener signature
|
|
23
|
-
*
|
|
24
|
-
* ```typescript
|
|
25
|
-
* () => void;
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* ### "dispose"
|
|
29
|
-
*
|
|
30
|
-
* The "dispose" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
|
|
31
|
-
*
|
|
32
|
-
* #### Listener signature
|
|
33
|
-
*
|
|
34
|
-
* ```typescript
|
|
35
|
-
* () => void;
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* ### "disconnected"
|
|
39
|
-
*
|
|
40
|
-
* The "disconnected" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
|
|
41
|
-
*
|
|
42
|
-
* #### Listener signature
|
|
43
|
-
*
|
|
44
|
-
* ```typescript
|
|
45
|
-
* () => void;
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* ### "saved"
|
|
49
|
-
*
|
|
50
|
-
* The "saved" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
|
|
51
|
-
*
|
|
52
|
-
* #### Listener signature
|
|
53
|
-
*
|
|
54
|
-
* ```typescript
|
|
55
|
-
* () => void
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* ### "dirty"
|
|
59
|
-
*
|
|
60
|
-
* The "dirty" event is emitted when the `IFluidContainer` has local changes that have not yet
|
|
61
|
-
* been acknowledged by the service.
|
|
62
|
-
*
|
|
63
|
-
* #### Listener signature
|
|
64
|
-
*
|
|
65
|
-
* ```typescript
|
|
66
|
-
* () => void
|
|
67
|
-
* ```
|
|
68
12
|
*/
|
|
69
13
|
export interface IFluidContainerEvents extends IEvent {
|
|
70
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
|
|
16
|
+
*
|
|
17
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
18
|
+
*
|
|
19
|
+
* @see
|
|
20
|
+
*
|
|
21
|
+
* - {@link IFluidContainer.connectionState}
|
|
22
|
+
*
|
|
23
|
+
* - {@link IFluidContainer.disconnect}
|
|
24
|
+
*/
|
|
25
|
+
(event: "connected", listener: () => void): void;
|
|
26
|
+
/**
|
|
27
|
+
* Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
|
|
28
|
+
*
|
|
29
|
+
* @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
|
|
30
|
+
*
|
|
31
|
+
* @see
|
|
32
|
+
*
|
|
33
|
+
* - {@link IFluidContainer.connectionState}
|
|
34
|
+
*
|
|
35
|
+
* - {@link IFluidContainer.disconnect}
|
|
36
|
+
*/
|
|
37
|
+
(event: "disconnected", listener: () => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Emitted when all local changes/edits have been acknowledged by the service.
|
|
40
|
+
*
|
|
41
|
+
* @remarks "dirty" event will be emitted when the next local change has been made.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link IFluidContainer.isDirty}
|
|
44
|
+
*/
|
|
45
|
+
(event: "saved", listener: () => void): void;
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when the first local change has been made, following a "saved" event.
|
|
48
|
+
*
|
|
49
|
+
* @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link IFluidContainer.isDirty}
|
|
52
|
+
*/
|
|
53
|
+
(event: "dirty", listener: () => void): void;
|
|
54
|
+
/**
|
|
55
|
+
* Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
*
|
|
59
|
+
* If container was closed due to error (as opposed to an explicit call to
|
|
60
|
+
* {@link IFluidContainer.dispose}), optional argument contains further details about the error.
|
|
61
|
+
*/
|
|
62
|
+
(event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
|
|
71
63
|
}
|
|
72
64
|
/**
|
|
73
65
|
* Provides an entrypoint into the client side of collaborative Fluid data.
|
|
@@ -80,6 +72,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
80
72
|
readonly connectionState: ConnectionState;
|
|
81
73
|
/**
|
|
82
74
|
* A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
*
|
|
83
78
|
* You should always check the `isDirty` flag before closing the container or navigating away from the page.
|
|
84
79
|
* Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
|
|
85
80
|
* acknowledged by the service.
|
|
@@ -97,16 +92,21 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
97
92
|
*/
|
|
98
93
|
readonly isDirty: boolean;
|
|
99
94
|
/**
|
|
100
|
-
* Whether the container is disposed, which permanently disables it.
|
|
95
|
+
* Whether or not the container is disposed, which permanently disables it.
|
|
101
96
|
*/
|
|
102
97
|
readonly disposed: boolean;
|
|
103
98
|
/**
|
|
104
99
|
* The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
|
|
105
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* @remarks These data objects and DDSes exist for the lifetime of the container.
|
|
106
102
|
*/
|
|
107
103
|
readonly initialObjects: LoadableObjectRecord;
|
|
108
104
|
/**
|
|
109
|
-
* The current attachment state of the container.
|
|
105
|
+
* The current attachment state of the container.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
*
|
|
109
|
+
* Once a container has been attached, it remains attached.
|
|
110
110
|
* When loading an existing container, it will already be attached.
|
|
111
111
|
*/
|
|
112
112
|
readonly attachState: AttachState;
|
|
@@ -114,7 +114,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
114
114
|
* A newly created container starts detached from the collaborative service.
|
|
115
115
|
* Calling `attach()` uploads the new container to the service and connects to the collaborative service.
|
|
116
116
|
*
|
|
117
|
-
* @remarks
|
|
117
|
+
* @remarks
|
|
118
|
+
*
|
|
119
|
+
* This should only be called when the container is in the
|
|
118
120
|
* {@link @fluidframework/container-definitions#AttachState.Detatched} state.
|
|
119
121
|
*
|
|
120
122
|
* This can be determined by observing {@link IFluidContainer.attachState}.
|
|
@@ -126,7 +128,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
126
128
|
* Attempts to connect the container to the delta stream and process operations.
|
|
127
129
|
* Will throw an error if unsuccessful.
|
|
128
130
|
*
|
|
129
|
-
* @remarks
|
|
131
|
+
* @remarks
|
|
132
|
+
*
|
|
133
|
+
* This should only be called when the container is in the
|
|
130
134
|
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
131
135
|
*
|
|
132
136
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -135,7 +139,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
135
139
|
/**
|
|
136
140
|
* Disconnects the container from the delta stream and stops processing operations.
|
|
137
141
|
*
|
|
138
|
-
* @remarks
|
|
142
|
+
* @remarks
|
|
143
|
+
*
|
|
144
|
+
* This should only be called when the container is in the
|
|
139
145
|
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
140
146
|
*
|
|
141
147
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
@@ -144,11 +150,15 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
144
150
|
/**
|
|
145
151
|
* Create a new data object or Distributed Data Store (DDS) of the specified type.
|
|
146
152
|
*
|
|
147
|
-
* @remarks
|
|
153
|
+
* @remarks
|
|
154
|
+
*
|
|
155
|
+
* In order to share the data object or DDS with other
|
|
148
156
|
* collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
|
|
149
157
|
* initialObjects.
|
|
150
158
|
*
|
|
151
|
-
* @param objectClass - The class of
|
|
159
|
+
* @param objectClass - The class of the `DataObject` or `SharedObject` to create.
|
|
160
|
+
*
|
|
161
|
+
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
152
162
|
*/
|
|
153
163
|
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
154
164
|
/**
|
|
@@ -159,7 +169,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
159
169
|
/**
|
|
160
170
|
* Base {@link IFluidContainer} implementation.
|
|
161
171
|
*
|
|
162
|
-
* @remarks
|
|
172
|
+
* @remarks
|
|
173
|
+
*
|
|
174
|
+
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
163
175
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
164
176
|
*/
|
|
165
177
|
export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
|
|
@@ -170,7 +182,7 @@ export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEve
|
|
|
170
182
|
private readonly disposedHandler;
|
|
171
183
|
private readonly savedHandler;
|
|
172
184
|
private readonly dirtyHandler;
|
|
173
|
-
constructor(container: IContainer, rootDataObject:
|
|
185
|
+
constructor(container: IContainer, rootDataObject: IRootDataObject);
|
|
174
186
|
/**
|
|
175
187
|
* {@inheritDoc IFluidContainer.isDirty}
|
|
176
188
|
*/
|
|
@@ -193,7 +205,10 @@ export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEve
|
|
|
193
205
|
get initialObjects(): LoadableObjectRecord;
|
|
194
206
|
/**
|
|
195
207
|
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
196
|
-
*
|
|
208
|
+
*
|
|
209
|
+
* @remarks
|
|
210
|
+
*
|
|
211
|
+
* Note: this implementation will unconditionally throw.
|
|
197
212
|
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
198
213
|
* that provides an implementation of this method.
|
|
199
214
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EACH,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,eAAe,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAA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MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
6
|
+
import { AttachState, } from "@fluidframework/container-definitions";
|
|
6
7
|
/**
|
|
7
8
|
* Base {@link IFluidContainer} implementation.
|
|
8
9
|
*
|
|
9
|
-
* @remarks
|
|
10
|
+
* @remarks
|
|
11
|
+
*
|
|
12
|
+
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
10
13
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
11
14
|
*/
|
|
12
15
|
export class FluidContainer extends TypedEventEmitter {
|
|
@@ -16,7 +19,7 @@ export class FluidContainer extends TypedEventEmitter {
|
|
|
16
19
|
this.rootDataObject = rootDataObject;
|
|
17
20
|
this.connectedHandler = () => this.emit("connected");
|
|
18
21
|
this.disconnectedHandler = () => this.emit("disconnected");
|
|
19
|
-
this.disposedHandler = () => this.emit("disposed");
|
|
22
|
+
this.disposedHandler = (error) => this.emit("disposed", error);
|
|
20
23
|
this.savedHandler = () => this.emit("saved");
|
|
21
24
|
this.dirtyHandler = () => this.emit("dirty");
|
|
22
25
|
container.on("connected", this.connectedHandler);
|
|
@@ -57,7 +60,10 @@ export class FluidContainer extends TypedEventEmitter {
|
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* Incomplete base implementation of {@link IFluidContainer.attach}.
|
|
60
|
-
*
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
*
|
|
66
|
+
* Note: this implementation will unconditionally throw.
|
|
61
67
|
* Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
|
|
62
68
|
* that provides an implementation of this method.
|
|
63
69
|
*
|
|
@@ -65,7 +71,10 @@ export class FluidContainer extends TypedEventEmitter {
|
|
|
65
71
|
* but internally this separation is not there.
|
|
66
72
|
*/
|
|
67
73
|
async attach() {
|
|
68
|
-
|
|
74
|
+
if (this.container.attachState !== AttachState.Detached) {
|
|
75
|
+
throw new Error("Cannot attach container. Container is not in detached state.");
|
|
76
|
+
}
|
|
77
|
+
throw new Error("Cannot attach container. Attach method not provided.");
|
|
69
78
|
}
|
|
70
79
|
/**
|
|
71
80
|
* {@inheritDoc IFluidContainer.connect}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAsKjE;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAwC;IAOxE,YACqB,SAAqB,EACrB,cAA8B;QAE/C,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,mBAAc,GAAd,cAAc,CAAgB;QARlC,qBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,wBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACtD,oBAAe,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9C,iBAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,iBAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAOrD,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACjD,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7C,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,C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AAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport { AttachState, IContainer, ConnectionState } from \"@fluidframework/container-definitions\";\nimport { LoadableObjectClass, LoadableObjectRecord } from \"./types\";\nimport { RootDataObject } from \"./rootDataObject\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n *\n * @remarks\n *\n * The following is the list of events emitted.\n *\n * ### \"connected\"\n *\n * The \"connected\" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void;\n * ```\n *\n * ### \"dispose\"\n *\n * The \"dispose\" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void;\n * ```\n *\n * ### \"disconnected\"\n *\n * The \"disconnected\" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void;\n * ```\n *\n * ### \"saved\"\n *\n * The \"saved\" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void\n * ```\n *\n * ### \"dirty\"\n *\n * The \"dirty\" event is emitted when the `IFluidContainer` has local changes that have not yet\n * been acknowledged by the service.\n *\n * #### Listener signature\n *\n * ```typescript\n * () => void\n * ```\n */\nexport interface IFluidContainerEvents extends IEvent {\n (event: \"connected\" | \"dispose\" | \"disconnected\" | \"saved\" | \"dirty\", listener: () => void): void;\n}\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n * These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container. Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n * Will throw an error if unsuccessful.\n *\n * @remarks This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of data object or DDS to create\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = () => this.emit(\"disposed\");\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: RootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n * @remarks Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n throw new Error(\"Cannot attach container. Container is not in detached state\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EACH,WAAW,GAId,MAAM,uCAAuC,CAAC;AAmL/C;;;;;;;GAOG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAwC;IAOxE,YACqB,SAAqB,EACrB,cAA+B;QAEhD,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,mBAAc,GAAd,cAAc,CAAiB;QARnC,qBAAgB,GAAG,GAAG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;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,MAAM;QACf,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,KAAK,WAAW,CAAC,QAAQ,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;SACnF;QACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;;QAChB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,OAAO,kDAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;;QACnB,MAAA,MAAA,IAAI,CAAC,SAAS,EAAC,UAAU,kDAAI,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAA2B,WAAmC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IEvent, IEventProvider } from \"@fluidframework/common-definitions\";\nimport {\n AttachState,\n IContainer,\n ICriticalContainerError,\n ConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\n/* eslint-disable @typescript-eslint/unified-signatures */\nexport interface IFluidContainerEvents extends IEvent {\n /**\n * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"connected\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n *\n * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n *\n * @see\n *\n * - {@link IFluidContainer.connectionState}\n *\n * - {@link IFluidContainer.disconnect}\n */\n (event: \"disconnected\", listener: () => void): void;\n\n /**\n * Emitted when all local changes/edits have been acknowledged by the service.\n *\n * @remarks \"dirty\" event will be emitted when the next local change has been made.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"saved\", listener: () => void): void;\n\n /**\n * Emitted when the first local change has been made, following a \"saved\" event.\n *\n * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n *\n * @see {@link IFluidContainer.isDirty}\n */\n (event: \"dirty\", listener: () => void): void;\n\n /**\n * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n *\n * @remarks\n *\n * If container was closed due to error (as opposed to an explicit call to\n * {@link IFluidContainer.dispose}), optional argument contains further details about the error.\n */\n (event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n/* eslint-enable @typescript-eslint/unified-signatures */\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n /**\n * Provides the current connected state of the container\n */\n readonly connectionState: ConnectionState;\n\n /**\n * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n *\n * @remarks\n *\n * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n * acknowledged by the service.\n *\n * A container is considered dirty in the following cases:\n *\n * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n * attached, host may never know if the file was created or not.\n *\n * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n * service. In some cases this can be due to lack of network connection. If the network connection is down,\n * it needs to be restored for the pending changes to be acknowledged.\n */\n readonly isDirty: boolean;\n\n /**\n * Whether or not the container is disposed, which permanently disables it.\n */\n readonly disposed: boolean;\n\n /**\n * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n *\n * @remarks These data objects and DDSes exist for the lifetime of the container.\n */\n readonly initialObjects: LoadableObjectRecord;\n\n /**\n * The current attachment state of the container.\n *\n * @remarks\n *\n * Once a container has been attached, it remains attached.\n * When loading an existing container, it will already be attached.\n */\n readonly attachState: AttachState;\n\n /**\n * A newly created container starts detached from the collaborative service.\n * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n *\n * This can be determined by observing {@link IFluidContainer.attachState}.\n *\n * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n */\n attach(): Promise<string>;\n\n /**\n * Attempts to connect the container to the delta stream and process operations.\n * Will throw an error if unsuccessful.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n connect(): void;\n\n /**\n * Disconnects the container from the delta stream and stops processing operations.\n *\n * @remarks\n *\n * This should only be called when the container is in the\n * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n *\n * This can be determined by observing {@link IFluidContainer.connectionState}.\n */\n disconnect(): void;\n\n /**\n * Create a new data object or Distributed Data Store (DDS) of the specified type.\n *\n * @remarks\n *\n * In order to share the data object or DDS with other\n * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n * initialObjects.\n *\n * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n */\n create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n /**\n * Dispose of the container instance, permanently disabling it.\n */\n dispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {\n private readonly connectedHandler = () => this.emit(\"connected\");\n private readonly disconnectedHandler = () => this.emit(\"disconnected\");\n private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit(\"disposed\", error);\n private readonly savedHandler = () => this.emit(\"saved\");\n private readonly dirtyHandler = () => this.emit(\"dirty\");\n\n public constructor(\n private readonly container: IContainer,\n private readonly rootDataObject: IRootDataObject,\n ) {\n super();\n container.on(\"connected\", this.connectedHandler);\n container.on(\"closed\", this.disposedHandler);\n container.on(\"disconnected\", this.disconnectedHandler);\n container.on(\"saved\", this.savedHandler);\n container.on(\"dirty\", this.dirtyHandler);\n }\n\n /**\n * {@inheritDoc IFluidContainer.isDirty}\n */\n public get isDirty(): boolean {\n return this.container.isDirty;\n }\n\n /**\n * {@inheritDoc IFluidContainer.attachState}\n */\n public get attachState(): AttachState {\n return this.container.attachState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.disposed}\n */\n public get disposed() {\n return this.container.closed;\n }\n\n /**\n * {@inheritDoc IFluidContainer.connectionState}\n */\n public get connectionState(): ConnectionState {\n return this.container.connectionState;\n }\n\n /**\n * {@inheritDoc IFluidContainer.initialObjects}\n */\n public get initialObjects() {\n return this.rootDataObject.initialObjects;\n }\n\n /**\n * Incomplete base implementation of {@link IFluidContainer.attach}.\n *\n * @remarks\n *\n * Note: this implementation will unconditionally throw.\n * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n * that provides an implementation of this method.\n *\n * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n * but internally this separation is not there.\n */\n public async attach(): Promise<string> {\n if (this.container.attachState !== AttachState.Detached) {\n throw new Error(\"Cannot attach container. Container is not in detached state.\");\n }\n throw new Error(\"Cannot attach container. Attach method not provided.\");\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async connect(): Promise<void> {\n this.container.connect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.connect}\n */\n public async disconnect(): Promise<void> {\n this.container.disconnect?.();\n }\n\n /**\n * {@inheritDoc IFluidContainer.create}\n */\n public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n return this.rootDataObject.create(objectClass);\n }\n\n /**\n * {@inheritDoc IFluidContainer.dispose}\n */\n public dispose() {\n this.container.close();\n this.container.off(\"connected\", this.connectedHandler);\n this.container.off(\"closed\", this.disposedHandler);\n this.container.off(\"disconnected\", this.disconnectedHandler);\n this.container.off(\"saved\", this.savedHandler);\n this.container.off(\"dirty\", this.dirtyHandler);\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
10
|
+
export { FluidContainer, IFluidContainer, IFluidContainerEvents } from "./fluidContainer";
|
|
11
|
+
export { DOProviderContainerRuntimeFactory, RootDataObject, RootDataObjectProps } from "./rootDataObject";
|
|
12
|
+
export { ServiceAudience } from "./serviceAudience";
|
|
13
|
+
export { ContainerSchema, DataObjectClass, IConnection, IMember, IRootDataObject, IServiceAudience, IServiceAudienceEvents, LoadableObjectClass, LoadableObjectClassRecord, LoadableObjectCtor, LoadableObjectRecord, MemberChangedListener, SharedObjectClass, Myself, } from "./types";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,iCAAiC,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACN,eAAe,EACf,eAAe,EACf,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACd,MAAM,GACT,MAAM,SAAS,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export * from "./types";
|
|
10
|
+
export { FluidContainer } from "./fluidContainer";
|
|
11
|
+
export { DOProviderContainerRuntimeFactory, RootDataObject } from "./rootDataObject";
|
|
12
|
+
export { ServiceAudience } from "./serviceAudience";
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAA0C,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,iCAAiC,EAAE,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport { FluidContainer, IFluidContainer, IFluidContainerEvents } from \"./fluidContainer\";\nexport { DOProviderContainerRuntimeFactory, RootDataObject, RootDataObjectProps } from \"./rootDataObject\";\nexport { ServiceAudience } from \"./serviceAudience\";\nexport {\n\tContainerSchema,\n\tDataObjectClass,\n\tIConnection,\n\tIMember,\n\tIRootDataObject,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectCtor,\n\tLoadableObjectRecord,\n\tMemberChangedListener,\n\tSharedObjectClass,\n Myself,\n} from \"./types\";\n"]}
|
package/lib/rootDataObject.d.ts
CHANGED
|
@@ -5,25 +5,25 @@
|
|
|
5
5
|
import { BaseContainerRuntimeFactory, DataObject } from "@fluidframework/aqueduct";
|
|
6
6
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
7
7
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { ContainerSchema, LoadableObjectClass, LoadableObjectClassRecord, LoadableObjectRecord } from "./types";
|
|
8
|
+
import { ContainerSchema, IRootDataObject, LoadableObjectClass, LoadableObjectClassRecord, LoadableObjectRecord } from "./types";
|
|
9
9
|
/**
|
|
10
|
-
* Input props for {@link RootDataObject.initializingFirstTime}
|
|
10
|
+
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
11
11
|
*/
|
|
12
12
|
export interface RootDataObjectProps {
|
|
13
13
|
/**
|
|
14
14
|
* Initial object structure with which the {@link RootDataObject} will be first-time initialized.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* @see {@link RootDataObject.initializingFirstTime}
|
|
16
17
|
*/
|
|
17
18
|
initialObjects: LoadableObjectClassRecord;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
* The entry-point/root collaborative object of the Fluid Container.
|
|
21
|
-
*
|
|
22
|
-
* for end customers.
|
|
21
|
+
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
22
|
+
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
23
23
|
*/
|
|
24
24
|
export declare class RootDataObject extends DataObject<{
|
|
25
25
|
InitialState: RootDataObjectProps;
|
|
26
|
-
}> {
|
|
26
|
+
}> implements IRootDataObject {
|
|
27
27
|
private readonly initialObjectsDirKey;
|
|
28
28
|
private readonly _initialObjects;
|
|
29
29
|
private get initialObjectsDir();
|
|
@@ -31,32 +31,34 @@ export declare class RootDataObject extends DataObject<{
|
|
|
31
31
|
* The first time this object is initialized, creates each object identified in
|
|
32
32
|
* {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
|
|
35
35
|
*/
|
|
36
36
|
protected initializingFirstTime(props: RootDataObjectProps): Promise<void>;
|
|
37
37
|
/**
|
|
38
38
|
* Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
|
|
39
39
|
* accessed immediately.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
41
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
|
|
42
42
|
*/
|
|
43
43
|
protected hasInitialized(): Promise<void>;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* See {@link RootDataObject.initializingFirstTime}
|
|
45
|
+
* {@inheritDoc IRootDataObject.initialObjects}
|
|
47
46
|
*/
|
|
48
47
|
get initialObjects(): LoadableObjectRecord;
|
|
49
48
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param objectClass - Type of the collaborative object to be created.
|
|
49
|
+
* {@inheritDoc IRootDataObject.create}
|
|
52
50
|
*/
|
|
53
51
|
create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
|
|
54
52
|
private createDataObject;
|
|
55
53
|
private createSharedObject;
|
|
56
54
|
}
|
|
57
55
|
/**
|
|
58
|
-
* Container code that provides a single {@link RootDataObject}.
|
|
59
|
-
*
|
|
56
|
+
* Container code that provides a single {@link RootDataObject}.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
*
|
|
60
|
+
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
61
|
+
* to the container runtime factory.
|
|
60
62
|
*/
|
|
61
63
|
export declare class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
62
64
|
private readonly rootDataObjectFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACH,2BAA2B,EAC3B,UAAU,EAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GA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BaseContainerRuntimeFactory, DataObject, DataObjectFactory, defaultRouteRequestHandler, } from "@fluidframework/aqueduct";
|
|
6
6
|
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
7
|
-
import { requestFluidObject } from "@fluidframework/runtime-utils";
|
|
8
7
|
import { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from "./utils";
|
|
9
8
|
/**
|
|
10
|
-
* The entry-point/root collaborative object of the Fluid Container.
|
|
11
|
-
*
|
|
12
|
-
* for end customers.
|
|
9
|
+
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
10
|
+
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
13
11
|
*/
|
|
14
12
|
export class RootDataObject extends DataObject {
|
|
15
13
|
constructor() {
|
|
@@ -28,7 +26,7 @@ export class RootDataObject extends DataObject {
|
|
|
28
26
|
* The first time this object is initialized, creates each object identified in
|
|
29
27
|
* {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
|
|
30
28
|
*
|
|
31
|
-
*
|
|
29
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
|
|
32
30
|
*/
|
|
33
31
|
async initializingFirstTime(props) {
|
|
34
32
|
this.root.createSubDirectory(this.initialObjectsDirKey);
|
|
@@ -47,7 +45,7 @@ export class RootDataObject extends DataObject {
|
|
|
47
45
|
* Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
|
|
48
46
|
* accessed immediately.
|
|
49
47
|
*
|
|
50
|
-
*
|
|
48
|
+
* @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
|
|
51
49
|
*/
|
|
52
50
|
async hasInitialized() {
|
|
53
51
|
// We will always load the initial objects so they are available to the developer
|
|
@@ -62,8 +60,7 @@ export class RootDataObject extends DataObject {
|
|
|
62
60
|
await Promise.all(loadInitialObjectsP);
|
|
63
61
|
}
|
|
64
62
|
/**
|
|
65
|
-
*
|
|
66
|
-
* See {@link RootDataObject.initializingFirstTime}
|
|
63
|
+
* {@inheritDoc IRootDataObject.initialObjects}
|
|
67
64
|
*/
|
|
68
65
|
get initialObjects() {
|
|
69
66
|
if (Object.keys(this._initialObjects).length === 0) {
|
|
@@ -72,8 +69,7 @@ export class RootDataObject extends DataObject {
|
|
|
72
69
|
return this._initialObjects;
|
|
73
70
|
}
|
|
74
71
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param objectClass - Type of the collaborative object to be created.
|
|
72
|
+
* {@inheritDoc IRootDataObject.create}
|
|
77
73
|
*/
|
|
78
74
|
async create(objectClass) {
|
|
79
75
|
if (isDataObjectClass(objectClass)) {
|
|
@@ -85,10 +81,12 @@ export class RootDataObject extends DataObject {
|
|
|
85
81
|
throw new Error("Could not create new Fluid object because an unknown object was passed");
|
|
86
82
|
}
|
|
87
83
|
async createDataObject(dataObjectClass) {
|
|
84
|
+
var _a;
|
|
88
85
|
const factory = dataObjectClass.factory;
|
|
89
86
|
const packagePath = [...this.context.packagePath, factory.type];
|
|
90
|
-
const
|
|
91
|
-
|
|
87
|
+
const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
|
|
88
|
+
const entryPoint = await ((_a = dataStore.entryPoint) === null || _a === void 0 ? void 0 : _a.get());
|
|
89
|
+
return entryPoint;
|
|
92
90
|
}
|
|
93
91
|
createSharedObject(sharedObjectClass) {
|
|
94
92
|
const factory = sharedObjectClass.getFactory();
|
|
@@ -98,8 +96,12 @@ export class RootDataObject extends DataObject {
|
|
|
98
96
|
}
|
|
99
97
|
const rootDataStoreId = "rootDOId";
|
|
100
98
|
/**
|
|
101
|
-
* Container code that provides a single {@link RootDataObject}.
|
|
102
|
-
*
|
|
99
|
+
* Container code that provides a single {@link RootDataObject}.
|
|
100
|
+
*
|
|
101
|
+
* @remarks
|
|
102
|
+
*
|
|
103
|
+
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
104
|
+
* to the container runtime factory.
|
|
103
105
|
*/
|
|
104
106
|
export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
105
107
|
constructor(schema) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACH,2BAA2B,EAC3B,UAAU,EACV,iBAAiB,EACjB,0BAA0B,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AASnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAapG;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAkD;IAAtF;;QACqB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA4FhE,CAAC;IA1FG,IAAY,iBAAiB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC5D,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAExD,mDAAmD;QACnD,MAAM,eAAe,GAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE;YAC/D,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;gBAC5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC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S,EAAE,CACrC,CAAC;QACF,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAChD,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACrE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAC/C,eAAe,EACf,OAAO,EACP,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n BaseContainerRuntimeFactory,\n DataObject,\n DataObjectFactory,\n defaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ContainerSchema,\n DataObjectClass,\n LoadableObjectClass,\n LoadableObjectClassRecord,\n LoadableObjectRecord,\n SharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}\n */\nexport interface RootDataObjectProps {\n /**\n * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n * See {@link RootDataObject.initializingFirstTime}\n */\n initialObjects: LoadableObjectClassRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the Fluid Container.\n * This class abstracts the dynamic code required to build a Fluid Container into a static representation\n * for end customers.\n */\nexport class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {\n private readonly initialObjectsDirKey = \"initial-objects-key\";\n private readonly _initialObjects: LoadableObjectRecord = {};\n\n private get initialObjectsDir() {\n const dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n if (dir === undefined) {\n throw new Error(\"InitialObjects sub-directory was not initialized\");\n }\n return dir;\n }\n\n /**\n * The first time this object is initialized, creates each object identified in\n * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n *\n * See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n */\n protected async initializingFirstTime(props: RootDataObjectProps) {\n this.root.createSubDirectory(this.initialObjectsDirKey);\n\n // Create initial objects provided by the developer\n const initialObjectsP: Promise<void>[] = [];\n Object.entries(props.initialObjects).forEach(([id, objectClass]) => {\n const createObject = async () => {\n const obj = await this.create(objectClass);\n this.initialObjectsDir.set(id, obj.handle);\n };\n initialObjectsP.push(createObject());\n });\n\n await Promise.all(initialObjectsP);\n }\n\n /**\n * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n * accessed immediately.\n *\n * See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n */\n protected async hasInitialized() {\n // We will always load the initial objects so they are available to the developer\n const loadInitialObjectsP: Promise<void>[] = [];\n for (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n const loadDir = async () => {\n const obj = await value.get();\n Object.assign(this._initialObjects, { [key]: obj });\n };\n loadInitialObjectsP.push(loadDir());\n }\n\n await Promise.all(loadInitialObjectsP);\n }\n\n /**\n * Provides a record of the initial objects defined on creation.\n * See {@link RootDataObject.initializingFirstTime}\n */\n public get initialObjects(): LoadableObjectRecord {\n if (Object.keys(this._initialObjects).length === 0) {\n throw new Error(\"Initial Objects were not correctly initialized\");\n }\n return this._initialObjects;\n }\n\n /**\n * Dynamically creates a new detached collaborative object (DDS/DataObject).\n * @param objectClass - Type of the collaborative object to be created.\n */\n public async create<T extends IFluidLoadable>(\n objectClass: LoadableObjectClass<T>,\n ): Promise<T> {\n if (isDataObjectClass(objectClass)) {\n return this.createDataObject<T>(objectClass);\n } else if (isSharedObjectClass(objectClass)) {\n return this.createSharedObject<T>(objectClass);\n }\n throw new Error(\"Could not create new Fluid object because an unknown object was passed\");\n }\n\n private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {\n const factory = dataObjectClass.factory;\n const packagePath = [...this.context.packagePath, factory.type];\n const router = await this.context.containerRuntime.createDataStore(packagePath);\n return requestFluidObject<T>(router, \"/\");\n }\n\n private createSharedObject<T extends IFluidLoadable>(\n sharedObjectClass: SharedObjectClass<T>,\n ): T {\n const factory = sharedObjectClass.getFactory();\n const obj = this.runtime.createChannel(undefined, factory.type);\n return obj as unknown as T;\n }\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Container code that provides a single {@link RootDataObject}. This data object is\n * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {\n InitialState: RootDataObjectProps;\n }>;\n\n private readonly initialObjects: LoadableObjectClassRecord;\n\n constructor(schema: ContainerSchema) {\n const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n const rootDataObjectFactory =\n new DataObjectFactory(\n \"rootDO\",\n RootDataObject,\n sharedObjects,\n {},\n registryEntries,\n );\n super(\n [rootDataObjectFactory.registryEntry],\n undefined,\n [defaultRouteRequestHandler(rootDataStoreId)],\n // temporary workaround to disable message batching until the message batch size issue is resolved\n // resolution progress is tracked by the Feature 465 work item in AzDO\n { flushMode: FlushMode.Immediate },\n );\n this.rootDataObjectFactory = rootDataObjectFactory;\n this.initialObjects = schema.initialObjects;\n }\n\n /**\n * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n // The first time we create the container we create the RootDataObject\n await this.rootDataObjectFactory.createRootInstance(\n rootDataStoreId,\n runtime,\n { initialObjects: this.initialObjects });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":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;IAChD,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACrE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAC/C,eAAe,EACf,OAAO,EACP,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACjD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n BaseContainerRuntimeFactory,\n DataObject,\n DataObjectFactory,\n defaultRouteRequestHandler,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport {\n ContainerSchema,\n DataObjectClass,\n IRootDataObject,\n LoadableObjectClass,\n LoadableObjectClassRecord,\n LoadableObjectRecord,\n SharedObjectClass,\n} from \"./types\";\nimport { isDataObjectClass, isSharedObjectClass, parseDataObjectsFromSharedObjects } from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\nexport interface RootDataObjectProps {\n /**\n * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n *\n * @see {@link RootDataObject.initializingFirstTime}\n */\n initialObjects: LoadableObjectClassRecord;\n}\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nexport class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> implements IRootDataObject {\n private readonly initialObjectsDirKey = \"initial-objects-key\";\n private readonly _initialObjects: LoadableObjectRecord = {};\n\n private get initialObjectsDir() {\n const dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n if (dir === undefined) {\n throw new Error(\"InitialObjects sub-directory was not initialized\");\n }\n return dir;\n }\n\n /**\n * The first time this object is initialized, creates each object identified in\n * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n *\n * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n */\n protected async initializingFirstTime(props: RootDataObjectProps) {\n this.root.createSubDirectory(this.initialObjectsDirKey);\n\n // Create initial objects provided by the developer\n const initialObjectsP: Promise<void>[] = [];\n Object.entries(props.initialObjects).forEach(([id, objectClass]) => {\n const createObject = async () => {\n const obj = await this.create(objectClass);\n this.initialObjectsDir.set(id, obj.handle);\n };\n initialObjectsP.push(createObject());\n });\n\n await Promise.all(initialObjectsP);\n }\n\n /**\n * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n * accessed immediately.\n *\n * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n */\n protected async hasInitialized() {\n // We will always load the initial objects so they are available to the developer\n const loadInitialObjectsP: Promise<void>[] = [];\n for (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n const loadDir = async () => {\n const obj = await value.get();\n Object.assign(this._initialObjects, { [key]: obj });\n };\n loadInitialObjectsP.push(loadDir());\n }\n\n await Promise.all(loadInitialObjectsP);\n }\n\n /**\n * {@inheritDoc IRootDataObject.initialObjects}\n */\n public get initialObjects(): LoadableObjectRecord {\n if (Object.keys(this._initialObjects).length === 0) {\n throw new Error(\"Initial Objects were not correctly initialized\");\n }\n return this._initialObjects;\n }\n\n /**\n * {@inheritDoc IRootDataObject.create}\n */\n public async create<T extends IFluidLoadable>(\n objectClass: LoadableObjectClass<T>,\n ): Promise<T> {\n if (isDataObjectClass(objectClass)) {\n return this.createDataObject<T>(objectClass);\n } else if (isSharedObjectClass(objectClass)) {\n return this.createSharedObject<T>(objectClass);\n }\n throw new Error(\"Could not create new Fluid object because an unknown object was passed\");\n }\n\n private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {\n const factory = dataObjectClass.factory;\n const packagePath = [...this.context.packagePath, factory.type];\n const dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n const entryPoint = await dataStore.entryPoint?.get();\n return entryPoint as unknown as T;\n }\n\n private createSharedObject<T extends IFluidLoadable>(\n sharedObjectClass: SharedObjectClass<T>,\n ): T {\n const factory = sharedObjectClass.getFactory();\n const obj = this.runtime.createChannel(undefined, factory.type);\n return obj as unknown as T;\n }\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * Container code that provides a single {@link RootDataObject}.\n *\n * @remarks\n *\n * This data object is dynamically customized (registry and initial objects) based on the schema provided.\n * to the container runtime factory.\n */\nexport class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n private readonly rootDataObjectFactory: DataObjectFactory<RootDataObject, {\n InitialState: RootDataObjectProps;\n }>;\n\n private readonly initialObjects: LoadableObjectClassRecord;\n\n constructor(schema: ContainerSchema) {\n const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n const rootDataObjectFactory =\n new DataObjectFactory(\n \"rootDO\",\n RootDataObject,\n sharedObjects,\n {},\n registryEntries,\n );\n super(\n [rootDataObjectFactory.registryEntry],\n undefined,\n [defaultRouteRequestHandler(rootDataStoreId)],\n // temporary workaround to disable message batching until the message batch size issue is resolved\n // resolution progress is tracked by the Feature 465 work item in AzDO\n { flushMode: FlushMode.Immediate },\n );\n this.rootDataObjectFactory = rootDataObjectFactory;\n this.initialObjects = schema.initialObjects;\n }\n\n /**\n * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n // The first time we create the container we create the RootDataObject\n await this.rootDataObjectFactory.createRootInstance(\n rootDataStoreId,\n runtime,\n { initialObjects: this.initialObjects });\n }\n}\n"]}
|