taglib-wasm 2.2.3 → 2.3.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 (630) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +206 -21
  3. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/assertClassBrand.js +7 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/checkPrivateRedeclaration.js +6 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldGet2.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldInitSpec.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/classPrivateFieldSet2.js +7 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/defineProperty.js +12 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPrimitive.js +14 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/toPropertyKey.js +9 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/typeof.js +11 -0
  12. package/dist/_virtual/_@oxc-project_runtime@0.152.0/helpers/esm/usingCtx.js +57 -0
  13. package/dist/_virtual/_rolldown/runtime.js +13 -0
  14. package/dist/bwf/bext.d.ts.map +1 -0
  15. package/dist/bwf/bext.js +119 -0
  16. package/dist/{src/constants → constants}/additional-properties.d.ts.map +1 -1
  17. package/dist/constants/additional-properties.js +270 -0
  18. package/dist/constants/basic-properties.d.ts.map +1 -0
  19. package/dist/constants/basic-properties.js +128 -0
  20. package/dist/constants/complex-properties.d.ts.map +1 -0
  21. package/dist/constants/complex-properties.js +1 -0
  22. package/dist/constants/format-mappings.d.ts.map +1 -0
  23. package/dist/constants/format-mappings.js +58 -0
  24. package/dist/{src/constants → constants}/general-extended-properties.d.ts.map +1 -1
  25. package/dist/constants/general-extended-properties.js +272 -0
  26. package/dist/constants/index.d.ts.map +1 -0
  27. package/dist/constants/index.js +5 -0
  28. package/dist/{src/constants → constants}/properties.d.ts +1 -1
  29. package/dist/constants/properties.d.ts.map +1 -0
  30. package/dist/constants/properties.js +105 -0
  31. package/dist/constants/property-types.d.ts.map +1 -0
  32. package/dist/constants/property-types.js +1 -0
  33. package/dist/{src/constants → constants}/specialized-properties.d.ts.map +1 -1
  34. package/dist/constants/specialized-properties.js +335 -0
  35. package/dist/{src/constants → constants}/utilities.d.ts +1 -1
  36. package/dist/constants/utilities.d.ts.map +1 -0
  37. package/dist/constants/utilities.js +50 -0
  38. package/dist/constants.d.ts.map +1 -0
  39. package/dist/constants.js +5 -0
  40. package/dist/{src/deno-compile.d.ts → deno-compile.d.ts} +4 -2
  41. package/dist/deno-compile.d.ts.map +1 -0
  42. package/dist/deno-compile.js +109 -0
  43. package/dist/disc-folder.d.ts +4 -4
  44. package/dist/disc-folder.d.ts.map +1 -1
  45. package/dist/disc-folder.js +596 -544
  46. package/dist/errors/base.d.ts +38 -0
  47. package/dist/errors/base.d.ts.map +1 -0
  48. package/dist/errors/base.js +66 -0
  49. package/dist/errors/classes.d.ts.map +1 -0
  50. package/dist/errors/classes.js +164 -0
  51. package/dist/errors/guards.d.ts.map +1 -0
  52. package/dist/errors/guards.js +26 -0
  53. package/dist/errors/index.d.ts.map +1 -0
  54. package/dist/errors/index.js +4 -0
  55. package/dist/errors.d.ts.map +1 -0
  56. package/dist/errors.js +5 -0
  57. package/dist/file-utils/copy-and-find.d.ts.map +1 -0
  58. package/dist/file-utils/copy-and-find.js +107 -0
  59. package/dist/file-utils/export-operations.d.ts.map +1 -0
  60. package/dist/file-utils/export-operations.js +84 -0
  61. package/dist/file-utils/import-operations.d.ts.map +1 -0
  62. package/dist/file-utils/import-operations.js +109 -0
  63. package/dist/file-utils/index.d.ts.map +1 -0
  64. package/dist/file-utils/index.js +5 -0
  65. package/dist/file-utils/mime-detection.d.ts.map +1 -0
  66. package/dist/file-utils/mime-detection.js +44 -0
  67. package/dist/folder-api/album-corroborate.d.ts.map +1 -0
  68. package/dist/folder-api/album-corroborate.js +35 -0
  69. package/dist/folder-api/album-discs.d.ts.map +1 -0
  70. package/dist/folder-api/album-discs.js +119 -0
  71. package/dist/folder-api/album-grouping.d.ts.map +1 -0
  72. package/dist/folder-api/album-grouping.js +161 -0
  73. package/dist/folder-api/album-identity.d.ts.map +1 -0
  74. package/dist/folder-api/album-identity.js +165 -0
  75. package/dist/folder-api/album-types.d.ts.map +1 -0
  76. package/dist/folder-api/album-types.js +1 -0
  77. package/dist/folder-api/directory-walker.d.ts.map +1 -0
  78. package/dist/folder-api/directory-walker.js +27 -0
  79. package/dist/folder-api/file-processors.d.ts.map +1 -0
  80. package/dist/folder-api/file-processors.js +52 -0
  81. package/dist/folder-api/folder-disc.d.ts.map +1 -0
  82. package/dist/folder-api/folder-disc.js +166 -0
  83. package/dist/folder-api/folder-operations.d.ts.map +1 -0
  84. package/dist/folder-api/folder-operations.js +69 -0
  85. package/dist/folder-api/index.d.ts.map +1 -0
  86. package/dist/{src/folder-api → folder-api}/index.js +1 -8
  87. package/dist/folder-api/scan-for-albums.d.ts.map +1 -0
  88. package/dist/folder-api/scan-for-albums.js +25 -0
  89. package/dist/folder-api/scan-operations.d.ts.map +1 -0
  90. package/dist/folder-api/scan-operations.js +79 -0
  91. package/dist/folder-api/types.d.ts.map +1 -0
  92. package/dist/folder-api/types.js +21 -0
  93. package/dist/folder.d.ts +1 -1
  94. package/dist/folder.d.ts.map +1 -1
  95. package/dist/folder.js +7 -2
  96. package/dist/global.d.js +1 -0
  97. package/dist/index.browser.d.ts +40 -21
  98. package/dist/index.browser.d.ts.map +1 -1
  99. package/dist/index.browser.js +4194 -3656
  100. package/dist/index.d.ts +26 -25
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +40 -183
  103. package/dist/msgpack/decoder.d.ts.map +1 -0
  104. package/dist/msgpack/decoder.js +177 -0
  105. package/dist/msgpack/encoder.d.ts.map +1 -0
  106. package/dist/msgpack/encoder.js +211 -0
  107. package/dist/msgpack/index.d.ts.map +1 -0
  108. package/dist/msgpack/index.js +5 -0
  109. package/dist/{src/msgpack → msgpack}/types.d.ts +1 -1
  110. package/dist/msgpack/types.d.ts.map +1 -0
  111. package/dist/msgpack/types.js +13 -0
  112. package/dist/msgpack/utils.d.ts.map +1 -0
  113. package/dist/msgpack/utils.js +116 -0
  114. package/dist/rating.d.ts +1 -1
  115. package/dist/rating.d.ts.map +1 -1
  116. package/dist/rating.js +2 -2
  117. package/dist/runtime/deno-detect.d.ts.map +1 -0
  118. package/dist/runtime/deno-detect.js +12 -0
  119. package/dist/{src/runtime → runtime}/detector.d.ts +2 -0
  120. package/dist/runtime/detector.d.ts.map +1 -0
  121. package/dist/runtime/detector.js +173 -0
  122. package/dist/runtime/loader-types.d.ts.map +1 -0
  123. package/dist/runtime/loader-types.js +23 -0
  124. package/dist/runtime/module-loader-browser.d.ts.map +1 -0
  125. package/dist/runtime/module-loader-browser.js +33 -0
  126. package/dist/runtime/module-loader.d.ts.map +1 -0
  127. package/dist/runtime/module-loader.js +119 -0
  128. package/dist/runtime/platform-io.d.ts.map +1 -0
  129. package/dist/runtime/platform-io.js +153 -0
  130. package/dist/runtime/unified-loader/index.d.ts.map +1 -0
  131. package/dist/{src/runtime → runtime}/unified-loader/index.js +1 -7
  132. package/dist/runtime/unified-loader/loader.d.ts.map +1 -0
  133. package/dist/runtime/unified-loader/loader.js +64 -0
  134. package/dist/runtime/unified-loader/module-loading.d.ts.map +1 -0
  135. package/dist/runtime/unified-loader/module-loading.js +90 -0
  136. package/dist/runtime/unified-loader/module-selection.d.ts.map +1 -0
  137. package/dist/runtime/unified-loader/module-selection.js +25 -0
  138. package/dist/runtime/unified-loader/types.d.ts.map +1 -0
  139. package/dist/runtime/unified-loader/types.js +24 -0
  140. package/dist/{src/runtime → runtime}/wasi-adapter/adapter.d.ts +13 -1
  141. package/dist/runtime/wasi-adapter/adapter.d.ts.map +1 -0
  142. package/dist/runtime/wasi-adapter/adapter.js +114 -0
  143. package/dist/{src/runtime → runtime}/wasi-adapter/audio-properties.d.ts +4 -1
  144. package/dist/runtime/wasi-adapter/audio-properties.d.ts.map +1 -0
  145. package/dist/runtime/wasi-adapter/audio-properties.js +120 -0
  146. package/dist/runtime/wasi-adapter/file-handle.d.ts.map +1 -0
  147. package/dist/runtime/wasi-adapter/file-handle.js +181 -0
  148. package/dist/runtime/wasi-adapter/handle-state.d.ts.map +1 -0
  149. package/dist/runtime/wasi-adapter/handle-state.js +48 -0
  150. package/dist/runtime/wasi-adapter/index.d.ts.map +1 -0
  151. package/dist/{src/runtime → runtime}/wasi-adapter/index.js +1 -3
  152. package/dist/runtime/wasi-adapter/mp4-items.d.ts.map +1 -0
  153. package/dist/runtime/wasi-adapter/mp4-items.js +97 -0
  154. package/dist/runtime/wasi-adapter/path-open.d.ts +68 -0
  155. package/dist/runtime/wasi-adapter/path-open.d.ts.map +1 -0
  156. package/dist/runtime/wasi-adapter/path-open.js +101 -0
  157. package/dist/runtime/wasi-adapter/property-surface.d.ts.map +1 -0
  158. package/dist/runtime/wasi-adapter/property-surface.js +96 -0
  159. package/dist/runtime/wasi-adapter/structured-fields.d.ts.map +1 -0
  160. package/dist/runtime/wasi-adapter/structured-fields.js +144 -0
  161. package/dist/runtime/wasi-adapter/tag-keys.d.ts.map +1 -0
  162. package/dist/runtime/wasi-adapter/tag-keys.js +65 -0
  163. package/dist/runtime/wasi-adapter/wasm-io.d.ts.map +1 -0
  164. package/dist/runtime/wasi-adapter/wasm-io.js +154 -0
  165. package/dist/runtime/wasi-fs-deno.d.ts.map +1 -0
  166. package/dist/runtime/wasi-fs-deno.js +25 -0
  167. package/dist/runtime/wasi-fs-node.d.ts.map +1 -0
  168. package/dist/runtime/wasi-fs-node.js +58 -0
  169. package/dist/runtime/wasi-fs-provider.d.ts.map +1 -0
  170. package/dist/runtime/wasi-fs-provider.js +1 -0
  171. package/dist/runtime/wasi-host-loader.d.ts.map +1 -0
  172. package/dist/runtime/wasi-host-loader.js +101 -0
  173. package/dist/runtime/wasi-host.d.ts.map +1 -0
  174. package/dist/runtime/wasi-host.js +199 -0
  175. package/dist/runtime/wasi-memory.d.ts.map +1 -0
  176. package/dist/runtime/wasi-memory.js +179 -0
  177. package/dist/{src/runtime → runtime}/wasmer-sdk-loader/types.d.ts +13 -0
  178. package/dist/runtime/wasmer-sdk-loader/types.d.ts.map +1 -0
  179. package/dist/runtime/wasmer-sdk-loader/types.js +15 -0
  180. package/dist/simple/batch-operations.d.ts.map +1 -0
  181. package/dist/simple/batch-operations.js +245 -0
  182. package/dist/simple/checksum-operations.d.ts +25 -0
  183. package/dist/simple/checksum-operations.d.ts.map +1 -0
  184. package/dist/simple/checksum-operations.js +28 -0
  185. package/dist/simple/config.d.ts.map +1 -0
  186. package/dist/simple/config.js +17 -0
  187. package/dist/{src/simple → simple}/index.d.ts +2 -0
  188. package/dist/simple/index.d.ts.map +1 -0
  189. package/dist/simple/index.js +8 -0
  190. package/dist/simple/picture-operations.d.ts.map +1 -0
  191. package/dist/simple/picture-operations.js +132 -0
  192. package/dist/simple/tag-operations.d.ts.map +1 -0
  193. package/dist/simple/tag-operations.js +125 -0
  194. package/dist/simple/with-audio-file.d.ts.map +1 -0
  195. package/dist/simple/with-audio-file.js +28 -0
  196. package/dist/simple.browser.d.ts +2 -2
  197. package/dist/simple.browser.d.ts.map +1 -1
  198. package/dist/simple.browser.js +3462 -3425
  199. package/dist/simple.d.ts +1 -1
  200. package/dist/simple.d.ts.map +1 -1
  201. package/dist/simple.js +8 -2
  202. package/dist/taglib/audio-file-base.d.ts.map +1 -0
  203. package/dist/taglib/audio-file-base.js +166 -0
  204. package/dist/taglib/audio-file-bwf.d.ts.map +1 -0
  205. package/dist/taglib/audio-file-bwf.js +33 -0
  206. package/dist/taglib/audio-file-checksum.d.ts +47 -0
  207. package/dist/taglib/audio-file-checksum.d.ts.map +1 -0
  208. package/dist/taglib/audio-file-checksum.js +90 -0
  209. package/dist/{src/taglib → taglib}/audio-file-impl.d.ts +4 -0
  210. package/dist/taglib/audio-file-impl.d.ts.map +1 -0
  211. package/dist/taglib/audio-file-impl.js +234 -0
  212. package/dist/{src/taglib → taglib}/audio-file-interface.d.ts +17 -0
  213. package/dist/taglib/audio-file-interface.d.ts.map +1 -0
  214. package/dist/taglib/audio-file-interface.js +1 -0
  215. package/dist/taglib/auto-dispose.d.ts.map +1 -0
  216. package/dist/taglib/auto-dispose.js +34 -0
  217. package/dist/taglib/embind-adapter.d.ts.map +1 -0
  218. package/dist/taglib/embind-adapter.js +137 -0
  219. package/dist/taglib/extra-state-registry.d.ts.map +1 -0
  220. package/dist/taglib/extra-state-registry.js +72 -0
  221. package/dist/{src/taglib → taglib}/id3v2-frames.d.ts +0 -1
  222. package/dist/taglib/id3v2-frames.d.ts.map +1 -0
  223. package/dist/taglib/id3v2-frames.js +25 -0
  224. package/dist/taglib/index.d.ts.map +1 -0
  225. package/dist/taglib/index.js +7 -0
  226. package/dist/taglib/load-audio-data.d.ts.map +1 -0
  227. package/dist/taglib/load-audio-data.js +54 -0
  228. package/dist/taglib/media-ranges.d.ts +85 -0
  229. package/dist/taglib/media-ranges.d.ts.map +1 -0
  230. package/dist/taglib/media-ranges.js +309 -0
  231. package/dist/taglib/metadata-extent.d.ts +96 -0
  232. package/dist/taglib/metadata-extent.d.ts.map +1 -0
  233. package/dist/taglib/metadata-extent.js +394 -0
  234. package/dist/taglib/mp4-item-names.d.ts.map +1 -0
  235. package/dist/taglib/mp4-item-names.js +14 -0
  236. package/dist/taglib/mutable-tag-impl.d.ts.map +1 -0
  237. package/dist/taglib/mutable-tag-impl.js +81 -0
  238. package/dist/taglib/mutable-tag.d.ts.map +1 -0
  239. package/dist/taglib/mutable-tag.js +1 -0
  240. package/dist/taglib/save-reconstruct.d.ts.map +1 -0
  241. package/dist/taglib/save-reconstruct.js +53 -0
  242. package/dist/taglib/taglib-class.d.ts.map +1 -0
  243. package/dist/taglib/taglib-class.js +146 -0
  244. package/dist/taglib-wasi.wasm +0 -0
  245. package/dist/taglib-web.wasm +0 -0
  246. package/dist/taglib-wrapper.js +1 -1
  247. package/dist/taglib.d.ts.map +1 -0
  248. package/dist/taglib.js +7 -0
  249. package/dist/types/audio-formats.d.ts.map +1 -0
  250. package/dist/types/audio-formats.js +6 -0
  251. package/dist/types/bwf.d.ts.map +1 -0
  252. package/dist/types/bwf.js +1 -0
  253. package/dist/types/chapters.d.ts.map +1 -0
  254. package/dist/types/chapters.js +1 -0
  255. package/dist/types/config.d.ts.map +1 -0
  256. package/dist/types/config.js +1 -0
  257. package/dist/types/format-property-keys.d.ts.map +1 -0
  258. package/dist/types/format-property-keys.js +1 -0
  259. package/dist/types/index.d.ts.map +1 -0
  260. package/dist/types/index.js +9 -0
  261. package/dist/types/metadata-mappings.d.ts.map +1 -0
  262. package/dist/types/metadata-mappings.js +323 -0
  263. package/dist/types/pictures.d.ts.map +1 -0
  264. package/dist/types/pictures.js +79 -0
  265. package/dist/types/tags.d.ts.map +1 -0
  266. package/dist/types/tags.js +1 -0
  267. package/dist/types.d.ts.map +1 -0
  268. package/dist/types.js +5 -0
  269. package/dist/utils/file.d.ts.map +1 -0
  270. package/dist/utils/file.js +43 -0
  271. package/dist/utils/mirror-fields.d.ts.map +1 -0
  272. package/dist/utils/mirror-fields.js +107 -0
  273. package/dist/utils/node-fs.d.ts.map +1 -0
  274. package/dist/utils/node-fs.js +36 -0
  275. package/dist/utils/path.d.ts +26 -0
  276. package/dist/utils/path.d.ts.map +1 -0
  277. package/dist/utils/path.js +52 -0
  278. package/dist/utils/rating.d.ts.map +1 -0
  279. package/dist/utils/rating.js +150 -0
  280. package/dist/utils/tag-mapping.d.ts.map +1 -0
  281. package/dist/utils/tag-mapping.js +207 -0
  282. package/dist/utils/write.d.ts.map +1 -0
  283. package/dist/utils/write.js +18 -0
  284. package/dist/version.d.ts +2 -0
  285. package/dist/version.d.ts.map +1 -0
  286. package/dist/version.js +4 -0
  287. package/dist/{src/wasm.d.ts → wasm.d.ts} +9 -0
  288. package/dist/wasm.d.ts.map +1 -0
  289. package/dist/wasm.js +1 -0
  290. package/dist/web-utils/canvas.d.ts.map +1 -0
  291. package/dist/web-utils/canvas.js +97 -0
  292. package/dist/web-utils/data-url.d.ts.map +1 -0
  293. package/dist/web-utils/data-url.js +54 -0
  294. package/dist/web-utils/dom-integration.d.ts.map +1 -0
  295. package/dist/web-utils/dom-integration.js +105 -0
  296. package/dist/web-utils/index.d.ts.map +1 -0
  297. package/dist/web-utils/index.js +4 -0
  298. package/dist/web.browser.d.ts +13 -0
  299. package/dist/web.browser.d.ts.map +1 -0
  300. package/dist/web.browser.js +3387 -0
  301. package/dist/web.d.ts +1 -1
  302. package/dist/web.d.ts.map +1 -1
  303. package/dist/web.js +5 -2
  304. package/package.json +140 -97
  305. package/dist/src/bwf/bext.d.ts.map +0 -1
  306. package/dist/src/bwf/bext.js +0 -126
  307. package/dist/src/constants/additional-properties.js +0 -204
  308. package/dist/src/constants/basic-properties.d.ts.map +0 -1
  309. package/dist/src/constants/basic-properties.js +0 -89
  310. package/dist/src/constants/complex-properties.d.ts.map +0 -1
  311. package/dist/src/constants/complex-properties.js +0 -0
  312. package/dist/src/constants/format-mappings.d.ts.map +0 -1
  313. package/dist/src/constants/format-mappings.js +0 -54
  314. package/dist/src/constants/general-extended-properties.js +0 -254
  315. package/dist/src/constants/index.d.ts.map +0 -1
  316. package/dist/src/constants/index.js +0 -4
  317. package/dist/src/constants/properties.d.ts.map +0 -1
  318. package/dist/src/constants/properties.js +0 -95
  319. package/dist/src/constants/property-types.d.ts.map +0 -1
  320. package/dist/src/constants/property-types.js +0 -0
  321. package/dist/src/constants/specialized-properties.js +0 -223
  322. package/dist/src/constants/utilities.d.ts.map +0 -1
  323. package/dist/src/constants/utilities.js +0 -33
  324. package/dist/src/constants.d.ts.map +0 -1
  325. package/dist/src/constants.js +0 -1
  326. package/dist/src/deno-compile.d.ts.map +0 -1
  327. package/dist/src/deno-compile.js +0 -75
  328. package/dist/src/errors/base.d.ts +0 -23
  329. package/dist/src/errors/base.d.ts.map +0 -1
  330. package/dist/src/errors/base.js +0 -31
  331. package/dist/src/errors/classes.d.ts.map +0 -1
  332. package/dist/src/errors/classes.js +0 -170
  333. package/dist/src/errors/guards.d.ts.map +0 -1
  334. package/dist/src/errors/guards.js +0 -39
  335. package/dist/src/errors/index.d.ts.map +0 -1
  336. package/dist/src/errors/index.js +0 -39
  337. package/dist/src/errors.d.ts.map +0 -1
  338. package/dist/src/errors.js +0 -1
  339. package/dist/src/file-utils/copy-and-find.d.ts.map +0 -1
  340. package/dist/src/file-utils/copy-and-find.js +0 -89
  341. package/dist/src/file-utils/export-operations.d.ts.map +0 -1
  342. package/dist/src/file-utils/export-operations.js +0 -40
  343. package/dist/src/file-utils/import-operations.d.ts.map +0 -1
  344. package/dist/src/file-utils/import-operations.js +0 -42
  345. package/dist/src/file-utils/index.d.ts.map +0 -1
  346. package/dist/src/file-utils/index.js +0 -26
  347. package/dist/src/file-utils/mime-detection.d.ts.map +0 -1
  348. package/dist/src/file-utils/mime-detection.js +0 -45
  349. package/dist/src/folder-api/album-corroborate.d.ts.map +0 -1
  350. package/dist/src/folder-api/album-corroborate.js +0 -36
  351. package/dist/src/folder-api/album-discs.d.ts.map +0 -1
  352. package/dist/src/folder-api/album-discs.js +0 -122
  353. package/dist/src/folder-api/album-grouping.d.ts.map +0 -1
  354. package/dist/src/folder-api/album-grouping.js +0 -118
  355. package/dist/src/folder-api/album-identity.d.ts.map +0 -1
  356. package/dist/src/folder-api/album-identity.js +0 -151
  357. package/dist/src/folder-api/album-types.d.ts.map +0 -1
  358. package/dist/src/folder-api/album-types.js +0 -0
  359. package/dist/src/folder-api/directory-walker.d.ts.map +0 -1
  360. package/dist/src/folder-api/directory-walker.js +0 -35
  361. package/dist/src/folder-api/file-processors.d.ts.map +0 -1
  362. package/dist/src/folder-api/file-processors.js +0 -63
  363. package/dist/src/folder-api/folder-disc.d.ts.map +0 -1
  364. package/dist/src/folder-api/folder-disc.js +0 -169
  365. package/dist/src/folder-api/folder-operations.d.ts.map +0 -1
  366. package/dist/src/folder-api/folder-operations.js +0 -54
  367. package/dist/src/folder-api/index.d.ts.map +0 -1
  368. package/dist/src/folder-api/scan-for-albums.d.ts.map +0 -1
  369. package/dist/src/folder-api/scan-for-albums.js +0 -20
  370. package/dist/src/folder-api/scan-operations.d.ts.map +0 -1
  371. package/dist/src/folder-api/scan-operations.js +0 -77
  372. package/dist/src/folder-api/types.d.ts.map +0 -1
  373. package/dist/src/folder-api/types.js +0 -21
  374. package/dist/src/msgpack/decoder.d.ts.map +0 -1
  375. package/dist/src/msgpack/decoder.js +0 -215
  376. package/dist/src/msgpack/encoder.d.ts.map +0 -1
  377. package/dist/src/msgpack/encoder.js +0 -249
  378. package/dist/src/msgpack/index.d.ts.map +0 -1
  379. package/dist/src/msgpack/index.js +0 -56
  380. package/dist/src/msgpack/types.d.ts.map +0 -1
  381. package/dist/src/msgpack/types.js +0 -12
  382. package/dist/src/msgpack/utils.d.ts.map +0 -1
  383. package/dist/src/msgpack/utils.js +0 -134
  384. package/dist/src/runtime/deno-detect.d.ts.map +0 -1
  385. package/dist/src/runtime/deno-detect.js +0 -6
  386. package/dist/src/runtime/detector.d.ts.map +0 -1
  387. package/dist/src/runtime/detector.js +0 -181
  388. package/dist/src/runtime/loader-types.d.ts.map +0 -1
  389. package/dist/src/runtime/loader-types.js +0 -10
  390. package/dist/src/runtime/module-loader-browser.d.ts.map +0 -1
  391. package/dist/src/runtime/module-loader-browser.js +0 -37
  392. package/dist/src/runtime/module-loader.d.ts.map +0 -1
  393. package/dist/src/runtime/module-loader.js +0 -119
  394. package/dist/src/runtime/platform-io.d.ts.map +0 -1
  395. package/dist/src/runtime/platform-io.js +0 -188
  396. package/dist/src/runtime/unified-loader/index.d.ts.map +0 -1
  397. package/dist/src/runtime/unified-loader/loader.d.ts.map +0 -1
  398. package/dist/src/runtime/unified-loader/loader.js +0 -84
  399. package/dist/src/runtime/unified-loader/module-loading.d.ts.map +0 -1
  400. package/dist/src/runtime/unified-loader/module-loading.js +0 -122
  401. package/dist/src/runtime/unified-loader/module-selection.d.ts.map +0 -1
  402. package/dist/src/runtime/unified-loader/module-selection.js +0 -41
  403. package/dist/src/runtime/unified-loader/types.d.ts.map +0 -1
  404. package/dist/src/runtime/unified-loader/types.js +0 -25
  405. package/dist/src/runtime/wasi-adapter/adapter.d.ts.map +0 -1
  406. package/dist/src/runtime/wasi-adapter/adapter.js +0 -113
  407. package/dist/src/runtime/wasi-adapter/audio-properties.d.ts.map +0 -1
  408. package/dist/src/runtime/wasi-adapter/audio-properties.js +0 -85
  409. package/dist/src/runtime/wasi-adapter/file-handle.d.ts.map +0 -1
  410. package/dist/src/runtime/wasi-adapter/file-handle.js +0 -197
  411. package/dist/src/runtime/wasi-adapter/handle-state.d.ts.map +0 -1
  412. package/dist/src/runtime/wasi-adapter/handle-state.js +0 -58
  413. package/dist/src/runtime/wasi-adapter/index.d.ts.map +0 -1
  414. package/dist/src/runtime/wasi-adapter/mp4-items.d.ts.map +0 -1
  415. package/dist/src/runtime/wasi-adapter/mp4-items.js +0 -80
  416. package/dist/src/runtime/wasi-adapter/property-surface.d.ts.map +0 -1
  417. package/dist/src/runtime/wasi-adapter/property-surface.js +0 -104
  418. package/dist/src/runtime/wasi-adapter/structured-fields.d.ts.map +0 -1
  419. package/dist/src/runtime/wasi-adapter/structured-fields.js +0 -139
  420. package/dist/src/runtime/wasi-adapter/tag-keys.d.ts.map +0 -1
  421. package/dist/src/runtime/wasi-adapter/tag-keys.js +0 -46
  422. package/dist/src/runtime/wasi-adapter/wasm-io.d.ts.map +0 -1
  423. package/dist/src/runtime/wasi-adapter/wasm-io.js +0 -249
  424. package/dist/src/runtime/wasi-fs-deno.d.ts.map +0 -1
  425. package/dist/src/runtime/wasi-fs-deno.js +0 -26
  426. package/dist/src/runtime/wasi-fs-node.d.ts.map +0 -1
  427. package/dist/src/runtime/wasi-fs-node.js +0 -66
  428. package/dist/src/runtime/wasi-fs-provider.d.ts.map +0 -1
  429. package/dist/src/runtime/wasi-fs-provider.js +0 -0
  430. package/dist/src/runtime/wasi-host-loader.d.ts.map +0 -1
  431. package/dist/src/runtime/wasi-host-loader.js +0 -109
  432. package/dist/src/runtime/wasi-host.d.ts.map +0 -1
  433. package/dist/src/runtime/wasi-host.js +0 -202
  434. package/dist/src/runtime/wasi-memory.d.ts.map +0 -1
  435. package/dist/src/runtime/wasi-memory.js +0 -197
  436. package/dist/src/runtime/wasmer-sdk-loader/types.d.ts.map +0 -1
  437. package/dist/src/runtime/wasmer-sdk-loader/types.js +0 -12
  438. package/dist/src/simple/batch-operations.d.ts.map +0 -1
  439. package/dist/src/simple/batch-operations.js +0 -186
  440. package/dist/src/simple/config.d.ts.map +0 -1
  441. package/dist/src/simple/config.js +0 -18
  442. package/dist/src/simple/index.d.ts.map +0 -1
  443. package/dist/src/simple/index.js +0 -58
  444. package/dist/src/simple/picture-operations.d.ts.map +0 -1
  445. package/dist/src/simple/picture-operations.js +0 -68
  446. package/dist/src/simple/tag-operations.d.ts.map +0 -1
  447. package/dist/src/simple/tag-operations.js +0 -90
  448. package/dist/src/simple/with-audio-file.d.ts.map +0 -1
  449. package/dist/src/simple/with-audio-file.js +0 -39
  450. package/dist/src/taglib/audio-file-base.d.ts.map +0 -1
  451. package/dist/src/taglib/audio-file-base.js +0 -187
  452. package/dist/src/taglib/audio-file-bwf.d.ts.map +0 -1
  453. package/dist/src/taglib/audio-file-bwf.js +0 -41
  454. package/dist/src/taglib/audio-file-impl.d.ts.map +0 -1
  455. package/dist/src/taglib/audio-file-impl.js +0 -285
  456. package/dist/src/taglib/audio-file-interface.d.ts.map +0 -1
  457. package/dist/src/taglib/audio-file-interface.js +0 -0
  458. package/dist/src/taglib/auto-dispose.d.ts.map +0 -1
  459. package/dist/src/taglib/auto-dispose.js +0 -13
  460. package/dist/src/taglib/embind-adapter.d.ts.map +0 -1
  461. package/dist/src/taglib/embind-adapter.js +0 -141
  462. package/dist/src/taglib/extra-state-registry.d.ts.map +0 -1
  463. package/dist/src/taglib/extra-state-registry.js +0 -78
  464. package/dist/src/taglib/id3v2-frames.d.ts.map +0 -1
  465. package/dist/src/taglib/id3v2-frames.js +0 -42
  466. package/dist/src/taglib/index.d.ts.map +0 -1
  467. package/dist/src/taglib/index.js +0 -41
  468. package/dist/src/taglib/load-audio-data.d.ts.map +0 -1
  469. package/dist/src/taglib/load-audio-data.js +0 -51
  470. package/dist/src/taglib/metadata-extent.d.ts +0 -41
  471. package/dist/src/taglib/metadata-extent.d.ts.map +0 -1
  472. package/dist/src/taglib/metadata-extent.js +0 -171
  473. package/dist/src/taglib/mp4-item-names.d.ts.map +0 -1
  474. package/dist/src/taglib/mp4-item-names.js +0 -4
  475. package/dist/src/taglib/mutable-tag-impl.d.ts.map +0 -1
  476. package/dist/src/taglib/mutable-tag-impl.js +0 -88
  477. package/dist/src/taglib/mutable-tag.d.ts.map +0 -1
  478. package/dist/src/taglib/mutable-tag.js +0 -0
  479. package/dist/src/taglib/save-reconstruct.d.ts.map +0 -1
  480. package/dist/src/taglib/save-reconstruct.js +0 -43
  481. package/dist/src/taglib/taglib-class.d.ts.map +0 -1
  482. package/dist/src/taglib/taglib-class.js +0 -206
  483. package/dist/src/taglib.d.ts.map +0 -1
  484. package/dist/src/taglib.js +0 -1
  485. package/dist/src/types/audio-formats.d.ts.map +0 -1
  486. package/dist/src/types/audio-formats.js +0 -6
  487. package/dist/src/types/bwf.d.ts.map +0 -1
  488. package/dist/src/types/bwf.js +0 -0
  489. package/dist/src/types/chapters.d.ts.map +0 -1
  490. package/dist/src/types/chapters.js +0 -0
  491. package/dist/src/types/config.d.ts.map +0 -1
  492. package/dist/src/types/config.js +0 -0
  493. package/dist/src/types/format-property-keys.d.ts.map +0 -1
  494. package/dist/src/types/format-property-keys.js +0 -0
  495. package/dist/src/types/index.d.ts.map +0 -1
  496. package/dist/src/types/index.js +0 -8
  497. package/dist/src/types/metadata-mappings.d.ts.map +0 -1
  498. package/dist/src/types/metadata-mappings.js +0 -252
  499. package/dist/src/types/pictures.d.ts.map +0 -1
  500. package/dist/src/types/pictures.js +0 -64
  501. package/dist/src/types/tags.d.ts.map +0 -1
  502. package/dist/src/types/tags.js +0 -0
  503. package/dist/src/types.d.ts.map +0 -1
  504. package/dist/src/types.js +0 -1
  505. package/dist/src/utils/file.d.ts.map +0 -1
  506. package/dist/src/utils/file.js +0 -52
  507. package/dist/src/utils/mirror-fields.d.ts.map +0 -1
  508. package/dist/src/utils/mirror-fields.js +0 -75
  509. package/dist/src/utils/node-fs.d.ts.map +0 -1
  510. package/dist/src/utils/node-fs.js +0 -22
  511. package/dist/src/utils/path.d.ts +0 -14
  512. package/dist/src/utils/path.d.ts.map +0 -1
  513. package/dist/src/utils/path.js +0 -17
  514. package/dist/src/utils/rating.d.ts.map +0 -1
  515. package/dist/src/utils/rating.js +0 -73
  516. package/dist/src/utils/tag-mapping.d.ts.map +0 -1
  517. package/dist/src/utils/tag-mapping.js +0 -214
  518. package/dist/src/utils/write.d.ts.map +0 -1
  519. package/dist/src/utils/write.js +0 -17
  520. package/dist/src/version.d.ts +0 -2
  521. package/dist/src/version.d.ts.map +0 -1
  522. package/dist/src/version.js +0 -4
  523. package/dist/src/wasm.d.ts.map +0 -1
  524. package/dist/src/wasm.js +0 -0
  525. package/dist/src/web-utils/canvas.d.ts.map +0 -1
  526. package/dist/src/web-utils/canvas.js +0 -60
  527. package/dist/src/web-utils/data-url.d.ts.map +0 -1
  528. package/dist/src/web-utils/data-url.js +0 -34
  529. package/dist/src/web-utils/dom-integration.d.ts.map +0 -1
  530. package/dist/src/web-utils/dom-integration.js +0 -53
  531. package/dist/src/web-utils/index.d.ts.map +0 -1
  532. package/dist/src/web-utils/index.js +0 -21
  533. /package/dist/{src/bwf → bwf}/bext.d.ts +0 -0
  534. /package/dist/{src/constants → constants}/additional-properties.d.ts +0 -0
  535. /package/dist/{src/constants → constants}/basic-properties.d.ts +0 -0
  536. /package/dist/{src/constants → constants}/complex-properties.d.ts +0 -0
  537. /package/dist/{src/constants → constants}/format-mappings.d.ts +0 -0
  538. /package/dist/{src/constants → constants}/general-extended-properties.d.ts +0 -0
  539. /package/dist/{src/constants → constants}/index.d.ts +0 -0
  540. /package/dist/{src/constants → constants}/property-types.d.ts +0 -0
  541. /package/dist/{src/constants → constants}/specialized-properties.d.ts +0 -0
  542. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  543. /package/dist/{src/errors → errors}/classes.d.ts +0 -0
  544. /package/dist/{src/errors → errors}/guards.d.ts +0 -0
  545. /package/dist/{src/errors → errors}/index.d.ts +0 -0
  546. /package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
  547. /package/dist/{src/file-utils → file-utils}/copy-and-find.d.ts +0 -0
  548. /package/dist/{src/file-utils → file-utils}/export-operations.d.ts +0 -0
  549. /package/dist/{src/file-utils → file-utils}/import-operations.d.ts +0 -0
  550. /package/dist/{src/file-utils → file-utils}/index.d.ts +0 -0
  551. /package/dist/{src/file-utils → file-utils}/mime-detection.d.ts +0 -0
  552. /package/dist/{src/folder-api → folder-api}/album-corroborate.d.ts +0 -0
  553. /package/dist/{src/folder-api → folder-api}/album-discs.d.ts +0 -0
  554. /package/dist/{src/folder-api → folder-api}/album-grouping.d.ts +0 -0
  555. /package/dist/{src/folder-api → folder-api}/album-identity.d.ts +0 -0
  556. /package/dist/{src/folder-api → folder-api}/album-types.d.ts +0 -0
  557. /package/dist/{src/folder-api → folder-api}/directory-walker.d.ts +0 -0
  558. /package/dist/{src/folder-api → folder-api}/file-processors.d.ts +0 -0
  559. /package/dist/{src/folder-api → folder-api}/folder-disc.d.ts +0 -0
  560. /package/dist/{src/folder-api → folder-api}/folder-operations.d.ts +0 -0
  561. /package/dist/{src/folder-api → folder-api}/index.d.ts +0 -0
  562. /package/dist/{src/folder-api → folder-api}/scan-for-albums.d.ts +0 -0
  563. /package/dist/{src/folder-api → folder-api}/scan-operations.d.ts +0 -0
  564. /package/dist/{src/folder-api → folder-api}/types.d.ts +0 -0
  565. /package/dist/{src/msgpack → msgpack}/decoder.d.ts +0 -0
  566. /package/dist/{src/msgpack → msgpack}/encoder.d.ts +0 -0
  567. /package/dist/{src/msgpack → msgpack}/index.d.ts +0 -0
  568. /package/dist/{src/msgpack → msgpack}/utils.d.ts +0 -0
  569. /package/dist/{src/runtime → runtime}/deno-detect.d.ts +0 -0
  570. /package/dist/{src/runtime → runtime}/loader-types.d.ts +0 -0
  571. /package/dist/{src/runtime → runtime}/module-loader-browser.d.ts +0 -0
  572. /package/dist/{src/runtime → runtime}/module-loader.d.ts +0 -0
  573. /package/dist/{src/runtime → runtime}/platform-io.d.ts +0 -0
  574. /package/dist/{src/runtime → runtime}/unified-loader/index.d.ts +0 -0
  575. /package/dist/{src/runtime → runtime}/unified-loader/loader.d.ts +0 -0
  576. /package/dist/{src/runtime → runtime}/unified-loader/module-loading.d.ts +0 -0
  577. /package/dist/{src/runtime → runtime}/unified-loader/module-selection.d.ts +0 -0
  578. /package/dist/{src/runtime → runtime}/unified-loader/types.d.ts +0 -0
  579. /package/dist/{src/runtime → runtime}/wasi-adapter/file-handle.d.ts +0 -0
  580. /package/dist/{src/runtime → runtime}/wasi-adapter/handle-state.d.ts +0 -0
  581. /package/dist/{src/runtime → runtime}/wasi-adapter/index.d.ts +0 -0
  582. /package/dist/{src/runtime → runtime}/wasi-adapter/mp4-items.d.ts +0 -0
  583. /package/dist/{src/runtime → runtime}/wasi-adapter/property-surface.d.ts +0 -0
  584. /package/dist/{src/runtime → runtime}/wasi-adapter/structured-fields.d.ts +0 -0
  585. /package/dist/{src/runtime → runtime}/wasi-adapter/tag-keys.d.ts +0 -0
  586. /package/dist/{src/runtime → runtime}/wasi-adapter/wasm-io.d.ts +0 -0
  587. /package/dist/{src/runtime → runtime}/wasi-fs-deno.d.ts +0 -0
  588. /package/dist/{src/runtime → runtime}/wasi-fs-node.d.ts +0 -0
  589. /package/dist/{src/runtime → runtime}/wasi-fs-provider.d.ts +0 -0
  590. /package/dist/{src/runtime → runtime}/wasi-host-loader.d.ts +0 -0
  591. /package/dist/{src/runtime → runtime}/wasi-host.d.ts +0 -0
  592. /package/dist/{src/runtime → runtime}/wasi-memory.d.ts +0 -0
  593. /package/dist/{src/simple → simple}/batch-operations.d.ts +0 -0
  594. /package/dist/{src/simple → simple}/config.d.ts +0 -0
  595. /package/dist/{src/simple → simple}/picture-operations.d.ts +0 -0
  596. /package/dist/{src/simple → simple}/tag-operations.d.ts +0 -0
  597. /package/dist/{src/simple → simple}/with-audio-file.d.ts +0 -0
  598. /package/dist/{src/taglib → taglib}/audio-file-base.d.ts +0 -0
  599. /package/dist/{src/taglib → taglib}/audio-file-bwf.d.ts +0 -0
  600. /package/dist/{src/taglib → taglib}/auto-dispose.d.ts +0 -0
  601. /package/dist/{src/taglib → taglib}/embind-adapter.d.ts +0 -0
  602. /package/dist/{src/taglib → taglib}/extra-state-registry.d.ts +0 -0
  603. /package/dist/{src/taglib → taglib}/index.d.ts +0 -0
  604. /package/dist/{src/taglib → taglib}/load-audio-data.d.ts +0 -0
  605. /package/dist/{src/taglib → taglib}/mp4-item-names.d.ts +0 -0
  606. /package/dist/{src/taglib → taglib}/mutable-tag-impl.d.ts +0 -0
  607. /package/dist/{src/taglib → taglib}/mutable-tag.d.ts +0 -0
  608. /package/dist/{src/taglib → taglib}/save-reconstruct.d.ts +0 -0
  609. /package/dist/{src/taglib → taglib}/taglib-class.d.ts +0 -0
  610. /package/dist/{src/taglib.d.ts → taglib.d.ts} +0 -0
  611. /package/dist/{src/types → types}/audio-formats.d.ts +0 -0
  612. /package/dist/{src/types → types}/bwf.d.ts +0 -0
  613. /package/dist/{src/types → types}/chapters.d.ts +0 -0
  614. /package/dist/{src/types → types}/config.d.ts +0 -0
  615. /package/dist/{src/types → types}/format-property-keys.d.ts +0 -0
  616. /package/dist/{src/types → types}/index.d.ts +0 -0
  617. /package/dist/{src/types → types}/metadata-mappings.d.ts +0 -0
  618. /package/dist/{src/types → types}/pictures.d.ts +0 -0
  619. /package/dist/{src/types → types}/tags.d.ts +0 -0
  620. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  621. /package/dist/{src/utils → utils}/file.d.ts +0 -0
  622. /package/dist/{src/utils → utils}/mirror-fields.d.ts +0 -0
  623. /package/dist/{src/utils → utils}/node-fs.d.ts +0 -0
  624. /package/dist/{src/utils → utils}/rating.d.ts +0 -0
  625. /package/dist/{src/utils → utils}/tag-mapping.d.ts +0 -0
  626. /package/dist/{src/utils → utils}/write.d.ts +0 -0
  627. /package/dist/{src/web-utils → web-utils}/canvas.d.ts +0 -0
  628. /package/dist/{src/web-utils → web-utils}/data-url.d.ts +0 -0
  629. /package/dist/{src/web-utils → web-utils}/dom-integration.d.ts +0 -0
  630. /package/dist/{src/web-utils → web-utils}/index.d.ts +0 -0
