@fluidframework/fluid-static 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/dist/compatibilityConfiguration.d.ts.map +1 -1
- package/dist/compatibilityConfiguration.js +6 -5
- package/dist/compatibilityConfiguration.js.map +1 -1
- package/dist/fluidContainer.d.ts +19 -0
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/fluidContainer.js +14 -40
- package/dist/fluidContainer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/lib/compatibilityConfiguration.d.ts.map +1 -1
- package/lib/compatibilityConfiguration.js +6 -5
- package/lib/compatibilityConfiguration.js.map +1 -1
- package/lib/fluidContainer.d.ts +19 -0
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.js +12 -39
- package/lib/fluidContainer.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +24 -28
- package/src/compatibilityConfiguration.ts +6 -5
- package/src/fluidContainer.ts +31 -42
- package/src/index.ts +2 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `fluid-static` package provides a simple and powerful way to consume collaborative Fluid data.
|
|
4
4
|
|
|
5
|
-
<!-- AUTO-GENERATED-CONTENT:START (
|
|
5
|
+
<!-- AUTO-GENERATED-CONTENT:START (LIBRARY_README_HEADER) -->
|
|
6
6
|
|
|
7
7
|
<!-- prettier-ignore-start -->
|
|
8
8
|
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
@@ -37,7 +37,7 @@ The `fluid-static` package contains a container with a pre-created default data
|
|
|
37
37
|
|
|
38
38
|
This is consumed by separate client packages, such as [TinyliciousClient](../tinylicious-client/README.MD) for the Tinylicious service, to provide an easy way of creating and fetching FluidContainer instances that are backed by data stored on the respective services.
|
|
39
39
|
|
|
40
|
-
<!-- AUTO-GENERATED-CONTENT:START (
|
|
40
|
+
<!-- AUTO-GENERATED-CONTENT:START (README_FOOTER) -->
|
|
41
41
|
|
|
42
42
|
<!-- prettier-ignore-start -->
|
|
43
43
|
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,wBAAwB,CA+BxB,CAAC"}
|
|
@@ -25,9 +25,9 @@ exports.compatibilityModeRuntimeOptions = {
|
|
|
25
25
|
// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
26
26
|
enableGroupedBatching: false,
|
|
27
27
|
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
28
|
-
// Explicitly disable running Sweep and
|
|
29
|
-
//
|
|
30
|
-
gcOptions: { enableGCSweep: undefined
|
|
28
|
+
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
29
|
+
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
30
|
+
gcOptions: { enableGCSweep: undefined },
|
|
31
31
|
},
|
|
32
32
|
"2": {
|
|
33
33
|
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
@@ -36,8 +36,9 @@ exports.compatibilityModeRuntimeOptions = {
|
|
|
36
36
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
37
37
|
// It introduces a new type of op which is not compatible with 1.x clients.
|
|
38
38
|
enableRuntimeIdCompressor: "on",
|
|
39
|
-
//
|
|
40
|
-
|
|
39
|
+
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
40
|
+
// This setting explicitly disables it to be extra safe.
|
|
41
|
+
gcOptions: { enableGCSweep: undefined },
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
44
|
//# sourceMappingURL=compatibilityConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAGoD;AACpD,2EAAyE;AAIzE;;;GAGG;AACU,QAAA,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,oBAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,gCAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAGoD;AACpD,2EAAyE;AAIzE;;;GAGG;AACU,QAAA,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,oBAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,gCAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * The CompatibilityMode selected determines the set of runtime options to use. In \"1\" mode we support\n * full interop with true 1.x clients, while in \"2\" mode we only support interop with 2.x clients.\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptions\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
|
package/dist/fluidContainer.d.ts
CHANGED
|
@@ -196,6 +196,19 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
196
196
|
*/
|
|
197
197
|
dispose(): void;
|
|
198
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Internal interface for {@link IFluidContainer}.
|
|
201
|
+
*
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
export interface IFluidContainerInternal {
|
|
205
|
+
/**
|
|
206
|
+
* The underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
207
|
+
*
|
|
208
|
+
* @remarks Used to power debug tooling and experimental features.
|
|
209
|
+
*/
|
|
210
|
+
readonly container: IContainer;
|
|
211
|
+
}
|
|
199
212
|
/**
|
|
200
213
|
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
201
214
|
*
|
|
@@ -205,4 +218,10 @@ export declare function createFluidContainer<TContainerSchema extends ContainerS
|
|
|
205
218
|
container: IContainer;
|
|
206
219
|
rootDataObject: IRootDataObject;
|
|
207
220
|
}): IFluidContainer<TContainerSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
223
|
+
*
|
|
224
|
+
* @internal
|
|
225
|
+
*/
|
|
226
|
+
export declare function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(container: IFluidContainer<TContainerSchema> | IFluidContainerInternal): container is IFluidContainerInternal;
|
|
208
227
|
//# sourceMappingURL=fluidContainer.d.ts.map
|
|
@@ -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,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEzF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,IAAI;KAMtD,CAAC,IAAI,MAAM,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAChF,MAAM,QAAQ,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AAM,CAAC,CAAC,SAAS,cAAc,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,gBAAgB,SAAS,eAAe,GAAG,eAAe,EACzD,KAAK,EAAE;IACR,SAAS,EAAE,UAAU,CAAC;IACtB,cAAc,EAAE,eAAe,CAAC;CAChC,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,SAAS,eAAe,EAChF,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAAG,uBAAuB,GACpE,SAAS,IAAI,uBAAuB,CAKtC"}
|
package/dist/fluidContainer.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createFluidContainer = void 0;
|
|
7
|
+
exports.isInternalFluidContainer = exports.createFluidContainer = void 0;
|
|
8
8
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
9
|
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
10
10
|
/**
|
|
@@ -17,7 +17,19 @@ function createFluidContainer(props) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.createFluidContainer = createFluidContainer;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
function isInternalFluidContainer(container) {
|
|
25
|
+
// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be
|
|
26
|
+
// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,
|
|
27
|
+
// we use `instanceof` to confirm.
|
|
28
|
+
return container instanceof FluidContainer;
|
|
29
|
+
}
|
|
30
|
+
exports.isInternalFluidContainer = isInternalFluidContainer;
|
|
31
|
+
/**
|
|
32
|
+
* {@link IFluidContainer} implementation.
|
|
21
33
|
*
|
|
22
34
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
23
35
|
* @remarks
|
|
@@ -35,50 +47,24 @@ class FluidContainer extends client_utils_1.TypedEventEmitter {
|
|
|
35
47
|
this.disposedHandler = (error) => this.emit("disposed", error);
|
|
36
48
|
this.savedHandler = () => this.emit("saved");
|
|
37
49
|
this.dirtyHandler = () => this.emit("dirty");
|
|
38
|
-
/**
|
|
39
|
-
* FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
|
|
40
|
-
* We make no stability guarantees here whatsoever.
|
|
41
|
-
*
|
|
42
|
-
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
43
|
-
*
|
|
44
|
-
* @remarks Used to power debug tooling.
|
|
45
|
-
*/
|
|
46
|
-
this.INTERNAL_CONTAINER_DO_NOT_USE = () => {
|
|
47
|
-
return this.container;
|
|
48
|
-
};
|
|
49
50
|
container.on("connected", this.connectedHandler);
|
|
50
51
|
container.on("closed", this.disposedHandler);
|
|
51
52
|
container.on("disconnected", this.disconnectedHandler);
|
|
52
53
|
container.on("saved", this.savedHandler);
|
|
53
54
|
container.on("dirty", this.dirtyHandler);
|
|
54
55
|
}
|
|
55
|
-
/**
|
|
56
|
-
* {@inheritDoc IFluidContainer.isDirty}
|
|
57
|
-
*/
|
|
58
56
|
get isDirty() {
|
|
59
57
|
return this.container.isDirty;
|
|
60
58
|
}
|
|
61
|
-
/**
|
|
62
|
-
* {@inheritDoc IFluidContainer.attachState}
|
|
63
|
-
*/
|
|
64
59
|
get attachState() {
|
|
65
60
|
return this.container.attachState;
|
|
66
61
|
}
|
|
67
|
-
/**
|
|
68
|
-
* {@inheritDoc IFluidContainer.disposed}
|
|
69
|
-
*/
|
|
70
62
|
get disposed() {
|
|
71
63
|
return this.container.closed;
|
|
72
64
|
}
|
|
73
|
-
/**
|
|
74
|
-
* {@inheritDoc IFluidContainer.connectionState}
|
|
75
|
-
*/
|
|
76
65
|
get connectionState() {
|
|
77
66
|
return this.container.connectionState;
|
|
78
67
|
}
|
|
79
|
-
/**
|
|
80
|
-
* {@inheritDoc IFluidContainer.initialObjects}
|
|
81
|
-
*/
|
|
82
68
|
get initialObjects() {
|
|
83
69
|
return this.rootDataObject.initialObjects;
|
|
84
70
|
}
|
|
@@ -100,27 +86,15 @@ class FluidContainer extends client_utils_1.TypedEventEmitter {
|
|
|
100
86
|
}
|
|
101
87
|
throw new Error("Cannot attach container. Attach method not provided.");
|
|
102
88
|
}
|
|
103
|
-
/**
|
|
104
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
105
|
-
*/
|
|
106
89
|
async connect() {
|
|
107
90
|
this.container.connect?.();
|
|
108
91
|
}
|
|
109
|
-
/**
|
|
110
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
111
|
-
*/
|
|
112
92
|
async disconnect() {
|
|
113
93
|
this.container.disconnect?.();
|
|
114
94
|
}
|
|
115
|
-
/**
|
|
116
|
-
* {@inheritDoc IFluidContainer.create}
|
|
117
|
-
*/
|
|
118
95
|
async create(objectClass) {
|
|
119
96
|
return this.rootDataObject.create(objectClass);
|
|
120
97
|
}
|
|
121
|
-
/**
|
|
122
|
-
* {@inheritDoc IFluidContainer.dispose}
|
|
123
|
-
*/
|
|
124
98
|
dispose() {
|
|
125
99
|
this.container.close();
|
|
126
100
|
this.container.off("connected", this.connectedHandler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,iFAI+C;AA8N/C;;;;GA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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;CAaD","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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { ContainerAttachProps, ContainerSchema, IRootDataObject } 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 * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n\trootDataObject: IRootDataObject;\n}): IFluidContainer<TContainerSchema> {\n\treturn new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);\n}\n\n/**\n * Base {@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>\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\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(): boolean {\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(): 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\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: SharedObjectKind<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(): 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\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\tpublic readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {\n\t\treturn this.container;\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fluidContainer.js","sourceRoot":"","sources":["../src/fluidContainer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,iFAI+C;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AAC,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;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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { ContainerAttachProps, ContainerSchema, IRootDataObject } 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 {\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\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n\trootDataObject: IRootDataObject;\n}): IFluidContainer<TContainerSchema> {\n\treturn new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);\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\n\tpublic constructor(\n\t\tpublic 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\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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export { createFluidContainer, type IFluidContainer, type IFluidContainerEvents, type InitialObjects, } from "./fluidContainer.js";
|
|
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
13
|
export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IProvideRootDataObject, IRootDataObject, IServiceAudience, IServiceAudienceEvents, LoadableObjectRecord, MemberChangedListener, Myself, } from "./types.js";
|
package/dist/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,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,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,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,GACN,MAAM,YAAY,CAAC"}
|
|
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,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,GACN,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createServiceAudience = exports.createDOProviderContainerRuntimeFactory = exports.createFluidContainer = void 0;
|
|
7
|
+
exports.createServiceAudience = exports.createDOProviderContainerRuntimeFactory = exports.isInternalFluidContainer = exports.createFluidContainer = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* Provides a simple and powerful way to consume collaborative Fluid data.
|
|
10
10
|
*
|
|
@@ -12,6 +12,7 @@ exports.createServiceAudience = exports.createDOProviderContainerRuntimeFactory
|
|
|
12
12
|
*/
|
|
13
13
|
var fluidContainer_js_1 = require("./fluidContainer.js");
|
|
14
14
|
Object.defineProperty(exports, "createFluidContainer", { enumerable: true, get: function () { return fluidContainer_js_1.createFluidContainer; } });
|
|
15
|
+
Object.defineProperty(exports, "isInternalFluidContainer", { enumerable: true, get: function () { return fluidContainer_js_1.isInternalFluidContainer; } });
|
|
15
16
|
var rootDataObject_js_1 = require("./rootDataObject.js");
|
|
16
17
|
Object.defineProperty(exports, "createDOProviderContainerRuntimeFactory", { enumerable: true, get: function () { return rootDataObject_js_1.createDOProviderContainerRuntimeFactory; } });
|
|
17
18
|
var serviceAudience_js_1 = require("./serviceAudience.js");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,yDAO6B;AAN5B,yHAAA,oBAAoB,OAAA;AACpB,6HAAA,wBAAwB,OAAA;AAMzB,yDAA8E;AAArE,4IAAA,uCAAuC,OAAA;AAChD,2DAA6D;AAApD,2HAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Provides a simple and powerful way to consume collaborative Fluid data.\n *\n * @packageDocumentation\n */\n\nexport {\n\tcreateFluidContainer,\n\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\tIProvideRootDataObject,\n\tIRootDataObject,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tLoadableObjectRecord,\n\tMemberChangedListener,\n\tMyself,\n} from \"./types.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.d.ts","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,KAAK,wBAAwB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CACnD,iBAAiB,EACjB,wBAAwB,CA+BxB,CAAC"}
|
|
@@ -22,9 +22,9 @@ export const compatibilityModeRuntimeOptions = {
|
|
|
22
22
|
// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
|
|
23
23
|
enableGroupedBatching: false,
|
|
24
24
|
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
25
|
-
// Explicitly disable running Sweep and
|
|
26
|
-
//
|
|
27
|
-
gcOptions: { enableGCSweep: undefined
|
|
25
|
+
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
26
|
+
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
27
|
+
gcOptions: { enableGCSweep: undefined },
|
|
28
28
|
},
|
|
29
29
|
"2": {
|
|
30
30
|
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
@@ -33,8 +33,9 @@ export const compatibilityModeRuntimeOptions = {
|
|
|
33
33
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
34
34
|
// It introduces a new type of op which is not compatible with 1.x clients.
|
|
35
35
|
enableRuntimeIdCompressor: "on",
|
|
36
|
-
//
|
|
37
|
-
|
|
36
|
+
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
37
|
+
// This setting explicitly disables it to be extra safe.
|
|
38
|
+
gcOptions: { enableGCSweep: undefined },
|
|
38
39
|
},
|
|
39
40
|
};
|
|
40
41
|
//# sourceMappingURL=compatibilityConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,qBAAqB,GAErB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAIzE;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,qBAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,
|
|
1
|
+
{"version":3,"file":"compatibilityConfiguration.js","sourceRoot":"","sources":["../src/compatibilityConfiguration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,qBAAqB,GAErB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AAIzE;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAGxC;IACH,GAAG,EAAE;QACJ,0GAA0G;QAC1G,8GAA8G;QAC9G,6CAA6C;QAC7C,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,4GAA4G;QAC5G,kBAAkB,EAAE;YACnB,uBAAuB,EAAE,MAAM,CAAC,iBAAiB,EAAE,WAAW;YAC9D,oBAAoB,EAAE,qBAAqB,CAAC,GAAG;SAC/C;QACD,8GAA8G;QAC9G,qBAAqB,EAAE,KAAK;QAC5B,gFAAgF;QAEhF,4GAA4G;QAC5G,wEAAwE;QACxE,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;QAC/B,sHAAsH;QACtH,wDAAwD;QACxD,SAAS,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;KACvC;CACD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tCompressionAlgorithms,\n\ttype IContainerRuntimeOptions,\n} from \"@fluidframework/container-runtime/internal\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions/internal\";\n\nimport type { CompatibilityMode } from \"./types.js\";\n\n/**\n * The CompatibilityMode selected determines the set of runtime options to use. In \"1\" mode we support\n * full interop with true 1.x clients, while in \"2\" mode we only support interop with 2.x clients.\n */\nexport const compatibilityModeRuntimeOptions: Record<\n\tCompatibilityMode,\n\tIContainerRuntimeOptions\n> = {\n\t\"1\": {\n\t\t// 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode\n\t\t// as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as\n\t\t// fewer messages will be included per flush.\n\t\tflushMode: FlushMode.Immediate,\n\t\t// Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tcompressionOptions: {\n\t\t\tminimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled\n\t\t\tcompressionAlgorithm: CompressionAlgorithms.lz4,\n\t\t},\n\t\t// Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableGroupedBatching: false,\n\t\t// TODO: Include explicit disables for things that are currently off-by-default?\n\n\t\t// Explicitly disable running Sweep in compat mode \"1\". Sweep is supported only in 2.x. So, when 1.x and 2.x\n\t\t// clients are running in parallel, running sweep will fail 1.x clients.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n\t\"2\": {\n\t\t// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their\n\t\t// ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.\n\t\texplicitSchemaControl: true,\n\t\t// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.\n\t\t// It introduces a new type of op which is not compatible with 1.x clients.\n\t\tenableRuntimeIdCompressor: \"on\",\n\t\t// Explicitly disable running Sweep in compat mode \"2\". Although sweep is supported in 2.x, it is disabled by default.\n\t\t// This setting explicitly disables it to be extra safe.\n\t\tgcOptions: { enableGCSweep: undefined },\n\t},\n};\n"]}
|
package/lib/fluidContainer.d.ts
CHANGED
|
@@ -196,6 +196,19 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
196
196
|
*/
|
|
197
197
|
dispose(): void;
|
|
198
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Internal interface for {@link IFluidContainer}.
|
|
201
|
+
*
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
204
|
+
export interface IFluidContainerInternal {
|
|
205
|
+
/**
|
|
206
|
+
* The underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
207
|
+
*
|
|
208
|
+
* @remarks Used to power debug tooling and experimental features.
|
|
209
|
+
*/
|
|
210
|
+
readonly container: IContainer;
|
|
211
|
+
}
|
|
199
212
|
/**
|
|
200
213
|
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
201
214
|
*
|
|
@@ -205,4 +218,10 @@ export declare function createFluidContainer<TContainerSchema extends ContainerS
|
|
|
205
218
|
container: IContainer;
|
|
206
219
|
rootDataObject: IRootDataObject;
|
|
207
220
|
}): IFluidContainer<TContainerSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
223
|
+
*
|
|
224
|
+
* @internal
|
|
225
|
+
*/
|
|
226
|
+
export declare function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(container: IFluidContainer<TContainerSchema> | IFluidContainerInternal): container is IFluidContainerInternal;
|
|
208
227
|
//# sourceMappingURL=fluidContainer.d.ts.map
|
|
@@ -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;AA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C,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAE1D;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAElC;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtD;;;;;;;;;;;OAWG;IACH,OAAO,IAAI,IAAI,CAAC;IAEhB;;;;;;;;;OASG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/E;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,gBAAgB,SAAS,eAAe,GAAG,eAAe,EACzD,KAAK,EAAE;IACR,SAAS,EAAE,UAAU,CAAC;IACtB,cAAc,EAAE,eAAe,CAAC;CAChC,GAAG,eAAe,CAAC,gBAAgB,CAAC,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,SAAS,eAAe,EAChF,SAAS,EAAE,eAAe,CAAC,gBAAgB,CAAC,GAAG,uBAAuB,GACpE,SAAS,IAAI,uBAAuB,CAKtC"}
|
package/lib/fluidContainer.js
CHANGED
|
@@ -13,7 +13,18 @@ export function createFluidContainer(props) {
|
|
|
13
13
|
return new FluidContainer(props.container, props.rootDataObject);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export function isInternalFluidContainer(container) {
|
|
21
|
+
// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be
|
|
22
|
+
// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,
|
|
23
|
+
// we use `instanceof` to confirm.
|
|
24
|
+
return container instanceof FluidContainer;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* {@link IFluidContainer} implementation.
|
|
17
28
|
*
|
|
18
29
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
19
30
|
* @remarks
|
|
@@ -31,50 +42,24 @@ class FluidContainer extends TypedEventEmitter {
|
|
|
31
42
|
this.disposedHandler = (error) => this.emit("disposed", error);
|
|
32
43
|
this.savedHandler = () => this.emit("saved");
|
|
33
44
|
this.dirtyHandler = () => this.emit("dirty");
|
|
34
|
-
/**
|
|
35
|
-
* FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
|
|
36
|
-
* We make no stability guarantees here whatsoever.
|
|
37
|
-
*
|
|
38
|
-
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
39
|
-
*
|
|
40
|
-
* @remarks Used to power debug tooling.
|
|
41
|
-
*/
|
|
42
|
-
this.INTERNAL_CONTAINER_DO_NOT_USE = () => {
|
|
43
|
-
return this.container;
|
|
44
|
-
};
|
|
45
45
|
container.on("connected", this.connectedHandler);
|
|
46
46
|
container.on("closed", this.disposedHandler);
|
|
47
47
|
container.on("disconnected", this.disconnectedHandler);
|
|
48
48
|
container.on("saved", this.savedHandler);
|
|
49
49
|
container.on("dirty", this.dirtyHandler);
|
|
50
50
|
}
|
|
51
|
-
/**
|
|
52
|
-
* {@inheritDoc IFluidContainer.isDirty}
|
|
53
|
-
*/
|
|
54
51
|
get isDirty() {
|
|
55
52
|
return this.container.isDirty;
|
|
56
53
|
}
|
|
57
|
-
/**
|
|
58
|
-
* {@inheritDoc IFluidContainer.attachState}
|
|
59
|
-
*/
|
|
60
54
|
get attachState() {
|
|
61
55
|
return this.container.attachState;
|
|
62
56
|
}
|
|
63
|
-
/**
|
|
64
|
-
* {@inheritDoc IFluidContainer.disposed}
|
|
65
|
-
*/
|
|
66
57
|
get disposed() {
|
|
67
58
|
return this.container.closed;
|
|
68
59
|
}
|
|
69
|
-
/**
|
|
70
|
-
* {@inheritDoc IFluidContainer.connectionState}
|
|
71
|
-
*/
|
|
72
60
|
get connectionState() {
|
|
73
61
|
return this.container.connectionState;
|
|
74
62
|
}
|
|
75
|
-
/**
|
|
76
|
-
* {@inheritDoc IFluidContainer.initialObjects}
|
|
77
|
-
*/
|
|
78
63
|
get initialObjects() {
|
|
79
64
|
return this.rootDataObject.initialObjects;
|
|
80
65
|
}
|
|
@@ -96,27 +81,15 @@ class FluidContainer extends TypedEventEmitter {
|
|
|
96
81
|
}
|
|
97
82
|
throw new Error("Cannot attach container. Attach method not provided.");
|
|
98
83
|
}
|
|
99
|
-
/**
|
|
100
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
101
|
-
*/
|
|
102
84
|
async connect() {
|
|
103
85
|
this.container.connect?.();
|
|
104
86
|
}
|
|
105
|
-
/**
|
|
106
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
107
|
-
*/
|
|
108
87
|
async disconnect() {
|
|
109
88
|
this.container.disconnect?.();
|
|
110
89
|
}
|
|
111
|
-
/**
|
|
112
|
-
* {@inheritDoc IFluidContainer.create}
|
|
113
|
-
*/
|
|
114
90
|
async create(objectClass) {
|
|
115
91
|
return this.rootDataObject.create(objectClass);
|
|
116
92
|
}
|
|
117
|
-
/**
|
|
118
|
-
* {@inheritDoc IFluidContainer.dispose}
|
|
119
|
-
*/
|
|
120
93
|
dispose() {
|
|
121
94
|
this.container.close();
|
|
122
95
|
this.container.off("connected", this.connectedHandler);
|
|
@@ -1 +1 @@
|
|
|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CAAC;IAChD,CAAC;IAED;;OAEG;IACI,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;CAaD","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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { ContainerAttachProps, ContainerSchema, IRootDataObject } 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 * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n\trootDataObject: IRootDataObject;\n}): IFluidContainer<TContainerSchema> {\n\treturn new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);\n}\n\n/**\n * Base {@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>\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\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(): boolean {\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(): 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\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: SharedObjectKind<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(): 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\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\tpublic readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {\n\t\treturn this.container;\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;AA4O/C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAElC,KAGD;IACA,OAAO,IAAI,cAAc,CAAmB,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;AACpF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACvC,SAAsE;IAEtE,+EAA+E;IAC/E,4EAA4E;IAC5E,kCAAkC;IAClC,OAAO,SAAS,YAAY,cAAc,CAAC;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,cACL,SAAQ,iBAAwC;IAUhD,YACiB,SAAqB,EACpB,cAA+B;QAEhD,KAAK,EAAE,CAAC;QAHQ,cAAS,GAAT,SAAS,CAAY;QACpB,mBAAc,GAAd,cAAc,CAAiB;QAThC,qBAAgB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzD,wBAAmB,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/D,oBAAe,GAAG,CAAC,KAA+B,EAAW,EAAE,CAC/E,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACb,iBAAY,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,iBAAY,GAAG,GAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAOjE,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB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,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;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 { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport type { SharedObjectKind } from \"@fluidframework/shared-object-base\";\n\nimport type { ContainerAttachProps, ContainerSchema, IRootDataObject } 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 {\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\n/**\n * Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.\n *\n * @internal\n */\nexport function createFluidContainer<\n\tTContainerSchema extends ContainerSchema = ContainerSchema,\n>(props: {\n\tcontainer: IContainer;\n\trootDataObject: IRootDataObject;\n}): IFluidContainer<TContainerSchema> {\n\treturn new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);\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\n\tpublic constructor(\n\t\tpublic 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\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"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export { createFluidContainer, type IFluidContainer, type IFluidContainerEvents, type InitialObjects, } from "./fluidContainer.js";
|
|
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
13
|
export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IProvideRootDataObject, IRootDataObject, IServiceAudience, IServiceAudienceEvents, LoadableObjectRecord, MemberChangedListener, Myself, } from "./types.js";
|
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,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,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,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,GACN,MAAM,YAAY,CAAC"}
|
|
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,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,GACN,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
export { createFluidContainer, } from "./fluidContainer.js";
|
|
10
|
+
export { createFluidContainer, isInternalFluidContainer, } from "./fluidContainer.js";
|
|
11
11
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|
|
12
12
|
export { createServiceAudience } from "./serviceAudience.js";
|
|
13
13
|
//# 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,
|
|
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\tIProvideRootDataObject,\n\tIRootDataObject,\n\tIServiceAudience,\n\tIServiceAudienceEvents,\n\tLoadableObjectRecord,\n\tMemberChangedListener,\n\tMyself,\n} from \"./types.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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": {
|
|
@@ -57,32 +57,32 @@
|
|
|
57
57
|
"temp-directory": "nyc/.nyc_output"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@fluid-internal/client-utils": "~2.
|
|
61
|
-
"@fluidframework/aqueduct": "~2.
|
|
62
|
-
"@fluidframework/container-definitions": "~2.
|
|
63
|
-
"@fluidframework/container-loader": "~2.
|
|
64
|
-
"@fluidframework/container-runtime": "~2.
|
|
65
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
66
|
-
"@fluidframework/core-interfaces": "~2.
|
|
67
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
68
|
-
"@fluidframework/driver-definitions": "~2.
|
|
69
|
-
"@fluidframework/request-handler": "~2.
|
|
70
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
71
|
-
"@fluidframework/runtime-utils": "~2.
|
|
72
|
-
"@fluidframework/shared-object-base": "~2.
|
|
73
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
60
|
+
"@fluid-internal/client-utils": "~2.2.0",
|
|
61
|
+
"@fluidframework/aqueduct": "~2.2.0",
|
|
62
|
+
"@fluidframework/container-definitions": "~2.2.0",
|
|
63
|
+
"@fluidframework/container-loader": "~2.2.0",
|
|
64
|
+
"@fluidframework/container-runtime": "~2.2.0",
|
|
65
|
+
"@fluidframework/container-runtime-definitions": "~2.2.0",
|
|
66
|
+
"@fluidframework/core-interfaces": "~2.2.0",
|
|
67
|
+
"@fluidframework/datastore-definitions": "~2.2.0",
|
|
68
|
+
"@fluidframework/driver-definitions": "~2.2.0",
|
|
69
|
+
"@fluidframework/request-handler": "~2.2.0",
|
|
70
|
+
"@fluidframework/runtime-definitions": "~2.2.0",
|
|
71
|
+
"@fluidframework/runtime-utils": "~2.2.0",
|
|
72
|
+
"@fluidframework/shared-object-base": "~2.2.0",
|
|
73
|
+
"@fluidframework/telemetry-utils": "~2.2.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
77
77
|
"@biomejs/biome": "~1.8.3",
|
|
78
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
79
|
-
"@fluid-tools/build-cli": "^0.
|
|
78
|
+
"@fluid-internal/mocha-test-setup": "~2.2.0",
|
|
79
|
+
"@fluid-tools/build-cli": "^0.43.0",
|
|
80
80
|
"@fluidframework/build-common": "^2.0.3",
|
|
81
|
-
"@fluidframework/build-tools": "^0.
|
|
81
|
+
"@fluidframework/build-tools": "^0.43.0",
|
|
82
82
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
83
|
-
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.
|
|
84
|
-
"@fluidframework/map": "~2.
|
|
85
|
-
"@fluidframework/sequence": "~2.
|
|
83
|
+
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.1.0",
|
|
84
|
+
"@fluidframework/map": "~2.2.0",
|
|
85
|
+
"@fluidframework/sequence": "~2.2.0",
|
|
86
86
|
"@microsoft/api-extractor": "^7.45.1",
|
|
87
87
|
"@types/mocha": "^9.1.1",
|
|
88
88
|
"@types/node": "^18.19.0",
|
|
@@ -100,11 +100,7 @@
|
|
|
100
100
|
"typescript": "~5.4.5"
|
|
101
101
|
},
|
|
102
102
|
"typeValidation": {
|
|
103
|
-
"broken": {
|
|
104
|
-
"Interface_ContainerSchema": {
|
|
105
|
-
"forwardCompat": false
|
|
106
|
-
}
|
|
107
|
-
}
|
|
103
|
+
"broken": {}
|
|
108
104
|
},
|
|
109
105
|
"scripts": {
|
|
110
106
|
"api": "fluid-build . --task api",
|
|
@@ -138,8 +134,8 @@
|
|
|
138
134
|
"test": "npm run test:mocha",
|
|
139
135
|
"test:coverage": "c8 npm test",
|
|
140
136
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
141
|
-
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit
|
|
142
|
-
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit
|
|
137
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
|
|
138
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
|
|
143
139
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
144
140
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
145
141
|
"typetests:gen": "flub generate typetests --dir . -v",
|
|
@@ -33,9 +33,9 @@ export const compatibilityModeRuntimeOptions: Record<
|
|
|
33
33
|
enableGroupedBatching: false,
|
|
34
34
|
// TODO: Include explicit disables for things that are currently off-by-default?
|
|
35
35
|
|
|
36
|
-
// Explicitly disable running Sweep and
|
|
37
|
-
//
|
|
38
|
-
gcOptions: { enableGCSweep: undefined
|
|
36
|
+
// Explicitly disable running Sweep in compat mode "1". Sweep is supported only in 2.x. So, when 1.x and 2.x
|
|
37
|
+
// clients are running in parallel, running sweep will fail 1.x clients.
|
|
38
|
+
gcOptions: { enableGCSweep: undefined },
|
|
39
39
|
},
|
|
40
40
|
"2": {
|
|
41
41
|
// Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
|
|
@@ -44,7 +44,8 @@ export const compatibilityModeRuntimeOptions: Record<
|
|
|
44
44
|
// The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
|
|
45
45
|
// It introduces a new type of op which is not compatible with 1.x clients.
|
|
46
46
|
enableRuntimeIdCompressor: "on",
|
|
47
|
-
//
|
|
48
|
-
|
|
47
|
+
// Explicitly disable running Sweep in compat mode "2". Although sweep is supported in 2.x, it is disabled by default.
|
|
48
|
+
// This setting explicitly disables it to be extra safe.
|
|
49
|
+
gcOptions: { enableGCSweep: undefined },
|
|
49
50
|
},
|
|
50
51
|
};
|
package/src/fluidContainer.ts
CHANGED
|
@@ -230,6 +230,20 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
230
230
|
dispose(): void;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Internal interface for {@link IFluidContainer}.
|
|
235
|
+
*
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
export interface IFluidContainerInternal {
|
|
239
|
+
/**
|
|
240
|
+
* The underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
241
|
+
*
|
|
242
|
+
* @remarks Used to power debug tooling and experimental features.
|
|
243
|
+
*/
|
|
244
|
+
readonly container: IContainer;
|
|
245
|
+
}
|
|
246
|
+
|
|
233
247
|
/**
|
|
234
248
|
* Creates an {@link IFluidContainer} from the provided `container` and `rootDataObject`.
|
|
235
249
|
*
|
|
@@ -245,7 +259,21 @@ export function createFluidContainer<
|
|
|
245
259
|
}
|
|
246
260
|
|
|
247
261
|
/**
|
|
248
|
-
*
|
|
262
|
+
* Check that the provided `container` is an internal {@link IFluidContainerInternal}.
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
export function isInternalFluidContainer<TContainerSchema extends ContainerSchema>(
|
|
267
|
+
container: IFluidContainer<TContainerSchema> | IFluidContainerInternal,
|
|
268
|
+
): container is IFluidContainerInternal {
|
|
269
|
+
// IFluidContainer is sealed; so we never expect an `IFluidContainer` not to be
|
|
270
|
+
// `IFluidContainerInternal` implemented by `FluidContainer`. To be caution,
|
|
271
|
+
// we use `instanceof` to confirm.
|
|
272
|
+
return container instanceof FluidContainer;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* {@link IFluidContainer} implementation.
|
|
249
277
|
*
|
|
250
278
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
251
279
|
* @remarks
|
|
@@ -255,7 +283,7 @@ export function createFluidContainer<
|
|
|
255
283
|
*/
|
|
256
284
|
class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
257
285
|
extends TypedEventEmitter<IFluidContainerEvents>
|
|
258
|
-
implements IFluidContainer<TContainerSchema
|
|
286
|
+
implements IFluidContainer<TContainerSchema>, IFluidContainerInternal
|
|
259
287
|
{
|
|
260
288
|
private readonly connectedHandler = (): boolean => this.emit("connected");
|
|
261
289
|
private readonly disconnectedHandler = (): boolean => this.emit("disconnected");
|
|
@@ -265,7 +293,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
265
293
|
private readonly dirtyHandler = (): boolean => this.emit("dirty");
|
|
266
294
|
|
|
267
295
|
public constructor(
|
|
268
|
-
|
|
296
|
+
public readonly container: IContainer,
|
|
269
297
|
private readonly rootDataObject: IRootDataObject,
|
|
270
298
|
) {
|
|
271
299
|
super();
|
|
@@ -276,37 +304,22 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
276
304
|
container.on("dirty", this.dirtyHandler);
|
|
277
305
|
}
|
|
278
306
|
|
|
279
|
-
/**
|
|
280
|
-
* {@inheritDoc IFluidContainer.isDirty}
|
|
281
|
-
*/
|
|
282
307
|
public get isDirty(): boolean {
|
|
283
308
|
return this.container.isDirty;
|
|
284
309
|
}
|
|
285
310
|
|
|
286
|
-
/**
|
|
287
|
-
* {@inheritDoc IFluidContainer.attachState}
|
|
288
|
-
*/
|
|
289
311
|
public get attachState(): AttachState {
|
|
290
312
|
return this.container.attachState;
|
|
291
313
|
}
|
|
292
314
|
|
|
293
|
-
/**
|
|
294
|
-
* {@inheritDoc IFluidContainer.disposed}
|
|
295
|
-
*/
|
|
296
315
|
public get disposed(): boolean {
|
|
297
316
|
return this.container.closed;
|
|
298
317
|
}
|
|
299
318
|
|
|
300
|
-
/**
|
|
301
|
-
* {@inheritDoc IFluidContainer.connectionState}
|
|
302
|
-
*/
|
|
303
319
|
public get connectionState(): ConnectionState {
|
|
304
320
|
return this.container.connectionState;
|
|
305
321
|
}
|
|
306
322
|
|
|
307
|
-
/**
|
|
308
|
-
* {@inheritDoc IFluidContainer.initialObjects}
|
|
309
|
-
*/
|
|
310
323
|
public get initialObjects(): InitialObjects<TContainerSchema> {
|
|
311
324
|
return this.rootDataObject.initialObjects as InitialObjects<TContainerSchema>;
|
|
312
325
|
}
|
|
@@ -330,30 +343,18 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
330
343
|
throw new Error("Cannot attach container. Attach method not provided.");
|
|
331
344
|
}
|
|
332
345
|
|
|
333
|
-
/**
|
|
334
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
335
|
-
*/
|
|
336
346
|
public async connect(): Promise<void> {
|
|
337
347
|
this.container.connect?.();
|
|
338
348
|
}
|
|
339
349
|
|
|
340
|
-
/**
|
|
341
|
-
* {@inheritDoc IFluidContainer.connect}
|
|
342
|
-
*/
|
|
343
350
|
public async disconnect(): Promise<void> {
|
|
344
351
|
this.container.disconnect?.();
|
|
345
352
|
}
|
|
346
353
|
|
|
347
|
-
/**
|
|
348
|
-
* {@inheritDoc IFluidContainer.create}
|
|
349
|
-
*/
|
|
350
354
|
public async create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T> {
|
|
351
355
|
return this.rootDataObject.create(objectClass);
|
|
352
356
|
}
|
|
353
357
|
|
|
354
|
-
/**
|
|
355
|
-
* {@inheritDoc IFluidContainer.dispose}
|
|
356
|
-
*/
|
|
357
358
|
public dispose(): void {
|
|
358
359
|
this.container.close();
|
|
359
360
|
this.container.off("connected", this.connectedHandler);
|
|
@@ -362,16 +363,4 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
|
362
363
|
this.container.off("saved", this.savedHandler);
|
|
363
364
|
this.container.off("dirty", this.dirtyHandler);
|
|
364
365
|
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* FOR INTERNAL USE ONLY. NOT FOR EXTERNAL USE.
|
|
368
|
-
* We make no stability guarantees here whatsoever.
|
|
369
|
-
*
|
|
370
|
-
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
371
|
-
*
|
|
372
|
-
* @remarks Used to power debug tooling.
|
|
373
|
-
*/
|
|
374
|
-
public readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {
|
|
375
|
-
return this.container;
|
|
376
|
-
};
|
|
377
366
|
}
|
package/src/index.ts
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
13
|
createFluidContainer,
|
|
14
|
+
isInternalFluidContainer,
|
|
14
15
|
type IFluidContainer,
|
|
15
16
|
type IFluidContainerEvents,
|
|
17
|
+
type IFluidContainerInternal,
|
|
16
18
|
type InitialObjects,
|
|
17
19
|
} from "./fluidContainer.js";
|
|
18
20
|
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
|