@fluidframework/presence 2.10.0-307399 → 2.10.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 (100) hide show
  1. package/README.md +6 -2
  2. package/dist/alpha.d.ts +4 -3
  3. package/dist/broadcastControls.d.ts +70 -0
  4. package/dist/broadcastControls.d.ts.map +1 -0
  5. package/dist/broadcastControls.js +61 -0
  6. package/dist/broadcastControls.js.map +1 -0
  7. package/dist/exposedInternalTypes.d.ts +4 -1
  8. package/dist/exposedInternalTypes.d.ts.map +1 -1
  9. package/dist/exposedInternalTypes.js.map +1 -1
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/internalTypes.d.ts +2 -2
  14. package/dist/internalTypes.d.ts.map +1 -1
  15. package/dist/internalTypes.js.map +1 -1
  16. package/dist/latestMapValueManager.d.ts +3 -3
  17. package/dist/latestMapValueManager.d.ts.map +1 -1
  18. package/dist/latestMapValueManager.js +9 -13
  19. package/dist/latestMapValueManager.js.map +1 -1
  20. package/dist/latestValueManager.d.ts +3 -3
  21. package/dist/latestValueManager.d.ts.map +1 -1
  22. package/dist/latestValueManager.js +7 -11
  23. package/dist/latestValueManager.js.map +1 -1
  24. package/dist/notificationsManager.d.ts.map +1 -1
  25. package/dist/notificationsManager.js +16 -6
  26. package/dist/notificationsManager.js.map +1 -1
  27. package/dist/presence.d.ts +3 -1
  28. package/dist/presence.d.ts.map +1 -1
  29. package/dist/presence.js.map +1 -1
  30. package/dist/presenceDatastoreManager.d.ts +5 -4
  31. package/dist/presenceDatastoreManager.d.ts.map +1 -1
  32. package/dist/presenceDatastoreManager.js +6 -6
  33. package/dist/presenceDatastoreManager.js.map +1 -1
  34. package/dist/presenceManager.d.ts.map +1 -1
  35. package/dist/presenceManager.js +2 -2
  36. package/dist/presenceManager.js.map +1 -1
  37. package/dist/presenceStates.d.ts +23 -4
  38. package/dist/presenceStates.d.ts.map +1 -1
  39. package/dist/presenceStates.js +41 -13
  40. package/dist/presenceStates.js.map +1 -1
  41. package/dist/stateDatastore.d.ts +13 -3
  42. package/dist/stateDatastore.d.ts.map +1 -1
  43. package/dist/stateDatastore.js.map +1 -1
  44. package/dist/types.d.ts +27 -5
  45. package/dist/types.d.ts.map +1 -1
  46. package/dist/types.js.map +1 -1
  47. package/lib/alpha.d.ts +4 -3
  48. package/lib/broadcastControls.d.ts +70 -0
  49. package/lib/broadcastControls.d.ts.map +1 -0
  50. package/lib/broadcastControls.js +56 -0
  51. package/lib/broadcastControls.js.map +1 -0
  52. package/lib/exposedInternalTypes.d.ts +4 -1
  53. package/lib/exposedInternalTypes.d.ts.map +1 -1
  54. package/lib/exposedInternalTypes.js.map +1 -1
  55. package/lib/index.d.ts +3 -3
  56. package/lib/index.d.ts.map +1 -1
  57. package/lib/index.js.map +1 -1
  58. package/lib/internalTypes.d.ts +2 -2
  59. package/lib/internalTypes.d.ts.map +1 -1
  60. package/lib/internalTypes.js.map +1 -1
  61. package/lib/latestMapValueManager.d.ts +3 -3
  62. package/lib/latestMapValueManager.d.ts.map +1 -1
  63. package/lib/latestMapValueManager.js +9 -13
  64. package/lib/latestMapValueManager.js.map +1 -1
  65. package/lib/latestValueManager.d.ts +3 -3
  66. package/lib/latestValueManager.d.ts.map +1 -1
  67. package/lib/latestValueManager.js +7 -11
  68. package/lib/latestValueManager.js.map +1 -1
  69. package/lib/notificationsManager.d.ts.map +1 -1
  70. package/lib/notificationsManager.js +16 -6
  71. package/lib/notificationsManager.js.map +1 -1
  72. package/lib/presence.d.ts +3 -1
  73. package/lib/presence.d.ts.map +1 -1
  74. package/lib/presence.js.map +1 -1
  75. package/lib/presenceDatastoreManager.d.ts +5 -4
  76. package/lib/presenceDatastoreManager.d.ts.map +1 -1
  77. package/lib/presenceDatastoreManager.js +6 -6
  78. package/lib/presenceDatastoreManager.js.map +1 -1
  79. package/lib/presenceManager.d.ts.map +1 -1
  80. package/lib/presenceManager.js +2 -2
  81. package/lib/presenceManager.js.map +1 -1
  82. package/lib/presenceStates.d.ts +23 -4
  83. package/lib/presenceStates.d.ts.map +1 -1
  84. package/lib/presenceStates.js +41 -13
  85. package/lib/presenceStates.js.map +1 -1
  86. package/lib/stateDatastore.d.ts +13 -3
  87. package/lib/stateDatastore.d.ts.map +1 -1
  88. package/lib/stateDatastore.js.map +1 -1
  89. package/lib/types.d.ts +27 -5
  90. package/lib/types.d.ts.map +1 -1
  91. package/lib/types.js.map +1 -1
  92. package/package.json +17 -17
  93. package/dist/latestValueControls.d.ts +0 -44
  94. package/dist/latestValueControls.d.ts.map +0 -1
  95. package/dist/latestValueControls.js +0 -28
  96. package/dist/latestValueControls.js.map +0 -1
  97. package/lib/latestValueControls.d.ts +0 -44
  98. package/lib/latestValueControls.d.ts.map +0 -1
  99. package/lib/latestValueControls.js +0 -24
  100. package/lib/latestValueControls.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"presenceStates.js","sourceRoot":"","sources":["../src/presenceStates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAuB,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgG/C,SAAS,gBAAgB,CAMxB,KAAoD;IAEpD,OAAO,OAAO,IAAI,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,mBAAmB,CAM3B,IAA+D,EAC/D,MAAqD,EACrD,SAAiB;IAEjB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjD,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,C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tF,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YAC5B,CAAC;QACF,CAAC;QACD,OAAO,IAAmD,CAAC;IAC5D,CAAC;IAEM,aAAa,CACnB,QAAgB,EAChB,YAAoB,EACpB,eAAkC;QAElC,KAAK,MAAM,CAAC,GAAG,EAAE,mBAAmB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1E,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACvB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzC,KAAK,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,oBAAoB,CAAC,mBAAmB,CAAC,EAAE,CAAC;oBAClF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;oBAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,mFAAmF;gBACnF,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACjF,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAwB,EACxB,SAAgD,EAChD,cAAuB;IAEvB,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAU,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAEjF,OAAO;QACN,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;KACd,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ClientRecord } from \"./internalTypes.js\";\nimport { brandedObjectEntries } from \"./internalTypes.js\";\nimport type { ClientSessionId, ISessionClient } from \"./presence.js\";\nimport { handleFromDatastore, type StateDatastore } from \"./stateDatastore.js\";\nimport type { PresenceStates, PresenceStatesSchema } from \"./types.js\";\nimport { unbrandIVM } from \"./valueManager.js\";\n\n/**\n * @internal\n */\nexport type MapSchemaElement<\n\tTSchema extends PresenceStatesSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n\tKeys extends keyof TSchema = keyof TSchema,\n> = ReturnType<TSchema[Keys]>[Part];\n\n/**\n * @internal\n */\nexport interface PresenceRuntime {\n\treadonly clientSessionId: ClientSessionId;\n\tlookupClient(clientId: ClientConnectionId): ISessionClient;\n\tlocalUpdate(states: { [key: string]: ClientUpdateEntry }, forceBroadcast: boolean): void;\n}\n\ntype PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema extends PresenceStatesSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n> = {\n\t[Key in keyof TSchema]: MapSchemaElement<TSchema, Part, Key>;\n};\n\ntype MapEntries<TSchema extends PresenceStatesSchema> = PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema,\n\t\"manager\"\n>;\n\n/**\n * ValueElementMap is a map of key to a map of clientId to ValueState.\n * It is not restricted to the schema of the map as it may receive updates from other clients\n * with managers that have not been registered locally. Each map node is responsible for keeping\n * all sessions state to be able to pick arbitrary client to rebroadcast to others.\n *\n * This generic aspect makes some typing difficult. The loose typing is not broadcast to the\n * consumers that are expected to maintain their schema over multiple versions of clients.\n *\n * @internal\n */\nexport interface ValueElementMap<_TSchema extends PresenceStatesSchema> {\n\t[key: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<unknown>>;\n}\n\n// An attempt to make the type more precise, but it is not working.\n// If the casting in support code is too much we could keep two references to the same\n// complete datastore, but with the respective types desired.\n// type ValueElementMap<TSchema extends PresenceStatesNodeSchema> =\n// \t| {\n// \t\t\t[Key in keyof TSchema & string]?: {\n// \t\t\t\t[ClientSessionId: ClientSessionId]: InternalTypes.ValueDirectoryOrState<MapSchemaElement<TSchema,\"value\",Key>>;\n// \t\t\t};\n// \t }\n// \t| {\n// \t\t\t[key: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<unknown>>;\n// \t };\n// interface ValueElementMap<TValue> {\n// \t[Id: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// Version with local packed in is convenient for map, but not for join broadcast to serialize simply.\n// \t// [Id: string]: {\n// \t// \tlocal: InternalTypes.ValueDirectoryOrState<TValue>;\n// \t// \tall: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// };\n// }\n\n/**\n * @internal\n */\nexport type ClientUpdateEntry = InternalTypes.ValueDirectoryOrState<unknown> & {\n\tignoreUnmonitored?: true;\n};\n\ntype ClientUpdateRecord = ClientRecord<ClientUpdateEntry>;\n\ninterface ValueUpdateRecord {\n\t[valueKey: string]: ClientUpdateRecord;\n}\n\n/**\n * @internal\n */\nexport interface PresenceStatesInternal {\n\tensureContent<TSchemaAdditional extends PresenceStatesSchema>(\n\t\tcontent: TSchemaAdditional,\n\t): PresenceStates<TSchemaAdditional>;\n\tprocessUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t\tsenderConnectionId: ClientConnectionId,\n\t): void;\n}\n\nfunction isValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tvalue: InternalTypes.ValueDirectory<T> | TValueState,\n): value is InternalTypes.ValueDirectory<T> {\n\treturn \"items\" in value;\n}\n\nfunction mergeValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tbase: TValueState | InternalTypes.ValueDirectory<T> | undefined,\n\tupdate: TValueState | InternalTypes.ValueDirectory<T>,\n\ttimeDelta: number,\n): TValueState | InternalTypes.ValueDirectory<T> {\n\tif (!isValueDirectory(update)) {\n\t\tif (base === undefined || update.rev > base.rev) {\n\t\t\treturn { ...update, timestamp: update.timestamp + timeDelta };\n\t\t}\n\t\treturn base;\n\t}\n\n\tlet mergeBase: InternalTypes.ValueDirectory<T>;\n\tif (base === undefined) {\n\t\tmergeBase = { rev: update.rev, items: {} };\n\t} else {\n\t\tconst baseIsDirectory = isValueDirectory(base);\n\t\tif (base.rev >= update.rev) {\n\t\t\tif (!baseIsDirectory) {\n\t\t\t\t// base is leaf value that is more recent - nothing to do\n\t\t\t\treturn base;\n\t\t\t}\n\t\t\t// While base has more advanced revision, assume mis-ordering or\n\t\t\t// missed and catchup update needs merged in.\n\t\t\tmergeBase = base;\n\t\t} else {\n\t\t\tmergeBase = { rev: update.rev, items: baseIsDirectory ? base.items : {} };\n\t\t}\n\t}\n\tfor (const [key, value] of Object.entries(update.items)) {\n\t\tconst baseElement = mergeBase.items[key];\n\t\tmergeBase.items[key] = mergeValueDirectory(baseElement, value, timeDelta);\n\t}\n\treturn mergeBase;\n}\n\n/**\n * Updates remote state into the local [untracked] datastore.\n *\n * @param key - The key of the datastore to merge the untracked data into.\n * @param remoteAllKnownState - The remote state to merge into the datastore.\n * @param datastore - The datastore to merge the untracked data into.\n *\n * @remarks\n * In the case of ignored unmonitored data, the client entries are not stored,\n * though the value keys will be populated and often remain empty.\n *\n * @internal\n */\nexport function mergeUntrackedDatastore(\n\tkey: string,\n\tremoteAllKnownState: ClientUpdateRecord,\n\tdatastore: ValueElementMap<PresenceStatesSchema>,\n\ttimeModifier: number,\n): void {\n\tif (!(key in datastore)) {\n\t\tdatastore[key] = {};\n\t}\n\tconst localAllKnownState = datastore[key];\n\tfor (const [clientSessionId, value] of brandedObjectEntries(remoteAllKnownState)) {\n\t\tif (!(\"ignoreUnmonitored\" in value)) {\n\t\t\tlocalAllKnownState[clientSessionId] = mergeValueDirectory(\n\t\t\t\tlocalAllKnownState[clientSessionId],\n\t\t\t\tvalue,\n\t\t\t\ttimeModifier,\n\t\t\t);\n\t\t}\n\t}\n}\n\nclass PresenceStatesImpl<TSchema extends PresenceStatesSchema>\n\timplements\n\t\tPresenceStatesInternal,\n\t\tPresenceStates<TSchema>,\n\t\tStateDatastore<\n\t\t\tkeyof TSchema & string,\n\t\t\tMapSchemaElement<TSchema, \"value\", keyof TSchema & string>\n\t\t>\n{\n\tprivate readonly nodes: MapEntries<TSchema>;\n\tpublic readonly props: PresenceStates<TSchema>[\"props\"];\n\n\tpublic constructor(\n\t\tprivate readonly runtime: PresenceRuntime,\n\t\tprivate readonly datastore: ValueElementMap<TSchema>,\n\t\tinitialContent: TSchema,\n\t) {\n\t\t// Prepare initial map content from initial state\n\t\t{\n\t\t\tconst clientSessionId = this.runtime.clientSessionId;\n\t\t\tlet anyInitialValues = false;\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\tconst initial = Object.entries(initialContent).reduce(\n\t\t\t\t(acc, [key, nodeFactory]) => {\n\t\t\t\t\tconst newNodeData = nodeFactory(key, handleFromDatastore(this));\n\t\t\t\t\tacc.nodes[key as keyof TSchema] = newNodeData.manager;\n\t\t\t\t\tif (\"value\" in newNodeData) {\n\t\t\t\t\t\tacc.datastore[key] = acc.datastore[key] ?? {};\n\t\t\t\t\t\tacc.datastore[key][clientSessionId] = newNodeData.value;\n\t\t\t\t\t\tacc.newValues[key] = newNodeData.value;\n\t\t\t\t\t\tanyInitialValues = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\t\tnodes: {} as MapEntries<TSchema>,\n\t\t\t\t\tdatastore,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\t\tnewValues: {} as { [key: string]: InternalTypes.ValueDirectoryOrState<unknown> },\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.nodes = initial.nodes;\n\t\t\t// props is the public view of nodes that limits the entries types to\n\t\t\t// the public interface of the value manager with an additional type\n\t\t\t// filter that beguiles the type system. So just reinterpret cast.\n\t\t\tthis.props = this.nodes as unknown as PresenceStates<TSchema>[\"props\"];\n\n\t\t\tif (anyInitialValues) {\n\t\t\t\tthis.runtime.localUpdate(initial.newValues, false);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic knownValues<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t): {\n\t\tself: ClientSessionId | undefined;\n\t\tstates: ClientRecord<MapSchemaElement<TSchema, \"value\", Key>>;\n\t} {\n\t\treturn {\n\t\t\tself: this.runtime.clientSessionId,\n\t\t\tstates: this.datastore[key],\n\t\t};\n\t}\n\n\tpublic localUpdate<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tvalue: MapSchemaElement<TSchema, \"value\", Key> & ClientUpdateEntry,\n\t\tforceBroadcast: boolean,\n\t): void {\n\t\tthis.runtime.localUpdate({ [key]: value }, forceBroadcast);\n\t}\n\n\tpublic update<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tclientId: ClientSessionId,\n\t\tvalue: Exclude<MapSchemaElement<TSchema, \"value\", Key>, undefined>,\n\t): void {\n\t\tconst allKnownState = this.datastore[key];\n\t\tallKnownState[clientId] = mergeValueDirectory(allKnownState[clientId], value, 0);\n\t}\n\n\tpublic lookupClient(clientId: ClientConnectionId): ISessionClient {\n\t\treturn this.runtime.lookupClient(clientId);\n\t}\n\n\tpublic add<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\t\tTValueManager,\n\t>(\n\t\tkey: TKey,\n\t\tnodeFactory: InternalTypes.ManagerFactory<TKey, TValue, TValueManager>,\n\t): asserts this is PresenceStates<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TValueManager>>\n\t> {\n\t\tassert(!(key in this.nodes), 0xa3c /* Already have entry for key in map */);\n\t\tconst nodeData = nodeFactory(key, handleFromDatastore(this));\n\t\tthis.nodes[key] = nodeData.manager;\n\t\tif (\"value\" in nodeData) {\n\t\t\tif (key in this.datastore) {\n\t\t\t\t// Already have received state from other clients. Kept in `all`.\n\t\t\t\t// TODO: Send current `all` state to state manager.\n\t\t\t} else {\n\t\t\t\tthis.datastore[key] = {};\n\t\t\t}\n\t\t\tthis.datastore[key][this.runtime.clientSessionId] = nodeData.value;\n\t\t\tthis.runtime.localUpdate({ [key]: nodeData.value }, false);\n\t\t}\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends PresenceStatesSchema>(\n\t\tcontent: TSchemaAdditional,\n\t): PresenceStates<TSchema & TSchemaAdditional> {\n\t\tfor (const [key, nodeFactory] of Object.entries(content)) {\n\t\t\tif (key in this.nodes) {\n\t\t\t\tconst node = unbrandIVM(this.nodes[key]);\n\t\t\t\tif (!(node instanceof nodeFactory.instanceBase)) {\n\t\t\t\t\tthrow new TypeError(`State \"${key}\" previously created by different value manager.`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.add(key, nodeFactory);\n\t\t\t}\n\t\t}\n\t\treturn this as PresenceStates<TSchema & TSchemaAdditional>;\n\t}\n\n\tpublic processUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t): void {\n\t\tfor (const [key, remoteAllKnownState] of Object.entries(remoteDatastore)) {\n\t\t\tif (key in this.nodes) {\n\t\t\t\tconst node = unbrandIVM(this.nodes[key]);\n\t\t\t\tfor (const [clientSessionId, value] of brandedObjectEntries(remoteAllKnownState)) {\n\t\t\t\t\tconst client = this.runtime.lookupClient(clientSessionId);\n\t\t\t\t\tnode.update(client, received, value);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Assume all broadcast state is meant to be kept even if not currently registered.\n\t\t\t\tmergeUntrackedDatastore(key, remoteAllKnownState, this.datastore, timeModifier);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Create a new PresenceStates using the DataStoreRuntime provided.\n * @param initialContent - The initial value managers to register.\n */\nexport function createPresenceStates<TSchema extends PresenceStatesSchema>(\n\truntime: PresenceRuntime,\n\tdatastore: ValueElementMap<PresenceStatesSchema>,\n\tinitialContent: TSchema,\n): { public: PresenceStates<TSchema>; internal: PresenceStatesInternal } {\n\tconst impl = new PresenceStatesImpl<TSchema>(runtime, datastore, initialContent);\n\n\treturn {\n\t\tpublic: impl,\n\t\tinternal: impl,\n\t};\n}\n"]}
