@fluidframework/fluid-static 2.0.0-rc.4.0.6 → 2.0.0-rc.5.0.1

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/api-extractor/api-extractor-lint-bundle.json +5 -0
  3. package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
  4. package/api-extractor/api-extractor-lint-public.esm.json +5 -0
  5. package/api-extractor.json +1 -1
  6. package/api-report/{fluid-static.api.md → fluid-static.alpha.api.md} +15 -57
  7. package/api-report/fluid-static.beta.api.md +94 -0
  8. package/api-report/fluid-static.public.api.md +94 -0
  9. package/biome.jsonc +4 -0
  10. package/dist/compatibilityConfiguration.d.ts +12 -0
  11. package/dist/compatibilityConfiguration.d.ts.map +1 -0
  12. package/dist/compatibilityConfiguration.js +38 -0
  13. package/dist/compatibilityConfiguration.js.map +1 -0
  14. package/dist/fluidContainer.d.ts +22 -10
  15. package/dist/fluidContainer.d.ts.map +1 -1
  16. package/dist/fluidContainer.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/public.d.ts +1 -3
  21. package/dist/rootDataObject.d.ts +4 -3
  22. package/dist/rootDataObject.d.ts.map +1 -1
  23. package/dist/rootDataObject.js +11 -18
  24. package/dist/rootDataObject.js.map +1 -1
  25. package/dist/serviceAudience.d.ts +3 -3
  26. package/dist/serviceAudience.d.ts.map +1 -1
  27. package/dist/serviceAudience.js.map +1 -1
  28. package/dist/types.d.ts +19 -21
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js.map +1 -1
  31. package/dist/utils.d.ts +7 -14
  32. package/dist/utils.d.ts.map +1 -1
  33. package/dist/utils.js.map +1 -1
  34. package/lib/compatibilityConfiguration.d.ts +12 -0
  35. package/lib/compatibilityConfiguration.d.ts.map +1 -0
  36. package/lib/compatibilityConfiguration.js +35 -0
  37. package/lib/compatibilityConfiguration.js.map +1 -0
  38. package/lib/fluidContainer.d.ts +22 -10
  39. package/lib/fluidContainer.d.ts.map +1 -1
  40. package/lib/fluidContainer.js.map +1 -1
  41. package/lib/index.d.ts +1 -1
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js.map +1 -1
  44. package/lib/public.d.ts +1 -3
  45. package/lib/rootDataObject.d.ts +4 -3
  46. package/lib/rootDataObject.d.ts.map +1 -1
  47. package/lib/rootDataObject.js +9 -16
  48. package/lib/rootDataObject.js.map +1 -1
  49. package/lib/serviceAudience.d.ts +3 -3
  50. package/lib/serviceAudience.d.ts.map +1 -1
  51. package/lib/serviceAudience.js.map +1 -1
  52. package/lib/tsdoc-metadata.json +1 -1
  53. package/lib/types.d.ts +19 -21
  54. package/lib/types.d.ts.map +1 -1
  55. package/lib/types.js.map +1 -1
  56. package/lib/utils.d.ts +7 -14
  57. package/lib/utils.d.ts.map +1 -1
  58. package/lib/utils.js.map +1 -1
  59. package/package.json +49 -29
  60. package/src/compatibilityConfiguration.ts +44 -0
  61. package/src/fluidContainer.ts +24 -21
  62. package/src/index.ts +13 -15
  63. package/src/rootDataObject.ts +38 -41
  64. package/src/serviceAudience.ts +5 -10
  65. package/src/types.ts +20 -23
  66. package/src/utils.ts +10 -22
  67. package/tsconfig.json +1 -0
  68. package/tsdoc.json +4 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @fluidframework/fluid-static
2
2
 