@@ -0,0 +1,309 @@
1
+ import { flacAudioStart, flacMarkerOffset, id3v2End, mpegFrameLength } from "./metadata-extent.js";
2
+ //#region src/taglib/media-ranges.ts
3
+ const decoder = new TextDecoder();
4
+ const text = (b, o, n) => decoder.decode(b.subarray(o, o + n));
5
+ /** Every walk's "I cannot vouch for this" answer: the caller then hashes the
6
+ * whole file and reports source: "file". */
7
+ const fallback = (detail) => ({
8
+ kind: "fallback",
9
+ ranges: [],
10
+ detail
11
+ });
12
+ /**
13
+ * ADTS (raw AAC) frame length: 13 bits spanning bytes 3..5, header included.
14
+ * Syncword 0xFFF plus the layer bits that must be zero — which is exactly the
15
+ * header `mpegFrameLength` rejects (metadata-extent.ts returns 0 for
16
+ * `layer === 0`), so this is a rule of its own rather than a variant of it.
17
+ */
18
+ function adtsFrameLength(bytes, at) {
19
+ if (bytes.length < at + 7) return 0;
20
+ if (bytes[at] !== 255 || (bytes[at + 1] & 246) !== 240) return 0;
21
+ const length = (bytes[at + 3] & 3) << 11 | bytes[at + 4] << 3 | bytes[at + 5] >> 5;
22
+ return length >= 7 ? length : 0;
23
+ }
24
+ /** The frame length either rule recognises at `at`, or 0. */
25
+ const frameLengthAt = (bytes, at) => mpegFrameLength(bytes, at) || adtsFrameLength(bytes, at);
26
+ /**
27
+ * Start offset of a trailing tag run (ID3v1 and/or APEv2), scanning inward.
28
+ * TagLib ends a FLAC stream at its ID3v1 location for the same reason.
29
+ */
30
+ function trailingTagStart(bytes, end = bytes.length) {
31
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
32
+ let at = Math.max(0, Math.min(end, bytes.length));
33
+ for (;;) {
34
+ if (at >= 128 && text(bytes, at - 128, 3) === "TAG") {
35
+ at -= 128;
36
+ continue;
37
+ }
38
+ if (at >= 32 && text(bytes, at - 32, 8) === "APETAGEX") {
39
+ const size = view.getUint32(at - 32 + 12, true);
40
+ const flags = view.getUint32(at - 32 + 20, true);
41
+ const start = at - size - ((flags & 2147483648) !== 0 ? 32 : 0);
42
+ if (start < 0 || start >= at) return at;
43
+ at = start;
44
+ continue;
45
+ }
46
+ return at;
47
+ }
48
+ }
49
+ /** How far past the scan's start the MPEG first-frame hunt will look. A file
50
+ * whose audio does not start within this window is not one whose offsets this
51
+ * walk may vouch for, and an unbounded hunt turns a junk buffer into a
52
+ * quadratic scan. That bound is also why an MP3 with a large APEv2 tag *in
53
+ * front of* the audio falls back rather than guessing: `id3v2End` skips only
54
+ * ID3v2 (measured: a 70 KiB front area puts the first frame past the window and
55
+ * the walk falls back, while a 1 KiB one is found normally). */
56
+ const MPEG_SCAN_LIMIT = 65536;
57
+ /**
58
+ * First frame: skip ID3v2, then require two consecutive plausible frames. The
59
+ * hunt is bounded to `MPEG_SCAN_LIMIT` past the scan's start so a junk buffer
60
+ * cannot turn into a quadratic scan.
61
+ */
62
+ function firstFrame(bytes) {
63
+ const from = id3v2End(bytes) ?? 0;
64
+ const limit = Math.min(bytes.length - 6, from + MPEG_SCAN_LIMIT);
65
+ for (let o = from; o < limit; o++) {
66
+ const len = frameLengthAt(bytes, o);
67
+ if (len > 0 && frameLengthAt(bytes, o + len) > 0) return o;
68
+ }
69
+ return -1;
70
+ }
71
+ /**
72
+ * Forward walk from the first frame to the last: the authority for where the
73
+ * payload ends, O(frames).
74
+ *
75
+ * There is deliberately no backward scan to cross-check it. The spike used one
76
+ * to derive the boundary rule — a reverse scan is O(payload) per file, and a
77
+ * candidate that merely "fits inside" the payload is not the last frame, because
78
+ * a false sync can sit within the last frame's own payload (measured on
79
+ * kiss-snippet.mp3: an offer at 84558+72 inside the real frame ending at 85226).
80
+ * The rule that survived is "stop on the first frame that would cross the
81
+ * boundary": the payload ends at the last frame that ends at or before it, so
82
+ * the walk can stop short of the boundary rather than land on it — on
83
+ * ape-id3v1.mp3 it ends at 8150 against a trim boundary of 8208. A reverse pass
84
+ * could never change that answer, and would run in addition to the forward walk
85
+ * rather than instead of it.
86
+ */
87
+ function forwardLastFrame(bytes, from, end) {
88
+ let o = from;
89
+ let start = -1;
90
+ let length = 0;
91
+ let frames = 0;
92
+ while (o + 6 <= end) {
93
+ const len = frameLengthAt(bytes, o);
94
+ if (len === 0 || o + len > end) break;
95
+ start = o;
96
+ length = len;
97
+ frames++;
98
+ o += len;
99
+ }
100
+ return {
101
+ start,
102
+ length,
103
+ frames
104
+ };
105
+ }
106
+ function walkMpeg(bytes) {
107
+ const from = firstFrame(bytes);
108
+ if (from < 0) return fallback("no valid first frame");
109
+ const last = forwardLastFrame(bytes, from, trailingTagStart(bytes));
110
+ if (last.start < 0) return fallback("no valid frames");
111
+ return {
112
+ kind: "ranges",
113
+ ranges: [{
114
+ offset: from,
115
+ length: last.start + last.length - from
116
+ }],
117
+ detail: `first=${from} last=${last.start}+${last.length} frames=${last.frames}`
118
+ };
119
+ }
120
+ /** STREAMINFO is a FLAC file's first metadata block: the `fLaC` marker, a
121
+ * 4-byte block header, then its 34-byte payload, whose last 16 bytes are the
122
+ * MD5 of the *uncompressed* stream — the digest `basis: "pcm"` reports. */
123
+ function flacStreamInfoMd5(bytes) {
124
+ const marker = flacMarkerOffset(bytes);
125
+ if (marker === void 0) return void 0;
126
+ const header = marker + 4;
127
+ if (header + 4 > bytes.length) return void 0;
128
+ if ((bytes[header] & 127) !== 0) return void 0;
129
+ if ((bytes[header + 1] << 16 | bytes[header + 2] << 8 | bytes[header + 3]) < 34) return void 0;
130
+ const payload = header + 4;
131
+ if (payload + 34 > bytes.length) return void 0;
132
+ let hex = "";
133
+ for (const byte of bytes.subarray(payload + 18, payload + 34)) hex += byte.toString(16).padStart(2, "0");
134
+ return hex;
135
+ }
136
+ /**
137
+ * FLAC's encoded payload: the audio frames between the end of the metadata
138
+ * block chain and an appended ID3v1/APEv2 tag. An appended ID3v2 is *inside*
139
+ * the payload: TagLib ends a FLAC stream at its ID3v1 location
140
+ * (`flacfile.cpp:595-599`), and a tag not at that location is stream by the
141
+ * same rule — TagLib is this feature's ground truth, so the boundary is pinned
142
+ * by `tests/media-ranges.test.ts`, not "fixed" here. Nothing inside a FLAC
143
+ * stream delimits the frames — the block chain's end is the start, and the
144
+ * stream runs to EOF — so the whole rule is the block walk plus the
145
+ * trailing-tag trim.
146
+ *
147
+ * `flacAudioStart` may legitimately answer past `bytes.length`, because a
148
+ * block's declared length can reach beyond the bytes in hand: that is the
149
+ * extent the chain *implies*, and hashing it would read nothing while claiming
150
+ * a payload. The `end <= start` guard is what refuses it.
151
+ *
152
+ * The walk deliberately does **not** carry the STREAMINFO digest: a range result
153
+ * is not a digest carrier, and the PCM basis reads the digest with
154
+ * `flacStreamInfoMd5` directly. A second, unread path to the same value rots.
155
+ */
156
+ function walkFlac(bytes) {
157
+ const start = flacAudioStart(bytes);
158
+ if (start === void 0) return fallback("no fLaC marker");
159
+ const end = trailingTagStart(bytes);
160
+ if (end <= start) return fallback("no audio bytes");
161
+ return {
162
+ kind: "ranges",
163
+ ranges: [{
164
+ offset: start,
165
+ length: end - start
166
+ }],
167
+ detail: `audioStart=${start} end=${end}`
168
+ };
169
+ }
170
+ /** Length of the atom starting at `o`, or `undefined` when its size field is
171
+ * malformed. `size === 0` runs to end of file (8-byte header); `size === 1`
172
+ * means the real length is the 64-bit value after the type. */
173
+ function atomLength(bytes, view, o) {
174
+ const size = view.getUint32(o, false);
175
+ if (size === 0) return {
176
+ length: bytes.length - o,
177
+ headerSize: 8
178
+ };
179
+ if (size === 1) {
180
+ if (o + 16 > bytes.length) return void 0;
181
+ const big = view.getBigUint64(o + 8, false);
182
+ if (big > BigInt(Number.MAX_SAFE_INTEGER)) return void 0;
183
+ return {
184
+ length: Number(big),
185
+ headerSize: 16
186
+ };
187
+ }
188
+ return {
189
+ length: size,
190
+ headerSize: 8
191
+ };
192
+ }
193
+ /**
194
+ * MP4's payload: the contents of every non-empty top-level `mdat`, in file
195
+ * order — a fragmented file spreads its audio over several, and a rewritten one
196
+ * may carry an empty `mdat`, which is legal and contributes nothing. The header
197
+ * is excluded, and it is 16 bytes rather than 8 when the size took the 64-bit
198
+ * form.
199
+ *
200
+ * Deliberately not `metadata-extent.ts`'s atom walk: that one looks for `moov`
201
+ * to size the partial-load gate, so it bails on any size below 8 and has no
202
+ * 64-bit path. The checksum's rules differ — `size === 0` runs to EOF, a 64-bit
203
+ * size is legal, and anything the walk cannot fully account for is a fallback —
204
+ * so the two contracts stay apart rather than share an abstraction.
205
+ *
206
+ * Those fallbacks are the point. A range that runs past the buffer would hash
207
+ * zero padding while `bytesHashed` counts it as payload, and bytes no atom
208
+ * accounts for are not something this walk may call audio.
209
+ */
210
+ function walkMp4(bytes) {
211
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
212
+ const ranges = [];
213
+ let o = 0;
214
+ while (o + 8 <= bytes.length) {
215
+ const type = text(bytes, o + 4, 4);
216
+ const atom = atomLength(bytes, view, o);
217
+ if (atom === void 0) return fallback(`malformed ${type} size`);
218
+ if (atom.length < atom.headerSize) return fallback(`malformed ${type} size`);
219
+ if (o + atom.length > bytes.length) return fallback(`oversized ${type}`);
220
+ if (type === "mdat" && atom.length > atom.headerSize) ranges.push({
221
+ offset: o + atom.headerSize,
222
+ length: atom.length - atom.headerSize
223
+ });
224
+ o += atom.length;
225
+ }
226
+ if (o !== bytes.length) return fallback("trailing bytes after the last atom");
227
+ if (ranges.length === 0) return fallback("no non-empty mdat");
228
+ return {
229
+ kind: "ranges",
230
+ ranges,
231
+ detail: `${ranges.length} mdat(s)`
232
+ };
233
+ }
234
+ /**
235
+ * WAV's payload: every non-empty `data` chunk's contents, payload only.
236
+ *
237
+ * The chunk list is the whole rule: a chunk is a 4-byte id, a 4-byte
238
+ * little-endian size that counts the payload but not the header, and that
239
+ * payload padded to an even length. Tag chunks (`LIST`, `id3 `, `bext`, `iXML`)
240
+ * are therefore skipped by construction rather than by name, and chunks that
241
+ * follow `data` cannot move or clip the range — which is the property the
242
+ * repo's `wav/kiss-snippet.wav` pins, `data` first and `LIST` + `id3 ` behind it.
243
+ *
244
+ * A chunk whose declared size reaches past the buffer is a fallback, not a
245
+ * clamp: hashing the bytes that survive would report a payload the file does not
246
+ * claim. That is also the truncated-file case.
247
+ */
248
+ function walkWav(bytes) {
249
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
250
+ if (text(bytes, 0, 4) !== "RIFF") return fallback("not RIFF");
251
+ if (text(bytes, 8, 4) !== "WAVE") return fallback("not WAVE");
252
+ const ranges = [];
253
+ let o = 12;
254
+ while (o + 8 <= bytes.length) {
255
+ const id = text(bytes, o, 4);
256
+ const size = view.getUint32(o + 4, true);
257
+ const dataStart = o + 8;
258
+ if (dataStart + size > bytes.length) return fallback(`truncated ${id}`);
259
+ if (id === "data" && size > 0) ranges.push({
260
+ offset: dataStart,
261
+ length: size
262
+ });
263
+ o = dataStart + size + size % 2;
264
+ }
265
+ if (ranges.length === 0) return fallback("no data chunk");
266
+ return {
267
+ kind: "ranges",
268
+ ranges,
269
+ detail: `${ranges.length} data chunk(s)`
270
+ };
271
+ }
272
+ /**
273
+ * The per-format dispatch: the one entry point a consumer calls, and the one
274
+ * place a format-level fallback becomes a whole-file range.
275
+ *
276
+ * Consumers MUST dispatch on `kind`, never on `ranges.length`. The walks
277
+ * themselves answer a fallback with `ranges: []`, which this function replaces
278
+ * with the whole file — so after normalization there is no empty-ranges answer
279
+ * to detect, and a caller testing `ranges.length === 0` would read a fallback as
280
+ * a genuine payload and hash the whole file while claiming a range.
281
+ */
282
+ function mediaRanges(format, bytes) {
283
+ const walked = (() => {
284
+ switch (format.toUpperCase()) {
285
+ case "MP3":
286
+ case "AAC": return walkMpeg(bytes);
287
+ case "FLAC": return walkFlac(bytes);
288
+ case "MP4":
289
+ case "M4A": return walkMp4(bytes);
290
+ case "WAV": return walkWav(bytes);
291
+ default: return {
292
+ kind: "fallback",
293
+ ranges: [],
294
+ detail: "format not covered"
295
+ };
296
+ }
297
+ })();
298
+ if (walked.kind === "fallback") return {
299
+ kind: "fallback",
300
+ ranges: [{
301
+ offset: 0,
302
+ length: bytes.length
303
+ }],
304
+ detail: `${walked.detail} → whole file`
305
+ };
306
+ return walked;
307
+ }
308
+ //#endregion
309
+ export { flacStreamInfoMd5, mediaRanges, trailingTagStart, walkFlac, walkMp4, walkMpeg, walkWav };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @fileoverview Is a file's metadata provably contained in its first N bytes?
3
+ *
4
+ * Partial loading (`TagLib.open(path, { partial: true })`) hands TagLib the
5
+ * file's first `maxHeaderSize` bytes concatenated with its last `maxFooterSize`
6
+ * bytes, discarding the middle. That is only sound when the metadata lives
7
+ * entirely inside the header window: otherwise the tag is cut mid-structure and
8
+ * unrelated footer bytes are spliced onto the cut, so TagLib parses whatever
9
+ * lands there. Measured on a real library, 18 of 40 large MP3s read back
10
+ * DIFFERENT metadata that way, and before taglib-f5hp the malformed image also
11
+ * tripped a double free that trapped the whole Wasm module (taglib-f5hp).
12
+ *
13
+ * So the decision is made before splicing, and the rule is deliberately
14
+ * asymmetric: return true ONLY when the metadata is provably contained. Anything
15
+ * unrecognised, malformed, or unbounded answers false, which costs a full read
16
+ * and never costs correctness.
17
+ *
18
+ * The container walkers themselves are exported (id3v2End, mpegFrameLength,
19
+ * flacAudioStart, flacMarkerOffset) because the media checksum walks the same
20
+ * containers to find a file's encoded-audio payload. One walker per container:
21
+ * a second copy of these rules could silently disagree with the one that
22
+ * decides whether a splice is safe.
23
+ */
24
+ /**
25
+ * End of an ID3v2 tag at offset 0, or undefined when there is none.
26
+ *
27
+ * The size field is "syncsafe": seven bits per byte, so the high bit can never
28
+ * produce a false frame sync. A footer, when the flags say there is one, adds
29
+ * ten bytes that the size does not cover.
30
+ *
31
+ * The `ID3` magic check is part of the contract, not a convenience: the size
32
+ * arithmetic reads a number out of any ten bytes, so a tagless buffer would
33
+ * otherwise report 22.8 million as the end of a tag it does not have. Callers
34
+ * that have already established the magic pay one comparison for it; callers
35
+ * that have not (the media checksum walks) need it.
36
+ */
37
+ export declare function id3v2End(bytes: Uint8Array): number | undefined;
38
+ /**
39
+ * Offset of FLAC's `fLaC` stream marker — at 0, or just past a prepended ID3v2
40
+ * tag (TagLib supports exactly that, flacfile.cpp:90) — or undefined when
41
+ * neither is there. A caller that only wants STREAMINFO can seek straight to it
42
+ * instead of walking the metadata-block chain.
43
+ */
44
+ export declare function flacMarkerOffset(bytes: Uint8Array): number | undefined;
45
+ /**
46
+ * Offset of FLAC's first audio byte: the end of the metadata-block chain, past
47
+ * the optional ID3v2 tag.
48
+ *
49
+ * The chain is walked from block headers alone, so the result can exceed
50
+ * `bytes.length` when a block's declared length reaches past the buffer — that
51
+ * is the extent the chain implies, and the caller decides whether it holds
52
+ * enough of the file to believe it. A buffer too short to hold the next block
53
+ * header has no implied extent at all and answers undefined, as does one with
54
+ * no `fLaC` marker.
55
+ */
56
+ export declare function flacAudioStart(bytes: Uint8Array): number | undefined;
57
+ /**
58
+ * Length in bytes of the MPEG (Layer I/II/III) frame whose header sits at `at`,
59
+ * or 0 when `at` is not a plausible frame header.
60
+ *
61
+ * Plausibility is the header alone: eleven sync bits, a non-reserved version
62
+ * and layer, a bitrate index that is neither free (0) nor invalid (15), and a
63
+ * sample-rate index that is not reserved (3). Nothing here looks at what
64
+ * FOLLOWS the frame — a frame header at the very end of a file is as plausible
65
+ * as any other, which is what lets a walk reach the last frame. Callers that
66
+ * need confidence the bytes really are MPEG audio want isMpegFrameSync, which
67
+ * adds the next-header consistency check.
68
+ *
69
+ * The arithmetic mirrors mpegheader.cpp:236-264: bitrate/sample-rate tables
70
+ * plus the padding bit, and C++ integer division truncates.
71
+ */
72
+ export declare function mpegFrameLength(bytes: Uint8Array, at: number): number;
73
+ /**
74
+ * True only when the metadata of `header` provably ends within `limit` bytes.
75
+ *
76
+ * `header` is the start of the file and may be shorter than `limit`; anything
77
+ * this cannot prove — an unknown container, a truncated header, a malformed
78
+ * size — answers false so the caller reads the whole file.
79
+ *
80
+ * NOTE this judges the HEADER window only. Trailer metadata (ID3v1, APE) is the
81
+ * caller's business — see trailerFitsInFooter.
82
+ */
83
+ export declare function metadataFitsInHeader(header: Uint8Array, limit: number): boolean;
84
+ /**
85
+ * True when a file's TRAILER metadata provably fits in the last `footerSize`
86
+ * bytes, given `tail` — the end of the file, at least that long.
87
+ *
88
+ * Partial loading keeps the file's last `footerSize` bytes, so ID3v1 (always
89
+ * exactly 128 bytes) is safe by construction. APEv2 is not: it is unbounded
90
+ * because it can carry cover art, and an APE tag larger than the footer window
91
+ * is spliced so that TagLib computes its start inside the header window's audio
92
+ * and reads nothing. Measured: a 410 KB APE tag lost EVERY tag value silently,
93
+ * while a 41 KB one round-tripped.
94
+ */
95
+ export declare function trailerFitsInFooter(tail: Uint8Array, footerSize: number): boolean;
96
+ //# sourceMappingURL=metadata-extent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-extent.d.ts","sourceRoot":"","sources":["../../src/taglib/metadata-extent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAqBH;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAK9D;AA2BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAItE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAIpE;AAwGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CA4BrE;AAsED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAiCT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAuBT"}