@fluidframework/fluid-static 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277

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 (101) hide show
  1. package/.eslintrc.js +8 -10
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +225 -53
  4. package/README.md +38 -0
  5. package/api-extractor-esm.json +4 -0
  6. package/api-extractor-lint.json +4 -0
  7. package/api-extractor.json +2 -2
  8. package/api-report/fluid-static.api.md +141 -0
  9. package/dist/fluid-static-alpha.d.ts +408 -0
  10. package/dist/fluid-static-beta.d.ts +412 -0
  11. package/dist/fluid-static-public.d.ts +412 -0
  12. package/dist/fluid-static-untrimmed.d.ts +452 -0
  13. package/dist/{fluidContainer.js → fluidContainer.cjs} +39 -12
  14. package/dist/fluidContainer.cjs.map +1 -0
  15. package/dist/fluidContainer.d.ts +95 -142
  16. package/dist/fluidContainer.d.ts.map +1 -1
  17. package/dist/index.cjs +19 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/{rootDataObject.js → rootDataObject.cjs} +59 -23
  22. package/dist/rootDataObject.cjs.map +1 -0
  23. package/dist/rootDataObject.d.ts +9 -59
  24. package/dist/rootDataObject.d.ts.map +1 -1
  25. package/dist/{serviceAudience.js → serviceAudience.cjs} +44 -20
  26. package/dist/serviceAudience.cjs.map +1 -0
  27. package/dist/serviceAudience.d.ts +7 -54
  28. package/dist/serviceAudience.d.ts.map +1 -1
  29. package/dist/tsdoc-metadata.json +11 -0
  30. package/dist/{types.js → types.cjs} +1 -1
  31. package/dist/types.cjs.map +1 -0
  32. package/dist/types.d.ts +130 -80
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/{utils.js → utils.cjs} +7 -9
  35. package/dist/utils.cjs.map +1 -0
  36. package/dist/utils.d.ts +10 -2
  37. package/dist/utils.d.ts.map +1 -1
  38. package/lib/fluid-static-alpha.d.mts +402 -0
  39. package/lib/fluid-static-beta.d.mts +406 -0
  40. package/lib/fluid-static-public.d.mts +406 -0
  41. package/lib/fluid-static-untrimmed.d.mts +446 -0
  42. package/lib/fluidContainer.d.mts +188 -0
  43. package/lib/fluidContainer.d.mts.map +1 -0
  44. package/lib/{fluidContainer.js → fluidContainer.mjs} +36 -13
  45. package/lib/fluidContainer.mjs.map +1 -0
  46. package/lib/index.d.mts +9 -0
  47. package/lib/index.d.mts.map +1 -0
  48. package/lib/index.mjs +8 -0
  49. package/lib/index.mjs.map +1 -0
  50. package/lib/rootDataObject.d.mts +20 -0
  51. package/lib/rootDataObject.d.mts.map +1 -0
  52. package/lib/{rootDataObject.js → rootDataObject.mjs} +61 -28
  53. package/lib/rootDataObject.mjs.map +1 -0
  54. package/lib/serviceAudience.d.mts +15 -0
  55. package/lib/serviceAudience.d.mts.map +1 -0
  56. package/lib/{serviceAudience.js → serviceAudience.mjs} +42 -18
  57. package/lib/serviceAudience.mjs.map +1 -0
  58. package/lib/types.d.mts +223 -0
  59. package/lib/types.d.mts.map +1 -0
  60. package/lib/{types.js → types.mjs} +1 -1
  61. package/lib/types.mjs.map +1 -0
  62. package/lib/{utils.d.ts → utils.d.mts} +12 -4
  63. package/lib/utils.d.mts.map +1 -0
  64. package/lib/{utils.js → utils.mjs} +7 -9
  65. package/lib/utils.mjs.map +1 -0
  66. package/package.json +151 -60
  67. package/prettier.config.cjs +8 -0
  68. package/src/fluidContainer.ts +316 -250
  69. package/src/index.ts +25 -4
  70. package/src/rootDataObject.ts +203 -157
  71. package/src/serviceAudience.ts +152 -124
  72. package/src/types.ts +190 -132
  73. package/src/utils.ts +44 -39
  74. package/tsc-multi.test.json +4 -0
  75. package/tsconfig.json +12 -16
  76. package/dist/fluidContainer.js.map +0 -1
  77. package/dist/index.js +0 -26
  78. package/dist/index.js.map +0 -1
  79. package/dist/rootDataObject.js.map +0 -1
  80. package/dist/serviceAudience.js.map +0 -1
  81. package/dist/types.js.map +0 -1
  82. package/dist/utils.js.map +0 -1
  83. package/lib/fluidContainer.d.ts +0 -235
  84. package/lib/fluidContainer.d.ts.map +0 -1
  85. package/lib/fluidContainer.js.map +0 -1
  86. package/lib/index.d.ts +0 -14
  87. package/lib/index.d.ts.map +0 -1
  88. package/lib/index.js +0 -14
  89. package/lib/index.js.map +0 -1
  90. package/lib/rootDataObject.d.ts +0 -70
  91. package/lib/rootDataObject.d.ts.map +0 -1
  92. package/lib/rootDataObject.js.map +0 -1
  93. package/lib/serviceAudience.d.ts +0 -62
  94. package/lib/serviceAudience.d.ts.map +0 -1
  95. package/lib/serviceAudience.js.map +0 -1
  96. package/lib/types.d.ts +0 -173
  97. package/lib/types.d.ts.map +0 -1
  98. package/lib/types.js.map +0 -1
  99. package/lib/utils.d.ts.map +0 -1
  100. package/lib/utils.js.map +0 -1
  101. package/tsconfig.esnext.json +0 -7
