diff --git a/Cargo.lock b/Cargo.lock index c3db9b6..daf336e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,7 +76,7 @@ dependencies = [ "derive_more", "encoding_rs", "futures-core", - "h2", + "h2 0.3.26", "http 0.2.12", "httparse", "httpdate", @@ -168,7 +168,7 @@ dependencies = [ "impl-more", "pin-project-lite", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-util", "tracing", "webpki-roots", @@ -879,7 +879,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -899,7 +899,7 @@ dependencies = [ "cocoa-foundation", "core-foundation", "core-graphics", - "foreign-types", + "foreign-types 0.5.0", "libc", "objc", ] @@ -996,7 +996,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.5.0", "libc", ] @@ -1693,6 +1693,7 @@ version = "0.1.0" dependencies = [ "futures", "once_cell", + "reqwest", "serde", "serde_json", "shared", @@ -1751,6 +1752,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared 0.1.1", +] + [[package]] name = "foreign-types" version = "0.5.0" @@ -1758,7 +1768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared", + "foreign-types-shared 0.3.1", ] [[package]] @@ -1772,6 +1782,12 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -2367,6 +2383,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -2526,6 +2561,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", + "h2 0.4.7", "http 1.1.0", "http-body", "httparse", @@ -2536,6 +2572,39 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper", + "hyper-util", + "rustls 0.23.7", + "rustls-pki-types", + "tokio", + "tokio-rustls 0.26.0", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.3" @@ -2902,7 +2971,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.48.5", ] [[package]] @@ -3173,7 +3242,7 @@ dependencies = [ "once_cell", "parking_lot 0.12.2", "qrcode", - "rustls", + "rustls 0.21.11", "rustls-pemfile", "serde", "tokio", @@ -3223,6 +3292,23 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "native-tls" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "ndk" version = "0.7.0" @@ -3444,6 +3530,50 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types 0.3.2", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -3548,7 +3678,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec 1.13.2", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -4140,31 +4270,39 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", + "encoding_rs", "futures-core", "futures-util", + "h2 0.4.7", "http 1.1.0", "http-body", "http-body-util", "hyper", + "hyper-rustls", + "hyper-tls", "hyper-util", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", + "system-configuration", "tokio", + "tokio-native-tls", "tokio-util", "tower-service", "url", @@ -4172,7 +4310,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -4289,10 +4427,23 @@ checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring", - "rustls-webpki", + "rustls-webpki 0.101.7", "sct", ] +[[package]] +name = "rustls" +version = "0.23.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki 0.102.3", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" version = "2.0.0" @@ -4319,6 +4470,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustls-webpki" +version = "0.102.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + [[package]] name = "rustversion" version = "1.0.15" @@ -4351,6 +4513,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "schemars" version = "0.8.19" @@ -4399,6 +4570,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags 2.5.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "selectors" version = "0.22.0" @@ -4705,7 +4899,7 @@ dependencies = [ "cfg_aliases", "cocoa", "core-graphics", - "foreign-types", + "foreign-types 0.5.0", "js-sys", "log", "objc", @@ -4840,6 +5034,12 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "swift-rs" version = "1.0.6" @@ -4875,9 +5075,33 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.5.0", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "system-deps" @@ -5377,13 +5601,34 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.11", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls 0.23.7", + "rustls-pki-types", "tokio", ] @@ -5782,6 +6027,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.2.0" @@ -6525,7 +6776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ "windows-core 0.56.0", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6534,7 +6785,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6545,8 +6796,8 @@ checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" dependencies = [ "windows-implement", "windows-interface", - "windows-result", - "windows-targets 0.52.5", + "windows-result 0.1.1", + "windows-targets 0.52.6", ] [[package]] @@ -6571,13 +6822,43 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result 0.2.0", + "windows-strings", + "windows-targets 0.52.6", +] + [[package]] name = "windows-result" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", ] [[package]] @@ -6604,7 +6885,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -6639,18 +6929,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -6659,7 +6949,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6998aa457c9ba8ff2fb9f13e9d2a930dabcea28f1d0ab94d687d8b3654844515" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -6676,9 +6966,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -6694,9 +6984,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -6712,15 +7002,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -6736,9 +7026,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -6754,9 +7044,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -6772,9 +7062,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -6790,9 +7080,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -7023,6 +7313,12 @@ dependencies = [ "syn 2.0.61", ] +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + [[package]] name = "zoon" version = "0.1.0" diff --git a/frontend/src/header_panel.rs b/frontend/src/header_panel.rs index c2ed570..872025d 100644 --- a/frontend/src/header_panel.rs +++ b/frontend/src/header_panel.rs @@ -36,7 +36,8 @@ impl HeaderPanel { .s(Gap::both(15)) .item(self.load_button()) .item(self.layout_switcher()) - .item(self.mode_switcher()), + .item(self.mode_switcher()) + .item(self.open_konata_file()), ) } @@ -193,4 +194,22 @@ impl HeaderPanel { }) }) } + + fn open_konata_file(&self) -> impl Element { + let (hovered, hovered_signal) = Mutable::new_and_signal(false); + Button::new() + .s(Padding::new().x(20).y(10)) + .s(Background::new().color_signal( + hovered_signal.map_bool(|| COLOR_MEDIUM_SLATE_BLUE, || COLOR_SLATE_BLUE), + )) + .s(Align::new().left()) + .s(RoundedCorners::all(15)) + .label( + El::new() + .s(Font::new().no_wrap()) + .child("Open Konata file.."), + ) + .on_hovered_change(move |is_hovered| hovered.set_neq(is_hovered)) + .on_press(move || Task::start(platform::open_konata_file())) + } } diff --git a/frontend/src/platform.rs b/frontend/src/platform.rs index 3ed4408..8d3a9c4 100644 --- a/frontend/src/platform.rs +++ b/frontend/src/platform.rs @@ -119,3 +119,7 @@ pub async fn notify_diagram_connector_text_change( ) { platform::notify_diagram_connector_text_change(diagram_connector, component_id, text).await; } + +pub async fn open_konata_file() { + platform::open_konata_file().await; +} diff --git a/frontend/src/platform/browser.rs b/frontend/src/platform/browser.rs index 0d98a0a..fe341c8 100644 --- a/frontend/src/platform/browser.rs +++ b/frontend/src/platform/browser.rs @@ -166,3 +166,8 @@ pub async fn notify_diagram_connector_text_change( // @TODO error message for user eprintln!("Diagram connectors notifications are not supported in the browser."); } + +pub async fn open_konata_file() { + // @TODO error message for user + eprintln!("Opening Konata files is not supported in the browser."); +} diff --git a/frontend/src/platform/tauri.rs b/frontend/src/platform/tauri.rs index 96b9160..37b4c39 100644 --- a/frontend/src/platform/tauri.rs +++ b/frontend/src/platform/tauri.rs @@ -107,6 +107,10 @@ pub(super) async fn notify_diagram_connector_text_change( .unwrap_throw(); } +pub(super) async fn open_konata_file() { + tauri_glue::open_konata_file().await; +} + mod tauri_glue { use zoon::*; @@ -162,5 +166,7 @@ mod tauri_glue { component_id: super::super::ComponentId, text: String, ) -> Result<(), JsValue>; + + pub async fn open_konata_file(); } } diff --git a/frontend/typescript/bundles/tauri_glue.js b/frontend/typescript/bundles/tauri_glue.js index 6dc906b..de96555 100644 --- a/frontend/typescript/bundles/tauri_glue.js +++ b/frontend/typescript/bundles/tauri_glue.js @@ -1 +1 @@ -var ae=Object.defineProperty;var q=(n,e)=>{for(var t in e)ae(n,t,{get:e[t],enumerable:!0})};var M={};q(M,{Channel:()=>k,PluginListener:()=>R,Resource:()=>y,addPluginListener:()=>se,convertFileSrc:()=>le,invoke:()=>i,isTauri:()=>oe,transformCallback:()=>T});function u(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function _(n,e,t,r,a){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!a:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?a.call(n,t):a?a.value=t:e.set(n,t),t}var b,A,f,L;function T(n,e=!1){return window.__TAURI_INTERNALS__.transformCallback(n,e)}var k=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,b.set(this,()=>{}),A.set(this,0),f.set(this,{}),this.id=T(({message:e,id:t})=>{if(t===u(this,A,"f")){_(this,A,t+1,"f"),u(this,b,"f").call(this,e);let r=Object.keys(u(this,f,"f"));if(r.length>0){let a=t+1;for(let o of r.sort())if(parseInt(o)===a){let s=u(this,f,"f")[o];delete u(this,f,"f")[o],u(this,b,"f").call(this,s),a+=1}else break;_(this,A,a,"f")}}else u(this,f,"f")[t.toString()]=e})}set onmessage(e){_(this,b,e,"f")}get onmessage(){return u(this,b,"f")}toJSON(){return`__CHANNEL__:${this.id}`}};b=new WeakMap,A=new WeakMap,f=new WeakMap;var R=class{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r}async unregister(){return i(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function se(n,e,t){let r=new k;return r.onmessage=t,i(`plugin:${n}|register_listener`,{event:e,handler:r}).then(()=>new R(n,e,r.id))}async function i(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}function le(n,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,e)}var y=class{get rid(){return u(this,L,"f")}constructor(e){L.set(this,void 0),_(this,L,e,"f")}async close(){return i("plugin:resources|close",{rid:this.rid})}};L=new WeakMap;function oe(){return"isTauri"in window&&!!window.isTauri}var E={};q(E,{TauriEvent:()=>l,emit:()=>x,emitTo:()=>P,listen:()=>p,once:()=>w});var l;(function(n){n.WINDOW_RESIZED="tauri://resize",n.WINDOW_MOVED="tauri://move",n.WINDOW_CLOSE_REQUESTED="tauri://close-requested",n.WINDOW_DESTROYED="tauri://destroyed",n.WINDOW_FOCUS="tauri://focus",n.WINDOW_BLUR="tauri://blur",n.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",n.WINDOW_THEME_CHANGED="tauri://theme-changed",n.WINDOW_CREATED="tauri://window-created",n.WEBVIEW_CREATED="tauri://webview-created",n.DRAG="tauri://drag",n.DROP="tauri://drop",n.DROP_OVER="tauri://drop-over",n.DROP_CANCELLED="tauri://drag-cancelled"})(l||(l={}));async function J(n,e){await i("plugin:event|unlisten",{event:n,eventId:e})}async function p(n,e,t){var r;let a=typeof t?.target=="string"?{kind:"AnyLabel",label:t.target}:(r=t?.target)!==null&&r!==void 0?r:{kind:"Any"};return i("plugin:event|listen",{event:n,target:a,handler:T(e)}).then(o=>async()=>J(n,o))}async function w(n,e,t){return p(n,r=>{e(r),J(n,r.id).catch(()=>{})},t)}async function x(n,e){await i("plugin:event|emit",{event:n,payload:e})}async function P(n,e,t){await i("plugin:event|emit_to",{target:typeof n=="string"?{kind:"AnyLabel",label:n}:n,event:e,payload:t})}var F=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},h=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new F(this.width/e,this.height/e)}},O=class{constructor(e,t){this.type="Logical",this.x=e,this.y=t}},c=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new O(this.x/e,this.y/e)}};var I=class n extends y{constructor(e){super(e)}static async new(e,t,r){return i("plugin:image|new",{rgba:g(e),width:t,height:r}).then(a=>new n(a))}static async fromBytes(e){return i("plugin:image|from_bytes",{bytes:g(e)}).then(t=>new n(t))}static async fromPath(e){return i("plugin:image|from_path",{path:e}).then(t=>new n(t))}async rgba(){return i("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return i("plugin:image|size",{rid:this.rid})}};function g(n){return n==null?null:typeof n=="string"?n:n instanceof Uint8Array?Array.from(n):n instanceof ArrayBuffer?Array.from(new Uint8Array(n)):n instanceof I?n.rid:n}var V;(function(n){n[n.Critical=1]="Critical",n[n.Informational=2]="Informational"})(V||(V={}));var G=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},K;(function(n){n.None="none",n.Normal="normal",n.Indeterminate="indeterminate",n.Paused="paused",n.Error="error"})(K||(K={}));function H(){return new m(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function z(){return window.__TAURI_INTERNALS__.metadata.windows.map(n=>new m(n.label,{skip:!0}))}var U=["tauri://created","tauri://error"],m=class{constructor(e,t={}){var r;this.label=e,this.listeners=Object.create(null),t?.skip||i("plugin:window|create",{options:{...t,parent:typeof t.parent=="string"?t.parent:(r=t.parent)===null||r===void 0?void 0:r.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;return(t=z().find(r=>r.label===e))!==null&&t!==void 0?t:null}static getCurrent(){return H()}static getAll(){return z()}static async getFocusedWindow(){for(let e of z())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(U.includes(e)){for(let r of this.listeners[e]||[])r({event:e,id:-1,payload:t});return Promise.resolve()}return x(e,t)}async emitTo(e,t,r){if(U.includes(t)){for(let a of this.listeners[t]||[])a({event:t,id:-1,payload:r});return Promise.resolve()}return P(e,t,r)}_handleTauriEvent(e,t){return U.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return i("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return i("plugin:window|inner_position",{label:this.label}).then(({x:e,y:t})=>new c(e,t))}async outerPosition(){return i("plugin:window|outer_position",{label:this.label}).then(({x:e,y:t})=>new c(e,t))}async innerSize(){return i("plugin:window|inner_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async outerSize(){return i("plugin:window|outer_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async isFullscreen(){return i("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return i("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return i("plugin:window|is_maximized",{label:this.label})}async isFocused(){return i("plugin:window|is_focused",{label:this.label})}async isDecorated(){return i("plugin:window|is_decorated",{label:this.label})}async isResizable(){return i("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return i("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return i("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return i("plugin:window|is_closable",{label:this.label})}async isVisible(){return i("plugin:window|is_visible",{label:this.label})}async title(){return i("plugin:window|title",{label:this.label})}async theme(){return i("plugin:window|theme",{label:this.label})}async center(){return i("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(e===V.Critical?t={type:"Critical"}:t={type:"Informational"}),i("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return i("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return i("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return i("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return i("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return i("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return i("plugin:window|maximize",{label:this.label})}async unmaximize(){return i("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return i("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return i("plugin:window|minimize",{label:this.label})}async unminimize(){return i("plugin:window|unminimize",{label:this.label})}async show(){return i("plugin:window|show",{label:this.label})}async hide(){return i("plugin:window|hide",{label:this.label})}async close(){return i("plugin:window|close",{label:this.label})}async destroy(){return i("plugin:window|destroy",{label:this.label})}async setDecorations(e){return i("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return i("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return i("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return i("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return i("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return i("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return i("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t={};return t[`${e.type}`]={width:e.width,height:e.height},i("plugin:window|set_size",{label:this.label,value:t})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),i("plugin:window|set_min_size",{label:this.label,value:t})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),i("plugin:window|set_max_size",{label:this.label,value:t})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:window|set_position",{label:this.label,value:t})}async setFullscreen(e){return i("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return i("plugin:window|set_focus",{label:this.label})}async setIcon(e){return i("plugin:window|set_icon",{label:this.label,value:g(e)})}async setSkipTaskbar(e){return i("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return i("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return i("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return i("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:window|set_cursor_position",{label:this.label,value:t})}async setIgnoreCursorEvents(e){return i("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return i("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return i("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setProgressBar(e){return i("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return i("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async onResized(e){return this.listen(l.WINDOW_RESIZED,t=>{t.payload=pe(t.payload),e(t)})}async onMoved(e){return this.listen(l.WINDOW_MOVED,t=>{t.payload=W(t.payload),e(t)})}async onCloseRequested(e){return this.listen(l.WINDOW_CLOSE_REQUESTED,t=>{let r=new G(t);Promise.resolve(e(r)).then(()=>{if(!r.isPreventDefault())return this.destroy()})})}async onDragDropEvent(e){let t=await this.listen(l.DRAG,s=>{e({...s,payload:{type:"dragged",paths:s.payload.paths,position:W(s.payload.position)}})}),r=await this.listen(l.DROP,s=>{e({...s,payload:{type:"dropped",paths:s.payload.paths,position:W(s.payload.position)}})}),a=await this.listen(l.DROP_OVER,s=>{e({...s,payload:{type:"dragOver",position:W(s.payload.position)}})}),o=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"cancelled"}})});return()=>{t(),r(),a(),o()}}async onFocusChanged(e){let t=await this.listen(l.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),r=await this.listen(l.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{t(),r()}}async onScaleChanged(e){return this.listen(l.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(l.WINDOW_THEME_CHANGED,e)}},Z;(function(n){n.AppearanceBased="appearanceBased",n.Light="light",n.Dark="dark",n.MediumLight="mediumLight",n.UltraDark="ultraDark",n.Titlebar="titlebar",n.Selection="selection",n.Menu="menu",n.Popover="popover",n.Sidebar="sidebar",n.HeaderView="headerView",n.Sheet="sheet",n.WindowBackground="windowBackground",n.HudWindow="hudWindow",n.FullScreenUI="fullScreenUI",n.Tooltip="tooltip",n.ContentBackground="contentBackground",n.UnderWindowBackground="underWindowBackground",n.UnderPageBackground="underPageBackground",n.Mica="mica",n.Blur="blur",n.Acrylic="acrylic",n.Tabbed="tabbed",n.TabbedDark="tabbedDark",n.TabbedLight="tabbedLight"})(Z||(Z={}));var Y;(function(n){n.FollowsWindowActiveState="followsWindowActiveState",n.Active="active",n.Inactive="inactive"})(Y||(Y={}));function W(n){return new c(n.x,n.y)}function pe(n){return new h(n.width,n.height)}function N(){return new v(H(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}function X(){return window.__TAURI_INTERNALS__.metadata.webviews.map(n=>new v(m.getByLabel(n.windowLabel),n.label,{skip:!0}))}var j=["tauri://created","tauri://error"],v=class{constructor(e,t,r){this.window=e,this.label=t,this.listeners=Object.create(null),r?.skip||i("plugin:webview|create_webview",{windowLabel:e.label,label:t,options:r}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;return(t=X().find(r=>r.label===e))!==null&&t!==void 0?t:null}static getCurrent(){return N()}static getAll(){return X()}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(j.includes(e)){for(let r of this.listeners[e]||[])r({event:e,id:-1,payload:t});return Promise.resolve()}return x(e,t)}async emitTo(e,t,r){if(j.includes(t)){for(let a of this.listeners[t]||[])a({event:t,id:-1,payload:r});return Promise.resolve()}return P(e,t,r)}_handleTauriEvent(e,t){return j.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return i("plugin:webview|webview_position",{label:this.label}).then(({x:e,y:t})=>new c(e,t))}async size(){return i("plugin:webview|webview_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async close(){return i("plugin:webview|close",{label:this.label})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t={};return t[`${e.type}`]={width:e.width,height:e.height},i("plugin:webview|set_webview_size",{label:this.label,value:t})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:webview|set_webview_position",{label:this.label,value:t})}async setFocus(){return i("plugin:webview|set_webview_focus",{label:this.label})}async setZoom(e){return i("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return i("plugin:webview|set_webview_focus",{label:this.label,window:typeof e=="string"?e:e.label})}async onDragDropEvent(e){let t=await this.listen(l.DRAG,s=>{e({...s,payload:{type:"dragged",paths:s.payload.paths,position:$(s.payload.position)}})}),r=await this.listen(l.DROP,s=>{e({...s,payload:{type:"dropped",paths:s.payload.paths,position:$(s.payload.position)}})}),a=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"dragOver",position:$(s.payload.position)}})}),o=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"cancelled"}})});return()=>{t(),r(),a(),o()}}};function $(n){return new c(n.x,n.y)}function ye(){let n=N();return new C(n.label,{skip:!0})}function B(){return window.__TAURI_INTERNALS__.metadata.webviews.map(n=>new C(n.label,{skip:!0}))}var C=class n{constructor(e,t={}){var r;this.label=e,this.listeners=Object.create(null),t?.skip||i("plugin:webview|create_webview_window",{options:{...t,parent:typeof t.parent=="string"?t.parent:(r=t.parent)===null||r===void 0?void 0:r.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;let r=(t=B().find(a=>a.label===e))!==null&&t!==void 0?t:null;return r?new n(r.label,{skip:!0}):null}static getCurrent(){return ye()}static getAll(){return B().map(e=>new n(e.label,{skip:!0}))}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"WebviewWindow",label:this.label}})}};we(C,[m,v]);function we(n,e){(Array.isArray(e)?e:[e]).forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{var a;typeof n.prototype=="object"&&n.prototype&&r in n.prototype||Object.defineProperty(n.prototype,r,(a=Object.getOwnPropertyDescriptor(t.prototype,r))!==null&&a!==void 0?a:Object.create(null))})})}var ee;(function(n){n[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template"})(ee||(ee={}));var fe,ke;fe=new WeakMap,ke=new WeakMap;var Q;(function(n){n.Add="Add",n.Advanced="Advanced",n.Bluetooth="Bluetooth",n.Bookmarks="Bookmarks",n.Caution="Caution",n.ColorPanel="ColorPanel",n.ColumnView="ColumnView",n.Computer="Computer",n.EnterFullScreen="EnterFullScreen",n.Everyone="Everyone",n.ExitFullScreen="ExitFullScreen",n.FlowView="FlowView",n.Folder="Folder",n.FolderBurnable="FolderBurnable",n.FolderSmart="FolderSmart",n.FollowLinkFreestanding="FollowLinkFreestanding",n.FontPanel="FontPanel",n.GoLeft="GoLeft",n.GoRight="GoRight",n.Home="Home",n.IChatTheater="IChatTheater",n.IconView="IconView",n.Info="Info",n.InvalidDataFreestanding="InvalidDataFreestanding",n.LeftFacingTriangle="LeftFacingTriangle",n.ListView="ListView",n.LockLocked="LockLocked",n.LockUnlocked="LockUnlocked",n.MenuMixedState="MenuMixedState",n.MenuOnState="MenuOnState",n.MobileMe="MobileMe",n.MultipleDocuments="MultipleDocuments",n.Network="Network",n.Path="Path",n.PreferencesGeneral="PreferencesGeneral",n.QuickLook="QuickLook",n.RefreshFreestanding="RefreshFreestanding",n.Refresh="Refresh",n.Remove="Remove",n.RevealFreestanding="RevealFreestanding",n.RightFacingTriangle="RightFacingTriangle",n.Share="Share",n.Slideshow="Slideshow",n.SmartBadge="SmartBadge",n.StatusAvailable="StatusAvailable",n.StatusNone="StatusNone",n.StatusPartiallyAvailable="StatusPartiallyAvailable",n.StatusUnavailable="StatusUnavailable",n.StopProgressFreestanding="StopProgressFreestanding",n.StopProgress="StopProgress",n.TrashEmpty="TrashEmpty",n.TrashFull="TrashFull",n.User="User",n.UserAccounts="UserAccounts",n.UserGroup="UserGroup",n.UserGuest="UserGuest"})(Q||(Q={}));var d=M.invoke,xe=E.listen;async function zn(){return await d("show_window")}async function Un(){return await d("pick_and_load_waveform")}async function Vn(){return await d("load_file_with_selected_vars")}async function Gn(){return await d("get_hierarchy")}async function Hn(n,e,t,r,a,o){return await d("load_signal_and_get_timeline",{signal_ref_index:n,timeline_zoom:e,timeline_viewport_width:t,timeline_viewport_x:r,block_height:a,var_format:o})}async function jn(n){return await d("unload_signal",{signal_ref_index:n})}async function $n(n){return await d("add_decoders",{decoder_paths:n})}async function Nn(){return await d("remove_all_decoders")}async function Qn(n){return await d("add_diagram_connectors",{diagram_connector_paths:n})}async function qn(){return await d("remove_all_diagram_connectors")}async function Jn(n){return await xe("diagram_connector_message",e=>n(e.payload))}async function Kn(n,e,t){return await d("notify_diagram_connector_text_change",{diagram_connector:n,component_id:e,text:t})}export{$n as add_decoders,Qn as add_diagram_connectors,Gn as get_hierarchy,Jn as listen_diagram_connectors_messages,Vn as load_file_with_selected_vars,Hn as load_signal_and_get_timeline,Kn as notify_diagram_connector_text_change,Un as pick_and_load_waveform,Nn as remove_all_decoders,qn as remove_all_diagram_connectors,zn as show_window,jn as unload_signal}; +var ae=Object.defineProperty;var q=(n,e)=>{for(var t in e)ae(n,t,{get:e[t],enumerable:!0})};var M={};q(M,{Channel:()=>k,PluginListener:()=>R,Resource:()=>y,addPluginListener:()=>se,convertFileSrc:()=>le,invoke:()=>i,isTauri:()=>oe,transformCallback:()=>T});function c(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}function _(n,e,t,r,a){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!a:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?a.call(n,t):a?a.value=t:e.set(n,t),t}var b,A,f,L;function T(n,e=!1){return window.__TAURI_INTERNALS__.transformCallback(n,e)}var k=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,b.set(this,()=>{}),A.set(this,0),f.set(this,{}),this.id=T(({message:e,id:t})=>{if(t===c(this,A,"f")){_(this,A,t+1,"f"),c(this,b,"f").call(this,e);let r=Object.keys(c(this,f,"f"));if(r.length>0){let a=t+1;for(let u of r.sort())if(parseInt(u)===a){let s=c(this,f,"f")[u];delete c(this,f,"f")[u],c(this,b,"f").call(this,s),a+=1}else break;_(this,A,a,"f")}}else c(this,f,"f")[t.toString()]=e})}set onmessage(e){_(this,b,e,"f")}get onmessage(){return c(this,b,"f")}toJSON(){return`__CHANNEL__:${this.id}`}};b=new WeakMap,A=new WeakMap,f=new WeakMap;var R=class{constructor(e,t,r){this.plugin=e,this.event=t,this.channelId=r}async unregister(){return i(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function se(n,e,t){let r=new k;return r.onmessage=t,i(`plugin:${n}|register_listener`,{event:e,handler:r}).then(()=>new R(n,e,r.id))}async function i(n,e={},t){return window.__TAURI_INTERNALS__.invoke(n,e,t)}function le(n,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(n,e)}var y=class{get rid(){return c(this,L,"f")}constructor(e){L.set(this,void 0),_(this,L,e,"f")}async close(){return i("plugin:resources|close",{rid:this.rid})}};L=new WeakMap;function oe(){return"isTauri"in window&&!!window.isTauri}var E={};q(E,{TauriEvent:()=>l,emit:()=>x,emitTo:()=>P,listen:()=>p,once:()=>w});var l;(function(n){n.WINDOW_RESIZED="tauri://resize",n.WINDOW_MOVED="tauri://move",n.WINDOW_CLOSE_REQUESTED="tauri://close-requested",n.WINDOW_DESTROYED="tauri://destroyed",n.WINDOW_FOCUS="tauri://focus",n.WINDOW_BLUR="tauri://blur",n.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",n.WINDOW_THEME_CHANGED="tauri://theme-changed",n.WINDOW_CREATED="tauri://window-created",n.WEBVIEW_CREATED="tauri://webview-created",n.DRAG="tauri://drag",n.DROP="tauri://drop",n.DROP_OVER="tauri://drop-over",n.DROP_CANCELLED="tauri://drag-cancelled"})(l||(l={}));async function J(n,e){await i("plugin:event|unlisten",{event:n,eventId:e})}async function p(n,e,t){var r;let a=typeof t?.target=="string"?{kind:"AnyLabel",label:t.target}:(r=t?.target)!==null&&r!==void 0?r:{kind:"Any"};return i("plugin:event|listen",{event:n,target:a,handler:T(e)}).then(u=>async()=>J(n,u))}async function w(n,e,t){return p(n,r=>{e(r),J(n,r.id).catch(()=>{})},t)}async function x(n,e){await i("plugin:event|emit",{event:n,payload:e})}async function P(n,e,t){await i("plugin:event|emit_to",{target:typeof n=="string"?{kind:"AnyLabel",label:n}:n,event:e,payload:t})}var F=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},h=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new F(this.width/e,this.height/e)}},O=class{constructor(e,t){this.type="Logical",this.x=e,this.y=t}},d=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new O(this.x/e,this.y/e)}};var I=class n extends y{constructor(e){super(e)}static async new(e,t,r){return i("plugin:image|new",{rgba:g(e),width:t,height:r}).then(a=>new n(a))}static async fromBytes(e){return i("plugin:image|from_bytes",{bytes:g(e)}).then(t=>new n(t))}static async fromPath(e){return i("plugin:image|from_path",{path:e}).then(t=>new n(t))}async rgba(){return i("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return i("plugin:image|size",{rid:this.rid})}};function g(n){return n==null?null:typeof n=="string"?n:n instanceof Uint8Array?Array.from(n):n instanceof ArrayBuffer?Array.from(new Uint8Array(n)):n instanceof I?n.rid:n}var V;(function(n){n[n.Critical=1]="Critical",n[n.Informational=2]="Informational"})(V||(V={}));var G=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},K;(function(n){n.None="none",n.Normal="normal",n.Indeterminate="indeterminate",n.Paused="paused",n.Error="error"})(K||(K={}));function H(){return new m(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function z(){return window.__TAURI_INTERNALS__.metadata.windows.map(n=>new m(n.label,{skip:!0}))}var U=["tauri://created","tauri://error"],m=class{constructor(e,t={}){var r;this.label=e,this.listeners=Object.create(null),t?.skip||i("plugin:window|create",{options:{...t,parent:typeof t.parent=="string"?t.parent:(r=t.parent)===null||r===void 0?void 0:r.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;return(t=z().find(r=>r.label===e))!==null&&t!==void 0?t:null}static getCurrent(){return H()}static getAll(){return z()}static async getFocusedWindow(){for(let e of z())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"Window",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"Window",label:this.label}})}async emit(e,t){if(U.includes(e)){for(let r of this.listeners[e]||[])r({event:e,id:-1,payload:t});return Promise.resolve()}return x(e,t)}async emitTo(e,t,r){if(U.includes(t)){for(let a of this.listeners[t]||[])a({event:t,id:-1,payload:r});return Promise.resolve()}return P(e,t,r)}_handleTauriEvent(e,t){return U.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return i("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return i("plugin:window|inner_position",{label:this.label}).then(({x:e,y:t})=>new d(e,t))}async outerPosition(){return i("plugin:window|outer_position",{label:this.label}).then(({x:e,y:t})=>new d(e,t))}async innerSize(){return i("plugin:window|inner_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async outerSize(){return i("plugin:window|outer_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async isFullscreen(){return i("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return i("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return i("plugin:window|is_maximized",{label:this.label})}async isFocused(){return i("plugin:window|is_focused",{label:this.label})}async isDecorated(){return i("plugin:window|is_decorated",{label:this.label})}async isResizable(){return i("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return i("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return i("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return i("plugin:window|is_closable",{label:this.label})}async isVisible(){return i("plugin:window|is_visible",{label:this.label})}async title(){return i("plugin:window|title",{label:this.label})}async theme(){return i("plugin:window|theme",{label:this.label})}async center(){return i("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(e===V.Critical?t={type:"Critical"}:t={type:"Informational"}),i("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return i("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return i("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return i("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return i("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return i("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return i("plugin:window|maximize",{label:this.label})}async unmaximize(){return i("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return i("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return i("plugin:window|minimize",{label:this.label})}async unminimize(){return i("plugin:window|unminimize",{label:this.label})}async show(){return i("plugin:window|show",{label:this.label})}async hide(){return i("plugin:window|hide",{label:this.label})}async close(){return i("plugin:window|close",{label:this.label})}async destroy(){return i("plugin:window|destroy",{label:this.label})}async setDecorations(e){return i("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return i("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return i("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return i("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return i("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return i("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return i("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t={};return t[`${e.type}`]={width:e.width,height:e.height},i("plugin:window|set_size",{label:this.label,value:t})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),i("plugin:window|set_min_size",{label:this.label,value:t})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t=null;return e&&(t={},t[`${e.type}`]={width:e.width,height:e.height}),i("plugin:window|set_max_size",{label:this.label,value:t})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:window|set_position",{label:this.label,value:t})}async setFullscreen(e){return i("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return i("plugin:window|set_focus",{label:this.label})}async setIcon(e){return i("plugin:window|set_icon",{label:this.label,value:g(e)})}async setSkipTaskbar(e){return i("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return i("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return i("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return i("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:window|set_cursor_position",{label:this.label,value:t})}async setIgnoreCursorEvents(e){return i("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return i("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return i("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setProgressBar(e){return i("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return i("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async onResized(e){return this.listen(l.WINDOW_RESIZED,t=>{t.payload=pe(t.payload),e(t)})}async onMoved(e){return this.listen(l.WINDOW_MOVED,t=>{t.payload=W(t.payload),e(t)})}async onCloseRequested(e){return this.listen(l.WINDOW_CLOSE_REQUESTED,t=>{let r=new G(t);Promise.resolve(e(r)).then(()=>{if(!r.isPreventDefault())return this.destroy()})})}async onDragDropEvent(e){let t=await this.listen(l.DRAG,s=>{e({...s,payload:{type:"dragged",paths:s.payload.paths,position:W(s.payload.position)}})}),r=await this.listen(l.DROP,s=>{e({...s,payload:{type:"dropped",paths:s.payload.paths,position:W(s.payload.position)}})}),a=await this.listen(l.DROP_OVER,s=>{e({...s,payload:{type:"dragOver",position:W(s.payload.position)}})}),u=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"cancelled"}})});return()=>{t(),r(),a(),u()}}async onFocusChanged(e){let t=await this.listen(l.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),r=await this.listen(l.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{t(),r()}}async onScaleChanged(e){return this.listen(l.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(l.WINDOW_THEME_CHANGED,e)}},Z;(function(n){n.AppearanceBased="appearanceBased",n.Light="light",n.Dark="dark",n.MediumLight="mediumLight",n.UltraDark="ultraDark",n.Titlebar="titlebar",n.Selection="selection",n.Menu="menu",n.Popover="popover",n.Sidebar="sidebar",n.HeaderView="headerView",n.Sheet="sheet",n.WindowBackground="windowBackground",n.HudWindow="hudWindow",n.FullScreenUI="fullScreenUI",n.Tooltip="tooltip",n.ContentBackground="contentBackground",n.UnderWindowBackground="underWindowBackground",n.UnderPageBackground="underPageBackground",n.Mica="mica",n.Blur="blur",n.Acrylic="acrylic",n.Tabbed="tabbed",n.TabbedDark="tabbedDark",n.TabbedLight="tabbedLight"})(Z||(Z={}));var Y;(function(n){n.FollowsWindowActiveState="followsWindowActiveState",n.Active="active",n.Inactive="inactive"})(Y||(Y={}));function W(n){return new d(n.x,n.y)}function pe(n){return new h(n.width,n.height)}function N(){return new v(H(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}function X(){return window.__TAURI_INTERNALS__.metadata.webviews.map(n=>new v(m.getByLabel(n.windowLabel),n.label,{skip:!0}))}var j=["tauri://created","tauri://error"],v=class{constructor(e,t,r){this.window=e,this.label=t,this.listeners=Object.create(null),r?.skip||i("plugin:webview|create_webview",{windowLabel:e.label,label:t,options:r}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;return(t=X().find(r=>r.label===e))!==null&&t!==void 0?t:null}static getCurrent(){return N()}static getAll(){return X()}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"Webview",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"Webview",label:this.label}})}async emit(e,t){if(j.includes(e)){for(let r of this.listeners[e]||[])r({event:e,id:-1,payload:t});return Promise.resolve()}return x(e,t)}async emitTo(e,t,r){if(j.includes(t)){for(let a of this.listeners[t]||[])a({event:t,id:-1,payload:r});return Promise.resolve()}return P(e,t,r)}_handleTauriEvent(e,t){return j.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async position(){return i("plugin:webview|webview_position",{label:this.label}).then(({x:e,y:t})=>new d(e,t))}async size(){return i("plugin:webview|webview_size",{label:this.label}).then(({width:e,height:t})=>new h(e,t))}async close(){return i("plugin:webview|close",{label:this.label})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");let t={};return t[`${e.type}`]={width:e.width,height:e.height},i("plugin:webview|set_webview_size",{label:this.label,value:t})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");let t={};return t[`${e.type}`]={x:e.x,y:e.y},i("plugin:webview|set_webview_position",{label:this.label,value:t})}async setFocus(){return i("plugin:webview|set_webview_focus",{label:this.label})}async setZoom(e){return i("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return i("plugin:webview|set_webview_focus",{label:this.label,window:typeof e=="string"?e:e.label})}async onDragDropEvent(e){let t=await this.listen(l.DRAG,s=>{e({...s,payload:{type:"dragged",paths:s.payload.paths,position:$(s.payload.position)}})}),r=await this.listen(l.DROP,s=>{e({...s,payload:{type:"dropped",paths:s.payload.paths,position:$(s.payload.position)}})}),a=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"dragOver",position:$(s.payload.position)}})}),u=await this.listen(l.DROP_CANCELLED,s=>{e({...s,payload:{type:"cancelled"}})});return()=>{t(),r(),a(),u()}}};function $(n){return new d(n.x,n.y)}function ye(){let n=N();return new C(n.label,{skip:!0})}function B(){return window.__TAURI_INTERNALS__.metadata.webviews.map(n=>new C(n.label,{skip:!0}))}var C=class n{constructor(e,t={}){var r;this.label=e,this.listeners=Object.create(null),t?.skip||i("plugin:webview|create_webview_window",{options:{...t,parent:typeof t.parent=="string"?t.parent:(r=t.parent)===null||r===void 0?void 0:r.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static getByLabel(e){var t;let r=(t=B().find(a=>a.label===e))!==null&&t!==void 0?t:null;return r?new n(r.label,{skip:!0}):null}static getCurrent(){return ye()}static getAll(){return B().map(e=>new n(e.label,{skip:!0}))}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):p(e,t,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let r=this.listeners[e];r.splice(r.indexOf(t),1)}):w(e,t,{target:{kind:"WebviewWindow",label:this.label}})}};we(C,[m,v]);function we(n,e){(Array.isArray(e)?e:[e]).forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(r=>{var a;typeof n.prototype=="object"&&n.prototype&&r in n.prototype||Object.defineProperty(n.prototype,r,(a=Object.getOwnPropertyDescriptor(t.prototype,r))!==null&&a!==void 0?a:Object.create(null))})})}var ee;(function(n){n[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template"})(ee||(ee={}));var fe,ke;fe=new WeakMap,ke=new WeakMap;var Q;(function(n){n.Add="Add",n.Advanced="Advanced",n.Bluetooth="Bluetooth",n.Bookmarks="Bookmarks",n.Caution="Caution",n.ColorPanel="ColorPanel",n.ColumnView="ColumnView",n.Computer="Computer",n.EnterFullScreen="EnterFullScreen",n.Everyone="Everyone",n.ExitFullScreen="ExitFullScreen",n.FlowView="FlowView",n.Folder="Folder",n.FolderBurnable="FolderBurnable",n.FolderSmart="FolderSmart",n.FollowLinkFreestanding="FollowLinkFreestanding",n.FontPanel="FontPanel",n.GoLeft="GoLeft",n.GoRight="GoRight",n.Home="Home",n.IChatTheater="IChatTheater",n.IconView="IconView",n.Info="Info",n.InvalidDataFreestanding="InvalidDataFreestanding",n.LeftFacingTriangle="LeftFacingTriangle",n.ListView="ListView",n.LockLocked="LockLocked",n.LockUnlocked="LockUnlocked",n.MenuMixedState="MenuMixedState",n.MenuOnState="MenuOnState",n.MobileMe="MobileMe",n.MultipleDocuments="MultipleDocuments",n.Network="Network",n.Path="Path",n.PreferencesGeneral="PreferencesGeneral",n.QuickLook="QuickLook",n.RefreshFreestanding="RefreshFreestanding",n.Refresh="Refresh",n.Remove="Remove",n.RevealFreestanding="RevealFreestanding",n.RightFacingTriangle="RightFacingTriangle",n.Share="Share",n.Slideshow="Slideshow",n.SmartBadge="SmartBadge",n.StatusAvailable="StatusAvailable",n.StatusNone="StatusNone",n.StatusPartiallyAvailable="StatusPartiallyAvailable",n.StatusUnavailable="StatusUnavailable",n.StopProgressFreestanding="StopProgressFreestanding",n.StopProgress="StopProgress",n.TrashEmpty="TrashEmpty",n.TrashFull="TrashFull",n.User="User",n.UserAccounts="UserAccounts",n.UserGroup="UserGroup",n.UserGuest="UserGuest"})(Q||(Q={}));var o=M.invoke,xe=E.listen;async function zn(){return await o("show_window")}async function Un(){return await o("pick_and_load_waveform")}async function Vn(){return await o("load_file_with_selected_vars")}async function Gn(){return await o("get_hierarchy")}async function Hn(n,e,t,r,a,u){return await o("load_signal_and_get_timeline",{signal_ref_index:n,timeline_zoom:e,timeline_viewport_width:t,timeline_viewport_x:r,block_height:a,var_format:u})}async function jn(n){return await o("unload_signal",{signal_ref_index:n})}async function $n(n){return await o("add_decoders",{decoder_paths:n})}async function Nn(){return await o("remove_all_decoders")}async function Qn(n){return await o("add_diagram_connectors",{diagram_connector_paths:n})}async function qn(){return await o("remove_all_diagram_connectors")}async function Jn(n){return await xe("diagram_connector_message",e=>n(e.payload))}async function Kn(n,e,t){return await o("notify_diagram_connector_text_change",{diagram_connector:n,component_id:e,text:t})}async function Zn(){return await o("open_konata_file")}export{$n as add_decoders,Qn as add_diagram_connectors,Gn as get_hierarchy,Jn as listen_diagram_connectors_messages,Vn as load_file_with_selected_vars,Hn as load_signal_and_get_timeline,Kn as notify_diagram_connector_text_change,Zn as open_konata_file,Un as pick_and_load_waveform,Nn as remove_all_decoders,qn as remove_all_diagram_connectors,zn as show_window,jn as unload_signal}; diff --git a/frontend/typescript/tauri_glue/tauri_glue.ts b/frontend/typescript/tauri_glue/tauri_glue.ts index 5537654..3f37098 100644 --- a/frontend/typescript/tauri_glue/tauri_glue.ts +++ b/frontend/typescript/tauri_glue/tauri_glue.ts @@ -82,3 +82,7 @@ export async function listen_diagram_connectors_messages(on_message: (message: a export async function notify_diagram_connector_text_change(diagram_connector: DiagramConnectorName, component_id: ComponentId, text: string): Promise { return await invoke("notify_diagram_connector_text_change", { diagram_connector, component_id, text }); } + +export async function open_konata_file() { + return await invoke("open_konata_file"); +} diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8884690..421c6c9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -25,6 +25,7 @@ tauri-plugin-window-state = "=2.0.0-beta.9" tauri-plugin-dialog = "=2.0.0-beta.9" once_cell = "1.19.0" futures = "0.3.30" +reqwest = "0.12.9" # wasmtime = "22.0.0" # wasmtime-wasi = "22.0.0" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 90abb5b..5582dcf 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,6 +1,8 @@ use once_cell::sync::Lazy; use std::fs; +use std::process::Command; use std::sync::{Arc, RwLock as StdRwLock}; +use std::time::Duration; use tauri::{async_runtime::RwLock, AppHandle}; use tauri_plugin_dialog::DialogExt; use wasmtime::AsContextMut; @@ -179,6 +181,60 @@ async fn notify_diagram_connector_text_change( ) } +#[tauri::command(rename_all = "snake_case")] +async fn open_konata_file(app: tauri::AppHandle) { + let Some(file_response) = app.dialog().file().blocking_pick_file() else { + return; + }; + let file_path = file_response.path.into_os_string().into_string().unwrap(); + + spawn_konata_app(); + + let port = 30000; + let base_url = format!("http://localhost:{port}"); + let client = reqwest::Client::builder() + .timeout(Duration::from_secs(30)) + .build() + .unwrap(); + if client + .get(format!("{base_url}/status")) + .send() + .await + .is_ok() + { + client + .post(format!("{base_url}/open-konata-file")) + .json(&serde_json::json!({ + "file_path": file_path + })) + .send() + .await + .unwrap() + .error_for_status() + .unwrap(); + } else { + println!("Failed to get Konata server status"); + } +} + +#[cfg(target_family = "windows")] +fn spawn_konata_app() { + Command::new("cscript") + .current_dir("../../konata") + .arg("konata.vbs") + .spawn() + .unwrap(); +} + +#[cfg(target_family = "unix")] +fn spawn_konata_app() { + Command::new("sh") + .current_dir("../../konata") + .arg("konata.sh") + .spawn() + .unwrap(); +} + #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { // https://github.com/tauri-apps/tauri/issues/8462 @@ -202,6 +258,7 @@ pub fn run() { add_diagram_connectors, remove_all_diagram_connectors, notify_diagram_connector_text_change, + open_konata_file, ]) .setup(|app| { *APP_HANDLE.write().unwrap() = Some(app.handle().to_owned());