@fluidframework/fluid-static 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) 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-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/fluid-static.api.md +141 -0
  8. package/dist/fluid-static-alpha.d.ts +408 -0
  9. package/dist/fluid-static-beta.d.ts +412 -0
  10. package/dist/fluid-static-public.d.ts +412 -0
  11. package/dist/fluid-static-untrimmed.d.ts +452 -0
  12. package/dist/{fluidContainer.js → fluidContainer.cjs} +39 -12
  13. package/dist/fluidContainer.cjs.map +1 -0
  14. package/dist/fluidContainer.d.ts +95 -142
  15. package/dist/fluidContainer.d.ts.map +1 -1
  16. package/dist/index.cjs +19 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/{rootDataObject.js → rootDataObject.cjs} +59 -23
  21. package/dist/rootDataObject.cjs.map +1 -0
  22. package/dist/rootDataObject.d.ts +9 -59
  23. package/dist/rootDataObject.d.ts.map +1 -1
  24. package/dist/{serviceAudience.js → serviceAudience.cjs} +44 -20
  25. package/dist/serviceAudience.cjs.map +1 -0
  26. package/dist/serviceAudience.d.ts +7 -54
  27. package/dist/serviceAudience.d.ts.map +1 -1
  28. package/dist/tsdoc-metadata.json +11 -0
  29. package/dist/{types.js → types.cjs} +1 -1
  30. package/dist/types.cjs.map +1 -0
  31. package/dist/types.d.ts +130 -80
  32. package/dist/types.d.ts.map +1 -1
  33. package/dist/{utils.js → utils.cjs} +7 -9
  34. package/dist/utils.cjs.map +1 -0
  35. package/dist/utils.d.ts +10 -2
  36. package/dist/utils.d.ts.map +1 -1
  37. package/lib/fluid-static-alpha.d.mts +408 -0
  38. package/lib/fluid-static-beta.d.mts +412 -0
  39. package/lib/fluid-static-public.d.mts +412 -0
  40. package/lib/fluid-static-untrimmed.d.mts +452 -0
  41. package/lib/fluidContainer.d.mts +188 -0
  42. package/lib/fluidContainer.d.mts.map +1 -0
  43. package/lib/{fluidContainer.js → fluidContainer.mjs} +36 -13
  44. package/lib/fluidContainer.mjs.map +1 -0
  45. package/lib/index.d.mts +9 -0
  46. package/lib/index.d.mts.map +1 -0
  47. package/lib/index.mjs +8 -0
  48. package/lib/index.mjs.map +1 -0
  49. package/lib/rootDataObject.d.mts +20 -0
  50. package/lib/rootDataObject.d.mts.map +1 -0
  51. package/lib/{rootDataObject.js → rootDataObject.mjs} +61 -28
  52. package/lib/rootDataObject.mjs.map +1 -0
  53. package/lib/serviceAudience.d.mts +15 -0
  54. package/lib/serviceAudience.d.mts.map +1 -0
  55. package/lib/{serviceAudience.js → serviceAudience.mjs} +42 -18
  56. package/lib/serviceAudience.mjs.map +1 -0
  57. package/lib/types.d.mts +223 -0
  58. package/lib/types.d.mts.map +1 -0
  59. package/lib/{types.js → types.mjs} +1 -1
  60. package/lib/types.mjs.map +1 -0
  61. package/lib/{utils.d.ts → utils.d.mts} +11 -3
  62. package/lib/utils.d.mts.map +1 -0
  63. package/lib/{utils.js → utils.mjs} +7 -9
  64. package/lib/utils.mjs.map +1 -0
  65. package/package.json +130 -61
  66. package/prettier.config.cjs +8 -0
  67. package/src/fluidContainer.ts +316 -250
  68. package/src/index.ts +25 -4
  69. package/src/rootDataObject.ts +203 -157
  70. package/src/serviceAudience.ts +152 -124
  71. package/src/types.ts +190 -132
  72. package/src/utils.ts +44 -39
  73. package/tsc-multi.test.json +4 -0
  74. package/tsconfig.json +12 -16
  75. package/dist/fluidContainer.js.map +0 -1
  76. package/dist/index.js +0 -26
  77. package/dist/index.js.map +0 -1
  78. package/dist/rootDataObject.js.map +0 -1
  79. package/dist/serviceAudience.js.map +0 -1
  80. package/dist/types.js.map +0 -1
  81. package/dist/utils.js.map +0 -1
  82. package/lib/fluidContainer.d.ts +0 -235
  83. package/lib/fluidContainer.d.ts.map +0 -1
  84. package/lib/fluidContainer.js.map +0 -1
  85. package/lib/index.d.ts +0 -14
  86. package/lib/index.d.ts.map +0 -1
  87. package/lib/index.js +0 -14
  88. package/lib/index.js.map +0 -1
  89. package/lib/rootDataObject.d.ts +0 -70
  90. package/lib/rootDataObject.d.ts.map +0 -1
  91. package/lib/rootDataObject.js.map +0 -1
  92. package/lib/serviceAudience.d.ts +0 -62
  93. package/lib/serviceAudience.d.ts.map +0 -1
  94. package/lib/serviceAudience.js.map +0 -1
  95. package/lib/types.d.ts +0 -173
  96. package/lib/types.d.ts.map +0 -1
  97. package/lib/types.js.map +0 -1
  98. package/lib/utils.d.ts.map +0 -1
  99. package/lib/utils.js.map +0 -1
  100. package/tsconfig.esnext.json +0 -7