3
+ ## 2.0.0-rc.5.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fluid-framework: Type Erase ISharedObjectKind ([#21081](https://github.com/microsoft/FluidFramework/pull/21081)) [78f228e370](https://github.com/microsoft/FluidFramework/commit/78f228e37055bd4d9a8f02b3a1eefebf4da9c59c)
8
+
9
+ A new type, `SharedObjectKind` is added as a type erased version of `ISharedObjectKind` and `DataObjectClass`.
10
+
11
+ This type fills the role of both `ISharedObjectKind` and `DataObjectClass` in the `@public` "declarative API" exposed in the `fluid-framework` package.
12
+
13
+ This allows several types referenced by `ISharedObjectKind` to be made `@alpha` as they should only need to be used by legacy code and users of the unstable/alpha/legacy "encapsulated API".
14
+
15
+ Access to these now less public types should not be required for users of the `@public` "declarative API" exposed in the `fluid-framework` package, but can still be accessed for those who need them under the `/legacy` import paths.
16
+ The full list of such types is:
17
+
18
+ - `SharedTree` as exported from `@fluidframwork/tree`: It is still exported as `@public` from `fluid-framework` as `SharedObjectKind`.
19
+ - `ISharedObjectKind`: See new `SharedObjectKind` type for use in `@public` APIs.
20
+ `ISharedObject`
21
+ - `IChannel`
22
+ - `IChannelAttributes`
23
+ - `IChannelFactory`
24
+ - `IExperimentalIncrementalSummaryContext`
25
+ - `IGarbageCollectionData`
26
+ - `ISummaryStats`
27
+ - `ISummaryTreeWithStats`
28
+ - `ITelemetryContext`
29
+ - `IDeltaManagerErased`
30
+ - `IFluidDataStoreRuntimeEvents`
31
+ - `IFluidHandleContext`
32
+ - `IProvideFluidHandleContext`
33
+
34
+ Removed APIs:
35
+
36
+ - `DataObjectClass`: Usages replaced with `SharedObjectKind`.
37
+ - `LoadableObjectClass`: Replaced with `SharedObjectKind`.
38
+ - `LoadableObjectClassRecord`: Replaced with `Record<string, SharedObjectKind>`.
39
+ -
40
+
41
+ - Update to TypeScript 5.4 ([#21214](https://github.com/microsoft/FluidFramework/pull/21214)) [0e6256c722](https://github.com/microsoft/FluidFramework/commit/0e6256c722d8bf024f4325bf02547daeeb18bfa6)
42
+
43
+ Update package implementations to use TypeScript 5.4.5.
44
+
45
+ - azure-client, tinylicious-client: compatibilityMode parameter added to createContainer and getContainer on AzureClient and TinyliciousClient ([#20997](https://github.com/microsoft/FluidFramework/pull/20997)) [2730787209](https://github.com/microsoft/FluidFramework/commit/2730787209a60155752d51da3c78cf97e1b5f3f9)
46
+
47
+ To support migration from 1.x to 2.0, a compatibility mode parameter has been added to these methods on AzureClient and TinyliciousClient. When set to "1", this allows interop between the 2.0 clients and 1.x clients. When set to "2", interop with 1.x clients is disallowed but new 2.0 features may be used.
48
+
3
49
  ## 2.0.0-rc.4.0.0
4
50
 
5
51
  ### Minor Changes
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/dist/public.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
5
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-base.esm.no-legacy.json"
4
4
  }
@@ -1,4 +1,4 @@
1
- ## API Report File for "@fluidframework/fluid-static"
1
+ ## Alpha API Report File for "@fluidframework/fluid-static"
2
2
 
3
3
  > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
4
 
@@ -6,48 +6,27 @@
6
6
 
7
7
  import { AttachState } from '@fluidframework/container-definitions';
8
8
  import { ConnectionState } from '@fluidframework/container-definitions';
9
- import { IClient } from '@fluidframework/protocol-definitions';
10
- import { IContainer } from '@fluidframework/container-definitions/internal';
9
+ import type { IClient } from '@fluidframework/driver-definitions';
10
+ import type { IContainer } from '@fluidframework/container-definitions/internal';
11
11
  import { ICriticalContainerError } from '@fluidframework/container-definitions';
12
- import { IEvent } from '@fluidframework/core-interfaces';
13
- import { IEventProvider } from '@fluidframework/core-interfaces';
14
- import { IFluidLoadable } from '@fluidframework/core-interfaces';
15
- import { IRuntimeFactory } from '@fluidframework/container-definitions/internal';
16
- import { ISharedObjectKind } from '@fluidframework/shared-object-base';
12
+ import type { IEvent } from '@fluidframework/core-interfaces';
13
+ import type { IEventProvider } from '@fluidframework/core-interfaces';
14
+ import type { IFluidLoadable } from '@fluidframework/core-interfaces';
15
+ import type { IRuntimeFactory } from '@fluidframework/container-definitions/internal';
16
+ import type { SharedObjectKind } from '@fluidframework/shared-object-base';
17
+
18
+ // @public
19
+ export type CompatibilityMode = "1" | "2";
17
20
 
18
21
  // @public
19
22
  export type ContainerAttachProps<T = unknown> = T;
20
23
 
21
24
  // @public
22
25
  export interface ContainerSchema {
23
- readonly dynamicObjectTypes?: readonly LoadableObjectClass[];
24
- readonly initialObjects: LoadableObjectClassRecord;
26
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
27
+ readonly initialObjects: Record<string, SharedObjectKind>;
25
28
  }
26
29
 
27
- // @internal
28
- export function createDOProviderContainerRuntimeFactory(props: {
29
- schema: ContainerSchema;
30
- }): IRuntimeFactory;
31
-
32
- // @internal
33
- export function createFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>(props: {
34
- container: IContainer;
35
- rootDataObject: IRootDataObject;
36
- }): IFluidContainer<TContainerSchema>;
37
-
38
- // @internal
39
- export function createServiceAudience<TMember extends IMember = IMember>(props: {
40
- container: IContainer;
41
- createServiceMember: (audienceMember: IClient) => TMember;
42
- }): IServiceAudience<TMember>;
43
-
44
- // @public
45
- export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
46
- readonly factory: {
47
- readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"];
48
- };
49
- } & (new (...args: any[]) => T);
50
-
51
30
  // @public
52
31
  export interface IConnection {
53
32
  readonly id: string;
@@ -60,7 +39,7 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
60
39
  readonly attachState: AttachState;
61
40
  connect(): void;
62
41
  readonly connectionState: ConnectionState;
63
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
42
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
64
43
  disconnect(): void;
65
44
  dispose(): void;
66
45
  readonly disposed: boolean;
@@ -85,21 +64,9 @@ export interface IMember {
85
64
 
86
65
  // @public
87
66
  export type InitialObjects<T extends ContainerSchema> = {
88
- [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
67
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
89
68
  };
90
69
 
91
- // @internal (undocumented)
92
- export interface IProvideRootDataObject {
93
- // (undocumented)
94
- readonly IRootDataObject: IRootDataObject;
95
- }
96
-
97
- // @internal
98
- export interface IRootDataObject extends IProvideRootDataObject {
99
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
100
- readonly initialObjects: LoadableObjectRecord;
101
- }
102
-
103
70
  // @public
104
71
  export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
105
72
  getMembers(): ReadonlyMap<string, M>;
@@ -116,15 +83,6 @@ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
116
83
  (event: "memberRemoved", listener: MemberChangedListener<M>): void;
117
84
  }
118
85
 
119
- // @public
120
- export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = ISharedObjectKind<T> | DataObjectClass<T>;
121
-
122
- // @public
123
- export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
124
-
125
- // @internal
126
- export type LoadableObjectRecord = Record<string, IFluidLoadable>;
127
-
128
86
  // @public
129
87
  export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
130
88
 
@@ -0,0 +1,94 @@
1
+ ## Beta API Report File for "@fluidframework/fluid-static"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { AttachState } from '@fluidframework/container-definitions';
8
+ import { ConnectionState } from '@fluidframework/container-definitions';
9
+ import type { IClient } from '@fluidframework/driver-definitions';
10
+ import type { IContainer } from '@fluidframework/container-definitions/internal';
11
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
12
+ import type { IEvent } from '@fluidframework/core-interfaces';
13
+ import type { IEventProvider } from '@fluidframework/core-interfaces';
14
+ import type { IFluidLoadable } from '@fluidframework/core-interfaces';
15
+ import type { IRuntimeFactory } from '@fluidframework/container-definitions/internal';
16
+ import type { SharedObjectKind } from '@fluidframework/shared-object-base';
17
+
18
+ // @public
19
+ export type CompatibilityMode = "1" | "2";
20
+
21
+ // @public
22
+ export type ContainerAttachProps<T = unknown> = T;
23
+
24
+ // @public
25
+ export interface ContainerSchema {
26
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
27
+ readonly initialObjects: Record<string, SharedObjectKind>;
28
+ }
29
+
30
+ // @public
31
+ export interface IConnection {
32
+ readonly id: string;
33
+ readonly mode: "write" | "read";
34
+ }
35
+
36
+ // @public @sealed
37
+ export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
38
+ attach(props?: ContainerAttachProps): Promise<string>;
39
+ readonly attachState: AttachState;
40
+ connect(): void;
41
+ readonly connectionState: ConnectionState;
42
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
43
+ disconnect(): void;
44
+ dispose(): void;
45
+ readonly disposed: boolean;
46
+ readonly initialObjects: InitialObjects<TContainerSchema>;
47
+ readonly isDirty: boolean;
48
+ }
49
+
50
+ // @public @sealed
51
+ export interface IFluidContainerEvents extends IEvent {
52
+ (event: "connected", listener: () => void): void;
53
+ (event: "disconnected", listener: () => void): void;
54
+ (event: "saved", listener: () => void): void;
55
+ (event: "dirty", listener: () => void): void;
56
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
57
+ }
58
+
59
+ // @public
60
+ export interface IMember {
61
+ readonly connections: IConnection[];
62
+ readonly id: string;
63
+ }
64
+
65
+ // @public
66
+ export type InitialObjects<T extends ContainerSchema> = {
67
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
68
+ };
69
+
70
+ // @public
71
+ export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
72
+ getMembers(): ReadonlyMap<string, M>;
73
+ getMyself(): Myself<M> | undefined;
74
+ }
75
+
76
+ // @public
77
+ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
78
+ // @eventProperty
79
+ (event: "membersChanged", listener: () => void): void;
80
+ // @eventProperty
81
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
82
+ // @eventProperty
83
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
84
+ }
85
+
86
+ // @public
87
+ export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
88
+
89
+ // @public
90
+ export type Myself<M extends IMember = IMember> = M & {
91
+ readonly currentConnection: string;
92
+ };
93
+
94
+ ```
@@ -0,0 +1,94 @@
1
+ ## Public API Report File for "@fluidframework/fluid-static"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ import { AttachState } from '@fluidframework/container-definitions';
8
+ import { ConnectionState } from '@fluidframework/container-definitions';
9
+ import type { IClient } from '@fluidframework/driver-definitions';
10
+ import type { IContainer } from '@fluidframework/container-definitions/internal';
11
+ import { ICriticalContainerError } from '@fluidframework/container-definitions';
12
+ import type { IEvent } from '@fluidframework/core-interfaces';
13
+ import type { IEventProvider } from '@fluidframework/core-interfaces';
14
+ import type { IFluidLoadable } from '@fluidframework/core-interfaces';
15
+ import type { IRuntimeFactory } from '@fluidframework/container-definitions/internal';
16
+ import type { SharedObjectKind } from '@fluidframework/shared-object-base';
17
+
18
+ // @public
19
+ export type CompatibilityMode = "1" | "2";
20
+
21
+ // @public
22
+ export type ContainerAttachProps<T = unknown> = T;
23
+
24
+ // @public
25
+ export interface ContainerSchema {
26
+ readonly dynamicObjectTypes?: readonly SharedObjectKind[];
27
+ readonly initialObjects: Record<string, SharedObjectKind>;
28
+ }
29
+
30
+ // @public
31
+ export interface IConnection {
32
+ readonly id: string;
33
+ readonly mode: "write" | "read";
34
+ }
35
+
36
+ // @public @sealed
37
+ export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema> extends IEventProvider<IFluidContainerEvents> {
38
+ attach(props?: ContainerAttachProps): Promise<string>;
39
+ readonly attachState: AttachState;
40
+ connect(): void;
41
+ readonly connectionState: ConnectionState;
42
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
43
+ disconnect(): void;
44
+ dispose(): void;
45
+ readonly disposed: boolean;
46
+ readonly initialObjects: InitialObjects<TContainerSchema>;
47
+ readonly isDirty: boolean;
48
+ }
49
+
50
+ // @public @sealed
51
+ export interface IFluidContainerEvents extends IEvent {
52
+ (event: "connected", listener: () => void): void;
53
+ (event: "disconnected", listener: () => void): void;
54
+ (event: "saved", listener: () => void): void;
55
+ (event: "dirty", listener: () => void): void;
56
+ (event: "disposed", listener: (error?: ICriticalContainerError) => void): any;
57
+ }
58
+
59
+ // @public
60
+ export interface IMember {
61
+ readonly connections: IConnection[];
62
+ readonly id: string;
63
+ }
64
+
65
+ // @public
66
+ export type InitialObjects<T extends ContainerSchema> = {
67
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
68
+ };
69
+
70
+ // @public
71
+ export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
72
+ getMembers(): ReadonlyMap<string, M>;
73
+ getMyself(): Myself<M> | undefined;
74
+ }
75
+
76
+ // @public
77
+ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
78
+ // @eventProperty
79
+ (event: "membersChanged", listener: () => void): void;
80
+ // @eventProperty
81
+ (event: "memberAdded", listener: MemberChangedListener<M>): void;
82
+ // @eventProperty
83
+ (event: "memberRemoved", listener: MemberChangedListener<M>): void;
84
+ }
85
+
86
+ // @public
87
+ export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
88
+
89
+ // @public
90
+ export type Myself<M extends IMember = IMember> = M & {
91
+ readonly currentConnection: string;
92
+ };
93
+
94
+ ```
package/biome.jsonc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["../../../biome.jsonc"]
4
+ }
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
6
+ import type { CompatibilityMode } from "./types.js";
7
+ /**
8
+ * The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
9
+ * full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
10
+ */
11
+ export declare const compatibilityModeRuntimeOptions: Record<CompatibilityMode, IContainerRuntimeOptions>;
12
+ //# sourceMappingURL=compatibilityConfiguration.d.ts.map
@@ -0,0 +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,CAwBxB,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.compatibilityModeRuntimeOptions = void 0;
8
+ const internal_1 = require("@fluidframework/container-runtime/internal");
9
+ const internal_2 = require("@fluidframework/runtime-definitions/internal");
10
+ /**
11
+ * The CompatibilityMode selected determines the set of runtime options to use. In "1" mode we support
12
+ * full interop with true 1.x clients, while in "2" mode we only support interop with 2.x clients.
13
+ */
14
+ exports.compatibilityModeRuntimeOptions = {
15
+ "1": {
16
+ // 1.x clients are compatible with TurnBased flushing, but here we elect to remain on Immediate flush mode
17
+ // as a work-around for inability to send batches larger than 1Mb. Immediate flushing keeps batches smaller as
18
+ // fewer messages will be included per flush.
19
+ flushMode: internal_2.FlushMode.Immediate,
20
+ // Op compression is on by default but introduces a new type of op which is not compatible with 1.x clients.
21
+ compressionOptions: {
22
+ minimumBatchSizeInBytes: Number.POSITIVE_INFINITY, // disabled
23
+ compressionAlgorithm: internal_1.CompressionAlgorithms.lz4,
24
+ },
25
+ // Grouped batching is on by default but introduces a new type of op which is not compatible with 1.x clients.
26
+ enableGroupedBatching: false,
27
+ // TODO: Include explicit disables for things that are currently off-by-default?
28
+ },
29
+ "2": {
30
+ // Explicit schema control explicitly makes the container incompatible with 1.x clients, to force their
31
+ // ejection from collaboration and prevent container corruption. It is off by default and must be explicitly enabled.
32
+ explicitSchemaControl: true,
33
+ // The runtime ID compressor is a prerequisite to use SharedTree but is off by default and must be explicitly enabled.
34
+ // It introduces a new type of op which is not compatible with 1.x clients.
35
+ enableRuntimeIdCompressor: "on",
36
+ },
37
+ };
38
+ //# sourceMappingURL=compatibilityConfiguration.js.map
@@ -0,0 +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;KAChF;IACD,GAAG,EAAE;QACJ,uGAAuG;QACvG,sHAAsH;QACtH,qBAAqB,EAAE,IAAI;QAC3B,sHAAsH;QACtH,2EAA2E;QAC3E,yBAAyB,EAAE,IAAI;KAC/B;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\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},\n};\n"]}
@@ -3,15 +3,16 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { AttachState, type ConnectionState, type ICriticalContainerError } from "@fluidframework/container-definitions";
6
- import { type IContainer } from "@fluidframework/container-definitions/internal";
7
- import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import type { ContainerAttachProps, ContainerSchema, IRootDataObject, LoadableObjectClass } from "./types.js";
6
+ import type { IContainer } from "@fluidframework/container-definitions/internal";
7
+ import type { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
8
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
9
+ import type { ContainerAttachProps, ContainerSchema, IRootDataObject } from "./types.js";
9
10
  /**
10
11
  * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
11
12
  * @public
12
13
  */
13
14
  export type InitialObjects<T extends ContainerSchema> = {
14
- [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends LoadableObjectClass<infer TChannel> ? TChannel : never;
15
+ [K in keyof T["initialObjects"]]: T["initialObjects"][K] extends SharedObjectKind<infer TChannel> ? TChannel : never;
15
16
  };
16
17
  /**
17
18
  * Events emitted from {@link IFluidContainer}.
@@ -168,17 +169,28 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
168
169
  /**
169
170
  * Create a new data object or Distributed Data Store (DDS) of the specified type.
170
171
  *
172
+ * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
173
+ *
174
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
175
+ *
171
176
  * @remarks
172
177
  *
173
- * In order to share the data object or DDS with other
174
- * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your
175
- * initialObjects.
178
+ * In order to share the data object or DDS with other collaborators and retrieve it later,
179
+ * store its handle in a collection like a SharedDirectory from your initialObjects.
180
+ * It's typically a good idea to set any initial state on the object before doing so,
181
+ * as it is both more efficient and helpful to maintain domain model invariants
182
+ * (e.g. this approach easily allows state to only be set once).
176
183
  *
177
- * @param objectClass - The class of the `DataObject` or `SharedObject` to create.
184
+ * @example
178
185
  *
179
- * @typeParam T - The class of the `DataObject` or `SharedObject`.
186
+ * ```typescript
187
+ * const existingDirectory = container.initialObjects.myDirectory;
188
+ * const map = await container.create(SharedMap);
189
+ * map.set("initialState", "someValue");
190
+ * existingDirectory.set("myMap", map.handle);
191
+ * ```
180
192
  */
181
- create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
193
+ create<T extends IFluidLoadable>(objectClass: SharedObjectKind<T>): Promise<T>;
182
194
  /**
183
195
  * Dispose of the container instance, permanently disabling it.
184
196
  */
@@ -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,EAAE,KAAK,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EACN,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EACX,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,eAAe,IAAI;KAMtD,CAAC,IAAI,MAAM,CAAC,CAAC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CAAC;SAChF;QACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;QACtB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAA2B,WAAmC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,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 {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\n\nimport type {\n\tContainerAttachProps,\n\tContainerSchema,\n\tIRootDataObject,\n\tLoadableObjectClass,\n} from \"./types.js\";\n\n/**\n * Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.\n * @public\n */\nexport type InitialObjects<T extends ContainerSchema> = {\n\t// Construct a LoadableObjectRecord type by enumerating the keys of\n\t// 'ContainerSchema.initialObjects' and inferring the value type of each key.\n\t//\n\t// The '? TChannel : never' is required because infer can only be used in\n\t// a conditional 'extends' expression.\n\t[K in keyof T[\"initialObjects\"]]: T[\"initialObjects\"][K] extends LoadableObjectClass<\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 * @remarks\n\t *\n\t * In order to share the data object or DDS with other\n\t * collaborators and retrieve it later, store its handle in a collection like a SharedDirectory from your\n\t * initialObjects.\n\t *\n\t * @param objectClass - The class of the `DataObject` or `SharedObject` to create.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n\n\t/**\n\t * Dispose of the container instance, permanently disabling it.\n\t */\n\tdispose(): void;\n}\n\n/**\n * 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 * @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead\n * @internal\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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- AB#7608\n\t\tif (this.container.attachState !== AttachState.Detached) {\n\t\t\tthrow new Error(\"Cannot attach container. Container is not in detached state.\");\n\t\t}\n\t\tthrow new Error(\"Cannot attach container. Attach method not provided.\");\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.connect}\n\t */\n\tpublic async connect(): Promise<void> {\n\t\tthis.container.connect?.();\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.connect}\n\t */\n\tpublic async disconnect(): Promise<void> {\n\t\tthis.container.disconnect?.();\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.create}\n\t */\n\tpublic async create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T> {\n\t\treturn this.rootDataObject.create(objectClass);\n\t}\n\n\t/**\n\t * {@inheritDoc IFluidContainer.dispose}\n\t */\n\tpublic dispose(): 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;AA8N/C;;;;GAIG;AACH,SAAgB,oBAAoB,CAElC,KAGD;IACA,OAAO,IAAI,cAAc,CAAmB,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;AACpF,CAAC;AAPD,oDAOC;AAED;;;;;;;;;;GAUG;AACH,MAAM,cACL,SAAQ,gCAAwC;IAUhD,YACkB,SAAqB,EACrB,cAA+B;QAEhD,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,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;QAsGlE;;;;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CAAC,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU;QACtB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAA2B,WAAgC;QAC7E,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,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 * @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead\n * @internal\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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- AB#7608\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"]}
package/dist/index.d.ts CHANGED
@@ -10,5 +10,5 @@
10
10
  export { createFluidContainer, type IFluidContainer, type IFluidContainerEvents, type InitialObjects, } from "./fluidContainer.js";
11
11
  export { createDOProviderContainerRuntimeFactory } from "./rootDataObject.js";
12
12
  export { createServiceAudience } from "./serviceAudience.js";
13
- export { type ContainerSchema, type ContainerAttachProps, type DataObjectClass, type IConnection, type IMember, type IRootDataObject, type IServiceAudience, type IServiceAudienceEvents, type LoadableObjectClass, type LoadableObjectClassRecord, type LoadableObjectRecord, type MemberChangedListener, type Myself, type IProvideRootDataObject, } from "./types.js";
13
+ export type { CompatibilityMode, ContainerSchema, ContainerAttachProps, IConnection, IMember, IProvideRootDataObject, IRootDataObject, IServiceAudience, IServiceAudienceEvents, LoadableObjectRecord, MemberChangedListener, Myself, } from "./types.js";
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -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,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,MAAM,EACX,KAAK,sBAAsB,GAC3B,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,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"}
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,yDAK6B;AAJ5B,yHAAA,oBAAoB,OAAA;AAKrB,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\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\n\ttype InitialObjects,\n} from \"./fluidContainer.js\";\nexport { createDOProviderContainerRuntimeFactory } from \"./rootDataObject.js\";\nexport { createServiceAudience } from \"./serviceAudience.js\";\nexport {\n\ttype ContainerSchema,\n\ttype ContainerAttachProps,\n\ttype DataObjectClass,\n\ttype IConnection,\n\ttype IMember,\n\ttype IRootDataObject,\n\ttype IServiceAudience,\n\ttype IServiceAudienceEvents,\n\ttype LoadableObjectClass,\n\ttype LoadableObjectClassRecord,\n\ttype LoadableObjectRecord,\n\ttype MemberChangedListener,\n\ttype Myself,\n\ttype IProvideRootDataObject,\n} from \"./types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH,yDAK6B;AAJ5B,yHAAA,oBAAoB,OAAA;AAKrB,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\ttype IFluidContainer,\n\ttype IFluidContainerEvents,\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"]}