@fluidframework/fluid-static 2.0.0-internal.2.0.3 → 2.0.0-internal.2.1.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.
Files changed (42) hide show
  1. package/dist/fluidContainer.d.ts +44 -66
  2. package/dist/fluidContainer.d.ts.map +1 -1
  3. package/dist/fluidContainer.js.map +1 -1
  4. package/dist/index.d.ts +4 -4
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +8 -14
  7. package/dist/index.js.map +1 -1
  8. package/dist/rootDataObject.d.ts +4 -10
  9. package/dist/rootDataObject.d.ts.map +1 -1
  10. package/dist/rootDataObject.js +6 -11
  11. package/dist/rootDataObject.js.map +1 -1
  12. package/dist/serviceAudience.d.ts +2 -2
  13. package/dist/serviceAudience.d.ts.map +1 -1
  14. package/dist/serviceAudience.js +6 -1
  15. package/dist/serviceAudience.js.map +1 -1
  16. package/dist/types.d.ts +25 -1
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/types.js.map +1 -1
  19. package/lib/fluidContainer.d.ts +44 -66
  20. package/lib/fluidContainer.d.ts.map +1 -1
  21. package/lib/fluidContainer.js.map +1 -1
  22. package/lib/index.d.ts +4 -4
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/index.js +3 -4
  25. package/lib/index.js.map +1 -1
  26. package/lib/rootDataObject.d.ts +4 -10
  27. package/lib/rootDataObject.d.ts.map +1 -1
  28. package/lib/rootDataObject.js +6 -11
  29. package/lib/rootDataObject.js.map +1 -1
  30. package/lib/serviceAudience.d.ts +2 -2
  31. package/lib/serviceAudience.d.ts.map +1 -1
  32. package/lib/serviceAudience.js +6 -1
  33. package/lib/serviceAudience.js.map +1 -1
  34. package/lib/types.d.ts +25 -1
  35. package/lib/types.d.ts.map +1 -1
  36. package/lib/types.js.map +1 -1
  37. package/package.json +19 -21
  38. package/src/fluidContainer.ts +50 -67
  39. package/src/index.ts +19 -4
  40. package/src/rootDataObject.ts +7 -12
  41. package/src/serviceAudience.ts +11 -3
  42. package/src/types.ts +28 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.0.0-internal.2.0.3",
3
+ "version": "2.0.0-internal.2.1.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": {
@@ -34,8 +34,6 @@
34
34
  "test:mocha": "mocha --recursive dist/test/**/*.spec.js -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
35
35
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
36
36
  "tsc": "tsc",
37
- "tsfmt": "tsfmt --verify",
38
- "tsfmt:fix": "tsfmt --replace",
39
37
  "typetests:gen": "fluid-type-validator -g -d ."
40
38
  },
41
39
  "nyc": {
@@ -59,27 +57,28 @@
59
57
  "temp-directory": "nyc/.nyc_output"
60
58
  },
61
59
  "dependencies": {
62
- "@fluidframework/aqueduct": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
60
+ "@fluidframework/aqueduct": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
63
61
  "@fluidframework/common-definitions": "^0.20.1",
64
62
  "@fluidframework/common-utils": "^1.0.0",
65
- "@fluidframework/container-definitions": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
66
- "@fluidframework/container-loader": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
67
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
68
- "@fluidframework/core-interfaces": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
69
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
63
+ "@fluidframework/container-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
64
+ "@fluidframework/container-loader": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
65
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
66
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
67
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
70
68
  "@fluidframework/protocol-definitions": "^1.1.0",
71
- "@fluidframework/request-handler": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
72
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
73
- "@fluidframework/runtime-utils": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0"
69
+ "@fluidframework/request-handler": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
70
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
71
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0"
74
72
  },
75
73
  "devDependencies": {
76
- "@fluidframework/build-common": "^1.0.0",
77
- "@fluidframework/build-tools": "^0.4.6000",
78
- "@fluidframework/eslint-config-fluid": "^1.0.0",
74
+ "@fluid-tools/build-cli": "^0.5.0",
75
+ "@fluidframework/build-common": "^1.1.0",
76
+ "@fluidframework/build-tools": "^0.5.0",
77
+ "@fluidframework/eslint-config-fluid": "^1.1.0",
79
78
  "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.2.0.0",
80
- "@fluidframework/map": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
81
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
82
- "@fluidframework/sequence": ">=2.0.0-internal.2.0.3 <2.0.0-internal.3.0.0",
79
+ "@fluidframework/map": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
80
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
81
+ "@fluidframework/sequence": ">=2.0.0-internal.2.1.0 <2.0.0-internal.3.0.0",
83
82
  "@microsoft/api-extractor": "^7.22.2",
84
83
  "@rushstack/eslint-config": "^2.5.1",
85
84
  "@types/mocha": "^9.1.1",
@@ -91,11 +90,10 @@
91
90
  "mocha": "^10.0.0",
92
91
  "nyc": "^15.0.0",
93
92
  "rimraf": "^2.6.2",
94
- "typescript": "~4.5.5",
95
- "typescript-formatter": "7.1.0"
93
+ "typescript": "~4.5.5"
96
94
  },