@@ -1,99 +1,91 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
1
+ import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
2
+ import { AttachState, IContainer, ICriticalContainerError, ConnectionState } from "@fluidframework/container-definitions";
3
+ import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types";
4
+ /**
5
+ * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
6
+ * @public
4
7
  */
5
- import { TypedEventEmitter } from "@fluidframework/common-utils";
6
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
7
- import { IEvent, IEventProvider } from "@fluidframework/common-definitions";
8
- import { AttachState, ConnectionState, IContainer, ICriticalContainerError } from "@fluidframework/container-definitions";
9
- import { LoadableObjectClass, LoadableObjectRecord } from "./types";
10
- import { RootDataObject } from "./rootDataObject";
8
+ export type InitialObjects<T extends ContainerSchema> = {
9
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
10
+ };
11
11
  /**
12
12
  * Events emitted from {@link IFluidContainer}.
13
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
- * ### "disposed"
29
- *
30
- * The "disposed" 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
- * ```
14
+ * @remarks Note: external implementations of this interface are not supported.
15
+ * @sealed
16
+ * @public
68
17
  */
69
18
  export interface IFluidContainerEvents extends IEvent {
70
19
  /**
71
- * **connected** & **disconnected** events reflect connection state changes against the (delta)
72
- * service acknowledging ops/edits.
20
+ * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
21
+ *
22
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
23
+ *
24
+ * @see
25
+ *
26
+ * - {@link IFluidContainer.connectionState}
27
+ *
28
+ * - {@link IFluidContainer.connect}
29
+ */
30
+ (event: "connected", listener: () => void): void;
31
+ /**
32
+ * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
33
+ *
34
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
35
+ *
36
+ * @see
37
+ *
38
+ * - {@link IFluidContainer.connectionState}
39
+ *
40
+ * - {@link IFluidContainer.disconnect}
41
+ */
42
+ (event: "disconnected", listener: () => void): void;
43
+ /**
44
+ * Emitted when all local changes/edits have been acknowledged by the service.
45
+ *
46
+ * @remarks "dirty" event will be emitted when the next local change has been made.
47
+ *
48
+ * @see {@link IFluidContainer.isDirty}
73
49
  */
74
- (event: "connected" | "disconnected", listener: () => void): void;
50
+ (event: "saved", listener: () => void): void;
75
51
  /**
76
- * **saved** event is raised when all local changes/edits have been acknowledged by the service.
77
- * **dirty** event is raised when first local change has been made, following a "saved" state.
52
+ * Emitted when the first local change has been made, following a "saved" event.
53
+ *
54
+ * @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
55
+ *
56
+ * @see {@link IFluidContainer.isDirty}
78
57
  */
79
- (event: "saved" | "dirty", listener: () => void): void;
58
+ (event: "dirty", listener: () => void): void;
80
59
  /**
81
- * Disposed event is raised when container is closed. If container was closed due to error
82
- * (vs explicit **dispose** action), optional argument contains further details about the error.
60
+ * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
61
+ *
62
+ * @remarks Listener parameters:
63
+ *
64
+ * - `error`: If the container was closed due to error (as opposed to an explicit call to
65
+ * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.
83
66
  */
84
67
  (event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
85
68
  }
86
69
  /**
87
70
  * Provides an entrypoint into the client side of collaborative Fluid data.
88
71
  * Provides access to the data as well as status on the collaboration session.
72
+ *
73
+ * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
74
+ *
75
+ * @remarks Note: external implementations of this interface are not supported.
76
+ * @sealed
77
+ * @public
89
78
  */
90
- export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
79
+ export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
91
80
  /**
92
81
  * Provides the current connected state of the container
93
82
  */
94
83
  readonly connectionState: ConnectionState;
95
84
  /**
96
85
  * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.
86
+ *
87
+ * @remarks
88
+ *
97
89
  * You should always check the `isDirty` flag before closing the container or navigating away from the page.
98
90
  * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been
99
91
  * acknowledged by the service.
@@ -111,16 +103,21 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
111
103
  */
112
104
  readonly isDirty: boolean;
113
105
  /**
114
- * Whether the container is disposed, which permanently disables it.
106
+ * Whether or not the container is disposed, which permanently disables it.
115
107
  */
116
108
  readonly disposed: boolean;
117
109
  /**
118
110
  * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.
119
- * These data objects and DDSes exist for the lifetime of the container.
111
+ *
112
+ * @remarks These data objects and DDSes exist for the lifetime of the container.
120
113
  */
121
- readonly initialObjects: LoadableObjectRecord;
114
+ readonly initialObjects: InitialObjects<TContainerSchema>;
122
115
  /**
123
- * The current attachment state of the container. Once a container has been attached, it remains attached.
116
+ * The current attachment state of the container.
117
+ *
118
+ * @remarks
119
+ *
120
+ * Once a container has been attached, it remains attached.
124
121
  * When loading an existing container, it will already be attached.
125
122
  */
126
123
  readonly attachState: AttachState;
@@ -128,7 +125,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
128
125
  * A newly created container starts detached from the collaborative service.
129
126
  * Calling `attach()` uploads the new container to the service and connects to the collaborative service.
130
127
  *
131
- * @remarks This should only be called when the container is in the
128
+ * @remarks
129
+ *
130
+ * This should only be called when the container is in the
132
131
  * {@link @fluidframework/container-definitions#AttachState.Detatched} state.
133
132
  *
134
133
  * This can be determined by observing {@link IFluidContainer.attachState}.
@@ -138,9 +137,12 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
138
137
  attach(): Promise<string>;
139
138
  /**
140
139
  * Attempts to connect the container to the delta stream and process operations.
141
- * Will throw an error if unsuccessful.
142
140
  *
143
- * @remarks This should only be called when the container is in the
141
+ * @throws Will throw an error if connection is unsuccessful.
142
+ *
143
+ * @remarks
144
+ *
145
+ * This should only be called when the container is in the
144
146
  * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
145
147
  *
146
148
  * This can be determined by observing {@link IFluidContainer.connectionState}.
@@ -149,7 +151,9 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
149
151
  /**
150
152
  * Disconnects the container from the delta stream and stops processing operations.
151
153
  *
152
- * @remarks This should only be called when the container is in the
154
+ * @remarks
155
+ *
156
+ * This should only be called when the container is in the
153
157
  * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
154
158
  *
155
159
  * This can be determined by observing {@link IFluidContainer.connectionState}.
@@ -158,11 +162,15 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
158
162
  /**
159
163
  * Create a new data object or Distributed Data Store (DDS) of the specified type.
160
164
  *
161
- * @remarks In order to share the data object or DDS with other
165
+ * @remarks
166
+ *
167
+ * In order to share the data object or DDS with other
162
168
  * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
163
169
  * initialObjects.
164
170
  *
165
- * @param objectClass - The class of data object or DDS to create
171
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
172
+ *
173
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
166
174
  */
167
175
  create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
168
176
  /**
@@ -171,65 +179,10 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
171
179
  dispose(): void;
172
180
  }
173
181
  /**
174
- * Base {@link IFluidContainer} implementation.
175
- *
176
- * @remarks Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
177
- * will need to utilize or provide a service-specific implementation of this type that implements that method.
182
+ * @internal
178
183
  */
179
- export declare class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> implements IFluidContainer {
180
- private readonly container;
181
- private readonly rootDataObject;
182
- private readonly connectedHandler;
183
- private readonly disconnectedHandler;
184
- private readonly disposedHandler;
185
- private readonly savedHandler;
186
- private readonly dirtyHandler;
187
- constructor(container: IContainer, rootDataObject: RootDataObject);
188
- /**
189
- * {@inheritDoc IFluidContainer.isDirty}
190
- */
191
- get isDirty(): boolean;
192
- /**
193
- * {@inheritDoc IFluidContainer.attachState}
194
- */
195
- get attachState(): AttachState;
196
- /**
197
- * {@inheritDoc IFluidContainer.disposed}
198
- */
199
- get disposed(): boolean;
200
- /**
201
- * {@inheritDoc IFluidContainer.connectionState}
202
- */
203
- get connectionState(): ConnectionState;
204
- /**
205
- * {@inheritDoc IFluidContainer.initialObjects}
206
- */
207
- get initialObjects(): LoadableObjectRecord;
208
- /**
209
- * Incomplete base implementation of {@link IFluidContainer.attach}.
210
- * @remarks Note: this implementation will unconditionally throw.
211
- * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type
212
- * that provides an implementation of this method.
213
- *
214
- * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,
215
- * but internally this separation is not there.
216
- */
217
- attach(): Promise<string>;
218
- /**
219
- * {@inheritDoc IFluidContainer.connect}
220
- */
221
- connect(): Promise<void>;
222
- /**
223
- * {@inheritDoc IFluidContainer.connect}
224
- */
225
- disconnect(): Promise<void>;
226
- /**
227
- * {@inheritDoc IFluidContainer.create}
228
- */
229
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
230
- /**
231
- * {@inheritDoc IFluidContainer.dispose}
232
- */
233
- dispose(): void;
234
- }
184
+ export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
185
+ container: IContainer;
186
+ rootDataObject: IRootDataObject;
187
+ }): IFluidContainer<TContainerSchema>;
235
188
  //# sourceMappingURL=fluidContainer.d.ts.map
