Skip to content

Commit

Permalink
Move the LiveSocket and LiveChannel api into one central object. (#…
Browse files Browse the repository at this point in the history
…289)

Prior to removing any of the old `LiveSocket` api - add an initial api managing the lifecycle of sockets and connections through out the application lifetime intended to replace the previous `LiveSocket` , this includes code for handling redirects and patches.
  • Loading branch information
mobile-bungalow authored Feb 5, 2025
1 parent 51c9cd7 commit 6abc4bf
Show file tree
Hide file tree
Showing 47 changed files with 4,349 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.CARGO_MAKE_TOOLCHAIN }}
toolchain: nightly
components: rustfmt

- name: Cargo fmt
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ Package.resolved
crates/wasm/phoenix_live_view
crates/wasm/liveview-native-core-wasm-*
crates/wasm/liveview-native-core-wasm-*.tgz

### When vendoring in as a swift package
.swiftpm
77 changes: 73 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/core", "crates/uniffi-bindgen", "crates/wasm"]

[workspace.package]
version = "0.4.0-rc-4"
version = "0.4.0"
rust-version = "1.64"
authors = [
"Paul Schoenfelder <[email protected]>",
Expand All @@ -23,7 +23,7 @@ edition = "2021"
publish = false

[workspace.dependencies]
uniffi = "0.28.0"
uniffi = "0.28.3"

[profile.dev]
split-debuginfo = "unpacked"
Expand Down
24 changes: 21 additions & 3 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ name = "liveview_native_core"

[features]
default = ["liveview-channels-tls"]
liveview-channels = ["phoenix_channels_client", "reqwest", "uniffi/tokio"]
liveview-channels = [
"phoenix_channels_client",
"reqwest",
"uniffi/tokio",
"cookie_store",
"reqwest_cookie_store",
"tokio",
]
liveview-channels-tls = [
"liveview-channels",
"reqwest/native-tls-vendored",
Expand All @@ -35,8 +42,15 @@ browser = [
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
#
[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"

[target.'cfg(target_vendor = "apple")'.dependencies]
oslog = "0.2.0"

[dependencies]
serde_urlencoded = "0.7.1"
cranelift-entity = { version = "0.116" }
fixedbitset = { version = "0.5" }
fxhash = { version = "0.2" }
Expand All @@ -54,7 +68,13 @@ log = "0.4"
reqwest = { version = "0.12.3", default-features = false, optional = true, features = [
"cookies",
] }

cookie_store = { version = "0.21.1", default-features = false, optional = true }
reqwest_cookie_store = { version = "0.8.0", default-features = false, optional = true }
env_logger = "0.11.1"
uniffi = { workspace = true }

tokio = { version = "1.43", features = ["full"], optional = true }
phoenix_channels_client = { git = "https://github.com/liveview-native/phoenix-channels-client.git", branch = "main", optional = true, default-features = false }
# This is for wasm support on phoenix-channels-client
#phoenix_channels_client = { git = "https://github.com/liveview-native/phoenix-channels-client.git", branch = "simlay/webassembly-support", optional = true, default-features = false }
Expand All @@ -67,8 +87,6 @@ paste = { version = "1.0" }
pretty_assertions = { version = "1.4.0" }
text-diff = { version = "0.4.0" }
uniffi = { workspace = true, features = ["bindgen-tests", "tokio"] }
tokio = { version = "1.43", features = ["full"] }
env_logger = "0.11.1"

# For image generation for tests
image = "0.25.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import org.junit.Assert.assertEquals
import org.junit.Test
import org.phoenixframework.liveviewnative.core.ChangeType
import org.phoenixframework.liveviewnative.core.ConnectOpts
import org.phoenixframework.liveviewnative.core.ControlFlow
import org.phoenixframework.liveviewnative.core.Document
import org.phoenixframework.liveviewnative.core.DocumentChangeHandler
import org.phoenixframework.liveviewnative.core.LiveChannelStatus
import org.phoenixframework.liveviewnative.core.LiveFile
import org.phoenixframework.liveviewnative.core.LiveSocket
import org.phoenixframework.liveviewnative.core.NavOptions
Expand Down Expand Up @@ -62,10 +60,6 @@ class SimpleChangeHandler : DocumentChangeHandler {
) {
println("${changeType}")
}

override fun `handleChannelStatus`(`channelStatus`: LiveChannelStatus): ControlFlow {
return ControlFlow.ContinueListening
}
}

class DocumentTest {
Expand Down
Loading

0 comments on commit 6abc4bf

Please sign in to comment.