@browsersync/bslive 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/package.json +22 -17
  2. package/Cargo.toml +0 -34
  3. package/bslive/Cargo.toml +0 -35
  4. package/bslive/build.rs +0 -5
  5. package/bslive/src/lib.rs +0 -135
  6. package/bsnext/Cargo.toml +0 -21
  7. package/bsnext/src/main.rs +0 -116
  8. package/crates/bsnext_client/Cargo.toml +0 -8
  9. package/crates/bsnext_client/build.rs +0 -53
  10. package/crates/bsnext_client/generated/dto.ts +0 -147
  11. package/crates/bsnext_client/generated/schema.ts +0 -237
  12. package/crates/bsnext_client/inject/dist/index.js +0 -6540
  13. package/crates/bsnext_client/inject/package.json +0 -12
  14. package/crates/bsnext_client/inject/src/console.ts +0 -25
  15. package/crates/bsnext_client/inject/src/index.ts +0 -73
  16. package/crates/bsnext_client/package-lock.json +0 -2145
  17. package/crates/bsnext_client/package.json +0 -27
  18. package/crates/bsnext_client/src/lib.rs +0 -11
  19. package/crates/bsnext_client/tsconfig.json +0 -22
  20. package/crates/bsnext_client/ui/dist/index.css +0 -78
  21. package/crates/bsnext_client/ui/dist/index.js +0 -997
  22. package/crates/bsnext_client/ui/index.html +0 -18
  23. package/crates/bsnext_client/ui/input.yml +0 -19
  24. package/crates/bsnext_client/ui/package.json +0 -18
  25. package/crates/bsnext_client/ui/src/components/bs-debug.ts +0 -27
  26. package/crates/bsnext_client/ui/src/components/bs-header.ts +0 -33
  27. package/crates/bsnext_client/ui/src/components/bs-icon.ts +0 -101
  28. package/crates/bsnext_client/ui/src/components/bs-server-detail.ts +0 -21
  29. package/crates/bsnext_client/ui/src/components/bs-server-identity.ts +0 -24
  30. package/crates/bsnext_client/ui/src/components/bs-server-list.ts +0 -39
  31. package/crates/bsnext_client/ui/src/index.ts +0 -39
  32. package/crates/bsnext_client/ui/styles/base.css.ts +0 -17
  33. package/crates/bsnext_client/ui/styles/reset.css +0 -52
  34. package/crates/bsnext_client/ui/styles/style.css +0 -29
  35. package/crates/bsnext_client/ui/svg/wordmark-white.svg +0 -38
  36. package/crates/bsnext_core/Cargo.toml +0 -44
  37. package/crates/bsnext_core/src/common_layers.rs +0 -62
  38. package/crates/bsnext_core/src/dir_loader.rs +0 -230
  39. package/crates/bsnext_core/src/dto.rs +0 -341
  40. package/crates/bsnext_core/src/handlers/mod.rs +0 -1
  41. package/crates/bsnext_core/src/handlers/proxy.rs +0 -95
  42. package/crates/bsnext_core/src/lib.rs +0 -12
  43. package/crates/bsnext_core/src/meta/mod.rs +0 -5
  44. package/crates/bsnext_core/src/not_found/mod.rs +0 -1
  45. package/crates/bsnext_core/src/not_found/not_found_service.rs +0 -35
  46. package/crates/bsnext_core/src/panic_handler.rs +0 -32
  47. package/crates/bsnext_core/src/raw_loader.rs +0 -196
  48. package/crates/bsnext_core/src/server/actor.rs +0 -92
  49. package/crates/bsnext_core/src/server/error.rs +0 -41
  50. package/crates/bsnext_core/src/server/handler_change.rs +0 -85
  51. package/crates/bsnext_core/src/server/handler_listen.rs +0 -163
  52. package/crates/bsnext_core/src/server/handler_patch.rs +0 -42
  53. package/crates/bsnext_core/src/server/handler_routes_updated.rs +0 -27
  54. package/crates/bsnext_core/src/server/handler_stop.rs +0 -38
  55. package/crates/bsnext_core/src/server/mod.rs +0 -10
  56. package/crates/bsnext_core/src/server/router/assets.rs +0 -39
  57. package/crates/bsnext_core/src/server/router/mod.rs +0 -123
  58. package/crates/bsnext_core/src/server/router/pub_api.rs +0 -39
  59. package/crates/bsnext_core/src/server/router/snapshots/bsnext_core__server__router__tests__test__handlers.snap +0 -9
  60. package/crates/bsnext_core/src/server/router/tests.rs +0 -209
  61. package/crates/bsnext_core/src/server/signals.rs +0 -11
  62. package/crates/bsnext_core/src/server/state.rs +0 -23
  63. package/crates/bsnext_core/src/servers_supervisor/actor.rs +0 -199
  64. package/crates/bsnext_core/src/servers_supervisor/file_changed_handler.rs +0 -41
  65. package/crates/bsnext_core/src/servers_supervisor/get_servers_handler.rs +0 -24
  66. package/crates/bsnext_core/src/servers_supervisor/input_changed_handler.rs +0 -21
  67. package/crates/bsnext_core/src/servers_supervisor/mod.rs +0 -6
  68. package/crates/bsnext_core/src/servers_supervisor/start_handler.rs +0 -86
  69. package/crates/bsnext_core/src/servers_supervisor/stop_handler.rs +0 -26
  70. package/crates/bsnext_core/src/ws/mod.rs +0 -164
  71. package/crates/bsnext_example/Cargo.toml +0 -10
  72. package/crates/bsnext_example/src/basic.rs +0 -51
  73. package/crates/bsnext_example/src/lib.rs +0 -26
  74. package/crates/bsnext_example/src/lit.rs +0 -37
  75. package/crates/bsnext_example/src/md.rs +0 -18
  76. package/crates/bsnext_fs/Cargo.toml +0 -22
  77. package/crates/bsnext_fs/src/actor.rs +0 -123
  78. package/crates/bsnext_fs/src/buffered_debounce.rs +0 -166
  79. package/crates/bsnext_fs/src/filter.rs +0 -39
  80. package/crates/bsnext_fs/src/inner_fs_event_handler.rs +0 -94
  81. package/crates/bsnext_fs/src/lib.rs +0 -141
  82. package/crates/bsnext_fs/src/remove_path_handler.rs +0 -46
  83. package/crates/bsnext_fs/src/stop_handler.rs +0 -15
  84. package/crates/bsnext_fs/src/stream.rs +0 -167
  85. package/crates/bsnext_fs/src/test/mod.rs +0 -213
  86. package/crates/bsnext_fs/src/watch_path_handler.rs +0 -67
  87. package/crates/bsnext_fs/src/watcher.rs +0 -349
  88. package/crates/bsnext_input/Cargo.toml +0 -25
  89. package/crates/bsnext_input/src/input_test/mod.rs +0 -185
  90. package/crates/bsnext_input/src/input_test/snapshots/bsnext_input__input_test__deserialize_3_headers.snap +0 -29
  91. package/crates/bsnext_input/src/input_test/snapshots/bsnext_input__input_test__deserialize_3_headers_control.snap +0 -25
  92. package/crates/bsnext_input/src/lib.rs +0 -153
  93. package/crates/bsnext_input/src/md.rs +0 -541
  94. package/crates/bsnext_input/src/paths.rs +0 -64
  95. package/crates/bsnext_input/src/route.rs +0 -189
  96. package/crates/bsnext_input/src/route_manifest.rs +0 -186
  97. package/crates/bsnext_input/src/server_config.rs +0 -88
  98. package/crates/bsnext_input/src/target.rs +0 -7
  99. package/crates/bsnext_input/src/watch_opt_test/mod.rs +0 -68
  100. package/crates/bsnext_input/src/yml.rs +0 -1
  101. package/crates/bsnext_output/Cargo.toml +0 -16
  102. package/crates/bsnext_output/src/json.rs +0 -11
  103. package/crates/bsnext_output/src/lib.rs +0 -25
  104. package/crates/bsnext_output/src/pretty.rs +0 -147
  105. package/crates/bsnext_resp/Cargo.toml +0 -13
  106. package/crates/bsnext_resp/src/js/snippet.html +0 -1
  107. package/crates/bsnext_resp/src/js/ws.js +0 -1
  108. package/crates/bsnext_resp/src/lib.rs +0 -79
  109. package/crates/bsnext_system/Cargo.toml +0 -29
  110. package/crates/bsnext_system/src/args.rs +0 -46
  111. package/crates/bsnext_system/src/lib.rs +0 -227
  112. package/crates/bsnext_system/src/monitor.rs +0 -241
  113. package/crates/bsnext_system/src/monitor_any_watchables.rs +0 -133
  114. package/crates/bsnext_system/src/start_kind/snapshots/bsnext_system__start_kind__start_from_paths__test__test-2.snap +0 -12
  115. package/crates/bsnext_system/src/start_kind/snapshots/bsnext_system__start_kind__start_from_paths__test__test.snap +0 -30
  116. package/crates/bsnext_system/src/start_kind/start_from_example.rs +0 -49
  117. package/crates/bsnext_system/src/start_kind/start_from_inputs.rs +0 -67
  118. package/crates/bsnext_system/src/start_kind/start_from_paths.rs +0 -51
  119. package/crates/bsnext_system/src/start_kind.rs +0 -56
  120. package/crates/bsnext_system/src/startup.rs +0 -51
  121. package/crates/bsnext_tracing/Cargo.toml +0 -10
  122. package/crates/bsnext_tracing/src/lib.rs +0 -127
  123. package/examples/basic/input.yml +0 -5
  124. package/examples/basic/public/index.html +0 -15
  125. package/examples/basic/public/reset.css +0 -52
  126. package/examples/basic/public/script.js +0 -1
  127. package/examples/basic/public/styles.css +0 -3
  128. package/examples/kitchen-sink/a-file.md +0 -1
  129. package/examples/kitchen-sink/api/1.json +0 -1
  130. package/examples/kitchen-sink/api/2.json +0 -3
  131. package/examples/kitchen-sink/app.js +0 -1
  132. package/examples/kitchen-sink/input.html +0 -185
  133. package/examples/kitchen-sink/input.yml +0 -133
  134. package/examples/kitchen-sink/styles-2.css +0 -3
  135. package/examples/lit/index.html +0 -21
  136. package/examples/lit/input.yml +0 -5
  137. package/examples/lit/lit.js +0 -82
  138. package/examples/lit/package-lock.json +0 -62
  139. package/examples/lit/package.json +0 -15
  140. package/examples/md-single/frontmatter.md +0 -35
  141. package/examples/md-single/md-single.md +0 -35
  142. package/examples/openai/.nvm +0 -1
  143. package/examples/openai/build.mjs +0 -21
  144. package/examples/openai/index.html +0 -13
  145. package/examples/openai/input.yml +0 -59
  146. package/examples/openai/package-lock.json +0 -720
  147. package/examples/openai/package.json +0 -21
  148. package/examples/openai/src/index.js +0 -21
  149. package/examples/openai/sse/01.txt +0 -8
  150. package/examples/proxy-simple/input.yml +0 -9
  151. package/examples/single/input.yaml +0 -26
  152. package/input.yml +0 -8
  153. package/run.sh +0 -6
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@browsersync/bslive",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "bin": {
7
7
  "bslive": "./bin.js"
