mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
fix liveview
This commit is contained in:
parent
1f6195b2ec
commit
60616d0ba7
5 changed files with 22 additions and 9 deletions
|
@ -1 +1 @@
|
||||||
36839850333612604813
|
31613791829349842071
|
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,10 @@ import { SerializedEvent, serializeEvent } from "./serialize";
|
||||||
var JSChannel_: typeof BaseInterpreter;
|
var JSChannel_: typeof BaseInterpreter;
|
||||||
|
|
||||||
// @ts-ignore - this is coming from the host
|
// @ts-ignore - this is coming from the host
|
||||||
if (RawInterpreter) { JSChannel_ = RawInterpreter; }
|
if (RawInterpreter !== undefined && RawInterpreter !== null) {
|
||||||
|
// @ts-ignore - this is coming from the host
|
||||||
|
JSChannel_ = RawInterpreter;
|
||||||
|
};
|
||||||
|
|
||||||
export class NativeInterpreter extends JSChannel_ {
|
export class NativeInterpreter extends JSChannel_ {
|
||||||
intercept_link_redirects: boolean;
|
intercept_link_redirects: boolean;
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub use adapters::*;
|
||||||
mod element;
|
mod element;
|
||||||
pub mod pool;
|
pub mod pool;
|
||||||
mod query;
|
mod query;
|
||||||
|
use dioxus_interpreter_js::NATIVE_JS;
|
||||||
use futures_util::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
pub use pool::*;
|
pub use pool::*;
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -70,9 +71,17 @@ fn handle_edits_code() -> String {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}"#;
|
}"#;
|
||||||
let mut interpreter = SLEDGEHAMMER_JS
|
let mut interpreter = format!(
|
||||||
.replace("/*POST_EVENT_SERIALIZATION*/", serialize_file_uploads)
|
r#"
|
||||||
.replace("export", "");
|
// Bring the sledgehammer code
|
||||||
|
{SLEDGEHAMMER_JS}
|
||||||
|
|
||||||
|
// And then extend it with our native bindings
|
||||||
|
{NATIVE_JS}
|
||||||
|
"#
|
||||||
|
)
|
||||||
|
.replace("/*POST_EVENT_SERIALIZATION*/", serialize_file_uploads)
|
||||||
|
.replace("export", "");
|
||||||
while let Some(import_start) = interpreter.find("import") {
|
while let Some(import_start) = interpreter.find("import") {
|
||||||
let import_end = interpreter[import_start..]
|
let import_end = interpreter[import_start..]
|
||||||
.find(|c| c == ';' || c == '\n')
|
.find(|c| c == ';' || c == '\n')
|
||||||
|
|
|
@ -9,8 +9,9 @@ function main() {
|
||||||
|
|
||||||
class IPC {
|
class IPC {
|
||||||
constructor(root) {
|
constructor(root) {
|
||||||
window.interpreter = new JSChannel();
|
window.interpreter = new NativeInterpreter();
|
||||||
window.interpreter.initialize(root);
|
window.interpreter.initialize(root);
|
||||||
|
window.interpreter.ipc = this;
|
||||||
const ws = new WebSocket(WS_ADDR);
|
const ws = new WebSocket(WS_ADDR);
|
||||||
ws.binaryType = "arraybuffer";
|
ws.binaryType = "arraybuffer";
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ class IPC {
|
||||||
|
|
||||||
let decoder = new TextDecoder("utf-8");
|
let decoder = new TextDecoder("utf-8");
|
||||||
|
|
||||||
// Using decode method to get string output
|
// Using decode method to get string output
|
||||||
let str = decoder.decode(messageData);
|
let str = decoder.decode(messageData);
|
||||||
// Ignore pongs
|
// Ignore pongs
|
||||||
if (str != "__pong__") {
|
if (str != "__pong__") {
|
||||||
|
@ -64,4 +65,4 @@ class IPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
Loading…
Reference in a new issue