@@ -2,295 +2,361 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TypedEventEmitter } from "@fluidframework/common-utils";
6
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
7
- import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
8
7
  import {
9
- AttachState,
10
- ConnectionState,
11
- IContainer,
12
- ICriticalContainerError,
8
+ AttachState,
9
+ IContainer,
10
+ ICriticalContainerError,
11
+ ConnectionState,
13
12
  } from "@fluidframework/container-definitions";
14
- import { LoadableObjectClass, LoadableObjectRecord } from "./types";
15
- import { RootDataObject } from "./rootDataObject";
13
+ import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types";
14
+
15
+ /**
16
+ * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
17
+ * @public
18
+ */
19
+ export type InitialObjects<T extends ContainerSchema> = {
20
+ // Construct a LoadableObjectRecord type by enumerating the keys of
21
+ // 'ContainerSchema.initialObjects' and infering the value type of each key.
22
+ //
23
+ // The '? TChannel : never' is required because infer can only be used in
24
+ // a conditional 'extends' expression.
25
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<
26
+ infer TChannel
27
+ >
28
+ ? TChannel
29
+ : never;
30
+ };
16
31
 
17
32
  /**
18
33
  * Events emitted from {@link IFluidContainer}.
19
34
  *
20
- * @remarks
21
- *
22
- * The following is the list of events emitted.
23
- *
24
- * ### "connected"
25
- *
26
- * The "connected" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
27
- *
28
- * #### Listener signature
29
- *
30
- * ```typescript
31
- * () => void;
32
- * ```
33
- *
34
- * ### "disposed"
35
- *
36
- * The "disposed" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
37
- *
38
- * #### Listener signature
39
- *
40
- * ```typescript
41
- * () => void;
42
- * ```
43
- *
44
- * ### "disconnected"
45
- *
46
- * The "disconnected" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
47
- *
48
- * #### Listener signature
49
- *
50
- * ```typescript
51
- * () => void;
52
- * ```
53
- *
54
- * ### "saved"
55
- *
56
- * The "saved" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
57
- *
58
- * #### Listener signature
59
- *
60
- * ```typescript
61
- * () => void
62
- * ```
63
- *
64
- * ### "dirty"
65
- *
66
- * The "dirty" event is emitted when the `IFluidContainer` has local changes that have not yet
67
- * been acknowledged by the service.
68
- *
69
- * #### Listener signature
70
- *
71
- * ```typescript
72
- * () => void
73
- * ```
35
+ * @remarks Note: external implementations of this interface are not supported.
36
+ * @sealed
37
+ * @public
74
38
  */