8
8
  },
9
+ "files": [
10
+ "index.js",
11
+ "index.d.ts",
12
+ "bin.js"
13
+ ],
9
14
  "napi": {
10
15
  "name": "bslive",
11
16
  "triples": {
@@ -47,21 +52,21 @@
47
52
  "version": "napi version"
48
53
  },
49
54
  "optionalDependencies": {
50
- "@browsersync/bslive-win32-x64-msvc": "0.0.14",
51
- "@browsersync/bslive-darwin-x64": "0.0.14",
52
- "@browsersync/bslive-linux-x64-gnu": "0.0.14",
53
- "@browsersync/bslive-darwin-arm64": "0.0.14",
54
- "@browsersync/bslive-android-arm64": "0.0.14",
55
- "@browsersync/bslive-linux-arm64-gnu": "0.0.14",
56
- "@browsersync/bslive-linux-arm64-musl": "0.0.14",
57
- "@browsersync/bslive-win32-arm64-msvc": "0.0.14",
58
- "@browsersync/bslive-linux-arm-gnueabihf": "0.0.14",
59
- "@browsersync/bslive-linux-arm-musleabihf": "0.0.14",
60
- "@browsersync/bslive-linux-x64-musl": "0.0.14",
61
- "@browsersync/bslive-freebsd-x64": "0.0.14",
62
- "@browsersync/bslive-win32-ia32-msvc": "0.0.14",
63
- "@browsersync/bslive-android-arm-eabi": "0.0.14",
64
- "@browsersync/bslive-darwin-universal": "0.0.14",
65
- "@browsersync/bslive-linux-riscv64-gnu": "0.0.14"
55
+ "@browsersync/bslive-win32-x64-msvc": "0.0.15",
56
+ "@browsersync/bslive-darwin-x64": "0.0.15",
57
+ "@browsersync/bslive-linux-x64-gnu": "0.0.15",
58
+ "@browsersync/bslive-darwin-arm64": "0.0.15",
59
+ "@browsersync/bslive-android-arm64": "0.0.15",
60
+ "@browsersync/bslive-linux-arm64-gnu": "0.0.15",
61
+ "@browsersync/bslive-linux-arm64-musl": "0.0.15",
62
+ "@browsersync/bslive-win32-arm64-msvc": "0.0.15",
63
+ "@browsersync/bslive-linux-arm-gnueabihf": "0.0.15",
64
+ "@browsersync/bslive-linux-arm-musleabihf": "0.0.15",
65
+ "@browsersync/bslive-linux-x64-musl": "0.0.15",
66
+ "@browsersync/bslive-freebsd-x64": "0.0.15",
67
+ "@browsersync/bslive-win32-ia32-msvc": "0.0.15",
68
+ "@browsersync/bslive-android-arm-eabi": "0.0.15",
69
+ "@browsersync/bslive-darwin-universal": "0.0.15",
70
+ "@browsersync/bslive-linux-riscv64-gnu": "0.0.15"
66
71
  }
67
72
  }
