@openclaw/matrix 2026.10.10 → 2026.11.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (695) hide show
  1. package/dist/.setup/{account-selection-Co94mKNj.mjs → account-selection-Cow3TMFO.mjs} +11 -11
  2. package/dist/.setup/{approval-handler.runtime-DtNvJpfB.mjs → approval-handler.runtime-_0gqiVgR.mjs} +16 -51
  3. package/dist/.setup/{approval-reactions-DMDBJos0.mjs → approval-reactions-Bz_8XB01.mjs} +2 -2
  4. package/dist/.setup/{channel-CNjJyBS_.mjs → channel-ByHcZU28.mjs} +292 -357
  5. package/dist/.setup/channel.runtime-sNicWjmD.mjs +71 -0
  6. package/dist/.setup/{channel.setup-IjRB0ymg.mjs → channel.setup-Bmba21y9.mjs} +28 -39
  7. package/dist/.setup/{cli-CuEJNM3c.mjs → cli-B26pps0Q.mjs} +250 -308
  8. package/dist/.setup/{cli-metadata-rWmD_rzx.mjs → cli-metadata-CKGwVfmT.mjs} +1 -1
  9. package/dist/.setup/{client-7eyTX0cu.mjs → client-Bqu801rH.mjs} +88 -174
  10. package/dist/.setup/{client-CV0MkCZG.mjs → client-N8TEwtmk.mjs} +6 -6
  11. package/dist/.setup/{client-bootstrap-BjcmTmyR.mjs → client-bootstrap-k6Zm1M8Y.mjs} +5 -10
  12. package/dist/.setup/{client-support-CFofPPPm.mjs → client-support-CqXAOZp3.mjs} +1 -14
  13. package/dist/.setup/{create-client-C4Lnqs2C.mjs → create-client-DaGljdrk.mjs} +6 -6
  14. package/dist/.setup/{credentials-B0vpXvcB.mjs → credentials-DVmY0miU.mjs} +6 -20
  15. package/dist/.setup/{credentials-read-WCQSEvI8.mjs → credentials-read-rPqEpuxv.mjs} +3 -3
  16. package/dist/.setup/{crypto-runtime-Crp1is7m.mjs → crypto-runtime-KQupbxSM.mjs} +74 -158
  17. package/dist/.setup/{crypto-state-store-CM57gchf.mjs → crypto-state-store-p1mdYTWH.mjs} +14 -9
  18. package/dist/.setup/{crypto-store-ownership-Bratn-Np.mjs → crypto-store-ownership-7lVHeXWL.mjs} +1 -1
  19. package/dist/.setup/{crypto-unsafe-state-doctor-Brv4bIyx.mjs → crypto-unsafe-state-doctor-CG2nJk8P.mjs} +7 -6
  20. package/dist/.setup/{deps-O7rEnklr.mjs → deps-CVPT2Ros.mjs} +4 -3
  21. package/dist/.setup/device-health-D7n-lPeb.mjs +7 -0
  22. package/dist/.setup/{direct-management-DDaWVbQI.mjs → direct-management-D59C1WO-.mjs} +22 -28
  23. package/dist/.setup/{directory-live-B-csizuK.mjs → directory-live-YixmpyLW.mjs} +5 -5
  24. package/dist/.setup/doctor-contract-GiXgCj7k.mjs +37 -0
  25. package/dist/.setup/{draft-stream-dmhBHufd.mjs → draft-stream-C09OtoJZ.mjs} +10 -16
  26. package/dist/.setup/{encryption-guidance-Cn6-Tlx0.mjs → encryption-guidance-DfbEaKct.mjs} +1 -1
  27. package/dist/.setup/{exec-approvals-D7vv3AZS.mjs → exec-approvals-C3rCm0Sn.mjs} +31 -41
  28. package/dist/.setup/{file-sync-store-q5KCV2Lp.mjs → file-sync-store-NW6eDuai.mjs} +52 -8
  29. package/dist/.setup/{http-client-CxTmU1kT.mjs → http-client-CqnKFKUH.mjs} +19 -31
  30. package/dist/.setup/{idb-persistence-BF0MZglD.mjs → idb-persistence-CmoPtwDD.mjs} +22 -15
  31. package/dist/.setup/{joined-room-encryption-Dl7Sb9FF.mjs → joined-room-encryption-9sJK1kM-.mjs} +4 -3
  32. package/dist/.setup/{logger-BX5kXvh1.mjs → logger-B9TwnY6C.mjs} +2 -2
  33. package/dist/.setup/{logging-BLcaOSRD.mjs → logging-Bnsn7s4r.mjs} +20 -14
  34. package/dist/.setup/{messages-BiHM0DM3.mjs → messages-BjzsVgS6.mjs} +39 -22
  35. package/dist/.setup/{monitor-CPwDgRFY.mjs → monitor-D4vhbNUM.mjs} +647 -816
  36. package/dist/.setup/{onboarding-DiVtpjNu.mjs → onboarding-DKmt3jpW.mjs} +116 -128
  37. package/dist/.setup/{outbound-DwP97VpQ.mjs → outbound-wsXTF0z_.mjs} +2 -2
  38. package/dist/.setup/{profile-update-DnNA9mEa.mjs → profile-update-DX060MnL.mjs} +14 -14
  39. package/dist/.setup/{reaction-events-ClY9h_FC.mjs → reaction-events-BMsatzs4.mjs} +74 -99
  40. package/dist/.setup/{resolve-targets-B8PAwHVS.mjs → resolve-targets-Yz_3aN_2.mjs} +2 -2
  41. package/dist/.setup/{retired-state-vIr2IB90.mjs → retired-state-Bs3Gqkge.mjs} +6 -3
  42. package/dist/.setup/{room-info-T_PR_liR.mjs → room-info-OGKjk422.mjs} +21 -8
  43. package/dist/.setup/{doctor-contract-DybEjJcd.mjs → runtime-doctor-migrations-CSvRANPN.mjs} +12 -47
  44. package/dist/.setup/{sdk-Cj3ggJHG.mjs → sdk-BXcIyN-I.mjs} +95 -107
  45. package/dist/.setup/{send-C1qeMQAy.mjs → send-CWjH-l-T.mjs} +169 -251
  46. package/dist/.setup/{send-currentness-CAUVR-f3.mjs → send-currentness-D1x6YP9O.mjs} +9 -15
  47. package/dist/.setup/{setup-bootstrap-DDhwWvDs.mjs → setup-bootstrap-yKeGh4Iy.mjs} +2 -2
  48. package/dist/.setup/{setup-core-D2r4BivQ.mjs → setup-core-BaKffgBi.mjs} +19 -42
  49. package/dist/.setup/setup-plugin-api-B_t4waBw.mjs +2 -0
  50. package/dist/.setup/{startup-verification-B3LEbW33.mjs → startup-verification-C-lhD0gk.mjs} +9 -22
  51. package/dist/.setup/{storage-CxN4jqKI.mjs → storage-BLLN9jYG.mjs} +18 -22
  52. package/dist/.setup/{subagent-hooks-CT-rdJmh.mjs → subagent-hooks-D-lCcLGQ.mjs} +1 -1
  53. package/dist/.setup/{sync-cache-state-qYrd2EEh.mjs → sync-cache-state-B4hJFIPw.mjs} +10 -10
  54. package/dist/.setup/sync-state-Cu1nagBV.mjs +11 -0
  55. package/dist/.setup/task-runner-CYyGHdNW.mjs +51 -0
  56. package/dist/.setup/{thread-bindings-D2ZR6mEZ.mjs → thread-bindings-BA2xESjV.mjs} +34 -49
  57. package/dist/.setup/{thread-bindings-shared-FMu_szTm.mjs → thread-bindings-shared-CBlJu3Wz.mjs} +2 -2
  58. package/dist/.setup/{tool-actions-CdKa0DC4.mjs → tool-actions-CRuiVbqj.mjs} +59 -67
  59. package/dist/.setup/{url-validation-C77p4qT9.mjs → url-validation-DesoKUns.mjs} +1 -2
  60. package/dist/.setup/{verification-jP3tm-xD.mjs → verification-C5x4Hy5Y.mjs} +7 -7
  61. package/dist/.source-module-urls/1cd4d4ff8d44e1c8b830932b44d7cf8a7f3350e09e169910e1d7a85e131b7bea.json +1 -1
  62. package/dist/api.js +6 -6
  63. package/dist/auth-presence.js +1 -1
  64. package/dist/channel-plugin-api.js +1 -1
  65. package/dist/cli-metadata.js +1 -1
  66. package/dist/contract-api.js +2 -2
  67. package/dist/doctor-contract-api.js +149 -127
  68. package/dist/helper-api.js +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/plugin-entry.handlers.runtime.js +2 -2
  71. package/dist/runtime-api.js +3 -3
  72. package/dist/session-binding-contract-api.js +1 -1
  73. package/dist/setup-entry.js +1 -1
  74. package/dist/setup-plugin-api.js +1 -1
  75. package/dist/subagent-hooks-api.js +1 -1
  76. package/dist/thread-bindings-runtime.js +1 -1
  77. package/node_modules/@babel/runtime/helpers/asyncIterator.js +1 -1
  78. package/node_modules/@babel/runtime/helpers/createForOfIteratorHelper.js +12 -6
  79. package/node_modules/@babel/runtime/helpers/esm/asyncIterator.js +1 -1
  80. package/node_modules/@babel/runtime/helpers/esm/createForOfIteratorHelper.js +12 -6
  81. package/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +16 -19
  82. package/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +5 -5
  83. package/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +16 -19
  84. package/node_modules/@babel/runtime/helpers/toPrimitive.js +5 -5
  85. package/node_modules/@babel/runtime/package.json +1 -1
  86. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +94 -0
  87. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  88. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +1 -1
  89. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +3 -1
  90. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +2 -2
  91. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +8 -1
  92. package/node_modules/@openclaw/fs-safe/dist/file-open-error.d.ts +2 -0
  93. package/node_modules/@openclaw/fs-safe/dist/file-open-error.js +14 -0
  94. package/node_modules/@openclaw/fs-safe/dist/file-sync.d.ts +2 -1
  95. package/node_modules/@openclaw/fs-safe/dist/file-sync.js +6 -1
  96. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
  97. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
  98. package/node_modules/@openclaw/fs-safe/dist/native-config.js +14 -3
  99. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +2 -0
  100. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +9 -2
  101. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +40 -32
  102. package/node_modules/@openclaw/fs-safe/dist/output.js +6 -0
  103. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.d.ts +2 -0
  104. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -0
  105. package/node_modules/@openclaw/fs-safe/dist/path.js +5 -1
  106. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +25 -2
  107. package/node_modules/@openclaw/fs-safe/dist/publication-handle.d.ts +4 -0
  108. package/node_modules/@openclaw/fs-safe/dist/publication-handle.js +32 -0
  109. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.d.ts +2 -1
  110. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +19 -9
  111. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +23 -24
  112. package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.d.ts +21 -0
  113. package/node_modules/@openclaw/fs-safe/dist/publish-rename-fallback.js +102 -0
  114. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +2 -0
  115. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.d.ts +3 -1
  116. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +8 -5
  117. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +3 -0
  118. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +2 -1
  119. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +19 -9
  120. package/node_modules/@openclaw/fs-safe/dist/root-file-final-admission.js +3 -3
  121. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.d.ts +2 -2
  122. package/node_modules/@openclaw/fs-safe/dist/root-path-existing.js +27 -13
  123. package/node_modules/@openclaw/fs-safe/dist/root-path.js +2 -2
  124. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.d.ts +3 -0
  125. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +18 -3
  126. package/node_modules/@openclaw/fs-safe/dist/watch-hints.d.ts +1 -1
  127. package/node_modules/@openclaw/fs-safe/dist/watch-hints.js +68 -21
  128. package/node_modules/@openclaw/fs-safe/dist/watch-io-error.d.ts +2 -0
  129. package/node_modules/@openclaw/fs-safe/dist/watch-io-error.js +27 -0
  130. package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.d.ts +1 -0
  131. package/node_modules/@openclaw/fs-safe/dist/watch-io-worker.js +93 -0
  132. package/node_modules/@openclaw/fs-safe/dist/watch-io.d.ts +47 -0
  133. package/node_modules/@openclaw/fs-safe/dist/watch-io.js +236 -0
  134. package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +1 -1
  135. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -3
  136. package/node_modules/@openclaw/fs-safe/dist/watch-probe.d.ts +16 -0
  137. package/node_modules/@openclaw/fs-safe/dist/watch-probe.js +135 -0
  138. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.d.ts +1 -1
  139. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +86 -24
  140. package/node_modules/@openclaw/fs-safe/dist/watch-scan.d.ts +4 -0
  141. package/node_modules/@openclaw/fs-safe/dist/watch-scan.js +78 -16
  142. package/node_modules/@openclaw/fs-safe/dist/watch-stream.d.ts +2 -0
  143. package/node_modules/@openclaw/fs-safe/dist/watch-stream.js +23 -0
  144. package/node_modules/@openclaw/fs-safe/dist/watch-types.d.ts +3 -1
  145. package/node_modules/@openclaw/fs-safe/dist/watch.js +60 -13
  146. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +1 -1
  147. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +1 -0
  148. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  149. package/node_modules/@openclaw/fs-safe/docs/advanced.md +5 -2
  150. package/node_modules/@openclaw/fs-safe/docs/compiler-qualification.md +392 -0
  151. package/node_modules/@openclaw/fs-safe/docs/config.md +7 -1
  152. package/node_modules/@openclaw/fs-safe/docs/contributing.md +25 -5
  153. package/node_modules/@openclaw/fs-safe/docs/copy.md +10 -0
  154. package/node_modules/@openclaw/fs-safe/docs/durability.md +9 -3
  155. package/node_modules/@openclaw/fs-safe/docs/errors.md +13 -0
  156. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -4
  157. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +6 -4
  158. package/node_modules/@openclaw/fs-safe/docs/output.md +4 -2
  159. package/node_modules/@openclaw/fs-safe/docs/path.md +5 -2
  160. package/node_modules/@openclaw/fs-safe/docs/permissions.md +15 -0
  161. package/node_modules/@openclaw/fs-safe/docs/security-model.md +9 -0
  162. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +2 -0
  163. package/node_modules/@openclaw/fs-safe/docs/testing.md +1 -1
  164. package/node_modules/@openclaw/fs-safe/docs/watch.md +62 -5
  165. package/node_modules/@openclaw/fs-safe/docs/writing.md +6 -1
  166. package/node_modules/@openclaw/fs-safe/package.json +18 -16
  167. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  168. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  169. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  170. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  171. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  172. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +1 -1
  173. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  174. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +1 -1
  175. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  176. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  177. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  178. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  179. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  180. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  181. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  182. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  183. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  184. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +1 -1
  185. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  186. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  187. package/node_modules/@tokenizer/inflate/README.md +30 -1
  188. package/node_modules/@tokenizer/inflate/lib/GzipHandler.js +1 -1
  189. package/node_modules/@tokenizer/inflate/lib/ZipHandler.d.ts +8 -3
  190. package/node_modules/@tokenizer/inflate/lib/ZipHandler.js +101 -26
  191. package/node_modules/@tokenizer/inflate/lib/ZipLimitError.d.ts +16 -0
  192. package/node_modules/@tokenizer/inflate/lib/ZipLimitError.js +10 -0
  193. package/node_modules/@tokenizer/inflate/lib/ZipToken.d.ts +1 -1
  194. package/node_modules/@tokenizer/inflate/lib/ZipToken.js +11 -7
  195. package/node_modules/@tokenizer/inflate/lib/index.d.ts +2 -1
  196. package/node_modules/@tokenizer/inflate/lib/index.js +2 -1
  197. package/node_modules/@tokenizer/inflate/package.json +16 -15
  198. package/node_modules/argparse/lib/argparse.js +1 -1
  199. package/node_modules/argparse/package.json +1 -1
  200. package/node_modules/fake-indexeddb/build/cjs/FDBCursor.js +20 -18
  201. package/node_modules/fake-indexeddb/build/cjs/FDBKeyRange.js +6 -6
  202. package/node_modules/fake-indexeddb/build/cjs/FDBTransaction.js +20 -2
  203. package/node_modules/fake-indexeddb/build/cjs/lib/RecordStore.js +3 -3
  204. package/node_modules/fake-indexeddb/build/cjs/lib/binarySearchTree.js +11 -13
  205. package/node_modules/fake-indexeddb/build/cjs/lib/cmp.js +44 -14
  206. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/auto.js +54 -0
  207. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/binarySearchTree.js +413 -0
  208. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/fakeIndexedDB.js +1018 -0
  209. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/forceCloseDatabase.js +99 -0
  210. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/getAll.js +707 -0
  211. package/node_modules/fake-indexeddb/build/cjs/test/fakeIndexedDB/memoryLeaks.js +42 -0
  212. package/node_modules/fake-indexeddb/build/esm/FDBCursor.js +19 -18
  213. package/node_modules/fake-indexeddb/build/esm/FDBKeyRange.js +6 -6
  214. package/node_modules/fake-indexeddb/build/esm/FDBTransaction.js +20 -2
  215. package/node_modules/fake-indexeddb/build/esm/lib/RecordStore.js +3 -3
  216. package/node_modules/fake-indexeddb/build/esm/lib/binarySearchTree.js +11 -13
  217. package/node_modules/fake-indexeddb/build/esm/lib/cmp.js +41 -11
  218. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/auto.js +52 -0
  219. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/binarySearchTree.js +409 -0
  220. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/fakeIndexedDB.js +1014 -0
  221. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/forceCloseDatabase.js +95 -0
  222. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/getAll.js +703 -0
  223. package/node_modules/fake-indexeddb/build/esm/test/fakeIndexedDB/memoryLeaks.js +38 -0
  224. package/node_modules/fake-indexeddb/package.json +1 -1
  225. package/node_modules/file-type/node_modules/strtok3/LICENSE.txt +21 -0
  226. package/node_modules/file-type/node_modules/strtok3/README.md +591 -0
  227. package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
  228. package/node_modules/file-type/node_modules/strtok3/lib/AbortSignal.js +7 -0
  229. package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.d.ts +114 -0
  230. package/node_modules/file-type/node_modules/strtok3/lib/AbstractTokenizer.js +196 -0
  231. package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.d.ts +29 -0
  232. package/node_modules/file-type/node_modules/strtok3/lib/BlobTokenizer.js +56 -0
  233. package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
  234. package/node_modules/file-type/node_modules/strtok3/lib/BufferSizeError.js +27 -0
  235. package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.d.ts +29 -0
  236. package/node_modules/file-type/node_modules/strtok3/lib/BufferTokenizer.js +50 -0
  237. package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.d.ts +47 -0
  238. package/node_modules/file-type/node_modules/strtok3/lib/FileTokenizer.js +83 -0
  239. package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
  240. package/node_modules/file-type/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
  241. package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts +34 -0
  242. package/node_modules/file-type/node_modules/strtok3/lib/ReadStreamTokenizer.js +125 -0
  243. package/node_modules/file-type/node_modules/strtok3/lib/core.d.ts +41 -0
  244. package/node_modules/file-type/node_modules/strtok3/lib/core.js +69 -0
  245. package/node_modules/file-type/node_modules/strtok3/lib/index.d.ts +17 -0
  246. package/node_modules/file-type/node_modules/strtok3/lib/index.js +23 -0
  247. package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.d.ts +54 -0
  248. package/node_modules/file-type/node_modules/strtok3/lib/stream/AbstractStreamReader.js +73 -0
  249. package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.d.ts +6 -0
  250. package/node_modules/file-type/node_modules/strtok3/lib/stream/Deferred.js +10 -0
  251. package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.d.ts +10 -0
  252. package/node_modules/file-type/node_modules/strtok3/lib/stream/Errors.js +16 -0
  253. package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.d.ts +30 -0
  254. package/node_modules/file-type/node_modules/strtok3/lib/stream/StreamReader.js +104 -0
  255. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.d.ts +14 -0
  256. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamByobReader.js +29 -0
  257. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +19 -0
  258. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +67 -0
  259. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +14 -0
  260. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReader.js +13 -0
  261. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.d.ts +5 -0
  262. package/node_modules/file-type/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +19 -0
  263. package/node_modules/file-type/node_modules/strtok3/lib/stream/index.d.ts +6 -0
  264. package/node_modules/file-type/node_modules/strtok3/lib/stream/index.js +5 -0
  265. package/node_modules/file-type/node_modules/strtok3/lib/types.d.ts +146 -0
  266. package/node_modules/file-type/node_modules/strtok3/lib/types.js +1 -0
  267. package/node_modules/file-type/node_modules/strtok3/package.json +95 -0
  268. package/node_modules/file-type/package.json +28 -27
  269. package/node_modules/file-type/readme.md +32 -3
  270. package/node_modules/file-type/source/detectors/ebml.js +2 -2
  271. package/node_modules/file-type/source/detectors/png.js +1 -0
  272. package/node_modules/file-type/source/detectors/zip.js +71 -112
  273. package/node_modules/file-type/source/index.d.ts +18 -8
  274. package/node_modules/file-type/source/index.js +75 -49
  275. package/node_modules/file-type/source/index.test-d.ts +29 -21
  276. package/node_modules/file-type/source/supported.js +4 -0
  277. package/node_modules/file-type/source/tokens.js +2 -2
  278. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs +737 -686
  279. package/node_modules/markdown-it/dist/browser/markdown-it.esm.min.mjs.map +1 -1
  280. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js +8 -8
  281. package/node_modules/markdown-it/dist/browser/markdown-it.umd.min.js.map +1 -1
  282. package/node_modules/markdown-it/dist/markdown-it.cjs.js +660 -518
  283. package/node_modules/markdown-it/dist/markdown-it.cjs.js.map +1 -1
  284. package/node_modules/markdown-it/dist/markdown-it.d.mts +1 -0
  285. package/node_modules/markdown-it/dist/markdown-it.mjs +179 -124
  286. package/node_modules/markdown-it/dist/markdown-it.mjs.map +1 -1
  287. package/node_modules/markdown-it/package.json +11 -11
  288. package/node_modules/matrix-js-sdk/CHANGELOG.md +23 -0
  289. package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts +3 -1
  290. package/node_modules/matrix-js-sdk/lib/@types/PushRules.d.ts.map +1 -1
  291. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js +2 -0
  292. package/node_modules/matrix-js-sdk/lib/@types/PushRules.js.map +1 -1
  293. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts +1 -0
  294. package/node_modules/matrix-js-sdk/lib/@types/event.d.ts.map +1 -1
  295. package/node_modules/matrix-js-sdk/lib/@types/event.js.map +1 -1
  296. package/node_modules/matrix-js-sdk/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
  297. package/node_modules/matrix-js-sdk/lib/client.d.ts +88 -37
  298. package/node_modules/matrix-js-sdk/lib/client.d.ts.map +1 -1
  299. package/node_modules/matrix-js-sdk/lib/client.js +72 -47
  300. package/node_modules/matrix-js-sdk/lib/client.js.map +1 -1
  301. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts +3 -3
  302. package/node_modules/matrix-js-sdk/lib/crypto-api/index.d.ts.map +1 -1
  303. package/node_modules/matrix-js-sdk/lib/crypto-api/index.js.map +1 -1
  304. package/node_modules/matrix-js-sdk/lib/embedded.d.ts +17 -1
  305. package/node_modules/matrix-js-sdk/lib/embedded.d.ts.map +1 -1
  306. package/node_modules/matrix-js-sdk/lib/embedded.js +46 -1
  307. package/node_modules/matrix-js-sdk/lib/embedded.js.map +1 -1
  308. package/node_modules/matrix-js-sdk/lib/errors.d.ts +1 -1
  309. package/node_modules/matrix-js-sdk/lib/errors.d.ts.map +1 -1
  310. package/node_modules/matrix-js-sdk/lib/errors.js +2 -2
  311. package/node_modules/matrix-js-sdk/lib/errors.js.map +1 -1
  312. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts +7 -1
  313. package/node_modules/matrix-js-sdk/lib/http-api/fetch.d.ts.map +1 -1
  314. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js +14 -5
  315. package/node_modules/matrix-js-sdk/lib/http-api/fetch.js.map +1 -1
  316. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts +34 -8
  317. package/node_modules/matrix-js-sdk/lib/http-api/interface.d.ts.map +1 -1
  318. package/node_modules/matrix-js-sdk/lib/http-api/interface.js +10 -3
  319. package/node_modules/matrix-js-sdk/lib/http-api/interface.js.map +1 -1
  320. package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts +30 -11
  321. package/node_modules/matrix-js-sdk/lib/http-api/refresh.d.ts.map +1 -1
  322. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js +72 -5
  323. package/node_modules/matrix-js-sdk/lib/http-api/refresh.js.map +1 -1
  324. package/node_modules/matrix-js-sdk/lib/http-api/utils.js +1 -3
  325. package/node_modules/matrix-js-sdk/lib/matrix.d.ts +1 -1
  326. package/node_modules/matrix-js-sdk/lib/matrix.d.ts.map +1 -1
  327. package/node_modules/matrix-js-sdk/lib/matrix.js.map +1 -1
  328. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.d.ts.map +1 -1
  329. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js +20 -6
  330. package/node_modules/matrix-js-sdk/lib/matrixrtc/CallMembership.js.map +1 -1
  331. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts +5 -0
  332. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.d.ts.map +1 -1
  333. package/node_modules/matrix-js-sdk/lib/matrixrtc/IMembershipManager.js.map +1 -1
  334. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts +27 -1
  335. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -1
  336. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js +58 -36
  337. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
  338. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js +1 -1
  339. package/node_modules/matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
  340. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts +76 -0
  341. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.d.ts.map +1 -1
  342. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js +264 -47
  343. package/node_modules/matrix-js-sdk/lib/matrixrtc/MembershipManager.js.map +1 -1
  344. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts +1 -1
  345. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.d.ts.map +1 -1
  346. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js +1 -1
  347. package/node_modules/matrix-js-sdk/lib/matrixrtc/index.js.map +1 -1
  348. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts +8 -0
  349. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.d.ts.map +1 -1
  350. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js +10 -0
  351. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/common.js.map +1 -1
  352. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts +1 -1
  353. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.d.ts.map +1 -1
  354. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js +1 -1
  355. package/node_modules/matrix-js-sdk/lib/matrixrtc/membershipData/index.js.map +1 -1
  356. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts +104 -11
  357. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.d.ts.map +1 -1
  358. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js +263 -19
  359. package/node_modules/matrix-js-sdk/lib/matrixrtc/types.js.map +1 -1
  360. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts +22 -1
  361. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.d.ts.map +1 -1
  362. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js +38 -0
  363. package/node_modules/matrix-js-sdk/lib/matrixrtc/utils.js.map +1 -1
  364. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts +7 -0
  365. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.d.ts.map +1 -1
  366. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js +27 -0
  367. package/node_modules/matrix-js-sdk/lib/models/room-sticky-events.js.map +1 -1
  368. package/node_modules/matrix-js-sdk/lib/models/thread.d.ts.map +1 -1
  369. package/node_modules/matrix-js-sdk/lib/models/thread.js +8 -0
  370. package/node_modules/matrix-js-sdk/lib/models/thread.js.map +1 -1
  371. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js +1 -1
  372. package/node_modules/matrix-js-sdk/lib/oauth/authorize.js.map +1 -1
  373. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts +3 -5
  374. package/node_modules/matrix-js-sdk/lib/oauth/index.d.ts.map +1 -1
  375. package/node_modules/matrix-js-sdk/lib/oauth/index.js +7 -7
  376. package/node_modules/matrix-js-sdk/lib/oauth/index.js.map +1 -1
  377. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts +10 -4
  378. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.d.ts.map +1 -1
  379. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js +34 -24
  380. package/node_modules/matrix-js-sdk/lib/oauth/tokenRefresher.js.map +1 -1
  381. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts +10 -11
  382. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.d.ts.map +1 -1
  383. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js +26 -25
  384. package/node_modules/matrix-js-sdk/lib/receipt-accumulator.js.map +1 -1
  385. package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts +71 -0
  386. package/node_modules/matrix-js-sdk/lib/room-summary-api.d.ts.map +1 -0
  387. package/node_modules/matrix-js-sdk/lib/room-summary-api.js +82 -0
  388. package/node_modules/matrix-js-sdk/lib/room-summary-api.js.map +1 -0
  389. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts +7 -0
  390. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.d.ts.map +1 -1
  391. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js +41 -25
  392. package/node_modules/matrix-js-sdk/lib/rust-crypto/backup.js.map +1 -1
  393. package/node_modules/matrix-js-sdk/lib/rust-crypto/rust-crypto.js +1 -7
  394. package/node_modules/matrix-js-sdk/lib/sync.d.ts.map +1 -1
  395. package/node_modules/matrix-js-sdk/lib/sync.js +6 -1
  396. package/node_modules/matrix-js-sdk/lib/sync.js.map +1 -1
  397. package/node_modules/matrix-js-sdk/package.json +6 -6
  398. package/node_modules/matrix-js-sdk/src/@types/PushRules.ts +2 -0
  399. package/node_modules/matrix-js-sdk/src/@types/event.ts +1 -1
  400. package/node_modules/matrix-js-sdk/src/@types/matrix-sdk-crypto-wasm.d.ts +15 -12
  401. package/node_modules/matrix-js-sdk/src/client.ts +105 -62
  402. package/node_modules/matrix-js-sdk/src/crypto-api/index.ts +3 -3
  403. package/node_modules/matrix-js-sdk/src/embedded.ts +61 -2
  404. package/node_modules/matrix-js-sdk/src/errors.ts +2 -1
  405. package/node_modules/matrix-js-sdk/src/http-api/fetch.ts +14 -5
  406. package/node_modules/matrix-js-sdk/src/http-api/interface.ts +36 -8
  407. package/node_modules/matrix-js-sdk/src/http-api/refresh.ts +101 -17
  408. package/node_modules/matrix-js-sdk/src/http-api/utils.ts +1 -5
  409. package/node_modules/matrix-js-sdk/src/matrix.ts +1 -1
  410. package/node_modules/matrix-js-sdk/src/matrixrtc/CallMembership.ts +22 -4
  411. package/node_modules/matrix-js-sdk/src/matrixrtc/IMembershipManager.ts +6 -0
  412. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSession.ts +72 -49
  413. package/node_modules/matrix-js-sdk/src/matrixrtc/MatrixRTCSessionManager.ts +1 -1
  414. package/node_modules/matrix-js-sdk/src/matrixrtc/MembershipManager.ts +284 -61
  415. package/node_modules/matrix-js-sdk/src/matrixrtc/index.ts +7 -1
  416. package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/common.ts +12 -0
  417. package/node_modules/matrix-js-sdk/src/matrixrtc/membershipData/index.ts +1 -1
  418. package/node_modules/matrix-js-sdk/src/matrixrtc/types.ts +351 -23
  419. package/node_modules/matrix-js-sdk/src/matrixrtc/utils.ts +54 -1
  420. package/node_modules/matrix-js-sdk/src/models/room-sticky-events.ts +26 -1
  421. package/node_modules/matrix-js-sdk/src/models/thread.ts +9 -0
  422. package/node_modules/matrix-js-sdk/src/oauth/authorize.ts +1 -1
  423. package/node_modules/matrix-js-sdk/src/oauth/index.ts +7 -8
  424. package/node_modules/matrix-js-sdk/src/oauth/tokenRefresher.ts +15 -5
  425. package/node_modules/matrix-js-sdk/src/receipt-accumulator.ts +30 -26
  426. package/node_modules/matrix-js-sdk/src/room-summary-api.ts +114 -0
  427. package/node_modules/matrix-js-sdk/src/rust-crypto/backup.ts +46 -33
  428. package/node_modules/matrix-js-sdk/src/rust-crypto/rust-crypto.ts +1 -7
  429. package/node_modules/matrix-js-sdk/src/sync.ts +9 -1
  430. package/node_modules/music-metadata/README.md +125 -37
  431. package/node_modules/music-metadata/lib/ParseError.d.ts +10 -3
  432. package/node_modules/music-metadata/lib/ParseError.js +2 -0
  433. package/node_modules/music-metadata/lib/ParserFactory.d.ts +1 -1
  434. package/node_modules/music-metadata/lib/ParserFactory.js +20 -8
  435. package/node_modules/music-metadata/lib/aiff/AiffParser.d.ts +1 -0
  436. package/node_modules/music-metadata/lib/aiff/AiffParser.js +25 -17
  437. package/node_modules/music-metadata/lib/aiff/AiffToken.d.ts +9 -3
  438. package/node_modules/music-metadata/lib/aiff/AiffToken.js +10 -0
  439. package/node_modules/music-metadata/lib/apev2/APEv2Parser.d.ts +4 -3
  440. package/node_modules/music-metadata/lib/apev2/APEv2Parser.js +6 -30
  441. package/node_modules/music-metadata/lib/asf/AsfGuid.js +49 -49
  442. package/node_modules/music-metadata/lib/asf/AsfObject.d.ts +12 -6
  443. package/node_modules/music-metadata/lib/asf/AsfObject.js +201 -58
  444. package/node_modules/music-metadata/lib/asf/AsfParser.d.ts +4 -0
  445. package/node_modules/music-metadata/lib/asf/AsfParser.js +119 -27
  446. package/node_modules/music-metadata/lib/caf/CafLoader.d.ts +2 -0
  447. package/node_modules/music-metadata/lib/caf/CafLoader.js +8 -0
  448. package/node_modules/music-metadata/lib/caf/CafParser.d.ts +37 -0
  449. package/node_modules/music-metadata/lib/caf/CafParser.js +253 -0
  450. package/node_modules/music-metadata/lib/caf/CafTagMap.d.ts +8 -0
  451. package/node_modules/music-metadata/lib/caf/CafTagMap.js +38 -0
  452. package/node_modules/music-metadata/lib/caf/CafToken.d.ts +75 -0
  453. package/node_modules/music-metadata/lib/caf/CafToken.js +135 -0
  454. package/node_modules/music-metadata/lib/common/Allocation.d.ts +14 -0
  455. package/node_modules/music-metadata/lib/common/Allocation.js +70 -0
  456. package/node_modules/music-metadata/lib/common/BasicParser.d.ts +2 -0
  457. package/node_modules/music-metadata/lib/common/BasicParser.js +8 -0
  458. package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
  459. package/node_modules/music-metadata/lib/common/CaseInsensitiveTagMap.js +3 -3
  460. package/node_modules/music-metadata/lib/common/CombinedTagMapper.js +4 -3
  461. package/node_modules/music-metadata/lib/common/GenericTagMapper.d.ts +1 -1
  462. package/node_modules/music-metadata/lib/common/GenericTagMapper.js +4 -2
  463. package/node_modules/music-metadata/lib/common/GenericTagTypes.d.ts +2 -2
  464. package/node_modules/music-metadata/lib/common/MetadataCollector.d.ts +6 -5
  465. package/node_modules/music-metadata/lib/common/MetadataCollector.js +57 -30
  466. package/node_modules/music-metadata/lib/common/TrackInfo.d.ts +8 -0
  467. package/node_modules/music-metadata/lib/common/TrackInfo.js +68 -0
  468. package/node_modules/music-metadata/lib/common/Util.d.ts +1 -1
  469. package/node_modules/music-metadata/lib/common/Util.js +6 -12
  470. package/node_modules/music-metadata/lib/core.d.ts +1 -1
  471. package/node_modules/music-metadata/lib/core.js +10 -18
  472. package/node_modules/music-metadata/lib/dsdiff/DsdiffLoader.js +1 -1
  473. package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.d.ts +7 -3
  474. package/node_modules/music-metadata/lib/dsdiff/DsdiffParser.js +69 -33
  475. package/node_modules/music-metadata/lib/dsf/DsfParser.d.ts +4 -3
  476. package/node_modules/music-metadata/lib/dsf/DsfParser.js +1 -1
  477. package/node_modules/music-metadata/lib/ebml/EbmlIterator.d.ts +28 -19
  478. package/node_modules/music-metadata/lib/ebml/EbmlIterator.js +97 -67
  479. package/node_modules/music-metadata/lib/ebml/types.d.ts +36 -8
  480. package/node_modules/music-metadata/lib/ebml/types.js +2 -1
  481. package/node_modules/music-metadata/lib/flac/FlacParser.js +10 -18
  482. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.d.ts +1 -1
  483. package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +5 -1
  484. package/node_modules/music-metadata/lib/id3v2/AbstractID3Parser.js +1 -4
  485. package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.d.ts +5 -0
  486. package/node_modules/music-metadata/lib/id3v2/EmbeddedID3v2.js +29 -0
  487. package/node_modules/music-metadata/lib/id3v2/FrameParser.d.ts +5 -3
  488. package/node_modules/music-metadata/lib/id3v2/FrameParser.js +59 -33
  489. package/node_modules/music-metadata/lib/id3v2/ID3v2Parser.js +15 -8
  490. package/node_modules/music-metadata/lib/index.d.ts +2 -0
  491. package/node_modules/music-metadata/lib/index.js +8 -4
  492. package/node_modules/music-metadata/lib/matroska/MatroskaDtd.d.ts +630 -2
  493. package/node_modules/music-metadata/lib/matroska/MatroskaDtd.js +58 -40
  494. package/node_modules/music-metadata/lib/matroska/MatroskaParser.d.ts +4 -0
  495. package/node_modules/music-metadata/lib/matroska/MatroskaParser.js +211 -68
  496. package/node_modules/music-metadata/lib/matroska/types.d.ts +33 -131
  497. package/node_modules/music-metadata/lib/matroska/types.js +1 -18
  498. package/node_modules/music-metadata/lib/mp4/Atom.js +7 -0
  499. package/node_modules/music-metadata/lib/mp4/AtomToken.d.ts +17 -4
  500. package/node_modules/music-metadata/lib/mp4/AtomToken.js +124 -21
  501. package/node_modules/music-metadata/lib/mp4/MP4Parser.d.ts +12 -3
  502. package/node_modules/music-metadata/lib/mp4/MP4Parser.js +559 -242
  503. package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.d.ts +17 -0
  504. package/node_modules/music-metadata/lib/mpeg/AdtsFrameHeader.js +44 -0
  505. package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.d.ts +41 -0
  506. package/node_modules/music-metadata/lib/mpeg/MpegFrameHeader.js +84 -0
  507. package/node_modules/music-metadata/lib/mpeg/MpegParser.d.ts +11 -24
  508. package/node_modules/music-metadata/lib/mpeg/MpegParser.js +77 -337
  509. package/node_modules/music-metadata/lib/musepack/MusepackConentError.d.ts +4 -3
  510. package/node_modules/music-metadata/lib/musepack/sv7/BitReader.js +3 -2
  511. package/node_modules/music-metadata/lib/musepack/sv7/MpcSv7Parser.js +3 -6
  512. package/node_modules/music-metadata/lib/musepack/sv8/MpcSv8Parser.js +1 -4
  513. package/node_modules/music-metadata/lib/musepack/sv8/StreamVersion8.js +1 -0
  514. package/node_modules/music-metadata/lib/ogg/OggLoader.js +1 -1
  515. package/node_modules/music-metadata/lib/ogg/OggParser.d.ts +4 -3
  516. package/node_modules/music-metadata/lib/ogg/OggParser.js +54 -9
  517. package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.d.ts +14 -0
  518. package/node_modules/music-metadata/lib/ogg/OggStreamMetadata.js +27 -0
  519. package/node_modules/music-metadata/lib/ogg/OggToken.d.ts +1 -0
  520. package/node_modules/music-metadata/lib/ogg/OggToken.js +3 -1
  521. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.d.ts +3 -1
  522. package/node_modules/music-metadata/lib/ogg/flac/FlacStream.js +21 -3
  523. package/node_modules/music-metadata/lib/ogg/opus/Opus.d.ts +4 -3
  524. package/node_modules/music-metadata/lib/ogg/opus/Opus.js +1 -0
  525. package/node_modules/music-metadata/lib/ogg/opus/OpusStream.js +4 -2
  526. package/node_modules/music-metadata/lib/ogg/speex/SpeexStream.js +2 -1
  527. package/node_modules/music-metadata/lib/ogg/theora/Theora.d.ts +5 -0
  528. package/node_modules/music-metadata/lib/ogg/theora/Theora.js +7 -2
  529. package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.d.ts +5 -2
  530. package/node_modules/music-metadata/lib/ogg/theora/TheoraStream.js +43 -3
  531. package/node_modules/music-metadata/lib/ogg/vorbis/Vorbis.js +4 -3
  532. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.d.ts +11 -0
  533. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisDecoder.js +29 -0
  534. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.d.ts +6 -4
  535. package/node_modules/music-metadata/lib/ogg/vorbis/VorbisStream.js +24 -18
  536. package/node_modules/music-metadata/lib/riff/RiffChunk.js +3 -0
  537. package/node_modules/music-metadata/lib/type.d.ts +49 -6
  538. package/node_modules/music-metadata/lib/type.js +22 -1
  539. package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +4 -3
  540. package/node_modules/music-metadata/lib/wav/WaveChunk.js +2 -0
  541. package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +0 -1
  542. package/node_modules/music-metadata/lib/wav/WaveParser.js +21 -23
  543. package/node_modules/music-metadata/lib/wavpack/WavPackParser.d.ts +4 -3
  544. package/node_modules/music-metadata/lib/wavpack/WavPackParser.js +6 -6
  545. package/node_modules/music-metadata/package.json +26 -22
  546. package/node_modules/strtok3/LICENSE.txt +21 -21
  547. package/node_modules/strtok3/README.md +712 -399
  548. package/node_modules/strtok3/lib/AbortSignal.d.ts +2 -0
  549. package/node_modules/strtok3/lib/AbortSignal.js +7 -0
  550. package/node_modules/strtok3/lib/AbstractTokenizer.d.ts +40 -2
  551. package/node_modules/strtok3/lib/AbstractTokenizer.js +101 -16
  552. package/node_modules/strtok3/lib/BlobTokenizer.d.ts +1 -1
  553. package/node_modules/strtok3/lib/BlobTokenizer.js +14 -11
  554. package/node_modules/strtok3/lib/BufferSizeError.d.ts +19 -0
  555. package/node_modules/strtok3/lib/BufferSizeError.js +27 -0
  556. package/node_modules/strtok3/lib/BufferTokenizer.d.ts +1 -1
  557. package/node_modules/strtok3/lib/BufferTokenizer.js +7 -9
  558. package/node_modules/strtok3/lib/FileTokenizer.d.ts +13 -3
  559. package/node_modules/strtok3/lib/FileTokenizer.js +29 -7
  560. package/node_modules/strtok3/lib/NotRegularFileError.d.ts +5 -0
  561. package/node_modules/strtok3/lib/NotRegularFileError.js +8 -0
  562. package/node_modules/strtok3/lib/ReadStreamTokenizer.js +32 -9
  563. package/node_modules/strtok3/lib/TokenizerBoundaryError.d.ts +7 -0
  564. package/node_modules/strtok3/lib/TokenizerBoundaryError.js +10 -0
  565. package/node_modules/strtok3/lib/TokenizerView.d.ts +9 -0
  566. package/node_modules/strtok3/lib/TokenizerView.js +184 -0
  567. package/node_modules/strtok3/lib/core.d.ts +10 -6
  568. package/node_modules/strtok3/lib/core.js +16 -22
  569. package/node_modules/strtok3/lib/index.d.ts +5 -4
  570. package/node_modules/strtok3/lib/index.js +3 -2
  571. package/node_modules/strtok3/lib/isRandomAccessTokenizer.d.ts +6 -0
  572. package/node_modules/strtok3/lib/isRandomAccessTokenizer.js +10 -0
  573. package/node_modules/strtok3/lib/stream/AbstractStreamReader.js +5 -3
  574. package/node_modules/strtok3/lib/stream/Errors.js +3 -3
  575. package/node_modules/strtok3/lib/stream/StreamReader.d.ts +4 -3
  576. package/node_modules/strtok3/lib/stream/StreamReader.js +46 -25
  577. package/node_modules/strtok3/lib/stream/WebStreamByobReader.js +5 -3
  578. package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +1 -1
  579. package/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +9 -4
  580. package/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +13 -3
  581. package/node_modules/strtok3/lib/stream/WebStreamReader.js +1 -1
  582. package/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +1 -1
  583. package/node_modules/strtok3/lib/stream/index.d.ts +1 -1
  584. package/node_modules/strtok3/lib/types.d.ts +25 -1
  585. package/node_modules/strtok3/package.json +97 -94
  586. package/node_modules/typebox/build/format/duration.d.mts +2 -2
  587. package/node_modules/typebox/build/format/duration.mjs +2 -2
  588. package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
  589. package/node_modules/typebox/build/format/idn_email.mjs +1 -0
  590. package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
  591. package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
  592. package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
  593. package/node_modules/typebox/build/format/ipv4.mjs +2 -2
  594. package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
  595. package/node_modules/typebox/build/format/ipv6.mjs +1 -1
  596. package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
  597. package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
  598. package/node_modules/typebox/build/schema/build.mjs +1 -0
  599. package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
  600. package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
  601. package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
  602. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
  603. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
  604. package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
  605. package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
  606. package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
  607. package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
  608. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
  609. package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
  610. package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
  611. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
  612. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
  613. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
  614. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
  615. package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
  616. package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
  617. package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
  618. package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
  619. package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
  620. package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
  621. package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
  622. package/node_modules/typebox/build/system/memory/create.mjs +18 -13
  623. package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
  624. package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
  625. package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
  626. package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
  627. package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
  628. package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
  629. package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
  630. package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
  631. package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
  632. package/node_modules/typebox/build/system/memory/update.mjs +43 -16
  633. package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
  634. package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
  635. package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
  636. package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
  637. package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
  638. package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
  639. package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
  640. package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
  641. package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
  642. package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
  643. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
  644. package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
  645. package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
  646. package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
  647. package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
  648. package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
  649. package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
  650. package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
  651. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
  652. package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
  653. package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
  654. package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
  655. package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
  656. package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
  657. package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
  658. package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
  659. package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
  660. package/node_modules/typebox/package.json +1 -1
  661. package/node_modules/typebox/readme.md +1 -1
  662. package/node_modules/zod/package.json +1 -1
  663. package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
  664. package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
  665. package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
  666. package/node_modules/zod/src/v4/core/compile.ts +9 -0
  667. package/node_modules/zod/src/v4/core/schemas.ts +35 -1
  668. package/node_modules/zod/src/v4/core/util.ts +13 -0
  669. package/node_modules/zod/src/v4/core/versions.ts +1 -1
  670. package/node_modules/zod/v4/core/compile.cjs +8 -0
  671. package/node_modules/zod/v4/core/compile.js +8 -0
  672. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  673. package/node_modules/zod/v4/core/schemas.d.cts +3 -1
  674. package/node_modules/zod/v4/core/schemas.d.ts +3 -1
  675. package/node_modules/zod/v4/core/schemas.js +30 -0
  676. package/node_modules/zod/v4/core/util.cjs +15 -0
  677. package/node_modules/zod/v4/core/util.d.cts +2 -0
  678. package/node_modules/zod/v4/core/util.d.ts +2 -0
  679. package/node_modules/zod/v4/core/util.js +14 -0
  680. package/node_modules/zod/v4/core/versions.cjs +1 -1
  681. package/node_modules/zod/v4/core/versions.js +1 -1
  682. package/openclaw.plugin.json +11 -0
  683. package/package.json +11 -11
  684. package/dist/.setup/channel.runtime-DaGbm27q.mjs +0 -74
  685. package/dist/.setup/device-health-DnKAXW1v.mjs +0 -20
  686. package/dist/.setup/inbound-dedupe-CZnOq0ja.mjs +0 -47
  687. package/dist/.setup/setup-plugin-api-SO1hdrsT.mjs +0 -2
  688. package/node_modules/music-metadata/node_modules/content-type/LICENSE +0 -22
  689. package/node_modules/music-metadata/node_modules/content-type/README.md +0 -71
  690. package/node_modules/music-metadata/node_modules/content-type/dist/index.d.ts +0 -46
  691. package/node_modules/music-metadata/node_modules/content-type/dist/index.js +0 -176
  692. package/node_modules/music-metadata/node_modules/content-type/dist/index.js.map +0 -1
  693. package/node_modules/music-metadata/node_modules/content-type/package.json +0 -52
  694. package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
  695. package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
