@fluidframework/fluid-static 2.0.0-rc.2.0.2 → 2.0.0-rc.3.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 (70) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/api-report/fluid-static.api.md +13 -21
  3. package/dist/fluidContainer.d.ts +7 -2
  4. package/dist/fluidContainer.d.ts.map +1 -1
  5. package/dist/fluidContainer.js +3 -2
  6. package/dist/fluidContainer.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/public.d.ts +27 -0
  11. package/dist/rootDataObject.d.ts +5 -1
  12. package/dist/rootDataObject.d.ts.map +1 -1
  13. package/dist/rootDataObject.js +13 -11
  14. package/dist/rootDataObject.js.map +1 -1
  15. package/dist/serviceAudience.d.ts +2 -2
  16. package/dist/serviceAudience.d.ts.map +1 -1
  17. package/dist/serviceAudience.js.map +1 -1
  18. package/dist/types.d.ts +15 -31
  19. package/dist/types.d.ts.map +1 -1
  20. package/dist/types.js.map +1 -1
  21. package/dist/utils.d.ts +6 -5
  22. package/dist/utils.d.ts.map +1 -1
  23. package/dist/utils.js +16 -9
  24. package/dist/utils.js.map +1 -1
  25. package/internal.d.ts +11 -0
  26. package/lib/fluidContainer.d.ts +7 -2
  27. package/lib/fluidContainer.d.ts.map +1 -1
  28. package/lib/fluidContainer.js +1 -0
  29. package/lib/fluidContainer.js.map +1 -1
  30. package/lib/index.d.ts +1 -1
  31. package/lib/index.d.ts.map +1 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/public.d.ts +27 -0
  34. package/lib/rootDataObject.d.ts +5 -1
  35. package/lib/rootDataObject.d.ts.map +1 -1
  36. package/lib/rootDataObject.js +7 -5
  37. package/lib/rootDataObject.js.map +1 -1
  38. package/lib/serviceAudience.d.ts +2 -2
  39. package/lib/serviceAudience.d.ts.map +1 -1
  40. package/lib/serviceAudience.js.map +1 -1
  41. package/lib/types.d.ts +15 -31
  42. package/lib/types.d.ts.map +1 -1
  43. package/lib/types.js.map +1 -1
  44. package/lib/utils.d.ts +6 -5
  45. package/lib/utils.d.ts.map +1 -1
  46. package/lib/utils.js +14 -7
  47. package/lib/utils.js.map +1 -1
  48. package/package.json +44 -55
  49. package/src/fluidContainer.ts +10 -7
  50. package/src/index.ts +0 -2
  51. package/src/rootDataObject.ts +16 -13
  52. package/src/serviceAudience.ts +4 -2
  53. package/src/types.ts +16 -34
  54. package/src/utils.ts +32 -19
  55. package/api-extractor-cjs.json +0 -8
  56. package/dist/fluid-static-alpha.d.ts +0 -424
  57. package/dist/fluid-static-beta.d.ts +0 -428
  58. package/dist/fluid-static-public.d.ts +0 -428
  59. package/dist/fluid-static-untrimmed.d.ts +0 -480
  60. package/lib/fluid-static-alpha.d.ts +0 -424
  61. package/lib/fluid-static-beta.d.ts +0 -428
  62. package/lib/fluid-static-public.d.ts +0 -428
  63. package/lib/fluid-static-untrimmed.d.ts +0 -480
  64. package/lib/test/fluidContainer.spec.js +0 -21
  65. package/lib/test/fluidContainer.spec.js.map +0 -1
  66. package/lib/test/types/validateFluidStaticPrevious.generated.js +0 -46
  67. package/lib/test/types/validateFluidStaticPrevious.generated.js.map +0 -1
  68. package/lib/test/utils.spec.js +0 -86
  69. package/lib/test/utils.spec.js.map +0 -1
  70. /package/{dist → lib}/tsdoc-metadata.json +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,OAAO,EAEZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE;IAC/E,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1D,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE5B"}