75
39
  export interface IFluidContainerEvents extends IEvent {
76
- /**
77
- * **connected** & **disconnected** events reflect connection state changes against the (delta)
78
- * service acknowledging ops/edits.
79
- */
80
- (event: "connected" | "disconnected", listener: () => void): void;
81
- /**
82
- * **saved** event is raised when all local changes/edits have been acknowledged by the service.
83
- * **dirty** event is raised when first local change has been made, following a "saved" state.
84
- */
85
- // eslint-disable-next-line @typescript-eslint/unified-signatures
86
- (event: "saved" | "dirty", listener: () => void): void;
87
- /**
88
- * Disposed event is raised when container is closed. If container was closed due to error
89
- * (vs explicit **dispose** action), optional argument contains further details about the error.
90
- */
91
- (event: "disposed", listener: (error?: ICriticalContainerError) => void);
40
+ /**
41
+ * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
42
+ *
43
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
44
+ *
45
+ * @see
46
+ *
47
+ * - {@link IFluidContainer.connectionState}
48
+ *
49
+ * - {@link IFluidContainer.connect}
50
+ */
51
+ (event: "connected", listener: () => void): void;
52
+
53
+ /**
54
+ * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
55
+ *
56
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
57
+ *
58
+ * @see
59
+ *
60
+ * - {@link IFluidContainer.connectionState}
61
+ *
62
+ * - {@link IFluidContainer.disconnect}
63
+ */
64
+ (event: "disconnected", listener: () => void): void;
65
+
66
+ /**
67
+ * Emitted when all local changes/edits have been acknowledged by the service.
68
+ *
69
+ * @remarks "dirty" event will be emitted when the next local change has been made.
70
+ *
71
+ * @see {@link IFluidContainer.isDirty}
72
+ */
73
+ (event: "saved", listener: () => void): void;
74
+
75
+ /**
76
+ * Emitted when the first local change has been made, following a "saved" event.
77
+ *
78
+ * @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
79
+ *
80
+ * @see {@link IFluidContainer.isDirty}
81
+ */
82
+ (event: "dirty", listener: () => void): void;
83
+
84
+ /**
85
+ * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
86
+ *
87
+ * @remarks Listener parameters:
88
+ *
89
+ * - `error`: If the container was closed due to error (as opposed to an explicit call to
90
+ * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
91
+ */
92
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void);
92
93
  }
93
94
 
94
95
  /**
95
96
  * Provides an entrypoint into the client side of collaborative Fluid data.
96
97
  * Provides access to the data as well as status on the collaboration session.
98
+ *
99
+ * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
100
+ *
101
+ * @remarks Note: external implementations of this interface are not supported.
102
+ * @sealed
103
+ * @public
97
104
  */
