diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b9e22b84d3..410d028ca0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -47,6 +47,10 @@ jobs: run: | echo "C:\Program Files\Git\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "C:\Program Files\Git\mingw64\libexec\git-core" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: install setup tools + if: runner.os == 'macOS' + run: | + sudo -H pip install setuptools - run: npm ci - run: npm run lint - run: npm test @@ -92,6 +96,10 @@ jobs: run: | echo "C:\Program Files\Git\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "C:\Program Files\Git\mingw64\libexec\git-core" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: install setup tools + if: runner.os == 'macOS' + run: | + sudo -H pip install setuptools - run: npm ci - run: npm run ${{ matrix.platform.cmd }} shell: bash diff --git a/.gitignore b/.gitignore index 271c1c0bb7..c95bd90f3d 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,4 @@ build-dir #Travis/IDE stuff .travis.yml .vs/ +target/* \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..a1f318d9ca --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1149 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbe3c979c178231552ecba20214a8272df4e09f232a87aef4320cf06539aded" + +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "exr" +version = "1.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "fdeflate" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "flate2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gif" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "id3" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9389dd9c8c4671b1e4b2878a6329bccb573f9c24a75bc91c641c451ce5436501" +dependencies = [ + "bitflags 2.3.2", + "byteorder", + "flate2", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "image" +version = "0.24.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "exr", + "gif", + "jpeg-decoder", + "num-rational", + "num-traits", + "png", + "qoi", + "tiff", + "webp", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" +dependencies = [ + "rayon", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + +[[package]] +name = "libc" +version = "0.2.146" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" + +[[package]] +name = "libloading" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libwebp-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0df0a0f9444d52aee6335cd724d21a2ee3285f646291799a72be518ec8ee3c" +dependencies = [ + "cc", + "glob", +] + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "md5" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "metaflac" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1470d3cc1bb0d692af5eb3afb594330b8ba09fd91c32c4e1c6322172a5ba750" +dependencies = [ + "byteorder", + "hex", + "log", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + +[[package]] +name = "mockall" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "mp3-duration" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348bdc7300502f0801e5b57c448815713cd843b744ef9bda252a2698fdf90a0f" +dependencies = [ + "thiserror", +] + +[[package]] +name = "mp4ameta" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb23d62e8eb5299a3f79657c70ea9269eac8f6239a76952689bcd06a74057e81" +dependencies = [ + "lazy_static", + "mp4ameta_proc", +] + +[[package]] +name = "mp4ameta_proc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07dcca13d1740c0a665f77104803360da0bdb3323ecce2e93fa2c959a6d52806" + +[[package]] +name = "neon" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e15415261d880aed48122e917a45e87bb82cf0260bb6db48bbab44b7464373" +dependencies = [ + "neon-build", + "neon-macros", + "neon-runtime", + "semver", + "smallvec", +] + +[[package]] +name = "neon-build" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bac98a702e71804af3dacfde41edde4a16076a7bbe889ae61e56e18c5b1c811" + +[[package]] +name = "neon-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7288eac8b54af7913c60e0eb0e2a7683020dffa342ab3fd15e28f035ba897cf" +dependencies = [ + "quote", + "syn 1.0.109", + "syn-mid", +] + +[[package]] +name = "neon-runtime" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4676720fa8bb32c64c3d9f49c47a47289239ec46b4bdb66d0913cc512cb0daca" +dependencies = [ + "cfg-if", + "libloading", + "smallvec", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "png" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "scanner" +version = "0.1.0" +dependencies = [ + "derive_builder", + "id3", + "image", + "md5", + "metaflac", + "mockall", + "mp3-duration", + "mp4ameta", + "neon", + "symphonia", + "uuid", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "symphonia" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62e48dba70095f265fdb269b99619b95d04c89e619538138383e63310b14d941" +dependencies = [ + "lazy_static", + "symphonia-bundle-flac", + "symphonia-bundle-mp3", + "symphonia-codec-aac", + "symphonia-codec-adpcm", + "symphonia-codec-pcm", + "symphonia-codec-vorbis", + "symphonia-core", + "symphonia-format-isomp4", + "symphonia-format-mkv", + "symphonia-format-ogg", + "symphonia-format-wav", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-bundle-flac" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f23b0482a7cb18fcdf9981ab0b78df800ef0080187d294650023c462439058d" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-bundle-mp3" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f31d7fece546f1e6973011a9eceae948133bbd18fd3d52f6073b1e38ae6368a" +dependencies = [ + "bitflags 1.3.2", + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-codec-aac" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bdd75b25ce4b84b12a4bd20bfea2460c2dbd7fc1d227ef5533504d3168109d" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-adpcm" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "870e7dc1865d818c7b6318879d060553a73a3b2a3b8443dff90910f10ac41150" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-pcm" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47f1fbd220a06a641c8ce2ddad10f5ef6ee5cc0c54d9044d25d43b0d3119deaa" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-vorbis" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3953397e3506aa01350c4205817e4f95b58d476877a42f0458d07b665749e203" +dependencies = [ + "log", + "symphonia-core", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c73eb88fee79705268cc7b742c7bc93a7b76e092ab751d0833866970754142" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "bytemuck", + "lazy_static", + "log", +] + +[[package]] +name = "symphonia-format-isomp4" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf14bae5cf352032416bc64151e5d6242d29d33cbf3238513b44d4427a1efb" +dependencies = [ + "encoding_rs", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-mkv" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5c61dfc851ad25d4043d8c231d8617e8f7cd02a6cc0edad21ade21848d58895" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-ogg" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bf1a00ccd11452d44048a0368828040f778ae650418dbd9d8765b7ee2574c8d" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-wav" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da76614728fa27c003bdcdfbac51396bd8fcbf94c95fe8e62f1d2bac58ef03a4" +dependencies = [ + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-metadata" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89c3e1937e31d0e068bbe829f66b2f2bfaa28d056365279e0ef897172c3320c0" +dependencies = [ + "encoding_rs", + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-utils-xiph" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a450ca645b80d69aff8b35576cbfdc7f20940b29998202aab910045714c951f8" +dependencies = [ + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-mid" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tiff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "uuid" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81" +dependencies = [ + "getrandom", + "rand", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "webp" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bb5d8e7814e92297b0e1c773ce43d290bef6c17452dafd9fc49e5edb5beba71" +dependencies = [ + "libwebp-sys", +] + +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..aeae537396 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["packages/scanner"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1cd9698d16..c3070177d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4969,6 +4969,10 @@ "resolved": "packages/main", "link": true }, + "node_modules/@nuclear/scanner": { + "resolved": "packages/scanner", + "link": true + }, "node_modules/@nuclear/ui": { "resolved": "packages/ui", "link": true @@ -16815,6 +16819,15 @@ } ] }, + "node_modules/cargo-cp-artifact": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.8.tgz", + "integrity": "sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==", + "dev": true, + "bin": { + "cargo-cp-artifact": "bin/cargo-cp-artifact.js" + } + }, "node_modules/case-sensitive-paths-webpack-plugin": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz", @@ -46373,6 +46386,7 @@ "license": "AGPL-3.0", "dependencies": { "@nuclear/core": "^0.6.30", + "@nuclear/scanner": "^0.6.21", "autobind-decorator": "^2.4.0", "body-parser": "^1.19.0", "concat-stream": "^2.0.0", @@ -46463,6 +46477,14 @@ "uuid": "bin/uuid" } }, + "packages/scanner": { + "version": "0.6.21", + "hasInstallScript": true, + "license": "AGPL-3.0", + "devDependencies": { + "cargo-cp-artifact": "^0.1" + } + }, "packages/ui": { "name": "@nuclear/ui", "version": "0.6.30", @@ -50122,7 +50144,7 @@ "react-full-screen": "^1.0.1", "react-hifi": "^2.2.1", "react-hls-player": "^3.0.1", - "react-hot-loader": "^4.12", + "react-hot-loader": "^4.13.1", "react-i18next": "^11.12.0", "react-image": "^2.2.2", "react-list": "^0.8.13", @@ -50211,6 +50233,7 @@ "version": "file:packages/main", "requires": { "@nuclear/core": "^0.6.30", + "@nuclear/scanner": "^0.6.21", "@types/body-parser": "^1.17.1", "@types/concat-stream": "^1.6.0", "@types/cors": "^2.8.6", @@ -50295,6 +50318,12 @@ } } }, + "@nuclear/scanner": { + "version": "file:packages/scanner", + "requires": { + "cargo-cp-artifact": "^0.1" + } + }, "@nuclear/ui": { "version": "file:packages/ui", "requires": { @@ -59609,6 +59638,12 @@ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001547.tgz", "integrity": "sha512-W7CrtIModMAxobGhz8iXmDfuJiiKg1WADMO/9x7/CLNin5cpSbuBjooyoIUVB5eyCc36QuTVlkVa1iB2S5+/eA==" }, + "cargo-cp-artifact": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.8.tgz", + "integrity": "sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==", + "dev": true + }, "case-sensitive-paths-webpack-plugin": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/case-sensitive-paths-webpack-plugin/-/case-sensitive-paths-webpack-plugin-2.4.0.tgz", diff --git a/package.json b/package.json index 654976f0c4..a124eae70b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "homepage": "https://github.com/nukeop/nuclear#readme", "scripts": { - "postinstall": "electron-builder install-app-deps", + "postinstall": "electron-builder install-app-deps && lerna run build --scope @nuclear/scanner", "start": "lerna run start --stream", "build": "shx rm -rf dist && lerna run build && npm run pack", "test": "lerna run test", @@ -117,33 +117,13 @@ "ext": "opus", "mimeType": "audio/ogg" }, - { - "ext": "aac", - "mimeType": "audio/aac" - }, { "ext": "flac", "mimeType": "audio/flac" }, - { - "ext": "wav", - "mimeType": "audio/x-wav" - }, - { - "ext": "m4a", - "mimeType": "audio/m4a" - }, - { - "ext": "weba", - "mimeType": "audio/weba" - }, { "ext": "mp4", "mimeType": "audio/mp4" - }, - { - "ext": "webm", - "mimeType": "audio/webm" } ], "linux": { diff --git a/packages/app/app/actions/queue.ts b/packages/app/app/actions/queue.ts index f6db772737..fb7bb68bd1 100644 --- a/packages/app/app/actions/queue.ts +++ b/packages/app/app/actions/queue.ts @@ -1,6 +1,7 @@ import logger from 'electron-timber'; import _, { isEmpty, isString } from 'lodash'; import { createStandardAction } from 'typesafe-actions'; +import { v4 } from 'uuid'; import { rest, StreamProvider } from '@nuclear/core'; import { getTrackArtist } from '@nuclear/ui'; @@ -37,6 +38,7 @@ const localTrackToQueueItem = (track: LocalTrack, local: LocalLibraryState): Que return toQueueItem({ ...rest, + uuid: v4(), streams: [resolvedStream] }); }; diff --git a/packages/app/app/components/LibraryView/index.js b/packages/app/app/components/LibraryView/index.js index 90698207d4..3d1c87e796 100644 --- a/packages/app/app/components/LibraryView/index.js +++ b/packages/app/app/components/LibraryView/index.js @@ -15,7 +15,22 @@ import LibraryAlbumGrid from './LibraryAlbumGrid'; import LibraryHeader from './LibraryHeader'; import { sortTracks } from './utils'; -const LibraryView = ({ tracksMap, filter, expandedFolders, streamProviders, pending, scanProgress, scanTotal, localFolders, sortBy, direction, listType, actions, queueActions, playerActions }) => { +const LibraryView = ({ + tracksMap, + filter, + expandedFolders, + streamProviders, + pending, + scanProgress, + scanTotal, + localFolders, + sortBy, + direction, + listType, + actions, + queueActions, + playerActions +}) => { const localStreamProviders = useMemo(() => _.filter(streamProviders, { sourceName: 'Local' }), [streamProviders]); const unfilteredTracks = useMemo(() => _.values(tracksMap), [tracksMap]); diff --git a/packages/app/app/components/LibraryView/utils.js b/packages/app/app/components/LibraryView/utils.js index 7919ac4483..a2661fb1b3 100644 --- a/packages/app/app/components/LibraryView/utils.js +++ b/packages/app/app/components/LibraryView/utils.js @@ -3,11 +3,11 @@ import _ from 'lodash'; export function sortTracks(tracks, criteria) { switch (criteria) { case 'artist': - return _.sortBy(tracks, ['artist.name', 'album', 'pos']); + return _.sortBy(tracks, ['artist.name', 'album', 'position']); case 'name': return _.sortBy(tracks, ['name', 'artist.name']); case 'album': - return _.sortBy(tracks, ['album', 'pos']); + return _.sortBy(tracks, ['album', 'position']); default: return tracks; } diff --git a/packages/app/app/components/PlayQueue/index.tsx b/packages/app/app/components/PlayQueue/index.tsx index 3ed4f5af0d..ff81c090a4 100644 --- a/packages/app/app/components/PlayQueue/index.tsx +++ b/packages/app/app/components/PlayQueue/index.tsx @@ -232,7 +232,7 @@ const PlayQueue: React.FC = ({ {({ height, width }) => { await waitFor(() => component.getAllByTestId('play-now')[0].click()); const state = store.getState(); expect(state.queue.queueItems[0]).toEqual(expect.objectContaining({ - uuid: 'local-track-1', + uuid: expect.stringMatching(uuidRegex), artist: 'test artist 1', name: 'test track 1', local: true, diff --git a/packages/app/app/containers/LibraryViewContainer/LibraryViewContainer.test.tsx b/packages/app/app/containers/LibraryViewContainer/LibraryViewContainer.test.tsx index 1279ee27be..12f2f7e615 100644 --- a/packages/app/app/containers/LibraryViewContainer/LibraryViewContainer.test.tsx +++ b/packages/app/app/containers/LibraryViewContainer/LibraryViewContainer.test.tsx @@ -1,7 +1,7 @@ import { waitFor } from '@testing-library/react'; import { buildStoreState } from '../../../test/storeBuilders'; -import { mountedComponentFactory, setupI18Next } from '../../../test/testUtils'; +import { mountedComponentFactory, setupI18Next, uuidRegex } from '../../../test/testUtils'; describe('Library view container', () => { beforeAll(() => { @@ -66,7 +66,7 @@ describe('Library view container', () => { expect(state.queue.queueItems).toStrictEqual([ expect.objectContaining({ - uuid: 'local-track-1', + uuid: expect.stringMatching(uuidRegex), artist: 'local artist 1', name: 'local track 1', duration: 300, @@ -121,7 +121,7 @@ describe('Library view container', () => { expect(state.queue.queueItems).toStrictEqual([ expect.objectContaining({ - uuid: 'local-track-1', + uuid: expect.stringMatching(uuidRegex), artist: 'local artist 1', name: 'local track 1', duration: 250, diff --git a/packages/app/test/testUtils.tsx b/packages/app/test/testUtils.tsx index 210ca6bdbd..4a22fb68cb 100644 --- a/packages/app/test/testUtils.tsx +++ b/packages/app/test/testUtils.tsx @@ -24,6 +24,8 @@ export type AnyProps = { [k: string]: any; } +export const uuidRegex = /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/; + type TestRouteProviderProps = { children: React.ReactNode; history: ReturnType; diff --git a/packages/app/webpack.config.ts b/packages/app/webpack.config.ts index 3ecdd29fde..b2ca44b1d6 100644 --- a/packages/app/webpack.config.ts +++ b/packages/app/webpack.config.ts @@ -241,7 +241,6 @@ module.exports = (env) => { }; if (IS_DEV) { - config.plugins?.push(new webpack.HotModuleReplacementPlugin()); config.devServer = { hot: true, static: { diff --git a/packages/core/package.json b/packages/core/package.json index 45f6fac6e6..af52a4d2e1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -5,7 +5,7 @@ "type": "git", "url": "git+https://github.com/nukeop/nuclear.git" }, - "author": "nukeop ", + "author": "nukeop <12746779+nukeop@users.noreply.github.com>", "license": "AGPL-3.0", "bugs": { "url": "https://github.com/nukeop/nuclear/issues" @@ -58,4 +58,4 @@ "ts-node": "^10.7.0", "typescript": "^4.2.4" } -} +} \ No newline at end of file diff --git a/packages/core/src/rest/Nuclear/Configuration.ts b/packages/core/src/rest/Nuclear/Configuration.ts index a1ad33353d..ab951b6be0 100644 --- a/packages/core/src/rest/Nuclear/Configuration.ts +++ b/packages/core/src/rest/Nuclear/Configuration.ts @@ -42,7 +42,7 @@ export class NuclearConfigurationService extends NuclearSupabaseService { .from('params') .select(); - return dbParams?.data.reduce((acc, curr) => { + return dbParams?.data?.reduce((acc, curr) => { acc[curr.key] = curr.value; return acc; }, {} as Parameters); diff --git a/packages/i18n/package.json b/packages/i18n/package.json index d812da34f8..d64e63fb22 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -5,7 +5,7 @@ "type": "git", "url": "git+https://github.com/nukeop/nuclear.git" }, - "author": "nukeop ", + "author": "nukeop <12746779+nukeop@users.noreply.github.com>", "license": "AGPL-3.0", "bugs": { "url": "https://github.com/nukeop/nuclear/issues" @@ -25,4 +25,4 @@ "ts-node": "^10.7.0", "typescript": "^4.2.4" } -} +} \ No newline at end of file diff --git a/packages/main/package.json b/packages/main/package.json index de4c1c78c9..815aa4970a 100644 --- a/packages/main/package.json +++ b/packages/main/package.json @@ -13,7 +13,7 @@ "type": "git", "url": "git+https://github.com/nukeop/nuclear.git" }, - "author": "nukeop ", + "author": "nukeop <12746779+nukeop@users.noreply.github.com>", "license": "AGPL-3.0", "bugs": { "url": "https://github.com/nukeop/nuclear/issues" @@ -21,6 +21,7 @@ "homepage": "https://github.com/nukeop/nuclear#readme", "dependencies": { "@nuclear/core": "^0.6.30", + "@nuclear/scanner": "^0.6.21", "autobind-decorator": "^2.4.0", "body-parser": "^1.19.0", "concat-stream": "^2.0.0", diff --git a/packages/main/src/controllers/local-library.ts b/packages/main/src/controllers/local-library.ts index a4ca27dffa..3b5c5eefc9 100644 --- a/packages/main/src/controllers/local-library.ts +++ b/packages/main/src/controllers/local-library.ts @@ -1,19 +1,24 @@ import { inject } from 'inversify'; import { IpcMessageEvent } from 'electron'; +import { IpcEvents } from '@nuclear/core'; +import {scanFolders} from '@nuclear/scanner'; import LocalLibrary from '../services/local-library'; import { ipcController, ipcEvent } from '../utils/decorators'; import LocalLibraryDb from '../services/local-library/db'; import Platform from '../services/platform'; import Window from '../services/window'; -import { IpcEvents } from '@nuclear/core'; +import Config from '../services/config'; +import Logger, { $mainLogger } from '../services/logger'; @ipcController() class LocalIpcCtrl { constructor( + @inject(Config) private config: Config, @inject(LocalLibrary) private localLibrary: LocalLibrary, @inject(LocalLibraryDb) private localLibraryDb: LocalLibraryDb, @inject(Platform) private platform: Platform, + @inject($mainLogger) private logger: Logger, @inject(Window) private window: Window ) {} @@ -48,14 +53,14 @@ class LocalIpcCtrl { */ @ipcEvent(IpcEvents.LOCALFOLDERS_SET) async setLocalFolders(event: IpcMessageEvent, directories: string[]) { - const localFolders = await Promise.all( + await Promise.all( directories .map(folder => this.localLibraryDb.addFolder(this.normalizeFolderPath(folder))) ); - const cache = await this.localLibrary.scanFoldersAndGetMeta(localFolders, (scanProgress, scanTotal) => { + const cache = await scanFolders(directories, this.config.supportedFormats, this.localLibrary.getThumbnailsDir(), (scanProgress, scanTotal) => { this.window.send(IpcEvents.LOCAL_FILES_PROGRESS, {scanProgress, scanTotal}); - }); + }, () => {}); this.window.send(IpcEvents.LOCAL_FILES, Object.values(cache).reduce((acc, track) => ({ ...acc, @@ -82,12 +87,10 @@ class LocalIpcCtrl { async onRefreshLocalFolders() { try { const folders = await this.localLibraryDb.getLocalFolders(); - const cache = await this.localLibrary.scanFoldersAndGetMeta( - folders, - (scanProgress, scanTotal) => { - this.window.send(IpcEvents.LOCAL_FILES_PROGRESS, {scanProgress, scanTotal}); - } - ); + + const cache = await scanFolders(folders.map(folder => folder.path), this.config.supportedFormats, this.localLibrary.getThumbnailsDir(), (scanProgress, scanTotal) => { + this.window.send(IpcEvents.LOCAL_FILES_PROGRESS, {scanProgress, scanTotal}); + }, () => {}); this.window.send(IpcEvents.LOCAL_FILES, cache); } catch (err) { diff --git a/packages/main/src/services/library-scanner/library-scanner.test.ts b/packages/main/src/services/library-scanner/library-scanner.test.ts new file mode 100644 index 0000000000..8bbb445bda --- /dev/null +++ b/packages/main/src/services/library-scanner/library-scanner.test.ts @@ -0,0 +1,12 @@ +import {scanFolders} from '@nuclear/scanner'; + +// Enable when testing the local library scanner rust package +xdescribe('Local library scanner', () => { + it('scans folders', async () => { + // const result = await scanFolders([''], ['mp3'], (progress, total, lastScanned) => { + // // console.log({progress, total, lastScanned}); + // }); + const result = {}; + expect(result).toBe({}); + }); +}); diff --git a/packages/main/src/services/local-library/index.ts b/packages/main/src/services/local-library/index.ts index 09ad0d5729..e875e6c05f 100644 --- a/packages/main/src/services/local-library/index.ts +++ b/packages/main/src/services/local-library/index.ts @@ -53,6 +53,10 @@ class LocalLibrary { } } + getThumbnailsDir() { + return this.mediaDir; + } + /** * Format metadata from files to nuclear format */ diff --git a/packages/main/tsconfig.json b/packages/main/tsconfig.json index fa6acfa1cb..b5896f30e8 100644 --- a/packages/main/tsconfig.json +++ b/packages/main/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.json", "compilerOptions": { "module": "commonjs", - "lib": ["DOM"], + "lib": ["DOM", "ESNext"], "outDir": "dist", "allowJs": true, "strict": false, @@ -15,7 +15,8 @@ "src", "typings", "node_modules/@nuclear", - "../core/src" + "../core/src", + "../scanner" ], "exclude": [ "node_modules/@nuclear/*/test", diff --git a/packages/main/webpack.config.ts b/packages/main/webpack.config.ts index 28bb387932..4f3a02cec1 100644 --- a/packages/main/webpack.config.ts +++ b/packages/main/webpack.config.ts @@ -16,6 +16,8 @@ const osMapper: Record = { const MAIN_DIR = path.resolve(__dirname, 'src'); const CORE_DIR = path.resolve(__dirname, '..', '..', 'node_modules', '@nuclear', 'core', 'src'); +const SCANNER_DIR = path.resolve(__dirname, '..', '..', 'node_modules', '@nuclear', 'scanner'); +const SCANNER_DIR_SYMLINKED = path.resolve(__dirname, 'node_modules', '@nuclear', 'scanner'); module.exports = (env: BuildEnv): webpack.Configuration => { if (!env.TARGET) { @@ -28,7 +30,7 @@ module.exports = (env: BuildEnv): webpack.Configuration => { return { entry: './src/main.ts', resolve: { - extensions: ['.ts', '.js', '.json'], + extensions: ['.ts', '.js', '.json', '.node'], alias: { jsbi: path.resolve(__dirname, '..', '..', 'node_modules', 'jsbi', 'dist', 'jsbi-cjs.js') }, @@ -60,7 +62,8 @@ module.exports = (env: BuildEnv): webpack.Configuration => { }, { test: /\.node$/, - use: 'node-loader' + use: 'node-loader', + include: [MAIN_DIR, SCANNER_DIR, SCANNER_DIR_SYMLINKED] } ] }, diff --git a/packages/scanner/.gitignore b/packages/scanner/.gitignore new file mode 100644 index 0000000000..6ca71fb5fc --- /dev/null +++ b/packages/scanner/.gitignore @@ -0,0 +1,5 @@ +target +index.node +**/node_modules +**/.DS_Store +npm-debug.log* diff --git a/packages/scanner/Cargo.lock b/packages/scanner/Cargo.lock new file mode 100644 index 0000000000..ba3ac02eea --- /dev/null +++ b/packages/scanner/Cargo.lock @@ -0,0 +1,156 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "libloading" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "neon" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e15415261d880aed48122e917a45e87bb82cf0260bb6db48bbab44b7464373" +dependencies = [ + "neon-build", + "neon-macros", + "neon-runtime", + "semver", + "smallvec", +] + +[[package]] +name = "neon-build" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bac98a702e71804af3dacfde41edde4a16076a7bbe889ae61e56e18c5b1c811" + +[[package]] +name = "neon-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7288eac8b54af7913c60e0eb0e2a7683020dffa342ab3fd15e28f035ba897cf" +dependencies = [ + "quote", + "syn", + "syn-mid", +] + +[[package]] +name = "neon-runtime" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4676720fa8bb32c64c3d9f49c47a47289239ec46b4bdb66d0913cc512cb0daca" +dependencies = [ + "cfg-if", + "libloading", + "smallvec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "scanner" +version = "0.1.0" +dependencies = [ + "neon", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn-mid" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/packages/scanner/Cargo.toml b/packages/scanner/Cargo.toml new file mode 100644 index 0000000000..025ea306c8 --- /dev/null +++ b/packages/scanner/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "scanner" +version = "0.1.0" +license = "AGPL-3.0" +edition = "2018" +exclude = ["index.node"] + +[lib] +crate-type = ["cdylib"] + +[features] +profiling = [] + +[dependencies] +derive_builder = "0.12.0" +id3 = "1.7.0" +md5 = "0.7.0" +metaflac = "0.2.5" +mockall = "0.11.4" +mp3-duration = "0.1.10" +mp4ameta = "0.11.0" + +[dependencies.symphonia] +version = "0.5.3" +features = ["aac", "mp3", "flac", "ogg", "isomp4", "wav"] + +[dependencies.image] +version = "0.24.7" +features = ["webp-encoder"] + +[dependencies.uuid] +version = "1.3.4" +features = ["v4", "fast-rng"] + +[dependencies.neon] +version = "0.10" +default-features = false +features = ["napi-6"] diff --git a/packages/scanner/README.md b/packages/scanner/README.md new file mode 100644 index 0000000000..d005526e48 --- /dev/null +++ b/packages/scanner/README.md @@ -0,0 +1,119 @@ +# scanner + +This project was bootstrapped by [create-neon](https://www.npmjs.com/package/create-neon). + +## Installing scanner + +Installing scanner requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support). + +You can install the project with npm. In the project directory, run: + +```sh +$ npm install +``` + +This fully installs the project, including installing any dependencies and running the build. + +## Building scanner + +If you have already installed the project and only want to run the build, run: + +```sh +$ npm run build +``` + +This command uses the [cargo-cp-artifact](https://github.com/neon-bindings/cargo-cp-artifact) utility to run the Rust build and copy the built library into `./index.node`. + +## Exploring scanner + +After building scanner, you can explore its exports at the Node REPL: + +```sh +$ npm install +$ node +> require('.').hello() +"hello node" +``` + +## Available Scripts + +In the project directory, you can run: + +### `npm install` + +Installs the project, including running `npm run build`. + +### `npm build` + +Builds the Node addon (`index.node`) from source. + +Additional [`cargo build`](https://doc.rust-lang.org/cargo/commands/cargo-build.html) arguments may be passed to `npm build` and `npm build-*` commands. For example, to enable a [cargo feature](https://doc.rust-lang.org/cargo/reference/features.html): + +``` +npm run build -- --feature=beetle +``` + +#### `npm build-debug` + +Alias for `npm build`. + +#### `npm build-release` + +Same as [`npm build`](#npm-build) but, builds the module with the [`release`](https://doc.rust-lang.org/cargo/reference/profiles.html#release) profile. Release builds will compile slower, but run faster. + +### `npm test` + +Runs the unit tests by calling `cargo test`. You can learn more about [adding tests to your Rust code](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) from the [Rust book](https://doc.rust-lang.org/book/). + +## Project Layout + +The directory structure of this project is: + +``` +scanner/ +├── Cargo.toml +├── README.md +├── index.node +├── package.json +├── src/ +| └── lib.rs +└── target/ +``` + +### Cargo.toml + +The Cargo [manifest file](https://doc.rust-lang.org/cargo/reference/manifest.html), which informs the `cargo` command. + +### README.md + +This file. + +### index.node + +The Node addon—i.e., a binary Node module—generated by building the project. This is the main module for this package, as dictated by the `"main"` key in `package.json`. + +Under the hood, a [Node addon](https://nodejs.org/api/addons.html) is a [dynamically-linked shared object](https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries). The `"build"` script produces this file by copying it from within the `target/` directory, which is where the Rust build produces the shared object. + +### package.json + +The npm [manifest file](https://docs.npmjs.com/cli/v7/configuring-npm/package-json), which informs the `npm` command. + +### src/ + +The directory tree containing the Rust source code for the project. + +### src/lib.rs + +The Rust library's main module. + +### target/ + +Binary artifacts generated by the Rust build. + +## Learn More + +To learn more about Neon, see the [Neon documentation](https://neon-bindings.com). + +To learn more about Rust, see the [Rust documentation](https://www.rust-lang.org). + +To learn more about Node, see the [Node documentation](https://nodejs.org). diff --git a/packages/scanner/index.d.ts b/packages/scanner/index.d.ts new file mode 100644 index 0000000000..2ddbc0d594 --- /dev/null +++ b/packages/scanner/index.d.ts @@ -0,0 +1,26 @@ +export type LocalTrack = { + uuid: string; + artist: string; + title?: string; + album?: string; + duration?: number; + thumbnail?: string; + position?: number; + year?: string; + + filename: string; + path: string; + local: true; +} + +declare const scanFolders = ( + folders: string[], + supportedFormats: string[], + thumbnailsDir: string, + onProgress: (progress: number, total: number, lastScanned?: string) => void, + onError: (track: string, error: string) => void +) => new Promise; + +declare const generateThumbnail = (filename: string, thumbnailsDir: string) => new Promise; + +export { scanFolders, generateThumbnail }; diff --git a/packages/scanner/package-lock.json b/packages/scanner/package-lock.json new file mode 100644 index 0000000000..772be0c1e9 --- /dev/null +++ b/packages/scanner/package-lock.json @@ -0,0 +1,25 @@ +{ + "name": "@nuclear/scanner", + "version": "0.6.21", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@nuclear/scanner", + "version": "0.6.21", + "license": "AGPL-3.0", + "devDependencies": { + "cargo-cp-artifact": "^0.1" + } + }, + "node_modules/cargo-cp-artifact": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.8.tgz", + "integrity": "sha512-3j4DaoTrsCD1MRkTF2Soacii0Nx7UHCce0EwUf4fHnggwiE4fbmF2AbnfzayR36DF8KGadfh7M/Yfy625kgPlA==", + "dev": true, + "bin": { + "cargo-cp-artifact": "bin/cargo-cp-artifact.js" + } + } + } +} diff --git a/packages/scanner/package.json b/packages/scanner/package.json new file mode 100644 index 0000000000..8b0fd2af8f --- /dev/null +++ b/packages/scanner/package.json @@ -0,0 +1,28 @@ +{ + "name": "@nuclear/scanner", + "version": "0.6.21", + "description": "Local library scanner", + "main": "index.node", + "types": "index.d.ts", + "scripts": { + "build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics", + "build-profiling": "npm run build -- --features profiling --release", + "build-debug": "npm run build --", + "build-release": "npm run build -- --release", + "install": "npm run build-release", + "test": "cargo test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/nukeop/nuclear.git" + }, + "author": "nukeop ", + "license": "AGPL-3.0", + "bugs": { + "url": "https://github.com/nukeop/nuclear/issues" + }, + "homepage": "https://github.com/nukeop/nuclear#readme", + "devDependencies": { + "cargo-cp-artifact": "^0.1" + } +} \ No newline at end of file diff --git a/packages/scanner/src/error.rs b/packages/scanner/src/error.rs new file mode 100644 index 0000000000..1bec6b2f50 --- /dev/null +++ b/packages/scanner/src/error.rs @@ -0,0 +1,59 @@ +use std::error::Error; +use std::fmt; + +#[derive(Debug)] +pub struct ScannerError { + pub message: String, + pub path: String, +} + +impl Error for ScannerError {} + +impl ScannerError { + pub fn new(message: &str, path: &str) -> ScannerError { + ScannerError { + message: message.to_string(), + path: path.to_string(), + } + } +} + +impl fmt::Display for ScannerError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ScannerError: {}", self.message) + } +} + +#[derive(Debug)] +pub struct MetadataError { + pub message: String, +} + +impl MetadataError { + pub fn new(message: &str) -> MetadataError { + MetadataError { + message: message.to_string(), + } + } +} + +impl Error for MetadataError {} + +impl fmt::Display for MetadataError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "MetadataError: {}", self.message) + } +} + +#[derive(Debug)] +pub struct ThumbnailError { + pub message: String, +} + +impl Error for ThumbnailError {} + +impl fmt::Display for ThumbnailError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "ThumbnailError: {}", self.message) + } +} diff --git a/packages/scanner/src/js.rs b/packages/scanner/src/js.rs new file mode 100644 index 0000000000..3ad62539d5 --- /dev/null +++ b/packages/scanner/src/js.rs @@ -0,0 +1,73 @@ +use neon::prelude::*; + +use crate::metadata::AudioMetadata; + +pub fn set_optional_field_str( + cx: &mut FunctionContext, + obj: &mut Handle, + field_name: &str, + value: Option, +) { + match value { + Some(v) => { + let field_value = cx.string(&v); + obj.set(cx, field_name, field_value).unwrap(); + } + None => { + let undefined = cx.undefined(); + obj.set(cx, field_name, undefined).unwrap(); + } + } +} + +pub fn set_optional_field_u32( + cx: &mut FunctionContext, + obj: &mut Handle, + field_name: &str, + value: Option, +) { + match value { + Some(v) => { + let field_value = cx.number(v as f64); + obj.set(cx, field_name, field_value).unwrap(); + } + None => { + let undefined = cx.undefined(); + obj.set(cx, field_name, undefined).unwrap(); + } + } +} + +pub fn set_optional_field_buffer( + cx: &mut FunctionContext, + obj: &mut Handle, + field_name: &str, + value: Option>, +) { + match value { + Some(v) => { + let field_value = JsBuffer::external(cx, v); + obj.set(cx, field_name, field_value).unwrap(); + } + None => { + let undefined = cx.undefined(); + obj.set(cx, field_name, undefined).unwrap(); + } + } +} + +pub fn set_properties_from_metadata( + cx: &mut FunctionContext, + obj: &mut Handle, + metadata: &AudioMetadata, +) { + set_optional_field_str(cx, obj, "artist", metadata.artist.clone()); + set_optional_field_str(cx, obj, "title", metadata.title.clone()); + set_optional_field_str(cx, obj, "album", metadata.album.clone()); + + set_optional_field_u32(cx, obj, "duration", metadata.duration); + set_optional_field_str(cx, obj, "thumbnail", metadata.thumbnail.clone()); + set_optional_field_u32(cx, obj, "position", metadata.position); + set_optional_field_u32(cx, obj, "disc", metadata.disc); + set_optional_field_str(cx, obj, "year", metadata.year.clone()); +} diff --git a/packages/scanner/src/lib.rs b/packages/scanner/src/lib.rs new file mode 100644 index 0000000000..3b357ceb11 --- /dev/null +++ b/packages/scanner/src/lib.rs @@ -0,0 +1,162 @@ +#![forbid(unsafe_code)] + +mod error; +mod js; +mod local_track; +mod metadata; +mod profiling; +mod scanner; +mod thumbnails; +use error::ScannerError; + +use js::set_properties_from_metadata; +use local_track::LocalTrack; +use neon::prelude::*; +use scanner::{extractor_from_path, visit_directory, visit_file}; +use std::collections::LinkedList; +use thumbnails::create_thumbnails_dir; + +fn handle_progress<'a>( + cx: &mut FunctionContext<'a>, + total_files_to_scan_num: usize, + index: usize, + filename: String, + on_progress_callback: Handle, +) -> JsResult<'a, JsValue> { + let js_this = cx.undefined(); + let args = vec![ + cx.number(index as f64).upcast(), + cx.number(total_files_to_scan_num as f64).upcast(), + cx.string(filename.clone()).upcast(), + ]; + on_progress_callback.call(cx, js_this, args) +} + +fn handle_error<'a>( + cx: &mut FunctionContext<'a>, + error: &ScannerError, + on_error_callback: Handle, +) -> JsResult<'a, JsValue> { + let js_this = cx.undefined(); + let on_error_args = vec![ + cx.string(error.path.clone()).upcast(), + cx.string(error.message.clone()).upcast(), + ]; + on_error_callback.call(cx, js_this, on_error_args) +} + +fn scan_folders(mut cx: FunctionContext) -> JsResult { + let folders: Handle = cx.argument(0)?; + let supported_formats: Handle = cx.argument(1)?; + let thumbnails_dir: Handle = cx.argument(2)?; + let thumbnails_dir_str = thumbnails_dir.value(&mut cx); + let on_progress_callback: Handle = cx.argument(3)?; + let on_error_callback: Handle = cx.argument(4)?; + let result: Handle = cx.empty_array(); + + // Copy all the starting folders to a queue, which holds all the folders left to scan + let supported_formats_vec = supported_formats + .to_vec(&mut cx)? + .into_iter() + .map(|format| format.to_string(&mut cx).unwrap().value(&mut cx)) + .collect::>(); + let folders_vec = folders.to_vec(&mut cx)?; + let mut dirs_to_scan_queue: LinkedList = LinkedList::new(); + let mut files_to_scan_queue: LinkedList = LinkedList::new(); + let total_files_to_scan_num; + for folder in folders_vec { + let folder_string = folder.to_string(&mut cx)?.value(&mut cx); + dirs_to_scan_queue.push_back(folder_string); + } + + // While there are still folders left to scan + while !dirs_to_scan_queue.is_empty() { + // Get the next folder to scan + let folder = dirs_to_scan_queue.pop_front().unwrap(); + + // Scan the folder + visit_directory( + folder.clone(), + supported_formats_vec.clone(), + &mut dirs_to_scan_queue, + &mut files_to_scan_queue, + ); + + // Call the progress callback + let this = cx.undefined(); + let args = vec![ + cx.number(0).upcast(), + cx.number(files_to_scan_queue.len() as f64).upcast(), + cx.string(folder.clone()).upcast(), + ]; + on_progress_callback.call(&mut cx, this, args)?; + } + + // First, create a directory for thumbnails + create_thumbnails_dir(thumbnails_dir_str.as_str()).unwrap(); + + // All directories have been scanned, now scan the files + total_files_to_scan_num = files_to_scan_queue.len(); + + let scanned_local_tracks: Vec> = files_to_scan_queue + .iter() + .enumerate() + .map(|(index, file)| { + let result = visit_file( + file.clone(), + extractor_from_path, + thumbnails_dir_str.as_str(), + ); + + // Send progress back to JS + handle_progress( + &mut cx, + total_files_to_scan_num, + index, + file.clone(), + on_progress_callback.clone(), + ) + .unwrap(); + return result; + }) + .collect(); + + scanned_local_tracks.iter().for_each(|track| match track { + Ok(track) => { + let len = result.len(&mut cx); + let mut track_js_object = JsObject::new(&mut cx); + let track_uuid_js_string = cx.string(track.uuid.clone()); + track_js_object + .set(&mut cx, "uuid", track_uuid_js_string) + .unwrap(); + + set_properties_from_metadata(&mut cx, &mut track_js_object, &track.metadata); + + let track_filename_js_string = cx.string(track.filename.clone()); + track_js_object + .set(&mut cx, "filename", track_filename_js_string) + .unwrap(); + + let track_path_js_string = cx.string(track.path.clone()); + track_js_object + .set(&mut cx, "path", track_path_js_string) + .unwrap(); + + let track_local = cx.boolean(true); + track_js_object.set(&mut cx, "local", track_local).unwrap(); + + result.set(&mut cx, len, track_js_object).unwrap(); + } + Err(error) => { + handle_error(&mut cx, error, on_error_callback.clone()).unwrap(); + } + }); + + Ok(result) +} + +#[neon::main] +fn main(mut cx: ModuleContext) -> NeonResult<()> { + cx.export_function("scanFolders", scan_folders)?; + Ok(()) +} diff --git a/packages/scanner/src/local_track.rs b/packages/scanner/src/local_track.rs new file mode 100644 index 0000000000..c1d974c228 --- /dev/null +++ b/packages/scanner/src/local_track.rs @@ -0,0 +1,11 @@ +use crate::metadata::AudioMetadata; + +#[derive(Debug, Clone)] +pub struct LocalTrack { + pub uuid: String, + + pub metadata: AudioMetadata, + + pub filename: String, + pub path: String, +} diff --git a/packages/scanner/src/metadata.rs b/packages/scanner/src/metadata.rs new file mode 100644 index 0000000000..697027c24f --- /dev/null +++ b/packages/scanner/src/metadata.rs @@ -0,0 +1,251 @@ +use std::fs::File; + +use derive_builder::Builder; +use id3::TagLike; +use metaflac; +use symphonia::core::{ + formats::FormatOptions, + io::MediaSourceStream, + meta::{MetadataOptions, StandardTagKey}, + probe::Hint, +}; + +use crate::{ + error::MetadataError, + thumbnails::{FlacThumbnailGenerator, Mp3ThumbnailGenerator}, + thumbnails::{Mp4ThumbnailGenerator, ThumbnailGenerator}, +}; + +#[derive(Default, Debug, Clone, Builder)] +#[builder(setter(strip_option))] +pub struct AudioMetadata { + pub artist: Option, + pub title: Option, + pub album: Option, + pub duration: Option, + pub disc: Option, + pub position: Option, + pub year: Option, + pub thumbnail: Option, +} + +impl AudioMetadata { + pub fn new() -> Self { + Self { + artist: None, + title: None, + album: None, + duration: None, + disc: None, + position: None, + year: None, + thumbnail: None, + } + } +} + +pub trait MetadataExtractor { + fn extract_metadata( + &self, + path: &str, + thumbnails_dir: &str, + ) -> Result; +} + +#[derive(Debug, Clone)] + +pub struct Mp3MetadataExtractor; +impl MetadataExtractor for Mp3MetadataExtractor { + fn extract_metadata( + &self, + path: &str, + thumbnails_dir: &str, + ) -> Result { + let tag = id3::Tag::read_from_path(path).unwrap(); + let mut metadata = AudioMetadata::new(); + + metadata.artist = tag.artist().map(|s| s.to_string()); + metadata.title = tag.title().map(|s| s.to_string()); + metadata.album = tag.album().map(|s| s.to_string()); + let duration = mp3_duration::from_path(&path).map(|duration| duration.as_secs() as u32); + + match duration { + Ok(duration) => metadata.duration = Some(duration), + Err(_) => metadata.duration = None, + } + metadata.position = tag.track(); + metadata.disc = tag.disc(); + metadata.year = tag.year().map(|y| y.to_string()); + + metadata.thumbnail = Mp3ThumbnailGenerator::generate_thumbnail( + &path, + metadata.album.as_deref(), + thumbnails_dir, + ); + + Ok(metadata) + } +} + +pub struct FlacMetadataExtractor; +impl FlacMetadataExtractor { + fn extract_string_metadata( + tag: &metaflac::Tag, + key: &str, + fallback_key: Option<&str>, + ) -> Option { + tag.get_vorbis(key) + .and_then(|mut iter| iter.next()) + .map(|s| s.to_string()) + .or_else(|| { + fallback_key.and_then(|key| { + tag.get_vorbis(key) + .and_then(|mut iter| iter.next()) + .map(|s| s.to_string()) + }) + }) + } + + fn extract_numeric_metadata(tag: &metaflac::Tag, key: &str) -> Option { + tag.get_vorbis(key) + .and_then(|mut iter| iter.next()) + .and_then(|s| s.parse::().ok()) + } +} + +impl MetadataExtractor for FlacMetadataExtractor { + fn extract_metadata( + &self, + path: &str, + thumbnails_dir: &str, + ) -> Result { + let tag = metaflac::Tag::read_from_path(path).unwrap(); + let mut metadata = AudioMetadata::new(); + metadata.artist = Self::extract_string_metadata(&tag, "ARTIST", Some("ALBUMARTIST")); + metadata.title = Self::extract_string_metadata(&tag, "TITLE", None); + metadata.album = Self::extract_string_metadata(&tag, "ALBUM", None); + let total_samples = tag.get_streaminfo().unwrap().total_samples; + let sample_rate = tag.get_streaminfo().unwrap().sample_rate; + metadata.duration = Some(total_samples as u32 / (sample_rate as u32)); + metadata.position = Self::extract_numeric_metadata(&tag, "TRACKNUMBER"); + metadata.disc = Self::extract_numeric_metadata(&tag, "DISCNUMBER"); + metadata.year = Self::extract_numeric_metadata(&tag, "DATE"); + metadata.thumbnail = FlacThumbnailGenerator::generate_thumbnail( + &path, + metadata.album.as_deref(), + thumbnails_dir, + ); + + Ok(metadata) + } +} + +pub struct OggMetadataExtractor; + +impl OggMetadataExtractor {} + +impl MetadataExtractor for OggMetadataExtractor { + fn extract_metadata( + &self, + path: &str, + _thumbnails_dir: &str, // Thumbnail generation is not handled here + ) -> Result { + let file = File::open(path); + if file.is_err() { + return Err(MetadataError::new( + format!("Could not open file {}", path).as_str(), + )); + } + + let file = File::open(path); + + if let Err(_) = file { + return Err(MetadataError::new( + format!("Could not open file {}", path).as_str(), + )); + } + + let mss = MediaSourceStream::new(Box::new(file.unwrap()), Default::default()); + + let meta_opts: MetadataOptions = Default::default(); + let fmt_opts: FormatOptions = Default::default(); + + let mut hint = Hint::new(); + hint.with_extension("ogg"); + + let mut probed = symphonia::default::get_probe() + .format(&hint, mss, &fmt_opts, &meta_opts) + .expect("unsupported format"); + let mut metadata = AudioMetadata::new(); + + let track = probed.format.default_track().unwrap(); + let time_base = track.codec_params.time_base.unwrap(); + let duration = track + .codec_params + .n_frames + .map(|frames| track.codec_params.start_ts + frames); + + metadata.duration = duration.map(|d| ((d as u32) * time_base.numer / time_base.denom)); + + if let Some(meta) = probed.format.metadata().current() { + for tag in meta.tags().iter() { + if tag.is_known() { + match tag.std_key { + Some(StandardTagKey::TrackTitle) => { + metadata.title = Some(tag.value.to_string()); + } + Some(StandardTagKey::Artist) => { + metadata.artist = Some(tag.value.to_string()); + } + Some(StandardTagKey::Album) => { + metadata.album = Some(tag.value.to_string()); + } + Some(StandardTagKey::TrackNumber) => { + metadata.position = Some(tag.value.to_string().parse::().unwrap()); + } + Some(StandardTagKey::DiscNumber) => { + metadata.disc = Some(tag.value.to_string().parse::().unwrap()); + } + Some(StandardTagKey::Date) => { + metadata.year = Some(tag.value.to_string()); + } + _ => {} + } + } + } + } + Ok(metadata) + } +} + +pub struct Mp4MetadataExtractor; + +impl Mp4MetadataExtractor {} + +impl MetadataExtractor for Mp4MetadataExtractor { + fn extract_metadata( + &self, + path: &str, + thumbnails_dir: &str, + ) -> Result { + let tag = mp4ameta::Tag::read_from_path(path).unwrap(); + + let mut metadata = AudioMetadata::new(); + + metadata.artist = tag.artist().map(|s| s.to_string()); + metadata.title = tag.title().map(|s| s.to_string()); + metadata.album = tag.album().map(|s| s.to_string()); + metadata.duration = tag.duration().map(|d| d.as_secs() as u32); + metadata.position = tag.track_number().map(|n| n as u32); + metadata.disc = tag.disc_number().map(|n| n as u32); + metadata.year = tag.year().map(|y: &str| y.parse().unwrap()); + + metadata.thumbnail = Mp4ThumbnailGenerator::generate_thumbnail( + &path, + metadata.album.as_deref(), + thumbnails_dir, + ); + + Ok(metadata) + } +} diff --git a/packages/scanner/src/profiling.rs b/packages/scanner/src/profiling.rs new file mode 100644 index 0000000000..5ad7a2cbe8 --- /dev/null +++ b/packages/scanner/src/profiling.rs @@ -0,0 +1,43 @@ +#[cfg(feature = "profiling")] +pub struct Profiler { + label: String, + start: std::time::Instant, +} + +#[cfg(feature = "profiling")] +impl Profiler { + pub fn start(label: &str) -> Self { + Profiler { + label: label.to_owned(), + start: std::time::Instant::now(), + } + } + + pub fn end(self) { + let duration = self.start.elapsed(); + println!("{} - Elapsed time: {:?}", self.label, duration); + } +} + +#[cfg(feature = "profiling")] +impl Drop for Profiler { + fn drop(&mut self) { + let duration = self.start.elapsed(); + println!("{} - Elapsed time: {:?}", self.label, duration); + } +} + +// Provide no-op implementations when profiling feature is not enabled +#[cfg(not(feature = "profiling"))] +pub struct Profiler; + +#[cfg(not(feature = "profiling"))] +impl Profiler { + pub fn start(_label: &str) -> Self { + Profiler {} + } + + pub fn end(self) { + // Do nothing + } +} diff --git a/packages/scanner/src/scanner.rs b/packages/scanner/src/scanner.rs new file mode 100644 index 0000000000..c90193920a --- /dev/null +++ b/packages/scanner/src/scanner.rs @@ -0,0 +1,142 @@ +use id3::{Error, Tag}; +use std::collections::LinkedList; +use std::ffi::OsStr; +use std::path::Path; +use uuid::Uuid; + +use crate::error::{MetadataError, ScannerError}; +use crate::local_track::LocalTrack; +use crate::metadata::{ + AudioMetadata, FlacMetadataExtractor, MetadataExtractor, Mp3MetadataExtractor, + Mp4MetadataExtractor, OggMetadataExtractor, +}; + +pub trait TagReader { + fn read_from_path(path: impl AsRef) -> Result; +} + +fn get_extension(path: &str) -> Option<&str> { + Path::new(path).extension().and_then(OsStr::to_str) +} + +pub fn extractor_from_path(path: &str) -> Option> { + match get_extension(path) { + Some("mp3") => Some(Box::new(Mp3MetadataExtractor)), + Some("ogg") => Some(Box::new(OggMetadataExtractor)), + Some("flac") => Some(Box::new(FlacMetadataExtractor)), + Some("mp4") => Some(Box::new(Mp4MetadataExtractor)), + _ => None, + } +} + +pub fn visit_file( + path: String, + extractor_provider: F, + thumbnails_dir: &str, +) -> Result +where + F: Fn(&str) -> Option>, +{ + let extractor: Box = extractor_provider(&path) + .ok_or_else(|| ScannerError::new(&format!("Unsupported file format: {}", path), &path))?; + let metadata = extractor.extract_metadata(&path, thumbnails_dir); + + match metadata { + Ok(metadata) => Ok(LocalTrack { + uuid: Uuid::new_v4().to_string(), + metadata: metadata, + filename: path.split("/").last().map(|s| s.to_string()).unwrap(), + path: path.clone(), + }), + Err(e) => Err(ScannerError::new( + &format!("Error reading file: {}", e), + &path, + )), + } +} + +pub fn visit_directory( + path: String, + supported_formats: Vec, + dirs_to_scan_queue: &mut LinkedList, + files_to_scan_queue: &mut LinkedList, +) { + // Read the contents of the directory + let dir = std::fs::read_dir(path.clone()).unwrap(); + for entry in dir { + let entry = entry.unwrap(); + let path = entry.path(); + if path.is_dir() { + // Add the directory to the queue + dirs_to_scan_queue.push_back(path.to_str().unwrap().to_string()); + } else if let Some(extension) = path.extension().and_then(|ext| ext.to_str()) { + // Add the file to the queue, if it's a supported format + if supported_formats.contains(&extension.to_string()) { + files_to_scan_queue.push_back(path.to_str().unwrap().to_string()); + } + } + } +} + +#[cfg(test)] +mod tests { + use crate::metadata::AudioMetadataBuilder; + + use super::*; + + #[derive(Debug, Clone, Default)] + struct TestMetadataExtractor { + pub test_metadata: AudioMetadata, + } + impl TestMetadataExtractor { + pub fn new(metadata: AudioMetadata) -> TestMetadataExtractor { + TestMetadataExtractor { + test_metadata: metadata, + } + } + } + impl MetadataExtractor for TestMetadataExtractor { + fn extract_metadata( + &self, + _path: &str, + _thumbnails_dir: &str, + ) -> Result { + return Ok(self.test_metadata.clone()); + } + } + + pub fn test_extractor_from_path(_path: &str) -> Option> { + Some(Box::new(TestMetadataExtractor::new( + AudioMetadataBuilder::default() + .artist("Test Artist".to_string()) + .title("Test Title".to_string()) + .album("Test Album".to_string()) + .duration(10) + .position(1) + .disc(1) + .year("2020".to_string()) + .thumbnail("http://localhost:8080/thumbnails/0b/0b0b0b0b0b0b0b0b.webp".to_string()) + .build() + .unwrap(), + ))) + } + + #[test] + fn test_visit_file() { + let path = "tests/test.mp3".to_string(); + let thumbnails_dir: String = "tests/thumbnails".to_string(); + let local_track = visit_file(path, test_extractor_from_path, &thumbnails_dir).unwrap(); + assert_eq!(local_track.filename, "test.mp3"); + assert_eq!(local_track.metadata.artist, Some("Test Artist".to_string())); + assert_eq!(local_track.metadata.title, Some("Test Title".to_string())); + assert_eq!(local_track.metadata.album, Some("Test Album".to_string())); + assert_eq!(local_track.metadata.duration, Some(10)); + assert_eq!(local_track.metadata.position, Some(1)); + assert_eq!(local_track.metadata.disc, Some(1)); + assert_eq!(local_track.metadata.year, Some("2020".to_string())); + assert_eq!( + local_track.metadata.thumbnail, + Some("http://localhost:8080/thumbnails/0b/0b0b0b0b0b0b0b0b.webp".to_string()) + ); + } +} diff --git a/packages/scanner/src/thumbnails.rs b/packages/scanner/src/thumbnails.rs new file mode 100644 index 0000000000..999d1d7e17 --- /dev/null +++ b/packages/scanner/src/thumbnails.rs @@ -0,0 +1,147 @@ +use id3::Tag; +use image::{imageops::resize, imageops::FilterType, io::Reader as ImageReader, ImageFormat}; +use image::{ImageBuffer, ImageError, ImageResult, Rgba}; +use md5; +use metaflac::Tag as FlacTag; +use std::io::{self, Cursor}; +use std::path::{Path, PathBuf}; + +use crate::profiling::Profiler; + +pub trait ThumbnailGenerator { + fn generate_thumbnail( + filename: &str, + album: Option<&str>, + thumbnails_dir: &str, + ) -> Option; + fn read_image_data(filename: &str) -> Option>; +} + +pub struct Mp3ThumbnailGenerator; +impl ThumbnailGenerator for Mp3ThumbnailGenerator { + fn generate_thumbnail( + filename: &str, + album: Option<&str>, + thumbnails_dir: &str, + ) -> Option { + generate_thumbnail_common::(filename, album, thumbnails_dir) + } + + fn read_image_data(filename: &str) -> Option> { + let tag = Tag::read_from_path(filename).ok()?; + let mut pictures = tag.pictures(); + + pictures.next().map(|p| p.data.clone()) + } +} + +pub struct Mp4ThumbnailGenerator; +impl ThumbnailGenerator for Mp4ThumbnailGenerator { + fn generate_thumbnail( + filename: &str, + album: Option<&str>, + thumbnails_dir: &str, + ) -> Option { + generate_thumbnail_common::(filename, album, thumbnails_dir) + } + + fn read_image_data(filename: &str) -> Option> { + let tag = mp4ameta::Tag::read_from_path(filename).ok()?; + tag.artwork().map(|a| a.data.to_vec()) + } +} + +pub struct FlacThumbnailGenerator; +impl ThumbnailGenerator for FlacThumbnailGenerator { + fn generate_thumbnail( + filename: &str, + album: Option<&str>, + thumbnails_dir: &str, + ) -> Option { + generate_thumbnail_common::(filename, album, thumbnails_dir) + } + + fn read_image_data(filename: &str) -> Option> { + let tag = FlacTag::read_from_path(filename).ok()?; + let mut pictures = tag.pictures(); + pictures.next().map(|p| p.data.clone()) + } +} + +fn generate_thumbnail_common( + filename: &str, + album: Option<&str>, + thumbnails_dir: &str, +) -> Option { + let filename_for_thumbnail = album.unwrap_or(filename); + let thumbnail_path = create_and_get_thumbnail_path(filename_for_thumbnail, thumbnails_dir)?; + + if Path::new(&thumbnail_path).exists() { + Some(url_path_from_path(&thumbnail_path)) + } else if let Some(thumbnail_data) = T::read_image_data(filename) { + resize_and_save_thumbnail(&thumbnail_data, Path::new(&thumbnail_path)).ok()?; + Some(url_path_from_path(&thumbnail_path)) + } else { + None + } +} + +fn resize_and_save_thumbnail(data: &[u8], path: &Path) -> ImageResult<()> { + let _profiler = Profiler::start("resize_and_save_thumbnail"); + let img = get_resized_image(data)?; + img.save_with_format(path, ImageFormat::WebP) +} + +fn get_resized_image(data: &[u8]) -> Result, Vec>, ImageError> { + let img = ImageReader::new(Cursor::new(data)); + + let guess_format_profiler = Profiler::start("guess_format"); + let format = img.with_guessed_format()?; + guess_format_profiler.end(); + + let decode_start = Profiler::start("decode"); + let decoded = format.decode()?; + decode_start.end(); + + let resize_start = Profiler::start("resize"); + let resized = resize(&decoded, 256, 256, FilterType::CatmullRom); + resize_start.end(); + return Ok(resized); +} + +fn create_and_get_thumbnail_path(filename: &str, thumbnails_dir: &str) -> Option { + if let Ok(thumbnail_filename) = hash_thumb_filename(filename) { + let mut thumbnail_path = PathBuf::from(thumbnails_dir); + thumbnail_path.push(thumbnail_filename); + thumbnail_path.to_str().map(str::to_owned) + } else { + None + } +} + +fn hash_thumb_filename(path: &str) -> Result { + let filename = Path::new(path).file_name().ok_or_else(|| { + io::Error::new( + io::ErrorKind::InvalidInput, + format!("Invalid path: {}", path), + ) + })?; + let hash = md5::compute(filename.to_string_lossy().as_bytes()); + Ok(format!("{:x}.webp", hash)) +} + +pub fn create_thumbnails_dir(thumbnails_dir: &str) -> io::Result<()> { + let thumbnails_dir_path = Path::new(thumbnails_dir); + + if !thumbnails_dir_path.exists() { + std::fs::create_dir(thumbnails_dir_path) + } else { + Ok(()) + } +} + +fn url_path_from_path(path: &str) -> String { + let path = path.replace("\\", "/"); + let path = path.replace(" ", "%20"); + format!("file://{}", path) +} diff --git a/packages/scanner/tsconfig.json b/packages/scanner/tsconfig.json new file mode 100644 index 0000000000..4b2d100e9f --- /dev/null +++ b/packages/scanner/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "lib": ["ESNext"], + "outDir": "dist", + "allowJs": true, + "strict": false, + "typeRoots": [ + "typings", + "../../node_modules/@types" + ] + }, + "include": [ + "./index.d.ts" + ], + "exclude": [ + "node_modules/@nuclear/*/test", + "node_modules/@nuclear/**/*.test*", + "node_modules/@nuclear/ui/stories", + "../ui/stories", + "../*/test" + ] + } + \ No newline at end of file diff --git a/packages/ui/lib/components/AlbumPreview/index.tsx b/packages/ui/lib/components/AlbumPreview/index.tsx index 5e5f45e287..5d6001dd69 100644 --- a/packages/ui/lib/components/AlbumPreview/index.tsx +++ b/packages/ui/lib/components/AlbumPreview/index.tsx @@ -69,8 +69,8 @@ const AlbumPreview: React.FC = (props) => { } key={index} thumb={thumb} - title={track.name} - artist={_.get(album, 'artist.name')} + title={track.title} + artist={album.artist} > ", + "author": "nukeop <12746779+nukeop@users.noreply.github.com>", "homepage": "https://github.com/nukeop/nuclear/tree/master/packages/ui#readme", "license": "AGPL-3.0", "files": [ @@ -93,4 +93,4 @@ "styled-components": "^4.4.1", "yup": "^0.32.9" } -} +} \ No newline at end of file