@fluidframework/fluid-static 2.50.0 → 2.51.0-347100
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/api-report/fluid-static.alpha.api.md +17 -0
- package/dist/fluidContainer.d.ts +1 -1
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/rootDataObject.d.ts +6 -3
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/rootDataObject.js +27 -44
- package/dist/rootDataObject.js.map +1 -1
- package/dist/treeRootDataObject.d.ts +47 -0
- package/dist/treeRootDataObject.d.ts.map +1 -0
- package/dist/treeRootDataObject.js +157 -0
- package/dist/treeRootDataObject.js.map +1 -0
- package/dist/types.d.ts +23 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +29 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +62 -3
- package/dist/utils.js.map +1 -1
- package/lib/fluidContainer.d.ts +1 -1
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rootDataObject.d.ts +6 -3
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.js +25 -42
- package/lib/rootDataObject.js.map +1 -1
- package/lib/treeRootDataObject.d.ts +47 -0
- package/lib/treeRootDataObject.d.ts.map +1 -0
- package/lib/treeRootDataObject.js +153 -0
- package/lib/treeRootDataObject.js.map +1 -0
- package/lib/types.d.ts +23 -8
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +29 -4
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +55 -0
- package/lib/utils.js.map +1 -1
- package/package.json +21 -20
- package/src/fluidContainer.ts +1 -1
- package/src/index.ts +3 -0
- package/src/rootDataObject.ts +46 -69
- package/src/treeRootDataObject.ts +249 -0
- package/src/types.ts +30 -9
- package/src/utils.ts +90 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeRootDataObject.js","sourceRoot":"","sources":["../src/treeRootDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAEH,gEAI2C;AAG3C,yEAIoD;AAUpD,kEAA6D;AAK7D,mFAAkF;AASlF,yCAQoB;AAEpB;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,kBAAmB,SAAQ,yBAAc;IAC9C,YAAmB,KAAuB;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;IAED,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,sHAAsH;IACtH,yEAAyE;IACzE,IAAW,cAAc;QACxB,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,MAAM,CAAI,WAAgC;QACtD,MAAM,QAAQ,GAAG,WAAgE,CAAC;QAClF,IAAI,IAAA,2BAAgB,EAAC,QAAQ,CAAC,EAAE,CAAC;YAChC,OAAO,IAAA,2BAAgB,EAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,CAAC;aAAM,IAAI,IAAA,6BAAkB,EAAC,QAAQ,CAAC,EAAE,CAAC;YACzC,OAAO,IAAA,6BAAkB,EAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC3F,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;C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C;IACxF,CAAC;CACD;;AAED;;GAEG;AACH,MAAM,yBAA0B,SAAQ,gCAAyC;IAChF,YACC,gBAA4C,EAAE,EAC7B,iBAA0C;QAG3D,MAAM,IAAI,GAAS,UAAU,MAAM;YAClC,iEAAiE;YACjE,OAAO,IAAI,kBAAkB,CAAC;gBAC7B,GAAG,MAAM;gBACT,8CAA8C;aAC9C,CAAC,CAAC;QACJ,CAAoB,CAAC;QAErB,uGAAuG;QACvG,+GAA+G;QAC/G,KAAK,CAAC;YACL,IAAI,EAAE,sBAAsB;YAC5B,IAAI;YACJ,aAAa;SACb,CAAC,CAAC;QAjBc,sBAAiB,GAAjB,iBAAiB,CAAyB;IAkB5D,CAAC;IAED,IAAW,uBAAuB;QACjC,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAC/B,CAAC;CACD;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iCAAiC,CAAC,KA2BjD;IACA,MAAM,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,GACN,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,GAAG,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,qBAAqB,IAAI,IAAI,iCAAsB,CAAC,eAAe,CAAC,CAAC;IAEtF,OAAO,IAAI,2BAA2B,CACrC,iBAAiB,EACjB,IAAI,yBAAyB,CAAC,aAAa,EAAE,QAAQ,CAAC,EACtD;QACC,cAAc,EAAE,sBAAsB;QACtC,mBAAmB,EAAE,2BAA2B;KAChD,CACD,CAAC;AACH,CAAC;AA/CD,8EA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tBaseContainerRuntimeFactory,\n\tTreeDataObject,\n\tTreeDataObjectFactory,\n} from \"@fluidframework/aqueduct/internal\";\nimport type { IDataObjectProps } from \"@fluidframework/aqueduct/internal\";\nimport type { IRuntimeFactory } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tFluidDataStoreRegistry,\n\ttype IContainerRuntimeOptions,\n\ttype MinimumVersionForCollab,\n} from \"@fluidframework/container-runtime/internal\";\nimport type {\n\tIContainerRuntime,\n\tIContainerRuntimeInternal,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IChannelFactory } from \"@fluidframework/datastore-definitions/internal\";\nimport type { IFluidDataStoreRegistry } from \"@fluidframework/runtime-definitions/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport { compatibilityModeRuntimeOptions } from \"./compatibilityConfiguration.js\";\nimport type {\n\tCompatibilityMode,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n\tLoadableObjectKind,\n\tLoadableObjectRecord,\n\tTreeContainerSchema,\n} from \"./types.js\";\nimport {\n\tcompatibilityModeToMinVersionForCollab,\n\tcreateDataObject,\n\tcreateSharedObject,\n\tisDataObjectKind,\n\tisSharedObjectKind,\n\tmakeFluidObject,\n\tparseDataObjectsFromSharedObjects,\n} from \"./utils.js\";\n\n/**\n * This module contains types and factories for creating tree-based root data objects.\n * They exist as an alternative to the APIs in `rootDataObject.ts`.\n *\n * These APIs are currently shaped to parallel `RootDataObject`, but this is not intended as the long-term design.\n * The current shape is a short-term solution to allow for easier migration from the old APIs.\n */\n\n/**\n * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.\n *\n * @remarks\n * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.\n */\nclass TreeRootDataObject extends TreeDataObject implements IRootDataObject {\n\tpublic constructor(props: IDataObjectProps) {\n\t\tsuper(props);\n\t}\n\n\tpublic get TreeRootDataObject(): TreeRootDataObject {\n\t\treturn this;\n\t}\n\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\tpublic get initialObjects(): LoadableObjectRecord {\n\t\treturn {\n\t\t\ttree: this.tree,\n\t\t};\n\t}\n\n\tpublic async create<T>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\tconst internal = objectClass as unknown as LoadableObjectKind<T & IFluidLoadable>;\n\t\tif (isDataObjectKind(internal)) {\n\t\t\treturn createDataObject(internal, this.context);\n\t\t} else if (isSharedObjectKind(internal)) {\n\t\t\treturn createSharedObject(internal, this.runtime);\n\t\t}\n\t\tthrow new Error(\"Could not create new Fluid object because an unknown object was passed\");\n\t}\n\n\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.runtime.uploadBlob(blob);\n\t}\n}\n\nconst treeRootDataStoreId = \"treeRootDOId\";\n\n/**\n * Type of the {@link TreeRootDataObject}.\n * @remarks Used in the PureDataObjectFactory to create the root data object.\n */\nconst treeRootDataObjectType = \"treeRootDO\";\n\nasync function provideEntryPoint(\n\tcontainerRuntime: IContainerRuntime,\n): Promise<IStaticEntryPoint> {\n\tconst entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(treeRootDataStoreId);\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(`default dataStore [${treeRootDataStoreId}] must exist`);\n\t}\n\tconst treeRootDataObject = ((await entryPoint.get()) as FluidObject<TreeRootDataObject>)\n\t\t.TreeRootDataObject;\n\tassert(treeRootDataObject !== undefined, \"entryPoint must be of type TreeRootDataObject\");\n\treturn makeFluidObject<IStaticEntryPoint>(\n\t\t{\n\t\t\trootDataObject: treeRootDataObject,\n\t\t\textensionStore: containerRuntime as IContainerRuntimeInternal,\n\t\t},\n\t\t\"IStaticEntryPoint\",\n\t);\n}\n\n/**\n * Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}\n * (containing single {@link IRootDataObject}) as their entry point.\n */\nclass TreeContainerRuntimeFactory extends BaseContainerRuntimeFactory {\n\t// TODO: use for runtime factory.\n\treadonly #treeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>;\n\n\tpublic constructor(\n\t\tcompatibilityMode: CompatibilityMode,\n\t\ttreeRootDataObjectFactory: TreeDataObjectFactory<TreeRootDataObject>,\n\t\toverrides?: Partial<{\n\t\t\truntimeOptions: Partial<IContainerRuntimeOptions>;\n\t\t\tminVersionForCollab: MinimumVersionForCollab;\n\t\t}>,\n\t) {\n\t\tsuper({\n\t\t\tregistryEntries: [treeRootDataObjectFactory.registryEntry],\n\t\t\truntimeOptions: {\n\t\t\t\t...compatibilityModeRuntimeOptions[compatibilityMode],\n\t\t\t\t...overrides?.runtimeOptions,\n\t\t\t},\n\t\t\tprovideEntryPoint,\n\t\t\tminVersionForCollab:\n\t\t\t\toverrides?.minVersionForCollab ??\n\t\t\t\tcompatibilityModeToMinVersionForCollab[compatibilityMode],\n\t\t});\n\t\tthis.#treeRootDataObjectFactory = treeRootDataObjectFactory;\n\t}\n\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.#treeRootDataObjectFactory.createRootInstance(treeRootDataStoreId, runtime);\n\t}\n}\n\n/**\n * Factory that creates instances of a tree-based root data object.\n */\nclass TreeRootDataObjectFactory extends TreeDataObjectFactory<TreeRootDataObject> {\n\tpublic constructor(\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\tprivate readonly dataStoreRegistry: IFluidDataStoreRegistry,\n\t) {\n\t\ttype Ctor = new (props: IDataObjectProps) => TreeRootDataObject;\n\t\tconst ctor: Ctor = function (_props) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\treturn new TreeRootDataObject({\n\t\t\t\t..._props,\n\t\t\t\t// Add any additional injected properties here\n\t\t\t});\n\t\t} as unknown as Ctor;\n\n\t\t// Note: we're not specifying registry entries to the base class, so it won't create a registry itself,\n\t\t// and instead we override the necessary methods in this class to use the registry received in the constructor.\n\t\tsuper({\n\t\t\ttype: treeRootDataObjectType,\n\t\t\tctor,\n\t\t\tsharedObjects,\n\t\t});\n\t}\n\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n\t\treturn this.dataStoreRegistry;\n\t}\n}\n\n/**\n * Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers\n * with an entry point containing single tree-based root data object.\n *\n * @remarks\n * The entry point is opaque to caller.\n * The root data object's registry and shared objects are configured based on the provided\n * SharedTree and optionally data store registry.\n *\n * @legacy @alpha\n */\nexport function createTreeContainerRuntimeFactory(props: {\n\t/**\n\t * The schema for the container.\n\t */\n\treadonly schema: TreeContainerSchema;\n\n\t/**\n\t * See {@link CompatibilityMode} and compatibilityModeRuntimeOptions for more details.\n\t */\n\treadonly compatibilityMode: CompatibilityMode;\n\t/**\n\t * Optional registry of data stores to pass to the DataObject factory.\n\t * If not provided, one will be created based on the schema.\n\t */\n\treadonly rootDataStoreRegistry?: IFluidDataStoreRegistry;\n\t/**\n\t * Optional overrides for the container runtime options.\n\t * If not provided, only the default options for the given compatibilityMode will be used.\n\t */\n\treadonly runtimeOptionOverrides?: Partial<IContainerRuntimeOptions>;\n\t/**\n\t * Optional override for minimum version for collab.\n\t * If not provided, the default for the given compatibilityMode will be used.\n\t * @remarks\n\t * This is useful when runtime options are overridden and change the minimum version for collab.\n\t */\n\treadonly minVersionForCollabOverride?: MinimumVersionForCollab;\n}): IRuntimeFactory {\n\tconst {\n\t\tcompatibilityMode,\n\t\tminVersionForCollabOverride,\n\t\trootDataStoreRegistry,\n\t\truntimeOptionOverrides,\n\t\tschema,\n\t} = props;\n\n\tconst [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);\n\tconst registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);\n\n\treturn new TreeContainerRuntimeFactory(\n\t\tcompatibilityMode,\n\t\tnew TreeRootDataObjectFactory(sharedObjects, registry),\n\t\t{\n\t\t\truntimeOptions: runtimeOptionOverrides,\n\t\t\tminVersionForCollab: minVersionForCollabOverride,\n\t\t},\n\t);\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
|
|
6
6
|
import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
|
|
7
7
|
import type { IEvent, IEventProvider, IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
|
-
import type {
|
|
8
|
+
import type { ISharedObjectKind, SharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
9
|
+
import type { ITree } from "@fluidframework/tree";
|
|
10
10
|
/**
|
|
11
11
|
* Determines the set of runtime options that Fluid Framework will use when running.
|
|
12
12
|
* In "1" mode we support full interop between 2.x clients and 1.x clients,
|
|
@@ -84,14 +84,25 @@ export interface ContainerSchema {
|
|
|
84
84
|
readonly dynamicObjectTypes?: readonly SharedObjectKind[];
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
87
|
+
* Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
*
|
|
91
|
+
* It includes both the kind of `SharedTree` that will be initially available upon `Container` creation, as well
|
|
92
|
+
* as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
|
|
93
|
+
*
|
|
94
|
+
* @legacy @alpha
|
|
95
|
+
*/
|
|
96
|
+
export interface TreeContainerSchema extends ContainerSchema {
|
|
97
|
+
readonly initialObjects: {
|
|
98
|
+
readonly tree: SharedObjectKind<ITree>;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Holds the collection of objects that the container was initially created with.
|
|
103
|
+
* Additionally provides the ability to dynamically create further objects during usage.
|
|
89
104
|
*/
|
|
90
105
|
export interface IRootDataObject {
|
|
91
|
-
/**
|
|
92
|
-
* Provides a record of the initial objects defined on creation.
|
|
93
|
-
*/
|
|
94
|
-
readonly initialObjects: LoadableObjectRecord;
|
|
95
106
|
/**
|
|
96
107
|
* Dynamically creates a new detached collaborative object (DDS/DataObject).
|
|
97
108
|
*
|
|
@@ -109,6 +120,10 @@ export interface IRootDataObject {
|
|
|
109
120
|
* @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).
|
|
110
121
|
*/
|
|
111
122
|
uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
|
|
123
|
+
/**
|
|
124
|
+
* Provides a record of the initial objects defined on creation.
|
|
125
|
+
*/
|
|
126
|
+
readonly initialObjects: LoadableObjectRecord;
|
|
112
127
|
}
|
|
113
128
|
interface IProvideStaticEntryPoint {
|
|
114
129
|
readonly IStaticEntryPoint: IStaticEntryPoint;
|
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,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EACX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd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ACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +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 type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport type {
|
|
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 type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKind,\n} from \"@fluidframework/shared-object-base/internal\";\nimport type { ITree } from \"@fluidframework/tree\";\n\n/**\n * Determines the set of runtime options that Fluid Framework will use when running.\n * In \"1\" mode we support full interop between 2.x clients and 1.x clients,\n * while in \"2\" mode we only support interop between 2.x clients.\n *\n * @public\n */\nexport type CompatibilityMode = \"1\" | \"2\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\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 */\nexport type LoadableObjectKindRecord = Record<string, SharedObjectKind>;\n\n/**\n * A kind of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The kind of `DataObject` or `SharedObject`.\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectKind<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectKind<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\treadonly initialObjects: Record<string, SharedObjectKind>;\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\treadonly dynamicObjectTypes?: readonly SharedObjectKind[];\n}\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 kind of `SharedTree` that will be 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 *\n * @legacy @alpha\n */\nexport interface TreeContainerSchema extends ContainerSchema {\n\t// TODO: longer term, it would be better to not have to fit into the `initialObjects` model for tree-based containers.\n\t// But in the short term, fitting into this model makes migration easier.\n\treadonly initialObjects: {\n\t\treadonly tree: SharedObjectKind<ITree>;\n\t};\n}\n\n/**\n * Holds the collection of objects that the container was initially created with.\n * Additionally provides the ability to dynamically create further objects during usage.\n */\nexport interface IRootDataObject {\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>(objectClass: SharedObjectKind<T>): Promise<T>;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n}\n\ninterface IProvideStaticEntryPoint {\n\treadonly IStaticEntryPoint: IStaticEntryPoint;\n}\n\n/**\n * This is the internal entry point fluid-static creates.\n */\nexport interface IStaticEntryPoint extends IProvideStaticEntryPoint {\n\treadonly rootDataObject: IRootDataObject;\n\treadonly extensionStore: ContainerExtensionStore;\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(): ReadonlyMap<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\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"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\treadonly id: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
|
package/dist/utils.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import type { DataObjectKind } from "@fluidframework/aqueduct/internal";
|
|
6
|
-
import type { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
|
-
import type { IChannelFactory } from "@fluidframework/datastore-definitions/internal";
|
|
8
|
-
import type { NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
|
|
6
|
+
import type { FluidObjectKeys, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
|
+
import type { IChannelFactory, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
8
|
+
import type { IFluidDataStoreContext, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
|
|
9
9
|
import type { ISharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
10
|
-
import type { ContainerSchema, LoadableObjectKind } from "./types.js";
|
|
10
|
+
import type { ContainerSchema, LoadableObjectKind, TreeContainerSchema } from "./types.js";
|
|
11
11
|
/**
|
|
12
12
|
* Runtime check to determine if an object is a {@link DataObjectKind}.
|
|
13
13
|
*/
|
|
@@ -26,4 +26,29 @@ export declare function isSharedObjectKind(obj: LoadableObjectKind): obj is ISha
|
|
|
26
26
|
* of DataObject types and an array of SharedObjects.
|
|
27
27
|
*/
|
|
28
28
|
export declare const parseDataObjectsFromSharedObjects: (schema: ContainerSchema) => [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]];
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new data object of the specified type.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectKind<T>, context: IFluidDataStoreContext): Promise<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a new shared object of the specified type.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSharedObject<T extends IFluidLoadable>(sharedObjectClass: ISharedObjectKind<T>, runtime: IFluidDataStoreRuntime): T;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a Fluid object that has a property with the key `providerKey` that points to itself.
|
|
39
|
+
* @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeFluidObject<T extends object, K extends FluidObjectKeys<T> = FluidObjectKeys<T>>(object: Omit<T, K>, providerKey: K): T;
|
|
42
|
+
/**
|
|
43
|
+
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
44
|
+
*/
|
|
45
|
+
export declare const compatibilityModeToMinVersionForCollab: {
|
|
46
|
+
readonly "1": "1.0.0";
|
|
47
|
+
readonly "2": "2.0.0";
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Determines if the provided schema is a valid tree-based container schema.
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export declare function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema;
|
|
29
54
|
//# sourceMappingURL=utils.d.ts.map
|
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,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEvF,OAAO,KAAK,EACX,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,sBAAsB,EACtB,gCAAgC,EAChC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAIrF,OAAO,KAAK,EAEX,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,cAAc,EACxD,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,GACxB,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;AAE5B;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,kBAAkB,GACrB,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;AAyBzC;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,kBAAkB,GACrB,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAE1C;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC;AAEF;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,cAAc,EAC9D,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB,GAC7B,OAAO,CAAC,CAAC,CAAC,CAMZ;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,cAAc,EAC1D,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACvC,OAAO,EAAE,sBAAsB,GAC7B,CAAC,CAIH;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC9B,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EAChD,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,CAAC,CAEvC;AAED;;GAEG;AACH,eAAO,MAAM,sCAAsC;;;CAGoB,CAAC;AAExE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,IAAI,mBAAmB,CAqB5F"}
|
package/dist/utils.js
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.parseDataObjectsFromSharedObjects = exports.isSharedObjectKind = exports.isDataObjectKind = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/
|
|
7
|
+
exports.isTreeContainerSchema = exports.compatibilityModeToMinVersionForCollab = exports.makeFluidObject = exports.createSharedObject = exports.createDataObject = exports.parseDataObjectsFromSharedObjects = exports.isSharedObjectKind = exports.isDataObjectKind = void 0;
|
|
8
|
+
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
9
|
+
const internal_2 = require("@fluidframework/telemetry-utils/internal");
|
|
10
|
+
const internal_3 = require("@fluidframework/tree/internal");
|
|
9
11
|
/**
|
|
10
12
|
* Runtime check to determine if an object is a {@link DataObjectKind}.
|
|
11
13
|
*/
|
|
@@ -17,7 +19,7 @@ function isDataObjectKind(obj) {
|
|
|
17
19
|
(obj.getFactory !== undefined)) {
|
|
18
20
|
// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called "getFactory" so there is a risk of this being a false positive.
|
|
19
21
|
// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.
|
|
20
|
-
throw new
|
|
22
|
+
throw new internal_2.UsageError("Invalid LoadableObjectClass");
|
|
21
23
|
}
|
|
22
24
|
return isDataObject;
|
|
23
25
|
}
|
|
@@ -62,4 +64,61 @@ const parseDataObjectsFromSharedObjects = (schema) => {
|
|
|
62
64
|
return [[...registryEntries], [...sharedObjects]];
|
|
63
65
|
};
|
|
64
66
|
exports.parseDataObjectsFromSharedObjects = parseDataObjectsFromSharedObjects;
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new data object of the specified type.
|
|
69
|
+
*/
|
|
70
|
+
async function createDataObject(dataObjectClass, context) {
|
|
71
|
+
const factory = dataObjectClass.factory;
|
|
72
|
+
const packagePath = [...context.packagePath, factory.type];
|
|
73
|
+
const dataStore = await context.containerRuntime.createDataStore(packagePath);
|
|
74
|
+
const entryPoint = await dataStore.entryPoint.get();
|
|
75
|
+
return entryPoint;
|
|
76
|
+
}
|
|
77
|
+
exports.createDataObject = createDataObject;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new shared object of the specified type.
|
|
80
|
+
*/
|
|
81
|
+
function createSharedObject(sharedObjectClass, runtime) {
|
|
82
|
+
const factory = sharedObjectClass.getFactory();
|
|
83
|
+
const obj = runtime.createChannel(undefined, factory.type);
|
|
84
|
+
return obj;
|
|
85
|
+
}
|
|
86
|
+
exports.createSharedObject = createSharedObject;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a Fluid object that has a property with the key `providerKey` that points to itself.
|
|
89
|
+
* @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.
|
|
90
|
+
*/
|
|
91
|
+
function makeFluidObject(object, providerKey) {
|
|
92
|
+
return Object.defineProperty(object, providerKey, { value: object });
|
|
93
|
+
}
|
|
94
|
+
exports.makeFluidObject = makeFluidObject;
|
|
95
|
+
/**
|
|
96
|
+
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
97
|
+
*/
|
|
98
|
+
exports.compatibilityModeToMinVersionForCollab = {
|
|
99
|
+
"1": "1.0.0",
|
|
100
|
+
"2": "2.0.0",
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Determines if the provided schema is a valid tree-based container schema.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
function isTreeContainerSchema(schema) {
|
|
107
|
+
const schemaEntries = Object.entries(schema.initialObjects);
|
|
108
|
+
if (schemaEntries.length !== 1) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const entry = schemaEntries[0] ?? (0, internal_1.oob)();
|
|
112
|
+
const key = entry[0];
|
|
113
|
+
if (key !== "tree") {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
const objectKind = entry[1];
|
|
117
|
+
if (isSharedObjectKind(objectKind) &&
|
|
118
|
+
objectKind.getFactory().type === internal_3.SharedTreeFactoryType) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
exports.isTreeContainerSchema = isTreeContainerSchema;
|
|
65
124
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,kEAA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AAC;AAC5B,CAAC;AAPD,gDAOC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAG7B,MAAkB,EAAE,WAAc;IACnC,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAM,CAAC;AAC3E,CAAC;AALD,0CAKC;AAED;;GAEG;AACU,QAAA,sCAAsC,GAAG;IACrD,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,OAAO;CAC0D,CAAC;AAExE;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,IAAA,cAAG,GAAE,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAkC,CAAC;IAC7D,IACC,kBAAkB,CAAC,UAAU,CAAC;QAC9B,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,KAAK,gCAAqB,EACrD,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AArBD,sDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { DataObjectKind } from \"@fluidframework/aqueduct/internal\";\nimport type { MinimumVersionForCollab } from \"@fluidframework/container-runtime/internal\";\nimport type { FluidObjectKeys, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { oob } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { SharedTreeFactoryType } from \"@fluidframework/tree/internal\";\n\nimport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tLoadableObjectKind,\n\tTreeContainerSchema,\n} from \"./types.js\";\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind<T extends IFluidLoadable>(\n\tobj: LoadableObjectKind<T>,\n): obj is DataObjectKind<T>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable>;\n\n/**\n * Runtime check to determine if an object is a {@link DataObjectKind}.\n */\nexport function isDataObjectKind(\n\tobj: LoadableObjectKind,\n): obj is DataObjectKind<IFluidLoadable> {\n\tconst maybe = obj as Partial<DataObjectKind<IFluidLoadable>> | undefined;\n\tconst isDataObject =\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe.factory.IFluidDataStoreFactory === maybe.factory;\n\n\tif (\n\t\tisDataObject ===\n\t\t((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)\n\t) {\n\t\t// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called \"getFactory\" so there is a risk of this being a false positive.\n\t\t// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.\n\t\tthrow new UsageError(\"Invalid LoadableObjectClass\");\n\t}\n\n\treturn isDataObject;\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport function isSharedObjectKind(\n\tobj: LoadableObjectKind,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectKind(obj);\n}\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\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: LoadableObjectKind): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectKind(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 as unknown as LoadableObjectKind);\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\n/**\n * Creates a new data object of the specified type.\n */\nexport async function createDataObject<T extends IFluidLoadable>(\n\tdataObjectClass: DataObjectKind<T>,\n\tcontext: IFluidDataStoreContext,\n): Promise<T> {\n\tconst factory = dataObjectClass.factory;\n\tconst packagePath = [...context.packagePath, factory.type];\n\tconst dataStore = await context.containerRuntime.createDataStore(packagePath);\n\tconst entryPoint = await dataStore.entryPoint.get();\n\treturn entryPoint as T;\n}\n\n/**\n * Creates a new shared object of the specified type.\n */\nexport function createSharedObject<T extends IFluidLoadable>(\n\tsharedObjectClass: ISharedObjectKind<T>,\n\truntime: IFluidDataStoreRuntime,\n): T {\n\tconst factory = sharedObjectClass.getFactory();\n\tconst obj = runtime.createChannel(undefined, factory.type);\n\treturn obj as unknown as T;\n}\n\n/**\n * Creates a Fluid object that has a property with the key `providerKey` that points to itself.\n * @remarks This is useful for creating objects that need to reference themselves, such as DataObjects.\n */\nexport function makeFluidObject<\n\tT extends object,\n\tK extends FluidObjectKeys<T> = FluidObjectKeys<T>,\n>(object: Omit<T, K>, providerKey: K): T {\n\treturn Object.defineProperty(object, providerKey, { value: object }) as T;\n}\n\n/**\n * Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.\n */\nexport const compatibilityModeToMinVersionForCollab = {\n\t\"1\": \"1.0.0\",\n\t\"2\": \"2.0.0\",\n} as const satisfies Record<CompatibilityMode, MinimumVersionForCollab>;\n\n/**\n * Determines if the provided schema is a valid tree-based container schema.\n * @internal\n */\nexport function isTreeContainerSchema(schema: ContainerSchema): schema is TreeContainerSchema {\n\tconst schemaEntries = Object.entries(schema.initialObjects);\n\tif (schemaEntries.length !== 1) {\n\t\treturn false;\n\t}\n\n\tconst entry = schemaEntries[0] ?? oob();\n\tconst key = entry[0];\n\tif (key !== \"tree\") {\n\t\treturn false;\n\t}\n\n\tconst objectKind = entry[1] as unknown as LoadableObjectKind;\n\tif (\n\t\tisSharedObjectKind(objectKind) &&\n\t\tobjectKind.getFactory().type === SharedTreeFactoryType\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n"]}
|
package/lib/fluidContainer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { AttachState, type ConnectionState, type ICriticalContainerError } from
|
|
|
6
6
|
import type { IContainer } from "@fluidframework/container-definitions/internal";
|
|
7
7
|
import type { ContainerExtensionStore } from "@fluidframework/container-runtime-definitions/internal";
|
|
8
8
|
import type { IEvent, IEventProvider, IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
9
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
9
|
+
import type { SharedObjectKind } from "@fluidframework/shared-object-base/internal";
|
|
10
10
|
import type { ContainerAttachProps, ContainerSchema } from "./types.js";
|
|
11
11
|
/**
|
|
12
12
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAEX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fluidContainer.d.ts","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACtG,OAAO,KAAK,EAEX,MAAM,EACN,cAAc,EACd,YAAY,EACZ,cAAc,EACd,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EAGf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,IAAI;KAMtD,CAAC,IAAI,MAAM,CAAC,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C7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,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 {\n\tAttachState,\n\ttype ConnectionState,\n\ttype ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n} from \"./types.js\";\n\n/**\n * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.\n * @public\n */\nexport type InitialObjects<T extends ContainerSchema> = {\n\t// Construct a LoadableObjectRecord type by enumerating the keys of\n\t// 'ContainerSchema.initialObjects' and inferring the value type of each key.\n\t//\n\t// The '? TChannel : never' is required because infer can only be used in\n\t// a conditional 'extends' expression.\n\t[K in keyof T[\"initialObjects\"]]: T[\"initialObjects\"][K] extends SharedObjectKind<\n\t\tinfer TChannel\n\t>\n\t\t? TChannel\n\t\t: never;\n};\n\n/**\n * Events emitted from {@link IFluidContainer}.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * @sealed\n * @public\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 * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\n *\n * @remarks Note: external implementations of this interface are not supported.\n *\n * @sealed\n * @public\n */\nexport interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends 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: InitialObjects<TContainerSchema>;\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.Detached} 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(props?: ContainerAttachProps): 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:namespace).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:namespace).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 * @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\t * @remarks\n\t *\n\t * In order to share the data object or DDS with other collaborators and retrieve it later,\n\t * store its handle in a collection like a SharedDirectory from your initialObjects.\n\t * It's typically a good idea to set any initial state on the object before doing so,\n\t * as it is both more efficient and helpful to maintain domain model invariants\n\t * (e.g. this approach easily allows state to only be set once).\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * const existingDirectory = container.initialObjects.myDirectory;\n\t * const map = await container.create(SharedMap);\n\t * map.set(\"initialState\", \"someValue\");\n\t * existingDirectory.set(\"myMap\", map.handle);\n\t * ```\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: SharedObjectKind<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 * Internal interface for {@link IFluidContainer}.\n *\n * @internal\n */\nexport interface IFluidContainerInternal extends ContainerExtensionStore {\n\t/**\n\t * The underlying {@link @fluidframework/container-definitions#IContainer}.\n\t *\n\t * @remarks Used to power debug tooling and experimental features.\n\t */\n\treadonly container: IContainer;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n}\n\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport async function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n}): Promise<IFluidContainer<TContainerSchema>> {\n\tconst entryPoint: FluidObject<IStaticEntryPoint> = await props.container.getEntryPoint();\n\tassert(\n\t\tentryPoint.IStaticEntryPoint !== undefined,\n\t\t0xb9e /* entryPoint must be of type IStaticEntryPoint */,\n\t);\n\treturn new FluidContainer<TContainerSchema>(\n\t\tprops.container,\n\t\tentryPoint.IStaticEntryPoint.rootDataObject,\n\t\tentryPoint.IStaticEntryPoint.extensionStore,\n\t);\n}\n\n/**\n * Check that the provided `container` is an internal {@link IFluidContainerInternal}.\n *\n * @internal\n */\nexport function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(\n\tcontainer: IFluidContainer<TContainerSchema> | IFluidContainerInternal,\n): container is IFluidContainerInternal {\n\t// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be\n\t// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,\n\t// we use `instanceof` to confirm.\n\treturn container instanceof FluidContainer;\n}\n\n/**\n * {@link IFluidContainer} implementation.\n *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\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 */\nclass FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends TypedEventEmitter<IFluidContainerEvents>\n\timplements IFluidContainer<TContainerSchema>, IFluidContainerInternal\n{\n\tprivate readonly connectedHandler = (): boolean => this.emit(\"connected\");\n\tprivate readonly disconnectedHandler = (): boolean => this.emit(\"disconnected\");\n\tprivate readonly disposedHandler = (error?: ICriticalContainerError): boolean =>\n\t\tthis.emit(\"disposed\", error);\n\tprivate readonly savedHandler = (): boolean => this.emit(\"saved\");\n\tprivate readonly dirtyHandler = (): boolean => this.emit(\"dirty\");\n\tpublic readonly acquireExtension: ContainerExtensionStore[\"acquireExtension\"];\n\n\tpublic constructor(\n\t\tpublic readonly container: IContainer,\n\t\tprivate readonly rootDataObject: IRootDataObject,\n\t\textensionStore: ContainerExtensionStore,\n\t) {\n\t\tsuper();\n\t\tthis.acquireExtension = extensionStore.acquireExtension.bind(extensionStore);\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\tpublic get isDirty(): boolean {\n\t\treturn this.container.isDirty;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this.container.closed;\n\t}\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.container.connectionState;\n\t}\n\n\tpublic get initialObjects(): InitialObjects<TContainerSchema> {\n\t\treturn this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;\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(props?: ContainerAttachProps): 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\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\tpublic async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\tpublic dispose(): void {\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\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.rootDataObject.uploadBlob(blob);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,WAAW,GAGX,MAAM,uCAAuC,CAAC;AAU/C,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;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,MAAM,CAA2B,WAAgC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,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 {\n\tAttachState,\n\ttype ConnectionState,\n\ttype ICriticalContainerError,\n} from \"@fluidframework/container-definitions\";\nimport type { IContainer } from \"@fluidframework/container-definitions/internal\";\nimport type { ContainerExtensionStore } from \"@fluidframework/container-runtime-definitions/internal\";\nimport type {\n\tFluidObject,\n\tIEvent,\n\tIEventProvider,\n\tIFluidHandle,\n\tIFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIRootDataObject,\n\tIStaticEntryPoint,\n} from \"./types.js\";\n\n/**\n * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.\n * @public\n */\nexport type InitialObjects<T extends ContainerSchema> = {\n\t// Construct a LoadableObjectRecord type by enumerating the keys of\n\t// 'ContainerSchema.initialObjects' and inferring the value type of each key.\n\t//\n\t// The '? TChannel : never' is required because infer can only be used in\n\t// a conditional 'extends' expression.\n\t[K in keyof T[\"initialObjects\"]]: T[\"initialObjects\"][K] extends SharedObjectKind<\n\t\tinfer TChannel\n\t>\n\t\t? TChannel\n\t\t: never;\n};\n\n/**\n * Events emitted from {@link IFluidContainer}.\n *\n * @remarks Note: external implementations of this interface are not supported.\n * @sealed\n * @public\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 * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\n *\n * @remarks Note: external implementations of this interface are not supported.\n *\n * @sealed\n * @public\n */\nexport interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends 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: InitialObjects<TContainerSchema>;\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.Detached} 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(props?: ContainerAttachProps): 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:namespace).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:namespace).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 * @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\t * @remarks\n\t *\n\t * In order to share the data object or DDS with other collaborators and retrieve it later,\n\t * store its handle in a collection like a SharedDirectory from your initialObjects.\n\t * It's typically a good idea to set any initial state on the object before doing so,\n\t * as it is both more efficient and helpful to maintain domain model invariants\n\t * (e.g. this approach easily allows state to only be set once).\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * const existingDirectory = container.initialObjects.myDirectory;\n\t * const map = await container.create(SharedMap);\n\t * map.set(\"initialState\", \"someValue\");\n\t * existingDirectory.set(\"myMap\", map.handle);\n\t * ```\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: SharedObjectKind<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 * Internal interface for {@link IFluidContainer}.\n *\n * @internal\n */\nexport interface IFluidContainerInternal extends ContainerExtensionStore {\n\t/**\n\t * The underlying {@link @fluidframework/container-definitions#IContainer}.\n\t *\n\t * @remarks Used to power debug tooling and experimental features.\n\t */\n\treadonly container: IContainer;\n\n\t/**\n\t * Upload a blob of data.\n\t * Although it is marked as internal, there is external usage of this function for experimental purposes.\n\t * Please contact yunho-microsoft or vladsud if you need to change it.\n\t * @param blob - blob to be uploaded.\n\t *\n\t * @remarks This method is used to expose uploadBlob to the IFluidContainer level. UploadBlob will upload data to server side (as of now, ODSP only). There is no downloadBlob provided as it is not needed(blob lifetime managed by server).\n\t */\n\tuploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;\n}\n\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport async function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n}): Promise<IFluidContainer<TContainerSchema>> {\n\tconst entryPoint: FluidObject<IStaticEntryPoint> = await props.container.getEntryPoint();\n\tassert(\n\t\tentryPoint.IStaticEntryPoint !== undefined,\n\t\t0xb9e /* entryPoint must be of type IStaticEntryPoint */,\n\t);\n\treturn new FluidContainer<TContainerSchema>(\n\t\tprops.container,\n\t\tentryPoint.IStaticEntryPoint.rootDataObject,\n\t\tentryPoint.IStaticEntryPoint.extensionStore,\n\t);\n}\n\n/**\n * Check that the provided `container` is an internal {@link IFluidContainerInternal}.\n *\n * @internal\n */\nexport function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(\n\tcontainer: IFluidContainer<TContainerSchema> | IFluidContainerInternal,\n): container is IFluidContainerInternal {\n\t// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be\n\t// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,\n\t// we use `instanceof` to confirm.\n\treturn container instanceof FluidContainer;\n}\n\n/**\n * {@link IFluidContainer} implementation.\n *\n * @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.\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 */\nclass FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>\n\textends TypedEventEmitter<IFluidContainerEvents>\n\timplements IFluidContainer<TContainerSchema>, IFluidContainerInternal\n{\n\tprivate readonly connectedHandler = (): boolean => this.emit(\"connected\");\n\tprivate readonly disconnectedHandler = (): boolean => this.emit(\"disconnected\");\n\tprivate readonly disposedHandler = (error?: ICriticalContainerError): boolean =>\n\t\tthis.emit(\"disposed\", error);\n\tprivate readonly savedHandler = (): boolean => this.emit(\"saved\");\n\tprivate readonly dirtyHandler = (): boolean => this.emit(\"dirty\");\n\tpublic readonly acquireExtension: ContainerExtensionStore[\"acquireExtension\"];\n\n\tpublic constructor(\n\t\tpublic readonly container: IContainer,\n\t\tprivate readonly rootDataObject: IRootDataObject,\n\t\textensionStore: ContainerExtensionStore,\n\t) {\n\t\tsuper();\n\t\tthis.acquireExtension = extensionStore.acquireExtension.bind(extensionStore);\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\tpublic get isDirty(): boolean {\n\t\treturn this.container.isDirty;\n\t}\n\n\tpublic get attachState(): AttachState {\n\t\treturn this.container.attachState;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this.container.closed;\n\t}\n\n\tpublic get connectionState(): ConnectionState {\n\t\treturn this.container.connectionState;\n\t}\n\n\tpublic get initialObjects(): InitialObjects<TContainerSchema> {\n\t\treturn this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;\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(props?: ContainerAttachProps): 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\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\tpublic async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\tpublic dispose(): void {\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\tpublic async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n\t\treturn this.rootDataObject.uploadBlob(blob);\n\t}\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -10,5 +10,7 @@
|
|
|
10
10
|
export { createFluidContainer, isInternalFluidContainer, type IFluidContainer, type IFluidContainerEvents, type IFluidContainerInternal, type InitialObjects, } from "./fluidContainer.js";
|
|
11
11
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
12
12
|
export { createServiceAudience } from "./serviceAudience.js";
|
|
13
|
-
export
|
|
13
|
+
export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
|
|
14
|
+
export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IServiceAudience, IServiceAudienceEvents, MemberChangedListener, Myself, TreeContainerSchema, } from "./types.js";
|
|
15
|
+
export { isTreeContainerSchema } from "./utils.js";
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,EACN,mBAAmB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -10,4 +10,6 @@
|
|
|
10
10
|
export { createFluidContainer, isInternalFluidContainer, } from "./fluidContainer.js";
|
|
11
11
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
12
12
|
export { createServiceAudience } from "./serviceAudience.js";
|
|
13
|
+
export { createTreeContainerRuntimeFactory } from "./treeRootDataObject.js";
|
|
14
|
+
export { isTreeContainerSchema } from "./utils.js";
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n} from \"./types.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,GAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uCAAuC,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAa5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\tisInternalFluidContainer,\n\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype IFluidContainerInternal,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport { createTreeContainerRuntimeFactory } from \"./treeRootDataObject.js\";\nexport type {\n\tCompatibilityMode,\n\tContainerSchema,\n\tContainerAttachProps,\n\tIConnection,\n\tIMember,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tMemberChangedListener,\n\tMyself,\n\tTreeContainerSchema,\n} from \"./types.js\";\nexport { isTreeContainerSchema } from \"./utils.js\";\n"]}
|
package/lib/rootDataObject.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ import { type IContainerRuntimeOptions, type MinimumVersionForCollab } from "@fl
|
|
|
7
7
|
import type { IFluidDataStoreRegistry } from "@fluidframework/runtime-definitions/internal";
|
|
8
8
|
import type { CompatibilityMode, ContainerSchema } from "./types.js";
|
|
9
9
|
/**
|
|
10
|
-
* Creates an {@link @fluidframework/aqueduct#
|
|
11
|
-
* with an entry point containing single
|
|
12
|
-
*
|
|
10
|
+
* Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
|
|
11
|
+
* with an entry point containing single directory-based root data object.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* The entry point is opaque to caller.
|
|
15
|
+
* The root data object's registry and initial objects are configured based on the provided
|
|
13
16
|
* schema (and optionally, data store registry).
|
|
14
17
|
*
|
|
15
18
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"rootDataObject.d.ts","sourceRoot":"","sources":["../src/rootDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,MAAM,4CAA4C,CAAC;AAapD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,OAAO,KAAK,EACX,iBAAiB,EACjB,eAAe,EAMf,MAAM,YAAY,CAAC;AA2IpB;;;;;;;;;;GAUG;AACH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE;IAC9D;;OAEG;IACH,MAAM,EAAE,eAAe,CAAC;IACxB;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IAChD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC3D;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,uBAAuB,CAAC;CACtD,GAAG,eAAe,CAoBlB"}
|
package/lib/rootDataObject.js
CHANGED
|
@@ -6,14 +6,7 @@ import { BaseContainerRuntimeFactory, DataObject, DataObjectFactory, } from "@fl
|
|
|
6
6
|
import { FluidDataStoreRegistry, } from "@fluidframework/container-runtime/internal";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import { compatibilityModeRuntimeOptions } from "./compatibilityConfiguration.js";
|
|
9
|
-
import { isDataObjectKind, isSharedObjectKind, parseDataObjectsFromSharedObjects, } from "./utils.js";
|
|
10
|
-
/**
|
|
11
|
-
* Maps CompatibilityMode to a semver valid string that can be passed to the container runtime.
|
|
12
|
-
*/
|
|
13
|
-
const compatibilityModeToMinVersionForCollab = {
|
|
14
|
-
"1": "1.0.0",
|
|
15
|
-
"2": "2.0.0",
|
|
16
|
-
};
|
|
9
|
+
import { compatibilityModeToMinVersionForCollab, createDataObject, createSharedObject, isDataObjectKind, isSharedObjectKind, makeFluidObject, parseDataObjectsFromSharedObjects, } from "./utils.js";
|
|
17
10
|
/**
|
|
18
11
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
19
12
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
@@ -81,49 +74,19 @@ class RootDataObject extends DataObject {
|
|
|
81
74
|
async create(objectClass) {
|
|
82
75
|
const internal = objectClass;
|
|
83
76
|
if (isDataObjectKind(internal)) {
|
|
84
|
-
return
|
|
77
|
+
return createDataObject(internal, this.context);
|
|
85
78
|
}
|
|
86
79
|
else if (isSharedObjectKind(internal)) {
|
|
87
|
-
return
|
|
80
|
+
return createSharedObject(internal, this.runtime);
|
|
88
81
|
}
|
|
89
82
|
throw new Error("Could not create new Fluid object because an unknown object was passed");
|
|
90
83
|
}
|
|
91
84
|
async uploadBlob(blob) {
|
|
92
85
|
return this.runtime.uploadBlob(blob);
|
|
93
86
|
}
|
|
94
|
-
async createDataObject(dataObjectClass) {
|
|
95
|
-
const factory = dataObjectClass.factory;
|
|
96
|
-
const packagePath = [...this.context.packagePath, factory.type];
|
|
97
|
-
const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
|
|
98
|
-
const entryPoint = await dataStore.entryPoint.get();
|
|
99
|
-
return entryPoint;
|
|
100
|
-
}
|
|
101
|
-
createSharedObject(sharedObjectClass) {
|
|
102
|
-
const factory = sharedObjectClass.getFactory();
|
|
103
|
-
const obj = this.runtime.createChannel(undefined, factory.type);
|
|
104
|
-
return obj;
|
|
105
|
-
}
|
|
106
87
|
}
|
|
107
88
|
const rootDataStoreId = "rootDOId";
|
|
108
|
-
|
|
109
|
-
* Creates an {@link @fluidframework/aqueduct#BaseContainerRuntimeFactory} which constructs containers
|
|
110
|
-
* with an entry point containing single IRootDataObject (entry point is opaque to caller),
|
|
111
|
-
* where the root data object's registry and initial objects are configured based on the provided
|
|
112
|
-
* schema (and optionally, data store registry).
|
|
113
|
-
*
|
|
114
|
-
* @internal
|
|
115
|
-
*/
|
|
116
|
-
export function createDOProviderContainerRuntimeFactory(props) {
|
|
117
|
-
const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(props.schema);
|
|
118
|
-
const registry = props.rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
|
|
119
|
-
return new DOProviderContainerRuntimeFactory(props.schema, props.compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
|
|
120
|
-
runtimeOptions: props.runtimeOptionOverrides,
|
|
121
|
-
minVersionForCollab: props.minVersionForCollabOverride,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function makeFluidObject(object, providerKey) {
|
|
125
|
-
return Object.defineProperty(object, providerKey, { value: object });
|
|
126
|
-
}
|
|
89
|
+
const rootDataObjectType = "rootDO";
|
|
127
90
|
async function provideEntryPoint(containerRuntime) {
|
|
128
91
|
const entryPoint = await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
129
92
|
if (entryPoint === undefined) {
|
|
@@ -137,6 +100,26 @@ async function provideEntryPoint(containerRuntime) {
|
|
|
137
100
|
extensionStore: containerRuntime,
|
|
138
101
|
}, "IStaticEntryPoint");
|
|
139
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Creates an {@link @fluidframework/aqueduct#IRuntimeFactory} which constructs containers
|
|
105
|
+
* with an entry point containing single directory-based root data object.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* The entry point is opaque to caller.
|
|
109
|
+
* The root data object's registry and initial objects are configured based on the provided
|
|
110
|
+
* schema (and optionally, data store registry).
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export function createDOProviderContainerRuntimeFactory(props) {
|
|
115
|
+
const { compatibilityMode, minVersionForCollabOverride, rootDataStoreRegistry, runtimeOptionOverrides, schema, } = props;
|
|
116
|
+
const [registryEntries, sharedObjects] = parseDataObjectsFromSharedObjects(schema);
|
|
117
|
+
const registry = rootDataStoreRegistry ?? new FluidDataStoreRegistry(registryEntries);
|
|
118
|
+
return new DOProviderContainerRuntimeFactory(schema, compatibilityMode, new RootDataObjectFactory(sharedObjects, registry), {
|
|
119
|
+
runtimeOptions: runtimeOptionOverrides,
|
|
120
|
+
minVersionForCollab: minVersionForCollabOverride,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
140
123
|
/**
|
|
141
124
|
* Factory for Container Runtime instances that provide a {@link IStaticEntryPoint}
|
|
142
125
|
* (containing single {@link IRootDataObject}) as their entry point.
|
|
@@ -185,7 +168,7 @@ class RootDataObjectFactory extends DataObjectFactory {
|
|
|
185
168
|
// Note: we're passing `undefined` registry entries to the base class so it won't create a registry itself,
|
|
186
169
|
// and instead we override the necessary methods in this class to use the registry received in the constructor.
|
|
187
170
|
super({
|
|
188
|
-
type:
|
|
171
|
+
type: rootDataObjectType,
|
|
189
172
|
ctor: RootDataObject,
|
|
190
173
|
sharedObjects,
|
|
191
174
|
});
|