From 44fa046fc910ffea3a10679036f6aca9d863af88 Mon Sep 17 00:00:00 2001 From: Tim-Paik Date: Sat, 30 Jul 2022 23:15:33 +0800 Subject: [PATCH] Add support for creating projects, upgrade wry. Warning: Partially unavailable, Wayland support is broken --- Cargo.lock | 345 ++++++++++++++++++++++++--------- neutauri_bundler/Cargo.toml | 3 +- neutauri_bundler/src/bundle.rs | 19 +- neutauri_bundler/src/dev.rs | 15 +- neutauri_bundler/src/init.rs | 45 +++++ neutauri_bundler/src/main.rs | 21 ++ neutauri_data/Cargo.toml | 2 +- neutauri_runtime/Cargo.toml | 2 +- neutauri_runtime/src/main.rs | 1 + 9 files changed, 352 insertions(+), 101 deletions(-) create mode 100644 neutauri_bundler/src/init.rs diff --git a/Cargo.lock b/Cargo.lock index f68a3d7..8dbf103 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,9 +130,9 @@ checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "bytemuck" -version = "1.9.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" +checksum = "a5377c8865e74a160d21f29c2d40669f53286db6eab59b88540cbb12ffc8b835" [[package]] name = "byteorder" @@ -142,9 +142,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "f0b3de4a0c5e67e16066a0715723abd91edc2f9001d09c46e1dca929351e130e" [[package]] name = "cairo-rs" @@ -305,9 +305,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if", "crossbeam-utils", @@ -315,9 +315,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -326,9 +326,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" +checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" dependencies = [ "autocfg", "cfg-if", @@ -340,14 +340,39 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", "once_cell", ] +[[package]] +name = "crossterm" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486d44227f71a1ef39554c0dc47e44b9f4139927c75043312690c3f476d1d788" +dependencies = [ + "bitflags", + "crossterm_winapi", + "libc", + "mio", + "parking_lot 0.11.2", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a6966607622438301997d3dac0d2f6e9a90c68bb6bc1785ea98456ab93c0507" +dependencies = [ + "winapi", +] + [[package]] name = "cty" version = "0.2.2" @@ -434,9 +459,9 @@ dependencies = [ [[package]] name = "flume" -version = "0.10.13" +version = "0.10.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ceeb589a3157cac0ab8cc585feb749bd2cea5cb55a6ee802ad72d9fd38303da" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" dependencies = [ "futures-core", "futures-sink", @@ -843,9 +868,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.2" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28edd9d7bc256be2502e325ac0628bde30b7001b9b52e0abe31a1a9dc2701212" +checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964" dependencies = [ "bytemuck", "byteorder", @@ -853,7 +878,6 @@ dependencies = [ "exr", "gif", "jpeg-decoder", - "num-iter", "num-rational", "num-traits", "png", @@ -870,6 +894,21 @@ dependencies = [ "adler32", ] +[[package]] +name = "inquire" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2660dd0494633c5d60afe445e54fc5486a9a628d0ae58ee9e09cd42b6e976500" +dependencies = [ + "bitflags", + "crossterm", + "lazy_static", + "newline-converter", + "thiserror", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "instant" version = "0.1.12" @@ -953,9 +992,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.58" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" dependencies = [ "wasm-bindgen", ] @@ -1076,6 +1115,28 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + [[package]] name = "nanorand" version = "0.7.0" @@ -1119,6 +1180,7 @@ version = "0.1.0" dependencies = [ "anyhow", "gumdrop", + "inquire", "neutauri_data", "new_mime_guess", "rcedit", @@ -1160,6 +1222,21 @@ dependencies = [ "unicase", ] +[[package]] +name = "newline-converter" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f81c2b19eebbc4249b3ca6aff70ae05bf18d6a99b7cc63cf0248774e640565" + +[[package]] +name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1170,17 +1247,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.1" @@ -1252,9 +1318,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "pango" @@ -1289,7 +1355,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", ] [[package]] @@ -1306,6 +1382,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "paste" version = "1.0.7" @@ -1329,18 +1418,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" +checksum = "78203e83c48cffbe01e4a2d35d566ca4de445d79a85372fc64e378bfc812a260" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" +checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74" dependencies = [ "proc-macro2", "quote", @@ -1413,9 +1502,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" dependencies = [ "unicode-ident", ] @@ -1431,9 +1520,9 @@ dependencies = [ [[package]] name = "raw-window-handle" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" +checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a" dependencies = [ "cty", ] @@ -1482,9 +1571,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -1502,9 +1591,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.6" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -1513,9 +1602,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "rustc_version" @@ -1573,18 +1662,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.137" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" dependencies = [ "proc-macro2", "quote", @@ -1603,10 +1692,43 @@ dependencies = [ ] [[package]] -name = "slab" -version = "0.4.6" +name = "signal-hook" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" @@ -1644,9 +1766,9 @@ dependencies = [ [[package]] name = "spin" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530c2b0d0bf8b69304b39fe2001993e267461948b890cd037d8ad4293fa1a0d" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" dependencies = [ "lock_api", ] @@ -1690,9 +1812,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a71c32c2fa7bba46b01becf9cf470f6a781573af7e376c5e317a313ecce27545" +checksum = "e6b9e24ce8c3b52952209ad614fd978e2ca7bf49540a8d21a1d9069ee6999d21" dependencies = [ "bitflags", "cairo-rs", @@ -1723,7 +1845,7 @@ dependencies = [ "ndk-sys", "objc", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "paste", "png", "raw-window-handle", @@ -1767,9 +1889,9 @@ dependencies = [ [[package]] name = "tiff" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cfada0986f446a770eca461e8c6566cb879682f7d687c8348aa0c857bd52286" +checksum = "7259662e32d1e219321eb309d5f9d898b779769d81b76e762c07c8e5d38fcb65" dependencies = [ "flate2", "jpeg-decoder", @@ -1802,9 +1924,9 @@ dependencies = [ [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unicase" @@ -1823,9 +1945,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "unicode-normalization" @@ -1842,6 +1964,12 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + [[package]] name = "url" version = "2.2.2" @@ -1856,9 +1984,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "dd6469f4314d5f1ffec476e05f17cc9a78bc7a27a6a857842170bdf8d6f98d2f" dependencies = [ "getrandom", ] @@ -1900,9 +2028,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1910,13 +2038,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -1925,9 +2053,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1935,9 +2063,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", @@ -1948,9 +2076,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.81" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" [[package]] name = "webkit2gtk" @@ -2038,9 +2166,9 @@ dependencies = [ [[package]] name = "weezl" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c97e489d8f836838d497091de568cf16b117486d529ec5579233521065bd5e4" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "widestring" @@ -2086,11 +2214,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" dependencies = [ "windows-implement", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.37.0", + "windows_i686_gnu 0.37.0", + "windows_i686_msvc 0.37.0", + "windows_x86_64_gnu 0.37.0", + "windows_x86_64_msvc 0.37.0", ] [[package]] @@ -2119,36 +2247,79 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f33f2b90a6664e369c41ab5ff262d06f048fc9685d9bf8a0e99a47750bb0463" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + [[package]] name = "windows-tokens" version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3263d25f1170419995b78ff10c06b949e8a986c35c208dc24333c64753a87169" +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + [[package]] name = "windows_aarch64_msvc" version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + [[package]] name = "windows_i686_gnu" version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + [[package]] name = "windows_i686_msvc" version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + [[package]] name = "windows_x86_64_gnu" version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "windows_x86_64_msvc" version = "0.37.0" @@ -2166,9 +2337,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce19dddbd3ce01dc8f14eb6d4c8f914123bf8379aaa838f6da4f981ff7104a3f" +checksum = "8577a0d09cb80c5e0493694979a221d2328075b576238f1df1fff7e4e45934d8" dependencies = [ "block", "cocoa", diff --git a/neutauri_bundler/Cargo.toml b/neutauri_bundler/Cargo.toml index a9392f8..aed3255 100644 --- a/neutauri_bundler/Cargo.toml +++ b/neutauri_bundler/Cargo.toml @@ -6,11 +6,12 @@ version = "0.1.0" [dependencies] anyhow = "1.0" gumdrop = "0.8" +inquire = "0.2" neutauri_data = {path = "../neutauri_data", features = ["bundler"]} new_mime_guess = "4.0" serde = {version = "1.0", features = ["derive"]} toml = "0.5" -wry = {version = "0.19", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen", "devtools"]} +wry = {version = "0.20", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen", "devtools"]} [target.'cfg(windows)'.dependencies] rcedit = {git = "https://github.com/Tim-Paik/rcedit-rs.git", rev = "2805fca"} diff --git a/neutauri_bundler/src/bundle.rs b/neutauri_bundler/src/bundle.rs index 4922e8f..c9bf281 100644 --- a/neutauri_bundler/src/bundle.rs +++ b/neutauri_bundler/src/bundle.rs @@ -1,4 +1,3 @@ -#[cfg(windows)] use anyhow::Context; use neutauri_data as data; #[cfg(windows)] @@ -6,10 +5,7 @@ use std::{ env, hash::{Hash, Hasher}, }; -use std::{ - fs, - io::{self, Write}, -}; +use std::{fs, io::Write}; fn options() -> fs::OpenOptions { #[cfg(not(windows))] @@ -61,10 +57,17 @@ fn get_runtime_data( Ok(runtime_data) } -pub fn bundle(config_path: String) -> anyhow::Result<()> { - let config_path = std::path::Path::new(&config_path).canonicalize()?; +pub(crate) fn bundle(config_path: String) -> anyhow::Result<()> { + let config_path = std::path::Path::new(&config_path) + .canonicalize() + .with_context(|| { + format!( + "Error reading config file from {}\n\n{}", + &config_path, "You may want to create a neutauri.toml via the init subcommand?" + ) + })?; let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str()) - .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + .with_context(|| "toml parsing error")?; let source = match config_path.parent() { Some(path) => path.join(&config.source).canonicalize()?, None => config.source.canonicalize()?, diff --git a/neutauri_bundler/src/dev.rs b/neutauri_bundler/src/dev.rs index 53eeef6..a07d2cf 100644 --- a/neutauri_bundler/src/dev.rs +++ b/neutauri_bundler/src/dev.rs @@ -1,3 +1,4 @@ +use anyhow::{Context, Result}; use neutauri_data as data; use std::{fs, io::Read, path::PathBuf}; use wry::{ @@ -29,10 +30,17 @@ fn custom_protocol_uri_to_path>(protocol: T, uri: T) -> wry::Res } } -pub fn dev(config_path: String) -> wry::Result<()> { - let config_path = std::path::Path::new(&config_path).canonicalize()?; +pub(crate) fn dev(config_path: String) -> Result<()> { + let config_path = std::path::Path::new(&config_path) + .canonicalize() + .with_context(|| { + format!( + "Error reading config file from {}\n\n{}", + &config_path, "You may want to create a neutauri.toml via the init subcommand?" + ) + })?; let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str()) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; + .with_context(|| "toml parsing error")?; let source = config.source.canonicalize()?; let event_loop = EventLoop::new(); @@ -140,6 +148,7 @@ pub fn dev(config_path: String) -> wry::Result<()> { WebContext::new(None) }; let webview = webview_builder + .with_clipboard(true) .with_visible(config.window_attr()?.visible) .with_transparent(config.window_attr()?.transparent) .with_web_context(&mut web_context) diff --git a/neutauri_bundler/src/init.rs b/neutauri_bundler/src/init.rs new file mode 100644 index 0000000..4087621 --- /dev/null +++ b/neutauri_bundler/src/init.rs @@ -0,0 +1,45 @@ +use anyhow::Ok; +use neutauri_data as data; + +const TEMPLATE: &str = include_str!("../../neutauri.toml.example"); + +pub(crate) fn init() -> anyhow::Result<()> { + let config = TEMPLATE; + let config = config.replace( + "Neutauri Demo", + &inquire::Text::new("The name of your program? (for window title)") + .with_placeholder("Neutauri App") + .with_default("Neutauri App") + .prompt()?, + ); + let config = config.replace( + "web_src", + &inquire::Text::new("Where is your web source code? (relative to the current directory)") + .with_placeholder("web_src") + .with_default("web_src") + .prompt()?, + ); + let config = config.replace( + "neutauri_demo", + &inquire::Text::new("The name of your output target?") + .with_placeholder("app") + .with_default("app") + .prompt()?, + ); + let config = config.replacen( + "Small", + inquire::Select::new( + "The default size of the window?", + vec!["Small", "Medium", "Large"], + ) + .prompt()?, + 1, + ); + let config_path = data::normalize_path(std::path::Path::new("./neutauri.toml")); + std::fs::write(&config_path, config)?; + eprintln!( + "The configuration file has been written to \"{}\"", + config_path.display() + ); + Ok(()) +} diff --git a/neutauri_bundler/src/main.rs b/neutauri_bundler/src/main.rs index a322d2f..67b1d15 100644 --- a/neutauri_bundler/src/main.rs +++ b/neutauri_bundler/src/main.rs @@ -1,6 +1,7 @@ use gumdrop::Options; mod bundle; mod dev; +mod init; #[derive(Debug, Options)] struct Args { @@ -19,6 +20,8 @@ enum Command { Bundle(BundleOpts), #[options(help = "run the project in the current directory in development mode")] Dev(DevOpts), + #[options(help = "initialize a neutauri project")] + Init(InitOpts), } #[derive(Debug, Clone, Options)] @@ -37,6 +40,12 @@ struct DevOpts { config: Option, } +#[derive(Debug, Clone, Options)] +struct InitOpts { + #[options(help = "print help information")] + help: bool, +} + fn print_help_and_exit(args: Args) { if args.command.is_some() { Args::parse_args_default_or_exit(); @@ -67,6 +76,8 @@ fn main() -> anyhow::Result<()> { Some(command) => match command { Command::Bundle(opts) => { if opts.help_requested() { + eprintln!("Package according to the configuration in neutauri.toml"); + eprintln!(); print_help_and_exit(args); } let config_path = opts.config.unwrap_or_else(|| "neutauri.toml".to_string()); @@ -74,11 +85,21 @@ fn main() -> anyhow::Result<()> { } Command::Dev(opts) => { if opts.help_requested() { + eprintln!("Check the configuration in neutauri.toml and start directly"); + eprintln!(); print_help_and_exit(args); } let config_path = opts.config.unwrap_or_else(|| "neutauri.toml".to_string()); dev::dev(config_path)?; } + Command::Init(opts) => { + if opts.help_requested() { + eprintln!("Interactively create a neutauri.toml configuration file"); + eprintln!(); + print_help_and_exit(args); + } + init::init()?; + } }, None => print_help_and_exit(args), } diff --git a/neutauri_data/Cargo.toml b/neutauri_data/Cargo.toml index b28120b..df9328e 100644 --- a/neutauri_data/Cargo.toml +++ b/neutauri_data/Cargo.toml @@ -10,7 +10,7 @@ image = {version = "0.24", optional = true} new_mime_guess = {version = "4.0", optional = true} serde = {version = "1.0", features = ["derive"]} toml = {version = "0.5", optional = true} -wry = {version = "0.19", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]} +wry = {version = "0.20", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]} [features] bundler = ["new_mime_guess", "toml", "image"] diff --git a/neutauri_runtime/Cargo.toml b/neutauri_runtime/Cargo.toml index a9b9990..45a0756 100644 --- a/neutauri_runtime/Cargo.toml +++ b/neutauri_runtime/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] neutauri_data = {path = "../neutauri_data", features = ["runtime"]} -wry = {version = "0.19", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]} +wry = {version = "0.20", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]} [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/neutauri_runtime/src/main.rs b/neutauri_runtime/src/main.rs index c0db23a..4bb23c3 100644 --- a/neutauri_runtime/src/main.rs +++ b/neutauri_runtime/src/main.rs @@ -141,6 +141,7 @@ fn main() -> wry::Result<()> { WebContext::new(None) }; let webview = webview_builder + .with_clipboard(true) .with_visible(res.window_attr.visible) .with_transparent(res.window_attr.transparent) .with_web_context(&mut web_context)