1
+ {"version":3,"file":"serviceAudience.d.ts","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,gBAAgB,EAGrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,EAAE;IAC/E,SAAS,EAAE,UAAU,CAAC;IACtB,mBAAmB,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1D,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAE5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAUjE;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,eACL,SAAQ,iBAAkD;IA2B1D;IACC;;OAEG;IACc,SAAqB,EACrB,mBAAyD;QAE1E,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,wBAAmB,GAAnB,mBAAmB,CAAsC;QAxB3E;;;;;;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,CAAC;QACjE,IAAI,sBAAsB,KAAK,SAAS,EAAE;YACzC,OAAO,SAAS,CAAC;SACjB;QACD,2EAA2E;QAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,KAAK,CACd,6BAA6B,QAAQ,8CAA8C,CACnF,CAAC;SACF;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,qBAAqB,CAAC,MAAe;QAC5C,6BAA6B;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,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 { type IAudience, type IContainer } from \"@fluidframework/container-definitions\";\nimport { type IClient } from \"@fluidframework/protocol-definitions\";\nimport {\n\ttype IServiceAudience,\n\ttype IServiceAudienceEvents,\n\ttype IMember,\n\ttype Myself,\n} from \"./types.js\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n *\n * @internal\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
1
+ {"version":3,"file":"serviceAudience.js","sourceRoot":"","sources":["../src/serviceAudience.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAYjE;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAoC,KAGxE;IACA,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,eACL,SAAQ,iBAAkD;IA2B1D;IACC;;OAEG;IACc,SAAqB,EACrB,mBAAyD;QAE1E,KAAK,EAAE,CAAC;QAHS,cAAS,GAAT,SAAS,CAAY;QACrB,wBAAmB,GAAnB,mBAAmB,CAAsC;QAxB3E;;;;;;;;;;;;;;;;WAgBG;QACK,gBAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;QAUhD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEnC,iFAAiF;QACjF,+EAA+E;QAC/E,IAAI,CAAC,UAAU,EAAE,CAAC;QAElB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,QAAgB,EAAE,OAAgB,EAAE,EAAE;YACpE,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE;gBACxC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBAC3C,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aAC5B;QACF,CAAC,CAAC,CAAC;QAEH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ensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { type IAudience } from \"@fluidframework/container-definitions\";\nimport { type IContainer } from \"@fluidframework/container-definitions/internal\";\nimport { type IClient } from \"@fluidframework/protocol-definitions\";\n\nimport {\n\ttype IMember,\n\ttype IServiceAudience,\n\ttype IServiceAudienceEvents,\n\ttype Myself,\n} from \"./types.js\";\n\n/**\n * Creates a service audience for the provided container.\n *\n * @param container - The container with which the audience is associated.\n * @param createServiceMember - A function for creating audience members.\n *\n * @typeParam TMember - The {@link IMember} representation used by the audience.\n *\n * @internal\n */\nexport function createServiceAudience<TMember extends IMember = IMember>(props: {\n\tcontainer: IContainer;\n\tcreateServiceMember: (audienceMember: IClient) => TMember;\n}): IServiceAudience<TMember> {\n\treturn new ServiceAudience(props.container, props.createServiceMember);\n}\n\n/**\n * Base class for providing audience information for sessions interacting with {@link IFluidContainer}\n *\n * @remarks\n *\n * This can be extended by different service-specific client packages to additional parameters to\n * the user and client details returned in {@link IMember}.\n *\n * @typeParam TMember - A service-specific {@link IMember} implementation.\n *\n * @internal\n */\nclass ServiceAudience<TMember extends IMember = IMember>\n\textends TypedEventEmitter<IServiceAudienceEvents<TMember>>\n\timplements IServiceAudience<TMember>\n{\n\t/**\n\t * Audience object which includes all the existing members of the {@link IFluidContainer | container}.\n\t */\n\tprivate readonly audience: IAudience;\n\n\t/**\n\t * Retain the most recent member list.\n\t *\n\t * @remarks\n\t *\n\t * This is so we have more information about a member leaving the audience in the `removeMember` event.\n\t *\n\t * It allows us to match the behavior of the `addMember` event where it only fires on a change to the members this\n\t * class exposes (and would actually produce a change in what `getMembers` returns).\n\t *\n\t * It also allows us to provide the client details in the event which makes it easier to find that client connection\n\t * in a map keyed on the `userId` and not `clientId`.\n\t *\n\t * This map will always be up-to-date in a `removeMember` event because it is set once at construction and in\n\t * every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}\n\t * events provide.\n\t */\n\tprivate lastMembers = new Map<string, TMember>();\n\n\tpublic constructor(\n\t\t/**\n\t\t * Fluid Container to read the audience from.\n\t\t */\n\t\tprivate readonly container: IContainer,\n\t\tprivate readonly createServiceMember: (audienceMember: IClient) => TMember,\n\t) {\n\t\tsuper();\n\t\tthis.audience = container.audience;\n\n\t\t// getMembers will assign lastMembers so the removeMember event has what it needs\n\t\t// in case it would fire before getMembers otherwise gets called the first time\n\t\tthis.getMembers();\n\n\t\tthis.audience.on(\"addMember\", (clientId: string, details: IClient) => {\n\t\t\tif (this.shouldIncludeAsMember(details)) {\n\t\t\t\tconst member = this.getMember(clientId);\n\t\t\t\tthis.emit(\"memberAdded\", clientId, member);\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.audience.on(\"removeMember\", (clientId: string) => {\n\t\t\tif (this.lastMembers.has(clientId)) {\n\t\t\t\tthis.emit(\"memberRemoved\", clientId, this.lastMembers.get(clientId));\n\t\t\t\tthis.emit(\"membersChanged\");\n\t\t\t}\n\t\t});\n\n\t\tthis.container.on(\"connected\", () => this.emit(\"membersChanged\"));\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMembers}\n\t */\n\tpublic getMembers(): Map<string, TMember> {\n\t\tconst users = new Map<string, TMember>();\n\t\tconst clientMemberMap = new Map<string, TMember>();\n\t\t// Iterate through the members and get the user specifics.\n\t\tfor (const [clientId, member] of this.audience.getMembers()) {\n\t\t\tif (this.shouldIncludeAsMember(member)) {\n\t\t\t\tconst userId = member.user.id;\n\t\t\t\t// Ensure we're tracking the user\n\t\t\t\tlet user = users.get(userId);\n\t\t\t\tif (user === undefined) {\n\t\t\t\t\tuser = this.createServiceMember(member);\n\t\t\t\t\tusers.set(userId, user);\n\t\t\t\t}\n\n\t\t\t\t// Add this connection to their collection\n\t\t\t\tuser.connections.push({ id: clientId, mode: member.mode });\n\t\t\t\tclientMemberMap.set(clientId, user);\n\t\t\t}\n\t\t}\n\t\tthis.lastMembers = clientMemberMap;\n\t\treturn users;\n\t}\n\n\t/**\n\t * {@inheritDoc IServiceAudience.getMyself}\n\t */\n\tpublic getMyself(): Myself<TMember> | undefined {\n\t\tconst clientId = this.container.clientId;\n\t\tif (clientId === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst member = this.getMember(clientId);\n\t\tif (member === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst myself: Myself<TMember> = { ...member, currentConnection: clientId };\n\n\t\treturn myself;\n\t}\n\n\tprivate getMember(clientId: string): TMember | undefined {\n\t\t// Fetch the user ID assoicated with this client ID from the runtime\n\t\tconst internalAudienceMember = this.audience.getMember(clientId);\n\t\tif (internalAudienceMember === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\t// Return the member object with any other clients associated for this user\n\t\tconst allMembers = this.getMembers();\n\t\tconst member = allMembers.get(internalAudienceMember?.user.id);\n\t\tif (member === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Attempted to fetch client ${clientId} that is not part of the current member list`,\n\t\t\t);\n\t\t}\n\t\treturn member;\n\t}\n\n\t/**\n\t * Provides ability for the inheriting class to include/omit specific members.\n\t * An example use case is omitting the summarizer client.\n\t *\n\t * @param member - Member to be included/omitted.\n\t */\n\tprivate shouldIncludeAsMember(member: IClient): boolean {\n\t\t// Include only human members\n\t\treturn member.details.capabilities.interactive;\n\t}\n}\n"]}
package/lib/types.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { type IEvent, type IEventProvider, type IFluidLoadable } from "@fluidframework/core-interfaces";
6
- import { type IChannelFactory } from "@fluidframework/datastore-definitions";
6
+ import { type ISharedObjectKind } from "@fluidframework/shared-object-base";
7
7
  /**
8
8
  * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
9
9
  * @internal
@@ -25,41 +25,25 @@ export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
25
25
  * There are some edge cases in TypeScript where the order of the members in a union matter.
26
26
  * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.
27
27
  * In this case, its better to have the desired match and/or the simpler type first.
28
- * In this case placing SharedObjectClass fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.
28
+ * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.
29
29
  * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].
30
30
  */
31
- export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
31
+ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = ISharedObjectKind<T> | DataObjectClass<T>;
32
32
  /**
33
33
  * A class that has a factory that can create a `DataObject` and a
34
34
  * constructor that will return the type of the `DataObject`.
35
35
  *
36
36
  * @typeParam T - The class of the `DataObject`.
37
+ * @privateRemarks
38
+ * Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.
39
+ * This may need some refinement.
37
40
  * @public
38
41
  */
39
- export type DataObjectClass<T extends IFluidLoadable> = {
42
+ export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
40
43
  readonly factory: {
41
- IFluidDataStoreFactory: DataObjectClass<T>["factory"];
44
+ readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"];
42
45
  };
43
- } & LoadableObjectCtor<T>;
44
- /**
45
- * A factory that produces a factory that can create a DDSes (`SharedObject`s).
46
- *
47
- * @typeParam T - The class of the `SharedObject`.
48
- * @public
49
- */
50
- export interface SharedObjectClass<T extends IFluidLoadable> {
51
- /**
52
- * Gets the factory this factory is a wrapper for.
53
- */
54
- readonly getFactory: () => IChannelFactory<T>;
55
- }
56
- /**
57
- * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
58
- *
59
- * @typeParam T - The class of the loadable object.
60
- * @public
61
- */
62
- export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
46
+ } & (new (...args: any[]) => T);
63
47
  /**
64
48
  * Represents properties that can be attached to a container.
65
49
  * @public
@@ -189,7 +173,7 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
189
173
  * member object. The implementation may choose to exclude certain connections from the returned map.
190
174
  * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.
191
175
  */
