-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move the LiveSocket
and LiveChannel
api into one central object.
#289
Merged
mobile-bungalow
merged 57 commits into
liveview-native:main
from
mobile-bungalow:centralize_core
Feb 5, 2025
Merged
Changes from 23 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
68646b1
checkpoint
mobile-bungalow f0912a3
more stubs
mobile-bungalow fd8f856
filling in connection stubs
mobile-bungalow 5c3b320
remove swiftpm cruft
mobile-bungalow 9f863d3
Merge branch 'main' of https://github.com/liveview-native/liveview-na…
mobile-bungalow de2ccaa
fill in all stubs
mobile-bungalow bc65287
reorganize
mobile-bungalow 86eb33a
and now on to testing
mobile-bungalow 3315b2a
check
mobile-bungalow 1f0a740
clippy
mobile-bungalow 8d4d372
lints
mobile-bungalow c9fe5a8
wasm build fix
mobile-bungalow efbcee4
fmt needs nightly now.
mobile-bungalow 0406c0c
nightly fmt
mobile-bungalow 36323e3
failing swift tests
mobile-bungalow 3898005
get the cookies from static memory
mobile-bungalow 9156946
feature flag socket errors
mobile-bungalow a964ea7
move constructor to callbacks
mobile-bungalow e8a812a
missing modules
mobile-bungalow 5fedf85
move more callbacks into callbacks module
mobile-bungalow 682979f
reexports
mobile-bungalow 514c322
move dom parser into dom module
mobile-bungalow 7064cb5
first passing tests
mobile-bungalow 46f9fde
use swiftui everywhere
mobile-bungalow 07be329
use swiftui everywhere
mobile-bungalow a62e5c9
advanced navigation
mobile-bungalow 13f3f24
uploads
mobile-bungalow 9225032
ready for further testing
mobile-bungalow b88afab
playback test
mobile-bungalow 368fca3
merge resolve
mobile-bungalow 9e6409b
add swift unit tests
mobile-bungalow fe71f17
update interfaces
mobile-bungalow 1ac8d92
less agressive dead render printing, oslogs
mobile-bungalow 2e90044
complex platform conditionals for testing
mobile-bungalow 4638b7b
give navigatio interface more parameter control
mobile-bungalow 6f72b1d
clippy, expose more places to add headers, event inspection
mobile-bungalow c462eba
move connection opts onto each nav call
mobile-bungalow 6414ac2
clippy, typos
mobile-bungalow e3d1e6a
upload single file
mobile-bungalow 92f6a30
first draft handle live reload
mobile-bungalow 81b3ce7
lints
mobile-bungalow 7e93033
Merge branch 'main' into centralize_core
mobile-bungalow d806ca2
added socket status
mobile-bungalow f6cedb6
added socket status
mobile-bungalow 62bb16a
swift support
mobile-bungalow e8eee72
Merge branch 'centralize_core' of github.com:mobile-bungalow/liveview…
mobile-bungalow f1c86b6
Merge branch 'main' into centralize_core
mobile-bungalow 30b1a06
Merge branch 'centralize_core' of github.com:mobile-bungalow/liveview…
mobile-bungalow 6a90426
wasm
mobile-bungalow f64be71
kotlin
mobile-bungalow 101fa2a
payload
mobile-bungalow a80419a
tweaks for production
mobile-bungalow ad03783
add all event handlers and testing for patche and redirects
mobile-bungalow d822732
typos
mobile-bungalow a8cd206
clean up
mobile-bungalow 2ec8157
aggressive persistence
mobile-bungalow 8eea5cb
version diagnostics and no panic
mobile-bungalow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]>", | ||
|
@@ -23,7 +23,7 @@ edition = "2021" | |
publish = false | ||
|
||
[workspace.dependencies] | ||
uniffi = "0.28.0" | ||
uniffi = "0.28.3" | ||
|
||
[profile.dev] | ||
split-debuginfo = "unpacked" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::dom::{NodeData, NodeRef}; | ||
|
||
/// Provides secure persistent storage for session data like cookies. | ||
/// Implementations should handle platform-specific storage (e.g. NSUserDefaults on iOS) | ||
/// and ensure data is stored securely as some of it may be session tokens. | ||
#[uniffi::export(callback_interface)] | ||
pub trait SecurePersistentStore: Send + Sync { | ||
/// Removes the entry for the given key | ||
fn remove_entry(&self, key: String); | ||
|
||
/// Gets the value for the given key, or None if not found | ||
fn get(&self, key: String) -> Option<Vec<u8>>; | ||
|
||
/// Sets the value for the given key | ||
fn set(&self, key: String, value: Vec<u8>); | ||
} | ||
|
||
#[uniffi::export(callback_interface)] | ||
pub trait NavEventHandler: Send + Sync { | ||
/// This callback instruments events that occur when your user navigates to a | ||
/// new view. You can add serialized metadata to these events as a byte buffer | ||
/// through the [NavOptions] object. | ||
fn handle_event(&self, event: NavEvent) -> HandlerResponse; | ||
} | ||
|
||
/// Unique id in the history stack | ||
pub type HistoryId = u64; | ||
|
||
/// User emitted response from [NavEventHandler::handle_event]. | ||
/// Determines whether or not the default navigation action is taken. | ||
#[derive(uniffi::Enum, Clone, Debug, PartialEq, Default)] | ||
pub enum HandlerResponse { | ||
#[default] | ||
/// Return this to proceed as normal. | ||
Default, | ||
/// Return this to cancel the navigation before it occurs. | ||
PreventDefault, | ||
} | ||
|
||
#[derive(uniffi::Enum, Clone, Debug, PartialEq)] | ||
pub enum NavEventType { | ||
/// Pushing a new event onto the history stack | ||
Push, | ||
/// Replacing the most recent event on the history stack | ||
Replace, | ||
/// Reloading the view in place | ||
Reload, | ||
/// Skipping multiple items on the history stack, leaving them in tact. | ||
Traverse, | ||
} | ||
|
||
#[derive(uniffi::Record, Clone, Debug, PartialEq)] | ||
pub struct NavHistoryEntry { | ||
/// The target url. | ||
pub url: String, | ||
/// Unique id for this piece of nav entry state. | ||
pub id: HistoryId, | ||
/// state passed in by the user, to be passed in to the navigation event callback. | ||
pub state: Option<Vec<u8>>, | ||
} | ||
|
||
impl NavHistoryEntry { | ||
/// Create a new navigation history entry | ||
pub fn new(url: String, id: HistoryId, state: Option<Vec<u8>>) -> Self { | ||
Self { url, id, state } | ||
} | ||
} | ||
|
||
/// An event emitted when the user navigates between views. | ||
#[derive(uniffi::Record, Clone, Debug, PartialEq)] | ||
pub struct NavEvent { | ||
/// The type of event being emitted. | ||
pub event: NavEventType, | ||
/// True if from and to point to the same path. | ||
pub same_document: bool, | ||
/// The previous location of the page, if there was one. | ||
pub from: Option<NavHistoryEntry>, | ||
/// Destination URL. | ||
pub to: NavHistoryEntry, | ||
/// Additional user provided metadata handed to the event handler. | ||
pub info: Option<Vec<u8>>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, Eq, PartialEq, uniffi::Enum)] | ||
pub enum LiveChannelStatus { | ||
/// [Channel] is waiting for the [Socket](crate::Socket) to | ||
/// [Socket::connect](crate::Socket::connect) or automatically reconnect. | ||
WaitingForSocketToConnect, | ||
/// [Socket::status](crate::Socket::status) is | ||
/// [SocketStatus::Connected](crate::SocketStatus::Connected) and [Channel] is waiting for | ||
/// [Channel::join] to be called. | ||
WaitingToJoin, | ||
/// [Channel::join] was called and awaiting response from server. | ||
Joining, | ||
/// [Channel::join] was called previously, but the [Socket](crate::Socket) was disconnected and | ||
/// reconnected. | ||
WaitingToRejoin, | ||
/// [Channel::join] was called and the server responded that the [Channel::topic] was joined | ||
/// using [Channel::payload]. | ||
Joined, | ||
/// [Channel::leave] was called and awaiting response from server. | ||
Leaving, | ||
/// [Channel::leave] was called and the server responded that the [Channel::topic] was left. | ||
Left, | ||
/// [Channel::shutdown] was called, but the async task hasn't exited yet. | ||
ShuttingDown, | ||
/// The async task has exited. | ||
ShutDown, | ||
} | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone, uniffi::Enum)] | ||
pub enum ChangeType { | ||
Change = 0, | ||
Add = 1, | ||
Remove = 2, | ||
Replace = 3, | ||
} | ||
|
||
#[derive(Copy, Clone, uniffi::Enum)] | ||
pub enum EventType { | ||
Changed, // { change: ChangeType }, | ||
} | ||
|
||
#[derive(Clone, uniffi::Enum)] | ||
pub enum ControlFlow { | ||
ExitOk, | ||
ExitErr(String), | ||
ContinueListening, | ||
} | ||
|
||
/// Implements the change handling logic for inbound virtual dom | ||
/// changes. Your logic for handling document patches should go here. | ||
#[uniffi::export(callback_interface)] | ||
pub trait DocumentChangeHandler: Send + Sync { | ||
/// This callback should implement your dom manipulation logic | ||
/// after receiving patches from LVN. | ||
fn handle_document_change( | ||
&self, | ||
change_type: ChangeType, | ||
node_ref: Arc<NodeRef>, | ||
node_data: NodeData, | ||
parent: Option<Arc<NodeRef>>, | ||
); | ||
|
||
/// Called when the channel status changes. Background operations like [LiveChannel::merge_diffs] | ||
/// will exit with a status based on the return [ControlFlow] of this callback. | ||
/// TODO: this should be deprecated after core takes responsibility for channel clean up | ||
fn handle_channel_status(&self, channel_status: LiveChannelStatus) -> ControlFlow; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a optional dependency that's enabled with the
liveview-channels
feature.