@fluidframework/fluid-static 2.0.0-dev-rc.1.0.0.225277 → 2.0.0-dev-rc.1.0.0.232845
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 → .eslintrc.cjs} +1 -1
- package/CHANGELOG.md +34 -0
- package/README.md +0 -6
- package/api-report/fluid-static.api.md +10 -7
- package/dist/fluid-static-alpha.d.ts +11 -4
- package/dist/fluid-static-beta.d.ts +11 -4
- package/dist/fluid-static-public.d.ts +11 -4
- package/dist/fluid-static-untrimmed.d.ts +26 -7
- package/dist/fluidContainer.d.ts +9 -6
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/{fluidContainer.cjs → fluidContainer.js} +4 -2
- package/dist/fluidContainer.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/{index.cjs → index.js} +4 -4
- package/dist/index.js.map +1 -0
- package/dist/rootDataObject.d.ts +5 -2
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/{rootDataObject.cjs → rootDataObject.js} +16 -8
- package/dist/rootDataObject.js.map +1 -0
- package/dist/serviceAudience.d.ts +13 -6
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/{serviceAudience.cjs → serviceAudience.js} +13 -5
- package/dist/serviceAudience.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/{types.cjs → types.js} +1 -1
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +6 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/{utils.cjs → utils.js} +7 -4
- package/dist/utils.js.map +1 -0
- package/lib/fluid-static-alpha.d.mts +11 -4
- package/lib/fluid-static-beta.d.mts +11 -4
- package/lib/fluid-static-public.d.mts +11 -4
- package/lib/fluid-static-untrimmed.d.mts +26 -7
- package/lib/fluidContainer.d.mts +9 -6
- package/lib/fluidContainer.d.mts.map +1 -1
- package/lib/fluidContainer.mjs +3 -1
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.mts +2 -2
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/rootDataObject.d.mts +5 -2
- package/lib/rootDataObject.d.mts.map +1 -1
- package/lib/rootDataObject.mjs +14 -6
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.mts +13 -6
- package/lib/serviceAudience.d.mts.map +1 -1
- package/lib/serviceAudience.mjs +12 -4
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.mts +8 -3
- package/lib/types.d.mts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.mts +6 -6
- package/lib/utils.d.mts.map +1 -1
- package/lib/utils.mjs +6 -3
- package/lib/utils.mjs.map +1 -1
- package/package.json +29 -29
- package/src/fluidContainer.ts +28 -16
- package/src/index.ts +19 -18
- package/src/rootDataObject.ts +52 -29
- package/src/serviceAudience.ts +35 -22
- package/src/types.ts +16 -3
- package/src/utils.ts +15 -12
- package/dist/fluidContainer.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/rootDataObject.cjs.map +0 -1
- package/dist/serviceAudience.cjs.map +0 -1
- package/dist/types.cjs.map +0 -1
- package/dist/utils.cjs.map +0 -1
- package/tsc-multi.test.json +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rootDataObject.js","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAIkC;AAQlC,6EAAgE;AAEhE,iEAA8D;AAY9D,mCAKiB;AAcjB;;;GAGG;AACH,MAAM,cACL,SAAQ,qBAAiD;IAD1D;;QAIkB,yBAAoB,GAAG,qBAAqB,CAAC;QAC7C,oBAAe,GAAyB,EAAE,CAAC;IAgG7D,CAAC;IA9FA,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAY,iBA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K,EAAE;oBACzC,OAAO,EAAE,OAAO,CAAC,OAAO;iBACxB,CAAC,CAAC;aACH;YACD,OAAO,SAAS,CAAC,CAAC,kBAAkB;QACrC,CAAC,CAAC;QACF,KAAK,CAAC;YACL,eAAe,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC;YACtD,eAAe,EAAE,CAAC,gBAAgB,CAAC;YACnC,cAAc,EAAE;gBACf,kGAAkG;gBAClG,sEAAsE;gBACtE,SAAS,EAAE,+BAAS,CAAC,SAAS;gBAC9B,2EAA2E;gBAC3E,yBAAyB,EAAE,IAAI;aAC/B;YACD,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 { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport {\n\ttype FluidObject,\n\ttype IFluidLoadable,\n\ttype IRequest,\n\ttype IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport { type IRuntimeFactory } from \"@fluidframework/container-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\nimport { type ContainerRuntime } from \"@fluidframework/container-runtime\";\nimport { type IDirectory } from \"@fluidframework/map\";\n\nimport {\n\ttype ContainerSchema,\n\ttype IRootDataObject,\n\ttype LoadableObjectClass,\n\ttype LoadableObjectClassRecord,\n\ttype LoadableObjectRecord,\n\ttype SharedObjectClass,\n} from \"./types\";\nimport {\n\ttype InternalDataObjectClass,\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\n\tpublic get IRootDataObject(): IRootDataObject {\n\t\treturn this;\n\t}\n\n\tprivate get initialObjectsDir(): IDirectory {\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): Promise<void> {\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\tfor (const [id, objectClass] of Object.entries(props.initialObjects)) {\n\t\t\tconst createObject = async (): Promise<void> => {\n\t\t\t\tconst obj = await this.create<IFluidLoadable>(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(): Promise<void> {\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 this.initialObjectsDir.entries()) {\n\t\t\tconst loadDir = async (): Promise<void> => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n\t\t\t\tconst obj: unknown = 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 * Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single\n * {@link IRootDataObject}, which is constructed from the provided schema.\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\tpublic constructor(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 (\n\t\t\tcontainerRuntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<FluidObject> => {\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 (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<IResponse | undefined> => {\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\truntimeOptions: {\n\t\t\t\t// temporary workaround to disable message batching until the message batch size issue is resolved\n\t\t\t\t// resolution progress is tracked by the Feature 465 work item in AzDO\n\t\t\t\tflushMode: FlushMode.Immediate,\n\t\t\t\t// The runtime compressor is required to be on to use @fluidframework/tree.\n\t\t\t\tenableRuntimeIdCompressor: true,\n\t\t\t},\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): Promise<void> {\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"]}
|
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IContainer } from "@fluidframework/container-definitions";
|
|
6
|
-
import { IClient } from "@fluidframework/protocol-definitions";
|
|
7
|
-
import { IServiceAudience, IMember } from "./types";
|
|
5
|
+
import { type IContainer } from "@fluidframework/container-definitions";
|
|
6
|
+
import { type IClient } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { type IServiceAudience, type IMember } from "./types";
|
|
8
8
|
/**
|
|
9
|
+
* Creates a service audience for the provided container.
|
|
10
|
+
*
|
|
11
|
+
* @param container - The container with which the audience is associated.
|
|
12
|
+
* @param createServiceMember - A function for creating audience members.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TMember - The {@link IMember} representation used by the audience.
|
|
15
|
+
*
|
|
9
16
|
* @internal
|
|
10
17
|
*/
|
|
11
|
-
export declare function createServiceAudience<
|
|
18
|
+
export declare function createServiceAudience<TMember extends IMember = IMember>(props: {
|
|
12
19
|
container: IContainer;
|
|
13
|
-
createServiceMember: (audienceMember: IClient) =>
|
|
14
|
-
}): IServiceAudience<
|
|
20
|
+
createServiceMember: (audienceMember: IClient) => TMember;
|
|
21
|
+
}): IServiceAudience<TMember>;
|
|
15
22
|
//# sourceMappingURL=serviceAudience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,OAAO,EAEZ,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE;IAC/E,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1D,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE5B"}
|
|
@@ -7,6 +7,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.createServiceAudience = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
/**
|
|
10
|
+
* Creates a service audience for the provided container.
|
|
11
|
+
*
|
|
12
|
+
* @param container - The container with which the audience is associated.
|
|
13
|
+
* @param createServiceMember - A function for creating audience members.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam TMember - The {@link IMember} representation used by the audience.
|
|
16
|
+
*
|
|
10
17
|
* @internal
|
|
11
18
|
*/
|
|
12
19
|
function createServiceAudience(props) {
|
|
@@ -21,7 +28,8 @@ exports.createServiceAudience = createServiceAudience;
|
|
|
21
28
|
* This can be extended by different service-specific client packages to additional parameters to
|
|
22
29
|
* the user and client details returned in {@link IMember}.
|
|
23
30
|
*
|
|
24
|
-
* @typeParam
|
|
31
|
+
* @typeParam TMember - A service-specific {@link IMember} implementation.
|
|
32
|
+
*
|
|
25
33
|
* @internal
|
|
26
34
|
*/
|
|
27
35
|
class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
@@ -77,7 +85,7 @@ class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
|
77
85
|
const users = new Map();
|
|
78
86
|
const clientMemberMap = new Map();
|
|
79
87
|
// Iterate through the members and get the user specifics.
|
|
80
|
-
this.audience.getMembers()
|
|
88
|
+
for (const [clientId, member] of this.audience.getMembers()) {
|
|
81
89
|
if (this.shouldIncludeAsMember(member)) {
|
|
82
90
|
const userId = member.user.id;
|
|
83
91
|
// Ensure we're tracking the user
|
|
@@ -90,7 +98,7 @@ class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
|
90
98
|
user.connections.push({ id: clientId, mode: member.mode });
|
|
91
99
|
clientMemberMap.set(clientId, user);
|
|
92
100
|
}
|
|
93
|
-
}
|
|
101
|
+
}
|
|
94
102
|
this.lastMembers = clientMemberMap;
|
|
95
103
|
return users;
|
|
96
104
|
}
|
|
@@ -119,7 +127,7 @@ class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
|
119
127
|
const allMembers = this.getMembers();
|
|
120
128
|
const member = allMembers.get(internalAudienceMember?.user.id);
|
|
121
129
|
if (member === undefined) {
|
|
122
|
-
throw Error(`Attempted to fetch client ${clientId} that is not part of the current member list`);
|
|
130
|
+
throw new Error(`Attempted to fetch client ${clientId} that is not part of the current member list`);
|
|
123
131
|
}
|
|
124
132
|
return member;
|
|
125
133
|
}
|
|
@@ -134,4 +142,4 @@ class ServiceAudience extends client_utils_1.TypedEventEmitter {
|
|
|
134
142
|
return member.details.capabilities.interactive;
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
|
-
//# sourceMappingURL=serviceAudience.
|
|
145
|
+
//# sourceMappingURL=serviceAudience.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAUjE;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AALD,sDAKC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,eACL,SAAQ,gCAAkD;IA2B1D;IACC;;OAEG;IACc,SAAqB,EACrB,mBAAyD;QAE1E,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,wBAAmB,GAAnB,mBAAmB,CAAsC;QAxB3E;;;;;;;;;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AC;QACjE,IAAI,sBAAsB,KAAK,SAAS,EAAE;YACzC,OAAO,SAAS,CAAC;SACjB;QACD,2EAA2E;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACd,6BAA6B,QAAQ,8CAA8C,CACnF,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,MAAe;QAC5C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC;IAChD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { type IAudience, type IContainer } from \"@fluidframework/container-definitions\";\nimport { type IClient } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IServiceAudience,\n\ttype IServiceAudienceEvents,\n\ttype IMember,\n\ttype Myself,\n} from \"./types\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n *\n * @internal\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
|
package/dist/tsdoc-metadata.json
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
5
|
+
import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
9
9
|
* @internal
|
|
@@ -11,7 +11,7 @@ import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
|
11
11
|
export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
12
12
|
/**
|
|
13
13
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
14
|
-
* or `SharedObject
|
|
14
|
+
* or `SharedObject`.
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
@@ -51,6 +51,11 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
|
51
51
|
* @public
|
|
52
52
|
*/
|
|
53
53
|
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
54
|
+
/**
|
|
55
|
+
* Represents properties that can be attached to a container.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export type ContainerAttachProps<T = unknown> = T;
|
|
54
59
|
/**
|
|
55
60
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
56
61
|
*
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAElE;;;;GAIG;AAEH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,cAAc,IACrD,eAAe,CAAC,CAAC,CAAC,GAClB,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IACvD,QAAQ,CAAC,OAAO,EAAE;QAAE,sBAAsB,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,CAAC;CAC5E,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAAI;IACzD,QAAQ,CAAC,UAAU,EAAE,MAAM,eAAe,CAAC;CAC3C,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAE1B;;;;;GAKG;AAEH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,I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;CACnE;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAClD,SAAQ,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACjD;;;;OAIG;IACH,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE7B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,EAAE,WAAW,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> =\n\t| DataObjectClass<T>\n\t| SharedObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @public\n */\nexport type DataObjectClass<T extends IFluidLoadable> = {\n\treadonly factory: { IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n} & LoadableObjectCtor<T>;\n\n/**\n * A class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `SharedObject`.\n * @public\n */\nexport type SharedObjectClass<T extends IFluidLoadable> = {\n\treadonly getFactory: () => IChannelFactory;\n} & LoadableObjectCtor<T>;\n\n/**\n * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\tinitialObjects: LoadableObjectClassRecord;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdynamicObjectTypes?: LoadableObjectClass<any>[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): Map<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\tid: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\tmode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\tuserId: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\tconnections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string };\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
|
-
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
-
import { ContainerSchema, DataObjectClass, SharedObjectClass } from "./types";
|
|
5
|
+
import { type IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
+
import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
|
+
import { type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from "./types";
|
|
9
9
|
/**
|
|
10
10
|
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
11
11
|
* DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
|
|
@@ -16,11 +16,11 @@ export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<
|
|
|
16
16
|
/**
|
|
17
17
|
* Runtime check to determine if a class is a DataObject type
|
|
18
18
|
*/
|
|
19
|
-
export declare const isDataObjectClass: (obj:
|
|
19
|
+
export declare const isDataObjectClass: (obj: unknown) => obj is InternalDataObjectClass<IFluidLoadable>;
|
|
20
20
|
/**
|
|
21
21
|
* Runtime check to determine if a class is a SharedObject type
|
|
22
22
|
*/
|
|
23
|
-
export declare const isSharedObjectClass: (obj:
|
|
23
|
+
export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
|
|
24
24
|
/**
|
|
25
25
|
* The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
|
|
26
26
|
* of both SharedObject or DataObject. This function seperates the two and returns a registery
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE7F;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAS,OAAO,mDAM7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,OAAO,6CAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC"}
|
|
@@ -18,7 +18,8 @@ exports.isDataObjectClass = isDataObjectClass;
|
|
|
18
18
|
* Runtime check to determine if a class is a SharedObject type
|
|
19
19
|
*/
|
|
20
20
|
const isSharedObjectClass = (obj) => {
|
|
21
|
-
|
|
21
|
+
const maybe = obj;
|
|
22
|
+
return maybe?.getFactory !== undefined;
|
|
22
23
|
};
|
|
23
24
|
exports.isSharedObjectClass = isSharedObjectClass;
|
|
24
25
|
/**
|
|
@@ -45,11 +46,13 @@ const parseDataObjectsFromSharedObjects = (schema) => {
|
|
|
45
46
|
...Object.values(schema.initialObjects),
|
|
46
47
|
...(schema.dynamicObjectTypes ?? []),
|
|
47
48
|
]);
|
|
48
|
-
dedupedObjects
|
|
49
|
+
for (const obj of dedupedObjects) {
|
|
50
|
+
tryAddObject(obj);
|
|
51
|
+
}
|
|
49
52
|
if (registryEntries.size === 0 && sharedObjects.size === 0) {
|
|
50
53
|
throw new Error("Container cannot be initialized without any DataTypes");
|
|
51
54
|
}
|
|
52
|
-
return [
|
|
55
|
+
return [[...registryEntries], [...sharedObjects]];
|
|
53
56
|
};
|
|
54
57
|
exports.parseDataObjectsFromSharedObjects = parseDataObjectsFromSharedObjects;
|
|
55
|
-
//# sourceMappingURL=utils.
|
|
58
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAkD,EAAE;IACjG,MAAM,KAAK,GAAG,GAAmE,CAAC;IAClF,OAAO,CACN,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,KAAK,EAAE,OAAO,CACzD,CAAC;AACH,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,GAAY,EAA4C,EAAE;IAC7F,MAAM,KAAK,GAAG,GAA6D,CAAC;IAC5E,OAAO,KAAK,EAAE,UAAU,KAAK,SAAS,CAAC;AACxC,CAAC,CAAC;AAHW,QAAA,mBAAmB,uBAG9B;AAEF;;;;GAIG;AACI,MAAM,iCAAiC,GAAG,CAChD,MAAuB,EACmC,EAAE;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;IACpE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,GAAY,EAAQ,EAAE;QAC3C,IAAI,IAAA,2BAAmB,EAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,IAAA,yBAAiB,EAAC,GAAG,CAAC,EAAE;YAClC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACnE;IACF,CAAC,CAAC;IAEF,gDAAgD;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC9B,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE;QACjC,YAAY,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,CAAC,GAAG,eAAe,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC;AA9BW,QAAA,iCAAiC,qCA8B5C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from \"./types\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type\n */\nexport const isDataObjectClass = (obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> => {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\treturn (\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe?.factory?.IFluidDataStoreFactory === maybe?.factory\n\t);\n};\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {\n\tconst maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;\n\treturn maybe?.getFactory !== undefined;\n};\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function seperates the two and returns a registery\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: unknown): void => {\n\t\tif (isSharedObjectClass(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
|
|
@@ -9,6 +9,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
9
9
|
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
10
10
|
import { IRuntimeFactory } from '@fluidframework/container-definitions';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents properties that can be attached to a container.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type ContainerAttachProps<T = unknown> = T;
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
14
20
|
*
|
|
@@ -94,6 +100,7 @@ export declare interface IConnection {
|
|
|
94
100
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
95
101
|
*
|
|
96
102
|
* @remarks Note: external implementations of this interface are not supported.
|
|
103
|
+
*
|
|
97
104
|
* @sealed
|
|
98
105
|
* @public
|
|
99
106
|
*/
|
|
@@ -155,7 +162,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
155
162
|
*
|
|
156
163
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
157
164
|
*/
|
|
158
|
-
attach(): Promise<string>;
|
|
165
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
159
166
|
/**
|
|
160
167
|
* Attempts to connect the container to the delta stream and process operations.
|
|
161
168
|
*
|
|
@@ -164,7 +171,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
164
171
|
* @remarks
|
|
165
172
|
*
|
|
166
173
|
* This should only be called when the container is in the
|
|
167
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
174
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
168
175
|
*
|
|
169
176
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
170
177
|
*/
|
|
@@ -175,7 +182,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
175
182
|
* @remarks
|
|
176
183
|
*
|
|
177
184
|
* This should only be called when the container is in the
|
|
178
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
185
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
179
186
|
*
|
|
180
187
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
181
188
|
*/
|
|
@@ -354,7 +361,7 @@ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectCl
|
|
|
354
361
|
|
|
355
362
|
/**
|
|
356
363
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
357
|
-
* or `SharedObject
|
|
364
|
+
* or `SharedObject`.
|
|
358
365
|
* @public
|
|
359
366
|
*/
|
|
360
367
|
export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
@@ -9,6 +9,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
9
9
|
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
10
10
|
import { IRuntimeFactory } from '@fluidframework/container-definitions';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents properties that can be attached to a container.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type ContainerAttachProps<T = unknown> = T;
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
14
20
|
*
|
|
@@ -96,6 +102,7 @@ export declare interface IConnection {
|
|
|
96
102
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
97
103
|
*
|
|
98
104
|
* @remarks Note: external implementations of this interface are not supported.
|
|
105
|
+
*
|
|
99
106
|
* @sealed
|
|
100
107
|
* @public
|
|
101
108
|
*/
|
|
@@ -157,7 +164,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
157
164
|
*
|
|
158
165
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
159
166
|
*/
|
|
160
|
-
attach(): Promise<string>;
|
|
167
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
161
168
|
/**
|
|
162
169
|
* Attempts to connect the container to the delta stream and process operations.
|
|
163
170
|
*
|
|
@@ -166,7 +173,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
166
173
|
* @remarks
|
|
167
174
|
*
|
|
168
175
|
* This should only be called when the container is in the
|
|
169
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
176
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
170
177
|
*
|
|
171
178
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
172
179
|
*/
|
|
@@ -177,7 +184,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
177
184
|
* @remarks
|
|
178
185
|
*
|
|
179
186
|
* This should only be called when the container is in the
|
|
180
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
187
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
181
188
|
*
|
|
182
189
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
183
190
|
*/
|
|
@@ -358,7 +365,7 @@ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectCl
|
|
|
358
365
|
|
|
359
366
|
/**
|
|
360
367
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
361
|
-
* or `SharedObject
|
|
368
|
+
* or `SharedObject`.
|
|
362
369
|
* @public
|
|
363
370
|
*/
|
|
364
371
|
export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
@@ -9,6 +9,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
9
9
|
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
10
10
|
import { IRuntimeFactory } from '@fluidframework/container-definitions';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents properties that can be attached to a container.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type ContainerAttachProps<T = unknown> = T;
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
14
20
|
*
|
|
@@ -96,6 +102,7 @@ export declare interface IConnection {
|
|
|
96
102
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
97
103
|
*
|
|
98
104
|
* @remarks Note: external implementations of this interface are not supported.
|
|
105
|
+
*
|
|
99
106
|
* @sealed
|
|
100
107
|
* @public
|
|
101
108
|
*/
|
|
@@ -157,7 +164,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
157
164
|
*
|
|
158
165
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
159
166
|
*/
|
|
160
|
-
attach(): Promise<string>;
|
|
167
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
161
168
|
/**
|
|
162
169
|
* Attempts to connect the container to the delta stream and process operations.
|
|
163
170
|
*
|
|
@@ -166,7 +173,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
166
173
|
* @remarks
|
|
167
174
|
*
|
|
168
175
|
* This should only be called when the container is in the
|
|
169
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
176
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
170
177
|
*
|
|
171
178
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
172
179
|
*/
|
|
@@ -177,7 +184,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
177
184
|
* @remarks
|
|
178
185
|
*
|
|
179
186
|
* This should only be called when the container is in the
|
|
180
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
187
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
181
188
|
*
|
|
182
189
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
183
190
|
*/
|
|
@@ -358,7 +365,7 @@ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectCl
|
|
|
358
365
|
|
|
359
366
|
/**
|
|
360
367
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
361
|
-
* or `SharedObject
|
|
368
|
+
* or `SharedObject`.
|
|
362
369
|
* @public
|
|
363
370
|
*/
|
|
364
371
|
export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
@@ -9,6 +9,12 @@ import { IEventProvider } from '@fluidframework/core-interfaces';
|
|
|
9
9
|
import { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
10
10
|
import { IRuntimeFactory } from '@fluidframework/container-definitions';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents properties that can be attached to a container.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type ContainerAttachProps<T = unknown> = T;
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
14
20
|
*
|
|
@@ -52,6 +58,9 @@ export declare interface ContainerSchema {
|
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
61
|
+
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} for a container with a single
|
|
62
|
+
* {@link IRootDataObject}, which is constructed from the provided schema.
|
|
63
|
+
*
|
|
55
64
|
* @internal
|
|
56
65
|
*/
|
|
57
66
|
export declare function createDOProviderContainerRuntimeFactory(props: {
|
|
@@ -59,6 +68,8 @@ export declare function createDOProviderContainerRuntimeFactory(props: {
|
|
|
59
68
|
}): IRuntimeFactory;
|
|
60
69
|
|
|
61
70
|
/**
|
|
71
|
+
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
72
|
+
*
|
|
62
73
|
* @internal
|
|
63
74
|
*/
|
|
64
75
|
export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
|
|
@@ -67,12 +78,19 @@ export declare function createFluidContainer<TContainerSchema extends ContainerS
|
|
|
67
78
|
}): IFluidContainer<TContainerSchema>;
|
|
68
79
|
|
|
69
80
|
/**
|
|
81
|
+
* Creates a service audience for the provided container.
|
|
82
|
+
*
|
|
83
|
+
* @param container - The container with which the audience is associated.
|
|
84
|
+
* @param createServiceMember - A function for creating audience members.
|
|
85
|
+
*
|
|
86
|
+
* @typeParam TMember - The {@link IMember} representation used by the audience.
|
|
87
|
+
*
|
|
70
88
|
* @internal
|
|
71
89
|
*/
|
|
72
|
-
export declare function createServiceAudience<
|
|
90
|
+
export declare function createServiceAudience<TMember extends IMember = IMember>(props: {
|
|
73
91
|
container: IContainer;
|
|
74
|
-
createServiceMember: (audienceMember: IClient) =>
|
|
75
|
-
}): IServiceAudience<
|
|
92
|
+
createServiceMember: (audienceMember: IClient) => TMember;
|
|
93
|
+
}): IServiceAudience<TMember>;
|
|
76
94
|
|
|
77
95
|
/**
|
|
78
96
|
* A class that has a factory that can create a `DataObject` and a
|
|
@@ -111,6 +129,7 @@ export declare interface IConnection {
|
|
|
111
129
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
112
130
|
*
|
|
113
131
|
* @remarks Note: external implementations of this interface are not supported.
|
|
132
|
+
*
|
|
114
133
|
* @sealed
|
|
115
134
|
* @public
|
|
116
135
|
*/
|
|
@@ -172,7 +191,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
172
191
|
*
|
|
173
192
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
174
193
|
*/
|
|
175
|
-
attach(): Promise<string>;
|
|
194
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
176
195
|
/**
|
|
177
196
|
* Attempts to connect the container to the delta stream and process operations.
|
|
178
197
|
*
|
|
@@ -181,7 +200,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
181
200
|
* @remarks
|
|
182
201
|
*
|
|
183
202
|
* This should only be called when the container is in the
|
|
184
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
203
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
185
204
|
*
|
|
186
205
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
187
206
|
*/
|
|
@@ -192,7 +211,7 @@ export declare interface IFluidContainer<TContainerSchema extends ContainerSchem
|
|
|
192
211
|
* @remarks
|
|
193
212
|
*
|
|
194
213
|
* This should only be called when the container is in the
|
|
195
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
214
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
196
215
|
*
|
|
197
216
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
198
217
|
*/
|
|
@@ -394,7 +413,7 @@ export declare type LoadableObjectClass<T extends IFluidLoadable> = DataObjectCl
|
|
|
394
413
|
|
|
395
414
|
/**
|
|
396
415
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
397
|
-
* or `SharedObject
|
|
416
|
+
* or `SharedObject`.
|
|
398
417
|
* @public
|
|
399
418
|
*/
|
|
400
419
|
export declare type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
package/lib/fluidContainer.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.mjs";
|
|
1
|
+
import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
2
|
+
import { AttachState, type IContainer, type ICriticalContainerError, type ConnectionState } from "@fluidframework/container-definitions";
|
|
3
|
+
import type { ContainerSchema, ContainerAttachProps, IRootDataObject, LoadableObjectClass } from "./types.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
6
6
|
* @public
|
|
@@ -73,6 +73,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
73
73
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
74
74
|
*
|
|
75
75
|
* @remarks Note: external implementations of this interface are not supported.
|
|
76
|
+
*
|
|
76
77
|
* @sealed
|
|
77
78
|
* @public
|
|
78
79
|
*/
|
|
@@ -134,7 +135,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
134
135
|
*
|
|
135
136
|
* @returns A promise which resolves when the attach is complete, with the string identifier of the container.
|
|
136
137
|
*/
|
|
137
|
-
attach(): Promise<string>;
|
|
138
|
+
attach(props?: ContainerAttachProps): Promise<string>;
|
|
138
139
|
/**
|
|
139
140
|
* Attempts to connect the container to the delta stream and process operations.
|
|
140
141
|
*
|
|
@@ -143,7 +144,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
143
144
|
* @remarks
|
|
144
145
|
*
|
|
145
146
|
* This should only be called when the container is in the
|
|
146
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.
|
|
147
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Disconnected} state.
|
|
147
148
|
*
|
|
148
149
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
149
150
|
*/
|
|
@@ -154,7 +155,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
154
155
|
* @remarks
|
|
155
156
|
*
|
|
156
157
|
* This should only be called when the container is in the
|
|
157
|
-
* {@link @fluidframework/container-definitions#ConnectionState.Connected} state.
|
|
158
|
+
* {@link @fluidframework/container-definitions#(ConnectionState:namespace).Connected} state.
|
|
158
159
|
*
|
|
159
160
|
* This can be determined by observing {@link IFluidContainer.connectionState}.
|
|
160
161
|
*/
|
|
@@ -179,6 +180,8 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
179
180
|
dispose(): void;
|
|
180
181
|
}
|
|
181
182
|
/**
|
|
183
|
+
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
184
|
+
*
|
|
182
185
|
* @internal
|
|
183
186
|
*/
|
|
184
187
|
export declare function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
|