192
- getMembers(): Map<string, M>;
176
+ getMembers(): ReadonlyMap<string, M>;
193
177
  /**
194
178
  * Returns the current active user on this client once they are connected. Otherwise, returns undefined.
195
179
  */
@@ -205,11 +189,11 @@ export interface IConnection {
205
189
  /**
206
190
  * A unique ID for the connection. A single user may have multiple connections, each with a different ID.
207
191
  */
208
- id: string;
192
+ readonly id: string;
209
193
  /**
210
194
  * Whether the connection is in read or read/write mode.
211
195
  */
212
- mode: "write" | "read";
196
+ readonly mode: "write" | "read";
213
197
  }
214
198
  /**
215
199
  * Base interface to be implemented to fetch each service's member.
@@ -221,17 +205,17 @@ export interface IMember {
221
205
  /**
222
206
  * An ID for the user, unique among each individual user connecting to the session.
223
207
  */
224
- userId: string;
208
+ readonly userId: string;
225
209
  /**
226
210
  * The set of connections the user has made, e.g. from multiple tabs or devices.
227
211
  */
228
- connections: IConnection[];
212
+ readonly connections: IConnection[];
229
213
  }
230
214
  /**
231
215
  * An extended member object that includes currentConnection
232
216
  * @public
233
217
  */
