@openclaw/matrix 2026.7.1-beta.1 → 2026.7.1-beta.4

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 (1071) hide show
  1. package/dist/{account-selection-Bv_ZuOu4.js → account-selection-5e4mHR1m.js} +1 -1
  2. package/dist/api.js +5 -5
  3. package/dist/{approval-handler.runtime-GpL8SxX2.js → approval-handler.runtime-DI5x9r8I.js} +5 -5
  4. package/dist/{approval-ids-DIKCZewR.js → approval-ids-ZgqbspmS.js} +1 -1
  5. package/dist/{approval-reaction-auth-DhBxqiQQ.js → approval-reaction-auth-D9LijQhr.js} +2 -2
  6. package/dist/{approval-reactions-BRGQgOu2.js → approval-reactions-BdUaUXVw.js} +24 -73
  7. package/dist/auth-presence.js +1 -1
  8. package/dist/{channel-CGc6D4tf.js → channel-jUTBsjHU.js} +21 -23
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/{channel.runtime-CPu_uwsn.js → channel.runtime-DO1Nv9ed.js} +26 -17
  11. package/dist/{cli-BfwYmyEc.js → cli-CEfWwCKx.js} +10 -17
  12. package/dist/{cli-metadata-FO-fJqf0.js → cli-metadata-CfiEO-CE.js} +1 -1
  13. package/dist/cli-metadata.js +1 -1
  14. package/dist/{client-CVluBRDh.js → client-FRuyCNju.js} +2 -2
  15. package/dist/{client-bootstrap-1cbA9aSs.js → client-bootstrap-DjFJ7e0N.js} +6 -10
  16. package/dist/{client-Cb5ILtpE.js → client-tgnlQJk4.js} +2 -2
  17. package/dist/{config-schema-DFRmUTAG.js → config-schema-DtnhNYd-.js} +1 -1
  18. package/dist/contract-api.js +2 -2
  19. package/dist/{create-client-8YNurIAr.js → create-client-CNakT7zF.js} +7 -10
  20. package/dist/{credentials-G8lNmiME.js → credentials-Ds9V1mn2.js} +1 -1
  21. package/dist/{credentials-read-TzTOQPOM.js → credentials-read-BlkvsNFg.js} +1 -1
  22. package/dist/{credentials-write.runtime-cZhhyGAZ.js → credentials-write.runtime-CTqqxcut.js} +2 -5
  23. package/dist/{crypto-runtime-hMMmqNr1.js → crypto-runtime-B74cTS6A.js} +11 -9
  24. package/dist/{crypto-state-store-DK2tcEyP.js → crypto-state-store-Jy3qwhdy.js} +1 -1
  25. package/dist/{deps-D3bkh48_.js → deps-CdjHvnmh.js} +20 -2
  26. package/dist/{directory-live-pjbvjDz2.js → directory-live-Ufd4qSpX.js} +2 -2
  27. package/dist/{doctor-BRSDNU5C.js → doctor-DfaOqFtr.js} +3 -3
  28. package/dist/{doctor-contract-Dq8OZWHF.js → doctor-contract-BAja_fmb.js} +1 -1
  29. package/dist/doctor-contract-api.js +8 -14
  30. package/dist/{draft-stream-Djasj65z.js → draft-stream-D4EH25gv.js} +1 -1
  31. package/dist/{encryption-guidance-Bg3IRYoX.js → encryption-guidance-D8walY04.js} +1 -1
  32. package/dist/{file-sync-store-BWLVB01Y.js → file-sync-store-DVm0ACml.js} +3 -3
  33. package/dist/helper-api.js +1 -1
  34. package/dist/{idb-persistence-BGY1CJ7J.js → idb-persistence-BHm97th-.js} +1 -1
  35. package/dist/index.js +3 -6
  36. package/dist/{legacy-crypto-inspector-D_8iylBq.js → legacy-crypto-inspector-vzXSkm18.js} +1 -1
  37. package/dist/{legacy-crypto-restore-B0gcIEkE.js → legacy-crypto-restore-CIBfOmLn.js} +2 -2
  38. package/dist/{matrix-migration.runtime-Ctlb_rZl.js → matrix-migration.runtime-BMCyrANT.js} +3 -3
  39. package/dist/{media-text-CUFW_BP5.js → media-text-p-LP21qs.js} +1 -1
  40. package/dist/{messages-C1dIZHKy.js → messages-DRKkiEY-.js} +6 -5
  41. package/dist/{monitor-BMGnvIbg.js → monitor-CsGOGdwu.js} +89 -119
  42. package/dist/plugin-entry.handlers.runtime.js +2 -5
  43. package/dist/probe.runtime-2MZLc6ng.js +3 -0
  44. package/dist/{profile-update-BaEk4COs.js → profile-update-Ucc8RrJL.js} +2 -2
  45. package/dist/{reaction-events-n69MjKzG.js → reaction-events-DentrVii.js} +5 -12
  46. package/dist/{recovery-key-store-BGk8c_gf.js → recovery-key-store-DSeLFvNx.js} +1 -1
  47. package/dist/{resolve-targets-DyGW9WzC.js → resolve-targets-DcV_KfgX.js} +1 -1
  48. package/dist/{resolver.runtime-DhZV369r.js → resolver.runtime-Hr6bO5zl.js} +1 -1
  49. package/dist/runtime-api.js +2 -2
  50. package/dist/runtime-heavy-api.js +1 -1
  51. package/dist/{sdk-DOxaiBRE.js → sdk-AZYVl34z.js} +12 -13
  52. package/dist/{send-C0NwpZ-c.js → send-D92v6Yy0.js} +22 -12
  53. package/dist/session-binding-contract-api.js +1 -1
  54. package/dist/{setup-bootstrap-DbWPVINS.js → setup-bootstrap-Da564w5f.js} +2 -2
  55. package/dist/{setup-core-DVkrIoax.js → setup-core-BGgbrdaJ.js} +5 -8
  56. package/dist/setup-plugin-api.js +3 -3
  57. package/dist/{setup-surface-CN7DEvpg.js → setup-surface-iJ6pd-t5.js} +6 -6
  58. package/dist/{shared-iLI-9tb9.js → shared-DkFfq7mH.js} +16 -32
  59. package/dist/{startup-verification-Bd31KqLv.js → startup-verification-BKMAXvcV.js} +2 -2
  60. package/dist/{storage-t5S-5c_5.js → storage-CQdyKcGg.js} +5 -5
  61. package/dist/subagent-hooks-api.js +2 -5
  62. package/dist/{thread-bindings-D73QFTXW.js → thread-bindings-BX5nmWpw.js} +3 -3
  63. package/dist/{tool-actions.runtime-BCCPq_aO.js → tool-actions.runtime-C1d5fxE_.js} +12 -12
  64. package/dist/{verification-C0KvXyHK.js → verification-BGCMiO1p.js} +2 -2
  65. package/node_modules/@babel/runtime/package.json +468 -1089
  66. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/.cargo/config.toml +2 -0
  67. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/CHANGELOG.md +12 -3
  68. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/README.md +17 -0
  69. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/download-lib.js +10 -2
  70. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/package.json +1 -1
  71. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/modules.xml +8 -0
  72. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/vcs.xml +6 -0
  73. package/node_modules/@matrix-org/matrix-sdk-crypto-nodejs/xtask/.idea/xtask.iml +11 -0
  74. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/package.json +1 -1
  75. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.cjs +28 -28
  76. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.js +24 -24
  77. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm +0 -0
  78. package/node_modules/@matrix-org/matrix-sdk-crypto-wasm/pkg/matrix_sdk_crypto_wasm_bg.wasm.d.ts +58 -58
  79. package/node_modules/content-type/README.md +32 -57
  80. package/node_modules/content-type/dist/index.d.ts +26 -0
  81. package/node_modules/content-type/dist/index.js +170 -0
  82. package/node_modules/content-type/dist/index.js.map +1 -0
  83. package/node_modules/content-type/package.json +35 -25
  84. package/node_modules/linkify-it/README.md +3 -4
  85. package/node_modules/linkify-it/build/index.cjs.js +44 -41
  86. package/node_modules/linkify-it/index.mjs +10 -11
  87. package/node_modules/linkify-it/lib/re.mjs +34 -30
  88. package/node_modules/linkify-it/package.json +10 -15
  89. package/node_modules/markdown-it/dist/index.cjs.js +3652 -5378
  90. package/node_modules/markdown-it/dist/index.cjs.js.map +1 -0
  91. package/node_modules/markdown-it/dist/markdown-it.js +1399 -4479
  92. package/node_modules/markdown-it/dist/markdown-it.js.map +1 -0
  93. package/node_modules/markdown-it/dist/markdown-it.min.js +3 -2
  94. package/node_modules/markdown-it/dist/markdown-it.min.js.map +1 -0
  95. package/node_modules/markdown-it/lib/common/html_re.mjs +9 -9
  96. package/node_modules/markdown-it/lib/common/utils.mjs +2 -11
  97. package/node_modules/markdown-it/lib/parser_block.mjs +9 -9
  98. package/node_modules/markdown-it/lib/parser_core.mjs +7 -7
  99. package/node_modules/markdown-it/lib/parser_inline.mjs +16 -16
  100. package/node_modules/markdown-it/lib/renderer.mjs +2 -2
  101. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +6 -6
  102. package/node_modules/markdown-it/lib/rules_block/code.mjs +2 -2
  103. package/node_modules/markdown-it/lib/rules_block/fence.mjs +4 -4
  104. package/node_modules/markdown-it/lib/rules_block/heading.mjs +7 -7
  105. package/node_modules/markdown-it/lib/rules_block/hr.mjs +2 -2
  106. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +6 -6
  107. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +8 -8
  108. package/node_modules/markdown-it/lib/rules_block/list.mjs +6 -6
  109. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +5 -5
  110. package/node_modules/markdown-it/lib/rules_block/reference.mjs +1 -1
  111. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +6 -6
  112. package/node_modules/markdown-it/lib/rules_block/table.mjs +4 -4
  113. package/node_modules/markdown-it/lib/rules_core/block.mjs +3 -3
  114. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +15 -15
  115. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +2 -2
  116. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +17 -17
  117. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +2 -2
  118. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +8 -8
  119. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +7 -7
  120. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +15 -1
  121. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +1 -1
  122. package/node_modules/markdown-it/lib/rules_inline/link.mjs +1 -1
  123. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +2 -2
  124. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +10 -10
  125. package/node_modules/markdown-it/lib/token.mjs +12 -12
  126. package/node_modules/markdown-it/package.json +25 -34
  127. package/node_modules/matrix-js-sdk/CHANGELOG.md +24 -0
  128. package/node_modules/matrix-js-sdk/README.md +1 -1
  129. package/node_modules/matrix-js-sdk/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
  130. package/node_modules/matrix-js-sdk/lib/@types/IIdentityServerProvider.js +3 -1
  131. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +7 -7
  132. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
  133. package/node_modules/matrix-js-sdk/lib/@types/auth.js +4 -4
  134. package/node_modules/matrix-js-sdk/lib/@types/auth.js.map +1 -1
  135. package/node_modules/matrix-js-sdk/lib/@types/beacon.js +2 -2
  136. package/node_modules/matrix-js-sdk/lib/@types/beacon.js.map +1 -1
  137. package/node_modules/matrix-js-sdk/lib/@types/common.js +3 -1
  138. package/node_modules/matrix-js-sdk/lib/@types/crypto.js +3 -1
  139. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +6 -1
  140. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
  141. package/node_modules/matrix-js-sdk/lib/@types/event.js +23 -20
  142. package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
  143. package/node_modules/matrix-js-sdk/lib/@types/events.js +3 -1
  144. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js +6 -6
  145. package/node_modules/matrix-js-sdk/lib/@types/extensible_events.js.map +1 -1
  146. package/node_modules/matrix-js-sdk/lib/@types/global.d.js.map +1 -1
  147. package/node_modules/matrix-js-sdk/lib/@types/json.js +3 -1
  148. package/node_modules/matrix-js-sdk/lib/@types/local_notifications.js +3 -1
  149. package/node_modules/matrix-js-sdk/lib/@types/location.js +4 -4
  150. package/node_modules/matrix-js-sdk/lib/@types/location.js.map +1 -1
  151. package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
  152. package/node_modules/matrix-js-sdk/lib/@types/media.js +3 -1
  153. package/node_modules/matrix-js-sdk/lib/@types/membership.js +1 -1
  154. package/node_modules/matrix-js-sdk/lib/@types/membership.js.map +1 -1
  155. package/node_modules/matrix-js-sdk/lib/@types/partials.js +6 -6
  156. package/node_modules/matrix-js-sdk/lib/@types/partials.js.map +1 -1
  157. package/node_modules/matrix-js-sdk/lib/@types/polls.js +5 -5
  158. package/node_modules/matrix-js-sdk/lib/@types/polls.js.map +1 -1
  159. package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js +2 -2
  160. package/node_modules/matrix-js-sdk/lib/@types/read_receipts.js.map +1 -1
  161. package/node_modules/matrix-js-sdk/lib/@types/registration.js +3 -1
  162. package/node_modules/matrix-js-sdk/lib/@types/requests.js +1 -1
  163. package/node_modules/matrix-js-sdk/lib/@types/requests.js.map +1 -1
  164. package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts +15 -0
  165. package/node_modules/matrix-js-sdk/lib/@types/retention.d.ts.map +1 -0
  166. package/node_modules/matrix-js-sdk/lib/@types/retention.js +13 -0
  167. package/node_modules/matrix-js-sdk/lib/@types/retention.js.map +1 -0
  168. package/node_modules/matrix-js-sdk/lib/@types/search.js +1 -1
  169. package/node_modules/matrix-js-sdk/lib/@types/search.js.map +1 -1
  170. package/node_modules/matrix-js-sdk/lib/@types/signed.js +3 -1
  171. package/node_modules/matrix-js-sdk/lib/@types/spaces.js +3 -1
  172. package/node_modules/matrix-js-sdk/lib/@types/state_events.js +3 -1
  173. package/node_modules/matrix-js-sdk/lib/@types/synapse.js +3 -1
  174. package/node_modules/matrix-js-sdk/lib/@types/sync.js +1 -1
  175. package/node_modules/matrix-js-sdk/lib/@types/sync.js.map +1 -1
  176. package/node_modules/matrix-js-sdk/lib/@types/threepids.js +1 -1
  177. package/node_modules/matrix-js-sdk/lib/@types/threepids.js.map +1 -1
  178. package/node_modules/matrix-js-sdk/lib/@types/topic.js +1 -1
  179. package/node_modules/matrix-js-sdk/lib/@types/topic.js.map +1 -1
  180. package/node_modules/matrix-js-sdk/lib/@types/uia.js +3 -1
  181. package/node_modules/matrix-js-sdk/lib/NamespacedValue.js +8 -8
  182. package/node_modules/matrix-js-sdk/lib/NamespacedValue.js.map +1 -1
  183. package/node_modules/matrix-js-sdk/lib/ReEmitter.js +8 -15
  184. package/node_modules/matrix-js-sdk/lib/ReEmitter.js.map +1 -1
  185. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js +47 -55
  186. package/node_modules/matrix-js-sdk/lib/ToDeviceMessageQueue.js.map +1 -1
  187. package/node_modules/matrix-js-sdk/lib/autodiscovery.js +233 -247
  188. package/node_modules/matrix-js-sdk/lib/autodiscovery.js.map +1 -1
  189. package/node_modules/matrix-js-sdk/lib/base64.js +1 -1
  190. package/node_modules/matrix-js-sdk/lib/base64.js.map +1 -1
  191. package/node_modules/matrix-js-sdk/lib/browser-index.d.ts +2 -2
  192. package/node_modules/matrix-js-sdk/lib/browser-index.d.ts.map +1 -1
  193. package/node_modules/matrix-js-sdk/lib/browser-index.js +5 -5
  194. package/node_modules/matrix-js-sdk/lib/browser-index.js.map +1 -1
  195. package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts +38 -0
  196. package/node_modules/matrix-js-sdk/lib/capabilityPoller.d.ts.map +1 -0
  197. package/node_modules/matrix-js-sdk/lib/capabilityPoller.js +93 -0
  198. package/node_modules/matrix-js-sdk/lib/capabilityPoller.js.map +1 -0
  199. package/node_modules/matrix-js-sdk/lib/client.d.ts +9 -8
  200. package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
  201. package/node_modules/matrix-js-sdk/lib/client.js +2123 -2483
  202. package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
  203. package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js +3 -1
  204. package/node_modules/matrix-js-sdk/lib/common-crypto/CryptoBackend.js.map +1 -1
  205. package/node_modules/matrix-js-sdk/lib/common-crypto/key-passphrase.js.map +1 -1
  206. package/node_modules/matrix-js-sdk/lib/content-helpers.js +43 -48
  207. package/node_modules/matrix-js-sdk/lib/content-helpers.js.map +1 -1
  208. package/node_modules/matrix-js-sdk/lib/content-repo.js +14 -24
  209. package/node_modules/matrix-js-sdk/lib/content-repo.js.map +1 -1
  210. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js +6 -6
  211. package/node_modules/matrix-js-sdk/lib/crypto/store/base.js.map +1 -1
  212. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js +189 -237
  213. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
  214. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js +25 -28
  215. package/node_modules/matrix-js-sdk/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
  216. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js +113 -145
  217. package/node_modules/matrix-js-sdk/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
  218. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js +74 -105
  219. package/node_modules/matrix-js-sdk/lib/crypto/store/memory-crypto-store.js.map +1 -1
  220. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js +1 -1
  221. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEvent.js.map +1 -1
  222. package/node_modules/matrix-js-sdk/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
  223. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +15 -6
  224. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
  225. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js +76 -76
  226. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
  227. package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js +15 -23
  228. package/node_modules/matrix-js-sdk/lib/crypto-api/key-passphrase.js.map +1 -1
  229. package/node_modules/matrix-js-sdk/lib/crypto-api/keybackup.js +3 -1
  230. package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js +11 -12
  231. package/node_modules/matrix-js-sdk/lib/crypto-api/recovery-key.js.map +1 -1
  232. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js +3 -3
  233. package/node_modules/matrix-js-sdk/lib/crypto-api/verification.js.map +1 -1
  234. package/node_modules/matrix-js-sdk/lib/digest.js +7 -14
  235. package/node_modules/matrix-js-sdk/lib/digest.js.map +1 -1
  236. package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
  237. package/node_modules/matrix-js-sdk/lib/embedded.js +379 -500
  238. package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
  239. package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
  240. package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
  241. package/node_modules/matrix-js-sdk/lib/event-mapper.js +10 -12
  242. package/node_modules/matrix-js-sdk/lib/event-mapper.js.map +1 -1
  243. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
  244. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
  245. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js +26 -28
  246. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/MessageEvent.js.map +1 -1
  247. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js +11 -12
  248. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
  249. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js +6 -6
  250. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
  251. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js +36 -38
  252. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
  253. package/node_modules/matrix-js-sdk/lib/extensible_events_v1/utilities.js.map +1 -1
  254. package/node_modules/matrix-js-sdk/lib/feature.js +18 -31
  255. package/node_modules/matrix-js-sdk/lib/feature.js.map +1 -1
  256. package/node_modules/matrix-js-sdk/lib/filter-component.d.ts.map +1 -1
  257. package/node_modules/matrix-js-sdk/lib/filter-component.js +20 -26
  258. package/node_modules/matrix-js-sdk/lib/filter-component.js.map +1 -1
  259. package/node_modules/matrix-js-sdk/lib/filter.js +14 -15
  260. package/node_modules/matrix-js-sdk/lib/filter.js.map +1 -1
  261. package/node_modules/matrix-js-sdk/lib/http-api/errors.js +41 -56
  262. package/node_modules/matrix-js-sdk/lib/http-api/errors.js.map +1 -1
  263. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +140 -157
  264. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
  265. package/node_modules/matrix-js-sdk/lib/http-api/index.js +17 -20
  266. package/node_modules/matrix-js-sdk/lib/http-api/index.js.map +1 -1
  267. package/node_modules/matrix-js-sdk/lib/http-api/interface.js +1 -1
  268. package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
  269. package/node_modules/matrix-js-sdk/lib/http-api/method.js +1 -1
  270. package/node_modules/matrix-js-sdk/lib/http-api/method.js.map +1 -1
  271. package/node_modules/matrix-js-sdk/lib/http-api/prefix.js +3 -3
  272. package/node_modules/matrix-js-sdk/lib/http-api/prefix.js.map +1 -1
  273. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +80 -99
  274. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
  275. package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts +1 -1
  276. package/node_modules/matrix-js-sdk/lib/http-api/utils.d.ts.map +1 -1
  277. package/node_modules/matrix-js-sdk/lib/http-api/utils.js +35 -47
  278. package/node_modules/matrix-js-sdk/lib/http-api/utils.js.map +1 -1
  279. package/node_modules/matrix-js-sdk/lib/index.js.map +1 -1
  280. package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js +3 -3
  281. package/node_modules/matrix-js-sdk/lib/indexeddb-helpers.js.map +1 -1
  282. package/node_modules/matrix-js-sdk/lib/indexeddb-worker.js.map +1 -1
  283. package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts +5 -5
  284. package/node_modules/matrix-js-sdk/lib/interactive-auth.d.ts.map +1 -1
  285. package/node_modules/matrix-js-sdk/lib/interactive-auth.js +181 -203
  286. package/node_modules/matrix-js-sdk/lib/interactive-auth.js.map +1 -1
  287. package/node_modules/matrix-js-sdk/lib/logger.js +22 -56
  288. package/node_modules/matrix-js-sdk/lib/logger.js.map +1 -1
  289. package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -0
  290. package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
  291. package/node_modules/matrix-js-sdk/lib/matrix.js +8 -11
  292. package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
  293. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +83 -76
  294. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
  295. package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js +1 -1
  296. package/node_modules/matrix-js-sdk/lib/matrixrtc/EncryptionManager.js.map +1 -1
  297. package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js +1 -1
  298. package/node_modules/matrix-js-sdk/lib/matrixrtc/IKeyTransport.js.map +1 -1
  299. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js +1 -1
  300. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
  301. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.d.ts +1 -1
  302. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js +4 -4
  303. package/node_modules/matrix-js-sdk/lib/matrixrtc/LivekitTransport.js.map +1 -1
  304. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  305. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +144 -184
  306. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  307. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +35 -39
  308. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  309. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +2 -0
  310. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  311. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +346 -383
  312. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
  313. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.d.ts.map +1 -1
  314. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -59
  315. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
  316. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js +117 -139
  317. package/node_modules/matrix-js-sdk/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
  318. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js +49 -54
  319. package/node_modules/matrix-js-sdk/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
  320. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
  321. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +1 -1
  322. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
  323. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
  324. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js +15 -23
  325. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/rtc.js.map +1 -1
  326. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js +4 -5
  327. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/session.js.map +1 -1
  328. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +4 -6
  329. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
  330. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +4 -11
  331. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
  332. package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js +91 -116
  333. package/node_modules/matrix-js-sdk/lib/models/MSC3089Branch.js.map +1 -1
  334. package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js +209 -244
  335. package/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.js.map +1 -1
  336. package/node_modules/matrix-js-sdk/lib/models/ToDeviceMessage.js +3 -1
  337. package/node_modules/matrix-js-sdk/lib/models/beacon.js +20 -15
  338. package/node_modules/matrix-js-sdk/lib/models/beacon.js.map +1 -1
  339. package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js +13 -13
  340. package/node_modules/matrix-js-sdk/lib/models/compare-event-ordering.js.map +1 -1
  341. package/node_modules/matrix-js-sdk/lib/models/device.js +10 -3
  342. package/node_modules/matrix-js-sdk/lib/models/device.js.map +1 -1
  343. package/node_modules/matrix-js-sdk/lib/models/event-context.js +5 -7
  344. package/node_modules/matrix-js-sdk/lib/models/event-context.js.map +1 -1
  345. package/node_modules/matrix-js-sdk/lib/models/event-status.js +1 -1
  346. package/node_modules/matrix-js-sdk/lib/models/event-status.js.map +1 -1
  347. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js +91 -91
  348. package/node_modules/matrix-js-sdk/lib/models/event-timeline-set.js.map +1 -1
  349. package/node_modules/matrix-js-sdk/lib/models/event-timeline.js +31 -29
  350. package/node_modules/matrix-js-sdk/lib/models/event-timeline.js.map +1 -1
  351. package/node_modules/matrix-js-sdk/lib/models/event.js +215 -235
  352. package/node_modules/matrix-js-sdk/lib/models/event.js.map +1 -1
  353. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js +4 -4
  354. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer-types.js.map +1 -1
  355. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js +159 -179
  356. package/node_modules/matrix-js-sdk/lib/models/invites-ignorer.js.map +1 -1
  357. package/node_modules/matrix-js-sdk/lib/models/poll.js +72 -78
  358. package/node_modules/matrix-js-sdk/lib/models/poll.js.map +1 -1
  359. package/node_modules/matrix-js-sdk/lib/models/profile-keys.js +2 -2
  360. package/node_modules/matrix-js-sdk/lib/models/profile-keys.js.map +1 -1
  361. package/node_modules/matrix-js-sdk/lib/models/read-receipt.js +40 -56
  362. package/node_modules/matrix-js-sdk/lib/models/read-receipt.js.map +1 -1
  363. package/node_modules/matrix-js-sdk/lib/models/related-relations.js +2 -0
  364. package/node_modules/matrix-js-sdk/lib/models/related-relations.js.map +1 -1
  365. package/node_modules/matrix-js-sdk/lib/models/relations-container.js +20 -21
  366. package/node_modules/matrix-js-sdk/lib/models/relations-container.js.map +1 -1
  367. package/node_modules/matrix-js-sdk/lib/models/relations.js +131 -156
  368. package/node_modules/matrix-js-sdk/lib/models/relations.js.map +1 -1
  369. package/node_modules/matrix-js-sdk/lib/models/room-member.js +44 -27
  370. package/node_modules/matrix-js-sdk/lib/models/room-member.js.map +1 -1
  371. package/node_modules/matrix-js-sdk/lib/models/room-receipts.js +48 -55
  372. package/node_modules/matrix-js-sdk/lib/models/room-receipts.js.map +1 -1
  373. package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts +28 -0
  374. package/node_modules/matrix-js-sdk/lib/models/room-retention.d.ts.map +1 -0
  375. package/node_modules/matrix-js-sdk/lib/models/room-retention.js +192 -0
  376. package/node_modules/matrix-js-sdk/lib/models/room-retention.js.map +1 -0
  377. package/node_modules/matrix-js-sdk/lib/models/room-state.js +141 -170
  378. package/node_modules/matrix-js-sdk/lib/models/room-state.js.map +1 -1
  379. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +1 -0
  380. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
  381. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +46 -65
  382. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
  383. package/node_modules/matrix-js-sdk/lib/models/room-summary.js.map +1 -1
  384. package/node_modules/matrix-js-sdk/lib/models/room.d.ts +2 -1
  385. package/node_modules/matrix-js-sdk/lib/models/room.d.ts.map +1 -1
  386. package/node_modules/matrix-js-sdk/lib/models/room.js +800 -887
  387. package/node_modules/matrix-js-sdk/lib/models/room.js.map +1 -1
  388. package/node_modules/matrix-js-sdk/lib/models/search-result.js +5 -5
  389. package/node_modules/matrix-js-sdk/lib/models/search-result.js.map +1 -1
  390. package/node_modules/matrix-js-sdk/lib/models/thread.js +267 -283
  391. package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
  392. package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js +7 -18
  393. package/node_modules/matrix-js-sdk/lib/models/typed-event-emitter.js.map +1 -1
  394. package/node_modules/matrix-js-sdk/lib/models/user.js +26 -7
  395. package/node_modules/matrix-js-sdk/lib/models/user.js.map +1 -1
  396. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js +208 -241
  397. package/node_modules/matrix-js-sdk/lib/oidc/authorize.js.map +1 -1
  398. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js +23 -36
  399. package/node_modules/matrix-js-sdk/lib/oidc/discovery.js.map +1 -1
  400. package/node_modules/matrix-js-sdk/lib/oidc/error.js +1 -1
  401. package/node_modules/matrix-js-sdk/lib/oidc/error.js.map +1 -1
  402. package/node_modules/matrix-js-sdk/lib/oidc/index.js +1 -0
  403. package/node_modules/matrix-js-sdk/lib/oidc/index.js.map +1 -1
  404. package/node_modules/matrix-js-sdk/lib/oidc/register.js +60 -66
  405. package/node_modules/matrix-js-sdk/lib/oidc/register.js.map +1 -1
  406. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js +83 -94
  407. package/node_modules/matrix-js-sdk/lib/oidc/tokenRefresher.js.map +1 -1
  408. package/node_modules/matrix-js-sdk/lib/oidc/validate.js +18 -18
  409. package/node_modules/matrix-js-sdk/lib/oidc/validate.js.map +1 -1
  410. package/node_modules/matrix-js-sdk/lib/pushprocessor.js +70 -81
  411. package/node_modules/matrix-js-sdk/lib/pushprocessor.js.map +1 -1
  412. package/node_modules/matrix-js-sdk/lib/randomstring.js +9 -9
  413. package/node_modules/matrix-js-sdk/lib/randomstring.js.map +1 -1
  414. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js +25 -28
  415. package/node_modules/matrix-js-sdk/lib/realtime-callbacks.js.map +1 -1
  416. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +2 -0
  417. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
  418. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +14 -22
  419. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
  420. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js +272 -298
  421. package/node_modules/matrix-js-sdk/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
  422. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousChannel.js +3 -1
  423. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousCode.js +3 -1
  424. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousError.js.map +1 -1
  425. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js +2 -2
  426. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
  427. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js +1 -1
  428. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousIntent.js.map +1 -1
  429. package/node_modules/matrix-js-sdk/lib/rendezvous/RendezvousTransport.js +3 -1
  430. package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js +122 -144
  431. package/node_modules/matrix-js-sdk/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
  432. package/node_modules/matrix-js-sdk/lib/rendezvous/index.js +44 -69
  433. package/node_modules/matrix-js-sdk/lib/rendezvous/index.js.map +1 -1
  434. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
  435. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js +142 -152
  436. package/node_modules/matrix-js-sdk/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
  437. package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts +33 -0
  438. package/node_modules/matrix-js-sdk/lib/retentionPolicy.d.ts.map +1 -0
  439. package/node_modules/matrix-js-sdk/lib/retentionPolicy.js +39 -0
  440. package/node_modules/matrix-js-sdk/lib/retentionPolicy.js.map +1 -0
  441. package/node_modules/matrix-js-sdk/lib/room-hierarchy.js +52 -56
  442. package/node_modules/matrix-js-sdk/lib/room-hierarchy.js.map +1 -1
  443. package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js +94 -104
  444. package/node_modules/matrix-js-sdk/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
  445. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js +158 -190
  446. package/node_modules/matrix-js-sdk/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
  447. package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js +17 -20
  448. package/node_modules/matrix-js-sdk/lib/rust-crypto/KeyClaimManager.js.map +1 -1
  449. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
  450. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
  451. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js +72 -86
  452. package/node_modules/matrix-js-sdk/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
  453. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
  454. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js +195 -221
  455. package/node_modules/matrix-js-sdk/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
  456. package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js +121 -137
  457. package/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js.map +1 -1
  458. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -2
  459. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
  460. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +459 -544
  461. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
  462. package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js +1 -1
  463. package/node_modules/matrix-js-sdk/lib/rust-crypto/constants.js.map +1 -1
  464. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js +15 -28
  465. package/node_modules/matrix-js-sdk/lib/rust-crypto/device-converter.js.map +1 -1
  466. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js +103 -116
  467. package/node_modules/matrix-js-sdk/lib/rust-crypto/index.js.map +1 -1
  468. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js +303 -365
  469. package/node_modules/matrix-js-sdk/lib/rust-crypto/libolm_migration.js.map +1 -1
  470. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts +5 -1
  471. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
  472. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +1065 -1322
  473. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js.map +1 -1
  474. package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js +12 -25
  475. package/node_modules/matrix-js-sdk/lib/rust-crypto/secret-storage.js.map +1 -1
  476. package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js +134 -184
  477. package/node_modules/matrix-js-sdk/lib/rust-crypto/verification.js.map +1 -1
  478. package/node_modules/matrix-js-sdk/lib/scheduler.js +42 -17
  479. package/node_modules/matrix-js-sdk/lib/scheduler.js.map +1 -1
  480. package/node_modules/matrix-js-sdk/lib/secret-storage.js +179 -213
  481. package/node_modules/matrix-js-sdk/lib/secret-storage.js.map +1 -1
  482. package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts +4 -23
  483. package/node_modules/matrix-js-sdk/lib/serverCapabilities.d.ts.map +1 -1
  484. package/node_modules/matrix-js-sdk/lib/serverCapabilities.js +9 -62
  485. package/node_modules/matrix-js-sdk/lib/serverCapabilities.js.map +1 -1
  486. package/node_modules/matrix-js-sdk/lib/service-types.js +1 -1
  487. package/node_modules/matrix-js-sdk/lib/service-types.js.map +1 -1
  488. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.d.ts.map +1 -1
  489. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js +368 -421
  490. package/node_modules/matrix-js-sdk/lib/sliding-sync-sdk.js.map +1 -1
  491. package/node_modules/matrix-js-sdk/lib/sliding-sync.js +136 -167
  492. package/node_modules/matrix-js-sdk/lib/sliding-sync.js.map +1 -1
  493. package/node_modules/matrix-js-sdk/lib/store/index.d.ts +7 -0
  494. package/node_modules/matrix-js-sdk/lib/store/index.d.ts.map +1 -1
  495. package/node_modules/matrix-js-sdk/lib/store/index.js +3 -1
  496. package/node_modules/matrix-js-sdk/lib/store/index.js.map +1 -1
  497. package/node_modules/matrix-js-sdk/lib/store/indexeddb-backend.js +3 -1
  498. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts +1 -0
  499. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.d.ts.map +1 -1
  500. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js +197 -240
  501. package/node_modules/matrix-js-sdk/lib/store/indexeddb-local-backend.js.map +1 -1
  502. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts +3 -1
  503. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.d.ts.map +1 -1
  504. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js +51 -59
  505. package/node_modules/matrix-js-sdk/lib/store/indexeddb-remote-backend.js.map +1 -1
  506. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js +22 -22
  507. package/node_modules/matrix-js-sdk/lib/store/indexeddb-store-worker.js.map +1 -1
  508. package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts +7 -5
  509. package/node_modules/matrix-js-sdk/lib/store/indexeddb.d.ts.map +1 -1
  510. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js +63 -79
  511. package/node_modules/matrix-js-sdk/lib/store/indexeddb.js.map +1 -1
  512. package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js +2 -2
  513. package/node_modules/matrix-js-sdk/lib/store/local-storage-events-emitter.js.map +1 -1
  514. package/node_modules/matrix-js-sdk/lib/store/memory.d.ts +1 -0
  515. package/node_modules/matrix-js-sdk/lib/store/memory.d.ts.map +1 -1
  516. package/node_modules/matrix-js-sdk/lib/store/memory.js +38 -54
  517. package/node_modules/matrix-js-sdk/lib/store/memory.js.map +1 -1
  518. package/node_modules/matrix-js-sdk/lib/store/stub.d.ts +1 -0
  519. package/node_modules/matrix-js-sdk/lib/store/stub.d.ts.map +1 -1
  520. package/node_modules/matrix-js-sdk/lib/store/stub.js +22 -32
  521. package/node_modules/matrix-js-sdk/lib/store/stub.js.map +1 -1
  522. package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts +1 -0
  523. package/node_modules/matrix-js-sdk/lib/sync-accumulator.d.ts.map +1 -1
  524. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js +57 -65
  525. package/node_modules/matrix-js-sdk/lib/sync-accumulator.js.map +1 -1
  526. package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
  527. package/node_modules/matrix-js-sdk/lib/sync.js +914 -991
  528. package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
  529. package/node_modules/matrix-js-sdk/lib/testing.js +63 -105
  530. package/node_modules/matrix-js-sdk/lib/testing.js.map +1 -1
  531. package/node_modules/matrix-js-sdk/lib/thread-utils.js +1 -4
  532. package/node_modules/matrix-js-sdk/lib/thread-utils.js.map +1 -1
  533. package/node_modules/matrix-js-sdk/lib/timeline-window.js +90 -99
  534. package/node_modules/matrix-js-sdk/lib/timeline-window.js.map +1 -1
  535. package/node_modules/matrix-js-sdk/lib/types.js +1 -1
  536. package/node_modules/matrix-js-sdk/lib/types.js.map +1 -1
  537. package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js +14 -25
  538. package/node_modules/matrix-js-sdk/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
  539. package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js +27 -38
  540. package/node_modules/matrix-js-sdk/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
  541. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js +25 -32
  542. package/node_modules/matrix-js-sdk/lib/utils/internal/deriveKeys.js.map +1 -1
  543. package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js +1 -1
  544. package/node_modules/matrix-js-sdk/lib/utils/roomVersion.js.map +1 -1
  545. package/node_modules/matrix-js-sdk/lib/utils.js +83 -135
  546. package/node_modules/matrix-js-sdk/lib/utils.js.map +1 -1
  547. package/node_modules/matrix-js-sdk/lib/version-support.js +3 -3
  548. package/node_modules/matrix-js-sdk/lib/version-support.js.map +1 -1
  549. package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js +5 -6
  550. package/node_modules/matrix-js-sdk/lib/webrtc/audioContext.js.map +1 -1
  551. package/node_modules/matrix-js-sdk/lib/webrtc/call.js +1123 -1256
  552. package/node_modules/matrix-js-sdk/lib/webrtc/call.js.map +1 -1
  553. package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js +207 -214
  554. package/node_modules/matrix-js-sdk/lib/webrtc/callEventHandler.js.map +1 -1
  555. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js +2 -2
  556. package/node_modules/matrix-js-sdk/lib/webrtc/callEventTypes.js.map +1 -1
  557. package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js +33 -20
  558. package/node_modules/matrix-js-sdk/lib/webrtc/callFeed.js.map +1 -1
  559. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js +521 -594
  560. package/node_modules/matrix-js-sdk/lib/webrtc/groupCall.js.map +1 -1
  561. package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js +58 -61
  562. package/node_modules/matrix-js-sdk/lib/webrtc/groupCallEventHandler.js.map +1 -1
  563. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js +203 -233
  564. package/node_modules/matrix-js-sdk/lib/webrtc/mediaHandler.js.map +1 -1
  565. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
  566. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
  567. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js +65 -70
  568. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
  569. package/node_modules/matrix-js-sdk/lib/webrtc/stats/callStatsReportSummary.js +3 -1
  570. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStats.js.map +1 -1
  571. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
  572. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
  573. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
  574. package/node_modules/matrix-js-sdk/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
  575. package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js +4 -5
  576. package/node_modules/matrix-js-sdk/lib/webrtc/stats/groupCallStats.js.map +1 -1
  577. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
  578. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
  579. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
  580. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
  581. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
  582. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js +6 -6
  583. package/node_modules/matrix-js-sdk/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
  584. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js +1 -1
  585. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReport.js.map +1 -1
  586. package/node_modules/matrix-js-sdk/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
  587. package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
  588. package/node_modules/matrix-js-sdk/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
  589. package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js +32 -34
  590. package/node_modules/matrix-js-sdk/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
  591. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStats.js +3 -1
  592. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js +9 -9
  593. package/node_modules/matrix-js-sdk/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
  594. package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js +1 -1
  595. package/node_modules/matrix-js-sdk/lib/webrtc/stats/valueFormatter.js.map +1 -1
  596. package/node_modules/matrix-js-sdk/package.json +110 -138
  597. package/node_modules/matrix-js-sdk/src/@types/event.ts +9 -0
  598. package/node_modules/matrix-js-sdk/src/@types/global.d.ts +2 -2
  599. package/node_modules/matrix-js-sdk/src/@types/retention.ts +16 -0
  600. package/node_modules/matrix-js-sdk/src/ToDeviceMessageQueue.ts +2 -2
  601. package/node_modules/matrix-js-sdk/src/browser-index.ts +4 -4
  602. package/node_modules/matrix-js-sdk/src/capabilityPoller.ts +102 -0
  603. package/node_modules/matrix-js-sdk/src/client.ts +37 -25
  604. package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +17 -6
  605. package/node_modules/matrix-js-sdk/src/embedded.ts +4 -6
  606. package/node_modules/matrix-js-sdk/src/filter-component.ts +1 -0
  607. package/node_modules/matrix-js-sdk/src/http-api/utils.ts +5 -10
  608. package/node_modules/matrix-js-sdk/src/interactive-auth.ts +11 -5
  609. package/node_modules/matrix-js-sdk/src/matrix.ts +1 -0
  610. package/node_modules/matrix-js-sdk/src/matrixrtc/LivekitTransport.ts +1 -1
  611. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +5 -4
  612. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +2 -0
  613. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManagerActionScheduler.ts +4 -1
  614. package/node_modules/matrix-js-sdk/src/models/MSC3089Branch.ts +1 -1
  615. package/node_modules/matrix-js-sdk/src/models/room-retention.ts +230 -0
  616. package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +1 -0
  617. package/node_modules/matrix-js-sdk/src/models/room.ts +26 -12
  618. package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +2 -0
  619. package/node_modules/matrix-js-sdk/src/rendezvous/index.ts +1 -1
  620. package/node_modules/matrix-js-sdk/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
  621. package/node_modules/matrix-js-sdk/src/retentionPolicy.ts +65 -0
  622. package/node_modules/matrix-js-sdk/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
  623. package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +15 -4
  624. package/node_modules/matrix-js-sdk/src/rust-crypto/index.ts +6 -6
  625. package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +31 -7
  626. package/node_modules/matrix-js-sdk/src/rust-crypto/verification.ts +1 -1
  627. package/node_modules/matrix-js-sdk/src/serverCapabilities.ts +8 -67
  628. package/node_modules/matrix-js-sdk/src/sliding-sync-sdk.ts +5 -7
  629. package/node_modules/matrix-js-sdk/src/store/index.ts +8 -0
  630. package/node_modules/matrix-js-sdk/src/store/indexeddb-local-backend.ts +12 -2
  631. package/node_modules/matrix-js-sdk/src/store/indexeddb-remote-backend.ts +24 -5
  632. package/node_modules/matrix-js-sdk/src/store/indexeddb.ts +20 -8
  633. package/node_modules/matrix-js-sdk/src/store/memory.ts +4 -0
  634. package/node_modules/matrix-js-sdk/src/store/stub.ts +3 -0
  635. package/node_modules/matrix-js-sdk/src/sync-accumulator.ts +9 -0
  636. package/node_modules/matrix-js-sdk/src/sync.ts +11 -9
  637. package/node_modules/media-typer/README.md +19 -33
  638. package/node_modules/media-typer/dist/index.d.ts +29 -0
  639. package/node_modules/media-typer/dist/index.js +64 -0
  640. package/node_modules/media-typer/dist/index.js.map +1 -0
  641. package/node_modules/media-typer/package.json +37 -22
  642. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
  643. package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
  644. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
  645. package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
  646. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
  647. package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
  648. package/node_modules/music-metadata/package.json +5 -5
  649. package/node_modules/typebox/build/compile/validator.d.mts +2 -7
  650. package/node_modules/typebox/build/compile/validator.mjs +6 -36
  651. package/node_modules/typebox/build/error/errors.d.mts +1 -7
  652. package/node_modules/typebox/build/format/_idna.mjs +36 -6
  653. package/node_modules/typebox/build/format/_puny.mjs +4 -1
  654. package/node_modules/typebox/build/format/uuid.d.mts +2 -2
  655. package/node_modules/typebox/build/format/uuid.mjs +3 -3
  656. package/node_modules/typebox/build/guard/emit.d.mts +0 -4
  657. package/node_modules/typebox/build/guard/emit.mjs +0 -8
  658. package/node_modules/typebox/build/guard/guard.d.mts +4 -8
  659. package/node_modules/typebox/build/guard/guard.mjs +5 -13
  660. package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
  661. package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
  662. package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
  663. package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
  664. package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
  665. package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
  666. package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
  667. package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
  668. package/node_modules/typebox/build/schema/types/index.mjs +0 -1
  669. package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
  670. package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
  671. package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
  672. package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
  673. package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
  674. package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
  675. package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
  676. package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
  677. package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
  678. package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
  679. package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
  680. package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
  681. package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
  682. package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
  683. package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
  684. package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
  685. package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
  686. package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
  687. package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
  688. package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
  689. package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
  690. package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
  691. package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
  692. package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
  693. package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
  694. package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
  695. package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
  696. package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
  697. package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
  698. package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
  699. package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
  700. package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
  701. package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
  702. package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
  703. package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
  704. package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
  705. package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
  706. package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
  707. package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
  708. package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
  709. package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
  710. package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
  711. package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
  712. package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
  713. package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
  714. package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
  715. package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
  716. package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
  717. package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
  718. package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
  719. package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
  720. package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
  721. package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
  722. package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
  723. package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
  724. package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
  725. package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
  726. package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
  727. package/node_modules/typebox/build/type/action/index.d.mts +7 -4
  728. package/node_modules/typebox/build/type/action/index.mjs +7 -4
  729. package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
  730. package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
  731. package/node_modules/typebox/build/type/action/module.d.mts +8 -7
  732. package/node_modules/typebox/build/type/action/module.mjs +7 -6
  733. package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
  734. package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
  735. package/node_modules/typebox/build/type/action/with.d.mts +11 -0
  736. package/node_modules/typebox/build/type/action/with.mjs +11 -0
  737. package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
  738. package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
  739. package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
  740. package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
  741. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
  742. package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
  743. package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
  744. package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
  745. package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
  746. package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
  747. package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
  748. package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
  749. package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
  750. package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
  751. package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
  752. package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
  753. package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
  754. package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
  755. package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
  756. package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
  757. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
  758. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
  759. package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
  760. package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
  761. package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
  762. package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
  763. package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
  764. package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
  765. package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
  766. package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
  767. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
  768. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
  769. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
  770. package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
  771. package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
  772. package/node_modules/typebox/build/type/engine/index.mjs +2 -2
  773. package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
  774. package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
  775. package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
  776. package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
  777. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
  778. package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
  779. package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
  780. package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
  781. package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
  782. package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
  783. package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
  784. package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
  785. package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
  786. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
  787. package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
  788. package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
  789. package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
  790. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
  791. package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
  792. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
  793. package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
  794. package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
  795. package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
  796. package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
  797. package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
  798. package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
  799. package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
  800. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  801. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
  802. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
  803. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
  804. package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
  805. package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
  806. package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
  807. package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
  808. package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
  809. package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
  810. package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
  811. package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
  812. package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
  813. package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
  814. package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
  815. package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
  816. package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
  817. package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
  818. package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
  819. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
  820. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
  821. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
  822. package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
  823. package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
  824. package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
  825. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
  826. package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
  827. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
  828. package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
  829. package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
  830. package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
  831. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
  832. package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
  833. package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
  834. package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
  835. package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
  836. package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
  837. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
  838. package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
  839. package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
  840. package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
  841. package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
  842. package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
  843. package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
  844. package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
  845. package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
  846. package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
  847. package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
  848. package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
  849. package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
  850. package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
  851. package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
  852. package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
  853. package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
  854. package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
  855. package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
  856. package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
  857. package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
  858. package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
  859. package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
  860. package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
  861. package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
  862. package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
  863. package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
  864. package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
  865. package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
  866. package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
  867. package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
  868. package/node_modules/typebox/build/type/extends/object.mjs +25 -3
  869. package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
  870. package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
  871. package/node_modules/typebox/build/type/extends/record.mjs +23 -0
  872. package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
  873. package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
  874. package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
  875. package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
  876. package/node_modules/typebox/build/type/extends/union.mjs +2 -2
  877. package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
  878. package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
  879. package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
  880. package/node_modules/typebox/build/type/script/parser.mjs +22 -22
  881. package/node_modules/typebox/build/type/script/script.d.mts +3 -4
  882. package/node_modules/typebox/build/type/script/script.mjs +3 -2
  883. package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
  884. package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
  885. package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
  886. package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
  887. package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
  888. package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
  889. package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
  890. package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
  891. package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
  892. package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
  893. package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
  894. package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
  895. package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
  896. package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
  897. package/node_modules/typebox/build/type/types/call.d.mts +3 -3
  898. package/node_modules/typebox/build/type/types/call.mjs +3 -2
  899. package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
  900. package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
  901. package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
  902. package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
  903. package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
  904. package/node_modules/typebox/build/type/types/enum.mjs +5 -0
  905. package/node_modules/typebox/build/type/types/index.d.mts +1 -4
  906. package/node_modules/typebox/build/type/types/index.mjs +1 -4
  907. package/node_modules/typebox/build/type/types/number.d.mts +1 -1
  908. package/node_modules/typebox/build/type/types/number.mjs +1 -1
  909. package/node_modules/typebox/build/type/types/record.d.mts +13 -7
  910. package/node_modules/typebox/build/type/types/record.mjs +15 -9
  911. package/node_modules/typebox/build/type/types/static.d.mts +2 -5
  912. package/node_modules/typebox/build/typebox.d.mts +4 -8
  913. package/node_modules/typebox/build/typebox.mjs +4 -8
  914. package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
  915. package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
  916. package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
  917. package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
  918. package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
  919. package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
  920. package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
  921. package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
  922. package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
  923. package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
  924. package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
  925. package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
  926. package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
  927. package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
  928. package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
  929. package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
  930. package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
  931. package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
  932. package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
  933. package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
  934. package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
  935. package/node_modules/typebox/build/value/index.d.mts +0 -1
  936. package/node_modules/typebox/build/value/index.mjs +0 -1
  937. package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
  938. package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
  939. package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
  940. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
  941. package/node_modules/typebox/build/value/value.d.mts +0 -1
  942. package/node_modules/typebox/build/value/value.mjs +0 -1
  943. package/node_modules/typebox/package.json +25 -25
  944. package/node_modules/typebox/readme.md +97 -80
  945. package/npm-shrinkwrap.json +59 -54
  946. package/package.json +10 -10
  947. package/dist/probe.runtime-DFt7PIoE.js +0 -3
  948. package/node_modules/@babel/runtime/helpers/AwaitValue.js +0 -4
  949. package/node_modules/@babel/runtime/helpers/applyDecs.js +0 -236
  950. package/node_modules/@babel/runtime/helpers/applyDecs2203.js +0 -184
  951. package/node_modules/@babel/runtime/helpers/applyDecs2203R.js +0 -191
  952. package/node_modules/@babel/runtime/helpers/applyDecs2301.js +0 -222
  953. package/node_modules/@babel/runtime/helpers/applyDecs2305.js +0 -133
  954. package/node_modules/@babel/runtime/helpers/classApplyDescriptorDestructureSet.js +0 -10
  955. package/node_modules/@babel/runtime/helpers/classApplyDescriptorGet.js +0 -4
  956. package/node_modules/@babel/runtime/helpers/classApplyDescriptorSet.js +0 -7
  957. package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticAccess.js +0 -5
  958. package/node_modules/@babel/runtime/helpers/classCheckPrivateStaticFieldDescriptor.js +0 -4
  959. package/node_modules/@babel/runtime/helpers/classExtractFieldDescriptor.js +0 -5
  960. package/node_modules/@babel/runtime/helpers/classPrivateFieldDestructureSet.js +0 -7
  961. package/node_modules/@babel/runtime/helpers/classPrivateFieldGet.js +0 -7
  962. package/node_modules/@babel/runtime/helpers/classPrivateFieldSet.js +0 -7
  963. package/node_modules/@babel/runtime/helpers/classPrivateMethodGet.js +0 -5
  964. package/node_modules/@babel/runtime/helpers/classPrivateMethodSet.js +0 -4
  965. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldDestructureSet.js +0 -7
  966. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecGet.js +0 -7
  967. package/node_modules/@babel/runtime/helpers/classStaticPrivateFieldSpecSet.js +0 -7
  968. package/node_modules/@babel/runtime/helpers/classStaticPrivateMethodSet.js +0 -4
  969. package/node_modules/@babel/runtime/helpers/decorate.js +0 -250
  970. package/node_modules/@babel/runtime/helpers/defineEnumerableProperties.js +0 -12
  971. package/node_modules/@babel/runtime/helpers/dispose.js +0 -28
  972. package/node_modules/@babel/runtime/helpers/esm/AwaitValue.js +0 -4
  973. package/node_modules/@babel/runtime/helpers/esm/applyDecs.js +0 -236
  974. package/node_modules/@babel/runtime/helpers/esm/applyDecs2203.js +0 -184
  975. package/node_modules/@babel/runtime/helpers/esm/applyDecs2203R.js +0 -191
  976. package/node_modules/@babel/runtime/helpers/esm/applyDecs2301.js +0 -222
  977. package/node_modules/@babel/runtime/helpers/esm/applyDecs2305.js +0 -133
  978. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorDestructureSet.js +0 -10
  979. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorGet.js +0 -4
  980. package/node_modules/@babel/runtime/helpers/esm/classApplyDescriptorSet.js +0 -7
  981. package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticAccess.js +0 -5
  982. package/node_modules/@babel/runtime/helpers/esm/classCheckPrivateStaticFieldDescriptor.js +0 -4
  983. package/node_modules/@babel/runtime/helpers/esm/classExtractFieldDescriptor.js +0 -5
  984. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldDestructureSet.js +0 -7
  985. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldGet.js +0 -7
  986. package/node_modules/@babel/runtime/helpers/esm/classPrivateFieldSet.js +0 -7
  987. package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodGet.js +0 -5
  988. package/node_modules/@babel/runtime/helpers/esm/classPrivateMethodSet.js +0 -4
  989. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldDestructureSet.js +0 -7
  990. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecGet.js +0 -7
  991. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateFieldSpecSet.js +0 -7
  992. package/node_modules/@babel/runtime/helpers/esm/classStaticPrivateMethodSet.js +0 -4
  993. package/node_modules/@babel/runtime/helpers/esm/decorate.js +0 -250
  994. package/node_modules/@babel/runtime/helpers/esm/defineEnumerableProperties.js +0 -12
  995. package/node_modules/@babel/runtime/helpers/esm/dispose.js +0 -28
  996. package/node_modules/@babel/runtime/helpers/esm/objectSpread.js +0 -14
  997. package/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +0 -77
  998. package/node_modules/@babel/runtime/helpers/esm/using.js +0 -12
  999. package/node_modules/@babel/runtime/helpers/objectSpread.js +0 -14
  1000. package/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -77
  1001. package/node_modules/@babel/runtime/helpers/using.js +0 -12
  1002. package/node_modules/@babel/runtime/regenerator/index.js +0 -15
  1003. package/node_modules/content-type/HISTORY.md +0 -29
  1004. package/node_modules/content-type/index.js +0 -225
  1005. package/node_modules/media-typer/HISTORY.md +0 -50
  1006. package/node_modules/media-typer/index.js +0 -143
  1007. package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
  1008. package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
  1009. package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
  1010. package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
  1011. package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
  1012. package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
  1013. package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
  1014. package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
  1015. package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
  1016. package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
  1017. package/node_modules/typebox/build/type/action/options.d.mts +0 -11
  1018. package/node_modules/typebox/build/type/action/options.mjs +0 -11
  1019. package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
  1020. package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
  1021. package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
  1022. package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
  1023. package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
  1024. package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
  1025. package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
  1026. package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
  1027. package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
  1028. package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
  1029. package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
  1030. package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
  1031. package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
  1032. package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
  1033. package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
  1034. package/node_modules/typebox/build/type/types/base.d.mts +0 -50
  1035. package/node_modules/typebox/build/type/types/base.mjs +0 -84
  1036. package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
  1037. package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
  1038. package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
  1039. package/node_modules/typebox/build/type/types/promise.mjs +0 -29
  1040. package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
  1041. package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
  1042. package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
  1043. package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
  1044. package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
  1045. package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
  1046. package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
  1047. package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
  1048. package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
  1049. package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
  1050. package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
  1051. package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
  1052. package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
  1053. package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
  1054. package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
  1055. package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
  1056. package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
  1057. package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
  1058. package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
  1059. package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
  1060. package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
  1061. package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
  1062. package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
  1063. package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
  1064. package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
  1065. package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
  1066. package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
  1067. package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
  1068. package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
  1069. package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
  1070. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
  1071. /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