97
95
  "typeValidation": {
98
- "version": "2.0.0-internal.2.0.1",
96
+ "version": "2.0.0-internal.2.1.0",
99
97
  "broken": {}
100
98
  }
101
99
  }
@@ -11,85 +11,68 @@ import {
11
11
  ICriticalContainerError,
12
12
  ConnectionState,
13
13
  } from "@fluidframework/container-definitions";
14
- import { LoadableObjectClass, LoadableObjectRecord } from "./types";
15
- import { RootDataObject } from "./rootDataObject";
14
+ import type { IRootDataObject, LoadableObjectClass, LoadableObjectRecord } from "./types";
16
15
 
17
16
  /**
18
17
  * Events emitted from {@link IFluidContainer}.
19
- *
20
- * @remarks
21
- *
22
- * The following is the list of events emitted.
23
- *
24
- * ### "connected"
25
- *
26
- * The "connected" event is emitted when the `IFluidContainer` completes connecting to the Fluid service.
27
- *
28
- * #### Listener signature
29
- *
30
- * ```typescript
31
- * () => void;
32
- * ```
33
- *
34
- * ### "disposed"
35
- *
36
- * The "disposed" event is emitted when the `IFluidContainer` is disposed, which permanently disables it.
37
- *
38
- * #### Listener signature
39
- *
40
- * ```typescript
41
- * () => void;
42
- * ```
43
- *
44
- * ### "disconnected"
45
- *
46
- * The "disconnected" event is emitted when the `IFluidContainer` becomes disconnected from the Fluid service.
47
- *
48
- * #### Listener signature
49
- *
50
- * ```typescript
51
- * () => void;
52
- * ```
53
- *
54
- * ### "saved"
55
- *
56
- * The "saved" event is emitted when the `IFluidContainer` has local changes acknowledged by the service.
57
- *
58
- * #### Listener signature
59
- *
60
- * ```typescript
61
- * () => void
62
- * ```
63
- *
64
- * ### "dirty"
65
- *
66
- * The "dirty" event is emitted when the `IFluidContainer` has local changes that have not yet
67
- * been acknowledged by the service.
68
- *
69
- * #### Listener signature
70
- *
71
- * ```typescript
72
- * () => void
73
- * ```
74
18
  */
19
+ /* eslint-disable @typescript-eslint/unified-signatures */
75
20
  export interface IFluidContainerEvents extends IEvent {
76
21
  /**
77
- * **connected** & **disconnected** events reflect connection state changes against the (delta)
78
- * service acknowledging ops/edits.
22
+ * Emitted when the {@link IFluidContainer} completes connecting to the Fluid service.
23
+ *
24
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
25
+ *
26
+ * @see
27
+ *
28
+ * - {@link IFluidContainer.connectionState}
29
+ *
30
+ * - {@link IFluidContainer.disconnect}
79
31
  */
80
- (event: "connected" | "disconnected", listener: () => void): void;
32
+ (event: "connected", listener: () => void): void;
33
+
81
34
  /**
82
- * **saved** event is raised when all local changes/edits have been acknowledged by the service.
83
- * **dirty** event is raised when first local change has been made, following a "saved" state.
35
+ * Emitted when the {@link IFluidContainer} becomes disconnected from the Fluid service.
36
+ *
37
+ * @remarks Reflects connection state changes against the (delta) service acknowledging ops/edits.
38
+ *
39
+ * @see
40
+ *
41
+ * - {@link IFluidContainer.connectionState}
42
+ *
43
+ * - {@link IFluidContainer.disconnect}
84
44
  */
85
- // eslint-disable-next-line @typescript-eslint/unified-signatures
86
- (event: "saved" | "dirty", listener: () => void): void;
45
+ (event: "disconnected", listener: () => void): void;
46
+
87
47
  /**
88
- * Disposed event is raised when container is closed. If container was closed due to error
89
- * (vs explicit **dispose** action), optional argument contains further details about the error.
48
+ * Emitted when all local changes/edits have been acknowledged by the service.
49
+ *
50
+ * @remarks "dirty" event will be emitted when the next local change has been made.
51
+ *
52
+ * @see {@link IFluidContainer.isDirty}
53
+ */
54
+ (event: "saved", listener: () => void): void;
55
+
56
+ /**
57
+ * Emitted when the first local change has been made, following a "saved" event.
58
+ *
59
+ * @remarks "saved" event will be emitted once all local changes have been acknowledged by the service.
60
+ *
61
+ * @see {@link IFluidContainer.isDirty}
62
+ */
63
+ (event: "dirty", listener: () => void): void;
64
+
65
+ /**
66
+ * Emitted when the {@link IFluidContainer} is closed, which permanently disables it.
67
+ *
68
+ * @remarks
69
+ *
70
+ * If container was closed due to error (as opposed to an explicit call to
71
+ * {@link IFluidContainer.dispose}), optional argument contains further details about the error.
90
72
  */
91
73
  (event: "disposed", listener: (error?: ICriticalContainerError) => void);
92
74
  }