@@ -2,6 +2,7 @@ import { textDecode } from '@borewit/text-codec';
2
2
  import initDebug from 'debug';
3
3
  import * as Token from 'token-types';
4
4
  import { uint8ArrayToHex } from 'uint8array-extras';
5
+ import { readToken, validateAllocation } from '../common/Allocation.js';
5
6
  import { BasicParser } from '../common/BasicParser.js';
6
7
  import { Genres } from '../id3v1/ID3v1Parser.js';
7
8
  import { TrackType } from '../type.js';
@@ -10,6 +11,8 @@ import * as AtomToken from './AtomToken.js';
10
11
  import { ChapterTrackReferenceBox, Mp4ContentError } from './AtomToken.js';
11
12
  const debug = initDebug('music-metadata:parser:MP4');
12
13
  const tagFormat = 'iTunes';
14
+ const maxChapterCount = 1_000;
15
+ const maxChapterTitleBytes = 64 * 1024;
13
16
  const encoderDict = {
14
17
  raw: {
15
18
  lossy: false,
@@ -72,13 +75,16 @@ const encoderDict = {
72
75
  function distinct(value, index, self) {
73
76
  return self.indexOf(value) === index;
74
77
  }
78
+ /** Chapter offsets can be revisited even when the total input size is unknown. */
79
+ function supportsSeeking(tokenizer) {
80
+ return tokenizer.supportsRandomAccess() && 'setPosition' in tokenizer && typeof tokenizer.setPosition === 'function';
81
+ }
75
82
  /**
76
83
  * Determine if a track carries audio.
77
84
  *
78
85
  * Ref: ISO/IEC 14496-12, 8.5.2: the sample entries in a sample description box are track-type specific,
79
- * selected by the handler type of the enclosing track. Only an audio track holds an AudioSampleEntry, so
80
- * only such a track may be described by a sound sample description; `isAudio()` treats both the 'soun'
81
- * and 'audi' handler types as audio.
86
+ * selected by the handler type of the enclosing track. Only an audio track holds an AudioSampleEntry.
87
+ * Both the 'soun' and 'audi' handler types are treated as audio.
82
88
  *
83
89
  * Falls back to the sample description when no handler box was found, preserving the previous behavior.
84
90
  */
@@ -87,8 +93,8 @@ function isAudioTrack(track) {
87
93
  if (!ssd) {
88
94
  return false;
89
95
  }
90
- if (track.isAudio) {
91
- return track.isAudio();
96
+ if (track.handler) {
97
+ return track.handler.handlerType === 'soun' || track.handler.handlerType === 'audi';
92
98
  }
93
99
  return !!ssd.description && ssd.description.numAudioChannels > 0;
94
100
  }
@@ -111,87 +117,6 @@ function isAudioTrack(track) {
111
117
  * https://wiki.multimedia.cx/index.php/QuickTime_container
112
118
  */
113
119
  export class MP4Parser extends BasicParser {
114
- constructor() {
115
- super(...arguments);
116
- this.tracks = new Map();
117
- this.hasVideoTrack = false;
118
- this.hasAudioTrack = true;
119
- this.atomParsers = {
120
- /**
121
- * Parse movie header (mvhd) atom
122
- * Ref: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-56313
123
- */
124
- mvhd: async (len) => {
125
- const mvhd = await this.readToken(new AtomToken.MvhdAtom(len));
126
- this.metadata.setFormat('creationTime', mvhd.creationTime);
127
- this.metadata.setFormat('modificationTime', mvhd.modificationTime);
128
- },
129
- chap: async (len) => {
130
- const td = this.getTrackDescription();
131
- const trackIds = [];
132
- while (len >= Token.UINT32_BE.len) {
133
- trackIds.push(await this.tokenizer.readNumber(Token.UINT32_BE));
134
- len -= Token.UINT32_BE.len;
135
- }
136
- td.chapterList = trackIds;
137
- },
138
- /**
139
- * Parse mdat atom.
140
- * Will scan for chapters
141
- */
142
- mdat: async (len) => {
143
- if (this.options.includeChapters) {
144
- const trackWithChapters = [...this.tracks.values()].filter(track => track.chapterList);
145
- if (trackWithChapters.length === 1) {
146
- const chapterTrackIds = trackWithChapters[0].chapterList;
147
- const chapterTracks = [...this.tracks.values()].filter(track => chapterTrackIds.indexOf(track.header.trackId) !== -1);
148
- if (chapterTracks.length === 1) {
149
- return this.parseChapterTrack(chapterTracks[0], trackWithChapters[0], len);
150
- }
151
- }
152
- }
153
- await this.tokenizer.ignore(len);
154
- },
155
- ftyp: async (len) => {
156
- if (len < 8 || len % AtomToken.ftyp.len !== 0) {
157
- throw new Mp4ContentError(`Invalid ftyp payload length: ${len}`);
158
- }
159
- const types = [];
160
- while (len > 0) {
161
- const ftype = await this.readToken(AtomToken.ftyp);
162
- len -= AtomToken.ftyp.len;
163
- const value = ftype.type.replace(/\W/g, '');
164
- if (value.length > 0) {
165
- types.push(value); // unshift for backward compatibility
166
- }
167
- }
168
- debug(`ftyp: ${types.join('/')}`);
169
- const x = types.filter(distinct).join('/');
170
- this.metadata.setFormat('container', x);
171
- },
172
- /**
173
- * Parse sample description atom
174
- */
175
- stsd: async (len) => {
176
- const stsd = await this.readToken(new AtomToken.StsdAtom(len));
177
- const trackDescription = this.getTrackDescription();
178
- trackDescription.soundSampleDescription = stsd.table.map(dfEntry => this.parseSoundSampleDescription(dfEntry));
179
- },
180
- /**
181
- * Parse sample-sizes atom ('stsz')
182
- */
183
- stsz: async (len) => {
184
- const stsz = await this.readToken(new AtomToken.StszAtom(len));
185
- const td = this.getTrackDescription();
186
- td.sampleSize = stsz.sampleSize;
187
- td.sampleSizeTable = stsz.entries;
188
- },
189
- date: async (len) => {
190
- const date = await this.readToken(new Token.StringType(len, 'utf-8'));
191
- await this.addTag('date', date);
192
- }
193
- };
194
- }
195
120
  static read_BE_Integer(array, signed) {
196
121
  const integerType = (signed ? 'INT' : 'UINT') + array.length * 8 + (array.length > 1 ? '_BE' : '');
197
122
  const token = Token[integerType];
@@ -203,18 +128,30 @@ export class MP4Parser extends BasicParser {
203
128
  // Metadata and sample tables are buffered; media data is skipped separately.
204
129
  // A bound is also necessary for streams whose total size is unknown.
205
130
  validatePayloadLength(length) {
206
- if (!Number.isSafeInteger(length) || length < 0 || length > 64 * 1024 * 1024) {
207
- throw new Mp4ContentError(`Atom payload exceeds the 64 MiB buffering limit: ${length}`);
208
- }
131
+ validateAllocation(length, this.options, message => new Mp4ContentError(message));
209
132
  }
210
- async readToken(token) {
211
- this.validatePayloadLength(token.len);
212
- return this.tokenizer.readToken(token);
133
+ async readToken(token, position) {
134
+ return readToken(this.tokenizer, token, this.options, position, message => new Mp4ContentError(message));
213
135
  }
136
+ movieHeader;
137
+ trackDefaults = new Map();
138
+ tracks = new Map();
139
+ mediaDataRanges = [];
140
+ streamedChapters = new Map();
141
+ streamedChapterCount;
142
+ neroChapters = [];
143
+ hasVideoTrack = false;
144
+ hasAudioTrack = false;
214
145
  async parse() {
215
146
  this.hasVideoTrack = false;
216
- this.hasAudioTrack = true;
147
+ this.hasAudioTrack = false;
217
148
  this.tracks.clear();
149
+ this.mediaDataRanges = [];
150
+ this.streamedChapters.clear();
151
+ this.streamedChapterCount = undefined;
152
+ this.neroChapters = [];
153
+ this.trackDefaults.clear();
154
+ this.movieHeader = undefined;
218
155
  let remainingFileSize = this.tokenizer.fileInfo.size ?? Number.POSITIVE_INFINITY;
219
156
  while (remainingFileSize > 0) {
220
157
  try {
@@ -240,34 +177,39 @@ export class MP4Parser extends BasicParser {
240
177
  const rootAtom = await Atom.readAtom(this.tokenizer, (atom, remaining) => this.handleAtom(atom, remaining), null, remainingFileSize);
241
178
  remainingFileSize = rootAtom.header.length === 0n ? 0 : remainingFileSize - Number(rootAtom.header.length);
242
179
  }
180
+ if (this.mediaDataRanges.length > 0 && supportsSeeking(this.tokenizer)) {
181
+ // Track references and sample tables may follow the media data in a trailing moov box.
182
+ const tokenizer = this.tokenizer;
183
+ const position = tokenizer.position;
184
+ try {
185
+ await this.parseChapters(this.mediaDataRanges);
186
+ }
187
+ finally {
188
+ tokenizer.setPosition(position);
189
+ }
190
+ }
191
+ if (this.streamedChapterCount !== undefined && this.streamedChapters.size !== this.streamedChapterCount) {
192
+ if (this.neroChapters.length === 0) {
193
+ throw new Mp4ContentError('Chapter chunk exceeding media data bounds');
194
+ }
195
+ this.addWarning('Cannot read chapter track: Chapter chunk exceeding media data bounds');
196
+ }
197
+ if (this.options.includeChapters &&
198
+ this.neroChapters.length > 0 &&
199
+ !this.metadata.format.chapters?.some(chapter => chapter.title)) {
200
+ this.metadata.setFormat('chapters', this.neroChapters);
201
+ }
243
202
  // Post process metadata
244
203
  const formatList = [];
245
204
  this.tracks.forEach(track => {
246
205
  const trackFormats = [];
247
- const trackIsAudio = isAudioTrack(track);
248
- track.soundSampleDescription.forEach(ssd => {
249
- const streamInfo = {};
206
+ // Sample descriptions are alternative encodings of one track, not separate tracks.
207
+ for (const ssd of track.soundSampleDescription) {
250
208
  const encoderInfo = encoderDict[ssd.dataFormat];
251
209
  if (encoderInfo) {
252
210
  trackFormats.push(encoderInfo.format);
253
- streamInfo.codecName = encoderInfo.format;
254
211
  }
255
- else {
256
- streamInfo.codecName = `<${ssd.dataFormat}>`;
257
- }
258
- if (trackIsAudio && ssd.description) {
259
- const { description } = ssd;
260
- if (description.sampleRate > 0) {
261
- streamInfo.type = TrackType.audio;
262
- streamInfo.audio = {
263
- samplingFrequency: description.sampleRate,
264
- bitDepth: description.sampleSize,
265
- channels: description.numAudioChannels
266
- };
267
- }
268
- }
269
- this.metadata.addStreamInfo(streamInfo);
270
- });
212
+ }
271
213
  if (trackFormats.length >= 1) {
272
214
  formatList.push(trackFormats.join('/'));
273
215
  }
@@ -276,50 +218,19 @@ export class MP4Parser extends BasicParser {
276
218
  this.metadata.setFormat('codec', formatList.filter(distinct).join('+'));
277
219
  }
278
220
  const audioTracks = [...this.tracks.values()].filter(isAudioTrack);
279
- // Calculate duration and bitrate of audio tracks
221
+ // Both audio and video use the same sample tables and fragment timing.
222
+ for (const track of this.tracks.values()) {
223
+ this.calculateTrackTiming(track);
224
+ }
280
225
  for (const audioTrack of audioTracks) {
281
- if (audioTrack.media.header && audioTrack.media.header.timeScale > 0) {
282
- audioTrack.sampleRate = audioTrack.media.header.timeScale;
283
- if (audioTrack.media.header.duration > 0) {
284
- debug('Using duration defined on audio track');
285
- audioTrack.samples = audioTrack.media.header.duration;
286
- audioTrack.duration = audioTrack.samples / audioTrack.sampleRate;
287
- }
288
- if (audioTrack.fragments.length > 0) {
289
- debug('Calculate duration defined in track fragments');
290
- let totalTimeUnits = 0;
291
- audioTrack.sizeInBytes = 0;
292
- for (const fragment of audioTrack.fragments) {
293
- for (const sample of fragment.trackRun.samples) {
294
- const dur = sample.sampleDuration ?? fragment.header.defaultSampleDuration ?? 0;
295
- const size = sample.sampleSize ?? fragment.header.defaultSampleSize ?? 0;
296
- if (dur === 0) {
297
- throw new Error('Missing sampleDuration and no defaultSampleDuration in track fragment header');
298
- }
299
- if (size === 0) {
300
- throw new Error('Missing sampleSize and no defaultSampleSize in track fragment header');
301
- }
302
- totalTimeUnits += dur;
303
- audioTrack.sizeInBytes += size;
304
- }
305
- }
306
- if (!audioTrack.samples) {
307
- audioTrack.samples = totalTimeUnits;
308
- }
309
- if (!audioTrack.duration) {
310
- audioTrack.duration = totalTimeUnits / audioTrack.sampleRate;
311
- }
312
- }
313
- else if (audioTrack.sampleSizeTable.length > 0) {
314
- audioTrack.sizeInBytes = audioTrack.sampleSizeTable.reduce((sum, n) => sum + n, 0);
315
- }
316
- }
317
226
  const ssd = audioTrack.soundSampleDescription[0];
318
227
  if (ssd.description && audioTrack.media.header) {
319
228
  this.metadata.setFormat('sampleRate', ssd.description.sampleRate);
320
229
  this.metadata.setFormat('bitsPerSample', ssd.description.sampleSize);
321
230
  this.metadata.setFormat('numberOfChannels', ssd.description.numAudioChannels);
322
- if (audioTrack.media.header.timeScale === 0 && audioTrack.timeToSampleTable.length > 0) {
231
+ if (audioTrack.media.header.timeScale === 0 &&
232
+ audioTrack.timeToSampleTable.length > 0 &&
233
+ ssd.description.sampleRate > 0) {
323
234
  const totalSampleSize = audioTrack.timeToSampleTable
324
235
  .map(ttstEntry => ttstEntry.count * ttstEntry.duration)
325
236
  .reduce((total, sampleSize) => total + sampleSize);
@@ -340,8 +251,23 @@ export class MP4Parser extends BasicParser {
340
251
  }
341
252
  }
342
253
  }
343
- this.metadata.setFormat('hasAudio', this.hasAudioTrack);
254
+ for (const track of this.tracks.values()) {
255
+ this.metadata.addStreamInfo(this.getTrackInfo(track));
256
+ }
257
+ this.metadata.setFormat('hasAudio', this.hasAudioTrack || audioTracks.length > 0);
344
258
  this.metadata.setFormat('hasVideo', this.hasVideoTrack);
259
+ const movieDuration = this.getDuration(this.movieHeader);
260
+ if (movieDuration !== undefined) {
261
+ this.metadata.setFormat('containerDuration', movieDuration);
262
+ }
263
+ else {
264
+ const endTimes = [...this.tracks.values()]
265
+ .filter(track => isAudioTrack(track) || track.handler?.handlerType === 'vide')
266
+ .map(track => track.endTime);
267
+ if (endTimes.length > 0 && endTimes.every(endTime => endTime !== undefined)) {
268
+ this.metadata.setFormat('containerDuration', endTimes.reduce((maximum, endTime) => Math.max(maximum, endTime), 0));
269
+ }
270
+ }
345
271
  }
346
272
  async handleAtom(atom, remaining) {
347
273
  if (atom.parent) {
@@ -364,6 +290,23 @@ export class MP4Parser extends BasicParser {
364
290
  }
365
291
  }
366
292
  }
293
+ // Track-specific boxes are handled by parseTrackBox's local track context.
294
+ // An orphan box must not modify whichever track happened to be registered last.
295
+ if (['chap', 'stsd', 'stsz'].includes(atom.header.name)) {
296
+ this.validatePayloadLength(remaining);
297
+ // Retain structural validation of sample tables, including malformed-entry rejection.
298
+ if (atom.header.name === 'stsd') {
299
+ await this.readToken(new AtomToken.StsdAtom(remaining));
300
+ }
301
+ else if (atom.header.name === 'stsz') {
302
+ await this.readToken(new AtomToken.StszAtom(remaining));
303
+ }
304
+ else {
305
+ await this.tokenizer.ignore(remaining);
306
+ }
307
+ this.addWarning(`Ignoring track-specific atom ${atom.atomPath} outside a track`);
308
+ return;
309
+ }
367
310
  if (this.atomParsers[atom.header.name]) {
368
311
  if (atom.header.name !== 'mdat') {
369
312
  this.validatePayloadLength(remaining);
@@ -373,11 +316,6 @@ export class MP4Parser extends BasicParser {
373
316
  debug(`No parser for atom path=${atom.atomPath}, payload-len=${remaining}, ignoring atom`);
374
317
  await this.tokenizer.ignore(remaining);
375
318
  }
376
- getTrackDescription() {
377
- // ToDo: pick the right track, not the last track!!!!
378
- const tracks = [...this.tracks.values()];
379
- return tracks[tracks.length - 1];
380
- }
381
319
  async addTag(id, value) {
382
320
  await this.metadata.addTag(tagFormat, id, value);
383
321
  }
@@ -486,11 +424,212 @@ export class MP4Parser extends BasicParser {
486
424
  this.addWarning(`atom key=${tagKey}, has unknown well-known-type (data-type): ${dataAtom.type.type}`);
487
425
  }
488
426
  }
427
+ getDuration(header) {
428
+ if (header &&
429
+ header.timeScale > 0 &&
430
+ header.duration > 0 &&
431
+ header.duration !== 0xffffffff &&
432
+ header.duration !== Number(0xffffffffffffffffn)) {
433
+ return header.duration / header.timeScale;
434
+ }
435
+ return undefined;
436
+ }
437
+ calculateTrackTiming(track) {
438
+ const timeScale = track.media.header?.timeScale;
439
+ track.duration = this.getDuration(track.media.header);
440
+ track.endTime = track.duration;
441
+ if (track.sampleSize > 0 && track.sampleCount !== undefined) {
442
+ track.sizeInBytes = track.sampleSize * track.sampleCount;
443
+ }
444
+ else if (track.sampleSizeTable.length > 0) {
445
+ track.sizeInBytes = track.sampleSizeTable.reduce((sum, size) => sum + size, 0);
446
+ }
447
+ let sampleCount = track.timeToSampleTable.reduce((sum, entry) => sum + entry.count, 0);
448
+ let timeUnits = track.timeToSampleTable.reduce((sum, entry) => sum + entry.count * entry.duration, 0);
449
+ if (track.fragments.length > 0) {
450
+ const defaults = this.trackDefaults.get(track.header.trackId);
451
+ // Runs without tfdt continue after the samples in the initial media segment.
452
+ let cursor = timeUnits;
453
+ let start;
454
+ let end = 0;
455
+ let size = track.sizeInBytes ?? 0;
456
+ let timingComplete = true;
457
+ let sizesComplete = track.sampleCount === 0 || track.sizeInBytes !== undefined;
458
+ for (const fragment of track.fragments) {
459
+ cursor = fragment.decodeTime ?? cursor;
460
+ start = start === undefined ? cursor : Math.min(start, cursor);
461
+ const run = fragment.trackRun;
462
+ if (!run.flags.sampleDurationPresent &&
463
+ !run.flags.sampleSizePresent &&
464
+ !run.flags.sampleFlagsPresent &&
465
+ !run.flags.sampleCompositionTimeOffsetsPresent) {
466
+ const duration = fragment.header.defaultSampleDuration ?? defaults?.duration;
467
+ const sampleSize = fragment.header.defaultSampleSize ?? defaults?.size;
468
+ if (duration === undefined || duration <= 0) {
469
+ timingComplete = false;
470
+ }
471
+ else {
472
+ cursor += duration * run.sampleCount;
473
+ }
474
+ if (sampleSize === undefined) {
475
+ sizesComplete = false;
476
+ }
477
+ else {
478
+ size += sampleSize * run.sampleCount;
479
+ }
480
+ sampleCount += run.sampleCount;
481
+ }
482
+ for (const sample of fragment.trackRun.samples) {
483
+ const duration = sample.sampleDuration ?? fragment.header.defaultSampleDuration ?? defaults?.duration;
484
+ const sampleSize = sample.sampleSize ?? fragment.header.defaultSampleSize ?? defaults?.size;
485
+ if (duration === undefined || duration <= 0) {
486
+ timingComplete = false;
487
+ }
488
+ else {
489
+ cursor += duration;
490
+ }
491
+ if (sampleSize === undefined) {
492
+ sizesComplete = false;
493
+ }
494
+ else {
495
+ size += sampleSize;
496
+ }
497
+ ++sampleCount;
498
+ }
499
+ end = Math.max(end, cursor);
500
+ }
501
+ if (sizesComplete && Number.isSafeInteger(size)) {
502
+ track.sizeInBytes = size;
503
+ }
504
+ else {
505
+ track.sizeInBytes = undefined;
506
+ }
507
+ if (timingComplete && timeScale && start !== undefined && Number.isSafeInteger(end)) {
508
+ timeUnits += end - start;
509
+ track.duration = Math.max(track.duration ?? 0, timeUnits / timeScale);
510
+ track.endTime = Math.max(end / timeScale, track.duration);
511
+ }
512
+ else {
513
+ timeUnits = 0;
514
+ }
515
+ }
516
+ else if (track.duration === undefined && timeScale && timeUnits > 0) {
517
+ track.duration = timeUnits / timeScale;
518
+ track.endTime = track.duration;
519
+ }
520
+ if (timeScale && timeUnits > 0 && sampleCount > 0) {
521
+ track.frameRate = (sampleCount * timeScale) / timeUnits;
522
+ }
523
+ if (track.duration === undefined &&
524
+ this.movieHeader &&
525
+ track.header.duration > 0 &&
526
+ track.header.duration !== 0xffffffff &&
527
+ track.header.duration !== Number(0xffffffffffffffffn) &&
528
+ this.movieHeader.timeScale > 0) {
529
+ track.duration = track.header.duration / this.movieHeader.timeScale;
530
+ track.endTime = track.duration;
531
+ }
532
+ }
533
+ getTrackInfo(track) {
534
+ const info = {
535
+ id: track.header.trackId,
536
+ flagEnabled: (track.header.flags & 1) !== 0
537
+ };
538
+ switch (track.handler?.handlerType) {
539
+ case 'soun':
540
+ case 'audi':
541
+ info.type = TrackType.audio;
542
+ break;
543
+ case 'vide':
544
+ info.type = TrackType.video;
545
+ break;
546
+ case 'text':
547
+ case 'sbtl':
548
+ case 'subt':
549
+ case 'clcp':
550
+ info.type = TrackType.subtitle;
551
+ break;
552
+ case 'meta':
553
+ case 'mdta':
554
+ info.type = TrackType.metadata;
555
+ break;
556
+ default:
557
+ if (isAudioTrack(track)) {
558
+ info.type = TrackType.audio;
559
+ }
560
+ }
561
+ const mediaHeader = track.media.header;
562
+ if (mediaHeader) {
563
+ // ISO BMFF stores three lowercase letters in three 5-bit fields.
564
+ const letters = [10, 5, 0].map(shift => (mediaHeader.language >> shift) & 0x1f);
565
+ if (letters.every(letter => letter >= 1 && letter <= 26)) {
566
+ info.language = String.fromCharCode(...letters.map(letter => letter + 0x60));
567
+ }
568
+ }
569
+ if (track.duration !== undefined) {
570
+ info.duration = track.duration;
571
+ }
572
+ const size = track.sizeInBytes;
573
+ if (size !== undefined && info.duration && info.duration > 0) {
574
+ info.bitrate = (8 * size) / info.duration;
575
+ }
576
+ const ssd = track.soundSampleDescription[0];
577
+ if (ssd) {
578
+ info.codecId = ssd.dataFormat;
579
+ const encoder = encoderDict[ssd.dataFormat];
580
+ info.codecName = encoder?.format ?? `<${ssd.dataFormat}>`;
581
+ if (info.type === TrackType.audio) {
582
+ if (encoder) {
583
+ info.lossless = !encoder.lossy;
584
+ }
585
+ if (ssd.description) {
586
+ info.audio = {};
587
+ if (ssd.description.sampleRate > 0) {
588
+ info.audio.samplingFrequency = ssd.description.sampleRate;
589
+ }
590
+ if (ssd.description.numAudioChannels > 0) {
591
+ info.audio.channels = ssd.description.numAudioChannels;
592
+ }
593
+ if (ssd.description.sampleSize && ssd.description.sampleSize > 0) {
594
+ info.audio.bitDepth = ssd.description.sampleSize;
595
+ }
596
+ }
597
+ }
598
+ }
599
+ // A VisualSampleEntry has width and height 16 bytes after the SampleEntry base.
600
+ const description = track.sampleDescriptions?.[0]?.description;
601
+ if (info.type === TrackType.video) {
602
+ info.video = {};
603
+ if (track.frameRate !== undefined) {
604
+ info.video.frameRate = track.frameRate;
605
+ }
606
+ if (track.header.displayWidth && track.header.displayHeight) {
607
+ info.video.displayWidth = track.header.displayWidth;
608
+ info.video.displayHeight = track.header.displayHeight;
609
+ }
610
+ }
611
+ if (info.video && description && description.length >= 20) {
612
+ const pixelWidth = Token.UINT16_BE.get(description, 16);
613
+ const pixelHeight = Token.UINT16_BE.get(description, 18);
614
+ if (pixelWidth > 0 && pixelHeight > 0) {
615
+ info.video.pixelWidth = pixelWidth;
616
+ info.video.pixelHeight = pixelHeight;
617
+ }
618
+ }
619
+ return info;
620
+ }
489
621
  async parseTrackBox(trakBox) {
490
- // @ts-expect-error
622
+ // The handler and header can occur in any order; resolve them after parsing the track.
491
623
  const track = {
492
624
  media: {},
493
- fragments: []
625
+ fragments: [],
626
+ soundSampleDescription: [],
627
+ chunkOffsetTable: [],
628
+ sampleSize: 0,
629
+ sampleCount: 0,
630
+ sampleSizeTable: [],
631
+ sampleToChunkTable: [],
632
+ timeToSampleTable: []
494
633
  };
495
634
  await trakBox.readAtoms(this.tokenizer, async (child) => {
496
635
  const payLoadLength = child.getPayloadLength();
@@ -503,14 +642,18 @@ export class MP4Parser extends BasicParser {
503
642
  case 'tkhd': // TrackHeaderBox
504
643
  track.header = await this.readToken(new AtomToken.TrackHeaderAtom(payLoadLength));
505
644
  break;
506
- case 'hdlr': // TrackHeaderBox
645
+ case 'hdlr': // Media handler; metadata and data handlers do not identify the track type.
646
+ // QuickTime File Format, Media atom: Handler reference atom ('hdlr').
647
+ // https://developer.apple.com/documentation/quicktime-file-format/media_atom/handler_reference_atom
648
+ if (child.parent?.header.name !== 'mdia' || child.parent.parent !== trakBox) {
649
+ await this.tokenizer.ignore(payLoadLength);
650
+ break;
651
+ }
507
652
  track.handler = await this.readToken(new AtomToken.HandlerBox(payLoadLength));
508
- track.isAudio = () => track.handler.handlerType === 'audi' || track.handler.handlerType === 'soun';
509
- track.isVideo = () => track.handler.handlerType === 'vide';
510
- if (track.isAudio()) {
653
+ if (track.handler.handlerType === 'audi' || track.handler.handlerType === 'soun') {
511
654
  this.hasAudioTrack = true;
512
655
  }
513
- else if (track.isVideo()) {
656
+ else if (track.handler.handlerType === 'vide') {
514
657
  this.hasVideoTrack = true;
515
658
  }
516
659
  break;
@@ -520,8 +663,12 @@ export class MP4Parser extends BasicParser {
520
663
  track.media.header = mdhd_data;
521
664
  break;
522
665
  }
523
- case 'stco': {
524
- const stco = await this.readToken(new AtomToken.StcoAtom(payLoadLength));
666
+ case 'stco':
667
+ case 'co64': {
668
+ const token = child.header.name === 'co64'
669
+ ? new AtomToken.Co64Atom(payLoadLength)
670
+ : new AtomToken.StcoAtom(payLoadLength);
671
+ const stco = await this.readToken(token);
525
672
  track.chunkOffsetTable = stco.entries; // remember chunk offsets
526
673
  break;
527
674
  }
@@ -534,6 +681,7 @@ export class MP4Parser extends BasicParser {
534
681
  case 'stsd': {
535
682
  // sample description box
536
683
  const stsd = await this.readToken(new AtomToken.StsdAtom(payLoadLength));
684
+ track.sampleDescriptions = stsd.table;
537
685
  track.soundSampleDescription = stsd.table.map(dfEntry => this.parseSoundSampleDescription(dfEntry));
538
686
  break;
539
687
  }
@@ -546,6 +694,7 @@ export class MP4Parser extends BasicParser {
546
694
  case 'stsz': {
547
695
  const stsz = await this.readToken(new AtomToken.StszAtom(payLoadLength));
548
696
  track.sampleSize = stsz.sampleSize;
697
+ track.sampleCount = stsz.numberOfEntries;
549
698
  track.sampleSizeTable = stsz.entries;
550
699
  break;
551
700
  }
@@ -562,39 +711,121 @@ export class MP4Parser extends BasicParser {
562
711
  }
563
712
  }, trakBox.getPayloadLength());
564
713
  // Register track
565
- this.tracks.set(track.header.trackId, track);
714
+ if (track.header) {
715
+ this.tracks.set(track.header.trackId, { ...track, header: track.header });
716
+ }
566
717
  }
567
- parseTrackFragmentBox(trafBox) {
718
+ async parseTrackFragmentBox(trafBox) {
568
719
  let tfhd;
569
- return trafBox.readAtoms(this.tokenizer, async (child) => {
570
- const payLoadLength = child.getPayloadLength();
720
+ let decodeTime;
721
+ const runs = [];
722
+ await trafBox.readAtoms(this.tokenizer, async (child) => {
723
+ const length = child.getPayloadLength();
571
724
  switch (child.header.name) {
572
- case 'tfhd': {
573
- // TrackFragmentHeaderBox
574
- const fragmentHeaderBox = new AtomToken.TrackFragmentHeaderBox(child.getPayloadLength());
575
- tfhd = await this.readToken(fragmentHeaderBox);
725
+ case 'tfhd':
726
+ tfhd = await this.readToken(new AtomToken.TrackFragmentHeaderBox(length));
576
727
  break;
577
- }
578
- case 'tfdt': // TrackFragmentBaseMediaDecodeTimeBo
579
- await this.tokenizer.ignore(payLoadLength);
580
- break;
581
- case 'trun': {
582
- // TrackRunBox
583
- const trackRunBox = new AtomToken.TrackRunBox(payLoadLength);
584
- const trun = await this.readToken(trackRunBox);
585
- if (tfhd) {
586
- const track = this.tracks.get(tfhd.trackId);
587
- track?.fragments.push({ header: tfhd, trackRun: trun });
728
+ case 'tfdt': {
729
+ const data = await this.readToken(new Token.Uint8ArrayType(length));
730
+ if (length < 4 || (data[0] === 0 && length < 8) || (data[0] === 1 && length < 12)) {
731
+ throw new Mp4ContentError('Truncated tfdt box');
732
+ }
733
+ if (data[0] === 0) {
734
+ decodeTime = Token.UINT32_BE.get(data, 4);
735
+ }
736
+ else if (data[0] === 1) {
737
+ decodeTime = Number(Token.UINT64_BE.get(data, 4));
738
+ }
739
+ else {
740
+ throw new Mp4ContentError('Invalid tfdt version');
741
+ }
742
+ if (!Number.isSafeInteger(decodeTime)) {
743
+ throw new Mp4ContentError('Unsafe tfdt decode time');
588
744
  }
589
745
  break;
590
746
  }
591
- default: {
592
- debug(`Unexpected box: ${child.header.name}`);
593
- await this.tokenizer.ignore(payLoadLength);
594
- }
747
+ case 'trun':
748
+ runs.push(await this.readToken(new AtomToken.TrackRunBox(length)));
749
+ break;
750
+ default:
751
+ await this.tokenizer.ignore(length);
595
752
  }
596
753
  }, trafBox.getPayloadLength());
754
+ if (tfhd) {
755
+ const track = this.tracks.get(tfhd.trackId);
756
+ for (const run of runs) {
757
+ track?.fragments.push({ header: tfhd, trackRun: run, decodeTime });
758
+ decodeTime = undefined;
759
+ }
760
+ }
597
761
  }
762
+ atomParsers = {
763
+ /**
764
+ * Parse movie header (mvhd) atom
765
+ * Ref: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-56313
766
+ */
767
+ mvhd: async (len) => {
768
+ const mvhd = await this.readToken(new AtomToken.MvhdAtom(len));
769
+ this.movieHeader = mvhd;
770
+ this.metadata.setFormat('creationTime', mvhd.creationTime);
771
+ this.metadata.setFormat('modificationTime', mvhd.modificationTime);
772
+ },
773
+ chpl: async (len) => {
774
+ if (this.options.includeChapters) {
775
+ this.neroChapters = await this.readToken(new AtomToken.ChapterListAtom(len));
776
+ }
777
+ else {
778
+ await this.tokenizer.ignore(len);
779
+ }
780
+ },
781
+ trex: async (len) => {
782
+ const data = await this.readToken(new Token.Uint8ArrayType(len));
783
+ if (len < 24) {
784
+ throw new Mp4ContentError('Truncated trex box');
785
+ }
786
+ this.trackDefaults.set(Token.UINT32_BE.get(data, 4), {
787
+ duration: Token.UINT32_BE.get(data, 12),
788
+ size: Token.UINT32_BE.get(data, 16)
789
+ });
790
+ },
791
+ /**
792
+ * Parse mdat atom.
793
+ * Will scan for chapters
794
+ */
795
+ mdat: async (len) => {
796
+ const range = { offset: this.tokenizer.position, end: this.tokenizer.position + len };
797
+ if (this.options.includeChapters) {
798
+ if (supportsSeeking(this.tokenizer)) {
799
+ this.mediaDataRanges.push(range);
800
+ }
801
+ else {
802
+ await this.parseChapters([range], true);
803
+ }
804
+ }
805
+ await this.tokenizer.ignore(range.end - this.tokenizer.position);
806
+ },
807
+ ftyp: async (len) => {
808
+ if (len < 8 || len % AtomToken.ftyp.len !== 0) {
809
+ throw new Mp4ContentError(`Invalid ftyp payload length: ${len}`);
810
+ }
811
+ const types = [];
812
+ while (len > 0) {
813
+ const ftype = await this.readToken(AtomToken.ftyp);
814
+ len -= AtomToken.ftyp.len;
815
+ const value = ftype.type.replace(/\W/g, '');
816
+ if (value.length > 0) {
817
+ types.push(value); // unshift for backward compatibility
818
+ }
819
+ }
820
+ debug(`ftyp: ${types.join('/')}`);
821
+ const x = types.filter(distinct).join('/');
822
+ this.metadata.setFormat('container', x);
823
+ },
824
+ date: async (len) => {
825
+ const date = await this.readToken(new Token.StringType(len, 'utf-8'));
826
+ await this.addTag('date', date);
827
+ }
828
+ };
598
829
  /**
599
830
  * @param sampleDescription
600
831
  * Ref: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-128916
@@ -626,36 +857,114 @@ export class MP4Parser extends BasicParser {
626
857
  }
627
858
  return ssd;
628
859
  }
629
- async parseChapterTrack(chapterTrack, track, len) {
630
- if (!chapterTrack.sampleSize) {
631
- if (chapterTrack.chunkOffsetTable.length !== chapterTrack.sampleSizeTable.length) {
632
- throw new Error('Expected equal chunk-offset-table & sample-size-table length.');
860
+ async parseChapters(mediaDataRanges, forwardOnly = false) {
861
+ for (const track of this.tracks.values()) {
862
+ for (const id of track.chapterList ?? []) {
863
+ const chapterTrack = this.tracks.get(id);
864
+ if (!chapterTrack ||
865
+ chapterTrack === track ||
866
+ (chapterTrack.handler && !['text', 'sbtl'].includes(chapterTrack.handler.handlerType))) {
867
+ continue;
868
+ }
869
+ try {
870
+ await this.parseChapterTrack(chapterTrack, track, mediaDataRanges, forwardOnly);
871
+ }
872
+ catch (error) {
873
+ // A broken QuickTime track must not hide an independently usable Nero list.
874
+ if (this.neroChapters.length === 0 || !(error instanceof Mp4ContentError)) {
875
+ throw error;
876
+ }
877
+ this.streamedChapterCount = undefined;
878
+ this.streamedChapters.clear();
879
+ this.addWarning(`Cannot read chapter track: ${error.message}`);
880
+ }
881
+ return;
633
882
  }
634
883
  }
884
+ }
885
+ async parseChapterTrack(chapterTrack, track, mediaDataRanges, forwardOnly) {
886
+ const sampleCount = Math.min(chapterTrack.sampleCount, maxChapterCount);
887
+ if (chapterTrack.sampleCount > maxChapterCount) {
888
+ this.addWarning(`Chapter count exceeds the ${maxChapterCount} chapter limit`);
889
+ }
890
+ if (forwardOnly) {
891
+ this.streamedChapterCount = sampleCount;
892
+ }
635
893
  const chapters = [];
636
- for (let i = 0; i < chapterTrack.chunkOffsetTable.length && len > 0; ++i) {
637
- const start = chapterTrack.timeToSampleTable.slice(0, i).reduce((acc, cur) => acc + cur.duration, 0);
638
- const chunkOffset = chapterTrack.chunkOffsetTable[i];
639
- const nextChunkLen = chunkOffset - this.tokenizer.position;
640
- const sampleSize = chapterTrack.sampleSize > 0 ? chapterTrack.sampleSize : chapterTrack.sampleSizeTable[i];
641
- len -= nextChunkLen + sampleSize;
642
- if (len < 0) {
643
- throw new Mp4ContentError('Chapter chunk exceeding token length');
644
- }
645
- await this.tokenizer.ignore(nextChunkLen);
646
- const title = await this.readToken(new AtomToken.ChapterText(sampleSize));
647
- debug(`Chapter ${i + 1}: ${title}`);
648
- const chapter = {
649
- title,
650
- timeScale: chapterTrack.media.header ? chapterTrack.media.header.timeScale : 0,
651
- start,
652
- sampleOffset: this.findSampleOffset(track, this.tokenizer.position)
653
- };
654
- debug(`Chapter title=${chapter.title}, offset=${chapter.sampleOffset}/${track.header.duration}`); // ToDo, use media duration if required!!!
655
- chapters.push(chapter);
656
- }
657
- this.metadata.setFormat('chapters', chapters);
658
- await this.tokenizer.ignore(len);
894
+ let sampleIndex = 0;
895
+ let timeRun = 0;
896
+ let samplesInTimeRun = chapterTrack.timeToSampleTable[0]?.count ?? 0;
897
+ let start = 0;
898
+ const chunkRuns = chapterTrack.sampleToChunkTable;
899
+ for (let run = 0; run < chunkRuns.length && sampleIndex < sampleCount; ++run) {
900
+ const { firstChunk, samplesPerChunk } = chunkRuns[run];
901
+ const nextFirstChunk = chunkRuns[run + 1]?.firstChunk ?? chapterTrack.chunkOffsetTable.length + 1;
902
+ if ((run === 0 && firstChunk !== 1) ||
903
+ firstChunk < 1 ||
904
+ samplesPerChunk === 0 ||
905
+ nextFirstChunk <= firstChunk ||
906
+ nextFirstChunk > chapterTrack.chunkOffsetTable.length + 1) {
907
+ throw new Mp4ContentError('Invalid chapter sample-to-chunk table');
908
+ }
909
+ for (let chunk = firstChunk - 1; chunk < nextFirstChunk - 1 && sampleIndex < sampleCount; ++chunk) {
910
+ let offset = chapterTrack.chunkOffsetTable[chunk];
911
+ for (let sample = 0; sample < samplesPerChunk && sampleIndex < sampleCount; ++sample) {
912
+ while (samplesInTimeRun === 0 && timeRun < chapterTrack.timeToSampleTable.length) {
913
+ samplesInTimeRun = chapterTrack.timeToSampleTable[++timeRun]?.count ?? 0;
914
+ }
915
+ const timing = chapterTrack.timeToSampleTable[timeRun];
916
+ if (!timing) {
917
+ throw new Mp4ContentError('Missing chapter sample timing');
918
+ }
919
+ const size = chapterTrack.sampleSize || chapterTrack.sampleSizeTable[sampleIndex];
920
+ const deferred = forwardOnly && (this.streamedChapters.has(sampleIndex) || offset >= mediaDataRanges[0].end);
921
+ if (!deferred) {
922
+ if (!Number.isSafeInteger(offset) ||
923
+ !Number.isSafeInteger(size) ||
924
+ size < 0 ||
925
+ !mediaDataRanges.some(range => offset >= range.offset && size <= range.end - offset)) {
926
+ throw new Mp4ContentError('Chapter chunk exceeding media data bounds');
927
+ }
928
+ if (forwardOnly && offset < this.tokenizer.position) {
929
+ throw new Mp4ContentError('Chapter chunk exceeding media data bounds');
930
+ }
931
+ // Oversized or empty title samples retain their timestamps without buffering their data.
932
+ const title = size < 2 || size > maxChapterTitleBytes
933
+ ? ''
934
+ : await this.readToken(new AtomToken.ChapterText(size), offset);
935
+ const chapter = {
936
+ title,
937
+ timeScale: chapterTrack.media.header?.timeScale ?? 0,
938
+ start
939
+ };
940
+ if (track.chunkOffsetTable.length > 0 &&
941
+ track.sampleToChunkTable.length > 0 &&
942
+ track.timeToSampleTable.length > 0) {
943
+ chapter.sampleOffset = this.findSampleOffset(track, offset + size);
944
+ }
945
+ if (forwardOnly) {
946
+ this.streamedChapters.set(sampleIndex, chapter);
947
+ }
948
+ else {
949
+ chapters.push(chapter);
950
+ }
951
+ }
952
+ offset += size;
953
+ start += timing.duration;
954
+ --samplesInTimeRun;
955
+ ++sampleIndex;
956
+ }
957
+ }
958
+ }
959
+ if (sampleIndex < sampleCount) {
960
+ throw new Mp4ContentError('Missing chapter sample-to-chunk entries');
961
+ }
962
+ if (!forwardOnly) {
963
+ this.metadata.setFormat('chapters', chapters);
964
+ }
965
+ else if (this.streamedChapters.size === sampleCount) {
966
+ this.metadata.setFormat('chapters', [...this.streamedChapters].sort(([left], [right]) => left - right).map(([, chapter]) => chapter));
967
+ }
659
968
  }
660
969
  findSampleOffset(track, chapterOffset) {
661
970
  let chunkIndex = 0;
@@ -665,35 +974,43 @@ export class MP4Parser extends BasicParser {
665
974
  return this.getChunkDuration(chunkIndex + 1, track);
666
975
  }
667
976
  getChunkDuration(chunkId, track) {
668
- let ttsi = 0;
669
- let ttsc = track.timeToSampleTable[ttsi].count;
670
- let ttsd = track.timeToSampleTable[ttsi].duration;
671
- let curChunkId = 1;
672
- let samplesPerChunk = this.getSamplesPerChunk(curChunkId, track.sampleToChunkTable);
673
- let totalDuration = 0;
674
- while (curChunkId < chunkId) {
675
- const nrOfSamples = Math.min(ttsc, samplesPerChunk);
676
- totalDuration += nrOfSamples * ttsd;
677
- ttsc -= nrOfSamples;
678
- samplesPerChunk -= nrOfSamples;
679
- if (samplesPerChunk === 0) {
680
- ++curChunkId;
681
- samplesPerChunk = this.getSamplesPerChunk(curChunkId, track.sampleToChunkTable);
682
- }
683
- else {
684
- ++ttsi;
685
- ttsc = track.timeToSampleTable[ttsi].count;
686
- ttsd = track.timeToSampleTable[ttsi].duration;
977
+ let previousChunk = 0;
978
+ for (const entry of track.sampleToChunkTable) {
979
+ if ((previousChunk === 0 && entry.firstChunk !== 1) ||
980
+ entry.firstChunk <= previousChunk ||
981
+ entry.samplesPerChunk === 0) {
982
+ throw new Mp4ContentError('Invalid audio sample-to-chunk table');
687
983
  }
984
+ previousChunk = entry.firstChunk;
688
985
  }
689
- return totalDuration;
690
- }
691
- getSamplesPerChunk(chunkId, stcTable) {
692
- for (let i = 0; i < stcTable.length - 1; ++i) {
693
- if (chunkId >= stcTable[i].firstChunk && chunkId < stcTable[i + 1].firstChunk) {
694
- return stcTable[i].samplesPerChunk;
986
+ let timingIndex = 0;
987
+ let remainingSamples = 0;
988
+ let sampleDuration = 0;
989
+ let totalDuration = 0;
990
+ for (const [index, run] of track.sampleToChunkTable.entries()) {
991
+ const nextChunk = track.sampleToChunkTable[index + 1]?.firstChunk ?? chunkId;
992
+ const endChunk = Math.min(nextChunk, chunkId);
993
+ for (let chunk = run.firstChunk; chunk < endChunk; ++chunk) {
994
+ let samplesPerChunk = run.samplesPerChunk;
995
+ while (samplesPerChunk > 0) {
996
+ while (remainingSamples === 0) {
997
+ const timing = track.timeToSampleTable[timingIndex++];
998
+ if (!timing) {
999
+ throw new Mp4ContentError('Missing audio sample timing for chapter offset');
1000
+ }
1001
+ remainingSamples = timing.count;
1002
+ sampleDuration = timing.duration;
1003
+ }
1004
+ const samples = Math.min(remainingSamples, samplesPerChunk);
1005
+ totalDuration += samples * sampleDuration;
1006
+ if (!Number.isSafeInteger(totalDuration)) {
1007
+ throw new Mp4ContentError('Unsafe audio sample timing for chapter offset');
1008
+ }
1009
+ remainingSamples -= samples;
1010
+ samplesPerChunk -= samples;
1011
+ }
695
1012
  }
696
1013
  }
697
- return stcTable[stcTable.length - 1].samplesPerChunk;
1014
+ return totalDuration;
698
1015
  }
699
1016
  }