@@ -1,8 +1,5 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
6
3
  /*
7
4
  Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
8
5
 
@@ -49,13 +46,13 @@ import { KnownMembership } from "./@types/membership.js";
49
46
  // beyond that and wedge forever, so we need to track how long we are willing
50
47
  // to keep open the connection. This constant is *ADDED* to the timeout= value
51
48
  // to determine the max time we're willing to wait.
52
- var BUFFER_PERIOD_MS = 80 * 1000;
49
+ const BUFFER_PERIOD_MS = 80 * 1000;
53
50
 
54
51
  // Number of consecutive failed syncs that will lead to a syncState of ERROR as opposed
55
52
  // to RECONNECTING. This is needed to inform the client of server issues when the
56
53
  // keepAlive is successful but the server /sync fails.
57
- var FAILED_SYNC_ERROR_THRESHOLD = 3;
58
- export var SyncState = /*#__PURE__*/function (SyncState) {
54
+ const FAILED_SYNC_ERROR_THRESHOLD = 3;
55
+ export let SyncState = /*#__PURE__*/function (SyncState) {
59
56
  /** Emitted after we try to sync more than `FAILED_SYNC_ERROR_THRESHOLD`
60
57
  * times and are still failing. Or when we enounter a hard error like the
61
58
  * token being invalid. */
@@ -79,18 +76,18 @@ export var SyncState = /*#__PURE__*/function (SyncState) {
79
76
  // Room versions where "insertion", "batch", and "marker" events are controlled
80
77
  // by power-levels. MSC2716 is supported in existing room versions but they
81
78
  // should only have special meaning when the room creator sends them.
82
- var MSC2716_ROOM_VERSIONS = ["org.matrix.msc2716v3"];
79
+ const MSC2716_ROOM_VERSIONS = ["org.matrix.msc2716v3"];
83
80
  function getFilterName(userId, suffix) {
84
81
  // scope this on the user ID because people may login on many accounts
85
82
  // and they all need to be stored!
86
- return "FILTER_SYNC_".concat(userId) + (suffix ? "_" + suffix : "");
83
+ return `FILTER_SYNC_${userId}` + (suffix ? "_" + suffix : "");
87
84
  }
88
85
 
89
86
  /**
90
87
  * Options passed into the constructor of SyncApi by MatrixClient
91
88
  */
92
89
 
93
- export var SetPresence = /*#__PURE__*/function (SetPresence) {
90
+ export let SetPresence = /*#__PURE__*/function (SetPresence) {
94
91
  SetPresence["Offline"] = "offline";
95
92
  SetPresence["Online"] = "online";
96
93
  SetPresence["Unavailable"] = "unavailable";
@@ -112,8 +109,6 @@ export function defaultSyncApiOpts(syncOpts) {
112
109
  }, syncOpts);
113
110
  }
114
111
  export class SyncApi {
115
- // flag set if the store needs to be cleared before we can start
116
-
117
112
  /**
118
113
  * Construct an entity which is able to sync with a homeserver.
119
114
  * @param client - The matrix client instance to use.
@@ -122,35 +117,43 @@ export class SyncApi {
122
117
  * @internal
123
118
  */
124
119
  constructor(client, opts, syncOpts) {
125
- var _this = this;
120
+ _defineProperty(this, "opts", void 0);
121
+ _defineProperty(this, "syncOpts", void 0);
126
122
  _defineProperty(this, "_peekRoom", null);
123
+ _defineProperty(this, "currentSyncRequest", void 0);
124
+ _defineProperty(this, "abortController", void 0);
127
125
  _defineProperty(this, "syncState", null);
126
+ _defineProperty(this, "syncStateData", void 0);
128
127
  // additional data (eg. error object for failed sync)
129
128
  _defineProperty(this, "catchingUp", false);
130
129
  _defineProperty(this, "running", false);
130
+ _defineProperty(this, "keepAliveTimer", void 0);
131
+ _defineProperty(this, "connectionReturnedResolvers", void 0);
131
132
  _defineProperty(this, "notifEvents", []);
132
133
  // accumulator of sync events in the current sync response
133
134
  _defineProperty(this, "failedSyncCount", 0);
134
135
  // Number of consecutive failed /sync requests
135
136
  _defineProperty(this, "storeIsInvalid", false);
136
- _defineProperty(this, "getPushRules", /*#__PURE__*/_asyncToGenerator(function* () {
137
+ // flag set if the store needs to be cleared before we can start
138
+ _defineProperty(this, "presence", void 0);
139
+ _defineProperty(this, "getPushRules", async () => {
137
140
  try {
138
- _this.syncOpts.logger.debug("Getting push rules...");
139
- var result = yield _this.client.getPushRules();
140
- _this.syncOpts.logger.debug("Got push rules");
141
- _this.client.pushRules = result;
141
+ this.syncOpts.logger.debug("Getting push rules...");
142
+ const result = await this.client.getPushRules();
143
+ this.syncOpts.logger.debug("Got push rules");
144
+ this.client.pushRules = result;
142
145
  } catch (err) {
143
- _this.syncOpts.logger.error("Getting push rules failed", err);
144
- if (_this.shouldAbortSync(err)) return;
146
+ this.syncOpts.logger.error("Getting push rules failed", err);
147
+ if (this.shouldAbortSync(err)) return;
145
148
  // wait for saved sync to complete before doing anything else,
146
149
  // otherwise the sync state will end up being incorrect
147
- _this.syncOpts.logger.debug("Waiting for saved sync before retrying push rules...");
148
- yield _this.recoverFromSyncStartupError(_this.savedSyncPromise, err);
149
- return _this.getPushRules(); // try again
150
+ this.syncOpts.logger.debug("Waiting for saved sync before retrying push rules...");
151
+ await this.recoverFromSyncStartupError(this.savedSyncPromise, err);
152
+ return this.getPushRules(); // try again
150
153
  }
151
- }));
154
+ });
152
155
  _defineProperty(this, "buildDefaultFilter", () => {
153
- var filter = new Filter(this.client.credentials.userId);
156
+ const filter = new Filter(this.client.credentials.userId);
154
157
  if (this.client.canSupport.get(Feature.ThreadUnreadNotifications) !== ServerSupport.Unsupported) {
155
158
  filter.setUnreadThreadNotifications(true);
156
159
  }
@@ -176,51 +179,51 @@ export class SyncApi {
176
179
  /**
177
180
  * Preare sync filter options for the unstable MSC4429 user profile fields if enabled.
178
181
  */
179
- _defineProperty(this, "prepareSyncFilterUserProfiles", /*#__PURE__*/_asyncToGenerator(function* () {
180
- var _this$opts$unstableMS;
181
- if ((_this$opts$unstableMS = _this.opts.unstableMSC4429SyncUserProfileFields) !== null && _this$opts$unstableMS !== void 0 && _this$opts$unstableMS.length) {
182
- _this.syncOpts.logger.debug("Enabling EXPERIMENTAL user profiles on sync filter...");
183
- if (!_this.opts.filter) {
184
- _this.opts.filter = _this.buildDefaultFilter();
182
+ _defineProperty(this, "prepareSyncFilterUserProfiles", async () => {
183
+ if (this.opts.unstableMSC4429SyncUserProfileFields?.length) {
184
+ this.syncOpts.logger.debug("Enabling EXPERIMENTAL user profiles on sync filter...");
185
+ if (!this.opts.filter) {
186
+ this.opts.filter = this.buildDefaultFilter();
185
187
  }
186
- _this.opts.filter.setUnstableMSC4429SyncUserProfiles(_this.opts.unstableMSC4429SyncUserProfileFields, yield _this.client.doesServerSupportUnstableFeature("org.matrix.msc4429.stable"));
188
+ this.opts.filter.setUnstableMSC4429SyncUserProfiles(this.opts.unstableMSC4429SyncUserProfileFields, await this.client.doesServerSupportUnstableFeature("org.matrix.msc4429.stable"));
187
189
  }
188
- }));
189
- _defineProperty(this, "storeClientOptions", /*#__PURE__*/_asyncToGenerator(function* () {
190
+ });
191
+ _defineProperty(this, "storeClientOptions", async () => {
190
192
  try {
191
- _this.syncOpts.logger.debug("Storing client options...");
192
- yield _this.client.storeClientOptions();
193
- _this.syncOpts.logger.debug("Stored client options");
193
+ this.syncOpts.logger.debug("Storing client options...");
194
+ await this.client.storeClientOptions();
195
+ this.syncOpts.logger.debug("Stored client options");
194
196
  } catch (err) {
195
- _this.syncOpts.logger.error("Storing client options failed", err);
197
+ this.syncOpts.logger.error("Storing client options failed", err);
196
198
  throw err;
197
199
  }
198
- }));
199
- _defineProperty(this, "getFilter", /*#__PURE__*/_asyncToGenerator(function* () {
200
- _this.syncOpts.logger.debug("Getting filter...");
201
- var filter;
202
- if (_this.opts.filter) {
203
- filter = _this.opts.filter;
200
+ });
201
+ _defineProperty(this, "getFilter", async () => {
202
+ this.syncOpts.logger.debug("Getting filter...");
203
+ let filter;
204
+ if (this.opts.filter) {
205
+ filter = this.opts.filter;
204
206
  } else {
205
- filter = _this.buildDefaultFilter();
207
+ filter = this.buildDefaultFilter();
206
208
  }
207
- var filterId;
209
+ let filterId;
208
210
  try {
209
- filterId = yield _this.client.getOrCreateFilter(getFilterName(_this.client.credentials.userId), filter);
211
+ filterId = await this.client.getOrCreateFilter(getFilterName(this.client.credentials.userId), filter);
210
212
  } catch (err) {
211
- _this.syncOpts.logger.error("Getting filter failed", err);
212
- if (_this.shouldAbortSync(err)) return {};
213
+ this.syncOpts.logger.error("Getting filter failed", err);
214
+ if (this.shouldAbortSync(err)) return {};
213
215
  // wait for saved sync to complete before doing anything else,
214
216
  // otherwise the sync state will end up being incorrect
215
- _this.syncOpts.logger.debug("Waiting for saved sync before retrying filter...");
216
- yield _this.recoverFromSyncStartupError(_this.savedSyncPromise, err);
217
- return _this.getFilter(); // try again
217
+ this.syncOpts.logger.debug("Waiting for saved sync before retrying filter...");
218
+ await this.recoverFromSyncStartupError(this.savedSyncPromise, err);
219
+ return this.getFilter(); // try again
218
220
  }
219
221
  return {
220
222
  filter,
221
223
  filterId
222
224
  };
223
- }));
225
+ });
226
+ _defineProperty(this, "savedSyncPromise", void 0);
224
227
  /**
225
228
  * Event handler for the 'online' event
226
229
  * This event is generally unreliable and precise behaviour
@@ -239,7 +242,7 @@ export class SyncApi {
239
242
  }
240
243
  }
241
244
  createRoom(roomId) {
242
- var room = _createAndReEmitRoom(this.client, roomId, this.opts);
245
+ const room = _createAndReEmitRoom(this.client, roomId, this.opts);
243
246
  room.on(RoomStateEvent.Marker, (markerEvent, markerFoundOptions) => {
244
247
  this.onMarkerStateEvent(room, markerEvent, markerFoundOptions);
245
248
  });
@@ -255,19 +258,19 @@ export class SyncApi {
255
258
  * @param setStateOptions - When `timelineWasEmpty` is set
256
259
  * as `true`, the given marker event will be ignored
257
260
  */
258
- onMarkerStateEvent(room, markerEvent) {
259
- var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
260
- timelineWasEmpty = _ref5.timelineWasEmpty;
261
+ onMarkerStateEvent(room, markerEvent, {
262
+ timelineWasEmpty
263
+ } = {}) {
261
264
  // We don't need to refresh the timeline if it was empty before the
262
265
  // marker arrived. This could be happen in a variety of cases:
263
266
  // 1. From the initial sync
264
267
  // 2. If it's from the first state we're seeing after joining the room
265
268
  // 3. Or whether it's coming from `syncFromCache`
266
269
  if (timelineWasEmpty) {
267
- this.syncOpts.logger.debug("MarkerState: Ignoring markerEventId=".concat(markerEvent.getId(), " in roomId=").concat(room.roomId, " ") + "because the timeline was empty before the marker arrived which means there is nothing to refresh.");
270
+ this.syncOpts.logger.debug(`MarkerState: Ignoring markerEventId=${markerEvent.getId()} in roomId=${room.roomId} ` + `because the timeline was empty before the marker arrived which means there is nothing to refresh.`);
268
271
  return;
269
272
  }
270
- var isValidMsc2716Event =
273
+ const isValidMsc2716Event =
271
274
  // Check whether the room version directly supports MSC2716, in
272
275
  // which case, "marker" events are already auth'ed by
273
276
  // power_levels
@@ -292,11 +295,11 @@ export class SyncApi {
292
295
  if (isValidMsc2716Event) {
293
296
  // Saw new marker event, let's let the clients know they should
294
297
  // refresh the timeline.
295
- this.syncOpts.logger.debug("MarkerState: Timeline needs to be refreshed because " + "a new markerEventId=".concat(markerEvent.getId(), " was sent in roomId=").concat(room.roomId));
298
+ this.syncOpts.logger.debug(`MarkerState: Timeline needs to be refreshed because ` + `a new markerEventId=${markerEvent.getId()} was sent in roomId=${room.roomId}`);
296
299
  room.setTimelineNeedsRefresh(true);
297
300
  room.emit(RoomEvent.HistoryImportedWithinTimeline, markerEvent, room);
298
301
  } else {
299
- this.syncOpts.logger.debug("MarkerState: Ignoring markerEventId=".concat(markerEvent.getId(), " in roomId=").concat(room.roomId, " because ") + "MSC2716 is not supported in the room version or for any room version, the marker wasn't sent " + "by the room creator.");
302
+ this.syncOpts.logger.debug(`MarkerState: Ignoring markerEventId=${markerEvent.getId()} in roomId=${room.roomId} because ` + `MSC2716 is not supported in the room version or for any room version, the marker wasn't sent ` + `by the room creator.`);
300
303
  }
301
304
  }
302
305
 
@@ -304,67 +307,59 @@ export class SyncApi {
304
307
  * Sync rooms the user has left.
305
308
  * @returns Resolved when they've been added to the store.
306
309
  */
307
- syncLeftRooms() {
308
- var _this2 = this;
309
- return _asyncToGenerator(function* () {
310
- var _data$rooms;
311
- var client = _this2.client;
312
-
313
- // grab a filter with limit=1 and include_leave=true
314
- var filter = new Filter(_this2.client.credentials.userId);
315
- filter.setTimelineLimit(1);
316
- filter.setIncludeLeaveRooms(true);
317
- var localTimeoutMs = _this2.opts.pollTimeout + BUFFER_PERIOD_MS;
318
- var filterId = yield client.getOrCreateFilter(getFilterName(client.credentials.userId, "LEFT_ROOMS"), filter);
319
- var qps = {
320
- "timeout": 0,
321
- // don't want to block since this is a single isolated req
322
- "filter": filterId,
323
- "org.matrix.msc4222.use_state_after": true
324
- };
325
- var data = yield client.http.authedRequest(Method.Get, "/sync", qps, undefined, {
326
- localTimeoutMs
327
- });
328
- var leaveRooms = [];
329
- if ((_data$rooms = data.rooms) !== null && _data$rooms !== void 0 && _data$rooms.leave) {
330
- leaveRooms = _this2.mapSyncResponseToRoomArray(data.rooms.leave);
310
+ async syncLeftRooms() {
311
+ const client = this.client;
312
+
313
+ // grab a filter with limit=1 and include_leave=true
314
+ const filter = new Filter(this.client.credentials.userId);
315
+ filter.setTimelineLimit(1);
316
+ filter.setIncludeLeaveRooms(true);
317
+ const localTimeoutMs = this.opts.pollTimeout + BUFFER_PERIOD_MS;
318
+ const filterId = await client.getOrCreateFilter(getFilterName(client.credentials.userId, "LEFT_ROOMS"), filter);
319
+ const qps = {
320
+ "timeout": 0,
321
+ // don't want to block since this is a single isolated req
322
+ "filter": filterId,
323
+ "org.matrix.msc4222.use_state_after": true
324
+ };
325
+ const data = await client.http.authedRequest(Method.Get, "/sync", qps, undefined, {
326
+ localTimeoutMs
327
+ });
328
+ let leaveRooms = [];
329
+ if (data.rooms?.leave) {
330
+ leaveRooms = this.mapSyncResponseToRoomArray(data.rooms.leave);
331
+ }
332
+ const rooms = await Promise.all(leaveRooms.map(async leaveObj => {
333
+ const room = leaveObj.room;
334
+ if (!leaveObj.isBrandNewRoom) {
335
+ // the intention behind syncLeftRooms is to add in rooms which were
336
+ // *omitted* from the initial /sync. Rooms the user were joined to
337
+ // but then left whilst the app is running will appear in this list
338
+ // and we do not want to bother with them since they will have the
339
+ // current state already (and may get dupe messages if we add
340
+ // yet more timeline events!), so skip them.
341
+ // NB: When we persist rooms to localStorage this will be more
342
+ // complicated...
343
+ return;
331
344
  }
332
- var rooms = yield Promise.all(leaveRooms.map(/*#__PURE__*/function () {
333
- var _ref6 = _asyncToGenerator(function* (leaveObj) {
334
- var room = leaveObj.room;
335
- if (!leaveObj.isBrandNewRoom) {
336
- // the intention behind syncLeftRooms is to add in rooms which were
337
- // *omitted* from the initial /sync. Rooms the user were joined to
338
- // but then left whilst the app is running will appear in this list
339
- // and we do not want to bother with them since they will have the
340
- // current state already (and may get dupe messages if we add
341
- // yet more timeline events!), so skip them.
342
- // NB: When we persist rooms to localStorage this will be more
343
- // complicated...
344
- return;
345
- }
346
- leaveObj.timeline = leaveObj.timeline || {
347
- prev_batch: null,
348
- events: []
349
- };
350
-
351
- // set the back-pagination token. Do this *before* adding any
352
- // events so that clients can start back-paginating.
353
- room.getLiveTimeline().setPaginationToken(leaveObj.timeline.prev_batch, EventTimeline.BACKWARDS);
354
- var _yield$_this2$mapAndI = yield _this2.mapAndInjectRoomEvents(leaveObj),
355
- timelineEvents = _yield$_this2$mapAndI.timelineEvents;
356
- room.recalculate();
357
- client.store.storeRoom(room);
358
- client.emit(ClientEvent.Room, room);
359
- _this2.processEventsForNotifs(room, timelineEvents);
360
- return room;
361
- });
362
- return function (_x) {
363
- return _ref6.apply(this, arguments);
364
- };
365
- }()));
366
- return rooms.filter(Boolean);
367
- })();
345
+ leaveObj.timeline = leaveObj.timeline || {
346
+ prev_batch: null,
347
+ events: []
348
+ };
349
+
350
+ // set the back-pagination token. Do this *before* adding any
351
+ // events so that clients can start back-paginating.
352
+ room.getLiveTimeline().setPaginationToken(leaveObj.timeline.prev_batch, EventTimeline.BACKWARDS);
353
+ const {
354
+ timelineEvents
355
+ } = await this.mapAndInjectRoomEvents(leaveObj);
356
+ room.recalculate();
357
+ client.store.storeRoom(room);
358
+ client.emit(ClientEvent.Room, room);
359
+ this.processEventsForNotifs(room, timelineEvents);
360
+ return room;
361
+ }));
362
+ return rooms.filter(Boolean);
368
363
  }
369
364
 
370
365
  /**
@@ -375,17 +370,14 @@ export class SyncApi {
375
370
  * @returns A promise which resolves once the room has been added to the
376
371
  * store.
377
372
  */
378
- peek(roomId) {
379
- var _this$_peekRoom;
380
- var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;
381
- if (((_this$_peekRoom = this._peekRoom) === null || _this$_peekRoom === void 0 ? void 0 : _this$_peekRoom.roomId) === roomId) {
373
+ peek(roomId, limit = 20) {
374
+ if (this._peekRoom?.roomId === roomId) {
382
375
  return Promise.resolve(this._peekRoom);
383
376
  }
384
- var client = this.client;
377
+ const client = this.client;
385
378
  this._peekRoom = this.createRoom(roomId);
386
379
  return this.client.roomInitialSync(roomId, limit).then(response => {
387
- var _this$_peekRoom2;
388
- if (((_this$_peekRoom2 = this._peekRoom) === null || _this$_peekRoom2 === void 0 ? void 0 : _this$_peekRoom2.roomId) !== roomId) {
380
+ if (this._peekRoom?.roomId !== roomId) {
389
381
  throw new Error("Peeking aborted");
390
382
  }
391
383
 
@@ -398,15 +390,15 @@ export class SyncApi {
398
390
 
399
391
  // FIXME: Mostly duplicated from injectRoomEvents but not entirely
400
392
  // because "state" in this API is at the BEGINNING of the chunk
401
- var oldStateEvents = deepCopy(response.state).map(client.getEventMapper());
402
- var stateEvents = response.state.map(client.getEventMapper());
403
- var messages = response.messages.chunk.map(client.getEventMapper());
393
+ const oldStateEvents = deepCopy(response.state).map(client.getEventMapper());
394
+ const stateEvents = response.state.map(client.getEventMapper());
395
+ const messages = response.messages.chunk.map(client.getEventMapper());
404
396
 
405
397
  // XXX: copypasted from /sync until we kill off this minging v1 API stuff)
406
398
  // handle presence events (User objects)
407
399
  if (Array.isArray(response.presence)) {
408
400
  response.presence.map(client.getEventMapper()).forEach(function (presenceEvent) {
409
- var user = client.store.getUser(presenceEvent.getContent().user_id);
401
+ let user = client.store.getUser(presenceEvent.getContent().user_id);
410
402
  if (user) {
411
403
  user.setPresenceEvent(presenceEvent);
412
404
  } else {
@@ -455,8 +447,6 @@ export class SyncApi {
455
447
  * @param token - from= token
456
448
  */
457
449
  peekPoll(peekRoom, token) {
458
- var _this$abortController,
459
- _this3 = this;
460
450
  if (this._peekRoom !== peekRoom) {
461
451
  this.syncOpts.logger.debug("Stopped peeking in room %s", peekRoom.roomId);
462
452
  return;
@@ -469,51 +459,46 @@ export class SyncApi {
469
459
  from: token
470
460
  }, undefined, {
471
461
  localTimeoutMs: 50 * 1000,
472
- abortSignal: (_this$abortController = this.abortController) === null || _this$abortController === void 0 ? void 0 : _this$abortController.signal
473
- }).then(/*#__PURE__*/function () {
474
- var _ref7 = _asyncToGenerator(function* (res) {
475
- if (_this3._peekRoom !== peekRoom) {
476
- _this3.syncOpts.logger.debug("Stopped peeking in room %s", peekRoom.roomId);
477
- return;
462
+ abortSignal: this.abortController?.signal
463
+ }).then(async res => {
464
+ if (this._peekRoom !== peekRoom) {
465
+ this.syncOpts.logger.debug("Stopped peeking in room %s", peekRoom.roomId);
466
+ return;
467
+ }
468
+ // We have a problem that we get presence both from /events and /sync
469
+ // however, /sync only returns presence for users in rooms
470
+ // you're actually joined to.
471
+ // in order to be sure to get presence for all of the users in the
472
+ // peeked room, we handle presence explicitly here. This may result
473
+ // in duplicate presence events firing for some users, which is a
474
+ // performance drain, but such is life.
475
+ // XXX: copypasted from /sync until we can kill this minging v1 stuff.
476
+
477
+ res.chunk.filter(function (e) {
478
+ return e.type === "m.presence";
479
+ }).map(this.client.getEventMapper()).forEach(presenceEvent => {
480
+ let user = this.client.store.getUser(presenceEvent.getContent().user_id);
481
+ if (user) {
482
+ user.setPresenceEvent(presenceEvent);
483
+ } else {
484
+ user = User.createUser(presenceEvent.getContent().user_id, this.client);
485
+ user.setPresenceEvent(presenceEvent);
486
+ this.client.store.storeUser(user);
478
487
  }
479
- // We have a problem that we get presence both from /events and /sync
480
- // however, /sync only returns presence for users in rooms
481
- // you're actually joined to.
482
- // in order to be sure to get presence for all of the users in the
483
- // peeked room, we handle presence explicitly here. This may result
484
- // in duplicate presence events firing for some users, which is a
485
- // performance drain, but such is life.
486
- // XXX: copypasted from /sync until we can kill this minging v1 stuff.
487
-
488
- res.chunk.filter(function (e) {
489
- return e.type === "m.presence";
490
- }).map(_this3.client.getEventMapper()).forEach(presenceEvent => {
491
- var user = _this3.client.store.getUser(presenceEvent.getContent().user_id);
492
- if (user) {
493
- user.setPresenceEvent(presenceEvent);
494
- } else {
495
- user = User.createUser(presenceEvent.getContent().user_id, _this3.client);
496
- user.setPresenceEvent(presenceEvent);
497
- _this3.client.store.storeUser(user);
498
- }
499
- _this3.client.emit(ClientEvent.Event, presenceEvent);
500
- });
488
+ this.client.emit(ClientEvent.Event, presenceEvent);
489
+ });
501
490
 
502
- // strip out events which aren't for the given room_id (e.g presence)
503
- // and also ephemeral events (which we're assuming is anything without
504
- // and event ID because the /events API doesn't separate them).
505
- var events = res.chunk.filter(function (e) {
506
- return e.room_id === peekRoom.roomId && e.event_id;
507
- }).map(_this3.client.getEventMapper());
508
- yield peekRoom.addLiveEvents(events, {
509
- addToState: true
510
- });
511
- _this3.peekPoll(peekRoom, res.end);
491
+ // strip out events which aren't for the given room_id (e.g presence)
492
+ // and also ephemeral events (which we're assuming is anything without
493
+ // and event ID because the /events API doesn't separate them).
494
+ const events = res.chunk.filter(function (e) {
495
+ return e.room_id === peekRoom.roomId && e.event_id;
496
+ }).map(this.client.getEventMapper());
497
+ await peekRoom.addLiveEvents(events, {
498
+ addToState: true
512
499
  });
513
- return function (_x2) {
514
- return _ref7.apply(this, arguments);
515
- };
516
- }(), err => {
500
+ this.peekPoll(peekRoom, res.end);
501
+ }, err => {
517
502
  this.syncOpts.logger.error("[%s] Peek poll failed: %s", peekRoom.roomId, err);
518
503
  setTimeout(() => {
519
504
  this.peekPoll(peekRoom, token);
@@ -537,23 +522,19 @@ export class SyncApi {
537
522
  * this object.
538
523
  */
539
524
  getSyncStateData() {
540
- var _this$syncStateData;
541
- return (_this$syncStateData = this.syncStateData) !== null && _this$syncStateData !== void 0 ? _this$syncStateData : null;
525
+ return this.syncStateData ?? null;
542
526
  }
543
- recoverFromSyncStartupError(savedSyncPromise, error) {
544
- var _this4 = this;
545
- return _asyncToGenerator(function* () {
546
- // Wait for the saved sync to complete - we send the pushrules and filter requests
547
- // before the saved sync has finished so they can run in parallel, but only process
548
- // the results after the saved sync is done. Equivalently, we wait for it to finish
549
- // before reporting failures from these functions.
550
- yield savedSyncPromise;
551
- var keepaliveProm = _this4.startKeepAlives();
552
- _this4.updateSyncState(SyncState.Error, {
553
- error
554
- });
555
- yield keepaliveProm;
556
- })();
527
+ async recoverFromSyncStartupError(savedSyncPromise, error) {
528
+ // Wait for the saved sync to complete - we send the pushrules and filter requests
529
+ // before the saved sync has finished so they can run in parallel, but only process
530
+ // the results after the saved sync is done. Equivalently, we wait for it to finish
531
+ // before reporting failures from these functions.
532
+ await savedSyncPromise;
533
+ const keepaliveProm = this.startKeepAlives();
534
+ this.updateSyncState(SyncState.Error, {
535
+ error
536
+ });
537
+ await keepaliveProm;
557
538
  }
558
539
  shouldAbortSync(error) {
559
540
  if (error.errcode === "M_UNKNOWN_TOKEN") {
@@ -570,104 +551,100 @@ export class SyncApi {
570
551
  /**
571
552
  * Main entry point
572
553
  */
573
- sync() {
574
- var _this5 = this;
575
- return _asyncToGenerator(function* () {
576
- var _globalThis$window, _globalThis$window$ad;
577
- _this5.running = true;
578
- _this5.abortController = new AbortController();
579
- (_globalThis$window = globalThis.window) === null || _globalThis$window === void 0 || (_globalThis$window$ad = _globalThis$window.addEventListener) === null || _globalThis$window$ad === void 0 || _globalThis$window$ad.call(_globalThis$window, "online", _this5.onOnline, false);
580
- if (_this5.client.isGuest()) {
581
- // no push rules for guests, no access to POST filter for guests.
582
- return _this5.doSync({});
583
- }
584
-
585
- // Pull the saved sync token out first, before the worker starts sending
586
- // all the sync data which could take a while. This will let us send our
587
- // first incremental sync request before we've processed our saved data.
588
- _this5.syncOpts.logger.debug("Getting saved sync token...");
589
- var savedSyncTokenPromise = _this5.client.store.getSavedSyncToken().then(tok => {
590
- _this5.syncOpts.logger.debug("Got saved sync token");
591
- return tok;
592
- });
593
- _this5.savedSyncPromise = _this5.client.store.getSavedSync().then(savedSync => {
594
- _this5.syncOpts.logger.debug("Got reply from saved sync, exists? ".concat(!!savedSync));
595
- if (savedSync) {
596
- return _this5.syncFromCache(savedSync);
597
- }
598
- }).catch(err => {
599
- _this5.syncOpts.logger.error("Getting saved sync failed", err);
600
- });
554
+ async sync() {
555
+ this.running = true;
556
+ this.abortController = new AbortController();
557
+ globalThis.window?.addEventListener?.("online", this.onOnline, false);
558
+ if (this.client.isGuest()) {
559
+ // no push rules for guests, no access to POST filter for guests.
560
+ return this.doSync({});
561
+ }
601
562
 
602
- // We need to do one-off checks before we can begin the /sync loop.
603
- // These are:
604
- // 1) We need to get push rules so we can check if events should bing as we get
605
- // them from /sync.
606
- // 2) We need to get/create a filter which we can use for /sync.
607
- // 3) We need to prepare lazy loading for sync
608
- // 4) We need to store the client options
609
-
610
- // Now start the first incremental sync request: this can also
611
- // take a while so if we set it going now, we can wait for it
612
- // to finish while we process our saved sync data.
613
- yield _this5.getPushRules();
614
- _this5.prepareSyncFilterLazyLoading();
615
- yield _this5.prepareSyncFilterUserProfiles();
616
- yield _this5.storeClientOptions();
617
- var _yield$_this5$getFilt = yield _this5.getFilter(),
618
- filterId = _yield$_this5$getFilt.filterId,
619
- filter = _yield$_this5$getFilt.filter;
620
- if (!filter) return; // bail, getFilter failed
621
-
622
- // reset the notifications timeline to prepare it to paginate from
623
- // the current point in time.
624
- // The right solution would be to tie /sync pagination tokens into
625
- // /notifications API somehow.
626
- _this5.client.resetNotifTimelineSet();
627
- if (!_this5.currentSyncRequest) {
628
- var firstSyncFilter = filterId;
629
- var savedSyncToken = yield savedSyncTokenPromise;
630
- if (savedSyncToken) {
631
- _this5.syncOpts.logger.debug("Sending first sync request...");
632
- } else {
633
- _this5.syncOpts.logger.debug("Sending initial sync request...");
634
- var initialFilter = _this5.buildDefaultFilter();
635
- initialFilter.setDefinition(filter.getDefinition());
636
- initialFilter.setTimelineLimit(_this5.opts.initialSyncLimit);
637
- // Use an inline filter, no point uploading it for a single usage
638
- firstSyncFilter = JSON.stringify(initialFilter.getDefinition());
639
- }
563
+ // Pull the saved sync token out first, before the worker starts sending
564
+ // all the sync data which could take a while. This will let us send our
565
+ // first incremental sync request before we've processed our saved data.
566
+ this.syncOpts.logger.debug("Getting saved sync token...");
567
+ const savedSyncTokenPromise = this.client.store.getSavedSyncToken().then(tok => {
568
+ this.syncOpts.logger.debug("Got saved sync token");
569
+ return tok;
570
+ });
571
+ this.savedSyncPromise = this.client.store.getSavedSync().then(savedSync => {
572
+ this.syncOpts.logger.debug(`Got reply from saved sync, exists? ${!!savedSync}`);
573
+ if (savedSync) {
574
+ return this.syncFromCache(savedSync);
575
+ }
576
+ }).catch(err => {
577
+ this.syncOpts.logger.error("Getting saved sync failed", err);
578
+ });
640
579
 
641
- // Send this first sync request here so we can then wait for the saved
642
- // sync data to finish processing before we process the results of this one.
643
- _this5.currentSyncRequest = _this5.doSyncRequest({
644
- filter: firstSyncFilter
645
- }, savedSyncToken);
580
+ // We need to do one-off checks before we can begin the /sync loop.
581
+ // These are:
582
+ // 1) We need to get push rules so we can check if events should bing as we get
583
+ // them from /sync.
584
+ // 2) We need to get/create a filter which we can use for /sync.
585
+ // 3) We need to prepare lazy loading for sync
586
+ // 4) We need to store the client options
587
+
588
+ // Now start the first incremental sync request: this can also
589
+ // take a while so if we set it going now, we can wait for it
590
+ // to finish while we process our saved sync data.
591
+ await this.getPushRules();
592
+ this.prepareSyncFilterLazyLoading();
593
+ await this.prepareSyncFilterUserProfiles();
594
+ await this.storeClientOptions();
595
+ const {
596
+ filterId,
597
+ filter
598
+ } = await this.getFilter();
599
+ if (!filter) return; // bail, getFilter failed
600
+
601
+ // reset the notifications timeline to prepare it to paginate from
602
+ // the current point in time.
603
+ // The right solution would be to tie /sync pagination tokens into
604
+ // /notifications API somehow.
605
+ this.client.resetNotifTimelineSet();
606
+ if (!this.currentSyncRequest) {
607
+ let firstSyncFilter = filterId;
608
+ const savedSyncToken = await savedSyncTokenPromise;
609
+ if (savedSyncToken) {
610
+ this.syncOpts.logger.debug("Sending first sync request...");
611
+ } else {
612
+ this.syncOpts.logger.debug("Sending initial sync request...");
613
+ const initialFilter = this.buildDefaultFilter();
614
+ initialFilter.setDefinition(filter.getDefinition());
615
+ initialFilter.setTimelineLimit(this.opts.initialSyncLimit);
616
+ // Use an inline filter, no point uploading it for a single usage
617
+ firstSyncFilter = JSON.stringify(initialFilter.getDefinition());
646
618
  }
647
619
 
648
- // Now wait for the saved sync to finish...
649
- _this5.syncOpts.logger.debug("Waiting for saved sync before starting sync processing...");
650
- yield _this5.savedSyncPromise;
651
- // process the first sync request and continue syncing with the normal filterId
652
- return _this5.doSync({
653
- filter: filterId
654
- });
655
- })();
620
+ // Send this first sync request here so we can then wait for the saved
621
+ // sync data to finish processing before we process the results of this one.
622
+ this.currentSyncRequest = this.doSyncRequest({
623
+ filter: firstSyncFilter
624
+ }, savedSyncToken);
625
+ }
626
+
627
+ // Now wait for the saved sync to finish...
628
+ this.syncOpts.logger.debug("Waiting for saved sync before starting sync processing...");
629
+ await this.savedSyncPromise;
630
+ // process the first sync request and continue syncing with the normal filterId
631
+ return this.doSync({
632
+ filter: filterId
633
+ });
656
634
  }
657
635
 
658
636
  /**
659
637
  * Stops the sync object from syncing.
660
638
  */
661
639
  stop() {
662
- var _globalThis$window2, _globalThis$window2$r, _this$abortController2;
663
640
  this.syncOpts.logger.debug("SyncApi.stop");
664
641
  // It is necessary to check for the existance of
665
642
  // globalThis.window AND globalThis.window.removeEventListener.
666
643
  // Some platforms (e.g. React Native) register globalThis.window,
667
644
  // but do not have globalThis.window.removeEventListener.
668
- (_globalThis$window2 = globalThis.window) === null || _globalThis$window2 === void 0 || (_globalThis$window2$r = _globalThis$window2.removeEventListener) === null || _globalThis$window2$r === void 0 || _globalThis$window2$r.call(_globalThis$window2, "online", this.onOnline, false);
645
+ globalThis.window?.removeEventListener?.("online", this.onOnline, false);
669
646
  this.running = false;
670
- (_this$abortController2 = this.abortController) === null || _this$abortController2 === void 0 || _this$abortController2.abort();
647
+ this.abortController?.abort();
671
648
  if (this.keepAliveTimer) {
672
649
  clearTimeout(this.keepAliveTimer);
673
650
  this.keepAliveTimer = undefined;
@@ -691,134 +668,127 @@ export class SyncApi {
691
668
  * @param savedSync - a saved sync that was persisted by a store. This
692
669
  * should have been acquired via client.store.getSavedSync().
693
670
  */
694
- syncFromCache(savedSync) {
695
- var _this6 = this;
696
- return _asyncToGenerator(function* () {
697
- _this6.syncOpts.logger.debug("sync(): not doing HTTP hit, instead returning stored /sync data");
698
- var nextSyncToken = savedSync.nextBatch;
699
-
700
- // Set sync token for future incremental syncing
701
- _this6.client.store.setSyncToken(nextSyncToken);
702
-
703
- // No previous sync, set old token to null
704
- var syncEventData = {
705
- nextSyncToken,
706
- catchingUp: false,
707
- fromCache: true
708
- };
709
- var data = {
710
- next_batch: nextSyncToken,
711
- rooms: savedSync.roomsData,
712
- account_data: {
713
- events: savedSync.accountData
714
- }
715
- };
716
- try {
717
- yield _this6.processSyncResponse(syncEventData, data);
718
- } catch (e) {
719
- _this6.syncOpts.logger.error("Error processing cached sync", e);
671
+ async syncFromCache(savedSync) {
672
+ this.syncOpts.logger.debug("sync(): not doing HTTP hit, instead returning stored /sync data");
673
+ const nextSyncToken = savedSync.nextBatch;
674
+
675
+ // Set sync token for future incremental syncing
676
+ this.client.store.setSyncToken(nextSyncToken);
677
+
678
+ // No previous sync, set old token to null
679
+ const syncEventData = {
680
+ nextSyncToken,
681
+ catchingUp: false,
682
+ fromCache: true
683
+ };
684
+ const data = {
685
+ next_batch: nextSyncToken,
686
+ rooms: savedSync.roomsData,
687
+ account_data: {
688
+ events: savedSync.accountData
720
689
  }
690
+ };
691
+ try {
692
+ await this.processSyncResponse(syncEventData, data);
693
+ } catch (e) {
694
+ this.syncOpts.logger.error("Error processing cached sync", e);
695
+ }
721
696
 
722
- // Don't emit a prepared if we've bailed because the store is invalid:
723
- // in this case the client will not be usable until stopped & restarted
724
- // so this would be useless and misleading.
725
- if (!_this6.storeIsInvalid) {
726
- _this6.updateSyncState(SyncState.Prepared, syncEventData);
727
- }
728
- })();
697
+ // Don't emit a prepared if we've bailed because the store is invalid:
698
+ // in this case the client will not be usable until stopped & restarted
699
+ // so this would be useless and misleading.
700
+ if (!this.storeIsInvalid) {
701
+ this.updateSyncState(SyncState.Prepared, syncEventData);
702
+ }
729
703
  }
730
704
 
731
705
  /**
732
706
  * Invoke me to do /sync calls
733
707
  */
734
- doSync(syncOptions) {
735
- var _this7 = this;
736
- return _asyncToGenerator(function* () {
737
- while (_this7.running) {
738
- var syncToken = _this7.client.store.getSyncToken();
739
- var data = void 0;
740
- try {
741
- if (!_this7.currentSyncRequest) {
742
- _this7.currentSyncRequest = _this7.doSyncRequest(syncOptions, syncToken);
743
- }
744
- data = yield _this7.currentSyncRequest;
745
- } catch (e) {
746
- var abort = yield _this7.onSyncError(e);
747
- if (abort) return;
748
- continue;
749
- } finally {
750
- _this7.currentSyncRequest = undefined;
708
+ async doSync(syncOptions) {
709
+ while (this.running) {
710
+ const syncToken = this.client.store.getSyncToken();
711
+ let data;
712
+ try {
713
+ if (!this.currentSyncRequest) {
714
+ this.currentSyncRequest = this.doSyncRequest(syncOptions, syncToken);
751
715
  }
716
+ data = await this.currentSyncRequest;
717
+ } catch (e) {
718
+ const abort = await this.onSyncError(e);
719
+ if (abort) return;
720
+ continue;
721
+ } finally {
722
+ this.currentSyncRequest = undefined;
723
+ }
752
724
 
753
- // set the sync token NOW *before* processing the events. We do this so
754
- // if something barfs on an event we can skip it rather than constantly
755
- // polling with the same token.
756
- _this7.client.store.setSyncToken(data.next_batch);
757
-
758
- // Reset after a successful sync
759
- _this7.failedSyncCount = 0;
760
- var syncEventData = {
761
- oldSyncToken: syncToken !== null && syncToken !== void 0 ? syncToken : undefined,
762
- nextSyncToken: data.next_batch,
763
- catchingUp: _this7.catchingUp
764
- };
765
- try {
766
- yield _this7.processSyncResponse(syncEventData, data);
767
- } catch (e) {
768
- // log the exception with stack if we have it, else fall back
769
- // to the plain description
770
- _this7.syncOpts.logger.error("Caught /sync error", e);
771
-
772
- // Emit the exception for client handling
773
- _this7.client.emit(ClientEvent.SyncUnexpectedError, e);
774
- }
725
+ // set the sync token NOW *before* processing the events. We do this so
726
+ // if something barfs on an event we can skip it rather than constantly
727
+ // polling with the same token.
728
+ this.client.store.setSyncToken(data.next_batch);
729
+
730
+ // Reset after a successful sync
731
+ this.failedSyncCount = 0;
732
+ const syncEventData = {
733
+ oldSyncToken: syncToken ?? undefined,
734
+ nextSyncToken: data.next_batch,
735
+ catchingUp: this.catchingUp
736
+ };
737
+ try {
738
+ await this.processSyncResponse(syncEventData, data);
739
+ } catch (e) {
740
+ // log the exception with stack if we have it, else fall back
741
+ // to the plain description
742
+ this.syncOpts.logger.error("Caught /sync error", e);
775
743
 
776
- // Persist after processing as `unsigned` may get mutated
777
- // with an `org.matrix.msc4023.thread_id`
778
- yield _this7.client.store.setSyncData(data);
744
+ // Emit the exception for client handling
745
+ this.client.emit(ClientEvent.SyncUnexpectedError, e);
746
+ }
779
747
 
780
- // update this as it may have changed
781
- syncEventData.catchingUp = _this7.catchingUp;
748
+ // Persist after processing as `unsigned` may get mutated
749
+ // with an `org.matrix.msc4023.thread_id`
750
+ await this.client.store.setSyncData(data);
782
751
 
783
- // emit synced events
784
- if (!syncOptions.hasSyncedBefore) {
785
- _this7.updateSyncState(SyncState.Prepared, syncEventData);
786
- syncOptions.hasSyncedBefore = true;
787
- }
752
+ // update this as it may have changed
753
+ syncEventData.catchingUp = this.catchingUp;
788
754
 
789
- // tell the crypto module to do its processing. It may block (to do a
790
- // /keys/changes request).
791
- if (_this7.syncOpts.cryptoCallbacks) {
792
- yield _this7.syncOpts.cryptoCallbacks.onSyncCompleted(syncEventData);
793
- }
755
+ // emit synced events
756
+ if (!syncOptions.hasSyncedBefore) {
757
+ this.updateSyncState(SyncState.Prepared, syncEventData);
758
+ syncOptions.hasSyncedBefore = true;
759
+ }
794
760
 
795
- // keep emitting SYNCING -> SYNCING for clients who want to do bulk updates
796
- _this7.updateSyncState(SyncState.Syncing, syncEventData);
797
- if (_this7.client.store.wantsSave()) {
798
- // tell databases that everything is now in a consistent state and can be saved.
799
- yield _this7.client.store.save();
800
- }
761
+ // tell the crypto module to do its processing. It may block (to do a
762
+ // /keys/changes request).
763
+ if (this.syncOpts.cryptoCallbacks) {
764
+ this.syncOpts.cryptoCallbacks.onSyncCompleted(syncEventData);
801
765
  }
802
- if (!_this7.running) {
803
- _this7.syncOpts.logger.debug("Sync no longer running: exiting.");
804
- if (_this7.connectionReturnedResolvers) {
805
- _this7.connectionReturnedResolvers.reject();
806
- _this7.connectionReturnedResolvers = undefined;
807
- }
808
- _this7.updateSyncState(SyncState.Stopped);
766
+
767
+ // keep emitting SYNCING -> SYNCING for clients who want to do bulk updates
768
+ this.updateSyncState(SyncState.Syncing, syncEventData);
769
+ if (this.client.store.wantsSave()) {
770
+ // tell databases that everything is now in a consistent state and can be saved.
771
+ await this.client.store.save();
809
772
  }
810
- })();
773
+ }
774
+ if (!this.running) {
775
+ this.syncOpts.logger.debug("Sync no longer running: exiting.");
776
+ if (this.connectionReturnedResolvers) {
777
+ this.connectionReturnedResolvers.reject();
778
+ this.connectionReturnedResolvers = undefined;
779
+ }
780
+ this.updateSyncState(SyncState.Stopped);
781
+ }
811
782
  }
812
783
  doSyncRequest(syncOptions, syncToken) {
813
- var _this$abortController3;
814
- var qps = this.getSyncParams(syncOptions, syncToken);
784
+ const qps = this.getSyncParams(syncOptions, syncToken);
815
785
  return this.client.http.authedRequest(Method.Get, "/sync", qps, undefined, {
816
786
  localTimeoutMs: qps.timeout + BUFFER_PERIOD_MS,
817
- abortSignal: (_this$abortController3 = this.abortController) === null || _this$abortController3 === void 0 ? void 0 : _this$abortController3.signal
787
+ abortSignal: this.abortController?.signal
818
788
  });
819
789
  }
820
790
  getSyncParams(syncOptions, syncToken) {
821
- var timeout = this.opts.pollTimeout;
791
+ let timeout = this.opts.pollTimeout;
822
792
  if (this.getSyncState() !== SyncState.Syncing || this.catchingUp) {
823
793
  // unless we are happily syncing already, we want the server to return
824
794
  // as quickly as possible, even if there are no events queued. This
@@ -834,11 +804,11 @@ export class SyncApi {
834
804
  this.catchingUp = true;
835
805
  timeout = 0;
836
806
  }
837
- var filter = syncOptions.filter;
807
+ let filter = syncOptions.filter;
838
808
  if (this.client.isGuest() && !filter) {
839
809
  filter = this.getGuestFilter();
840
810
  }
841
- var qps = {
811
+ const qps = {
842
812
  filter,
843
813
  timeout,
844
814
  "org.matrix.msc4222.use_state_after": true
@@ -873,51 +843,48 @@ export class SyncApi {
873
843
  setPresence(presence) {
874
844
  this.presence = presence;
875
845
  }
876
- onSyncError(err) {
877
- var _this8 = this;
878
- return _asyncToGenerator(function* () {
879
- if (!_this8.running) {
880
- _this8.syncOpts.logger.debug("Sync no longer running: exiting");
881
- if (_this8.connectionReturnedResolvers) {
882
- _this8.connectionReturnedResolvers.reject();
883
- _this8.connectionReturnedResolvers = undefined;
884
- }
885
- _this8.updateSyncState(SyncState.Stopped);
886
- return true; // abort
887
- }
888
- _this8.syncOpts.logger.error("/sync error %s", err);
889
- if (_this8.shouldAbortSync(err)) {
890
- return true; // abort
846
+ async onSyncError(err) {
847
+ if (!this.running) {
848
+ this.syncOpts.logger.debug("Sync no longer running: exiting");
849
+ if (this.connectionReturnedResolvers) {
850
+ this.connectionReturnedResolvers.reject();
851
+ this.connectionReturnedResolvers = undefined;
891
852
  }
892
- _this8.failedSyncCount++;
893
- _this8.syncOpts.logger.debug("Number of consecutive failed sync requests:", _this8.failedSyncCount);
894
- _this8.syncOpts.logger.debug("Starting keep-alive");
895
- // Note that we do *not* mark the sync connection as
896
- // lost yet: we only do this if a keepalive poke
897
- // fails, since long lived HTTP connections will
898
- // go away sometimes and we shouldn't treat this as
899
- // erroneous. We set the state to 'reconnecting'
900
- // instead, so that clients can observe this state
901
- // if they wish.
902
- var keepAlivePromise = _this8.startKeepAlives();
903
- _this8.currentSyncRequest = undefined;
904
- // Transition from RECONNECTING to ERROR after a given number of failed syncs
905
- _this8.updateSyncState(_this8.failedSyncCount >= FAILED_SYNC_ERROR_THRESHOLD ? SyncState.Error : SyncState.Reconnecting, {
906
- error: err
853
+ this.updateSyncState(SyncState.Stopped);
854
+ return true; // abort
855
+ }
856
+ this.syncOpts.logger.error("/sync error %s", err);
857
+ if (this.shouldAbortSync(err)) {
858
+ return true; // abort
859
+ }
860
+ this.failedSyncCount++;
861
+ this.syncOpts.logger.debug("Number of consecutive failed sync requests:", this.failedSyncCount);
862
+ this.syncOpts.logger.debug("Starting keep-alive");
863
+ // Note that we do *not* mark the sync connection as
864
+ // lost yet: we only do this if a keepalive poke
865
+ // fails, since long lived HTTP connections will
866
+ // go away sometimes and we shouldn't treat this as
867
+ // erroneous. We set the state to 'reconnecting'
868
+ // instead, so that clients can observe this state
869
+ // if they wish.
870
+ const keepAlivePromise = this.startKeepAlives();
871
+ this.currentSyncRequest = undefined;
872
+ // Transition from RECONNECTING to ERROR after a given number of failed syncs
873
+ this.updateSyncState(this.failedSyncCount >= FAILED_SYNC_ERROR_THRESHOLD ? SyncState.Error : SyncState.Reconnecting, {
874
+ error: err
875
+ });
876
+ const connDidFail = await keepAlivePromise;
877
+
878
+ // Only emit CATCHUP if we detected a connectivity error: if we didn't,
879
+ // it's quite likely the sync will fail again for the same reason and we
880
+ // want to stay in ERROR rather than keep flip-flopping between ERROR
881
+ // and CATCHUP.
882
+ if (connDidFail && this.getSyncState() === SyncState.Error) {
883
+ this.updateSyncState(SyncState.Catchup, {
884
+ catchingUp: true
907
885
  });
908
- var connDidFail = yield keepAlivePromise;
909
-
910
- // Only emit CATCHUP if we detected a connectivity error: if we didn't,
911
- // it's quite likely the sync will fail again for the same reason and we
912
- // want to stay in ERROR rather than keep flip-flopping between ERROR
913
- // and CATCHUP.
914
- if (connDidFail && _this8.getSyncState() === SyncState.Error) {
915
- _this8.updateSyncState(SyncState.Catchup, {
916
- catchingUp: true
917
- });
918
- }
919
- return false;
920
- })();
886
+ }
887
+ return false;
921
888
  }
922
889
 
923
890
  /**
@@ -927,483 +894,450 @@ export class SyncApi {
927
894
  * @param syncEventData - Object containing sync tokens associated with this sync
928
895
  * @param data - The response from /sync
929
896
  */
930
- processSyncResponse(syncEventData, data) {
931
- var _this9 = this;
932
- return _asyncToGenerator(function* () {
933
- var _data$presence, _data$account_data, _data$users, _this9$syncOpts$crypt, _data$device_unused_f;
934
- var client = _this9.client;
935
-
936
- // data looks like:
937
- // {
938
- // next_batch: $token,
939
- // presence: { events: [] },
940
- // account_data: { events: [] },
941
- // device_lists: { changed: ["@user:server", ... ]},
942
- // to_device: { events: [] },
943
- // device_one_time_keys_count: { signed_curve25519: 42 },
944
- // rooms: {
945
- // invite: {
946
- // $roomid: {
947
- // invite_state: { events: [] }
948
- // }
949
- // },
950
- // join: {
951
- // $roomid: {
952
- // state: { events: [] },
953
- // timeline: { events: [], prev_batch: $token, limited: true },
954
- // ephemeral: { events: [] },
955
- // summary: {
956
- // m.heroes: [ $user_id ],
957
- // m.joined_member_count: $count,
958
- // m.invited_member_count: $count
959
- // },
960
- // account_data: { events: [] },
961
- // unread_notifications: {
962
- // highlight_count: 0,
963
- // notification_count: 0,
964
- // }
965
- // "org.matrix.msc4222.state_after": { events: [] }, // only if "org.matrix.msc4222.use_state_after" is true
966
- // msc4354_sticky: { events: [] }, // only if "org.matrix.msc4354.sticky" is true
967
- // }
968
- // },
969
- // leave: {
970
- // $roomid: {
971
- // state: { events: [] },
972
- // timeline: { events: [], prev_batch: $token }
973
- // }
974
- // }
975
- // }
976
- // }
977
-
978
- // TODO-arch:
979
- // - Each event we pass through needs to be emitted via 'event', can we
980
- // do this in one place?
981
- // - The isBrandNewRoom boilerplate is boilerplatey.
897
+ async processSyncResponse(syncEventData, data) {
898
+ const client = this.client;
899
+
900
+ // data looks like:
901
+ // {
902
+ // next_batch: $token,
903
+ // presence: { events: [] },
904
+ // account_data: { events: [] },
905
+ // device_lists: { changed: ["@user:server", ... ]},
906
+ // to_device: { events: [] },
907
+ // device_one_time_keys_count: { signed_curve25519: 42 },
908
+ // rooms: {
909
+ // invite: {
910
+ // $roomid: {
911
+ // invite_state: { events: [] }
912
+ // }
913
+ // },
914
+ // join: {
915
+ // $roomid: {
916
+ // state: { events: [] },
917
+ // timeline: { events: [], prev_batch: $token, limited: true },
918
+ // ephemeral: { events: [] },
919
+ // summary: {
920
+ // m.heroes: [ $user_id ],
921
+ // m.joined_member_count: $count,
922
+ // m.invited_member_count: $count
923
+ // },
924
+ // account_data: { events: [] },
925
+ // unread_notifications: {
926
+ // highlight_count: 0,
927
+ // notification_count: 0,
928
+ // }
929
+ // "org.matrix.msc4222.state_after": { events: [] }, // only if "org.matrix.msc4222.use_state_after" is true
930
+ // msc4354_sticky: { events: [] }, // only if "org.matrix.msc4354.sticky" is true
931
+ // }
932
+ // },
933
+ // leave: {
934
+ // $roomid: {
935
+ // state: { events: [] },
936
+ // timeline: { events: [], prev_batch: $token }
937
+ // }
938
+ // }
939
+ // }
940
+ // }
941
+
942
+ // TODO-arch:
943
+ // - Each event we pass through needs to be emitted via 'event', can we
944
+ // do this in one place?
945
+ // - The isBrandNewRoom boilerplate is boilerplatey.
946
+
947
+ // handle presence events (User objects)
948
+ if (Array.isArray(data.presence?.events)) {
949
+ data.presence.events.filter(noUnsafeEventProps).map(client.getEventMapper()).forEach(function (presenceEvent) {
950
+ let user = client.store.getUser(presenceEvent.getSender());
951
+ if (user) {
952
+ user.setPresenceEvent(presenceEvent);
953
+ } else {
954
+ user = User.createUser(presenceEvent.getSender(), client);
955
+ user.setPresenceEvent(presenceEvent);
956
+ client.store.storeUser(user);
957
+ }
958
+ client.emit(ClientEvent.Event, presenceEvent);
959
+ });
960
+ }
982
961
 
983
- // handle presence events (User objects)
984
- if (Array.isArray((_data$presence = data.presence) === null || _data$presence === void 0 ? void 0 : _data$presence.events)) {
985
- data.presence.events.filter(noUnsafeEventProps).map(client.getEventMapper()).forEach(function (presenceEvent) {
986
- var user = client.store.getUser(presenceEvent.getSender());
987
- if (user) {
988
- user.setPresenceEvent(presenceEvent);
989
- } else {
990
- user = User.createUser(presenceEvent.getSender(), client);
991
- user.setPresenceEvent(presenceEvent);
992
- client.store.storeUser(user);
993
- }
994
- client.emit(ClientEvent.Event, presenceEvent);
995
- });
962
+ // handle non-room account_data
963
+ if (Array.isArray(data.account_data?.events)) {
964
+ const events = data.account_data.events.filter(noUnsafeEventProps).map(client.getEventMapper());
965
+ const prevEventsMap = events.reduce((m, c) => {
966
+ m[c.getType()] = client.store.getAccountData(c.getType());
967
+ return m;
968
+ }, {});
969
+ client.store.storeAccountDataEvents(events);
970
+ events.forEach(function (accountDataEvent) {
971
+ // Honour push rules that come down the sync stream but also
972
+ // honour push rules that were previously cached. Base rules
973
+ // will be updated when we receive push rules via getPushRules
974
+ // (see sync) before syncing over the network.
975
+ if (accountDataEvent.getType() === EventType.PushRules) {
976
+ const rules = accountDataEvent.getContent();
977
+ client.setPushRules(rules);
978
+ }
979
+ const prevEvent = prevEventsMap[accountDataEvent.getType()];
980
+ client.emit(ClientEvent.AccountData, accountDataEvent, prevEvent);
981
+ return accountDataEvent;
982
+ });
983
+ }
984
+
985
+ // handle user profile updates (MSC4429)
986
+ const userUpdate = data["users"] ?? data["org.matrix.msc4429.users"];
987
+ if (typeof userUpdate === "object" && userUpdate !== null) {
988
+ const usersToRemove = [];
989
+ const profilesToAmend = new Map();
990
+ for (const [userId, userData] of Object.entries(userUpdate)) {
991
+ logger.info(`Storing user profile ${userId}`, userData);
992
+ if (userData.profile_updates) {
993
+ const existingProfile = await client.store.getUserProfile(userId);
994
+ profilesToAmend.set(userId, _objectSpread(_objectSpread({}, existingProfile), userData.profile_updates));
995
+ } else if (userData.profile_updates === null) {
996
+ usersToRemove.push(userId);
997
+ }
998
+ }
999
+ if (usersToRemove.length) {
1000
+ await client.store.removeUserProfiles(usersToRemove);
1001
+ }
1002
+ if (profilesToAmend.size) {
1003
+ await client.store.storeUserProfiles(profilesToAmend);
996
1004
  }
997
1005
 
998
- // handle non-room account_data
999
- if (Array.isArray((_data$account_data = data.account_data) === null || _data$account_data === void 0 ? void 0 : _data$account_data.events)) {
1000
- var events = data.account_data.events.filter(noUnsafeEventProps).map(client.getEventMapper());
1001
- var prevEventsMap = events.reduce((m, c) => {
1002
- m[c.getType()] = client.store.getAccountData(c.getType());
1003
- return m;
1004
- }, {});
1005
- client.store.storeAccountDataEvents(events);
1006
- events.forEach(function (accountDataEvent) {
1007
- // Honour push rules that come down the sync stream but also
1008
- // honour push rules that were previously cached. Base rules
1009
- // will be updated when we receive push rules via getPushRules
1010
- // (see sync) before syncing over the network.
1011
- if (accountDataEvent.getType() === EventType.PushRules) {
1012
- var rules = accountDataEvent.getContent();
1013
- client.setPushRules(rules);
1014
- }
1015
- var prevEvent = prevEventsMap[accountDataEvent.getType()];
1016
- client.emit(ClientEvent.AccountData, accountDataEvent, prevEvent);
1017
- return accountDataEvent;
1018
- });
1006
+ // emit after we've update the store so that clients can get the updated profile if they want to
1007
+ for (const [userId, userData] of Object.entries(userUpdate)) {
1008
+ client.emit(ClientEvent.UserProfileUpdate, userId, userData.profile_updates ?? null);
1019
1009
  }
1010
+ }
1020
1011
 
1021
- // handle user profile updates (MSC4429)
1022
- var userUpdate = (_data$users = data["users"]) !== null && _data$users !== void 0 ? _data$users : data["org.matrix.msc4429.users"];
1023
- if (typeof userUpdate === "object" && userUpdate !== null) {
1024
- var usersToRemove = [];
1025
- var profilesToAmend = new Map();
1026
- for (var _ref0 of Object.entries(userUpdate)) {
1027
- var _ref9 = _slicedToArray(_ref0, 2);
1028
- var userId = _ref9[0];
1029
- var userData = _ref9[1];
1030
- logger.info("Storing user profile ".concat(userId), userData);
1031
- if (userData.profile_updates) {
1032
- client.emit(ClientEvent.UserProfileUpdate, userId, userData.profile_updates);
1033
- var existingProfile = yield client.store.getUserProfile(userId);
1034
- profilesToAmend.set(userId, _objectSpread(_objectSpread({}, existingProfile), userData.profile_updates));
1035
- } else if (userData.profile_updates === null) {
1036
- usersToRemove.push(userId);
1037
- }
1038
- }
1039
- if (usersToRemove.length) {
1040
- yield client.store.removeUserProfiles(usersToRemove);
1041
- }
1042
- if (profilesToAmend.size) {
1043
- yield client.store.storeUserProfiles(profilesToAmend);
1044
- }
1012
+ // handle to-device events
1013
+ if (data.to_device && Array.isArray(data.to_device.events) && data.to_device.events.length > 0) {
1014
+ const toDeviceMessages = data.to_device.events.filter(noUnsafeEventProps);
1015
+ let receivedToDeviceMessages;
1016
+ if (this.syncOpts.cryptoCallbacks) {
1017
+ receivedToDeviceMessages = await this.syncOpts.cryptoCallbacks.preprocessToDeviceMessages(toDeviceMessages);
1018
+ } else {
1019
+ // Crypto is not enabled, so we just return the events.
1020
+ receivedToDeviceMessages = toDeviceMessages.map(rawEvent => ({
1021
+ message: rawEvent,
1022
+ encryptionInfo: null
1023
+ }));
1045
1024
  }
1025
+ processToDeviceMessages(receivedToDeviceMessages, client);
1026
+ } else {
1027
+ // no more to-device events: we can stop polling with a short timeout.
1028
+ this.catchingUp = false;
1029
+ }
1046
1030
 
1047
- // handle to-device events
1048
- if (data.to_device && Array.isArray(data.to_device.events) && data.to_device.events.length > 0) {
1049
- var toDeviceMessages = data.to_device.events.filter(noUnsafeEventProps);
1050
- var receivedToDeviceMessages;
1051
- if (_this9.syncOpts.cryptoCallbacks) {
1052
- receivedToDeviceMessages = yield _this9.syncOpts.cryptoCallbacks.preprocessToDeviceMessages(toDeviceMessages);
1053
- } else {
1054
- receivedToDeviceMessages = toDeviceMessages.map(rawEvent => (
1055
- // Crypto is not enabled, so we just return the events.
1056
- {
1057
- message: rawEvent,
1058
- encryptionInfo: null
1059
- }));
1060
- }
1061
- processToDeviceMessages(receivedToDeviceMessages, client);
1031
+ // the returned json structure is a bit crap, so make it into a
1032
+ // nicer form (array) after applying sanity to make sure we don't fail
1033
+ // on missing keys (on the off chance)
1034
+ let inviteRooms = [];
1035
+ let joinRooms = [];
1036
+ let leaveRooms = [];
1037
+ let knockRooms = [];
1038
+ if (data.rooms) {
1039
+ if (data.rooms.invite) {
1040
+ inviteRooms = this.mapSyncResponseToRoomArray(data.rooms.invite);
1041
+ }
1042
+ if (data.rooms.join) {
1043
+ joinRooms = this.mapSyncResponseToRoomArray(data.rooms.join);
1044
+ }
1045
+ if (data.rooms.leave) {
1046
+ leaveRooms = this.mapSyncResponseToRoomArray(data.rooms.leave);
1047
+ }
1048
+ if (data.rooms.knock) {
1049
+ knockRooms = this.mapSyncResponseToRoomArray(data.rooms.knock);
1050
+ }
1051
+ }
1052
+ this.notifEvents = [];
1053
+
1054
+ // Handle invites
1055
+ await Promise.all(inviteRooms.map(async inviteObj => {
1056
+ const room = inviteObj.room;
1057
+ const stateEvents = this.mapSyncEventsFormat(inviteObj.invite_state, room);
1058
+ await this.injectRoomEvents(room, stateEvents, undefined);
1059
+ if (inviteObj.isBrandNewRoom) {
1060
+ room.recalculate();
1061
+ client.store.storeRoom(room);
1062
+ client.emit(ClientEvent.Room, room);
1062
1063
  } else {
1063
- // no more to-device events: we can stop polling with a short timeout.
1064
- _this9.catchingUp = false;
1064
+ // Update room state for invite->reject->invite cycles
1065
+ room.recalculate();
1065
1066
  }
1067
+ stateEvents.forEach(function (e) {
1068
+ client.emit(ClientEvent.Event, e);
1069
+ });
1070
+ }));
1066
1071
 
1067
- // the returned json structure is a bit crap, so make it into a
1068
- // nicer form (array) after applying sanity to make sure we don't fail
1069
- // on missing keys (on the off chance)
1070
- var inviteRooms = [];
1071
- var joinRooms = [];
1072
- var leaveRooms = [];
1073
- var knockRooms = [];
1074
- if (data.rooms) {
1075
- if (data.rooms.invite) {
1076
- inviteRooms = _this9.mapSyncResponseToRoomArray(data.rooms.invite);
1072
+ // Handle joins
1073
+ await Promise.all(joinRooms.map(async joinObj => {
1074
+ const room = joinObj.room;
1075
+ const stateEvents = this.mapSyncEventsFormat(joinObj.state, room);
1076
+ const stateAfterEvents = this.mapSyncEventsFormat(joinObj["org.matrix.msc4222.state_after"], room);
1077
+ // Prevent events from being decrypted ahead of time
1078
+ // this helps large account to speed up faster
1079
+ // room::decryptCriticalEvent is in charge of decrypting all the events
1080
+ // required for a client to function properly
1081
+ const timelineEvents = this.mapSyncEventsFormat(joinObj.timeline, room, false);
1082
+ const ephemeralEvents = this.mapSyncEventsFormat(joinObj.ephemeral);
1083
+ const accountDataEvents = this.mapSyncEventsFormat(joinObj.account_data);
1084
+ const stickyEvents = this.mapSyncEventsFormat(joinObj.msc4354_sticky);
1085
+
1086
+ // If state_after is present, this is the events that form the state at the end of the timeline block and
1087
+ // regular timeline events do *not* count towards state. If it's not present, then the state is formed by
1088
+ // the state events plus the timeline events. Note mapSyncEventsFormat returns an empty array if the field
1089
+ // is absent so we explicitly check the field on the original object.
1090
+ const eventsFormingFinalState = joinObj["org.matrix.msc4222.state_after"] ? stateAfterEvents : stateEvents.concat(timelineEvents);
1091
+ const encrypted = this.isRoomEncrypted(room, eventsFormingFinalState);
1092
+ // We store the server-provided value first so it's correct when any of the events fire.
1093
+ if (joinObj.unread_notifications) {
1094
+ /**
1095
+ * We track unread notifications ourselves in encrypted rooms, so don't
1096
+ * bother setting it here. We trust our calculations better than the
1097
+ * server's for this case, and therefore will assume that our non-zero
1098
+ * count is accurate.
1099
+ * XXX: this is known faulty as the push rule for `.m.room.encrypted` may be disabled so server
1100
+ * may issue notification counts of 0 which we wrongly trust.
1101
+ * https://github.com/matrix-org/matrix-spec-proposals/pull/2654 would fix this
1102
+ *
1103
+ * @see import("./client").fixNotificationCountOnDecryption
1104
+ */
1105
+ if (!encrypted || joinObj.unread_notifications.notification_count === 0) {
1106
+ // In an encrypted room, if the room has notifications enabled then it's typical for
1107
+ // the server to flag all new messages as notifying. However, some push rules calculate
1108
+ // events as ignored based on their event contents (e.g. ignoring msgtype=m.notice messages)
1109
+ // so we want to calculate this figure on the client in all cases.
1110
+ room.setUnreadNotificationCount(NotificationCountType.Total, joinObj.unread_notifications.notification_count ?? 0);
1077
1111
  }
1078
- if (data.rooms.join) {
1079
- joinRooms = _this9.mapSyncResponseToRoomArray(data.rooms.join);
1080
- }
1081
- if (data.rooms.leave) {
1082
- leaveRooms = _this9.mapSyncResponseToRoomArray(data.rooms.leave);
1083
- }
1084
- if (data.rooms.knock) {
1085
- knockRooms = _this9.mapSyncResponseToRoomArray(data.rooms.knock);
1112
+ if (!encrypted || room.getUnreadNotificationCount(NotificationCountType.Highlight) <= 0) {
1113
+ // If the locally stored highlight count is zero, use the server provided value.
1114
+ room.setUnreadNotificationCount(NotificationCountType.Highlight, joinObj.unread_notifications.highlight_count ?? 0);
1086
1115
  }
1087
1116
  }
1088
- _this9.notifEvents = [];
1089
-
1090
- // Handle invites
1091
- yield Promise.all(inviteRooms.map(/*#__PURE__*/function () {
1092
- var _ref1 = _asyncToGenerator(function* (inviteObj) {
1093
- var room = inviteObj.room;
1094
- var stateEvents = _this9.mapSyncEventsFormat(inviteObj.invite_state, room);
1095
- yield _this9.injectRoomEvents(room, stateEvents, undefined);
1096
- if (inviteObj.isBrandNewRoom) {
1097
- room.recalculate();
1098
- client.store.storeRoom(room);
1099
- client.emit(ClientEvent.Room, room);
1100
- } else {
1101
- // Update room state for invite->reject->invite cycles
1102
- room.recalculate();
1103
- }
1104
- stateEvents.forEach(function (e) {
1105
- client.emit(ClientEvent.Event, e);
1106
- });
1107
- });
1108
- return function (_x3) {
1109
- return _ref1.apply(this, arguments);
1110
- };
1111
- }()));
1112
-
1113
- // Handle joins
1114
- yield Promise.all(joinRooms.map(/*#__PURE__*/function () {
1115
- var _ref10 = _asyncToGenerator(function* (joinObj) {
1116
- var _joinObj$UNREAD_THREA;
1117
- var room = joinObj.room;
1118
- var stateEvents = _this9.mapSyncEventsFormat(joinObj.state, room);
1119
- var stateAfterEvents = _this9.mapSyncEventsFormat(joinObj["org.matrix.msc4222.state_after"], room);
1120
- // Prevent events from being decrypted ahead of time
1121
- // this helps large account to speed up faster
1122
- // room::decryptCriticalEvent is in charge of decrypting all the events
1123
- // required for a client to function properly
1124
- var timelineEvents = _this9.mapSyncEventsFormat(joinObj.timeline, room, false);
1125
- var ephemeralEvents = _this9.mapSyncEventsFormat(joinObj.ephemeral);
1126
- var accountDataEvents = _this9.mapSyncEventsFormat(joinObj.account_data);
1127
- var stickyEvents = _this9.mapSyncEventsFormat(joinObj.msc4354_sticky);
1128
-
1129
- // If state_after is present, this is the events that form the state at the end of the timeline block and
1130
- // regular timeline events do *not* count towards state. If it's not present, then the state is formed by
1131
- // the state events plus the timeline events. Note mapSyncEventsFormat returns an empty array if the field
1132
- // is absent so we explicitly check the field on the original object.
1133
- var eventsFormingFinalState = joinObj["org.matrix.msc4222.state_after"] ? stateAfterEvents : stateEvents.concat(timelineEvents);
1134
- var encrypted = _this9.isRoomEncrypted(room, eventsFormingFinalState);
1135
- // We store the server-provided value first so it's correct when any of the events fire.
1136
- if (joinObj.unread_notifications) {
1137
- /**
1138
- * We track unread notifications ourselves in encrypted rooms, so don't
1139
- * bother setting it here. We trust our calculations better than the
1140
- * server's for this case, and therefore will assume that our non-zero
1141
- * count is accurate.
1142
- * XXX: this is known faulty as the push rule for `.m.room.encrypted` may be disabled so server
1143
- * may issue notification counts of 0 which we wrongly trust.
1144
- * https://github.com/matrix-org/matrix-spec-proposals/pull/2654 would fix this
1145
- *
1146
- * @see import("./client").fixNotificationCountOnDecryption
1147
- */
1148
- if (!encrypted || joinObj.unread_notifications.notification_count === 0) {
1149
- var _joinObj$unread_notif;
1150
- // In an encrypted room, if the room has notifications enabled then it's typical for
1151
- // the server to flag all new messages as notifying. However, some push rules calculate
1152
- // events as ignored based on their event contents (e.g. ignoring msgtype=m.notice messages)
1153
- // so we want to calculate this figure on the client in all cases.
1154
- room.setUnreadNotificationCount(NotificationCountType.Total, (_joinObj$unread_notif = joinObj.unread_notifications.notification_count) !== null && _joinObj$unread_notif !== void 0 ? _joinObj$unread_notif : 0);
1155
- }
1156
- if (!encrypted || room.getUnreadNotificationCount(NotificationCountType.Highlight) <= 0) {
1157
- var _joinObj$unread_notif2;
1158
- // If the locally stored highlight count is zero, use the server provided value.
1159
- room.setUnreadNotificationCount(NotificationCountType.Highlight, (_joinObj$unread_notif2 = joinObj.unread_notifications.highlight_count) !== null && _joinObj$unread_notif2 !== void 0 ? _joinObj$unread_notif2 : 0);
1160
- }
1161
- }
1162
- var unreadThreadNotifications = (_joinObj$UNREAD_THREA = joinObj[UNREAD_THREAD_NOTIFICATIONS.name]) !== null && _joinObj$UNREAD_THREA !== void 0 ? _joinObj$UNREAD_THREA : joinObj[UNREAD_THREAD_NOTIFICATIONS.altName];
1163
- if (unreadThreadNotifications) {
1164
- // This mirrors the logic above for rooms: take the *total* notification count from
1165
- // the server for unencrypted rooms or is it's zero. Any threads not present in this
1166
- // object implicitly have zero notifications, so start by clearing the total counts
1167
- // for all such threads.
1168
- room.resetThreadUnreadNotificationCountFromSync(Object.keys(unreadThreadNotifications));
1169
- for (var _ref13 of Object.entries(unreadThreadNotifications)) {
1170
- var _ref12 = _slicedToArray(_ref13, 2);
1171
- var threadId = _ref12[0];
1172
- var unreadNotification = _ref12[1];
1173
- if (!encrypted || unreadNotification.notification_count === 0) {
1174
- var _unreadNotification$n;
1175
- room.setThreadUnreadNotificationCount(threadId, NotificationCountType.Total, (_unreadNotification$n = unreadNotification.notification_count) !== null && _unreadNotification$n !== void 0 ? _unreadNotification$n : 0);
1176
- }
1177
- var hasNoNotifications = room.getThreadUnreadNotificationCount(threadId, NotificationCountType.Highlight) <= 0;
1178
- if (!encrypted || encrypted && hasNoNotifications) {
1179
- var _unreadNotification$h;
1180
- room.setThreadUnreadNotificationCount(threadId, NotificationCountType.Highlight, (_unreadNotification$h = unreadNotification.highlight_count) !== null && _unreadNotification$h !== void 0 ? _unreadNotification$h : 0);
1181
- }
1182
- }
1183
- } else {
1184
- room.resetThreadUnreadNotificationCountFromSync();
1117
+ const unreadThreadNotifications = joinObj[UNREAD_THREAD_NOTIFICATIONS.name] ?? joinObj[UNREAD_THREAD_NOTIFICATIONS.altName];
1118
+ if (unreadThreadNotifications) {
1119
+ // This mirrors the logic above for rooms: take the *total* notification count from
1120
+ // the server for unencrypted rooms or is it's zero. Any threads not present in this
1121
+ // object implicitly have zero notifications, so start by clearing the total counts
1122
+ // for all such threads.
1123
+ room.resetThreadUnreadNotificationCountFromSync(Object.keys(unreadThreadNotifications));
1124
+ for (const [threadId, unreadNotification] of Object.entries(unreadThreadNotifications)) {
1125
+ if (!encrypted || unreadNotification.notification_count === 0) {
1126
+ room.setThreadUnreadNotificationCount(threadId, NotificationCountType.Total, unreadNotification.notification_count ?? 0);
1185
1127
  }
1186
- joinObj.timeline = joinObj.timeline || {};
1187
- if (joinObj.isBrandNewRoom) {
1188
- // set the back-pagination token. Do this *before* adding any
1189
- // events so that clients can start back-paginating.
1190
- if (joinObj.timeline.prev_batch !== null) {
1191
- room.getLiveTimeline().setPaginationToken(joinObj.timeline.prev_batch, EventTimeline.BACKWARDS);
1192
- }
1193
- } else if (joinObj.timeline.limited) {
1194
- var limited = true;
1195
-
1196
- // we've got a limited sync, so we *probably* have a gap in the
1197
- // timeline, so should reset. But we might have been peeking or
1198
- // paginating and already have some of the events, in which
1199
- // case we just want to append any subsequent events to the end
1200
- // of the existing timeline.
1201
- //
1202
- // This is particularly important in the case that we already have
1203
- // *all* of the events in the timeline - in that case, if we reset
1204
- // the timeline, we'll end up with an entirely empty timeline,
1205
- // which we'll try to paginate but not get any new events (which
1206
- // will stop us linking the empty timeline into the chain).
1207
- //
1208
- for (var i = timelineEvents.length - 1; i >= 0; i--) {
1209
- var eventId = timelineEvents[i].getId();
1210
- if (room.getTimelineForEvent(eventId)) {
1211
- _this9.syncOpts.logger.debug("Already have event ".concat(eventId, " in limited sync - not resetting"));
1212
- limited = false;
1213
-
1214
- // we might still be missing some of the events before i;
1215
- // we don't want to be adding them to the end of the
1216
- // timeline because that would put them out of order.
1217
- timelineEvents.splice(0, i);
1218
-
1219
- // XXX: there's a problem here if the skipped part of the
1220
- // timeline modifies the state set in stateEvents, because
1221
- // we'll end up using the state from stateEvents rather
1222
- // than the later state from timelineEvents. We probably
1223
- // need to wind stateEvents forward over the events we're
1224
- // skipping.
1225
-
1226
- break;
1227
- }
1228
- }
1229
- if (limited) {
1230
- var _syncEventData$oldSyn;
1231
- room.resetLiveTimeline(joinObj.timeline.prev_batch, _this9.syncOpts.canResetEntireTimeline(room.roomId) ? null : (_syncEventData$oldSyn = syncEventData.oldSyncToken) !== null && _syncEventData$oldSyn !== void 0 ? _syncEventData$oldSyn : null);
1232
-
1233
- // We have to assume any gap in any timeline is
1234
- // reason to stop incrementally tracking notifications and
1235
- // reset the timeline.
1236
- client.resetNotifTimelineSet();
1237
- }
1128
+ const hasNoNotifications = room.getThreadUnreadNotificationCount(threadId, NotificationCountType.Highlight) <= 0;
1129
+ if (!encrypted || encrypted && hasNoNotifications) {
1130
+ room.setThreadUnreadNotificationCount(threadId, NotificationCountType.Highlight, unreadNotification.highlight_count ?? 0);
1238
1131
  }
1239
-
1240
- // process any crypto events *before* emitting the RoomStateEvent events. This
1241
- // avoids a race condition if the application tries to send a message after the
1242
- // state event is processed, but before crypto is enabled, which then causes the
1243
- // crypto layer to complain.
1244
-
1245
- if (_this9.syncOpts.cryptoCallbacks) {
1246
- for (var e of eventsFormingFinalState) {
1247
- if (e.isState() && e.getType() === EventType.RoomEncryption && e.getStateKey() === "") {
1248
- yield _this9.syncOpts.cryptoCallbacks.onCryptoEvent(room, e);
1249
- }
1250
- }
1132
+ }
1133
+ } else {
1134
+ room.resetThreadUnreadNotificationCountFromSync();
1135
+ }
1136
+ joinObj.timeline = joinObj.timeline || {};
1137
+ if (joinObj.isBrandNewRoom) {
1138
+ // set the back-pagination token. Do this *before* adding any
1139
+ // events so that clients can start back-paginating.
1140
+ if (joinObj.timeline.prev_batch !== null) {
1141
+ room.getLiveTimeline().setPaginationToken(joinObj.timeline.prev_batch, EventTimeline.BACKWARDS);
1142
+ }
1143
+ } else if (joinObj.timeline.limited) {
1144
+ let limited = true;
1145
+
1146
+ // we've got a limited sync, so we *probably* have a gap in the
1147
+ // timeline, so should reset. But we might have been peeking or
1148
+ // paginating and already have some of the events, in which
1149
+ // case we just want to append any subsequent events to the end
1150
+ // of the existing timeline.
1151
+ //
1152
+ // This is particularly important in the case that we already have
1153
+ // *all* of the events in the timeline - in that case, if we reset
1154
+ // the timeline, we'll end up with an entirely empty timeline,
1155
+ // which we'll try to paginate but not get any new events (which
1156
+ // will stop us linking the empty timeline into the chain).
1157
+ //
1158
+ for (let i = timelineEvents.length - 1; i >= 0; i--) {
1159
+ const eventId = timelineEvents[i].getId();
1160
+ if (room.getTimelineForEvent(eventId)) {
1161
+ this.syncOpts.logger.debug(`Already have event ${eventId} in limited sync - not resetting`);
1162
+ limited = false;
1163
+
1164
+ // we might still be missing some of the events before i;
1165
+ // we don't want to be adding them to the end of the
1166
+ // timeline because that would put them out of order.
1167
+ timelineEvents.splice(0, i);
1168
+
1169
+ // XXX: there's a problem here if the skipped part of the
1170
+ // timeline modifies the state set in stateEvents, because
1171
+ // we'll end up using the state from stateEvents rather
1172
+ // than the later state from timelineEvents. We probably
1173
+ // need to wind stateEvents forward over the events we're
1174
+ // skipping.
1175
+
1176
+ break;
1251
1177
  }
1178
+ }
1179
+ if (limited) {
1180
+ room.resetLiveTimeline(joinObj.timeline.prev_batch, this.syncOpts.canResetEntireTimeline(room.roomId) ? null : syncEventData.oldSyncToken ?? null);
1252
1181
 
1253
- // Proactively decrypt state events: normally we decrypt on demand, but for state
1254
- // events we need them immediately, so we handle them here. Specifically, consumers
1255
- // (e.g. Element Web) expect state events to be unencrypted upon receipt.
1256
- for (var ev of timelineEvents.filter(ev => ev.isState())) {
1257
- yield _this9.client.decryptEventIfNeeded(ev);
1258
- }
1259
- try {
1260
- if ("org.matrix.msc4222.state_after" in joinObj) {
1261
- yield _this9.injectRoomEvents(room, undefined, stateAfterEvents, timelineEvents, syncEventData.fromCache);
1262
- } else {
1263
- yield _this9.injectRoomEvents(room, stateEvents, undefined, timelineEvents, syncEventData.fromCache);
1264
- }
1265
- } catch (e) {
1266
- _this9.syncOpts.logger.error("Failed to process events on room ".concat(room.roomId, ":"), e);
1267
- }
1182
+ // We have to assume any gap in any timeline is
1183
+ // reason to stop incrementally tracking notifications and
1184
+ // reset the timeline.
1185
+ client.resetNotifTimelineSet();
1186
+ }
1187
+ }
1268
1188
 
1269
- // set summary after processing events,
1270
- // because it will trigger a name calculation
1271
- // which needs the room state to be up to date
1272
- if (joinObj.summary) {
1273
- room.setSummary(joinObj.summary);
1274
- }
1189
+ // process any crypto events *before* emitting the RoomStateEvent events. This
1190
+ // avoids a race condition if the application tries to send a message after the
1191
+ // state event is processed, but before crypto is enabled, which then causes the
1192
+ // crypto layer to complain.
1275
1193
 
1276
- // we deliberately don't add ephemeral events to the timeline
1277
- room.addEphemeralEvents(ephemeralEvents);
1278
-
1279
- // we deliberately don't add accountData to the timeline
1280
- room.addAccountData(accountDataEvents);
1281
-
1282
- // Sticky events primarily come via the `timeline` field, with the
1283
- // sticky info field marking them as sticky.
1284
- // If the sync is "gappy" (meaning it is skipping events to catch up) then
1285
- // sticky events will instead come down the sticky section.
1286
- // This ensures we collect sticky events from both places.
1287
- var stickyEventsAndStickyEventsFromTheTimeline = stickyEvents.concat(timelineEvents.filter(e => e.unstableStickyInfo !== undefined));
1288
- // Note: We calculate sticky events before emitting `.Room` as it's nice to have
1289
- // sticky events calculated and ready to go.
1290
- room._unstable_addStickyEvents(stickyEventsAndStickyEventsFromTheTimeline);
1291
- room.recalculate();
1292
- if (joinObj.isBrandNewRoom) {
1293
- client.store.storeRoom(room);
1294
- client.emit(ClientEvent.Room, room);
1295
- }
1296
- _this9.processEventsForNotifs(room, timelineEvents);
1297
- var emitEvent = e => client.emit(ClientEvent.Event, e);
1298
- // this fires a couple of times for some events. (eg state events are in the timeline and the state)
1299
- // should this get a sync section as an additional event emission param (e, syncSection))?
1300
- stateEvents.forEach(emitEvent);
1301
- timelineEvents.forEach(emitEvent);
1302
- ephemeralEvents.forEach(emitEvent);
1303
- accountDataEvents.forEach(emitEvent);
1304
- stickyEvents.filter(stickyEvent =>
1305
- // This is highly unlikey, but in the case where a sticky event
1306
- // has appeared in the timeline AND the sticky section, we only
1307
- // want to emit the event once.
1308
- !timelineEvents.some(timelineEvent => timelineEvent.getId() === stickyEvent.getId())).forEach(emitEvent);
1309
- // Decrypt only the last message in all rooms to make sure we can generate a preview
1310
- // And decrypt all events after the recorded read receipt to ensure an accurate
1311
- // notification count
1312
- room.decryptCriticalEvents();
1313
- });
1314
- return function (_x4) {
1315
- return _ref10.apply(this, arguments);
1316
- };
1317
- }()));
1318
-
1319
- // Handle leaves (e.g. kicked rooms)
1320
- yield Promise.all(leaveRooms.map(/*#__PURE__*/function () {
1321
- var _ref14 = _asyncToGenerator(function* (leaveObj) {
1322
- var room = leaveObj.room;
1323
- var _yield$_this9$mapAndI = yield _this9.mapAndInjectRoomEvents(leaveObj),
1324
- timelineEvents = _yield$_this9$mapAndI.timelineEvents,
1325
- stateEvents = _yield$_this9$mapAndI.stateEvents,
1326
- stateAfterEvents = _yield$_this9$mapAndI.stateAfterEvents;
1327
- var accountDataEvents = _this9.mapSyncEventsFormat(leaveObj.account_data);
1328
- room.addAccountData(accountDataEvents);
1329
- room.recalculate();
1330
- if (leaveObj.isBrandNewRoom) {
1331
- client.store.storeRoom(room);
1332
- client.emit(ClientEvent.Room, room);
1333
- }
1334
- _this9.processEventsForNotifs(room, timelineEvents);
1335
- stateEvents === null || stateEvents === void 0 || stateEvents.forEach(function (e) {
1336
- client.emit(ClientEvent.Event, e);
1337
- });
1338
- stateAfterEvents === null || stateAfterEvents === void 0 || stateAfterEvents.forEach(function (e) {
1339
- client.emit(ClientEvent.Event, e);
1340
- });
1341
- timelineEvents.forEach(function (e) {
1342
- client.emit(ClientEvent.Event, e);
1343
- });
1344
- accountDataEvents.forEach(function (e) {
1345
- client.emit(ClientEvent.Event, e);
1346
- });
1347
- });
1348
- return function (_x5) {
1349
- return _ref14.apply(this, arguments);
1350
- };
1351
- }()));
1352
-
1353
- // Handle knocks
1354
- yield Promise.all(knockRooms.map(/*#__PURE__*/function () {
1355
- var _ref15 = _asyncToGenerator(function* (knockObj) {
1356
- var room = knockObj.room;
1357
- var stateEvents = _this9.mapSyncEventsFormat(knockObj.knock_state, room);
1358
- yield _this9.injectRoomEvents(room, stateEvents, undefined);
1359
- if (knockObj.isBrandNewRoom) {
1360
- room.recalculate();
1361
- client.store.storeRoom(room);
1362
- client.emit(ClientEvent.Room, room);
1363
- } else {
1364
- // Update room state for knock->leave->knock cycles
1365
- room.recalculate();
1194
+ if (this.syncOpts.cryptoCallbacks) {
1195
+ for (const e of eventsFormingFinalState) {
1196
+ if (e.isState() && e.getType() === EventType.RoomEncryption && e.getStateKey() === "") {
1197
+ await this.syncOpts.cryptoCallbacks.onCryptoEvent(room, e);
1366
1198
  }
1367
- stateEvents.forEach(function (e) {
1368
- client.emit(ClientEvent.Event, e);
1369
- });
1370
- });
1371
- return function (_x6) {
1372
- return _ref15.apply(this, arguments);
1373
- };
1374
- }()));
1375
-
1376
- // update the notification timeline, if appropriate.
1377
- // we only do this for live events, as otherwise we can't order them sanely
1378
- // in the timeline relative to ones paginated in by /notifications.
1379
- // XXX: we could fix this by making EventTimeline support chronological
1380
- // ordering... but it doesn't, right now.
1381
- if (syncEventData.oldSyncToken && _this9.notifEvents.length) {
1382
- _this9.notifEvents.sort(function (a, b) {
1383
- return a.getTs() - b.getTs();
1384
- });
1385
- _this9.notifEvents.forEach(function (event) {
1386
- var _client$getNotifTimel;
1387
- (_client$getNotifTimel = client.getNotifTimelineSet()) === null || _client$getNotifTimel === void 0 || _client$getNotifTimel.addLiveEvent(event, {
1388
- addToState: true
1389
- });
1390
- });
1199
+ }
1391
1200
  }
1392
1201
 
1393
- // Handle device list updates
1394
- if (data.device_lists) {
1395
- if (_this9.syncOpts.cryptoCallbacks) {
1396
- yield _this9.syncOpts.cryptoCallbacks.processDeviceLists(data.device_lists);
1202
+ // Proactively decrypt state events: normally we decrypt on demand, but for state
1203
+ // events we need them immediately, so we handle them here. Specifically, consumers
1204
+ // (e.g. Element Web) expect state events to be unencrypted upon receipt.
1205
+ for (const ev of timelineEvents.filter(ev => ev.isState())) {
1206
+ await this.client.decryptEventIfNeeded(ev);
1207
+ }
1208
+ try {
1209
+ if ("org.matrix.msc4222.state_after" in joinObj) {
1210
+ await this.injectRoomEvents(room, undefined, stateAfterEvents, timelineEvents, syncEventData.fromCache);
1397
1211
  } else {
1398
- // FIXME if we *don't* have a crypto module, we still need to
1399
- // invalidate the device lists. But that would require a
1400
- // substantial bit of rework :/.
1212
+ await this.injectRoomEvents(room, stateEvents, undefined, timelineEvents, syncEventData.fromCache);
1401
1213
  }
1214
+ } catch (e) {
1215
+ this.syncOpts.logger.error(`Failed to process events on room ${room.roomId}:`, e);
1216
+ }
1217
+
1218
+ // set summary after processing events,
1219
+ // because it will trigger a name calculation
1220
+ // which needs the room state to be up to date
1221
+ if (joinObj.summary) {
1222
+ room.setSummary(joinObj.summary);
1223
+ }
1224
+
1225
+ // we deliberately don't add ephemeral events to the timeline
1226
+ room.addEphemeralEvents(ephemeralEvents);
1227
+
1228
+ // we deliberately don't add accountData to the timeline
1229
+ room.addAccountData(accountDataEvents);
1230
+
1231
+ // Sticky events primarily come via the `timeline` field, with the
1232
+ // sticky info field marking them as sticky.
1233
+ // If the sync is "gappy" (meaning it is skipping events to catch up) then
1234
+ // sticky events will instead come down the sticky section.
1235
+ // This ensures we collect sticky events from both places.
1236
+ const stickyEventsAndStickyEventsFromTheTimeline = stickyEvents.concat(timelineEvents.filter(e => e.unstableStickyInfo !== undefined));
1237
+ // Note: We calculate sticky events before emitting `.Room` as it's nice to have
1238
+ // sticky events calculated and ready to go.
1239
+ room._unstable_addStickyEvents(stickyEventsAndStickyEventsFromTheTimeline);
1240
+ room.recalculate();
1241
+ if (joinObj.isBrandNewRoom) {
1242
+ client.store.storeRoom(room);
1243
+ client.emit(ClientEvent.Room, room);
1244
+ }
1245
+ this.processEventsForNotifs(room, timelineEvents);
1246
+ const emitEvent = e => client.emit(ClientEvent.Event, e);
1247
+ // this fires a couple of times for some events. (eg state events are in the timeline and the state)
1248
+ // should this get a sync section as an additional event emission param (e, syncSection))?
1249
+ stateEvents.forEach(emitEvent);
1250
+ timelineEvents.forEach(emitEvent);
1251
+ ephemeralEvents.forEach(emitEvent);
1252
+ accountDataEvents.forEach(emitEvent);
1253
+ stickyEvents.filter(stickyEvent =>
1254
+ // This is highly unlikey, but in the case where a sticky event
1255
+ // has appeared in the timeline AND the sticky section, we only
1256
+ // want to emit the event once.
1257
+ !timelineEvents.some(timelineEvent => timelineEvent.getId() === stickyEvent.getId())).forEach(emitEvent);
1258
+ // Decrypt only the last message in all rooms to make sure we can generate a preview
1259
+ // And decrypt all events after the recorded read receipt to ensure an accurate
1260
+ // notification count
1261
+ room.decryptCriticalEvents();
1262
+ }));
1263
+
1264
+ // Handle leaves (e.g. kicked rooms)
1265
+ await Promise.all(leaveRooms.map(async leaveObj => {
1266
+ const room = leaveObj.room;
1267
+ const {
1268
+ timelineEvents,
1269
+ stateEvents,
1270
+ stateAfterEvents
1271
+ } = await this.mapAndInjectRoomEvents(leaveObj);
1272
+ const accountDataEvents = this.mapSyncEventsFormat(leaveObj.account_data);
1273
+ room.addAccountData(accountDataEvents);
1274
+ room.recalculate();
1275
+ if (leaveObj.isBrandNewRoom) {
1276
+ client.store.storeRoom(room);
1277
+ client.emit(ClientEvent.Room, room);
1402
1278
  }
1279
+ this.processEventsForNotifs(room, timelineEvents);
1280
+ stateEvents?.forEach(function (e) {
1281
+ client.emit(ClientEvent.Event, e);
1282
+ });
1283
+ stateAfterEvents?.forEach(function (e) {
1284
+ client.emit(ClientEvent.Event, e);
1285
+ });
1286
+ timelineEvents.forEach(function (e) {
1287
+ client.emit(ClientEvent.Event, e);
1288
+ });
1289
+ accountDataEvents.forEach(function (e) {
1290
+ client.emit(ClientEvent.Event, e);
1291
+ });
1292
+ }));
1293
+
1294
+ // Handle knocks
1295
+ await Promise.all(knockRooms.map(async knockObj => {
1296
+ const room = knockObj.room;
1297
+ const stateEvents = this.mapSyncEventsFormat(knockObj.knock_state, room);
1298
+ await this.injectRoomEvents(room, stateEvents, undefined);
1299
+ if (knockObj.isBrandNewRoom) {
1300
+ room.recalculate();
1301
+ client.store.storeRoom(room);
1302
+ client.emit(ClientEvent.Room, room);
1303
+ } else {
1304
+ // Update room state for knock->leave->knock cycles
1305
+ room.recalculate();
1306
+ }
1307
+ stateEvents.forEach(function (e) {
1308
+ client.emit(ClientEvent.Event, e);
1309
+ });
1310
+ }));
1403
1311
 
1404
- // Handle one_time_keys_count and unused fallback keys
1405
- yield (_this9$syncOpts$crypt = _this9.syncOpts.cryptoCallbacks) === null || _this9$syncOpts$crypt === void 0 ? void 0 : _this9$syncOpts$crypt.processKeyCounts(data.device_one_time_keys_count, (_data$device_unused_f = data.device_unused_fallback_key_types) !== null && _data$device_unused_f !== void 0 ? _data$device_unused_f : data["org.matrix.msc2732.device_unused_fallback_key_types"]);
1406
- })();
1312
+ // update the notification timeline, if appropriate.
1313
+ // we only do this for live events, as otherwise we can't order them sanely
1314
+ // in the timeline relative to ones paginated in by /notifications.
1315
+ // XXX: we could fix this by making EventTimeline support chronological
1316
+ // ordering... but it doesn't, right now.
1317
+ if (syncEventData.oldSyncToken && this.notifEvents.length) {
1318
+ this.notifEvents.sort(function (a, b) {
1319
+ return a.getTs() - b.getTs();
1320
+ });
1321
+ this.notifEvents.forEach(function (event) {
1322
+ client.getNotifTimelineSet()?.addLiveEvent(event, {
1323
+ addToState: true
1324
+ });
1325
+ });
1326
+ }
1327
+
1328
+ // Handle device list updates
1329
+ if (data.device_lists) {
1330
+ if (this.syncOpts.cryptoCallbacks) {
1331
+ await this.syncOpts.cryptoCallbacks.processDeviceLists(data.device_lists);
1332
+ } else {
1333
+ // FIXME if we *don't* have a crypto module, we still need to
1334
+ // invalidate the device lists. But that would require a
1335
+ // substantial bit of rework :/.
1336
+ }
1337
+ }
1338
+
1339
+ // Handle one_time_keys_count and unused fallback keys
1340
+ await this.syncOpts.cryptoCallbacks?.processKeyCounts(data.device_one_time_keys_count, data.device_unused_fallback_key_types ?? data["org.matrix.msc2732.device_unused_fallback_key_types"]);
1407
1341
  }
1408
1342
 
1409
1343
  /**
@@ -1440,9 +1374,7 @@ export class SyncApi {
1440
1374
  *
1441
1375
  * @param connDidFail - True if a connectivity failure has been detected. Optional.
1442
1376
  */
1443
- pokeKeepAlive() {
1444
- var _this$abortController4;
1445
- var connDidFail = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1377
+ pokeKeepAlive(connDidFail = false) {
1446
1378
  if (!this.running) {
1447
1379
  // we are in a keepAlive, retrying to connect, but the syncronization
1448
1380
  // was stopped, so we are stopping the retry.
@@ -1453,7 +1385,7 @@ export class SyncApi {
1453
1385
  }
1454
1386
  return;
1455
1387
  }
1456
- var success = () => {
1388
+ const success = () => {
1457
1389
  clearTimeout(this.keepAliveTimer);
1458
1390
  if (this.connectionReturnedResolvers) {
1459
1391
  this.connectionReturnedResolvers.resolve(connDidFail);
@@ -1467,7 +1399,7 @@ export class SyncApi {
1467
1399
  {
1468
1400
  prefix: "",
1469
1401
  localTimeoutMs: 15 * 1000,
1470
- abortSignal: (_this$abortController4 = this.abortController) === null || _this$abortController4 === void 0 ? void 0 : _this$abortController4.signal
1402
+ abortSignal: this.abortController?.signal
1471
1403
  }).then(() => {
1472
1404
  success();
1473
1405
  }, err => {
@@ -1497,10 +1429,10 @@ export class SyncApi {
1497
1429
  // Maps { roomid: {stuff}, roomid: {stuff} }
1498
1430
  // to
1499
1431
  // [{stuff+Room+isBrandNewRoom}, {stuff+Room+isBrandNewRoom}]
1500
- var client = this.client;
1432
+ const client = this.client;
1501
1433
  return Object.keys(obj).filter(k => !unsafeProp(k)).map(roomId => {
1502
- var room = client.store.getRoom(roomId);
1503
- var isBrandNewRoom = false;
1434
+ let room = client.store.getRoom(roomId);
1435
+ let isBrandNewRoom = false;
1504
1436
  if (!room) {
1505
1437
  room = this.createRoom(roomId);
1506
1438
  isBrandNewRoom = true;
@@ -1511,12 +1443,11 @@ export class SyncApi {
1511
1443
  });
1512
1444
  });
1513
1445
  }
1514
- mapSyncEventsFormat(obj, room) {
1515
- var decrypt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1446
+ mapSyncEventsFormat(obj, room, decrypt = true) {
1516
1447
  if (!obj || !Array.isArray(obj.events)) {
1517
1448
  return [];
1518
1449
  }
1519
- var mapper = this.client.getEventMapper({
1450
+ const mapper = this.client.getEventMapper({
1520
1451
  decrypt
1521
1452
  });
1522
1453
  return obj.events.filter(noUnsafeEventProps).map(function (e) {
@@ -1533,15 +1464,15 @@ export class SyncApi {
1533
1464
  if (!room || !this.opts.resolveInvitesToProfiles) {
1534
1465
  return;
1535
1466
  }
1536
- var client = this.client;
1467
+ const client = this.client;
1537
1468
  // For each invited room member we want to give them a displayname/avatar url
1538
1469
  // if they have one (the m.room.member invites don't contain this).
1539
1470
  room.getMembersWithMembership(KnownMembership.Invite).forEach(function (member) {
1540
1471
  if (member.requestedProfileInfo) return;
1541
1472
  member.requestedProfileInfo = true;
1542
1473
  // try to get a cached copy first.
1543
- var user = client.getUser(member.userId);
1544
- var promise;
1474
+ const user = client.getUser(member.userId);
1475
+ let promise;
1545
1476
  if (user) {
1546
1477
  promise = Promise.resolve({
1547
1478
  avatar_url: user.avatarUrl,
@@ -1554,8 +1485,8 @@ export class SyncApi {
1554
1485
  // slightly naughty by doctoring the invite event but this means all
1555
1486
  // the code paths remain the same between invite/join display name stuff
1556
1487
  // which is a worthy trade-off for some minor pollution.
1557
- var inviteEvent = member.events.member;
1558
- if ((inviteEvent === null || inviteEvent === void 0 ? void 0 : inviteEvent.getContent().membership) !== KnownMembership.Invite) {
1488
+ const inviteEvent = member.events.member;
1489
+ if (inviteEvent?.getContent().membership !== KnownMembership.Invite) {
1559
1490
  // between resolving and now they have since joined, so don't clobber
1560
1491
  return;
1561
1492
  }
@@ -1569,7 +1500,7 @@ export class SyncApi {
1569
1500
  });
1570
1501
  }
1571
1502
  findEncryptionEvent(events) {
1572
- return events === null || events === void 0 ? void 0 : events.find(e => e.getType() === EventType.RoomEncryption && e.getStateKey() === "");
1503
+ return events?.find(e => e.getType() === EventType.RoomEncryption && e.getStateKey() === "");
1573
1504
  }
1574
1505
 
1575
1506
  // When processing the sync response we cannot rely on Room.hasEncryptionStateEvent we actually
@@ -1577,23 +1508,20 @@ export class SyncApi {
1577
1508
  isRoomEncrypted(room, eventsFormingFinalState) {
1578
1509
  return room.hasEncryptionStateEvent() || !!this.findEncryptionEvent(eventsFormingFinalState);
1579
1510
  }
1580
- mapAndInjectRoomEvents(wrappedRoom) {
1581
- var _this0 = this;
1582
- return _asyncToGenerator(function* () {
1583
- var stateEvents = _this0.mapSyncEventsFormat(wrappedRoom.state, wrappedRoom.room);
1584
- var stateAfterEvents = _this0.mapSyncEventsFormat(wrappedRoom["org.matrix.msc4222.state_after"], wrappedRoom.room);
1585
- var timelineEvents = _this0.mapSyncEventsFormat(wrappedRoom.timeline, wrappedRoom.room);
1586
- if ("org.matrix.msc4222.state_after" in wrappedRoom) {
1587
- yield _this0.injectRoomEvents(wrappedRoom.room, undefined, stateAfterEvents, timelineEvents);
1588
- } else {
1589
- yield _this0.injectRoomEvents(wrappedRoom.room, stateEvents, undefined, timelineEvents);
1590
- }
1591
- return {
1592
- timelineEvents,
1593
- stateEvents,
1594
- stateAfterEvents
1595
- };
1596
- })();
1511
+ async mapAndInjectRoomEvents(wrappedRoom) {
1512
+ const stateEvents = this.mapSyncEventsFormat(wrappedRoom.state, wrappedRoom.room);
1513
+ const stateAfterEvents = this.mapSyncEventsFormat(wrappedRoom["org.matrix.msc4222.state_after"], wrappedRoom.room);
1514
+ const timelineEvents = this.mapSyncEventsFormat(wrappedRoom.timeline, wrappedRoom.room);
1515
+ if ("org.matrix.msc4222.state_after" in wrappedRoom) {
1516
+ await this.injectRoomEvents(wrappedRoom.room, undefined, stateAfterEvents, timelineEvents);
1517
+ } else {
1518
+ await this.injectRoomEvents(wrappedRoom.room, stateEvents, undefined, timelineEvents);
1519
+ }
1520
+ return {
1521
+ timelineEvents,
1522
+ stateEvents,
1523
+ stateAfterEvents
1524
+ };
1597
1525
  }
1598
1526
 
1599
1527
  /**
@@ -1612,76 +1540,71 @@ export class SyncApi {
1612
1540
  * are not added to the state.
1613
1541
  */
1614
1542
 
1615
- injectRoomEvents(room, stateEventList, stateAfterEventList, timelineEventList) {
1616
- var _arguments = arguments,
1617
- _this1 = this;
1618
- return _asyncToGenerator(function* () {
1619
- var fromCache = _arguments.length > 4 && _arguments[4] !== undefined ? _arguments[4] : false;
1620
- var eitherStateEventList = stateAfterEventList !== null && stateAfterEventList !== void 0 ? stateAfterEventList : stateEventList;
1621
-
1622
- // If there are no events in the timeline yet, initialise it with
1623
- // the given state events
1624
- var liveTimeline = room.getLiveTimeline();
1625
- var timelineWasEmpty = liveTimeline.getEvents().length == 0;
1626
- if (timelineWasEmpty) {
1627
- // Passing these events into initialiseState will freeze them, so we need
1628
- // to compute and cache the push actions for them now, otherwise sync dies
1629
- // with an attempt to assign to read only property.
1630
- // XXX: This is pretty horrible and is assuming all sorts of behaviour from
1631
- // these functions that it shouldn't be. We should probably either store the
1632
- // push actions cache elsewhere so we can freeze MatrixEvents, or otherwise
1633
- // find some solution where MatrixEvents are immutable but allow for a cache
1634
- // field.
1635
-
1636
- for (var ev of eitherStateEventList) {
1637
- _this1.client.getPushActionsForEvent(ev);
1638
- }
1639
- liveTimeline.initialiseState(eitherStateEventList, {
1640
- timelineWasEmpty
1641
- });
1642
- }
1643
- _this1.resolveInvites(room);
1644
-
1645
- // recalculate the room name at this point as adding events to the timeline
1646
- // may make notifications appear which should have the right name.
1647
- // XXX: This looks suspect: we'll end up recalculating the room once here
1648
- // and then again after adding events (processSyncResponse calls it after
1649
- // calling us) even if no state events were added. It also means that if
1650
- // one of the room events in timelineEventList is something that needs
1651
- // a recalculation (like m.room.name) we won't recalculate until we've
1652
- // finished adding all the events, which will cause the notification to have
1653
- // the old room name rather than the new one.
1654
- room.recalculate();
1543
+ async injectRoomEvents(room, stateEventList, stateAfterEventList, timelineEventList, fromCache = false) {
1544
+ const eitherStateEventList = stateAfterEventList ?? stateEventList;
1655
1545
 
1656
- // If the timeline wasn't empty, we process the state events here: they're
1657
- // defined as updates to the state before the start of the timeline, so this
1658
- // starts to roll the state forward.
1659
- // XXX: That's what we *should* do, but this can happen if we were previously
1660
- // peeking in a room, in which case we obviously do *not* want to add the
1661
- // state events here onto the end of the timeline. Historically, the js-sdk
1662
- // has just set these new state events on the old and new state. This seems
1663
- // very wrong because there could be events in the timeline that diverge the
1664
- // state, in which case this is going to leave things out of sync. However,
1665
- // for now I think it;s best to behave the same as the code has done previously.
1666
- if (!timelineWasEmpty) {
1667
- // XXX: As above, don't do this...
1668
- //room.addLiveEvents(stateEventList || []);
1669
- // Do this instead...
1670
- room.oldState.setStateEvents(eitherStateEventList);
1671
- room.currentState.setStateEvents(eitherStateEventList);
1546
+ // If there are no events in the timeline yet, initialise it with
1547
+ // the given state events
1548
+ const liveTimeline = room.getLiveTimeline();
1549
+ const timelineWasEmpty = liveTimeline.getEvents().length == 0;
1550
+ if (timelineWasEmpty) {
1551
+ // Passing these events into initialiseState will freeze them, so we need
1552
+ // to compute and cache the push actions for them now, otherwise sync dies
1553
+ // with an attempt to assign to read only property.
1554
+ // XXX: This is pretty horrible and is assuming all sorts of behaviour from
1555
+ // these functions that it shouldn't be. We should probably either store the
1556
+ // push actions cache elsewhere so we can freeze MatrixEvents, or otherwise
1557
+ // find some solution where MatrixEvents are immutable but allow for a cache
1558
+ // field.
1559
+
1560
+ for (const ev of eitherStateEventList) {
1561
+ this.client.getPushActionsForEvent(ev);
1672
1562
  }
1673
-
1674
- // Execute the timeline events. If addToState is true the timeline has any state
1675
- // events in it, this will continue to diverge the current state.
1676
- // This also needs to be done before running push rules on the events as they need
1677
- // to be decorated with sender etc.
1678
- yield room.addLiveEvents(timelineEventList || [], {
1679
- fromCache,
1680
- timelineWasEmpty,
1681
- addToState: stateAfterEventList === undefined
1563
+ liveTimeline.initialiseState(eitherStateEventList, {
1564
+ timelineWasEmpty
1682
1565
  });
1683
- _this1.client.processBeaconEvents(room, timelineEventList);
1684
- })();
1566
+ }
1567
+ this.resolveInvites(room);
1568
+
1569
+ // recalculate the room name at this point as adding events to the timeline
1570
+ // may make notifications appear which should have the right name.
1571
+ // XXX: This looks suspect: we'll end up recalculating the room once here
1572
+ // and then again after adding events (processSyncResponse calls it after
1573
+ // calling us) even if no state events were added. It also means that if
1574
+ // one of the room events in timelineEventList is something that needs
1575
+ // a recalculation (like m.room.name) we won't recalculate until we've
1576
+ // finished adding all the events, which will cause the notification to have
1577
+ // the old room name rather than the new one.
1578
+ room.recalculate();
1579
+
1580
+ // If the timeline wasn't empty, we process the state events here: they're
1581
+ // defined as updates to the state before the start of the timeline, so this
1582
+ // starts to roll the state forward.
1583
+ // XXX: That's what we *should* do, but this can happen if we were previously
1584
+ // peeking in a room, in which case we obviously do *not* want to add the
1585
+ // state events here onto the end of the timeline. Historically, the js-sdk
1586
+ // has just set these new state events on the old and new state. This seems
1587
+ // very wrong because there could be events in the timeline that diverge the
1588
+ // state, in which case this is going to leave things out of sync. However,
1589
+ // for now I think it;s best to behave the same as the code has done previously.
1590
+ if (!timelineWasEmpty) {
1591
+ // XXX: As above, don't do this...
1592
+ //room.addLiveEvents(stateEventList || []);
1593
+ // Do this instead...
1594
+ room.oldState.setStateEvents(eitherStateEventList);
1595
+ room.currentState.setStateEvents(eitherStateEventList);
1596
+ }
1597
+
1598
+ // Execute the timeline events. If addToState is true the timeline has any state
1599
+ // events in it, this will continue to diverge the current state.
1600
+ // This also needs to be done before running push rules on the events as they need
1601
+ // to be decorated with sender etc.
1602
+ await room.addLiveEvents(timelineEventList || [], {
1603
+ fromCache,
1604
+ timelineWasEmpty,
1605
+ addToState: stateAfterEventList === undefined
1606
+ });
1607
+ this.client.processBeaconEvents(room, timelineEventList);
1685
1608
  }
1686
1609
 
1687
1610
  /**
@@ -1695,10 +1618,9 @@ export class SyncApi {
1695
1618
  processEventsForNotifs(room, timelineEventList) {
1696
1619
  // gather our notifications into this.notifEvents
1697
1620
  if (this.client.getNotifTimelineSet()) {
1698
- for (var event of timelineEventList) {
1699
- var _pushActions$tweaks;
1700
- var pushActions = this.client.getPushActionsForEvent(event);
1701
- if (pushActions !== null && pushActions !== void 0 && pushActions.notify && (_pushActions$tweaks = pushActions.tweaks) !== null && _pushActions$tweaks !== void 0 && _pushActions$tweaks.highlight) {
1621
+ for (const event of timelineEventList) {
1622
+ const pushActions = this.client.getPushActionsForEvent(event);
1623
+ if (pushActions?.notify && pushActions.tweaks?.highlight) {
1702
1624
  this.notifEvents.push(event);
1703
1625
  }
1704
1626
  }
@@ -1716,7 +1638,7 @@ export class SyncApi {
1716
1638
  * @param data - Object of additional data to emit in the event
1717
1639
  */
1718
1640
  updateSyncState(newState, data) {
1719
- var old = this.syncState;
1641
+ const old = this.syncState;
1720
1642
  this.syncState = newState;
1721
1643
  this.syncStateData = data;
1722
1644
  this.client.emit(ClientEvent.Sync, this.syncState, old, data);
@@ -1726,8 +1648,10 @@ export class SyncApi {
1726
1648
  // /!\ This function is not intended for public use! It's only exported from
1727
1649
  // here in order to share some common logic with sliding-sync-sdk.ts.
1728
1650
  export function _createAndReEmitRoom(client, roomId, opts) {
1729
- var timelineSupport = client.timelineSupport;
1730
- var room = new Room(roomId, client, client.getUserId(), {
1651
+ const {
1652
+ timelineSupport
1653
+ } = client;
1654
+ const room = new Room(roomId, client, client.getUserId(), {
1731
1655
  lazyLoadMembers: opts.lazyLoadMembers,
1732
1656
  pendingEventOrdering: opts.pendingEventOrdering,
1733
1657
  timelineSupport
@@ -1737,8 +1661,7 @@ export function _createAndReEmitRoom(client, roomId, opts) {
1737
1661
  // We need to add a listener for RoomState.members in order to hook them
1738
1662
  // correctly.
1739
1663
  room.on(RoomStateEvent.NewMember, (event, state, member) => {
1740
- var _client$getUser;
1741
- member.user = (_client$getUser = client.getUser(member.userId)) !== null && _client$getUser !== void 0 ? _client$getUser : undefined;
1664
+ member.user = client.getUser(member.userId) ?? undefined;
1742
1665
  client.reEmitter.reEmit(member, [RoomMemberEvent.Name, RoomMemberEvent.Typing, RoomMemberEvent.PowerLevel, RoomMemberEvent.Membership]);
1743
1666
  });
1744
1667
  return room;
@@ -1751,7 +1674,7 @@ export function _createAndReEmitRoom(client, roomId, opts) {
1751
1674
  * Also converts the events into `MatrixEvent`s, and emits the now deprecated {@link ClientEvent.ToDeviceEvent} events for compatibility.
1752
1675
  * */
1753
1676
  export function processToDeviceMessages(toDeviceMessages, client) {
1754
- var cancelledKeyVerificationTxns = [];
1677
+ const cancelledKeyVerificationTxns = [];
1755
1678
  toDeviceMessages.map(processedMessage => {
1756
1679
  // map is a cheap inline forEach
1757
1680
  // We want to flag m.key.verification.start events as cancelled
@@ -1760,7 +1683,7 @@ export function processToDeviceMessages(toDeviceMessages, client) {
1760
1683
  // so we can flag the verification events as cancelled in the loop
1761
1684
  // below.
1762
1685
  if (processedMessage.message.type === "m.key.verification.cancel") {
1763
- var txnId = processedMessage.message.content["transaction_id"];
1686
+ const txnId = processedMessage.message.content["transaction_id"];
1764
1687
  if (txnId) {
1765
1688
  cancelledKeyVerificationTxns.push(txnId);
1766
1689
  }
@@ -1772,14 +1695,14 @@ export function processToDeviceMessages(toDeviceMessages, client) {
1772
1695
  }).forEach(function (processedEvent) {
1773
1696
  // For backwards compatibility, we also emit the event as a `MatrixEvent` using `ClientEvent.ToDeviceEvent`.
1774
1697
  {
1775
- var toDeviceEvent = processedEvent.message;
1776
- var content = toDeviceEvent.content;
1698
+ const toDeviceEvent = processedEvent.message;
1699
+ const content = toDeviceEvent.content;
1777
1700
  // The message is cloned before being passed to the MatrixEvent constructor, because
1778
1701
  // the `makeEncrypted` method will mutate the type and content properties of the original message and will interfere
1779
1702
  // with the emitted event for `ReceivedToDeviceMessage`.
1780
- var deprecatedCompatibilityEvent = new MatrixEvent(Object.assign({}, toDeviceEvent));
1703
+ const deprecatedCompatibilityEvent = new MatrixEvent(Object.assign({}, toDeviceEvent));
1781
1704
  if (toDeviceEvent.type === "m.key.verification.start" || toDeviceEvent.type === "m.key.verification.request") {
1782
- var txnId = content["transaction_id"];
1705
+ const txnId = content["transaction_id"];
1783
1706
  if (cancelledKeyVerificationTxns.includes(txnId)) {
1784
1707
  deprecatedCompatibilityEvent.flagCancelled();
1785
1708
  }