98
- export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
99
- /**
100
- * Provides the current connected state of the container
101
- */
102
- readonly connectionState: ConnectionState;
105
+ export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
106
+ extends IEventProvider<IFluidContainerEvents> {
107
+ /**
108
+ * Provides the current connected state of the container
109
+ */
110
+ readonly connectionState: ConnectionState;
103
111
 
104
- /**
105
- * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
106
- * You should always check the `isDirty` flag before closing the container or navigating away from the page.
107
- * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
108
- * acknowledged by the service.
109
- *
110
- * A container is considered dirty in the following cases:
111
- *
112
- * 1. The container has been created in the detached state, and either it has not been attached yet or it is
113
- * in the process of being attached (container is in `attaching` state). If container is closed prior to being
114
- * attached, host may never know if the file was created or not.
115
- *
116
- * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.
117
- * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the
118
- * service. In some cases this can be due to lack of network connection. If the network connection is down,
119
- * it needs to be restored for the pending changes to be acknowledged.
120
- */
121
- readonly isDirty: boolean;
112
+ /**
113
+ * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
114
+ *
115
+ * @remarks
116
+ *
117
+ * You should always check the `isDirty` flag before closing the container or navigating away from the page.
118
+ * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
119
+ * acknowledged by the service.
120
+ *
121
+ * A container is considered dirty in the following cases:
122
+ *
123
+ * 1. The container has been created in the detached state, and either it has not been attached yet or it is
124
+ * in the process of being attached (container is in `attaching` state). If container is closed prior to being
125
+ * attached, host may never know if the file was created or not.
126
+ *
127
+ * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.
128
+ * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the
129
+ * service. In some cases this can be due to lack of network connection. If the network connection is down,
130
+ * it needs to be restored for the pending changes to be acknowledged.
131
+ */
132
+ readonly isDirty: boolean;
122
133
 
123
- /**
124
- * Whether the container is disposed, which permanently disables it.
125
- */
126
- readonly disposed: boolean;
134
+ /**
135
+ * Whether or not the container is disposed, which permanently disables it.
136
+ */
137
+ readonly disposed: boolean;
127
138
 
128
- /**
129
- * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
130
- * These data objects and DDSes exist for the lifetime of the container.
131
- */
132
- readonly initialObjects: LoadableObjectRecord;
139
+ /**
140
+ * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
141
+ *
142
+ * @remarks These data objects and DDSes exist for the lifetime of the container.
143
+ */
144
+ readonly initialObjects: InitialObjects<TContainerSchema>;
133
145
 
134
- /**
135
- * The current attachment state of the container. Once a container has been attached, it remains attached.
136
- * When loading an existing container, it will already be attached.
137
- */
138
- readonly attachState: AttachState;
146
+ /**
147
+ * The current attachment state of the container.
148
+ *
149
+ * @remarks
150
+ *
151
+ * Once a container has been attached, it remains attached.
152
+ * When loading an existing container, it will already be attached.
153
+ */
154
+ readonly attachState: AttachState;
139
155
 
140
- /**
141
- * A newly created container starts detached from the collaborative service.
142
- * Calling `attach()` uploads the new container to the service and connects to the collaborative service.
143
- *
144
- * @remarks This should only be called when the container is in the
145
- * {@link @fluidframework/container-definitions#AttachState.Detatched} state.
146
- *
147
- * This can be determined by observing {@link IFluidContainer.attachState}.
148
- *
149
- * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
150
- */
151
- attach(): Promise<string>;
156
+ /**
157
+ * A newly created container starts detached from the collaborative service.
158
+ * Calling `attach()` uploads the new container to the service and connects to the collaborative service.
159
+ *
160
+ * @remarks
161
+ *
162
+ * This should only be called when the container is in the
163
+ * {@link @fluidframework/container-definitions#AttachState.Detatched} state.
164
+ *
165
+ * This can be determined by observing {@link IFluidContainer.attachState}.
166
+ *
167
+ * @returns A promise which resolves when the attach is complete, with the string identifier of the container.
168
+ */
169
+ attach(): Promise<string>;
152
170
 
153
- /**
154
- * Attempts to connect the container to the delta stream and process operations.
155
- * Will throw an error if unsuccessful.
156
- *
157
- * @remarks This should only be called when the container is in the
158
- * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
159
- *
160
- * This can be determined by observing {@link IFluidContainer.connectionState}.
161
- */
162
- connect(): void;
171
+ /**
172
+ * Attempts to connect the container to the delta stream and process operations.
173
+ *
174
+ * @throws Will throw an error if connection is unsuccessful.
175
+ *
176
+ * @remarks
177
+ *
178
+ * This should only be called when the container is in the
179
+ * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
180
+ *
181
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
182
+ */
183
+ connect(): void;
163
184
 
164
- /**
165
- * Disconnects the container from the delta stream and stops processing operations.
166
- *
167
- * @remarks This should only be called when the container is in the
168
- * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
169
- *
170
- * This can be determined by observing {@link IFluidContainer.connectionState}.
171
- */
172
- disconnect(): void;
185
+ /**
186
+ * Disconnects the container from the delta stream and stops processing operations.
187
+ *
188
+ * @remarks
189
+ *
190
+ * This should only be called when the container is in the
191
+ * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
192
+ *
193
+ * This can be determined by observing {@link IFluidContainer.connectionState}.
194
+ */
195
+ disconnect(): void;
173
196
 
174
- /**
175
- * Create a new data object or Distributed Data Store (DDS) of the specified type.
176
- *
177
- * @remarks In order to share the data object or DDS with other
178
- * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
179
- * initialObjects.
180
- *
181
- * @param objectClass - The class of data object or DDS to create
182
- */
183
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
197
+ /**
198
+ * Create a new data object or Distributed Data Store (DDS) of the specified type.
199
+ *
200
+ * @remarks
201
+ *
202
+ * In order to share the data object or DDS with other
203
+ * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
204
+ * initialObjects.
205
+ *
206
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
207
+ *
208
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
209
+ */
210
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
184
211
 
185
- /**
186
- * Dispose of the container instance, permanently disabling it.
187
- */
188
- dispose(): void;
212
+ /**
213
+ * Dispose of the container instance, permanently disabling it.
214
+ */
215
+ dispose(): void;
216
+ }
217
+
218
+ /**
219
+ * @internal
220
+ */
221
+ export function createFluidContainer<
222
+ TContainerSchema extends ContainerSchema = ContainerSchema,
223
+ >(props: {
224
+ container: IContainer;
225
+ rootDataObject: IRootDataObject;
226
+ }): IFluidContainer<TContainerSchema> {
227
+ return new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);
189
228
  }
