@fluidframework/fluid-static 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.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 +20 -0
- package/README.md +1 -2
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/fluid-static.api.md +53 -25
- package/dist/fluid-static-alpha.d.ts +417 -0
- package/dist/fluid-static-beta.d.ts +99 -0
- package/dist/fluid-static-public.d.ts +99 -0
- package/dist/fluid-static-untrimmed.d.ts +619 -0
- package/dist/{fluidContainer.js → fluidContainer.cjs} +12 -4
- package/dist/fluidContainer.cjs.map +1 -0
- package/dist/fluidContainer.d.ts +26 -7
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/{rootDataObject.js → rootDataObject.cjs} +15 -4
- package/dist/rootDataObject.cjs.map +1 -0
- package/dist/rootDataObject.d.ts +9 -36
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/{serviceAudience.js → serviceAudience.cjs} +17 -2
- package/dist/serviceAudience.cjs.map +1 -0
- package/dist/serviceAudience.d.ts +9 -0
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{types.js → types.cjs} +1 -1
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +21 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{utils.js → utils.cjs} +1 -1
- package/dist/utils.cjs.map +1 -0
- package/lib/fluid-static-alpha.d.ts +417 -0
- package/lib/fluid-static-beta.d.ts +99 -0
- package/lib/fluid-static-public.d.ts +99 -0
- package/lib/fluid-static-untrimmed.d.ts +619 -0
- package/lib/fluidContainer.d.ts +26 -11
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/{fluidContainer.js → fluidContainer.mjs} +10 -7
- package/lib/fluidContainer.mjs.map +1 -0
- package/lib/index.d.ts +4 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +8 -0
- package/lib/index.mjs.map +1 -0
- package/lib/rootDataObject.d.ts +9 -40
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/{rootDataObject.js → rootDataObject.mjs} +14 -7
- package/lib/rootDataObject.mjs.map +1 -0
- package/lib/serviceAudience.d.ts +10 -1
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/{serviceAudience.js → serviceAudience.mjs} +15 -1
- package/lib/serviceAudience.mjs.map +1 -0
- package/lib/types.d.ts +21 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/{types.js → types.mjs} +1 -1
- package/lib/types.mjs.map +1 -0
- package/lib/utils.d.ts +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/{utils.js → utils.mjs} +1 -1
- package/lib/utils.mjs.map +1 -0
- package/package.json +53 -33
- package/src/fluidContainer.ts +44 -9
- package/src/index.ts +14 -4
- package/src/rootDataObject.ts +16 -1
- package/src/serviceAudience.ts +18 -0
- package/src/types.ts +22 -1
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +5 -3
- package/dist/fluidContainer.js.map +0 -1
- package/dist/index.js +0 -19
- package/dist/index.js.map +0 -1
- package/dist/rootDataObject.js.map +0 -1
- package/dist/serviceAudience.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/lib/fluidContainer.js.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
- package/lib/rootDataObject.js.map +0 -1
- package/lib/serviceAudience.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @alpha\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` in a {@link LoadableObjectRecord}.\n * @alpha\n */\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 * @alpha\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 * @alpha\n */\nexport type DataObjectClass<T extends IFluidLoadable> = {\n\treadonly factory: IFluidDataStoreFactory;\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 * @alpha\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 * @alpha\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => 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 * @alpha\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\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\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 * @alpha\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string };\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
6
|
import { NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
|
-
import { ContainerSchema, DataObjectClass, SharedObjectClass } from "./types";
|
|
7
|
+
import { ContainerSchema, DataObjectClass, SharedObjectClass } from "./types.mjs";
|
|
8
8
|
/**
|
|
9
9
|
* Runtime check to determine if a class is a DataObject type
|
|
10
10
|
*/
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,eAAe,EAAE,MAAM,uCAAuC;OAChE,EAAE,gCAAgC,EAAE,MAAM,qCAAqC;OAC/E,EAAE,eAAe,EAAE,eAAe,EAAuB,iBAAiB,EAAE;AAEnF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAS,GAAG,gCAEzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,GAAG,kCAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA0BxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAQ,EAA+B,EAAE;IAC1E,OAAO,GAAG,EAAE,OAAO,KAAK,SAAS,CAAC;AACnC,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAiC,EAAE;IAC9E,OAAO,GAAG,EAAE,UAAU,KAAK,SAAS,CAAC;AACtC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,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,GAA6B,EAAE,EAAE;QACtD,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,iBAAiB,CAAC,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,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAErC,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,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { NamedFluidDataStoreRegistryEntry } from \"@fluidframework/runtime-definitions\";\nimport { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from \"./types\";\n\n/**\n * Runtime check to determine if a class is a DataObject type\n */\nexport const isDataObjectClass = (obj: any): obj is DataObjectClass<any> => {\n\treturn obj?.factory !== undefined;\n};\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport const isSharedObjectClass = (obj: any): obj is SharedObjectClass<any> => {\n\treturn obj?.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: LoadableObjectClass<any>) => {\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\tdedupedObjects.forEach(tryAddObject);\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 [Array.from(registryEntries), Array.from(sharedObjects)];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.4.0",
|
|
4
4
|
"description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"main": "dist/index.
|
|
15
|
-
"module": "lib/index.
|
|
14
|
+
"main": "dist/index.cjs",
|
|
15
|
+
"module": "lib/index.mjs",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
17
|
"c8": {
|
|
18
18
|
"all": true,
|
|
19
19
|
"cache-dir": "nyc/.cache",
|
|
20
20
|
"exclude": [
|
|
21
21
|
"src/test/**/*.ts",
|
|
22
|
-
"dist/test/**/*.
|
|
22
|
+
"dist/test/**/*.cjs"
|
|
23
23
|
],
|
|
24
24
|
"exclude-after-remap": false,
|
|
25
25
|
"include": [
|
|
26
26
|
"src/**/*.ts",
|
|
27
|
-
"dist/**/*.
|
|
27
|
+
"dist/**/*.cjs"
|
|
28
28
|
],
|
|
29
29
|
"report-dir": "nyc/report",
|
|
30
30
|
"reporter": [
|
|
@@ -35,31 +35,33 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.
|
|
39
|
-
"@fluidframework/aqueduct": ">=2.0.0-internal.7.
|
|
40
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.7.
|
|
41
|
-
"@fluidframework/container-loader": ">=2.0.0-internal.7.
|
|
42
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.
|
|
43
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
44
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
39
|
+
"@fluidframework/aqueduct": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
40
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
41
|
+
"@fluidframework/container-loader": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
42
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
43
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
44
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
45
45
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
46
|
-
"@fluidframework/request-handler": ">=2.0.0-internal.7.
|
|
47
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.
|
|
48
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.
|
|
46
|
+
"@fluidframework/request-handler": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
47
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
48
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@
|
|
51
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
52
|
+
"@fluid-tools/build-cli": "^0.28.0",
|
|
52
53
|
"@fluidframework/build-common": "^2.0.3",
|
|
53
|
-
"@fluidframework/build-tools": "^0.
|
|
54
|
-
"@fluidframework/eslint-config-fluid": "^3.
|
|
55
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.7.2.
|
|
56
|
-
"@fluidframework/map": ">=2.0.0-internal.7.
|
|
57
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.
|
|
58
|
-
"@fluidframework/sequence": ">=2.0.0-internal.7.
|
|
59
|
-
"@microsoft/api-extractor": "^7.
|
|
54
|
+
"@fluidframework/build-tools": "^0.28.0",
|
|
55
|
+
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
56
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.7.2.0",
|
|
57
|
+
"@fluidframework/map": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
58
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
59
|
+
"@fluidframework/sequence": ">=2.0.0-internal.7.4.0 <2.0.0-internal.7.5.0",
|
|
60
|
+
"@microsoft/api-extractor": "^7.38.3",
|
|
60
61
|
"@types/mocha": "^9.1.1",
|
|
61
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^18.19.0",
|
|
62
63
|
"c8": "^7.7.1",
|
|
64
|
+
"copyfiles": "^2.4.1",
|
|
63
65
|
"cross-env": "^7.0.3",
|
|
64
66
|
"eslint": "~8.50.0",
|
|
65
67
|
"mocha": "^10.2.0",
|
|
@@ -68,32 +70,50 @@
|
|
|
68
70
|
"moment": "^2.21.0",
|
|
69
71
|
"prettier": "~3.0.3",
|
|
70
72
|
"rimraf": "^4.4.0",
|
|
73
|
+
"tsc-multi": "^1.1.0",
|
|
71
74
|
"typescript": "~5.1.6"
|
|
72
75
|
},
|
|
76
|
+
"fluidBuild": {
|
|
77
|
+
"tasks": {
|
|
78
|
+
"build:docs": {
|
|
79
|
+
"dependsOn": [
|
|
80
|
+
"...",
|
|
81
|
+
"api-extractor:commonjs",
|
|
82
|
+
"api-extractor:esnext"
|
|
83
|
+
],
|
|
84
|
+
"script": false
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
73
88
|
"typeValidation": {
|
|
74
89
|
"broken": {}
|
|
75
90
|
},
|
|
76
91
|
"scripts": {
|
|
92
|
+
"api": "fluid-build . --task api",
|
|
93
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
94
|
+
"api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
|
|
77
95
|
"build": "fluid-build . --task build",
|
|
78
96
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
79
97
|
"build:compile": "fluid-build . --task compile",
|
|
80
|
-
"build:docs": "
|
|
81
|
-
"build:esnext": "tsc --
|
|
82
|
-
"build:test": "tsc --
|
|
98
|
+
"build:docs": "fluid-build . --task api",
|
|
99
|
+
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
100
|
+
"build:test": "tsc-multi --config ./tsc-multi.test.json",
|
|
101
|
+
"check:are-the-types-wrong": "attw --pack",
|
|
102
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
83
103
|
"ci:build:docs": "api-extractor run",
|
|
84
|
-
"clean": "rimraf --glob dist lib \"
|
|
104
|
+
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
85
105
|
"eslint": "eslint --format stylish src",
|
|
86
106
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
87
107
|
"format": "npm run prettier:fix",
|
|
88
|
-
"lint": "npm run prettier && npm run eslint",
|
|
108
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
89
109
|
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
90
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
91
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
110
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
111
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
92
112
|
"test": "npm run test:mocha",
|
|
93
113
|
"test:coverage": "c8 npm test",
|
|
94
|
-
"test:mocha": "mocha --recursive
|
|
114
|
+
"test:mocha": "mocha --recursive \"dist/test/**/*.spec.cjs\" -r node_modules/@fluidframework/mocha-test-setup",
|
|
95
115
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
96
|
-
"tsc": "tsc",
|
|
116
|
+
"tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
|
|
97
117
|
"typetests:gen": "fluid-type-test-generator",
|
|
98
118
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
99
119
|
}
|
package/src/fluidContainer.ts
CHANGED
|
@@ -10,10 +10,28 @@ import {
|
|
|
10
10
|
ICriticalContainerError,
|
|
11
11
|
ConnectionState,
|
|
12
12
|
} from "@fluidframework/container-definitions";
|
|
13
|
-
import type { IRootDataObject, LoadableObjectClass
|
|
13
|
+
import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
export type InitialObjects<T extends ContainerSchema> = {
|
|
20
|
+
// Construct a LoadableObjectRecord type by enumerating the keys of
|
|
21
|
+
// 'ContainerSchema.initialObjects' and infering the value type of each key.
|
|
22
|
+
//
|
|
23
|
+
// The '? TChannel : never' is required because infer can only be used in
|
|
24
|
+
// a conditional 'extends' expression.
|
|
25
|
+
[K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<
|
|
26
|
+
infer TChannel
|
|
27
|
+
>
|
|
28
|
+
? TChannel
|
|
29
|
+
: never;
|
|
30
|
+
};
|
|
14
31
|
|
|
15
32
|
/**
|
|
16
33
|
* Events emitted from {@link IFluidContainer}.
|
|
34
|
+
* @alpha
|
|
17
35
|
*/
|
|
18
36
|
export interface IFluidContainerEvents extends IEvent {
|
|
19
37
|
/**
|
|
@@ -75,9 +93,13 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
75
93
|
* Provides an entrypoint into the client side of collaborative Fluid data.
|
|
76
94
|
* Provides access to the data as well as status on the collaboration session.
|
|
77
95
|
*
|
|
96
|
+
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
97
|
+
*
|
|
78
98
|
* @remarks Note: external implementations of this interface are not supported.
|
|
99
|
+
* @alpha
|
|
79
100
|
*/
|
|
80
|
-
export interface IFluidContainer extends
|
|
101
|
+
export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
102
|
+
extends IEventProvider<IFluidContainerEvents> {
|
|
81
103
|
/**
|
|
82
104
|
* Provides the current connected state of the container
|
|
83
105
|
*/
|
|
@@ -115,7 +137,7 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
115
137
|
*
|
|
116
138
|
* @remarks These data objects and DDSes exist for the lifetime of the container.
|
|
117
139
|
*/
|
|
118
|
-
readonly initialObjects:
|
|
140
|
+
readonly initialObjects: InitialObjects<TContainerSchema>;
|
|
119
141
|
|
|
120
142
|
/**
|
|
121
143
|
* The current attachment state of the container.
|
|
@@ -189,17 +211,32 @@ export interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {
|
|
|
189
211
|
dispose(): void;
|
|
190
212
|
}
|
|
191
213
|
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
export function createFluidContainer<
|
|
218
|
+
TContainerSchema extends ContainerSchema = ContainerSchema,
|
|
219
|
+
>(props: {
|
|
220
|
+
container: IContainer;
|
|
221
|
+
rootDataObject: IRootDataObject;
|
|
222
|
+
}): IFluidContainer<TContainerSchema> {
|
|
223
|
+
return new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);
|
|
224
|
+
}
|
|
225
|
+
|
|
192
226
|
/**
|
|
193
227
|
* Base {@link IFluidContainer} implementation.
|
|
194
228
|
*
|
|
229
|
+
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
195
230
|
* @remarks
|
|
196
231
|
*
|
|
197
232
|
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
198
233
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
234
|
+
* @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead
|
|
235
|
+
* @internal
|
|
199
236
|
*/
|
|
200
|
-
export class FluidContainer
|
|
237
|
+
export class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
201
238
|
extends TypedEventEmitter<IFluidContainerEvents>
|
|
202
|
-
implements IFluidContainer
|
|
239
|
+
implements IFluidContainer<TContainerSchema>
|
|
203
240
|
{
|
|
204
241
|
private readonly connectedHandler = () => this.emit("connected");
|
|
205
242
|
private readonly disconnectedHandler = () => this.emit("disconnected");
|
|
@@ -251,8 +288,8 @@ export class FluidContainer
|
|
|
251
288
|
/**
|
|
252
289
|
* {@inheritDoc IFluidContainer.initialObjects}
|
|
253
290
|
*/
|
|
254
|
-
public get initialObjects() {
|
|
255
|
-
return this.rootDataObject.initialObjects
|
|
291
|
+
public get initialObjects(): InitialObjects<TContainerSchema> {
|
|
292
|
+
return this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;
|
|
256
293
|
}
|
|
257
294
|
|
|
258
295
|
/**
|
|
@@ -314,8 +351,6 @@ export class FluidContainer
|
|
|
314
351
|
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
315
352
|
*
|
|
316
353
|
* @remarks Used to power debug tooling.
|
|
317
|
-
*
|
|
318
|
-
* @internal
|
|
319
354
|
*/
|
|
320
355
|
public readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {
|
|
321
356
|
return this.container;
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,18 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export {
|
|
13
|
+
FluidContainer,
|
|
14
|
+
createFluidContainer,
|
|
15
|
+
IFluidContainer,
|
|
16
|
+
IFluidContainerEvents,
|
|
17
|
+
InitialObjects,
|
|
18
|
+
} from "./fluidContainer";
|
|
19
|
+
export {
|
|
20
|
+
DOProviderContainerRuntimeFactory,
|
|
21
|
+
createDOProviderContainerRuntimeFactory,
|
|
22
|
+
} from "./rootDataObject";
|
|
23
|
+
export { ServiceAudience, createServiceAudience } from "./serviceAudience";
|
|
15
24
|
export {
|
|
16
25
|
ContainerSchema,
|
|
17
26
|
DataObjectClass,
|
|
@@ -25,6 +34,7 @@ export {
|
|
|
25
34
|
LoadableObjectCtor,
|
|
26
35
|
LoadableObjectRecord,
|
|
27
36
|
MemberChangedListener,
|
|
28
|
-
SharedObjectClass,
|
|
29
37
|
Myself,
|
|
38
|
+
SharedObjectClass,
|
|
39
|
+
IProvideRootDataObject,
|
|
30
40
|
} from "./types";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
13
13
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
14
14
|
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
15
|
+
import { IRuntimeFactory } from "@fluidframework/container-definitions";
|
|
15
16
|
import {
|
|
16
17
|
ContainerSchema,
|
|
17
18
|
DataObjectClass,
|
|
@@ -39,12 +40,15 @@ export interface RootDataObjectProps {
|
|
|
39
40
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
40
41
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
class RootDataObject
|
|
43
44
|
extends DataObject<{ InitialState: RootDataObjectProps }>
|
|
44
45
|
implements IRootDataObject
|
|
45
46
|
{
|
|
46
47
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
47
48
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
49
|
+
public get IRootDataObject() {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
48
52
|
|
|
49
53
|
private get initialObjectsDir() {
|
|
50
54
|
const dir = this.root.getSubDirectory(this.initialObjectsDirKey);
|
|
@@ -139,6 +143,15 @@ export class RootDataObject
|
|
|
139
143
|
|
|
140
144
|
const rootDataStoreId = "rootDOId";
|
|
141
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @internal
|
|
148
|
+
*/
|
|
149
|
+
export function createDOProviderContainerRuntimeFactory(props: {
|
|
150
|
+
schema: ContainerSchema;
|
|
151
|
+
}): IRuntimeFactory {
|
|
152
|
+
return new DOProviderContainerRuntimeFactory(props.schema);
|
|
153
|
+
}
|
|
154
|
+
|
|
142
155
|
/**
|
|
143
156
|
* Container code that provides a single {@link IRootDataObject}.
|
|
144
157
|
*
|
|
@@ -146,6 +159,8 @@ const rootDataStoreId = "rootDOId";
|
|
|
146
159
|
*
|
|
147
160
|
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
148
161
|
* to the container runtime factory.
|
|
162
|
+
* @deprecated use {@link createDOProviderContainerRuntimeFactory} instead
|
|
163
|
+
* @internal
|
|
149
164
|
*/
|
|
150
165
|
export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
151
166
|
private readonly rootDataObjectFactory: DataObjectFactory<
|
package/src/serviceAudience.ts
CHANGED
|
@@ -8,6 +8,22 @@ import { IAudience, IContainer } from "@fluidframework/container-definitions";
|
|
|
8
8
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } from "./types";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function createServiceAudience<M extends IMember = IMember>(props: {
|
|
15
|
+
container: IContainer;
|
|
16
|
+
createServiceMember: (audienceMember: IClient) => M;
|
|
17
|
+
}): IServiceAudience<M> {
|
|
18
|
+
// todo: once ServiceAudience isn't exported, we can remove abstract from it, and just use that here
|
|
19
|
+
const c = class NewServiceAudience extends ServiceAudience<M> {
|
|
20
|
+
protected createServiceMember(audienceMember: IClient) {
|
|
21
|
+
return props.createServiceMember(audienceMember);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return new c(props.container);
|
|
25
|
+
}
|
|
26
|
+
|
|
11
27
|
/**
|
|
12
28
|
* Base class for providing audience information for sessions interacting with {@link IFluidContainer}
|
|
13
29
|
*
|
|
@@ -17,6 +33,8 @@ import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } from "./typ
|
|
|
17
33
|
* the user and client details returned in {@link IMember}.
|
|
18
34
|
*
|
|
19
35
|
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
36
|
+
* @deprecated use {@link createServiceAudience} and {@link IServiceAudience} instead
|
|
37
|
+
* @internal
|
|
20
38
|
*/
|
|
21
39
|
export abstract class ServiceAudience<M extends IMember = IMember>
|
|
22
40
|
extends TypedEventEmitter<IServiceAudienceEvents<M>>
|
package/src/types.ts
CHANGED
|
@@ -9,12 +9,14 @@ import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
12
|
+
* @alpha
|
|
12
13
|
*/
|
|
13
14
|
export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
17
18
|
* or `SharedObject` in a {@link LoadableObjectRecord}.
|
|
19
|
+
* @alpha
|
|
18
20
|
*/
|
|
19
21
|
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
20
22
|
|
|
@@ -22,6 +24,7 @@ export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>
|
|
|
22
24
|
* A class object of `DataObject` or `SharedObject`.
|
|
23
25
|
*
|
|
24
26
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
27
|
+
* @alpha
|
|
25
28
|
*/
|
|
26
29
|
export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
27
30
|
| DataObjectClass<T>
|
|
@@ -32,6 +35,7 @@ export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
|
32
35
|
* constructor that will return the type of the `DataObject`.
|
|
33
36
|
*
|
|
34
37
|
* @typeParam T - The class of the `DataObject`.
|
|
38
|
+
* @alpha
|
|
35
39
|
*/
|
|
36
40
|
export type DataObjectClass<T extends IFluidLoadable> = {
|
|
37
41
|
readonly factory: IFluidDataStoreFactory;
|
|
@@ -42,6 +46,7 @@ export type DataObjectClass<T extends IFluidLoadable> = {
|
|
|
42
46
|
* constructor that will return the type of the `DataObject`.
|
|
43
47
|
*
|
|
44
48
|
* @typeParam T - The class of the `SharedObject`.
|
|
49
|
+
* @alpha
|
|
45
50
|
*/
|
|
46
51
|
export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
47
52
|
readonly getFactory: () => IChannelFactory;
|
|
@@ -51,6 +56,7 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
|
51
56
|
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
52
57
|
*
|
|
53
58
|
* @typeParam T - The class of the loadable object.
|
|
59
|
+
* @alpha
|
|
54
60
|
*/
|
|
55
61
|
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
56
62
|
|
|
@@ -61,6 +67,7 @@ export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[])
|
|
|
61
67
|
*
|
|
62
68
|
* It includes both the instances of objects that are initially available upon `Container` creation, as well
|
|
63
69
|
* as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
|
|
70
|
+
* @alpha
|
|
64
71
|
*/
|
|
65
72
|
export interface ContainerSchema {
|
|
66
73
|
/**
|
|
@@ -96,11 +103,19 @@ export interface ContainerSchema {
|
|
|
96
103
|
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
97
104
|
}
|
|
98
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export interface IProvideRootDataObject {
|
|
110
|
+
readonly IRootDataObject?: IRootDataObject;
|
|
111
|
+
}
|
|
112
|
+
|
|
99
113
|
/**
|
|
100
114
|
* Holds the collection of objects that the container was initially created with, as well as provides the ability
|
|
101
115
|
* to dynamically create further objects during usage.
|
|
116
|
+
* @internal
|
|
102
117
|
*/
|
|
103
|
-
export interface IRootDataObject {
|
|
118
|
+
export interface IRootDataObject extends IProvideRootDataObject {
|
|
104
119
|
/**
|
|
105
120
|
* Provides a record of the initial objects defined on creation.
|
|
106
121
|
*/
|
|
@@ -123,6 +138,7 @@ export interface IRootDataObject {
|
|
|
123
138
|
* @param member - The service-specific member object for the client.
|
|
124
139
|
*
|
|
125
140
|
* @see See {@link IServiceAudienceEvents} for usage details.
|
|
141
|
+
* @alpha
|
|
126
142
|
*/
|
|
127
143
|
export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
|
|
128
144
|
|
|
@@ -135,6 +151,7 @@ export type MemberChangedListener<M extends IMember> = (clientId: string, member
|
|
|
135
151
|
* {@link IServiceAudience.getMembers} method will emit events.
|
|
136
152
|
*
|
|
137
153
|
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
154
|
+
* @alpha
|
|
138
155
|
*/
|
|
139
156
|
export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
140
157
|
/**
|
|
@@ -168,6 +185,7 @@ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
|
168
185
|
* details about the connecting client, such as device information, environment, or a username.
|
|
169
186
|
*
|
|
170
187
|
* @typeParam M - A service-specific {@link IMember} type.
|
|
188
|
+
* @alpha
|
|
171
189
|
*/
|
|
172
190
|
export interface IServiceAudience<M extends IMember>
|
|
173
191
|
extends IEventProvider<IServiceAudienceEvents<M>> {
|
|
@@ -188,6 +206,7 @@ export interface IServiceAudience<M extends IMember>
|
|
|
188
206
|
* Base interface for information for each connection made to the Fluid session.
|
|
189
207
|
*
|
|
190
208
|
* @remarks This interface can be extended to provide additional information specific to each service.
|
|
209
|
+
* @alpha
|
|
191
210
|
*/
|
|
192
211
|
export interface IConnection {
|
|
193
212
|
/**
|
|
@@ -205,6 +224,7 @@ export interface IConnection {
|
|
|
205
224
|
* Base interface to be implemented to fetch each service's member.
|
|
206
225
|
*
|
|
207
226
|
* @remarks This interface can be extended by each service to provide additional service-specific user metadata.
|
|
227
|
+
* @alpha
|
|
208
228
|
*/
|
|
209
229
|
export interface IMember {
|
|
210
230
|
/**
|
|
@@ -220,5 +240,6 @@ export interface IMember {
|
|
|
220
240
|
|
|
221
241
|
/**
|
|
222
242
|
* An extended member object that includes currentConnection
|
|
243
|
+
* @alpha
|
|
223
244
|
*/
|
|
224
245
|
export type Myself<M extends IMember = IMember> = M & { currentConnection: string };
|
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends":
|
|
2
|
+
"extends": [
|
|
3
|
+
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
+
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
+
],
|
|
6
|
+
"include": ["src/**/*"],
|
|
3
7
|
"exclude": ["src/test/**/*"],
|
|
4
8
|
"compilerOptions": {
|
|
5
9
|
"rootDir": "./src",
|
|
6
10
|
"outDir": "./dist",
|
|
7
|
-
"composite": true,
|
|
8
11
|
"types": ["node"],
|
|
9
12
|
},
|
|
10
|
-
"include": ["src/**/*"],
|
|
11
13
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport {\n\tAttachState,\n\tIContainer,\n\tICriticalContainerError,\n\tConnectionState,\n} from \"@fluidframework/container-definitions\";\nimport type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from \"./types\";\n\n/**\n * Events emitted from {@link IFluidContainer}.\n */\nexport interface IFluidContainerEvents extends IEvent {\n\t/**\n\t * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.connect}\n\t */\n\t(event: \"connected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.\n\t *\n\t * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.\n\t *\n\t * @see\n\t *\n\t * - {@link IFluidContainer.connectionState}\n\t *\n\t * - {@link IFluidContainer.disconnect}\n\t */\n\t(event: \"disconnected\", listener: () => void): void;\n\n\t/**\n\t * Emitted when all local changes/edits have been acknowledged by the service.\n\t *\n\t * @remarks \"dirty\" event will be emitted when the next local change has been made.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"saved\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the first local change has been made, following a \"saved\" event.\n\t *\n\t * @remarks \"saved\" event will be emitted once all local changes have been acknowledged by the service.\n\t *\n\t * @see {@link IFluidContainer.isDirty}\n\t */\n\t(event: \"dirty\", listener: () => void): void;\n\n\t/**\n\t * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.\n\t *\n\t * @remarks Listener parameters:\n\t *\n\t * - `error`: If the container was closed due to error (as opposed to an explicit call to\n\t * {@link IFluidContainer.dispose}), this will contain details about the error that caused it.\n\t */\n\t(event: \"disposed\", listener: (error?: ICriticalContainerError) => void);\n}\n\n/**\n * Provides an entrypoint into the client side of collaborative Fluid data.\n * Provides access to the data as well as status on the collaboration session.\n *\n * @remarks Note: external implementations of this interface are not supported.\n */\nexport interface IFluidContainer extends IEventProvider<IFluidContainerEvents> {\n\t/**\n\t * Provides the current connected state of the container\n\t */\n\treadonly connectionState: ConnectionState;\n\n\t/**\n\t * A container is considered **dirty** if it has local changes that have not yet been acknowledged by the service.\n\t *\n\t * @remarks\n\t *\n\t * You should always check the `isDirty` flag before closing the container or navigating away from the page.\n\t * Closing the container while `isDirty === true` may result in the loss of operations that have not yet been\n\t * acknowledged by the service.\n\t *\n\t * A container is considered dirty in the following cases:\n\t *\n\t * 1. The container has been created in the detached state, and either it has not been attached yet or it is\n\t * in the process of being attached (container is in `attaching` state). If container is closed prior to being\n\t * attached, host may never know if the file was created or not.\n\t *\n\t * 2. The container was attached, but it has local changes that have not yet been saved to service endpoint.\n\t * This occurs as part of normal op flow where pending operation (changes) are awaiting acknowledgement from the\n\t * service. In some cases this can be due to lack of network connection. If the network connection is down,\n\t * it needs to be restored for the pending changes to be acknowledged.\n\t */\n\treadonly isDirty: boolean;\n\n\t/**\n\t * Whether or not the container is disposed, which permanently disables it.\n\t */\n\treadonly disposed: boolean;\n\n\t/**\n\t * The collection of data objects and Distributed Data Stores (DDSes) that were specified by the schema.\n\t *\n\t * @remarks These data objects and DDSes exist for the lifetime of the container.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * The current attachment state of the container.\n\t *\n\t * @remarks\n\t *\n\t * Once a container has been attached, it remains attached.\n\t * When loading an existing container, it will already be attached.\n\t */\n\treadonly attachState: AttachState;\n\n\t/**\n\t * A newly created container starts detached from the collaborative service.\n\t * Calling `attach()` uploads the new container to the service and connects to the collaborative service.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#AttachState.Detatched} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.attachState}.\n\t *\n\t * @returns A promise which resolves when the attach is complete, with the string identifier of the container.\n\t */\n\tattach(): Promise<string>;\n\n\t/**\n\t * Attempts to connect the container to the delta stream and process operations.\n\t *\n\t * @throws Will throw an error if connection is unsuccessful.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#ConnectionState.Disconnected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tconnect(): void;\n\n\t/**\n\t * Disconnects the container from the delta stream and stops processing operations.\n\t *\n\t * @remarks\n\t *\n\t * This should only be called when the container is in the\n\t * {@link @fluidframework/container-definitions#ConnectionState.Connected} state.\n\t *\n\t * This can be determined by observing {@link IFluidContainer.connectionState}.\n\t */\n\tdisconnect(): void;\n\n\t/**\n\t * Create a new data object or Distributed Data Store (DDS) of the specified type.\n\t *\n\t * @remarks\n\t *\n\t * In order to share the data object or DDS with other\n\t * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n\t * initialObjects.\n\t *\n\t * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\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\t/**\n\t * Dispose of the container instance, permanently disabling it.\n\t */\n\tdispose(): void;\n}\n\n/**\n * Base {@link IFluidContainer} implementation.\n *\n * @remarks\n *\n * Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}\n * will need to utilize or provide a service-specific implementation of this type that implements that method.\n */\nexport class FluidContainer\n\textends TypedEventEmitter<IFluidContainerEvents>\n\timplements IFluidContainer\n{\n\tprivate readonly connectedHandler = () => this.emit(\"connected\");\n\tprivate readonly disconnectedHandler = () => this.emit(\"disconnected\");\n\tprivate readonly disposedHandler = (error?: ICriticalContainerError) =>\n\t\tthis.emit(\"disposed\", error);\n\tprivate readonly savedHandler = () => this.emit(\"saved\");\n\tprivate readonly dirtyHandler = () => this.emit(\"dirty\");\n\n\tpublic constructor(\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly rootDataObject: IRootDataObject,\n\t) {\n\t\tsuper();\n\t\tcontainer.on(\"connected\", this.connectedHandler);\n\t\tcontainer.on(\"closed\", this.disposedHandler);\n\t\tcontainer.on(\"disconnected\", this.disconnectedHandler);\n\t\tcontainer.on(\"saved\", this.savedHandler);\n\t\tcontainer.on(\"dirty\", this.dirtyHandler);\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.isDirty}\n\t */\n\tpublic get isDirty(): boolean {\n\t\treturn this.container.isDirty;\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.attachState}\n\t */\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.disposed}\n\t */\n\tpublic get disposed() {\n\t\treturn this.container.closed;\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.connectionState}\n\t */\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.container.connectionState;\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.initialObjects}\n\t */\n\tpublic get initialObjects() {\n\t\treturn this.rootDataObject.initialObjects;\n\t}\n\n\t/**\n\t * Incomplete base implementation of {@link IFluidContainer.attach}.\n\t *\n\t * @remarks\n\t *\n\t * Note: this implementation will unconditionally throw.\n\t * Consumers who rely on this will need to utilize or provide a service specific implementation of this base type\n\t * that provides an implementation of this method.\n\t *\n\t * The reason is because externally we are presenting a separation between the service and the `FluidContainer`,\n\t * but internally this separation is not there.\n\t */\n\tpublic async attach(): Promise<string> {\n\t\tif (this.container.attachState !== AttachState.Detached) {\n\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state.\");\n\t\t}\n\t\tthrow new Error(\"Cannot attach container. Attach method not provided.\");\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.connect}\n\t */\n\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.connect}\n\t */\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.create}\n\t */\n\tpublic async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.dispose}\n\t */\n\tpublic dispose() {\n\t\tthis.container.close();\n\t\tthis.container.off(\"connected\", this.connectedHandler);\n\t\tthis.container.off(\"closed\", this.disposedHandler);\n\t\tthis.container.off(\"disconnected\", this.disconnectedHandler);\n\t\tthis.container.off(\"saved\", this.savedHandler);\n\t\tthis.container.off(\"dirty\", this.dirtyHandler);\n\t}\n\n\t/**\n\t * FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.\n\t * We make no stability guarantees here whatsoever.\n\t *\n\t * Gets the underlying {@link @fluidframework/container-definitions#IContainer}.\n\t *\n\t * @remarks Used to power debug tooling.\n\t *\n\t * @internal\n\t */\n\tpublic readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {\n\t\treturn this.container;\n\t};\n}\n"]}
|
package/dist/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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.ServiceAudience = exports.DOProviderContainerRuntimeFactory = exports.FluidContainer = 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");
|
|
14
|
-
Object.defineProperty(exports, "FluidContainer", { enumerable: true, get: function () { return fluidContainer_1.FluidContainer; } });
|
|
15
|
-
var rootDataObject_1 = require("./rootDataObject");
|
|
16
|
-
Object.defineProperty(exports, "DOProviderContainerRuntimeFactory", { enumerable: true, get: function () { return rootDataObject_1.DOProviderContainerRuntimeFactory; } });
|
|
17
|
-
var serviceAudience_1 = require("./serviceAudience");
|
|
18
|
-
Object.defineProperty(exports, "ServiceAudience", { enumerable: true, get: function () { return serviceAudience_1.ServiceAudience; } });
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,mDAA0F;AAAjF,gHAAA,cAAc,OAAA;AACvB,mDAAqE;AAA5D,mIAAA,iCAAiC,OAAA;AAC1C,qDAAoD;AAA3C,kHAAA,eAAe,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 { FluidContainer, IFluidContainer, IFluidContainerEvents } from \"./fluidContainer\";\nexport { DOProviderContainerRuntimeFactory } from \"./rootDataObject\";\nexport { ServiceAudience } from \"./serviceAudience\";\nexport {\n\tContainerSchema,\n\tDataObjectClass,\n\tIConnection,\n\tIMember,\n\tIRootDataObject,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tLoadableObjectClass,\n\tLoadableObjectClassRecord,\n\tLoadableObjectCtor,\n\tLoadableObjectRecord,\n\tMemberChangedListener,\n\tSharedObjectClass,\n\tMyself,\n} from \"./types\";\n"]}
|