1
+ {"version":3,"file":"presenceStates.js","sourceRoot":"","sources":["../src/presenceStates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAI7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAwH/C,SAAS,gBAAgB,CAMxB,KAAoD;IAEpD,OAAO,OAAO,IAAI,KAAK,CAAC;AACzB,CAAC;AAED,SAAS,mBAAmB,CAM3B,IAA+D,EAC/D,MAAqD,EACrD,SAAiB;IAEjB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjD,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAI,SAA0C,CAAC;IAC/C,IAAI,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G,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACvB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzC,KAAK,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,oBAAoB,CAAC,mBAAmB,CAAC,EAAE,CAAC;oBAClF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;oBAC1D,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,mFAAmF;gBACnF,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACjF,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,OAAwB,EACxB,SAAgD,EAChD,cAAuB,EACvB,QAA8C;IAE9C,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAU,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IAE3F,OAAO;QACN,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;KACd,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { BroadcastControlSettings } from \"./broadcastControls.js\";\nimport { RequiredBroadcastControl } from \"./broadcastControls.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ClientRecord } from \"./internalTypes.js\";\nimport { brandedObjectEntries } from \"./internalTypes.js\";\nimport type { ClientSessionId, ISessionClient } from \"./presence.js\";\nimport type { LocalStateUpdateOptions, StateDatastore } from \"./stateDatastore.js\";\nimport { handleFromDatastore } from \"./stateDatastore.js\";\nimport type { PresenceStates, PresenceStatesSchema } from \"./types.js\";\nimport { unbrandIVM } from \"./valueManager.js\";\n\n/**\n * Extracts `Part` from {@link InternalTypes.ManagerFactory} return type\n * matching the {@link PresenceStatesSchema} `Keys` given.\n *\n * @remarks\n * If the `Part` is an optional property, undefined will be included in the\n * result. Applying `Required` to the return type prior to extracting `Part`\n * does not work as expected. Use Exclude\\<, undefined\\> can be used as needed.\n *\n * @internal\n */\nexport type MapSchemaElement<\n\tTSchema extends PresenceStatesSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n\tKeys extends keyof TSchema = keyof TSchema,\n> = ReturnType<TSchema[Keys]>[Part];\n\n/**\n * @internal\n */\nexport interface RuntimeLocalUpdateOptions {\n\tallowableUpdateLatencyMs: number;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * @internal\n */\nexport interface PresenceRuntime {\n\treadonly clientSessionId: ClientSessionId;\n\tlookupClient(clientId: ClientConnectionId): ISessionClient;\n\tlocalUpdate(\n\t\tstates: { [key: string]: ClientUpdateEntry },\n\t\toptions: RuntimeLocalUpdateOptions,\n\t): void;\n}\n\ntype PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema extends PresenceStatesSchema,\n\tPart extends keyof ReturnType<TSchema[keyof TSchema]>,\n> = {\n\t[Key in keyof TSchema]: MapSchemaElement<TSchema, Part, Key>;\n};\n\ntype MapEntries<TSchema extends PresenceStatesSchema> = PresenceSubSchemaFromWorkspaceSchema<\n\tTSchema,\n\t\"manager\"\n>;\n\n/**\n * ValueElementMap is a map of key to a map of clientId to ValueState.\n * It is not restricted to the schema of the map as it may receive updates from other clients\n * with managers that have not been registered locally. Each map node is responsible for keeping\n * all session's state to be able to pick arbitrary client to rebroadcast to others.\n *\n * This generic aspect makes some typing difficult. The loose typing is not broadcast to the\n * consumers that are expected to maintain their schema over multiple versions of clients.\n *\n * @internal\n */\nexport interface ValueElementMap<_TSchema extends PresenceStatesSchema> {\n\t[key: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<unknown>>;\n}\n\n// An attempt to make the type more precise, but it is not working.\n// If the casting in support code is too much we could keep two references to the same\n// complete datastore, but with the respective types desired.\n// type ValueElementMap<TSchema extends PresenceStatesNodeSchema> =\n// \t| {\n// \t\t\t[Key in keyof TSchema & string]?: {\n// \t\t\t\t[ClientSessionId: ClientSessionId]: InternalTypes.ValueDirectoryOrState<MapSchemaElement<TSchema,\"value\",Key>>;\n// \t\t\t};\n// \t }\n// \t| {\n// \t\t\t[key: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<unknown>>;\n// \t };\n// interface ValueElementMap<TValue> {\n// \t[Id: string]: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// Version with local packed in is convenient for map, but not for join broadcast to serialize simply.\n// \t// [Id: string]: {\n// \t// \tlocal: InternalTypes.ValueDirectoryOrState<TValue>;\n// \t// \tall: ClientRecord<InternalTypes.ValueDirectoryOrState<TValue>>;\n// \t// };\n// }\n\n/**\n * @internal\n */\nexport type ClientUpdateEntry = InternalTypes.ValueDirectoryOrState<unknown> & {\n\tignoreUnmonitored?: true;\n};\n\ntype ClientUpdateRecord = ClientRecord<ClientUpdateEntry>;\n\ninterface ValueUpdateRecord {\n\t[valueKey: string]: ClientUpdateRecord;\n}\n\n/**\n * @internal\n */\nexport interface PresenceStatesInternal {\n\tensureContent<TSchemaAdditional extends PresenceStatesSchema>(\n\t\tcontent: TSchemaAdditional,\n\t\tcontrols: BroadcastControlSettings | undefined,\n\t): PresenceStates<TSchemaAdditional>;\n\tprocessUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t\tsenderConnectionId: ClientConnectionId,\n\t): void;\n}\n\nfunction isValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tvalue: InternalTypes.ValueDirectory<T> | TValueState,\n): value is InternalTypes.ValueDirectory<T> {\n\treturn \"items\" in value;\n}\n\nfunction mergeValueDirectory<\n\tT,\n\tTValueState extends\n\t\t| InternalTypes.ValueRequiredState<T>\n\t\t| InternalTypes.ValueOptionalState<T>,\n>(\n\tbase: TValueState | InternalTypes.ValueDirectory<T> | undefined,\n\tupdate: TValueState | InternalTypes.ValueDirectory<T>,\n\ttimeDelta: number,\n): TValueState | InternalTypes.ValueDirectory<T> {\n\tif (!isValueDirectory(update)) {\n\t\tif (base === undefined || update.rev > base.rev) {\n\t\t\treturn { ...update, timestamp: update.timestamp + timeDelta };\n\t\t}\n\t\treturn base;\n\t}\n\n\tlet mergeBase: InternalTypes.ValueDirectory<T>;\n\tif (base === undefined) {\n\t\tmergeBase = { rev: update.rev, items: {} };\n\t} else {\n\t\tconst baseIsDirectory = isValueDirectory(base);\n\t\tif (base.rev >= update.rev) {\n\t\t\tif (!baseIsDirectory) {\n\t\t\t\t// base is leaf value that is more recent - nothing to do\n\t\t\t\treturn base;\n\t\t\t}\n\t\t\t// While base has more advanced revision, assume mis-ordering or\n\t\t\t// missed and catchup update needs merged in.\n\t\t\tmergeBase = base;\n\t\t} else {\n\t\t\tmergeBase = { rev: update.rev, items: baseIsDirectory ? base.items : {} };\n\t\t}\n\t}\n\tfor (const [key, value] of Object.entries(update.items)) {\n\t\tconst baseElement = mergeBase.items[key];\n\t\tmergeBase.items[key] = mergeValueDirectory(baseElement, value, timeDelta);\n\t}\n\treturn mergeBase;\n}\n\n/**\n * Updates remote state into the local [untracked] datastore.\n *\n * @param key - The key of the datastore to merge the untracked data into.\n * @param remoteAllKnownState - The remote state to merge into the datastore.\n * @param datastore - The datastore to merge the untracked data into.\n *\n * @remarks\n * In the case of ignored unmonitored data, the client entries are not stored,\n * though the value keys will be populated and often remain empty.\n *\n * @internal\n */\nexport function mergeUntrackedDatastore(\n\tkey: string,\n\tremoteAllKnownState: ClientUpdateRecord,\n\tdatastore: ValueElementMap<PresenceStatesSchema>,\n\ttimeModifier: number,\n): void {\n\tif (!(key in datastore)) {\n\t\tdatastore[key] = {};\n\t}\n\tconst localAllKnownState = datastore[key];\n\tfor (const [clientSessionId, value] of brandedObjectEntries(remoteAllKnownState)) {\n\t\tif (!(\"ignoreUnmonitored\" in value)) {\n\t\t\tlocalAllKnownState[clientSessionId] = mergeValueDirectory(\n\t\t\t\tlocalAllKnownState[clientSessionId],\n\t\t\t\tvalue,\n\t\t\t\ttimeModifier,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/**\n * The default allowable update latency for PresenceStates workspaces in milliseconds.\n */\nconst defaultAllowableUpdateLatencyMs = 60;\n\n/**\n * Produces the value type of a schema element or set of elements.\n */\ntype SchemaElementValueType<\n\tTSchema extends PresenceStatesSchema,\n\tKeys extends keyof TSchema & string,\n> = Exclude<MapSchemaElement<TSchema, \"initialData\", Keys>, undefined>[\"value\"];\n\nclass PresenceStatesImpl<TSchema extends PresenceStatesSchema>\n\timplements\n\t\tPresenceStatesInternal,\n\t\tPresenceStates<TSchema>,\n\t\tStateDatastore<\n\t\t\tkeyof TSchema & string,\n\t\t\tSchemaElementValueType<TSchema, keyof TSchema & string>\n\t\t>\n{\n\tprivate readonly nodes: MapEntries<TSchema>;\n\tpublic readonly props: PresenceStates<TSchema>[\"props\"];\n\n\tpublic readonly controls: RequiredBroadcastControl;\n\n\tpublic constructor(\n\t\tprivate readonly runtime: PresenceRuntime,\n\t\tprivate readonly datastore: ValueElementMap<TSchema>,\n\t\tinitialContent: TSchema,\n\t\tcontrolsSettings: BroadcastControlSettings | undefined,\n\t) {\n\t\tthis.controls = new RequiredBroadcastControl(defaultAllowableUpdateLatencyMs);\n\t\tif (controlsSettings?.allowableUpdateLatencyMs !== undefined) {\n\t\t\tthis.controls.allowableUpdateLatencyMs = controlsSettings.allowableUpdateLatencyMs;\n\t\t}\n\n\t\t// Prepare initial map content from initial state\n\t\t{\n\t\t\tconst clientSessionId = this.runtime.clientSessionId;\n\t\t\tlet anyInitialValues = false;\n\t\t\tlet cumulativeAllowableUpdateLatencyMs: number | undefined;\n\t\t\t// eslint-disable-next-line unicorn/no-array-reduce\n\t\t\tconst initial = Object.entries(initialContent).reduce(\n\t\t\t\t(acc, [key, nodeFactory]) => {\n\t\t\t\t\tconst newNodeData = nodeFactory(key, handleFromDatastore(this));\n\t\t\t\t\tacc.nodes[key as keyof TSchema] = newNodeData.manager;\n\t\t\t\t\tif (\"initialData\" in newNodeData) {\n\t\t\t\t\t\tconst { value, allowableUpdateLatencyMs } = newNodeData.initialData;\n\t\t\t\t\t\tacc.datastore[key] = acc.datastore[key] ?? {};\n\t\t\t\t\t\tacc.datastore[key][clientSessionId] = value;\n\t\t\t\t\t\tacc.newValues[key] = value;\n\t\t\t\t\t\tif (allowableUpdateLatencyMs !== undefined) {\n\t\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs =\n\t\t\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs === undefined\n\t\t\t\t\t\t\t\t\t? allowableUpdateLatencyMs\n\t\t\t\t\t\t\t\t\t: Math.min(cumulativeAllowableUpdateLatencyMs, allowableUpdateLatencyMs);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanyInitialValues = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\t\tnodes: {} as MapEntries<TSchema>,\n\t\t\t\t\tdatastore,\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\t\tnewValues: {} as { [key: string]: InternalTypes.ValueDirectoryOrState<unknown> },\n\t\t\t\t},\n\t\t\t);\n\t\t\tthis.nodes = initial.nodes;\n\t\t\t// props is the public view of nodes that limits the entries types to\n\t\t\t// the public interface of the value manager with an additional type\n\t\t\t// filter that beguiles the type system. So just reinterpret cast.\n\t\t\tthis.props = this.nodes as unknown as PresenceStates<TSchema>[\"props\"];\n\n\t\t\tif (anyInitialValues) {\n\t\t\t\tthis.runtime.localUpdate(initial.newValues, {\n\t\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\t\tcumulativeAllowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic knownValues<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t): {\n\t\tself: ClientSessionId | undefined;\n\t\tstates: ClientRecord<SchemaElementValueType<TSchema, Key>>;\n\t} {\n\t\treturn {\n\t\t\tself: this.runtime.clientSessionId,\n\t\t\tstates: this.datastore[key],\n\t\t};\n\t}\n\n\tpublic localUpdate<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tvalue: SchemaElementValueType<TSchema, Key> & ClientUpdateEntry,\n\t\toptions: LocalStateUpdateOptions,\n\t): void {\n\t\tthis.runtime.localUpdate(\n\t\t\t{ [key]: value },\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\toptions.allowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t},\n\t\t);\n\t}\n\n\tpublic update<Key extends keyof TSchema & string>(\n\t\tkey: Key,\n\t\tclientId: ClientSessionId,\n\t\tvalue: Exclude<MapSchemaElement<TSchema, \"initialData\", Key>, undefined>[\"value\"],\n\t): void {\n\t\tconst allKnownState = this.datastore[key];\n\t\tallKnownState[clientId] = mergeValueDirectory(allKnownState[clientId], value, 0);\n\t}\n\n\tpublic lookupClient(clientId: ClientConnectionId): ISessionClient {\n\t\treturn this.runtime.lookupClient(clientId);\n\t}\n\n\tpublic add<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\t\tTValueManager,\n\t>(\n\t\tkey: TKey,\n\t\tnodeFactory: InternalTypes.ManagerFactory<TKey, TValue, TValueManager>,\n\t): asserts this is PresenceStates<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TValueManager>>\n\t> {\n\t\tassert(!(key in this.nodes), 0xa3c /* Already have entry for key in map */);\n\t\tconst nodeData = nodeFactory(key, handleFromDatastore(this));\n\t\tthis.nodes[key] = nodeData.manager;\n\t\tif (\"initialData\" in nodeData) {\n\t\t\tconst { value, allowableUpdateLatencyMs } = nodeData.initialData;\n\t\t\tif (key in this.datastore) {\n\t\t\t\t// Already have received state from other clients. Kept in `all`.\n\t\t\t\t// TODO: Send current `all` state to state manager.\n\t\t\t} else {\n\t\t\t\tthis.datastore[key] = {};\n\t\t\t}\n\t\t\tthis.datastore[key][this.runtime.clientSessionId] = value;\n\t\t\tthis.runtime.localUpdate(\n\t\t\t\t{ [key]: value },\n\t\t\t\t{\n\t\t\t\t\tallowableUpdateLatencyMs:\n\t\t\t\t\t\tallowableUpdateLatencyMs ?? this.controls.allowableUpdateLatencyMs,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic ensureContent<TSchemaAdditional extends PresenceStatesSchema>(\n\t\tcontent: TSchemaAdditional,\n\t\tcontrols: BroadcastControlSettings | undefined,\n\t): PresenceStates<TSchema & TSchemaAdditional> {\n\t\tif (controls?.allowableUpdateLatencyMs !== undefined) {\n\t\t\tthis.controls.allowableUpdateLatencyMs = controls.allowableUpdateLatencyMs;\n\t\t}\n\t\tfor (const [key, nodeFactory] of Object.entries(content)) {\n\t\t\tif (key in this.nodes) {\n\t\t\t\tconst node = unbrandIVM(this.nodes[key]);\n\t\t\t\tif (!(node instanceof nodeFactory.instanceBase)) {\n\t\t\t\t\tthrow new TypeError(`State \"${key}\" previously created by different value manager.`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.add(key, nodeFactory);\n\t\t\t}\n\t\t}\n\t\treturn this as PresenceStates<TSchema & TSchemaAdditional>;\n\t}\n\n\tpublic processUpdate(\n\t\treceived: number,\n\t\ttimeModifier: number,\n\t\tremoteDatastore: ValueUpdateRecord,\n\t): void {\n\t\tfor (const [key, remoteAllKnownState] of Object.entries(remoteDatastore)) {\n\t\t\tif (key in this.nodes) {\n\t\t\t\tconst node = unbrandIVM(this.nodes[key]);\n\t\t\t\tfor (const [clientSessionId, value] of brandedObjectEntries(remoteAllKnownState)) {\n\t\t\t\t\tconst client = this.runtime.lookupClient(clientSessionId);\n\t\t\t\t\tnode.update(client, received, value);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Assume all broadcast state is meant to be kept even if not currently registered.\n\t\t\t\tmergeUntrackedDatastore(key, remoteAllKnownState, this.datastore, timeModifier);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Create a new PresenceStates using the DataStoreRuntime provided.\n * @param initialContent - The initial value managers to register.\n */\nexport function createPresenceStates<TSchema extends PresenceStatesSchema>(\n\truntime: PresenceRuntime,\n\tdatastore: ValueElementMap<PresenceStatesSchema>,\n\tinitialContent: TSchema,\n\tcontrols: BroadcastControlSettings | undefined,\n): { public: PresenceStates<TSchema>; internal: PresenceStatesInternal } {\n\tconst impl = new PresenceStatesImpl<TSchema>(runtime, datastore, initialContent, controls);\n\n\treturn {\n\t\tpublic: impl,\n\t\tinternal: impl,\n\t};\n}\n"]}
@@ -9,10 +9,20 @@ import type { ClientSessionId, ISessionClient } from "./presence.js";
9
9
  /**
10
10
  * @internal
11
11
  */