190
229
 
191
230
  /**
192
231
  * Base {@link IFluidContainer} implementation.
193
232
  *
194
- * @remarks Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
233
+ * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
234
+ * @remarks
235
+ *
236
+ * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
195
237
  * will need to utilize or provide a service-specific implementation of this type that implements that method.
238
+ * @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead
239
+ * @internal
196
240
  */
197
- export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
198
- private readonly connectedHandler = () => this.emit("connected");
199
- private readonly disconnectedHandler = () => this.emit("disconnected");
200
- private readonly disposedHandler = (error?: ICriticalContainerError) => this.emit("disposed", error);
201
- private readonly savedHandler = () => this.emit("saved");
202
- private readonly dirtyHandler = () => this.emit("dirty");
241
+ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
242
+ extends TypedEventEmitter<IFluidContainerEvents>
243
+ implements IFluidContainer<TContainerSchema>
244
+ {
245
+ private readonly connectedHandler = () => this.emit("connected");
246
+ private readonly disconnectedHandler = () => this.emit("disconnected");
247
+ private readonly disposedHandler = (error?: ICriticalContainerError) =>
248
+ this.emit("disposed", error);
249
+ private readonly savedHandler = () => this.emit("saved");
250
+ private readonly dirtyHandler = () => this.emit("dirty");
251
+
252
+ public constructor(
253
+ private readonly container: IContainer,
254
+ private readonly rootDataObject: IRootDataObject,
255
+ ) {
256
+ super();
257
+ container.on("connected", this.connectedHandler);
258
+ container.on("closed", this.disposedHandler);
259
+ container.on("disconnected", this.disconnectedHandler);
260
+ container.on("saved", this.savedHandler);
261
+ container.on("dirty", this.dirtyHandler);
262
+ }
203
263
 
204
- public constructor(
205
- private readonly container: IContainer,
206
- private readonly rootDataObject: RootDataObject,
207
- ) {
208
- super();
209
- container.on("connected", this.connectedHandler);
210
- container.on("closed", this.disposedHandler);
211
- container.on("disconnected", this.disconnectedHandler);
212
- container.on("saved", this.savedHandler);
213
- container.on("dirty", this.dirtyHandler);
214
- }
264
+ /**
265
+ * {@inheritDoc IFluidContainer.isDirty}
266
+ */
267
+ public get isDirty(): boolean {
268
+ return this.container.isDirty;
269
+ }
215
270
 
216
- /**
217
- * {@inheritDoc IFluidContainer.isDirty}
218
- */
219
- public get isDirty(): boolean {
220
- return this.container.isDirty;
221
- }
271
+ /**
272
+ * {@inheritDoc IFluidContainer.attachState}
273
+ */
274
+ public get attachState(): AttachState {
275
+ return this.container.attachState;
276
+ }
222
277
 
223
- /**
224
- * {@inheritDoc IFluidContainer.attachState}
225
- */
226
- public get attachState(): AttachState {
227
- return this.container.attachState;
228
- }
278
+ /**
279
+ * {@inheritDoc IFluidContainer.disposed}
280
+ */
281
+ public get disposed() {
282
+ return this.container.closed;
283
+ }
229
284
 
230
- /**
231
- * {@inheritDoc IFluidContainer.disposed}
232
- */
233
- public get disposed() {
234
- return this.container.closed;
235
- }
285
+ /**
286
+ * {@inheritDoc IFluidContainer.connectionState}
287
+ */
288
+ public get connectionState(): ConnectionState {
289
+ return this.container.connectionState;
290
+ }
236
291
 
237
- /**
238
- * {@inheritDoc IFluidContainer.connectionState}
239
- */
240
- public get connectionState(): ConnectionState {
241
- return this.container.connectionState;
242
- }
292
+ /**
293
+ * {@inheritDoc IFluidContainer.initialObjects}
294
+ */
295
+ public get initialObjects(): InitialObjects<TContainerSchema> {
296
+ return this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;
297
+ }
243
298
 
244
- /**
245
- * {@inheritDoc IFluidContainer.initialObjects}
246
- */
247
- public get initialObjects() {
248
- return this.rootDataObject.initialObjects;
249
- }
299
+ /**
300
+ * Incomplete base implementation of {@link IFluidContainer.attach}.
301
+ *
302
+ * @remarks
303
+ *
304
+ * Note: this implementation will unconditionally throw.
305
+ * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
306
+ * that provides an implementation of this method.
307
+ *
308
+ * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
309
+ * but internally this separation is not there.
310
+ */
311
+ public async attach(): Promise<string> {
312
+ if (this.container.attachState !== AttachState.Detached) {
313
+ throw new Error("Cannot attach container. Container is not in detached state.");
314
+ }
315
+ throw new Error("Cannot attach container. Attach method not provided.");
316
+ }
250
317
 
251
- /**
252
- * Incomplete base implementation of {@link IFluidContainer.attach}.
253
- * @remarks Note: this implementation will unconditionally throw.
254
- * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
255
- * that provides an implementation of this method.
256
- *
257
- * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
258
- * but internally this separation is not there.
259
- */
260
- public async attach(): Promise<string> {
261
- throw new Error("Cannot attach container. Container is not in detached state");
262
- }
318
+ /**
319
+ * {@inheritDoc IFluidContainer.connect}
320
+ */
321
+ public async connect(): Promise<void> {
322
+ this.container.connect?.();
323
+ }
263
324
 
264
- /**
265
- * {@inheritDoc IFluidContainer.connect}
266
- */
267
- public async connect(): Promise<void> {
268
- this.container.connect?.();
269
- }
325
+ /**
326
+ * {@inheritDoc IFluidContainer.connect}
327
+ */
328
+ public async disconnect(): Promise<void> {
329
+ this.container.disconnect?.();
330
+ }
270
331
 
271
- /**
272
- * {@inheritDoc IFluidContainer.connect}
273
- */
274
- public async disconnect(): Promise<void> {
275
- this.container.disconnect?.();
276
- }
332
+ /**
333
+ * {@inheritDoc IFluidContainer.create}
334
+ */
335
+ public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
336
+ return this.rootDataObject.create(objectClass);
337
+ }
277
338
 