75
+ /* eslint-enable @typescript-eslint/unified-signatures */
93
76
 
94
77
  /**
95
78
  * Provides an entrypoint into the client side of collaborative Fluid data.
@@ -223,7 +206,7 @@ export class FluidContainer extends TypedEventEmitter<IFluidContainerEvents> imp
223
206
 
224
207
  public constructor(
225
208
  private readonly container: IContainer,
226
- private readonly rootDataObject: RootDataObject,
209
+ private readonly rootDataObject: IRootDataObject,
227
210
  ) {
228
211
  super();
229
212
  container.on("connected", this.connectedHandler);
package/src/index.ts CHANGED
@@ -9,7 +9,22 @@
9
9
  * @packageDocumentation
10
10
  */
11
11
 
12
- export * from "./fluidContainer";
13
- export * from "./rootDataObject";
14
- export * from "./serviceAudience";
15
- export * from "./types";
12
+ export { FluidContainer, IFluidContainer, IFluidContainerEvents } from "./fluidContainer";
13
+ export { DOProviderContainerRuntimeFactory, RootDataObject, RootDataObjectProps } from "./rootDataObject";
14
+ export { ServiceAudience } from "./serviceAudience";
15
+ export {
16
+ ContainerSchema,
17
+ DataObjectClass,
18
+ IConnection,
19
+ IMember,
20
+ IRootDataObject,
21
+ IServiceAudience,
22
+ IServiceAudienceEvents,
23
+ LoadableObjectClass,
24
+ LoadableObjectClassRecord,
25
+ LoadableObjectCtor,
26
+ LoadableObjectRecord,
27
+ MemberChangedListener,
28
+ SharedObjectClass,
29
+ Myself,
30
+ } from "./types";
@@ -11,10 +11,10 @@ import {
11
11
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
12
12
  import { IFluidLoadable } from "@fluidframework/core-interfaces";
13
13
  import { FlushMode } from "@fluidframework/runtime-definitions";
14
- import { requestFluidObject } from "@fluidframework/runtime-utils";
15
14
  import {
16
15
  ContainerSchema,
17
16
  DataObjectClass,
17
+ IRootDataObject,
18
18
  LoadableObjectClass,
19
19
  LoadableObjectClassRecord,
20
20
  LoadableObjectRecord,
@@ -38,7 +38,7 @@ export interface RootDataObjectProps {
38
38
  * The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
39
39
  * Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
40
40
  */
41
- export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> {
41
+ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectProps; }> implements IRootDataObject {
42
42
  private readonly initialObjectsDirKey = "initial-objects-key";
43
43
  private readonly _initialObjects: LoadableObjectRecord = {};
44
44
 
@@ -93,9 +93,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
93
93
  }
94
94
 
95
95
  /**
96
- * Provides a record of the initial objects defined on creation.
97
- *
98
- * @see {@link RootDataObject.initializingFirstTime}
96
+ * {@inheritDoc IRootDataObject.initialObjects}
99
97
  */
100
98
  public get initialObjects(): LoadableObjectRecord {
101
99
  if (Object.keys(this._initialObjects).length === 0) {
@@ -105,11 +103,7 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
105
103
  }
106
104
 
107
105
  /**
108
- * Dynamically creates a new detached collaborative object (DDS/DataObject).
109
- *
110
- * @param objectClass - Type of the collaborative object to be created.
111
- *
112
- * @typeParam T - The class of the `DataObject` or `SharedObject`.
106
+ * {@inheritDoc IRootDataObject.create}
113
107
  */
114
108
  public async create<T extends IFluidLoadable>(
115
109
  objectClass: LoadableObjectClass<T>,
@@ -125,8 +119,9 @@ export class RootDataObject extends DataObject<{ InitialState: RootDataObjectPro
125
119
  private async createDataObject<T extends IFluidLoadable>(dataObjectClass: DataObjectClass<T>): Promise<T> {
126
120
  const factory = dataObjectClass.factory;
127
121
  const packagePath = [...this.context.packagePath, factory.type];
128
- const router = await this.context.containerRuntime.createDataStore(packagePath);
129
- return requestFluidObject<T>(router, "/");
122
+ const dataStore = await this.context.containerRuntime.createDataStore(packagePath);
123
+ const entryPoint = await dataStore.entryPoint?.get();
124
+ return entryPoint as unknown as T;
130
125
  }
131
126
 
132
127
  private createSharedObject<T extends IFluidLoadable>(
@@ -6,7 +6,7 @@
6
6
  import { TypedEventEmitter } from "@fluidframework/common-utils";
7
7
  import { IAudience, IContainer } from "@fluidframework/container-definitions";
8
8
  import { IClient } from "@fluidframework/protocol-definitions";
9
- import { IServiceAudience, IServiceAudienceEvents, IMember } from "./types";
9
+ import { IServiceAudience, IServiceAudienceEvents, IMember, Myself } from "./types";
10
10
 
11
11
  /**
12
12
  * Base class for providing audience information for sessions interacting with {@link IFluidContainer}
@@ -112,12 +112,20 @@ export abstract class ServiceAudience<M extends IMember = IMember>
112
112
  /**
113
113
  * {@inheritDoc IServiceAudience.getMyself}
114
114
  */
115
- public getMyself(): M | undefined {
115
+ public getMyself(): Myself<M> | undefined {
116
116
  const clientId = this.container.clientId;
117
117
  if (clientId === undefined) {
118
118
  return undefined;
119
119
  }
120
- return this.getMember(clientId);
120
+
121
+ const member = this.getMember(clientId);
122
+ if (member === undefined) {
123
+ return undefined;
124
+ }
125
+
126
+ const myself: Myself<M> = { ...member, currentConnection: clientId };
127
+
128
+ return myself;
121
129
  }
122
130
 
123
131
  private getMember(clientId: string): M | undefined {
package/src/types.ts CHANGED
@@ -93,6 +93,26 @@ export interface ContainerSchema {
93
93
  dynamicObjectTypes?: LoadableObjectClass<any>[];
94
94
  }
95
95
 
96
+ /**
97
+ * Holds the collection of objects that the container was initially created with, as well as provides the ability
98
+ * to dynamically create further objects during usage.
99
+ */
100
+ export interface IRootDataObject {
101
+ /**
102
+ * Provides a record of the initial objects defined on creation.
103
+ */
104
+ readonly initialObjects: LoadableObjectRecord;
105
+
106
+ /**
107
+ * Dynamically creates a new detached collaborative object (DDS/DataObject).
108
+ *
109
+ * @param objectClass - Type of the collaborative object to be created.
110
+ *
111
+ * @typeParam T - The class of the `DataObject` or `SharedObject`.
112
+ */
113
+ create<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;
114
+ }
115
+
96
116
  /**
97
117
  * Signature for {@link IMember} change events.
98
118
  *
@@ -148,7 +168,8 @@ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
148
168
  *
149
169
  * @typeParam M - A service-specific {@link IMember} type.
150
170
  */
151
- export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
171
+ export interface IServiceAudience<M extends IMember>
172
+ extends IEventProvider<IServiceAudienceEvents<M>> {
152
173
  /**
153
174
  * Returns an map of all users currently in the Fluid session where key is the userId and the value is the
154
175
  * member object. The implementation may choose to exclude certain connections from the returned map.
@@ -159,7 +180,7 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
159
180
  /**
160
181
  * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
161
182
  */
162
- getMyself(): M | undefined;
183
+ getMyself(): Myself<M> | undefined;
163
184
  }
164
185
 
165
186
  /**
@@ -195,3 +216,8 @@ export interface IMember {
195
216
  */
196
217
  connections: IConnection[];
197
218
  }
219
+
220
+ /**
221
+ * An extended member object that includes currentConnection
222
+ */
223
+ export type Myself<M extends IMember = IMember> = M & { currentConnection: string; };