12
- export interface StateDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any> | undefined> {
12
+ export interface LocalStateUpdateOptions {
13
+ allowableUpdateLatencyMs: number | undefined;
14
+ /**
15
+ * Special option allowed for unicast notifications.
16
+ */
17
+ targetClientId?: ClientConnectionId;
18
+ }
19
+ /**
20
+ * @internal
21
+ */
22
+ export interface StateDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>> {
13
23
  localUpdate(key: TKey, value: TValue & {
14
24
  ignoreUnmonitored?: true;
15
- }, forceBroadcast: boolean): void;
25
+ }, options: LocalStateUpdateOptions): void;
16
26
  update(key: TKey, clientSessionId: ClientSessionId, value: TValue): void;
17
27
  knownValues(key: TKey): {
18
28
  self: ClientSessionId | undefined;
@@ -25,7 +35,7 @@ export interface StateDatastore<TKey extends string, TValue extends InternalType
25
35
  *
26
36
  * @internal
27
37
  */
28
- export declare function handleFromDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown> | undefined>(datastore: StateDatastore<TKey, TValue>): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>>;
38
+ export declare function handleFromDatastore<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>>(datastore: StateDatastore<TKey, TValue>): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>>;
29
39
  /**
30
40
  * Helper to get the datastore back from its handle.
31
41
  *
@@ -1 +1 @@
1
- {"version":3,"file":"stateDatastore.d.ts","sourceRoot":"","sources":["../src/stateDatastore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAiBrE;;GAEG;AACH,MAAM,WAAW,cAAc,CAC9B,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,SAAS;IAEnE,WAAW,CACV,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,GAAG;QACf,iBAAiB,CAAC,EAAE,IAAI,CAAC;KACzB,EACD,cAAc,EAAE,OAAO,GACrB,IAAI,CAAC;IACR,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACzE,WAAW,CAA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;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAGjC,MAAwD;IACzD,OAAO,MAAiD,CAAC;AAC1D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ClientRecord } from \"./internalTypes.js\";\nimport type { ClientSessionId, ISessionClient } from \"./presence.js\";\n\n// type StateDatastoreSchemaNode<\n// \tTValue extends InternalTypes.ValueDirectoryOrState<any> = InternalTypes.ValueDirectoryOrState<unknown>,\n// > = TValue extends InternalTypes.ValueDirectoryOrState<infer T> ? InternalTypes.ValueDirectoryOrState<T> : never;\n\n// /**\n// * @internal\n// */\n// export interface StateDatastoreSchema {\n// \t// This type is not precise. It may\n// \t// need to be replaced with PresenceStates schema pattern\n// \t// similar to what is commented out.\n// \t[key: string]: InternalTypes.ValueDirectoryOrState<unknown>;\n// \t// [key: string]: StateDatastoreSchemaNode;\n// }\n\n/**\n * @internal\n */\nexport interface StateDatastore<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<any> | undefined,\n> {\n\tlocalUpdate(\n\t\tkey: TKey,\n\t\tvalue: TValue & {\n\t\t\tignoreUnmonitored?: true;\n\t\t},\n\t\tforceBroadcast: boolean,\n\t): void;\n\tupdate(key: TKey, clientSessionId: ClientSessionId, value: TValue): void;\n\tknownValues(key: TKey): {\n\t\tself: ClientSessionId | undefined;\n\t\tstates: ClientRecord<TValue>;\n\t};\n\tlookupClient(clientId: ClientConnectionId): ISessionClient;\n}\n\n/**\n * Helper to get a handle from a datastore.\n *\n * @internal\n */\nexport function handleFromDatastore<\n\t// Constraining TSchema would be great, but it seems nested types (at least with undefined) cause trouble.\n\t// TSchema as `unknown` still provides some type safety.\n\t// TSchema extends StateDatastoreSchema,\n\tTKey extends string /* & keyof TSchema */,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown> | undefined,\n>(\n\tdatastore: StateDatastore<TKey, TValue>,\n): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>> {\n\treturn datastore as unknown as InternalTypes.StateDatastoreHandle<\n\t\tTKey,\n\t\tExclude<TValue, undefined>\n\t>;\n}\n\n/**\n * Helper to get the datastore back from its handle.\n *\n * @internal\n */\nexport function datastoreFromHandle<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue> {\n\treturn handle as unknown as StateDatastore<TKey, TValue>;\n}\n"]}
1
+ {"version":3,"file":"stateDatastore.js","sourceRoot":"","sources":["../src/stateDatastore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwDH;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAOlC,SAAuC;IAEvC,OAAO,SAGN,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAGjC,MAAwD;IACzD,OAAO,MAAiD,CAAC;AAC1D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ClientConnectionId } from \"./baseTypes.js\";\nimport type { InternalTypes } from \"./exposedInternalTypes.js\";\nimport type { ClientRecord } from \"./internalTypes.js\";\nimport type { ClientSessionId, ISessionClient } from \"./presence.js\";\n\n// type StateDatastoreSchemaNode<\n// \tTValue extends InternalTypes.ValueDirectoryOrState<any> = InternalTypes.ValueDirectoryOrState<unknown>,\n// > = TValue extends InternalTypes.ValueDirectoryOrState<infer T> ? InternalTypes.ValueDirectoryOrState<T> : never;\n\n// /**\n// * @internal\n// */\n// export interface StateDatastoreSchema {\n// \t// This type is not precise. It may\n// \t// need to be replaced with PresenceStates schema pattern\n// \t// similar to what is commented out.\n// \t[key: string]: InternalTypes.ValueDirectoryOrState<unknown>;\n// \t// [key: string]: StateDatastoreSchemaNode;\n// }\n\n/**\n * @internal\n */\nexport interface LocalStateUpdateOptions {\n\tallowableUpdateLatencyMs: number | undefined;\n\n\t/**\n\t * Special option allowed for unicast notifications.\n\t */\n\ttargetClientId?: ClientConnectionId;\n}\n\n/**\n * @internal\n */\nexport interface StateDatastore<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n> {\n\tlocalUpdate(\n\t\tkey: TKey,\n\t\tvalue: TValue & {\n\t\t\tignoreUnmonitored?: true;\n\t\t},\n\t\toptions: LocalStateUpdateOptions,\n\t): void;\n\tupdate(key: TKey, clientSessionId: ClientSessionId, value: TValue): void;\n\tknownValues(key: TKey): {\n\t\tself: ClientSessionId | undefined;\n\t\tstates: ClientRecord<TValue>;\n\t};\n\tlookupClient(clientId: ClientConnectionId): ISessionClient;\n}\n\n/**\n * Helper to get a handle from a datastore.\n *\n * @internal\n */\nexport function handleFromDatastore<\n\t// Constraining TSchema would be great, but it seems nested types (at least with undefined) cause trouble.\n\t// TSchema as `unknown` still provides some type safety.\n\t// TSchema extends StateDatastoreSchema,\n\tTKey extends string /* & keyof TSchema */,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n>(\n\tdatastore: StateDatastore<TKey, TValue>,\n): InternalTypes.StateDatastoreHandle<TKey, Exclude<TValue, undefined>> {\n\treturn datastore as unknown as InternalTypes.StateDatastoreHandle<\n\t\tTKey,\n\t\tExclude<TValue, undefined>\n\t>;\n}\n\n/**\n * Helper to get the datastore back from its handle.\n *\n * @internal\n */\nexport function datastoreFromHandle<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n>(handle: InternalTypes.StateDatastoreHandle<TKey, TValue>): StateDatastore<TKey, TValue> {\n\treturn handle as unknown as StateDatastore<TKey, TValue>;\n}\n"]}
package/lib/types.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import type { BroadcastControls } from "./broadcastControls.js";
5
6
  import type { NotificationsManager } from "./notificationsManager.js";
6
7
  import type { InternalTypes } from "@fluidframework/presence/internal/exposedInternalTypes";
7
8
  /**
@@ -22,11 +23,11 @@ import type { InternalTypes } from "@fluidframework/presence/internal/exposedInt
22
23
  */
23
24
  export type PresenceWorkspaceAddress = `${string}:${string}`;
24
25
  /**
25
- * Single entry in {@link PresenceStatesSchema}.
26
+ * Single entry in {@link PresenceStatesSchema} or {@link PresenceNotificationsSchema}.
26
27
  *
27
28
  * @alpha
28
29
  */
29
- export type PresenceStatesEntry<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>, TManager = unknown> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;
30
+ export type PresenceWorkspaceEntry<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<unknown>, TManager = unknown> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;
30
31
  /**
31
32
  * Schema for a {@link PresenceStates} workspace.
32
33
  *
@@ -35,7 +36,7 @@ export type PresenceStatesEntry<TKey extends string, TValue extends InternalType
35
36
  * @alpha
36
37
  */
37
38
  export interface PresenceStatesSchema {
38
- [key: string]: PresenceStatesEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;
39
+ [key: string]: PresenceWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;
39
40
  }
40
41
  /**
41
42
  * Map of `Value Manager`s registered with {@link PresenceStates}.
@@ -62,7 +63,7 @@ export type PresenceStatesEntries<TSchema extends PresenceStatesSchema> = {
62
63
  export interface PresenceStates<TSchema extends PresenceStatesSchema, TManagerConstraints = unknown> {
63
64
  /**
64
65
  * Registers a new `Value Manager` with the {@link PresenceStates}.
65
- * @param key - new unique key for the `Value Manager`
66
+ * @param key - new unique key for the `Value Manager` within the workspace
66
67
  * @param manager - factory for creating a `Value Manager`
67
68
  */
68
69
  add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>, TManager extends TManagerConstraints>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is PresenceStates<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>, TManagerConstraints>;
@@ -70,6 +71,10 @@ export interface PresenceStates<TSchema extends PresenceStatesSchema, TManagerCo
70
71
  * Registry of `Value Manager`s.
71
72
  */
72
73
  readonly props: PresenceStatesEntries<TSchema>;
74
+ /**
75
+ * Default controls for management of broadcast updates.
76
+ */
77
+ readonly controls: BroadcastControls;
73
78
  }