package/Cargo.toml DELETED
@@ -1,34 +0,0 @@
1
- workspace.members = [
2
- "bslive",
3
- "bsnext",
4
- "crates/*"
5
- ]
6
- workspace.resolver = "2"
7
-
8
- [workspace.dependencies]
9
- clap = { version = "4.5.3", features = ["derive"] }
10
- axum = { version = "0.7.4", features = ["ws"] }
11
- tokio = { version = "1", features = ["full"] }
12
- tokio-stream = { version = "0.1.15", features = ["sync"] }
13
- futures = "0.3.30"
14
- futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
15
- tower = { version = "0.4.13" }
16
- tower-http = { version = "0.5.0", features = ['trace', 'fs', 'compression-full', 'decompression-full', 'catch-panic', 'cors', 'timeout', 'set-header'] }
17
- tracing = "0.1.40"
18
- tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
19
- actix = "0.13.1"
20
- actix-rt = "2.9.0"
21
- anyhow = "1.0.69"
22
- serde = { version = "1.0.152", features = ["derive"] }
23
- serde_yaml = "0.9.33"
24
- serde_json = "1.0.115"
25
- thiserror = "1.0.58"
26
- bytes = "1.6.0"
27
- http = "1.1.0"
28
- http-body-util = "0.1.1"
29
- typeshare = "1"
30
- random_word = { version = "0.4.3", features = ["en"] }
31
- toml = { version = "0.8.12" }
32
- mime_guess = "2.0.4"
33
- tempfile = "3.10.1"
34
- insta = { version = "1.38.0", features = ["yaml"] }
package/bslive/Cargo.toml DELETED
@@ -1,35 +0,0 @@
1
- [package]
2
- edition = "2021"
3
- name = "bslive"
4
- version = "0.0.0"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
-
9
- [dependencies]
10
- bsnext_core = { path = "../crates/bsnext_core" }
11
- bsnext_input = { path = "../crates/bsnext_input" }
12
- bsnext_fs = { path = "../crates/bsnext_fs" }
13
- bsnext_tracing = { path = "../crates/bsnext_tracing" }
14
- bsnext_system = { path = "../crates/bsnext_system" }
15
- bsnext_output = { path = "../crates/bsnext_output" }
16
-
17
- clap = { workspace = true }
18
- tokio = { workspace = true }
19
- tracing = { workspace = true }
20
- actix = { workspace = true }
21
- actix-rt = { workspace = true }
22
- anyhow = { workspace = true }
23
- serde = { workspace = true }
24
- serde_json = { workspace = true }
25
-
26
- # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
27
- napi = { version = "2.12.2", default-features = false, features = ["napi4", "tokio_rt", "tokio_full"] }
28
- napi-derive = "2.12.2"
29
-
30
- [build-dependencies]
31
- napi-build = "2.0.1"
32
-
33
- [profile.release]
34
- lto = true
35
- strip = "symbols"
package/bslive/build.rs DELETED
@@ -1,5 +0,0 @@
1
- extern crate napi_build;
2
-
3
- fn main() {
4
- napi_build::setup();
5
- }
package/bslive/src/lib.rs DELETED
@@ -1,135 +0,0 @@
1
- #![deny(clippy::all)]
2
-
3
- #[macro_use]
4
- extern crate napi_derive;
5
-
6
- use actix::Actor;
7
- use std::env::current_dir;
8
- use std::io::Write;
9
- use std::path::PathBuf;
10
- use std::time::Duration;
11
-
12
- use clap::Parser;
13
-
14
- use bsnext_core::dto::ExternalEvents;
15
- use bsnext_output::{OutputWriter, Writers};
16
- use bsnext_system::args::Args;
17
- use bsnext_system::start_kind::StartKind;
18
- use bsnext_system::startup::{DidStart, StartupResult};
19
- use bsnext_system::{BsSystem, Start};
20
- use bsnext_tracing::{init_tracing, OutputFormat, WriteOption};
21
- use tokio::sync::{mpsc, oneshot};
22
- use tokio::time::sleep;
23
-
24
- #[napi]
25
- async fn start(_args: Vec<String>) -> napi::bindgen_prelude::Result<i32> {
26
- eprintln!("async not supported yet");
27
- sleep(Duration::from_secs(2)).await;
28
- Ok(32)
29
- }
30
-
31
- /// Launch in a blocking way
32
- #[napi]
33
- fn start_sync(args: Vec<String>) -> napi::bindgen_prelude::Result<i32> {
34
- let sys = actix_rt::System::new();
35
- println!("sync args {:?}", args);
36
- std::env::set_var("RUST_LIB_BACKTRACE", "0");
37
- let result = sys.block_on(async move {
38
- match main_sync(args).await {
39
- Ok(_) => 0,
40
- Err(e) => {
41
- eprintln!("{:?}", e);
42
- 1
43
- }
44
- }
45
- });
46
- Ok(result)
47
- }
48
-
49
- async fn main_sync(args: Vec<String>) -> Result<(), anyhow::Error> {
50
- let cwd = PathBuf::from(current_dir().unwrap().to_string_lossy().to_string());
51
- let args = Args::parse_from(&args);
52
- let format_clone = args.format;
53
-
54
- let write_opt = if args.write_log {
55
- WriteOption::File
56
- } else {
57
- WriteOption::None
58
- };
59
- init_tracing(args.log_level, args.format, write_opt);
60
- tracing::debug!("{:#?}", args);
61
-
62
- let (tx, rx) = oneshot::channel();
63
- let (startup_oneshot_sender, startup_oneshot_receiver) = oneshot::channel::<StartupResult>();
64
- let (events_sender, mut events_receiver) = mpsc::channel::<ExternalEvents>(1);
65
-
66
- let system = BsSystem::new();
67
- let sys_addr = system.start();
68
-
69
- let start_kind = StartKind::from_args(args);
70
-
71
- let start = Start {
72
- kind: start_kind,
73
- cwd: Some(cwd),
74
- ack: tx,
75
- events_sender,
76
- startup_oneshot_sender,
77
- };
78
-
79
- sys_addr.do_send(start);
80
-
81
- match startup_oneshot_receiver.await {
82
- Ok(Ok(DidStart::Started)) => tracing::info!("started..."),
83
- Ok(Err(e)) => return Err(e.into()),
84
- Err(e) => return Err(e.into()),
85
- };
86
-
87
- let events_handler = tokio::spawn(async move {
88
- let events = vec![];
89
- let stdout = &mut std::io::stdout();
90
- let printer = match format_clone {
91
- None | Some(OutputFormat::Normal) => Writers::Pretty,
92
- Some(OutputFormat::Json) => Writers::Json,
93
- };
94
- while let Some(evt) = events_receiver.recv().await {
95
- match printer.handle_event(stdout, &evt) {
96
- Ok(_v) => {}
97
- Err(e) => tracing::error!("could not write to stdout {e}"),
98
- }
99
- match stdout.flush() {
100
- Ok(_) => {}
101
- Err(e) => tracing::error!("could not flush {e}"),
102
- };
103
- }
104
- events
105
- });
106
-
107
- match rx.await {
108
- Ok(_) => {
109
- tracing::info!("servers ended");
110
- }
111
- Err(e) => {
112
- // dropped? this is ok
113
- tracing::trace!(?e, "");
114
- }
115
- };
116
-
117
- match events_handler.await {
118
- Ok(v) => {
119
- tracing::info!(?v, "events seen");
120
- let errors = v
121
- .iter()
122
- .filter(|e| matches!(e, ExternalEvents::StartupFailed(..)))
123
- .collect::<Vec<_>>();
124
- if !errors.is_empty() {
125
- tracing::info!("stopped for the following reasons");
126
- for msg in errors {
127
- tracing::error!(?msg);
128
- }
129
- return Err(anyhow::anyhow!("exited..."));
130
- }
131
- }
132
- Err(e) => tracing::error!(?e),
133
- }
134
- Ok(())
135
- }
package/bsnext/Cargo.toml DELETED
@@ -1,21 +0,0 @@
1
- [package]
2
- name = "bsnext"
3
- version = "0.1.0"
4
- edition = "2021"
5
-
6
- [dependencies]
7
- bsnext_core = { path = "../crates/bsnext_core" }
8
- bsnext_input = { path = "../crates/bsnext_input" }
9
- bsnext_fs = { path = "../crates/bsnext_fs" }
10
- bsnext_tracing = { path = "../crates/bsnext_tracing" }
11
- bsnext_system = { path = "../crates/bsnext_system" }
12
- bsnext_output = { path = "../crates/bsnext_output" }
13
-
14
- clap = { workspace = true }
15
- tokio = { workspace = true }
16
- tracing = { workspace = true }
17
- actix = { workspace = true }
18
- actix-rt = { workspace = true }
19
- anyhow = { workspace = true }
20
- serde = { workspace = true }
21
- serde_json = { workspace = true }
@@ -1,116 +0,0 @@
1
- use actix::Actor;
2
- use std::env::current_dir;
3
- use std::io::Write;
4
- use std::path::PathBuf;
5
-
6
- use bsnext_core::dto::ExternalEvents;
7
- use bsnext_output::{OutputWriter, Writers};
8
- use bsnext_system::args::Args;
9
- use bsnext_system::start_kind::StartKind;
10
- use bsnext_system::startup::{DidStart, StartupResult};
11
- use bsnext_system::{BsSystem, Start};
12
- use bsnext_tracing::{init_tracing, OutputFormat, WriteOption};
13
- use clap::Parser;
14
- use tokio::sync::{mpsc, oneshot};
15
-
16
- #[actix_rt::main]
17
- async fn main() -> Result<(), anyhow::Error> {
18
- std::env::set_var("RUST_LIB_BACKTRACE", "0");
19
- let cwd = PathBuf::from(current_dir().unwrap().to_string_lossy().to_string());
20
- let args = Args::parse();
21
- let format_clone = args.format;
22
- let write_opt = if args.write_log {
23
- WriteOption::File
24
- } else {
25
- WriteOption::None
26
- };
27
-
28
- init_tracing(args.log_level, args.format, write_opt);
29
- tracing::debug!("{:#?}", args);
30
-
31
- let (tx, rx) = oneshot::channel();
32
- let (startup_oneshot_sender, startup_oneshot_receiver) = oneshot::channel::<StartupResult>();
33
- let (events_sender, mut events_receiver) = mpsc::channel::<ExternalEvents>(1);
34
-
35
- let system = BsSystem::new();
36
- let sys_addr = system.start();
37
-
38
- let start_kind = StartKind::from_args(args);
39
-
40
- let start = Start {
41
- kind: start_kind,
42
- cwd: Some(cwd),
43
- ack: tx,
44
- events_sender,
45
- startup_oneshot_sender,
46
- };
47
-
48
- sys_addr.do_send(start);
49
-
50
- match startup_oneshot_receiver.await? {
51
- Ok(DidStart::Started) => tracing::info!("started..."),
52
- Err(e) => return Err(e.into()),
53
- };
54
-
55
- let events_handler = tokio::spawn(async move {
56
- let events = vec![];
57
- let stdout = &mut std::io::stdout();
58
- let printer = match format_clone {
59
- None | Some(OutputFormat::Normal) => Writers::Pretty,
60
- Some(OutputFormat::Json) => Writers::Json,
61
- };
62
- while let Some(evt) = events_receiver.recv().await {
63
- tracing::debug!(external_event=?evt);
64
- match printer.handle_event(stdout, &evt) {
65
- Ok(_v) => {}
66
- Err(e) => tracing::error!("could not write to stdout {e}"),
67
- }
68
- match stdout.flush() {
69
- Ok(_) => {}
70
- Err(e) => tracing::error!("could not flush {e}"),
71
- };
72
- // let as_evt = ExternalEvent {
73
- // level: EventLevel::External,
74
- // fields: evt,
75
- // };
76
- // let json = serde_json::to_string_pretty(&as_evt).unwrap();
77
- // println!("{json}");
78
- // match handle_event(stdout, &evt) {
79
- // Ok(_) => {
80
- // events.push(evt);
81
- // }
82
- // Err(e) => tracing::error!("could not write to stdout {e}"),
83
- // }
84
- }
85
- events
86
- });
87
-
88
- match rx.await {
89
- Ok(_) => {
90
- tracing::info!("servers ended");
91
- }
92
- Err(e) => {
93
- // dropped? this is ok
94
- tracing::trace!(?e, "");
95
- }
96
- };
97
-
98
- match events_handler.await {
99
- Ok(v) => {
100
- tracing::info!(?v, "events seen");
101
- let errors = v
102
- .iter()
103
- .filter(|e| matches!(e, ExternalEvents::StartupFailed(..)))
104
- .collect::<Vec<_>>();
105
- if !errors.is_empty() {
106
- tracing::info!("stopped for the following reasons");
107
- for msg in errors {
108
- tracing::error!(?msg);
109
- }
110
- return Err(anyhow::anyhow!("exited..."));
111
- }
112
- }
113
- Err(e) => tracing::error!(?e),
114
- }
115
- Ok(())
116
- }
@@ -1,8 +0,0 @@
1
- [package]
2
- name = "bsnext_client"
3
- version = "0.1.0"
4
- edition = "2021"
5
-
6
- # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
-
8
- [dependencies]
@@ -1,53 +0,0 @@
1
- use std::env::current_dir;
2
- use std::io::Write;
3
- use std::process::Command;
4
- use std::{env, io};
5
-
6
- fn main() {
7
- if env::var("CI").is_ok() {
8
- return;
9
- }
10
- let curr = current_dir().expect("current dir");
11
- let root = curr
12
- .parent()
13
- .expect("parent")
14
- .parent()
15
- .expect("parent 2")
16
- .to_path_buf();
17
- let output = Command::new("typeshare")
18
- .args([
19
- "crates/bsnext_core",
20
- "--lang=typescript",
21
- "--output-file=crates/bsnext_client/generated/dto.ts",
22
- ])
23
- .current_dir(&root)
24
- .output()
25
- .expect("build types");
26
-
27
- io::stdout().write_all(&output.stdout).unwrap();
28
- io::stderr().write_all(&output.stderr).unwrap();
29
-
30
- assert!(output.status.success());
31
-
32
- let output = Command::new("npm")
33
- .args(["run", "schema"])
34
- .current_dir(root.join("crates").join("bsnext_client"))
35
- .output()
36
- .expect("build schema");
37
-
38
- io::stdout().write_all(&output.stdout).unwrap();
39
- io::stderr().write_all(&output.stderr).unwrap();
40
-
41
- assert!(output.status.success());
42
-
43
- let output = Command::new("npm")
44
- .args(["run", "build"])
45
- .current_dir(root.join("crates").join("bsnext_client"))
46
- .output()
47
- .expect("sh command failed to start");
48
-
49
- io::stdout().write_all(&output.stdout).unwrap();
50
- io::stderr().write_all(&output.stderr).unwrap();
51
-
52
- assert!(output.status.success());
53
- }
@@ -1,147 +0,0 @@
1
- /*
2
- Generated by typeshare 1.9.2
3
- */
4
-
5
- export type RouteKindDTO =
6
- | { kind: "Html", payload: {
7
- html: string;
8
- }}
9
- | { kind: "Json", payload: {
10
- json_str: string;
11
- }}
12
- | { kind: "Raw", payload: {
13
- raw: string;
14
- }}
15
- | { kind: "Sse", payload: {
16
- sse: string;
17
- }}
18
- | { kind: "Proxy", payload: {
19
- proxy: string;
20
- }}
21
- | { kind: "Dir", payload: {
22
- dir: string;
23
- }};
24
-
25
- export interface RouteDTO {
26
- path: string;
27
- kind: RouteKindDTO;
28
- }
29
-
30
- export interface ServerDesc {
31
- routes: RouteDTO[];
32
- id: string;
33
- }
34
-
35
- export type IdentityDTO =
36
- | { kind: "Both", payload: {
37
- name: string;
38
- bind_address: string;
39
- }}
40
- | { kind: "Address", payload: {
41
- bind_address: string;
42
- }}
43
- | { kind: "Named", payload: {
44
- name: string;
45
- }};
46
-
47
- export interface ServerDTO {
48
- id: string;
49
- identity: IdentityDTO;
50
- socket_addr: string;
51
- }
52
-
53
- export interface GetServersMessageResponse {
54
- servers: ServerDTO[];
55
- }
56
-
57
- export type ServerChange =
58
- | { kind: "Stopped", payload: {
59
- bind_address: string;
60
- }}
61
- | { kind: "Started", payload?: undefined }
62
- | { kind: "Patched", payload?: undefined };
63
-
64
- export interface ServerChangeSetItem {
65
- identity: IdentityDTO;
66
- change: ServerChange;
67
- }
68
-
69
- export interface ServerChangeSet {
70
- items: ServerChangeSetItem[];
71
- }
72
-
73
- export interface ServersStarted {
74
- servers_resp: GetServersMessageResponse;
75
- changeset: ServerChangeSet;
76
- }
77
-
78
- export enum EventLevel {
79
- External = "BSLIVE_EXTERNAL",
80
- }
81
-
82
- export type ExternalEvents =
83
- | { kind: "ServersStarted", payload: ServersStarted }
84
- | { kind: "Watching", payload: Watching }
85
- | { kind: "WatchingStopped", payload: StoppedWatching }
86
- | { kind: "FileChanged", payload: FileChanged }
87
- | { kind: "FilesChanged", payload: FilesChangedDTO }
88
- | { kind: "InputFileChanged", payload: FileChanged }
89
- | { kind: "InputAccepted", payload: InputAccepted }
90
- | { kind: "StartupFailed", payload: InputErrorDTO };
91
-
92
- export interface ExternalEvent {
93
- level: EventLevel;
94
- fields: ExternalEvents;
95
- }
96
-
97
- export interface InputAccepted {
98
- path: string;
99
- }
100
-
101
- export interface FileChanged {
102
- path: string;
103
- }
104
-
105
- export interface FilesChangedDTO {
106
- paths: string[];
107
- }
108
-
109
- export interface DebounceDTO {
110
- kind: string;
111
- ms: string;
112
- }
113
-
114
- export interface Watching {
115
- paths: string[];
116
- debounce: DebounceDTO;
117
- }
118
-
119
- export interface StoppedWatching {
120
- paths: string[];
121
- }
122
-
123
- export type InputErrorDTO =
124
- | { kind: "MissingInputs", payload: string }
125
- | { kind: "InvalidInput", payload: string }
126
- | { kind: "NotFound", payload: string }
127
- | { kind: "InputWriteError", payload: string }
128
- | { kind: "PathError", payload: string }
129
- | { kind: "PortError", payload: string }
130
- | { kind: "DirError", payload: string };
131
-
132
- export type ClientEvent =
133
- | { kind: "Change", payload: ChangeDTO };
134
-
135
- export type ChangeDTO =
136
- | { kind: "Fs", payload: {
137
- path: string;
138
- change_kind: ChangeKind;
139
- }}
140
- | { kind: "FsMany", payload: ChangeDTO[] };
141
-
142
- export enum ChangeKind {
143
- Changed = "Changed",
144
- Added = "Added",
145
- Removed = "Removed",
146
- }
147
-