278
- /**
279
- * {@inheritDoc IFluidContainer.create}
280
- */
281
- public async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {
282
- return this.rootDataObject.create(objectClass);
283
- }
339
+ /**
340
+ * {@inheritDoc IFluidContainer.dispose}
341
+ */
342
+ public dispose() {
343
+ this.container.close();
344
+ this.container.off("connected", this.connectedHandler);
345
+ this.container.off("closed", this.disposedHandler);
346
+ this.container.off("disconnected", this.disconnectedHandler);
347
+ this.container.off("saved", this.savedHandler);
348
+ this.container.off("dirty", this.dirtyHandler);
349
+ }
284
350
 
285
- /**
286
- * {@inheritDoc IFluidContainer.dispose}
287
- */
288
- public dispose() {
289
- this.container.close();
290
- this.container.off("connected", this.connectedHandler);
291
- this.container.off("closed", this.disposedHandler);
292
- this.container.off("disconnected", this.disconnectedHandler);
293
- this.container.off("saved", this.savedHandler);
294
- this.container.off("dirty", this.dirtyHandler);
295
- }
351
+ /**
352
+ * FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
353
+ * We make no stability guarantees here whatsoever.
354
+ *
355
+ * Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
356
+ *
357
+ * @remarks Used to power debug tooling.
358
+ */
359
+ public readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {
360
+ return this.container;
361
+ };
296
362
  }
package/src/index.ts CHANGED
@@ -9,7 +9,28 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
 
12
- export * from "./fluidContainer";
13
- export * from "./rootDataObject";
14
- export * from "./serviceAudience";
15
- export * from "./types";
12
+ export {
13
+ createFluidContainer,
14
+ IFluidContainer,
15
+ IFluidContainerEvents,
16
+ InitialObjects,
17
+ } from "./fluidContainer";
18
+ export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
19
+ export { createServiceAudience } from "./serviceAudience";
20
+ export {
21
+ ContainerSchema,
22
+ DataObjectClass,
23
+ IConnection,
24
+ IMember,
25
+ IRootDataObject,
26
+ IServiceAudience,
27
+ IServiceAudienceEvents,
28
+ LoadableObjectClass,
29
+ LoadableObjectClassRecord,
30
+ LoadableObjectCtor,
31
+ LoadableObjectRecord,
32
+ MemberChangedListener,
33
+ Myself,
34
+ SharedObjectClass,
35
+ IProvideRootDataObject,
36
+ } from "./types";