diff --git a/Cargo.lock b/Cargo.lock index 0c5244be..20609489 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,9 +60,9 @@ dependencies = [ [[package]] name = "actix-files" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81bde9a79336aa51ebed236e91fc1a0528ff67cfdf4f68ca4c61ede9fd26fb5" +checksum = "e04dcf7654254676d434b0285e2298d577ed4826f67f536e7a39bb0f64721164" dependencies = [ "actix-http", "actix-service", @@ -83,9 +83,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.4" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5885cb81a0d4d0d322864bea1bb6c2a8144626b4fdc625d4c51eba197e7797a" +checksum = "cfeeac0149fc76f58894a08f221282975f4c6659d2cb31ffd22a3be7a83c5771" dependencies = [ "actix-codec", "actix-rt", @@ -108,13 +108,13 @@ dependencies = [ "itoa 1.0.2", "language-tags", "local-channel", - "log", "mime", "percent-encoding", "pin-project-lite", "rand 0.8.5", - "sha-1", + "sha1", "smallvec", + "tracing", "zstd", ] @@ -193,9 +193,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.1" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e5ebffd51d50df56a3ae0de0e59487340ca456f05dd0b90c0a7a6dd6a74d31" +checksum = "a27e8fe9ba4ae613c21f677c2cfaf0696c3744030c6f485b34634e502d6bb379" dependencies = [ "actix-codec", "actix-http", @@ -227,7 +227,7 @@ dependencies = [ "serde_urlencoded", "smallvec", "socket2", - "time 0.3.9", + "time 0.3.11", "url", ] @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "actix-web-codegen" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7525bedf54704abb1d469e88d7e7e9226df73778798a69cea5022d53b2ae91bc" +checksum = "5f270541caec49c15673b0af0e9a00143421ad4f118d2df7edcb68b627632f56" dependencies = [ "actix-router", "proc-macro2", @@ -336,7 +336,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", "once_cell", "version_check", ] @@ -614,7 +614,7 @@ dependencies = [ "serde", "serde_bytes", "serde_json", - "time 0.3.9", + "time 0.3.11", "uuid 0.8.2", ] @@ -656,18 +656,18 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "bytestring" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +checksum = "86b6a75fd3048808ef06af5cd79712be8111960adaf89d90250974b38fc3928a" dependencies = [ "bytes", ] [[package]] name = "cairo-rs" -version = "0.15.11" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62be3562254e90c1c6050a72aa638f6315593e98c5cdaba9017cedbabf0a5dee" +checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" dependencies = [ "bitflags", "cairo-sys-rs", @@ -853,7 +853,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ "percent-encoding", - "time 0.3.9", + "time 0.3.11", "version_check", ] @@ -962,9 +962,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" dependencies = [ "cfg-if", "crossbeam-utils", @@ -972,12 +972,12 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" +checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" dependencies = [ "cfg-if", - "lazy_static", + "once_cell", ] [[package]] @@ -1292,9 +1292,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "embed-resource" @@ -1666,22 +1666,22 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] [[package]] name = "gio" -version = "0.15.11" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f132be35e05d9662b9fa0fee3f349c6621f7782e0105917f4cc73c1bf47eceb" +checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" dependencies = [ "bitflags", "futures-channel", @@ -1709,9 +1709,9 @@ dependencies = [ [[package]] name = "glib" -version = "0.15.11" +version = "0.15.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124026a2fa8c33a3d17a3fe59c103f2d9fa5bd92c19e029e037736729abeab" +checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d" dependencies = [ "bitflags", "futures-channel", @@ -1760,9 +1760,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "globset" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" +checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" dependencies = [ "aho-corasick", "bstr", @@ -1868,9 +1868,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" [[package]] name = "heck" @@ -1927,9 +1927,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8670570af52249509a86f5e3e18a08c60b177071826898fde8997cf5f6bfbb" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", @@ -2021,9 +2021,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -2137,9 +2137,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.57" +version = "0.3.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" dependencies = [ "wasm-bindgen", ] @@ -2157,9 +2157,9 @@ dependencies = [ [[package]] name = "jsonwebtoken" -version = "8.1.0" +version = "8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9051c17f81bae79440afa041b3a278e1de71bfb96d32454b477fd4703ccb6f" +checksum = "1aa4b4af834c6cfd35d8763d359661b90f2e45d8f750a0849156c7f4671af09c" dependencies = [ "base64", "pem", @@ -2172,14 +2172,14 @@ dependencies = [ [[package]] name = "juniper" version = "0.16.0-dev" -source = "git+https://github.com/graphql-rust/juniper#4dd5150bcbb10a420e00d74fc67e550735bc68fc" +source = "git+https://github.com/graphql-rust/juniper#a32140cd46f17491d3f7a93b4a6c67732a29b0e8" dependencies = [ "async-trait", "bson", "fnv", "futures", "futures-enum", - "getrandom 0.2.6", + "getrandom 0.2.7", "graphql-parser", "indexmap", "juniper_codegen", @@ -2188,13 +2188,13 @@ dependencies = [ "static_assertions", "url", "uuid 0.8.2", - "uuid 1.1.1", + "uuid 1.1.2", ] [[package]] name = "juniper_actix" version = "0.5.0-dev" -source = "git+https://github.com/graphql-rust/juniper#4dd5150bcbb10a420e00d74fc67e550735bc68fc" +source = "git+https://github.com/graphql-rust/juniper#a32140cd46f17491d3f7a93b4a6c67732a29b0e8" dependencies = [ "actix", "actix-http", @@ -2214,7 +2214,7 @@ dependencies = [ [[package]] name = "juniper_codegen" version = "0.16.0-dev" -source = "git+https://github.com/graphql-rust/juniper#4dd5150bcbb10a420e00d74fc67e550735bc68fc" +source = "git+https://github.com/graphql-rust/juniper#a32140cd46f17491d3f7a93b4a6c67732a29b0e8" dependencies = [ "proc-macro-error", "proc-macro2", @@ -2226,7 +2226,7 @@ dependencies = [ [[package]] name = "juniper_graphql_ws" version = "0.4.0-dev" -source = "git+https://github.com/graphql-rust/juniper#4dd5150bcbb10a420e00d74fc67e550735bc68fc" +source = "git+https://github.com/graphql-rust/juniper#a32140cd46f17491d3f7a93b4a6c67732a29b0e8" dependencies = [ "juniper", "juniper_subscriptions", @@ -2237,7 +2237,7 @@ dependencies = [ [[package]] name = "juniper_subscriptions" version = "0.17.0-dev" -source = "git+https://github.com/graphql-rust/juniper#4dd5150bcbb10a420e00d74fc67e550735bc68fc" +source = "git+https://github.com/graphql-rust/juniper#a32140cd46f17491d3f7a93b4a6c67732a29b0e8" dependencies = [ "futures", "juniper", @@ -2289,6 +2289,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "line-wrap" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +dependencies = [ + "safemem", +] + [[package]] name = "local-channel" version = "0.1.3" @@ -2448,9 +2457,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713d550d9b44d89174e066b7a6217ae06234c10cb47819a88290d2b353c31799" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ "libc", "log", @@ -2612,9 +2621,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-integer", @@ -3040,6 +3049,20 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" +[[package]] +name = "plist" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd39bc6cdc9355ad1dc5eeedefee696bb35c34caf21768741e81826c0bbd7225" +dependencies = [ + "base64", + "indexmap", + "line-wrap", + "serde", + "time 0.3.11", + "xml-rs", +] + [[package]] name = "png" version = "0.11.0" @@ -3127,9 +3150,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ "unicode-ident", ] @@ -3148,21 +3171,21 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] [[package]] name = "r2d2" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" +checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" dependencies = [ "log", - "parking_lot 0.11.2", + "parking_lot 0.12.1", "scheduled-thread-pool", ] @@ -3226,7 +3249,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", ] [[package]] @@ -3271,7 +3294,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", "redox_syscall", "thiserror", ] @@ -3382,14 +3405,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.9", + "semver 1.0.12", ] [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf" [[package]] name = "ryu" @@ -3397,6 +3420,12 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + [[package]] name = "same-file" version = "1.0.6" @@ -3491,9 +3520,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" dependencies = [ "serde", ] @@ -3551,9 +3580,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" dependencies = [ "indexmap", "itoa 1.0.2", @@ -3670,10 +3699,10 @@ dependencies = [ ] [[package]] -name = "sha-1" -version = "0.10.0" +name = "sha1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" dependencies = [ "cfg-if", "cpufeatures", @@ -3734,7 +3763,7 @@ dependencies = [ "num-bigint", "num-traits", "thiserror", - "time 0.3.9", + "time 0.3.11", ] [[package]] @@ -3751,9 +3780,9 @@ checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "smartstring" @@ -3996,9 +4025,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.96" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", @@ -4033,9 +4062,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.11.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bfe4c782f0543f667ee3b732d026b2f1c64af39cd52e726dec1ea1f2d8f6b80" +checksum = "a71c32c2fa7bba46b01becf9cf470f6a781573af7e376c5e317a313ecce27545" dependencies = [ "bitflags", "cairo-rs", @@ -4070,7 +4099,6 @@ dependencies = [ "raw-window-handle", "scopeguard", "serde", - "tao-core-video-sys", "unicode-segmentation", "uuid 0.8.2", "windows", @@ -4078,18 +4106,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "tao-core-video-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6" -dependencies = [ - "cfg-if", - "core-foundation-sys", - "libc", - "objc", -] - [[package]] name = "tar" version = "0.4.38" @@ -4103,9 +4119,9 @@ dependencies = [ [[package]] name = "tauri" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1ebb60bb8f246d5351ff9b7728fdfa7a6eba72baa722ab6021d553981caba1" +checksum = "421641ec549d34935530886151a42ce5ecbbb57beb30e5eec1b22f8e08e10ee9" dependencies = [ "anyhow", "attohttpc", @@ -4132,7 +4148,7 @@ dependencies = [ "raw-window-handle", "regex", "rfd", - "semver 1.0.9", + "semver 1.0.12", "serde", "serde_json", "serde_repr", @@ -4146,10 +4162,10 @@ dependencies = [ "tauri-utils", "tempfile", "thiserror", - "time 0.3.9", + "time 0.3.11", "tokio", "url", - "uuid 1.1.1", + "uuid 1.1.2", "webkit2gtk", "webview2-com", "windows", @@ -4158,14 +4174,14 @@ dependencies = [ [[package]] name = "tauri-build" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7b26eb3523e962b90012fedbfb744ca153d9be85e7981e00737e106d5323941" +checksum = "598bd36884ee15ac73dfca9921066fd87d13d9beea60384b99a66c3a5d800d70" dependencies = [ "anyhow", "cargo_toml", "heck 0.4.0", - "semver 1.0.9", + "semver 1.0.12", "serde_json", "tauri-utils", "winres", @@ -4173,32 +4189,34 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9468c5189188c820ef605dfe4937c768cb2918e9460c8093dc4ee2cbd717b262" +checksum = "048a7b404b92c86e7dc32458fd0963f042a76d520681e6f598d73a97c2feeeef" dependencies = [ "base64", "brotli", "ico", + "plist", "png 0.17.5", "proc-macro2", "quote", "regex", - "semver 1.0.9", + "semver 1.0.12", "serde", "serde_json", "sha2", "tauri-utils", "thiserror", - "uuid 1.1.1", + "time 0.3.11", + "uuid 1.1.2", "walkdir", ] [[package]] name = "tauri-macros" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40e3ffddd7a274fc7baaa260888c971a0d95d2ef403aa16600c878b8b1c00ffe" +checksum = "aaf70098bfab21efde9b2c089008b319ba333f4ee6e55c38bdea188dea86497f" dependencies = [ "heck 0.4.0", "proc-macro2", @@ -4210,36 +4228,38 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7dc4db360bb40584187b6cb7834da736ce4ef2ab0914e2be98014444fa9920" +checksum = "82d34f58c61a6790ba3de5753daea61b5beb6926b2384d1ad03b9dfe622c72be" dependencies = [ "gtk", "http", "http-range", "infer", + "raw-window-handle", "serde", "serde_json", "tauri-utils", "thiserror", - "uuid 1.1.1", + "uuid 1.1.2", "webview2-com", "windows", ] [[package]] name = "tauri-runtime-wry" -version = "0.9.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c876fb3a6e7c6fe2ac466b2a6ecd83658528844b4df0914558a9bc1501b31cf3" +checksum = "cd9a56e25146ff1f13f37bdb010ed0d692e7e81c824b9f977ae439f446f37ab4" dependencies = [ "cocoa", "gtk", "percent-encoding", "rand 0.8.5", + "raw-window-handle", "tauri-runtime", "tauri-utils", - "uuid 1.1.1", + "uuid 1.1.2", "webkit2gtk", "webview2-com", "windows", @@ -4248,9 +4268,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727145cb55b8897fa9f2bcea4fad31dc39394703d037c9669b40f2d1c0c2d7f3" +checksum = "616f178da1e0466ca45963ed108a1567d4b8803662addaca313169d0dcd97715" dependencies = [ "brotli", "ctor", @@ -4263,13 +4283,14 @@ dependencies = [ "phf 0.10.1", "proc-macro2", "quote", - "semver 1.0.9", + "semver 1.0.12", "serde", "serde_json", "serde_with", "thiserror", "url", "walkdir", + "windows", ] [[package]] @@ -4354,9 +4375,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2702e08a7a860f005826c6815dcac101b19b5eb330c27fe4a5928fec1d20ddd" +checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217" dependencies = [ "itoa 1.0.2", "libc", @@ -4387,9 +4408,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.19.1" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95eec79ea28c00a365f539f1961e9278fbcaf81c0ff6aaf0e93c181352446948" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ "bytes", "libc", @@ -4441,9 +4462,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.34" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" dependencies = [ "cfg-if", "log", @@ -4465,11 +4486,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" dependencies = [ - "lazy_static", + "once_cell", "valuable", ] @@ -4540,15 +4561,15 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "81dee68f85cab8cf68dec42158baf3a79a1cdc065a8b103025965d6ccb7f6cbd" dependencies = [ "tinyvec", ] @@ -4605,17 +4626,17 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", "serde", ] [[package]] name = "uuid" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d5d669b51467dcf7b2f1a796ce0f955f05f01cafda6c19d6e95f730df29238" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ - "getrandom 0.2.6", + "getrandom 0.2.7", ] [[package]] @@ -4711,9 +4732,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4721,9 +4742,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" dependencies = [ "bumpalo", "lazy_static", @@ -4736,9 +4757,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.30" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" +checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" dependencies = [ "cfg-if", "js-sys", @@ -4748,9 +4769,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4758,9 +4779,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" dependencies = [ "proc-macro2", "quote", @@ -4771,15 +4792,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" +checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" [[package]] name = "web-sys" -version = "0.3.57" +version = "0.3.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" dependencies = [ "js-sys", "wasm-bindgen", @@ -4871,9 +4892,9 @@ dependencies = [ [[package]] name = "wildmatch" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c48bd20df7e4ced539c12f570f937c6b4884928a87fee70a479d72f031d4e0" +checksum = "ee583bdc5ff1cf9db20e9db5bb3ff4c3089a8f6b8b31aff265c9aba85812db86" [[package]] name = "winapi" @@ -5057,9 +5078,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1ba327c7dd4292f46bf8e6ba8e6ec2db4443b2973c9d304a359d95e0aa856" +checksum = "ce19dddbd3ce01dc8f14eb6d4c8f914123bf8379aaa838f6da4f981ff7104a3f" dependencies = [ "block", "cocoa", @@ -5117,6 +5138,12 @@ dependencies = [ "libc", ] +[[package]] +name = "xml-rs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" + [[package]] name = "zip" version = "0.6.2" @@ -5130,18 +5157,18 @@ dependencies = [ [[package]] name = "zstd" -version = "0.10.2+zstd.1.5.2" +version = "0.11.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "4.1.6+zstd.1.5.2" +version = "5.0.2+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ "libc", "zstd-sys", @@ -5149,9 +5176,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "1.6.3+zstd.1.5.2" +version = "2.0.1+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" dependencies = [ "cc", "libc", diff --git a/packages/tauriapp/Info.plist b/packages/tauriapp/Info.plist new file mode 100644 index 00000000..b99313dd --- /dev/null +++ b/packages/tauriapp/Info.plist @@ -0,0 +1,17 @@ + + + + + CFBundleDocumentTypes + + + CFBundleTypeRole + Editor + LSItemContentTypes + + public.nes + + + + + \ No newline at end of file diff --git a/packages/tauriapp/tauri.conf.json b/packages/tauriapp/tauri.conf.json index e586e28b..97962992 100644 --- a/packages/tauriapp/tauri.conf.json +++ b/packages/tauriapp/tauri.conf.json @@ -63,6 +63,7 @@ "title": "NESBox", "width": 1024, "height": 640, + "fileDropEnabled": false, "visible": true } ] diff --git a/packages/tauriapp/tauri.macos.conf.json b/packages/tauriapp/tauri.macos.conf.json index 2fe8c121..d215630f 100644 --- a/packages/tauriapp/tauri.macos.conf.json +++ b/packages/tauriapp/tauri.macos.conf.json @@ -4,6 +4,7 @@ { "width": 1024, "height": 640, + "fileDropEnabled": false, "visible": false } ] diff --git a/packages/webapp/public/manifest.webmanifest b/packages/webapp/public/manifest.webmanifest index 70bee81c..aaa611ee 100644 --- a/packages/webapp/public/manifest.webmanifest +++ b/packages/webapp/public/manifest.webmanifest @@ -11,7 +11,7 @@ "display": "standalone", "file_handlers": [ { - "action": "/", + "action": "/emulator", "name": "NES file", "accept": { "application/octet-stream": [".nes"] diff --git a/packages/webapp/src/configure.ts b/packages/webapp/src/configure.ts index 28962886..071b464b 100644 --- a/packages/webapp/src/configure.ts +++ b/packages/webapp/src/configure.ts @@ -8,7 +8,7 @@ import { localStorageKeys } from 'src/constants'; import type { ThemeName } from 'src/theme'; import { GetAccountQuery } from 'src/generated/graphql'; -const defaultKeybinding = { +export const defaultKeybinding = { Up: 'w', Left: 'a', Down: 's', @@ -70,6 +70,7 @@ interface Configure { searchState?: boolean; friendChatState?: number; usedRelease?: number; + openNesFile?: File; theme: ThemeName; shortcuts: { OPEN_SEARCH: Shortcut; @@ -77,19 +78,23 @@ interface Configure { }; } -export const [configure] = createCacheStore(localStorageKeys.CONFIGURE_LOCAL_STORAGE_KEY, { - theme: 'default', - shortcuts: { - OPEN_SEARCH: { - win: ['ctrl', 'k'], - mac: ['command', 'k'], - }, - OPEN_SETTINGS: { - win: ['esc'], - mac: ['esc'], +export const [configure] = createCacheStore( + localStorageKeys.CONFIGURE_LOCAL_STORAGE_KEY, + { + theme: 'default', + shortcuts: { + OPEN_SEARCH: { + win: ['ctrl', 'k'], + mac: ['command', 'k'], + }, + OPEN_SETTINGS: { + win: ['esc'], + mac: ['esc'], + }, }, }, -}); + { cacheExcludeKeys: ['openNesFile'] }, +); export function getShortcut(command: keyof Configure['shortcuts'], isDisplay = false) { const keys = configure.shortcuts[command][isMac ? 'mac' : 'win']; @@ -120,3 +125,7 @@ export const toggoleSettingsState = () => { export const toggoleSearchState = () => { updateStore(configure, { searchState: !configure.searchState }); }; + +export const setNesFile = (file?: File) => { + updateStore(configure, { openNesFile: file }); +}; diff --git a/packages/webapp/src/constants.ts b/packages/webapp/src/constants.ts index a2fa10eb..fa3e0140 100644 --- a/packages/webapp/src/constants.ts +++ b/packages/webapp/src/constants.ts @@ -25,7 +25,7 @@ export const queryKeys = { // clean outdate cache data [].forEach((key) => localStorage.removeItem(key)); export const localStorageKeys = { - CONFIGURE_LOCAL_STORAGE_KEY: 'configure_v3', + CONFIGURE_LOCAL_STORAGE_KEY: 'configure_v4', STORE_LOCAL_STORAGE_KEY: 'store_v2', FRIEND_CHAT_STORAGE_KEY: 'friend_chat_v2', }; diff --git a/packages/webapp/src/drop.ts b/packages/webapp/src/drop.ts new file mode 100644 index 00000000..a0988083 --- /dev/null +++ b/packages/webapp/src/drop.ts @@ -0,0 +1,21 @@ +import { history } from '@mantou/gem'; +import { createPath } from 'duoyun-ui/elements/route'; + +import { setNesFile } from 'src/configure'; +import { routes } from 'src/routes'; +import { matchRoute } from 'src/utils'; + +window.launchQueue?.setConsumer(async (launchParams: any) => { + if (!launchParams.files.length) return; + + // https://github.com/WICG/file-system-access/blob/master/EXPLAINER.md#example-code + const files = await Promise.all(launchParams.files.map((h: any) => h.getFile())); + dropHandler(files); +}); + +export const dropHandler = (files: File[]) => { + if (!matchRoute(routes.emulator)) { + history.push({ path: createPath(routes.emulator) }); + } + setNesFile(files.find((e) => e.name.toLowerCase().endsWith('.nes'))); +}; diff --git a/packages/webapp/src/index.ts b/packages/webapp/src/index.ts index 8f167659..b13096fb 100644 --- a/packages/webapp/src/index.ts +++ b/packages/webapp/src/index.ts @@ -1,7 +1,7 @@ -import { html, render, history, styleMap } from '@mantou/gem'; +import { html, render, styleMap } from '@mantou/gem'; import { mediaQuery } from '@mantou/gem/helper/mediaquery'; import { Toast } from 'duoyun-ui/elements/toast'; -import { matchPath, RouteItem } from 'duoyun-ui/elements/route'; +import { DuoyunDropAreaElement } from 'duoyun-ui/elements/drop-area'; import { theme } from 'src/theme'; import { configure } from 'src/configure'; @@ -9,8 +9,9 @@ import { COMMAND, isTauriMacApp, isTauriWinApp, RELEASE } from 'src/constants'; import { logger } from 'src/logger'; import { routes } from 'src/routes'; import { gotoRedirectUri, isExpiredProfile, logout } from 'src/auth'; -import { isInputElement } from 'src/utils'; +import { isInputElement, matchRoute } from 'src/utils'; import { listener } from 'src/gamepad'; +import { dropHandler } from 'src/drop'; import 'src/modules/meta'; @@ -20,14 +21,12 @@ logger.info('MODE\t', import.meta.env.MODE); logger.info('RELEASE\t', RELEASE); logger.info('COMMAND\t', COMMAND); -const match = (route: RouteItem) => matchPath(route.pattern, history.getParams().path); - -if ([routes.login, routes.register].some(match)) { +if ([routes.login, routes.register].some(matchRoute)) { if (configure.profile) { gotoRedirectUri(); } -} else if ([routes.download].some(match)) { - // +} else if ([routes.download, routes.emulator].some(matchRoute)) { + logger.info('Welcome!'); } else if (!configure.profile || isExpiredProfile(configure.profile)) { logout(true); } @@ -54,6 +53,11 @@ render( color: ${theme.textColor}; background-color: ${theme.backgroundColor}; } + dy-drop-area { + display: flex; + flex-direction: column; + flex-grow: 1; + } @media ${mediaQuery.DESKTOP} { body { font-size: 1.1rem; @@ -74,22 +78,27 @@ render( > ` : ''} - e.preventDefault()} - .routes=${[ - routes.login, - routes.register, - routes.download, - { - pattern: '*', - getContent() { - import('src/app'); - return html``; - }, - }, - ]} + ) => evt.target instanceof DuoyunDropAreaElement && dropHandler(evt.detail)} > - + e.preventDefault()} + .routes=${[ + routes.login, + routes.register, + routes.download, + routes.emulator, + { + pattern: '*', + getContent() { + import('src/app'); + return html``; + }, + }, + ]} + > + + `, document.body, ); diff --git a/packages/webapp/src/modules/settings.ts b/packages/webapp/src/modules/settings.ts index e4472b10..ffc5a2b3 100644 --- a/packages/webapp/src/modules/settings.ts +++ b/packages/webapp/src/modules/settings.ts @@ -70,7 +70,7 @@ export class MSettingsElement extends GemElement { tab: i18n.get('accountSetting'), getContent() { return html` - + `; @@ -80,7 +80,7 @@ export class MSettingsElement extends GemElement { tab: i18n.get('keySetting'), getContent() { return html` - + `; @@ -90,7 +90,7 @@ export class MSettingsElement extends GemElement { tab: i18n.get('soundSetting'), getContent() { return html` - + `; @@ -100,7 +100,7 @@ export class MSettingsElement extends GemElement { tab: i18n.get('license'), getContent() { return html` - + MIT License Copyright (c) 2021-present Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, diff --git a/packages/webapp/src/pages/emulator.ts b/packages/webapp/src/pages/emulator.ts new file mode 100644 index 00000000..0fa45f7e --- /dev/null +++ b/packages/webapp/src/pages/emulator.ts @@ -0,0 +1,157 @@ +import { + GemElement, + html, + adoptedStyle, + customElement, + createCSSSheet, + css, + connectStore, + refobject, + RefObject, +} from '@mantou/gem'; +import { locale } from 'duoyun-ui/lib/locale'; +import { Button, WasmNes } from 'nes_rust_wasm'; +import { hotkeys } from 'duoyun-ui/lib/hotkeys'; +import { Modal } from 'duoyun-ui/elements/modal'; + +import { configure, defaultKeybinding } from 'src/configure'; + +import 'duoyun-ui/elements/heading'; + +const style = createCSSSheet(css` + .canvas { + position: absolute; + width: 100%; + height: 100%; + object-fit: contain; + background-color: black; + } + .nodata { + position: absolute; + inset: 0; + display: flex; + place-content: center; + place-items: center; + margin-block-start: -10vh; + } + .nodata[hidden] { + display: none; + } +`); + +/** + * @customElement p-emulator + */ +@customElement('p-emulator') +@adoptedStyle(style) +@connectStore(configure) +export class PEmulatorElement extends GemElement { + @refobject canvasRef: RefObject; + + get #isVisible() { + return document.visibilityState === 'visible'; + } + + #nes?: WasmNes; + #imageData?: ImageData; + #audioContext?: AudioContext; + + #enableAudio = () => { + if (this.#audioContext?.state === 'suspended') { + this.#audioContext.resume(); + } + }; + + #getButton = (event: KeyboardEvent) => { + const map: Record = { + [defaultKeybinding.Up]: Button.Joypad1Up, + [defaultKeybinding.Left]: Button.Joypad1Left, + [defaultKeybinding.Down]: Button.Joypad1Down, + [defaultKeybinding.Right]: Button.Joypad1Right, + [defaultKeybinding.A]: Button.Joypad1A, + [defaultKeybinding.B]: Button.Joypad1B, + [defaultKeybinding.Select]: Button.Select, + [defaultKeybinding.Start]: Button.Start, + }; + return map[event.key.toLowerCase()]; + }; + + #quit = async () => { + await Modal.confirm('回到首页?'); + window.location.replace(`/`); + }; + + #onKeyDown = (event: KeyboardEvent) => { + const button = this.#getButton(event); + if (!button) { + hotkeys({ esc: this.#quit })(event); + return; + } + if (button !== Button.Reset) this.#enableAudio(); + this.#nes?.press_button(button); + }; + + #onKeyUp = (event: KeyboardEvent) => { + const button = this.#getButton(event); + if (!button) return; + this.#nes?.release_button(button); + }; + + #renderCanvas = () => { + if (this.isConnected) { + requestAnimationFrame(this.#renderCanvas); + } + + if (!this.#nes || !this.#imageData) return; + this.#nes.step_frame(); + this.#nes.update_pixels(new Uint8Array(this.#imageData.data.buffer)); + this.canvasRef.element!.getContext('2d')!.putImageData(this.#imageData, 0, 0); + }; + + #initAudio = () => { + this.#audioContext = new AudioContext({ sampleRate: 44100 }); + this.#audioContext.suspend(); + const scriptProcessor = this.#audioContext.createScriptProcessor(4096, 0, 1); + scriptProcessor.connect(this.#audioContext.destination); + scriptProcessor.onaudioprocess = (e) => { + if (this.#isVisible) { + const data = e.outputBuffer.getChannelData(0); + this.#nes?.update_sample_buffer(data); + } + }; + }; + + #initNes = async () => { + if (!configure.openNesFile) return; + + const ctx = this.canvasRef.element!.getContext('2d')!; + this.#imageData = ctx.createImageData(ctx.canvas.width, ctx.canvas.height); + const buffer = await configure.openNesFile.arrayBuffer(); + this.#nes = WasmNes.new(); + this.#nes.set_rom(new Uint8Array(buffer)); + this.#nes.bootup(); + }; + + mounted = async () => { + this.#renderCanvas(); + this.#initAudio(); + this.effect(this.#initNes, () => [configure.openNesFile]); + addEventListener('keydown', this.#onKeyDown); + addEventListener('keyup', this.#onKeyUp); + }; + + unmounted = () => { + this.#audioContext?.close(); + removeEventListener('keydown', this.#onKeyDown); + removeEventListener('keyup', this.#onKeyUp); + }; + + render = () => { + return html` + +
+ ${locale.noData} +
+ `; + }; +} diff --git a/packages/webapp/src/pages/room.ts b/packages/webapp/src/pages/room.ts index 494eec9f..1cb7fa6b 100644 --- a/packages/webapp/src/pages/room.ts +++ b/packages/webapp/src/pages/room.ts @@ -114,6 +114,11 @@ export class PRoomElement extends GemElement { return document.visibilityState === 'visible'; } + constructor() { + super(); + this.addEventListener('dragover', (e) => e.stopPropagation()); + } + #nes?: WasmNes; #imageData?: ImageData; #audioContext?: AudioContext; diff --git a/packages/webapp/src/routes.ts b/packages/webapp/src/routes.ts index 150a0010..ae034ad2 100644 --- a/packages/webapp/src/routes.ts +++ b/packages/webapp/src/routes.ts @@ -23,6 +23,14 @@ const getInitRoutes = () => { return html``; }, }, + emulator: { + title: '模拟器', + pattern: '/emulator', + async getContent(_params: Record) { + await import('src/pages/emulator'); + return html``; + }, + }, game: { title: i18n.get('gameTitle'), pattern: `/game/:${paramKeys.GAME_ID}`, diff --git a/packages/webapp/src/utils.ts b/packages/webapp/src/utils.ts index aef892bf..e4330822 100644 --- a/packages/webapp/src/utils.ts +++ b/packages/webapp/src/utils.ts @@ -1,5 +1,6 @@ -import { render, TemplateResult } from '@mantou/gem'; +import { history, render, TemplateResult } from '@mantou/gem'; import { UserAttentionType } from '@tauri-apps/api/window'; +import { matchPath, RouteItem } from 'duoyun-ui/elements/route'; import { Time } from 'duoyun-ui/lib/time'; import { configure } from 'src/configure'; @@ -79,3 +80,5 @@ export const formatTime = (timestamp: number) => { } return time.format(); }; + +export const matchRoute = (route: RouteItem) => matchPath(route.pattern, history.getParams().path); diff --git a/packages/webapp/vite-env.d.ts b/packages/webapp/vite-env.d.ts index 3d46c35a..2b331053 100644 --- a/packages/webapp/vite-env.d.ts +++ b/packages/webapp/vite-env.d.ts @@ -11,6 +11,7 @@ declare global { shell: typeof shell; tauri: typeof tauri; }; + launchQueue?: any; } interface Navigator {