234
218
  export type Myself<M extends IMember = IMember> = M & {
235
- currentConnection: string;
219
+ readonly currentConnection: string;
236
220
  };
237
221
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EA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IAErC;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing SharedObjectClass fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =\n\t| SharedObjectClass<T>\n\t| DataObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @public\n */\nexport type DataObjectClass<T extends IFluidLoadable> = {\n\treadonly factory: { IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n} & LoadableObjectCtor<T>;\n\n/**\n * A factory that produces a factory that can create a DDSes (`SharedObject`s).\n *\n * @typeParam T - The class of the `SharedObject`.\n * @public\n */\nexport interface SharedObjectClass<T extends IFluidLoadable> {\n\t/**\n\t * Gets the factory this factory is a wrapper for.\n\t */\n\treadonly getFactory: () => IChannelFactory<T>;\n}\n\n/**\n * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: LoadableObjectClassRecord;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly LoadableObjectClass[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): Map<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\tid: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\tmode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\tuserId: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\tconnections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IEvent,\n\ttype IEventProvider,\n\ttype IFluidLoadable,\n} from \"@fluidframework/core-interfaces\";\nimport { type ISharedObjectKind } from \"@fluidframework/shared-object-base\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @internal\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject`.\n * @public\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @public\n *\n * @privateRemarks\n * There are some edge cases in TypeScript where the order of the members in a union matter.\n * Once such edge case is when multiple members of a generic union partially match, and the type parameter is being inferred.\n * In this case, its better to have the desired match and/or the simpler type first.\n * In this case placing ISharedObjectKind fixed one usage and didn't break anything, and generally seems more likely to work than the reverse, so this is the order being used.\n * This is likely (a bug in TypeScript)[https://github.com/microsoft/TypeScript/issues/45809].\n */\nexport type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> =\n\t| ISharedObjectKind<T>\n\t| DataObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @privateRemarks\n * Having both `factory` and `LoadableObjectCtor` is redundant, and having `factory` not actually work as a factory is also strange.\n * This may need some refinement.\n * @public\n */\nexport type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {\n\treadonly factory: { readonly IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n} & (new (...args: any[]) => T);\n\n/**\n * Represents properties that can be attached to a container.\n * @public\n */\nexport type ContainerAttachProps<T = unknown> = T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @public\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\treadonly initialObjects: LoadableObjectClassRecord;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\treadonly dynamicObjectTypes?: readonly LoadableObjectClass[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @public\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @public\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @public\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): ReadonlyMap<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @public\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\treadonly id: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\treadonly mode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @public\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\treadonly userId: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\treadonly connections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @public\n */\nexport type Myself<M extends IMember = IMember> = M & { readonly currentConnection: string };\n"]}
package/lib/utils.d.ts CHANGED
@@ -2,10 +2,11 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { type IChannelFactory } from "@fluidframework/datastore-definitions";
6
- import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
7
5
  import { type IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass, type SharedObjectClass } from "./types.js";
6
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
+ import { type IFluidDataStoreFactory, type NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions/internal";
8
+ import type { ISharedObjectKind } from "@fluidframework/shared-object-base";
9
+ import { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from "./types.js";
9
10
  /**
10
11
  * An internal type used by the internal type guard isDataObjectClass to cast a
11
12
  * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
@@ -20,11 +21,11 @@ export declare function isDataObjectClass<T extends IFluidLoadable>(obj: Loadabl
20
21
  /**
21
22
  * Runtime check to determine if a class is a DataObject type.
22
23
  */
23
- export declare function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;
24
+ export declare function isDataObjectClass(obj: LoadableObjectClass): obj is InternalDataObjectClass<IFluidLoadable>;
24
25
  /**
25
26
  * Runtime check to determine if a class is a SharedObject type
26
27
  */
27
- export declare const isSharedObjectClass: (obj: unknown) => obj is SharedObjectClass<IFluidLoadable>;
28
+ export declare function isSharedObjectKind(obj: LoadableObjectClass): obj is ISharedObjectKind<IFluidLoadable>;
28
29
  /**
29
30
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
30
31
  * of both SharedObject or DataObject. This function separates the two and returns a registry
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACzD,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACzB,GAAG,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;AAahG;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,OAAO,6CAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACrC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAElG;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACzD,GAAG,EAAE,mBAAmB,CAAC,CAAC,CAAC,GACzB,GAAG,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,mBAAmB,GACtB,GAAG,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC;AAyBlD;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,mBAAmB,GACtB,GAAG,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAE1C;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA4BxD,CAAC"}
package/lib/utils.js CHANGED
@@ -2,21 +2,28 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { UsageError } from "@fluidframework/telemetry-utils/internal";
5
6
  /**
6
7
  * Runtime check to determine if a class is a DataObject type.
7
8
  */
8
9
  export function isDataObjectClass(obj) {
9
10
  const maybe = obj;
10
- return (maybe?.factory?.IFluidDataStoreFactory !== undefined &&
11
- maybe?.factory?.IFluidDataStoreFactory === maybe?.factory);
11
+ const isDataObject = maybe?.factory?.IFluidDataStoreFactory !== undefined &&
12
+ maybe.factory.IFluidDataStoreFactory === maybe.factory;
13
+ if (isDataObject ===
14
+ (obj.getFactory !== undefined)) {
15
+ // TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called "getFactory" so there is a risk of this being a false positive.
16
+ // Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.
17
+ throw new UsageError("Invalid LoadableObjectClass");
18
+ }
19
+ return isDataObject;
12
20
  }
13
21
  /**
14
22
  * Runtime check to determine if a class is a SharedObject type
15
23
  */
16
- export const isSharedObjectClass = (obj) => {
17
- const maybe = obj;
18
- return maybe?.getFactory !== undefined;
19
- };
24
+ export function isSharedObjectKind(obj) {
25
+ return !isDataObjectClass(obj);
26
+ }
20
27
  /**
21
28
  * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be
22
29
  * of both SharedObject or DataObject. This function separates the two and returns a registry
@@ -26,7 +33,7 @@ export const parseDataObjectsFromSharedObjects = (schema) => {
26
33
  const registryEntries = new Set();
27
34
  const sharedObjects = new Set();
28
35
  const tryAddObject = (obj) => {
29
- if (isSharedObjectClass(obj)) {
36
+ if (isSharedObjectKind(obj)) {
30
37
  sharedObjects.add(obj.getFactory());
31
38
  }
32
39
  else if (isDataObjectClass(obj)) {
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoCH;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAA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C,GAAG,CAAC,CAAC;KAClB;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,CAAC,GAAG,eAAe,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ContainerSchema,\n\ttype DataObjectClass,\n\ttype LoadableObjectClass,\n\ttype SharedObjectClass,\n} from \"./types.js\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass<T extends IFluidLoadable>(\n\tobj: LoadableObjectClass<T>,\n): obj is InternalDataObjectClass<T>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(obj: unknown): obj is InternalDataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\treturn (\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe?.factory?.IFluidDataStoreFactory === maybe?.factory\n\t);\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport const isSharedObjectClass = (obj: unknown): obj is SharedObjectClass<IFluidLoadable> => {\n\tconst maybe = obj as Partial<SharedObjectClass<IFluidLoadable>> | undefined;\n\treturn maybe?.getFactory !== undefined;\n};\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: unknown): void => {\n\t\tif (isSharedObjectClass(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AA2BtE;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAwB;IAExB,MAAM,KAAK,GAAG,GAAm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AE,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE;QACjC,YAAY,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,CAAC,GAAG,eAAe,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype IFluidDataStoreFactory,\n\ttype NamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport type { ISharedObjectKind } from \"@fluidframework/shared-object-base\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type ContainerSchema, type DataObjectClass, type LoadableObjectClass } from \"./types.js\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass<T extends IFluidLoadable>(\n\tobj: LoadableObjectClass<T>,\n): obj is InternalDataObjectClass<T>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable>;\n\n/**\n * Runtime check to determine if a class is a DataObject type.\n */\nexport function isDataObjectClass(\n\tobj: LoadableObjectClass,\n): obj is InternalDataObjectClass<IFluidLoadable> {\n\tconst maybe = obj as Partial<InternalDataObjectClass<IFluidLoadable>> | undefined;\n\tconst isDataObject =\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe.factory.IFluidDataStoreFactory === maybe.factory;\n\n\tif (\n\t\tisDataObject ===\n\t\t((obj as Partial<ISharedObjectKind<IFluidLoadable>>).getFactory !== undefined)\n\t) {\n\t\t// TODO: Currently nothing in the types or docs requires an actual DataObjectClass to not have a member called \"getFactory\" so there is a risk of this being a false positive.\n\t\t// Refactoring the use of LoadableObjectClass such that explicit down casting is not required (for example by having a single factory API shared by both cases) could avoid problems like this.\n\t\tthrow new UsageError(\"Invalid LoadableObjectClass\");\n\t}\n\n\treturn isDataObject;\n}\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport function isSharedObjectKind(\n\tobj: LoadableObjectClass,\n): obj is ISharedObjectKind<IFluidLoadable> {\n\treturn !isDataObjectClass(obj);\n}\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function separates the two and returns a registry\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: LoadableObjectClass): void => {\n\t\tif (isSharedObjectKind(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tfor (const obj of dedupedObjects) {\n\t\ttryAddObject(obj);\n\t}\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [[...registryEntries], [...sharedObjects]];\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-static",
3
- "version": "2.0.0-rc.2.0.2",
3
+ "version": "2.0.0-rc.3.0.1",
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": {
@@ -15,21 +15,11 @@
15
15
  "exports": {
16
16
  ".": {
17
17
  "import": {
18
- "types": "./lib/index.d.ts",
18
+ "types": "./lib/public.d.ts",
19
19
  "default": "./lib/index.js"
20
20
  },
21
21
  "require": {
22
- "types": "./dist/index.d.ts",
23
- "default": "./dist/index.js"
24
- }
25
- },
26
- "./public": {
27
- "import": {
28
- "types": "./lib/fluid-static-public.d.ts",
29
- "default": "./lib/index.js"
30
- },
31
- "require": {
32
- "types": "./dist/fluid-static-public.d.ts",
22
+ "types": "./dist/public.d.ts",
33
23
  "default": "./dist/index.js"
34
24
  }
35
25
  },
@@ -44,8 +34,8 @@
44
34
  }
45
35
  }
46
36
  },
47
- "main": "dist/index.js",
48
- "types": "dist/index.d.ts",
37
+ "main": "lib/index.js",
38
+ "types": "lib/public.d.ts",
49
39
  "c8": {
50
40
  "all": true,
51
41
  "cache-dir": "nyc/.cache",
@@ -67,29 +57,32 @@
67
57
  "temp-directory": "nyc/.nyc_output"
68
58
  },
69
59
  "dependencies": {
70
- "@fluid-internal/client-utils": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
71
- "@fluidframework/aqueduct": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
72
- "@fluidframework/container-definitions": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
73
- "@fluidframework/container-loader": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
74
- "@fluidframework/container-runtime": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
75
- "@fluidframework/container-runtime-definitions": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
76
- "@fluidframework/core-interfaces": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
77
- "@fluidframework/datastore-definitions": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
60
+ "@fluid-internal/client-utils": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
61
+ "@fluidframework/aqueduct": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
62
+ "@fluidframework/container-definitions": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
63
+ "@fluidframework/container-loader": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
64
+ "@fluidframework/container-runtime": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
65
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
66
+ "@fluidframework/core-interfaces": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
67
+ "@fluidframework/datastore-definitions": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
78
68
  "@fluidframework/protocol-definitions": "^3.2.0",
79
- "@fluidframework/request-handler": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
80
- "@fluidframework/runtime-definitions": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
81
- "@fluidframework/runtime-utils": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0"
69
+ "@fluidframework/request-handler": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
70
+ "@fluidframework/runtime-definitions": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
71
+ "@fluidframework/runtime-utils": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
72
+ "@fluidframework/shared-object-base": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
73
+ "@fluidframework/telemetry-utils": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0"
82
74
  },
83
75
  "devDependencies": {
84
- "@arethetypeswrong/cli": "^0.13.3",
85
- "@fluid-internal/mocha-test-setup": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
86
- "@fluid-tools/build-cli": "^0.34.0",
76
+ "@arethetypeswrong/cli": "^0.15.2",
77
+ "@biomejs/biome": "^1.6.2",
78
+ "@fluid-internal/mocha-test-setup": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
79
+ "@fluid-tools/build-cli": "^0.37.0",
87
80
  "@fluidframework/build-common": "^2.0.3",
88
- "@fluidframework/build-tools": "^0.34.0",
89
- "@fluidframework/eslint-config-fluid": "^4.0.0",
81
+ "@fluidframework/build-tools": "^0.37.0",
82
+ "@fluidframework/eslint-config-fluid": "^5.1.0",
90
83
  "@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.8.0.0",
91
- "@fluidframework/map": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
92
- "@fluidframework/sequence": ">=2.0.0-rc.2.0.2 <2.0.0-rc.2.1.0",
84
+ "@fluidframework/map": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
85
+ "@fluidframework/sequence": ">=2.0.0-rc.3.0.1 <2.0.0-rc.3.1.0",
93
86
  "@microsoft/api-extractor": "^7.42.3",
94
87
  "@types/mocha": "^9.1.1",
95
88
  "@types/node": "^18.19.0",
@@ -105,48 +98,44 @@
105
98
  "rimraf": "^4.4.0",
106
99
  "typescript": "~5.1.6"
107
100
  },
108
- "fluidBuild": {
109
- "tasks": {
110
- "build:docs": {
111
- "dependsOn": [
112
- "...",
113
- "api-extractor:commonjs",
114
- "api-extractor:esnext"
115
- ],
116
- "script": false
117
- }
118
- }
119
- },
120
101
  "typeValidation": {
121
102
  "broken": {
122
103
  "InterfaceDeclaration_ContainerSchema": {
123
104
  "backCompat": false
105
+ },
106
+ "RemovedTypeAliasDeclaration_LoadableObjectCtor": {
107
+ "backCompat": false,
108
+ "forwardCompat": false
109
+ },
110
+ "RemovedTypeAliasDeclaration_SharedObjectClass": {
111
+ "forwardCompat": false,
112
+ "backCompat": false
124
113
  }
125
114
  }
126
115
  },
127
116
  "scripts": {
128
117
  "api": "fluid-build . --task api",
129
- "api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
130
- "api-extractor:esnext": "api-extractor run --local",
118
+ "api-extractor:commonjs": "flub generate entrypoints --outFileAlpha legacy --outDir ./dist",
119
+ "api-extractor:esnext": "flub generate entrypoints --outFileAlpha legacy --outDir ./lib --node10TypeCompat",
131
120
  "build": "fluid-build . --task build",
132
121
  "build:commonjs": "fluid-build . --task commonjs",
133
122
  "build:compile": "fluid-build . --task compile",
134
- "build:docs": "fluid-build . --task api",
123
+ "build:docs": "api-extractor run --local",
135
124
  "build:esnext": "tsc --project ./tsconfig.json",
136
125
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
137
126
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
138
127
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
139
- "check:are-the-types-wrong": "attw --pack . --entrypoints .",
128
+ "check:are-the-types-wrong": "attw --pack .",
129
+ "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
140
130
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
141
131
  "ci:build:docs": "api-extractor run",
142
- "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
132
+ "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
143
133
  "eslint": "eslint --format stylish src",
144
134
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
145
- "format": "npm run prettier:fix",
146
- "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
147
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
148
- "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
149
- "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
135
+ "format": "fluid-build --task format .",
136
+ "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
137
+ "lint": "fluid-build . --task lint",
138
+ "lint:fix": "fluid-build . --task eslint:fix --task format",
150
139
  "test": "npm run test:mocha",
151
140
  "test:coverage": "c8 npm test",
152
141
  "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
@@ -2,21 +2,23 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+
5
6
  import { TypedEventEmitter } from "@fluid-internal/client-utils";
7
+ import {
8
+ AttachState,
9
+ type ConnectionState,
10
+ type ICriticalContainerError,
11
+ } from "@fluidframework/container-definitions";
12
+ import { type IContainer } from "@fluidframework/container-definitions/internal";
6
13
  import {
7
14
  type IEvent,
8
15
  type IEventProvider,
9
16
  type IFluidLoadable,
10
17
  } from "@fluidframework/core-interfaces";
11
- import {
12
- AttachState,
13
- type IContainer,
14
- type ICriticalContainerError,
15
- type ConnectionState,
16
- } from "@fluidframework/container-definitions";
18
+
17
19
  import type {
18
- ContainerSchema,
19
20
  ContainerAttachProps,
21
+ ContainerSchema,
20
22
  IRootDataObject,
21
23
  LoadableObjectClass,
22
24
  } from "./types.js";
@@ -321,6 +323,7 @@ class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
321
323
  * but internally this separation is not there.
322
324
  */
323
325
  public async attach(props?: ContainerAttachProps): Promise<string> {
326
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- AB#7608
324
327
  if (this.container.attachState !== AttachState.Detached) {
325
328
  throw new Error("Cannot attach container. Container is not in detached state.");
326
329
  }
package/src/index.ts CHANGED
@@ -28,10 +28,8 @@ export {
28
28
  type IServiceAudienceEvents,
29
29
  type LoadableObjectClass,
30
30
  type LoadableObjectClassRecord,
31
- type LoadableObjectCtor,
32
31
  type LoadableObjectRecord,
33
32
  type MemberChangedListener,
34
33
  type Myself,
35
- type SharedObjectClass,
36
34
  type IProvideRootDataObject,
37
35
  } from "./types.js";