@@ -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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CAAC,qBAAqB,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAE1D;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAElC;;;;;;;;;;;;OAYG;IACH,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,IAAI,CAAC;IAEhB;;;;;;;;;OASG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAElF;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CACnC,gBAAgB,SAAS,eAAe,GAAG,eAAe,EACzD,KAAK,EAAE;IACR,SAAS,EAAE,UAAU,CAAC;IACtB,cAAc,EAAE,eAAe,CAAC;CAChC,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAEpC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createServiceAudience = exports.createDOProviderContainerRuntimeFactory = exports.createFluidContainer = void 0;
8
+ /**
9
+ * Provides a simple and powerful way to consume collaborative Fluid data.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ var fluidContainer_1 = require("./fluidContainer.cjs");
14
+ Object.defineProperty(exports, "createFluidContainer", { enumerable: true, get: function () { return fluidContainer_1.createFluidContainer; } });
15
+ var rootDataObject_1 = require("./rootDataObject.cjs");
16
+ Object.defineProperty(exports, "createDOProviderContainerRuntimeFactory", { enumerable: true, get: function () { return rootDataObject_1.createDOProviderContainerRuntimeFactory; } });
17
+ var serviceAudience_1 = require("./serviceAudience.cjs");
18
+ Object.defineProperty(exports, "createServiceAudience", { enumerable: true, get: function () { return serviceAudience_1.createServiceAudience; } });
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,uDAK0B;AAJzB,sHAAA,oBAAoB,OAAA;AAKrB,uDAA2E;AAAlE,yIAAA,uCAAuC,OAAA;AAChD,yDAA0D;AAAjD,wHAAA,qBAAqB,OAAA","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 {\n\tcreateFluidContainer,\n\tIFluidContainer,\n\tIFluidContainerEvents,\n\tInitialObjects,\n} from \"./fluidContainer\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject\";\nexport { createServiceAudience } 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\tMyself,\n\tSharedObjectClass,\n\tIProvideRootDataObject,\n} from \"./types\";\n"]}
package/dist/index.d.ts CHANGED
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * @packageDocumentation
9
9
  */