74
79
  /**
75
80
  * Schema for a {@link PresenceNotifications} workspace.
@@ -85,8 +90,25 @@ export interface PresenceNotificationsSchema {
85
90
  * `PresenceNotifications` maintains a registry of {@link NotificationsManager}s
86
91
  * that facilitate messages across client members in a session.
87
92
  *
93
+ * @privateRemarks
94
+ * This should be kept mostly in sync with {@link PresenceStates}. Notably the
95
+ * return type of `add` is limited here and the `controls` property is omitted.
96
+ * The `PresenceStatesImpl` class implements `PresenceStates` and therefore
97
+ * `PresenceNotifications`, so long as this is proper subset.
98
+ *
88
99
  * @sealed
89
100
  * @alpha
90
101
  */
91
- export type PresenceNotifications<TSchema extends PresenceNotificationsSchema> = PresenceStates<TSchema, NotificationsManager<any>>;
102
+ export interface PresenceNotifications<TSchema extends PresenceNotificationsSchema> {
103
+ /**
104
+ * Registers a new `Value Manager` with the {@link PresenceNotifications}.
105
+ * @param key - new unique key for the `Value Manager` within the workspace
106
+ * @param manager - factory for creating a `Value Manager`
107
+ */
108
+ add<TKey extends string, TValue extends InternalTypes.ValueDirectoryOrState<any>, TManager extends NotificationsManager<any>>(key: TKey, manager: InternalTypes.ManagerFactory<TKey, TValue, TManager>): asserts this is PresenceNotifications<TSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>>;
109
+ /**
110
+ * Registry of `Value Manager`s.
111
+ */
112
+ readonly props: PresenceStatesEntries<TSchema>;
113
+ }
92
114
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","s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EACV,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAChE,oBAAoB,CAAC,GAAG,CAAC,CACzB,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,qBAAqB,CAAC,OAAO,SAAS,2BAA2B;IACjF;;;;OAIG;IACH,GAAG,CACF,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,aAAa,CAAC,qBAAqB,CAAC,GAAG,CAAC,EACvD,QAAQ,SAAS,oBAAoB,CAAC,GAAG,CAAC,EAE1C,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,GAC3D,OAAO,CAAC,IAAI,IAAI,qBAAqB,CACvC,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAC5E,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;CAC/C"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAmIH,mCAAmC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { NotificationsManager } from \"./notificationsManager.js\";\n\nimport type { InternalTypes } from \"@fluidframework/presence/internal/exposedInternalTypes\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @alpha\n */\nexport type PresenceWorkspaceAddress = `${string}:${string}`;\n\n// #region PresenceStates\n\n/**\n * Single entry in {@link PresenceStatesSchema}.\n *\n * @alpha\n */\nexport type PresenceStatesEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n/**\n * Schema for a {@link PresenceStates} workspace.\n *\n * Keys of schema are the keys of the {@link PresenceStates} providing access to `Value Manager`s.\n *\n * @alpha\n */\nexport interface PresenceStatesSchema {\n\t[key: string]: PresenceStatesEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;\n}\n\n/**\n * Map of `Value Manager`s registered with {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport type PresenceStatesEntries<TSchema extends PresenceStatesSchema> = {\n\t/**\n\t * Registered `Value Manager`s\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `PresenceStates` maintains a registry of `Value Manager`s that all share and provide access to\n * presence state values across client members in a session.\n *\n * `Value Manager`s offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @alpha\n */\nexport interface PresenceStates<\n\tTSchema extends PresenceStatesSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new `Value Manager` with the {@link PresenceStates}.\n\t * @param key - new unique key for the `Value Manager`\n\t * @param manager - factory for creating a `Value Manager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is PresenceStates<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of `Value Manager`s.\n\t */\n\treadonly props: PresenceStatesEntries<TSchema>;\n}\n\n// #endregion PresenceStates\n\n// #region PresenceNotifications\n\n/**\n * Schema for a {@link PresenceNotifications} workspace.\n *\n * Keys of schema are the keys of the {@link PresenceNotifications} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface PresenceNotificationsSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<any>\n\t>;\n}\n\n/**\n * `PresenceNotifications` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @sealed\n * @alpha\n */\nexport type PresenceNotifications<TSchema extends PresenceNotificationsSchema> =\n\tPresenceStates<TSchema, NotificationsManager<any>>;\n\n// #endregion PresenceNotifications\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAmKH,mCAAmC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { BroadcastControls } from \"./broadcastControls.js\";\nimport type { NotificationsManager } from \"./notificationsManager.js\";\n\nimport type { InternalTypes } from \"@fluidframework/presence/internal/exposedInternalTypes\";\n\n/**\n * Unique address within a session.\n *\n * @remarks\n * A string known to all clients working with a certain Workspace and unique\n * among Workspaces. Recommend using specifying concatenation of: type of\n * unique identifier, `:` (required), and unique identifier.\n *\n * @example Examples\n * ```typescript\n * \"guid:g0fl001d-1415-5000-c00l-g0fa54g0b1g1\"\n * \"address:object0/sub-object2:pointers\"\n * ```\n *\n * @alpha\n */\nexport type PresenceWorkspaceAddress = `${string}:${string}`;\n\n/**\n * Single entry in {@link PresenceStatesSchema} or {@link PresenceNotificationsSchema}.\n *\n * @alpha\n */\nexport type PresenceWorkspaceEntry<\n\tTKey extends string,\n\tTValue extends InternalTypes.ValueDirectoryOrState<unknown>,\n\tTManager = unknown,\n> = InternalTypes.ManagerFactory<TKey, TValue, TManager>;\n\n// #region PresenceStates\n\n/**\n * Schema for a {@link PresenceStates} workspace.\n *\n * Keys of schema are the keys of the {@link PresenceStates} providing access to `Value Manager`s.\n *\n * @alpha\n */\nexport interface PresenceStatesSchema {\n\t[key: string]: PresenceWorkspaceEntry<typeof key, InternalTypes.ValueDirectoryOrState<any>>;\n}\n\n/**\n * Map of `Value Manager`s registered with {@link PresenceStates}.\n *\n * @sealed\n * @alpha\n */\nexport type PresenceStatesEntries<TSchema extends PresenceStatesSchema> = {\n\t/**\n\t * Registered `Value Manager`s\n\t */\n\treadonly [Key in keyof TSchema]: ReturnType<\n\t\tTSchema[Key]\n\t>[\"manager\"] extends InternalTypes.StateValue<infer TManager>\n\t\t? TManager\n\t\t: never;\n};\n\n/**\n * `PresenceStates` maintains a registry of `Value Manager`s that all share and provide access to\n * presence state values across client members in a session.\n *\n * `Value Manager`s offer variations on how to manage states, but all share same principle that\n * each client's state is independent and may only be updated by originating client.\n *\n * @sealed\n * @alpha\n */\nexport interface PresenceStates<\n\tTSchema extends PresenceStatesSchema,\n\tTManagerConstraints = unknown,\n> {\n\t/**\n\t * Registers a new `Value Manager` with the {@link PresenceStates}.\n\t * @param key - new unique key for the `Value Manager` within the workspace\n\t * @param manager - factory for creating a `Value Manager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends TManagerConstraints,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is PresenceStates<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>,\n\t\tTManagerConstraints\n\t>;\n\n\t/**\n\t * Registry of `Value Manager`s.\n\t */\n\treadonly props: PresenceStatesEntries<TSchema>;\n\n\t/**\n\t * Default controls for management of broadcast updates.\n\t */\n\treadonly controls: BroadcastControls;\n}\n\n// #endregion PresenceStates\n\n// #region PresenceNotifications\n\n/**\n * Schema for a {@link PresenceNotifications} workspace.\n *\n * Keys of schema are the keys of the {@link PresenceNotifications} providing access to {@link NotificationsManager}s.\n *\n * @alpha\n */\nexport interface PresenceNotificationsSchema {\n\t[key: string]: InternalTypes.ManagerFactory<\n\t\ttypeof key,\n\t\tInternalTypes.ValueRequiredState<InternalTypes.NotificationType>,\n\t\tNotificationsManager<any>\n\t>;\n}\n\n/**\n * `PresenceNotifications` maintains a registry of {@link NotificationsManager}s\n * that facilitate messages across client members in a session.\n *\n * @privateRemarks\n * This should be kept mostly in sync with {@link PresenceStates}. Notably the\n * return type of `add` is limited here and the `controls` property is omitted.\n * The `PresenceStatesImpl` class implements `PresenceStates` and therefore\n * `PresenceNotifications`, so long as this is proper subset.\n *\n * @sealed\n * @alpha\n */\nexport interface PresenceNotifications<TSchema extends PresenceNotificationsSchema> {\n\t/**\n\t * Registers a new `Value Manager` with the {@link PresenceNotifications}.\n\t * @param key - new unique key for the `Value Manager` within the workspace\n\t * @param manager - factory for creating a `Value Manager`\n\t */\n\tadd<\n\t\tTKey extends string,\n\t\tTValue extends InternalTypes.ValueDirectoryOrState<any>,\n\t\tTManager extends NotificationsManager<any>,\n\t>(\n\t\tkey: TKey,\n\t\tmanager: InternalTypes.ManagerFactory<TKey, TValue, TManager>,\n\t): asserts this is PresenceNotifications<\n\t\tTSchema & Record<TKey, InternalTypes.ManagerFactory<TKey, TValue, TManager>>\n\t>;\n\n\t/**\n\t * Registry of `Value Manager`s.\n\t */\n\treadonly props: PresenceStatesEntries<TSchema>;\n}\n\n// #endregion PresenceNotifications\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/presence",
3
- "version": "2.10.0-307399",
3
+ "version": "2.10.0",
4
4
  "description": "A component for lightweight data sharing within a single session",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -73,19 +73,19 @@
