@fluidframework/fluid-static 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.1.0.0.232845

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 (62) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +1 -1
  2. package/api-report/fluid-static.api.md +10 -7
  3. package/dist/fluid-static-alpha.d.ts +11 -4
  4. package/dist/fluid-static-beta.d.ts +11 -4
  5. package/dist/fluid-static-public.d.ts +11 -4
  6. package/dist/fluid-static-untrimmed.d.ts +26 -7
  7. package/dist/fluidContainer.d.ts +9 -6
  8. package/dist/fluidContainer.d.ts.map +1 -1
  9. package/dist/fluidContainer.js +3 -1
  10. package/dist/fluidContainer.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/rootDataObject.d.ts +5 -2
  15. package/dist/rootDataObject.d.ts.map +1 -1
  16. package/dist/rootDataObject.js +7 -3
  17. package/dist/rootDataObject.js.map +1 -1
  18. package/dist/serviceAudience.d.ts +13 -6
  19. package/dist/serviceAudience.d.ts.map +1 -1
  20. package/dist/serviceAudience.js +12 -4
  21. package/dist/serviceAudience.js.map +1 -1
  22. package/dist/tsdoc-metadata.json +1 -1
  23. package/dist/types.d.ts +8 -3
  24. package/dist/types.d.ts.map +1 -1
  25. package/dist/types.js.map +1 -1
  26. package/dist/utils.d.ts +6 -6
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +6 -3
  29. package/dist/utils.js.map +1 -1
  30. package/lib/fluid-static-alpha.d.mts +11 -4
  31. package/lib/fluid-static-beta.d.mts +11 -4
  32. package/lib/fluid-static-public.d.mts +11 -4
  33. package/lib/fluid-static-untrimmed.d.mts +26 -7
  34. package/lib/fluidContainer.d.mts +9 -6
  35. package/lib/fluidContainer.d.mts.map +1 -1
  36. package/lib/fluidContainer.mjs +3 -1
  37. package/lib/fluidContainer.mjs.map +1 -1
  38. package/lib/index.d.mts +2 -2
  39. package/lib/index.d.mts.map +1 -1
  40. package/lib/index.mjs.map +1 -1
  41. package/lib/rootDataObject.d.mts +5 -2
  42. package/lib/rootDataObject.d.mts.map +1 -1
  43. package/lib/rootDataObject.mjs +7 -3
  44. package/lib/rootDataObject.mjs.map +1 -1
  45. package/lib/serviceAudience.d.mts +13 -6
  46. package/lib/serviceAudience.d.mts.map +1 -1
  47. package/lib/serviceAudience.mjs +12 -4
  48. package/lib/serviceAudience.mjs.map +1 -1
  49. package/lib/types.d.mts +8 -3
  50. package/lib/types.d.mts.map +1 -1
  51. package/lib/types.mjs.map +1 -1
  52. package/lib/utils.d.mts +6 -6
  53. package/lib/utils.d.mts.map +1 -1
  54. package/lib/utils.mjs +6 -3
  55. package/lib/utils.mjs.map +1 -1
  56. package/package.json +18 -18
  57. package/src/fluidContainer.ts +28 -16
  58. package/src/index.ts +19 -18
  59. package/src/rootDataObject.ts +45 -26
  60. package/src/serviceAudience.ts +35 -22
  61. package/src/types.ts +16 -3
  62. package/src/utils.ts +15 -12
package/src/types.ts CHANGED
@@ -3,8 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
7
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
6
+ import {
7
+ type IEvent,
8
+ type IEventProvider,
9
+ type IFluidLoadable,
10
+ } from "@fluidframework/core-interfaces";
11
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
8
12
 
9
13
  /**
10
14
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
@@ -14,9 +18,10 @@ export type LoadableObjectRecord = Record<string, IFluidLoadable>;
14
18
 
15
19
  /**
16
20
  * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
17
- * or `SharedObject` in a {@link LoadableObjectRecord}.
21
+ * or `SharedObject`.
18
22
  * @public
19
23
  */
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
25
  export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