10
- export * from "./fluidContainer";
11
- export * from "./rootDataObject";
12
- export * from "./serviceAudience";
13
- export * from "./types";
10
+ export { createFluidContainer, IFluidContainer, IFluidContainerEvents, InitialObjects, } from "./fluidContainer";
11
+ export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
12
+ export { createServiceAudience } from "./serviceAudience";
13
+ export { ContainerSchema, DataObjectClass, IConnection, IMember, IRootDataObject, IServiceAudience, IServiceAudienceEvents, LoadableObjectClass, LoadableObjectClassRecord, LoadableObjectCtor, LoadableObjectRecord, MemberChangedListener, Myself, SharedObjectClass, IProvideRootDataObject, } from "./types";
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,cAAc,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uCAAuC,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,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,MAAM,EACN,iBAAiB,EACjB,sBAAsB,GACtB,MAAM,SAAS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DOProviderContainerRuntimeFactory = exports.RootDataObject = void 0;
3
+ exports.createDOProviderContainerRuntimeFactory = void 0;
4
4
  /*!
5
5
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
6
6
  * Licensed under the MIT License.
@@ -8,11 +8,10 @@ exports.DOProviderContainerRuntimeFactory = exports.RootDataObject = void 0;
8
8
  const aqueduct_1 = require("@fluidframework/aqueduct");
9
9
  const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
10
10
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
11
- const utils_1 = require("./utils");
11
+ const utils_1 = require("./utils.cjs");
12
12
  /**
13
- * The entry-point/root collaborative object of the Fluid Container.
14
- * This class abstracts the dynamic code required to build a Fluid Container into a static representation
15
- * for end customers.
13
+ * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
14
+ * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
16
15
  */
