@fluidframework/fluid-static 2.41.0-338401 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/fluidContainer.d.ts +4 -4
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +7 -3
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +3 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +23 -12
- package/dist/rootDataObject.js.map +1 -1
- package/dist/types.d.ts +13 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/lib/fluidContainer.d.ts +4 -4
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +7 -3
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +3 -2
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +23 -12
- package/lib/rootDataObject.js.map +1 -1
- package/lib/types.d.ts +13 -7
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +20 -19
- package/src/fluidContainer.ts +30 -7
- package/src/index.ts +0 -2
- package/src/rootDataObject.ts +48 -18
- package/src/types.ts +14 -8
package/src/rootDataObject.ts
CHANGED
|
@@ -14,8 +14,16 @@ import {
|
|
|
14
14
|
FluidDataStoreRegistry,
|
|
15
15
|
type MinimumVersionForCollab,
|
|
16
16
|
} from "@fluidframework/container-runtime/internal";
|
|
17
|
-
import type {
|
|
18
|
-
|
|
17
|
+
import type {
|
|
18
|
+
IContainerRuntime,
|
|
19
|
+
IContainerRuntimeInternal,
|
|
20
|
+
} from "@fluidframework/container-runtime-definitions/internal";
|
|
21
|
+
import type {
|
|
22
|
+
FluidObject,
|
|
23
|
+
FluidObjectKeys,
|
|
24
|
+
IFluidLoadable,
|
|
25
|
+
} from "@fluidframework/core-interfaces";
|
|
26
|
+
import { assert } from "@fluidframework/core-utils/internal";
|
|
19
27
|
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
20
28
|
import type { IDirectory } from "@fluidframework/map/internal";
|
|
21
29
|
import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
|
|
@@ -29,6 +37,7 @@ import type {
|
|
|
29
37
|
CompatibilityMode,
|
|
30
38
|
ContainerSchema,
|
|
31
39
|
IRootDataObject,
|
|
40
|
+
IStaticEntryPoint,
|
|
32
41
|
LoadableObjectKind,
|
|
33
42
|
LoadableObjectKindRecord,
|
|
34
43
|
LoadableObjectRecord,
|
|
@@ -59,18 +68,22 @@ interface RootDataObjectProps {
|
|
|
59
68
|
readonly initialObjects: LoadableObjectKindRecord;
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
interface IProvideRootDataObject {
|
|
72
|
+
readonly RootDataObject: RootDataObject;
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
/**
|
|
63
76
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
64
77
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
65
78
|
*/
|
|
66
79
|
class RootDataObject
|
|
67
80
|
extends DataObject<{ InitialState: RootDataObjectProps }>
|
|
68
|
-
implements IRootDataObject
|
|
81
|
+
implements IRootDataObject, IProvideRootDataObject
|
|
69
82
|
{
|
|
70
83
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
71
84
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
72
85
|
|
|
73
|
-
public get
|
|
86
|
+
public get RootDataObject(): RootDataObject {
|
|
74
87
|
return this;
|
|
75
88
|
}
|
|
76
89
|
|
|
@@ -173,8 +186,9 @@ const rootDataStoreId = "rootDOId";
|
|
|
173
186
|
|
|
174
187
|
/**
|
|
175
188
|
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
|
|
176
|
-
* with
|
|
177
|
-
* and initial objects are configured based on the provided
|
|
189
|
+
* with an entry point containing single IRootDataObject (entry point is opaque to caller),
|
|
190
|
+
* where the root data object's registry and initial objects are configured based on the provided
|
|
191
|
+
* schema (and optionally, data store registry).
|
|
178
192
|
*
|
|
179
193
|
* @internal
|
|
180
194
|
*/
|
|
@@ -203,9 +217,35 @@ export function createDOProviderContainerRuntimeFactory(props: {
|
|
|
203
217
|
);
|
|
204
218
|
}
|
|
205
219
|
|
|
220
|
+
function makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(
|
|
221
|
+
object: Omit<T, K>,
|
|
222
|
+
providerKey: K,
|
|
223
|
+
): T {
|
|
224
|
+
return Object.defineProperty(object, providerKey, { value: object }) as T;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function provideEntryPoint(
|
|
228
|
+
containerRuntime: IContainerRuntime,
|
|
229
|
+
): Promise<IStaticEntryPoint> {
|
|
230
|
+
const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
231
|
+
if (entryPoint === undefined) {
|
|
232
|
+
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
233
|
+
}
|
|
234
|
+
const rootDataObject = ((await entryPoint.get()) as FluidObject<RootDataObject>)
|
|
235
|
+
.RootDataObject;
|
|
236
|
+
assert(rootDataObject !== undefined, 0xb9f /* entryPoint must be of type RootDataObject */);
|
|
237
|
+
return makeFluidObject<IStaticEntryPoint>(
|
|
238
|
+
{
|
|
239
|
+
rootDataObject,
|
|
240
|
+
extensionStore: containerRuntime as IContainerRuntimeInternal,
|
|
241
|
+
},
|
|
242
|
+
"IStaticEntryPoint",
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
206
246
|
/**
|
|
207
|
-
* Factory for Container Runtime instances that provide a
|
|
208
|
-
* as their entry point.
|
|
247
|
+
* Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
|
|
248
|
+
* (containing single {@link IRootDataObject}) as their entry point.
|
|
209
249
|
*/
|
|
210
250
|
class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
211
251
|
private readonly rootDataObjectFactory: DataObjectFactory<
|
|
@@ -239,16 +279,6 @@ class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
|
239
279
|
{ InitialState: RootDataObjectProps }
|
|
240
280
|
>,
|
|
241
281
|
) {
|
|
242
|
-
const provideEntryPoint = async (
|
|
243
|
-
containerRuntime: IContainerRuntime,
|
|
244
|
-
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
245
|
-
): Promise<FluidObject> => {
|
|
246
|
-
const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
247
|
-
if (entryPoint === undefined) {
|
|
248
|
-
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
249
|
-
}
|
|
250
|
-
return entryPoint.get();
|
|
251
|
-
};
|
|
252
282
|
super({
|
|
253
283
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
254
284
|
runtimeOptions: compatibilityModeRuntimeOptions[compatibilityMode],
|
package/src/types.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
|
|
7
|
+
import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
|
|
7
8
|
import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
9
|
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
10
|
import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
@@ -94,19 +95,12 @@ export interface ContainerSchema {
|
|
|
94
95
|
readonly dynamicObjectTypes?: readonly SharedObjectKind[];
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
/**
|
|
98
|
-
* @internal
|
|
99
|
-
*/
|
|
100
|
-
export interface IProvideRootDataObject {
|
|
101
|
-
readonly IRootDataObject: IRootDataObject;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
98
|
/**
|
|
105
99
|
* Holds the collection of objects that the container was initially created with, as well as provides the ability
|
|
106
100
|
* to dynamically create further objects during usage.
|
|
107
101
|
* @internal
|
|
108
102
|
*/
|
|
109
|
-
export interface IRootDataObject
|
|
103
|
+
export interface IRootDataObject {
|
|
110
104
|
/**
|
|
111
105
|
* Provides a record of the initial objects defined on creation.
|
|
112
106
|
*/
|
|
@@ -122,6 +116,18 @@ export interface IRootDataObject extends IProvideRootDataObject {
|
|
|
122
116
|
create<T>(objectClass: SharedObjectKind<T>): Promise<T>;
|
|
123
117
|
}
|
|
124
118
|
|
|
119
|
+
interface IProvideStaticEntryPoint {
|
|
120
|
+
readonly IStaticEntryPoint: IStaticEntryPoint;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
export interface IStaticEntryPoint extends IProvideStaticEntryPoint {
|
|
127
|
+
readonly rootDataObject: IRootDataObject;
|
|
128
|
+
readonly extensionStore: ContainerExtensionStore;
|
|
129
|
+
}
|
|
130
|
+
|
|
125
131
|
/**
|
|
126
132
|
* Signature for {@link IMember} change events.
|
|
127
133
|
*
|