21
26
 
22
27
  /**
@@ -57,8 +62,15 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
57
62
  * @typeParam T - The class of the loadable object.
58
63
  * @public
59
64
  */
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
66
  export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
61
67
 
68
+ /**
69
+ * Represents properties that can be attached to a container.
70
+ * @public
71
+ */
72
+ export type ContainerAttachProps<T = unknown> = T;
73
+
62
74
  /**
63
75
  * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.
64
76
  *
@@ -99,6 +111,7 @@ export interface ContainerSchema {
99
111
  * For best practice it's recommended to define all the dynamic types you create even if they are
100
112
  * included via initialObjects.
101
113
  */
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
115
  dynamicObjectTypes?: LoadableObjectClass<any>[];
103
116
  }
104
117
 
package/src/utils.ts CHANGED
@@ -3,13 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
6
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
7
  import {
8
- IFluidDataStoreFactory,
9
- NamedFluidDataStoreRegistryEntry,
8
+ type IFluidDataStoreFactory,
9
+ type NamedFluidDataStoreRegistryEntry,
10
10
  } from "@fluidframework/runtime-definitions";
11
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
12
- import { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from "./types";
11
+ import { type IFluidLoadable } from "@fluidframework/core-interfaces";
12
+ import { type ContainerSchema, type DataObjectClass, type SharedObjectClass } from "./types";
13
13
 
14
14
  /**
15
15
  * An internal type used by the internal type guard isDataObjectClass to cast a
@@ -23,8 +23,8 @@ export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<
23
23
  /**
24
24
  * Runtime check to determine if a class is a DataObject type
25
25
  */
26
- export const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFluidLoadable> => {
27
- const maybe: Partial<InternalDataObjectClass<IFluidLoadable>> | undefined = obj;
26
+ export const isDataObjectClass = (obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> => {
27
+ const maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;
28
28
  return (
29
29
  maybe?.factory?.IFluidDataStoreFactory !== undefined &&
30
30
  maybe?.factory?.IFluidDataStoreFactory === maybe?.factory
@@ -34,8 +34,9 @@ export const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFlu
34
34
  /**
35
35
  * Runtime check to determine if a class is a SharedObject type
36
36
  */
37
- export const isSharedObjectClass = (obj: any): obj is SharedObjectClass<any> => {
38
- return obj?.getFactory !== undefined;
37
+ export const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {
38
+ const maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;
39
+ return maybe?.getFactory !== undefined;
39
40
  };
40
41
 
41
42
  /**
@@ -49,7 +50,7 @@ export const parseDataObjectsFromSharedObjects = (
49
50
  const registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();
50
51
  const sharedObjects = new Set<IChannelFactory>();
51
52
 
52
- const tryAddObject = (obj: LoadableObjectClass<any>) => {
53
+ const tryAddObject = (obj: unknown): void => {
53
54
  if (isSharedObjectClass(obj)) {
54
55
  sharedObjects.add(obj.getFactory());
55
56
  } else if (isDataObjectClass(obj)) {
@@ -64,11 +65,13 @@ export const parseDataObjectsFromSharedObjects = (
64
65
  ...Object.values(schema.initialObjects),
65
66
  ...(schema.dynamicObjectTypes ?? []),
66
67
  ]);
67
- dedupedObjects.forEach(tryAddObject);
68
+ for (const obj of dedupedObjects) {
69
+ tryAddObject(obj);
70
+ }
68
71
 
69
72
  if (registryEntries.size === 0 && sharedObjects.size === 0) {
70
73
  throw new Error("Container cannot be initialized without any DataTypes");
71
74
  }
72
75
 
73
- return [Array.from(registryEntries), Array.from(sharedObjects)];
76
+ return [[...registryEntries], [...sharedObjects]];
74
77
  };