17
16
  class RootDataObject extends aqueduct_1.DataObject {
18
17
  constructor() {
@@ -20,6 +19,9 @@ class RootDataObject extends aqueduct_1.DataObject {
20
19
  this.initialObjectsDirKey = "initial-objects-key";
21
20
  this._initialObjects = {};
22
21
  }
22
+ get IRootDataObject() {
23
+ return this;
24
+ }
23
25
  get initialObjectsDir() {
24
26
  const dir = this.root.getSubDirectory(this.initialObjectsDirKey);
25
27
  if (dir === undefined) {
@@ -31,7 +33,7 @@ class RootDataObject extends aqueduct_1.DataObject {
31
33
  * The first time this object is initialized, creates each object identified in
32
34
  * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
33
35
  *
34
- * See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
36
+ * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
35
37
  */
36
38
  async initializingFirstTime(props) {
37
39
  this.root.createSubDirectory(this.initialObjectsDirKey);
@@ -50,7 +52,7 @@ class RootDataObject extends aqueduct_1.DataObject {
50
52
  * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
51
53
  * accessed immediately.
52
54
  *
53
- * See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
55
+ * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
54
56
  */
55
57
  async hasInitialized() {
56
58
  // We will always load the initial objects so they are available to the developer
@@ -65,8 +67,7 @@ class RootDataObject extends aqueduct_1.DataObject {
65
67
  await Promise.all(loadInitialObjectsP);
66
68
  }
67
69
  /**
68
- * Provides a record of the initial objects defined on creation.
69
- * See {@link RootDataObject.initializingFirstTime}
70
+ * {@inheritDoc IRootDataObject.initialObjects}
70
71
  */
71
72
  get initialObjects() {
72
73
  if (Object.keys(this._initialObjects).length === 0) {
@@ -75,8 +76,7 @@ class RootDataObject extends aqueduct_1.DataObject {
75
76
  return this._initialObjects;
76
77
  }
77
78
  /**
78
- * Dynamically creates a new detached collaborative object (DDS/DataObject).
79
- * @param objectClass - Type of the collaborative object to be created.
79
+ * {@inheritDoc IRootDataObject.create}
80
80
  */
81
81
  async create(objectClass) {
82
82
  if ((0, utils_1.isDataObjectClass)(objectClass)) {
@@ -90,8 +90,9 @@ class RootDataObject extends aqueduct_1.DataObject {
90
90
  async createDataObject(dataObjectClass) {
91
91
  const factory = dataObjectClass.factory;
92
92
  const packagePath = [...this.context.packagePath, factory.type];
93
- const router = await this.context.containerRuntime.createDataStore(packagePath);
94
- return (0, runtime_utils_1.requestFluidObject)(router, "/");
93
+ const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
94
+ const entryPoint = await dataStore.entryPoint.get();
95
+ return entryPoint;
95
96
  }
96
97
  createSharedObject(sharedObjectClass) {
97
98
  const factory = sharedObjectClass.getFactory();
@@ -99,20 +100,54 @@ class RootDataObject extends aqueduct_1.DataObject {
99
100
  return obj;
100
101
  }
101
102
  }
102
- exports.RootDataObject = RootDataObject;
103
103
  const rootDataStoreId = "rootDOId";
104
104
  /**
105
- * Container code that provides a single {@link RootDataObject}. This data object is
106
- * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.
105
+ * @internal
106
+ */
107
+ function createDOProviderContainerRuntimeFactory(props) {
108
+ return new DOProviderContainerRuntimeFactory(props.schema);
109
+ }
110
+ exports.createDOProviderContainerRuntimeFactory = createDOProviderContainerRuntimeFactory;
111
+ /**
112
+ * Container code that provides a single {@link IRootDataObject}.
113
+ *
114
+ * @remarks
115
+ *
116
+ * This data object is dynamically customized (registry and initial objects) based on the schema provided.
117
+ * to the container runtime factory.
118
+ *
119
+ * @internal
107
120
  */
108
121
  class DOProviderContainerRuntimeFactory extends aqueduct_1.BaseContainerRuntimeFactory {
109
122
  constructor(schema) {
110
123
  const [registryEntries, sharedObjects] = (0, utils_1.parseDataObjectsFromSharedObjects)(schema);
111
124
  const rootDataObjectFactory = new aqueduct_1.DataObjectFactory("rootDO", RootDataObject, sharedObjects, {}, registryEntries);
112
- super([rootDataObjectFactory.registryEntry], undefined, [(0, aqueduct_1.defaultRouteRequestHandler)(rootDataStoreId)],
113
- // temporary workaround to disable message batching until the message batch size issue is resolved
114
- // resolution progress is tracked by the Feature 465 work item in AzDO
115
- { flushMode: runtime_definitions_1.FlushMode.Immediate });
125
+ const provideEntryPoint = async (containerRuntime) => {
126
+ const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
127
+ if (entryPoint === undefined) {
128
+ throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
129
+ }
130
+ return entryPoint.get();
131
+ };
132
+ const getDefaultObject = async (request, runtime) => {
133
+ const parser = runtime_utils_1.RequestParser.create(request);
134
+ if (parser.pathParts.length === 0) {
135
+ // This cast is safe as ContainerRuntime.loadRuntime is called in the base class
136
+ return runtime.resolveHandle({
137
+ url: `/${rootDataStoreId}${parser.query}`,
138
+ headers: request.headers,
139
+ });
140
+ }
141
+ return undefined; // continue search
142
+ };
143
+ super({
144
+ registryEntries: [rootDataObjectFactory.registryEntry],
145
+ requestHandlers: [getDefaultObject],
146
+ // temporary workaround to disable message batching until the message batch size issue is resolved
147
+ // resolution progress is tracked by the Feature 465 work item in AzDO
148
+ runtimeOptions: { flushMode: runtime_definitions_1.FlushMode.Immediate },
149
+ provideEntryPoint,
150
+ });
116
151
  this.rootDataObjectFactory = rootDataObjectFactory;
117
152
  this.initialObjects = schema.initialObjects;
118
153
  }
@@ -121,8 +156,9 @@ class DOProviderContainerRuntimeFactory extends aqueduct_1.BaseContainerRuntimeF
121
156
  */
122
157
  async containerInitializingFirstTime(runtime) {
123
158
  // The first time we create the container we create the RootDataObject
124
- await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, { initialObjects: this.initialObjects });
159
+ await this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {
160
+ initialObjects: this.initialObjects,
161
+ });
125
162
  }
126
163
  }
127
- exports.DOProviderContainerRuntimeFactory = DOProviderContainerRuntimeFactory;
128
- //# sourceMappingURL=rootDataObject.js.map
164
+ //# sourceMappingURL=rootDataObject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootDataObject.cjs","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAIkC;AAGlC,6EAAgE;AAEhE,iEAA8D;AAU9D,uCAKiB;AAcjB;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IA8F7D,CAAC;IA7FA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBAAiB;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACpE;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAA0B;QAC/D,IAAI,CAAC,IAAI,CAAC,kB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AE,SAAS,EAAE,+BAAS,CAAC,SAAS,EAAE;YAClD,iBAAiB;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,sEAAsE;QACtE,MAAM,IAAI,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,eAAe,EAAE,OAAO,EAAE;YAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;SACnC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tBaseContainerRuntimeFactory,\n\tDataObject,\n\tDataObjectFactory,\n} from \"@fluidframework/aqueduct\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidLoadable, IRequest } from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport { IRuntimeFactory } from \"@fluidframework/container-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\nimport { ContainerRuntime } from \"@fluidframework/container-runtime\";\nimport {\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectRecord,\n\tSharedObjectClass,\n} from \"./types\";\nimport {\n\tInternalDataObjectClass,\n\tisDataObjectClass,\n\tisSharedObjectClass,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils\";\n\n/**\n * Input props for {@link RootDataObject.initializingFirstTime}.\n */\nexport interface RootDataObjectProps {\n\t/**\n\t * Initial object structure with which the {@link RootDataObject} will be first-time initialized.\n\t *\n\t * @see {@link RootDataObject.initializingFirstTime}\n\t */\n\tinitialObjects: 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 */\nclass RootDataObject\n\textends DataObject<{ InitialState: RootDataObjectProps }>\n\timplements IRootDataObject\n{\n\tprivate readonly initialObjectsDirKey = \"initial-objects-key\";\n\tprivate readonly _initialObjects: LoadableObjectRecord = {};\n\tpublic get IRootDataObject() {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir() {\n\t\tconst dir = this.root.getSubDirectory(this.initialObjectsDirKey);\n\t\tif (dir === undefined) {\n\t\t\tthrow new Error(\"InitialObjects sub-directory was not initialized\");\n\t\t}\n\t\treturn dir;\n\t}\n\n\t/**\n\t * The first time this object is initialized, creates each object identified in\n\t * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}\n\t */\n\tprotected async initializingFirstTime(props: RootDataObjectProps) {\n\t\tthis.root.createSubDirectory(this.initialObjectsDirKey);\n\n\t\t// Create initial objects provided by the developer\n\t\tconst initialObjectsP: Promise<void>[] = [];\n\t\tObject.entries(props.initialObjects).forEach(([id, objectClass]) => {\n\t\t\tconst createObject = async () => {\n\t\t\t\tconst obj = await this.create(objectClass);\n\t\t\t\tthis.initialObjectsDir.set(id, obj.handle);\n\t\t\t};\n\t\t\tinitialObjectsP.push(createObject());\n\t\t});\n\n\t\tawait Promise.all(initialObjectsP);\n\t}\n\n\t/**\n\t * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be\n\t * accessed immediately.\n\t *\n\t * @see {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}\n\t */\n\tprotected async hasInitialized() {\n\t\t// We will always load the initial objects so they are available to the developer\n\t\tconst loadInitialObjectsP: Promise<void>[] = [];\n\t\tfor (const [key, value] of Array.from(this.initialObjectsDir.entries())) {\n\t\t\tconst loadDir = async () => {\n\t\t\t\tconst obj = await value.get();\n\t\t\t\tObject.assign(this._initialObjects, { [key]: obj });\n\t\t\t};\n\t\t\tloadInitialObjectsP.push(loadDir());\n\t\t}\n\n\t\tawait Promise.all(loadInitialObjectsP);\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.initialObjects}\n\t */\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\tif (Object.keys(this._initialObjects).length === 0) {\n\t\t\tthrow new Error(\"Initial Objects were not correctly initialized\");\n\t\t}\n\t\treturn this._initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc IRootDataObject.create}\n\t */\n\tpublic async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\tif (isDataObjectClass(objectClass)) {\n\t\t\treturn this.createDataObject<T>(objectClass);\n\t\t} else if (isSharedObjectClass(objectClass)) {\n\t\t\treturn this.createSharedObject<T>(objectClass);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tprivate async createDataObject<T extends IFluidLoadable>(\n\t\tdataObjectClass: InternalDataObjectClass<T>,\n\t): Promise<T> {\n\t\tconst factory = dataObjectClass.factory;\n\t\tconst packagePath = [...this.context.packagePath, factory.type];\n\t\tconst dataStore = await this.context.containerRuntime.createDataStore(packagePath);\n\t\tconst entryPoint = await dataStore.entryPoint.get();\n\t\treturn entryPoint as unknown as T;\n\t}\n\n\tprivate createSharedObject<T extends IFluidLoadable>(\n\t\tsharedObjectClass: SharedObjectClass<T>,\n\t): T {\n\t\tconst factory = sharedObjectClass.getFactory();\n\t\tconst obj = this.runtime.createChannel(undefined, factory.type);\n\t\treturn obj as unknown as T;\n\t}\n}\n\nconst rootDataStoreId = \"rootDOId\";\n\n/**\n * @internal\n */\nexport function createDOProviderContainerRuntimeFactory(props: {\n\tschema: ContainerSchema;\n}): IRuntimeFactory {\n\treturn new DOProviderContainerRuntimeFactory(props.schema);\n}\n\n/**\n * Container code that provides a single {@link IRootDataObject}.\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 *\n * @internal\n */\nclass DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\tprivate readonly rootDataObjectFactory: DataObjectFactory<\n\t\tRootDataObject,\n\t\t{\n\t\t\tInitialState: RootDataObjectProps;\n\t\t}\n\t>;\n\n\tprivate readonly initialObjects: LoadableObjectClassRecord;\n\n\tconstructor(schema: ContainerSchema) {\n\t\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\t\tconst rootDataObjectFactory = new DataObjectFactory(\n\t\t\t\"rootDO\",\n\t\t\tRootDataObject,\n\t\t\tsharedObjects,\n\t\t\t{},\n\t\t\tregistryEntries,\n\t\t);\n\t\tconst provideEntryPoint = async (containerRuntime: IContainerRuntime) => {\n\t\t\tconst entryPoint =\n\t\t\t\tawait containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tif (entryPoint === undefined) {\n\t\t\t\tthrow new Error(`default dataStore [${rootDataStoreId}] must exist`);\n\t\t\t}\n\t\t\treturn entryPoint.get();\n\t\t};\n\t\tconst getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called in the base class\n\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\turl: `/${rootDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\t\tsuper({\n\t\t\tregistryEntries: [rootDataObjectFactory.registryEntry],\n\t\t\trequestHandlers: [getDefaultObject],\n\t\t\t// temporary workaround to disable message batching until the message batch size issue is resolved\n\t\t\t// resolution progress is tracked by the Feature 465 work item in AzDO\n\t\t\truntimeOptions: { flushMode: FlushMode.Immediate },\n\t\t\tprovideEntryPoint,\n\t\t});\n\t\tthis.rootDataObjectFactory = rootDataObjectFactory;\n\t\tthis.initialObjects = schema.initialObjects;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n\t\t// The first time we create the container we create the RootDataObject\n\t\tawait this.rootDataObjectFactory.createRootInstance(rootDataStoreId, runtime, {\n\t\t\tinitialObjects: this.initialObjects,\n\t\t});\n\t}\n}\n"]}
@@ -1,70 +1,20 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { BaseContainerRuntimeFactory, DataObject } from "@fluidframework/aqueduct";
6
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
7
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import { ContainerSchema, LoadableObjectClass, LoadableObjectClassRecord, LoadableObjectRecord } from "./types";
1
+ import { IRuntimeFactory } from "@fluidframework/container-definitions";
2
+ import { ContainerSchema, LoadableObjectClassRecord } from "./types";
9
3
  /**
10
- * Input props for {@link RootDataObject.initializingFirstTime}
4
+ * Input props for {@link RootDataObject.initializingFirstTime}.
11
5
  */
12
6
  export interface RootDataObjectProps {
13
7
  /**
14
8
  * Initial object structure with which the {@link RootDataObject} will be first-time initialized.
15
- * See {@link RootDataObject.initializingFirstTime}
16
- */
17
- initialObjects: LoadableObjectClassRecord;
18
- }
19
- /**
20
- * The entry-point/root collaborative object of the Fluid Container.
21
- * This class abstracts the dynamic code required to build a Fluid Container into a static representation
22
- * for end customers.
23
- */
24
- export declare class RootDataObject extends DataObject<{
25
- InitialState: RootDataObjectProps;
26
- }> {
27
- private readonly initialObjectsDirKey;
28
- private readonly _initialObjects;
29
- private get initialObjectsDir();
30
- /**
31
- * The first time this object is initialized, creates each object identified in
32
- * {@link RootDataObjectProps.initialObjects} and stores them as unique values in the root directory.
33
- *
34
- * See {@link @fluidframework/aqueduct#PureDataObject.initializingFirstTime}
35
- */
36
- protected initializingFirstTime(props: RootDataObjectProps): Promise<void>;
37
- /**
38
- * Every time an instance is initialized, loads all of the initial objects in the root directory so they can be
39
- * accessed immediately.
40
9
  *
41
- * See {@link @fluidframework/aqueduct#PureDataObject.hasInitialized}
42
- */
43
- protected hasInitialized(): Promise<void>;
44
- /**
45
- * Provides a record of the initial objects defined on creation.
46
- * See {@link RootDataObject.initializingFirstTime}
47
- */
48
- get initialObjects(): LoadableObjectRecord;
49
- /**
50
- * Dynamically creates a new detached collaborative object (DDS/DataObject).
51
- * @param objectClass - Type of the collaborative object to be created.
10
+ * @see {@link RootDataObject.initializingFirstTime}
52
11
  */
53
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
54
- private createDataObject;
55
- private createSharedObject;
12
+ initialObjects: LoadableObjectClassRecord;
56
13
  }
57
14
  /**
58
- * Container code that provides a single {@link RootDataObject}. This data object is
59
- * dynamically customized (registry and initial objects) based on the schema provided to the container runtime factory.
15
+ * @internal
60
16
  */
61
- export declare class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
62
- private readonly rootDataObjectFactory;
63
- private readonly initialObjects;
64
- constructor(schema: ContainerSchema);
65
- /**
66
- * {@inheritDoc @fluidframework/aqueduct#BaseContainerRuntimeFactory.containerInitializingFirstTime}
67
- */
68
- protected containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void>;
69
- }
17
+ export declare function createDOProviderContainerRuntimeFactory(props: {
18
+ schema: ContainerSchema;
19
+ }): IRuntimeFactory;
70
20
  //# sourceMappingURL=rootDataObject.d.ts.map
@@ -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;AAGjE,OAAO,EACH,eAAe,EAE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