73
73
  "temp-directory": "nyc/.nyc_output"
74
74
  },
75
75
  "dependencies": {
76
- "@fluidframework/container-definitions": "2.10.0-307399",
77
- "@fluidframework/container-loader": "2.10.0-307399",
78
- "@fluidframework/container-runtime-definitions": "2.10.0-307399",
79
- "@fluidframework/core-interfaces": "2.10.0-307399",
80
- "@fluidframework/core-utils": "2.10.0-307399",
81
- "@fluidframework/datastore": "2.10.0-307399",
82
- "@fluidframework/datastore-definitions": "2.10.0-307399",
83
- "@fluidframework/fluid-static": "2.10.0-307399",
84
- "@fluidframework/id-compressor": "2.10.0-307399",
85
- "@fluidframework/runtime-definitions": "2.10.0-307399",
86
- "@fluidframework/runtime-utils": "2.10.0-307399",
87
- "@fluidframework/shared-object-base": "2.10.0-307399",
88
- "@fluidframework/telemetry-utils": "2.10.0-307399"
76
+ "@fluidframework/container-definitions": "~2.10.0",
77
+ "@fluidframework/container-loader": "~2.10.0",
78
+ "@fluidframework/container-runtime-definitions": "~2.10.0",
79
+ "@fluidframework/core-interfaces": "~2.10.0",
80
+ "@fluidframework/core-utils": "~2.10.0",
81
+ "@fluidframework/datastore": "~2.10.0",
82
+ "@fluidframework/datastore-definitions": "~2.10.0",
83
+ "@fluidframework/fluid-static": "~2.10.0",
84
+ "@fluidframework/id-compressor": "~2.10.0",
85
+ "@fluidframework/runtime-definitions": "~2.10.0",
86
+ "@fluidframework/runtime-utils": "~2.10.0",
87
+ "@fluidframework/shared-object-base": "~2.10.0",
88
+ "@fluidframework/telemetry-utils": "~2.10.0"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@arethetypeswrong/cli": "^0.16.4",
@@ -93,11 +93,11 @@
93
93
  "@fluid-tools/build-cli": "^0.51.0",
94
94
  "@fluidframework/build-common": "^2.0.3",
95
95
  "@fluidframework/build-tools": "^0.51.0",
96
- "@fluidframework/driver-definitions": "2.10.0-307399",
96
+ "@fluidframework/driver-definitions": "~2.10.0",
97
97
  "@fluidframework/eslint-config-fluid": "^5.4.0",
98
98
  "@fluidframework/presence-previous": "npm:@fluid-experimental/presence@2.5.0",
99
- "@fluidframework/test-runtime-utils": "2.10.0-307399",
100
- "@fluidframework/test-utils": "2.10.0-307399",
99
+ "@fluidframework/test-runtime-utils": "~2.10.0",
100
+ "@fluidframework/test-utils": "~2.10.0",
101
101
  "@microsoft/api-extractor": "7.47.8",
102
102
  "@types/mocha": "^9.1.1",
103
103
  "@types/node": "^18.19.0",
@@ -1,44 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * Common controls for the Latest* Value Managers.
7
- *
8
- * @alpha
9
- */
10
- export interface LatestValueControls {
11
- /**
12
- * Maximum time in milliseconds that a local value update is allowed
13
- * to remain pending before it must be broadcast.
14
- *
15
- * @remarks There is no guarantee of broadcast within time allowed
16
- * as other conditions such as disconnect or service throttling may
17
- * cause a delay.
18
- */
19
- allowableUpdateLatency: number;
20
- /**
21
- * Target time in milliseconds between oldest changed local state
22
- * has been broadcast and forced rebroadcast of all local values.
23
- * A value of less than 10 disables forced refresh.
24
- *
25
- * @defaultValue 0
26
- *
27
- * @privateRemarks
28
- * Any time less than 10 milliseconds is likely to generate too
29
- * many signals. Ideally this feature becomes obsolete as
30
- * we understand the system better and account for holes.
31
- */
32
- forcedRefreshInterval: number;
33
- }
34
- /**
35
- * @internal
36
- */
37
- export declare class LatestValueControl implements LatestValueControls {
38
- allowableUpdateLatency: number;
39
- private _forcedRefreshInterval;
40
- constructor(settings: LatestValueControls);
41
- get forcedRefreshInterval(): number;
42
- set forcedRefreshInterval(value: number);
43
- }
44
- //# sourceMappingURL=latestValueControls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueControls.d.ts","sourceRoot":"","sources":["../src/latestValueControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;OAOG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;;;;;;;;;;OAWG;IACH,qBAAqB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IACtD,sBAAsB,EAAE,MAAM,CAAC;IACtC,OAAO,CAAC,sBAAsB,CAAS;gBAEpB,QAAQ,EAAE,mBAAmB;IAKhD,IAAW,qBAAqB,IAAI,MAAM,CAEzC;IACD,IAAW,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAM7C;CACD"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LatestValueControl = void 0;
8
- /**
9
- * @internal
10
- */
11
- class LatestValueControl {
12
- constructor(settings) {
13
- this.allowableUpdateLatency = settings.allowableUpdateLatency;
14
- this._forcedRefreshInterval = settings.forcedRefreshInterval;
15
- }
16
- get forcedRefreshInterval() {
17
- return this._forcedRefreshInterval;
18
- }
19
- set forcedRefreshInterval(value) {
20
- this._forcedRefreshInterval = value < 10 ? 0 : value;
21
- if (this._forcedRefreshInterval >= 10) {
22
- // TODO: enable periodic forced refresh
23
- throw new Error("Forced Refresh feature is not implemented");
24
- }
25
- }
26
- }
27
- exports.LatestValueControl = LatestValueControl;
28
- //# sourceMappingURL=latestValueControls.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueControls.js","sourceRoot":"","sources":["../src/latestValueControls.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAiCH;;GAEG;AACH,MAAa,kBAAkB;IAI9B,YAAmB,QAA6B;QAC/C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC9D,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IAC9D,CAAC;IAED,IAAW,qBAAqB;QAC/B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACpC,CAAC;IACD,IAAW,qBAAqB,CAAC,KAAa;QAC7C,IAAI,CAAC,sBAAsB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrD,IAAI,IAAI,CAAC,sBAAsB,IAAI,EAAE,EAAE,CAAC;YACvC,uCAAuC;YACvC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;CACD;AAnBD,gDAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Common controls for the Latest* Value Managers.\n *\n * @alpha\n */\nexport interface LatestValueControls {\n\t/**\n\t * Maximum time in milliseconds that a local value update is allowed\n\t * to remain pending before it must be broadcast.\n\t *\n\t * @remarks There is no guarantee of broadcast within time allowed\n\t * as other conditions such as disconnect or service throttling may\n\t * cause a delay.\n\t */\n\tallowableUpdateLatency: number;\n\n\t/**\n\t * Target time in milliseconds between oldest changed local state\n\t * has been broadcast and forced rebroadcast of all local values.\n\t * A value of less than 10 disables forced refresh.\n\t *\n\t * @defaultValue 0\n\t *\n\t * @privateRemarks\n\t * Any time less than 10 milliseconds is likely to generate too\n\t * many signals. Ideally this feature becomes obsolete as\n\t * we understand the system better and account for holes.\n\t */\n\tforcedRefreshInterval: number;\n}\n\n/**\n * @internal\n */\nexport class LatestValueControl implements LatestValueControls {\n\tpublic allowableUpdateLatency: number;\n\tprivate _forcedRefreshInterval: number;\n\n\tpublic constructor(settings: LatestValueControls) {\n\t\tthis.allowableUpdateLatency = settings.allowableUpdateLatency;\n\t\tthis._forcedRefreshInterval = settings.forcedRefreshInterval;\n\t}\n\n\tpublic get forcedRefreshInterval(): number {\n\t\treturn this._forcedRefreshInterval;\n\t}\n\tpublic set forcedRefreshInterval(value: number) {\n\t\tthis._forcedRefreshInterval = value < 10 ? 0 : value;\n\t\tif (this._forcedRefreshInterval >= 10) {\n\t\t\t// TODO: enable periodic forced refresh\n\t\t\tthrow new Error(\"Forced Refresh feature is not implemented\");\n\t\t}\n\t}\n}\n"]}
@@ -1,44 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * Common controls for the Latest* Value Managers.
7
- *
8
- * @alpha
9
- */
10
- export interface LatestValueControls {
11
- /**
12
- * Maximum time in milliseconds that a local value update is allowed
13
- * to remain pending before it must be broadcast.
14
- *
15
- * @remarks There is no guarantee of broadcast within time allowed
16
- * as other conditions such as disconnect or service throttling may
17
- * cause a delay.
18
- */
19
- allowableUpdateLatency: number;
20
- /**
21
- * Target time in milliseconds between oldest changed local state
22
- * has been broadcast and forced rebroadcast of all local values.
23
- * A value of less than 10 disables forced refresh.
24
- *
25
- * @defaultValue 0
26
- *
27
- * @privateRemarks
28
- * Any time less than 10 milliseconds is likely to generate too
29
- * many signals. Ideally this feature becomes obsolete as
30
- * we understand the system better and account for holes.
31
- */
32
- forcedRefreshInterval: number;
33
- }
34
- /**
35
- * @internal
36
- */
37
- export declare class LatestValueControl implements LatestValueControls {
38
- allowableUpdateLatency: number;
39
- private _forcedRefreshInterval;
40
- constructor(settings: LatestValueControls);
41
- get forcedRefreshInterval(): number;
42
- set forcedRefreshInterval(value: number);
43
- }
44
- //# sourceMappingURL=latestValueControls.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueControls.d.ts","sourceRoot":"","sources":["../src/latestValueControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;OAOG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAE/B;;;;;;;;;;;OAWG;IACH,qBAAqB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IACtD,sBAAsB,EAAE,MAAM,CAAC;IACtC,OAAO,CAAC,sBAAsB,CAAS;gBAEpB,QAAQ,EAAE,mBAAmB;IAKhD,IAAW,qBAAqB,IAAI,MAAM,CAEzC;IACD,IAAW,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAM7C;CACD"}
@@ -1,24 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * @internal
7
- */
8
- export class LatestValueControl {
9
- constructor(settings) {
10
- this.allowableUpdateLatency = settings.allowableUpdateLatency;
11
- this._forcedRefreshInterval = settings.forcedRefreshInterval;
12
- }
13
- get forcedRefreshInterval() {
14
- return this._forcedRefreshInterval;
15
- }
16
- set forcedRefreshInterval(value) {
17
- this._forcedRefreshInterval = value < 10 ? 0 : value;
18
- if (this._forcedRefreshInterval >= 10) {
19
- // TODO: enable periodic forced refresh
20
- throw new Error("Forced Refresh feature is not implemented");
21
- }
22
- }
23
- }
24
- //# sourceMappingURL=latestValueControls.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latestValueControls.js","sourceRoot":"","sources":["../src/latestValueControls.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiCH;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAI9B,YAAmB,QAA6B;QAC/C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;QAC9D,IAAI,CAAC,sBAAsB,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IAC9D,CAAC;IAED,IAAW,qBAAqB;QAC/B,OAAO,IAAI,CAAC,sBAAsB,CAAC;IACpC,CAAC;IACD,IAAW,qBAAqB,CAAC,KAAa;QAC7C,IAAI,CAAC,sBAAsB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACrD,IAAI,IAAI,CAAC,sBAAsB,IAAI,EAAE,EAAE,CAAC;YACvC,uCAAuC;YACvC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Common controls for the Latest* Value Managers.\n *\n * @alpha\n */\nexport interface LatestValueControls {\n\t/**\n\t * Maximum time in milliseconds that a local value update is allowed\n\t * to remain pending before it must be broadcast.\n\t *\n\t * @remarks There is no guarantee of broadcast within time allowed\n\t * as other conditions such as disconnect or service throttling may\n\t * cause a delay.\n\t */\n\tallowableUpdateLatency: number;\n\n\t/**\n\t * Target time in milliseconds between oldest changed local state\n\t * has been broadcast and forced rebroadcast of all local values.\n\t * A value of less than 10 disables forced refresh.\n\t *\n\t * @defaultValue 0\n\t *\n\t * @privateRemarks\n\t * Any time less than 10 milliseconds is likely to generate too\n\t * many signals. Ideally this feature becomes obsolete as\n\t * we understand the system better and account for holes.\n\t */\n\tforcedRefreshInterval: number;\n}\n\n/**\n * @internal\n */\nexport class LatestValueControl implements LatestValueControls {\n\tpublic allowableUpdateLatency: number;\n\tprivate _forcedRefreshInterval: number;\n\n\tpublic constructor(settings: LatestValueControls) {\n\t\tthis.allowableUpdateLatency = settings.allowableUpdateLatency;\n\t\tthis._forcedRefreshInterval = settings.forcedRefreshInterval;\n\t}\n\n\tpublic get forcedRefreshInterval(): number {\n\t\treturn this._forcedRefreshInterval;\n\t}\n\tpublic set forcedRefreshInterval(value: number) {\n\t\tthis._forcedRefreshInterval = value < 10 ? 0 : value;\n\t\tif (this._forcedRefreshInterval >= 10) {\n\t\t\t// TODO: enable periodic forced refresh\n\t\t\tthrow new Error(\"Forced Refresh feature is not implemented\");\n\t\t}\n\t}\n}\n"]}