From 3326e6b2fa70073f03c9fe7747072dc83cca6f68 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Sat, 7 Dec 2024 22:40:07 -0800 Subject: [PATCH 1/8] bump wasm-bindgen and js-sys --- Cargo.lock | 66 ++++++++++++++++++++++++++---------------------------- Cargo.toml | 10 ++++----- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab6a0fca85..fb0955122e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7154,9 +7154,9 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ "once_cell", "wasm-bindgen", @@ -14885,9 +14885,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -14896,13 +14896,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.90", @@ -14911,9 +14910,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-cli-support" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ff44829c4a8cb55c9c1764609522cddf6a092dae2e34a4b0f48d863737c5ff1" +checksum = "533e5315f66ba7a1c0b9731b1f6606a6fb7fc6d800eff4d5e43d48567f137203" dependencies = [ "anyhow", "base64 0.22.1", @@ -14934,9 +14933,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-externref-xform" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e18f2b3830afd01899e1f3252bd310c52eb4e76aae8ee406de26ade3ce80618c" +checksum = "e71a35edea8d70380465025fcd6fb5376c9f2b5dacb2bc515bce5575e0ff0a2c" dependencies = [ "anyhow", "walrus", @@ -14945,9 +14944,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.47" +version = "0.4.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" +checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" dependencies = [ "cfg-if", "js-sys", @@ -14958,9 +14957,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -14968,9 +14967,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -14981,9 +14980,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-multi-value-xform" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688e1343d8220793ed018c6d516ab782708e7550152f36f089adde39f69eef5a" +checksum = "58d05670395e140f246c9fd6f59ca75da67030121e1679031089aa71309d0ee5" dependencies = [ "anyhow", "walrus", @@ -14992,19 +14991,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "wasm-bindgen-test" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d919bb60ebcecb9160afee6c71b43a58a4f0517a2de0054cd050d02cec08201" +checksum = "c61d44563646eb934577f2772656c7ad5e9c90fac78aa8013d776fcdaf24625d" dependencies = [ "js-sys", "minicov", - "once_cell", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", @@ -15013,9 +15011,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.47" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222ebde6ea87fbfa6bdd2e9f1fd8a91d60aee5db68792632176c4e16a74fc7d8" +checksum = "54171416ce73aa0b9c377b51cc3cb542becee1cd678204812e8392e5b0e4a031" dependencies = [ "proc-macro2", "quote", @@ -15024,9 +15022,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-threads-xform" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa429167b4fe4155e91343b31dba3e8fbd07bcc70bf26d44fed1b241f446acef" +checksum = "578e66a90d904cc4ff44f48e8ac3f606a42ecfda5cbe336e89b315127fe02952" dependencies = [ "anyhow", "walrus", @@ -15035,9 +15033,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-conventions" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8ba4fca3be5dd6bd3850b73c1e24c1fe05f5ae309c0a5ea9e0da8ba0c295" +checksum = "3523d0794bca5434b5e05d8cd7498ff7c6f2c86a4e5d790e35a3bd8e29c1351b" dependencies = [ "anyhow", "leb128", @@ -15048,9 +15046,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-interpreter" -version = "0.2.97" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170b4ec3be6a888c7fe3e221e18abc5981fc52e06215481e066a85fe25f0e6ad" +checksum = "0d94f86fcc9c75aac4823f9cbf156ff37e3e8f4ebc1ccff2785e045efd9aeee1" dependencies = [ "anyhow", "log", @@ -15159,9 +15157,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.74" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 5305a5c733..2f13f023cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -167,10 +167,12 @@ futures = "0.3.30" futures-channel = "0.3.21" futures-util = { version = "0.3", default-features = false } rustc-hash = "1.1.0" -wasm-bindgen = "0.2.95" -wasm-bindgen-cli-support = "0.2.95" -wasm-bindgen-shared = "0.2.95" +wasm-bindgen = "0.2.99" +wasm-bindgen-cli-support = "0.2.99" +wasm-bindgen-shared = "0.2.99" wasm-bindgen-futures = "0.4.42" +js-sys = "0.3.76" +web-sys = { version = "0.3.76", default-features = false } html_parser = "0.7.0" thiserror = "1.0.40" prettyplease = { version = "0.2.20", features = ["verbatim"] } @@ -217,8 +219,6 @@ rustversion = "1.0.17" rand = "0.8.5" longest-increasing-subsequence = "0.1.0" trybuild = "1.0" -js-sys = "0.3.56" -web-sys = { version = "0.3.56", default-features = false } dirs = "5.0.1" cargo-config2 = "0.1.26" criterion = { version = "0.5" } From b6434611296ed9d2cd4d8e22c3dd4248187b3ee6 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 9 Dec 2024 11:09:57 -0600 Subject: [PATCH 2/8] Fix hot reloading stylesheets with an existing query parameter and deduplicate random query param (#3315) --- packages/interpreter/src/js/hash.txt | 2 +- packages/interpreter/src/js/native.js | 2 +- packages/interpreter/src/ts/native.ts | 43 +++++++++++++++++++++------ packages/web/src/devtools.rs | 13 +++++++- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/packages/interpreter/src/js/hash.txt b/packages/interpreter/src/js/hash.txt index e103a97f2f..0702f4ee34 100644 --- a/packages/interpreter/src/js/hash.txt +++ b/packages/interpreter/src/js/hash.txt @@ -1 +1 @@ -[6449103750905854967, 3846442265490457921, 13069001215487072322, 8716623267269178440, 5336385715226370016, 14456089431355876478, 7422899642446454418, 5052021921702764563, 12925655762638175824, 5638004933879392817] \ No newline at end of file +[6449103750905854967, 3846442265490457921, 13069001215487072322, 8716623267269178440, 5336385715226370016, 14456089431355876478, 12156139214887111728, 5052021921702764563, 12925655762638175824, 5638004933879392817] \ No newline at end of file diff --git a/packages/interpreter/src/js/native.js b/packages/interpreter/src/js/native.js index 0564a33cf1..74eb600634 100644 --- a/packages/interpreter/src/js/native.js +++ b/packages/interpreter/src/js/native.js @@ -1 +1 @@ -function retrieveValues(event,target){let contents={values:{}},form=target.closest("form");if(form){if(event.type==="input"||event.type==="change"||event.type==="submit"||event.type==="reset"||event.type==="click")contents=retrieveFormValues(form)}return contents}function retrieveFormValues(form){const formData=new FormData(form),contents={};return formData.forEach((value,key)=>{if(contents[key])contents[key].push(value);else contents[key]=[value]}),{valid:form.checkValidity(),values:contents}}function retrieveSelectValue(target){let options=target.selectedOptions,values=[];for(let i=0;icontents={...contents,...obj};if(event instanceof WheelEvent)extend(serializeWheelEvent(event));if(event instanceof MouseEvent)extend(serializeMouseEvent(event));if(event instanceof KeyboardEvent)extend(serializeKeyboardEvent(event));if(event instanceof InputEvent)extend(serializeInputEvent(event,target));if(event instanceof PointerEvent)extend(serializePointerEvent(event));if(event instanceof AnimationEvent)extend(serializeAnimationEvent(event));if(event instanceof TransitionEvent)extend({property_name:event.propertyName,elapsed_time:event.elapsedTime,pseudo_element:event.pseudoElement});if(event instanceof CompositionEvent)extend({data:event.data});if(event instanceof DragEvent)extend(serializeDragEvent(event));if(event instanceof FocusEvent)extend({});if(event instanceof ClipboardEvent)extend({});if(event instanceof CustomEvent){const detail=event.detail;if(detail instanceof ResizeObserverEntry)extend(serializeResizeEventDetail(detail));else if(detail instanceof IntersectionObserverEntry)extend(serializeIntersectionEventDetail(detail))}if(typeof TouchEvent!=="undefined"&&event instanceof TouchEvent)extend(serializeTouchEvent(event));if(event.type==="submit"||event.type==="reset"||event.type==="click"||event.type==="change"||event.type==="input")extend(serializeInputEvent(event,target));if(event instanceof DragEvent);return contents}var toSerializableResizeObserverSize=function(size,is_inline_width){return[is_inline_width?size.inlineSize:size.blockSize,is_inline_width?size.blockSize:size.inlineSize]};function serializeResizeEventDetail(detail){let is_inline_width=!0;if(detail.target instanceof HTMLElement){if(window.getComputedStyle(detail.target).getPropertyValue("writing-mode")!=="horizontal-tb")is_inline_width=!1}return{border_box_size:detail.borderBoxSize!==void 0?toSerializableResizeObserverSize(detail.borderBoxSize[0],is_inline_width):detail.contentRect,content_box_size:detail.contentBoxSize!==void 0?toSerializableResizeObserverSize(detail.contentBoxSize[0],is_inline_width):detail.contentRect,content_rect:detail.contentRect}}function serializeIntersectionEventDetail(detail){return{bounding_client_rect:detail.boundingClientRect,intersection_ratio:detail.intersectionRatio,intersection_rect:detail.intersectionRect,is_intersecting:detail.isIntersecting,root_bounds:detail.rootBounds,time_ms:Math.floor(Date.now()+detail.time)}}var serializeInputEvent=function(event,target){let contents={};if(target instanceof HTMLElement){let values=retrieveValues(event,target);contents.values=values.values,contents.valid=values.valid}if(event.target instanceof HTMLInputElement){let target2=event.target,value=target2.value??target2.textContent??"";if(target2.type==="checkbox")value=target2.checked?"true":"false";else if(target2.type==="radio")value=target2.value;contents.value=value}if(event.target instanceof HTMLTextAreaElement)contents.value=event.target.value;if(event.target instanceof HTMLSelectElement)contents.value=retrieveSelectValue(event.target).join(",");if(contents.value===void 0)contents.value="";return contents},serializeWheelEvent=function(event){return{delta_x:event.deltaX,delta_y:event.deltaY,delta_z:event.deltaZ,delta_mode:event.deltaMode}},serializeTouchEvent=function(event){return{alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,shift_key:event.shiftKey,changed_touches:event.changedTouches,target_touches:event.targetTouches,touches:event.touches}},serializePointerEvent=function(event){return{alt_key:event.altKey,button:event.button,buttons:event.buttons,client_x:event.clientX,client_y:event.clientY,ctrl_key:event.ctrlKey,meta_key:event.metaKey,page_x:event.pageX,page_y:event.pageY,screen_x:event.screenX,screen_y:event.screenY,shift_key:event.shiftKey,pointer_id:event.pointerId,width:event.width,height:event.height,pressure:event.pressure,tangential_pressure:event.tangentialPressure,tilt_x:event.tiltX,tilt_y:event.tiltY,twist:event.twist,pointer_type:event.pointerType,is_primary:event.isPrimary}},serializeMouseEvent=function(event){return{alt_key:event.altKey,button:event.button,buttons:event.buttons,client_x:event.clientX,client_y:event.clientY,ctrl_key:event.ctrlKey,meta_key:event.metaKey,offset_x:event.offsetX,offset_y:event.offsetY,page_x:event.pageX,page_y:event.pageY,screen_x:event.screenX,screen_y:event.screenY,shift_key:event.shiftKey}},serializeKeyboardEvent=function(event){return{char_code:event.charCode,is_composing:event.isComposing,key:event.key,alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,key_code:event.keyCode,shift_key:event.shiftKey,location:event.location,repeat:event.repeat,which:event.which,code:event.code}},serializeAnimationEvent=function(event){return{animation_name:event.animationName,elapsed_time:event.elapsedTime,pseudo_element:event.pseudoElement}},serializeDragEvent=function(event){let files=void 0;if(event.dataTransfer&&event.dataTransfer.files&&event.dataTransfer.files.length>0)files={files:{placeholder:[]}};return{mouse:{alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,shift_key:event.shiftKey,...serializeMouseEvent(event)},files}};var handleVirtualdomEventSync=function(endpoint,contents){const xhr=new XMLHttpRequest;return xhr.open("POST",endpoint,!1),xhr.setRequestHeader("Content-Type","application/json"),xhr.setRequestHeader("dioxus-data",contents),xhr.send(contents),JSON.parse(xhr.responseText)},getTargetId=function(target){if(!(target instanceof Node))return null;let ourTarget=target,realId=null;while(realId==null){if(ourTarget===null)return null;if(ourTarget instanceof Element)realId=ourTarget.getAttribute("data-dioxus-id");ourTarget=ourTarget.parentNode}return parseInt(realId)},JSChannel_;if(RawInterpreter!==void 0&&RawInterpreter!==null)JSChannel_=RawInterpreter;class NativeInterpreter extends JSChannel_{intercept_link_redirects;ipc;editsPath;eventsPath;kickStylesheets;queuedBytes=[];liveview;constructor(editsPath,eventsPath){super();this.editsPath=editsPath,this.eventsPath=eventsPath,this.kickStylesheets=!1}initialize(root){this.intercept_link_redirects=!0,this.liveview=!1,window.addEventListener("dragover",function(e){if(e.target instanceof Element&&e.target.tagName!="INPUT")e.preventDefault()},!1),window.addEventListener("drop",function(e){if(!(e.target instanceof Element))return;e.preventDefault()},!1),window.addEventListener("click",(event)=>{const target=event.target;if(target instanceof HTMLInputElement&&target.getAttribute("type")==="file"){let target_id=getTargetId(target);if(target_id!==null){const message=this.serializeIpcMessage("file_dialog",{event:"change&input",accept:target.getAttribute("accept"),directory:target.getAttribute("webkitdirectory")==="true",multiple:target.hasAttribute("multiple"),target:target_id,bubbles:event.bubbles});this.ipc.postMessage(message),event.preventDefault()}}}),this.ipc=window.ipc;const handler=(event)=>this.handleEvent(event,event.type,!0);super.initialize(root,handler)}serializeIpcMessage(method,params={}){return JSON.stringify({method,params})}scrollTo(id,behavior){const node=this.nodes[id];if(node instanceof HTMLElement)node.scrollIntoView({behavior})}getScrollHeight(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollHeight}getScrollLeft(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollLeft}getScrollTop(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollTop}getScrollWidth(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollWidth}getClientRect(id){const node=this.nodes[id];if(node instanceof HTMLElement){const rect=node.getBoundingClientRect();return{type:"GetClientRect",origin:[rect.x,rect.y],size:[rect.width,rect.height]}}}setFocus(id,focus){const node=this.nodes[id];if(node instanceof HTMLElement)if(focus)node.focus();else node.blur()}handleWindowsDragDrop(){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent);let data=new DataTransfer;const file=new File(["content"],"file.txt",{type:"text/plain"});data.items.add(file);const dragDropEvent=new DragEvent("drop",{bubbles:!0,cancelable:!0,dataTransfer:data});window.dxDragLastElement.dispatchEvent(dragDropEvent),window.dxDragLastElement=null}}handleWindowsDragOver(xPos,yPos){const element=document.elementFromPoint(xPos,yPos);if(element!=window.dxDragLastElement){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent)}const dragOverEvent=new DragEvent("dragover",{bubbles:!0,cancelable:!0});element.dispatchEvent(dragOverEvent),window.dxDragLastElement=element}}handleWindowsDragLeave(){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent),window.dxDragLastElement=null}}loadChild(array){let node=this.stack[this.stack.length-1];for(let i=0;i0;end--)node=node.nextSibling}return node}appendChildren(id,many){const root=this.nodes[id],els=this.stack.splice(this.stack.length-many);for(let k=0;k{this.flushQueuedBytes(),this.waitForRequest(headless)})}waitForRequest(headless){fetch(new Request(this.editsPath)).then((response)=>response.arrayBuffer()).then((bytes)=>{this.rafEdits(headless,bytes)})}kickAllStylesheetsOnPage(){let stylesheets=document.querySelectorAll("link[rel=stylesheet]");for(let i=0;i{sheet.href=sheet.href+"?"+Math.random()})}}async readFiles(target,contents,bubbles,realId,name){let files=target.files,file_contents={};for(let i=0;i{if(contents[key])contents[key].push(value);else contents[key]=[value]}),{valid:form.checkValidity(),values:contents}}function retrieveSelectValue(target){let options=target.selectedOptions,values=[];for(let i=0;icontents={...contents,...obj};if(event instanceof WheelEvent)extend(serializeWheelEvent(event));if(event instanceof MouseEvent)extend(serializeMouseEvent(event));if(event instanceof KeyboardEvent)extend(serializeKeyboardEvent(event));if(event instanceof InputEvent)extend(serializeInputEvent(event,target));if(event instanceof PointerEvent)extend(serializePointerEvent(event));if(event instanceof AnimationEvent)extend(serializeAnimationEvent(event));if(event instanceof TransitionEvent)extend({property_name:event.propertyName,elapsed_time:event.elapsedTime,pseudo_element:event.pseudoElement});if(event instanceof CompositionEvent)extend({data:event.data});if(event instanceof DragEvent)extend(serializeDragEvent(event));if(event instanceof FocusEvent)extend({});if(event instanceof ClipboardEvent)extend({});if(event instanceof CustomEvent){const detail=event.detail;if(detail instanceof ResizeObserverEntry)extend(serializeResizeEventDetail(detail));else if(detail instanceof IntersectionObserverEntry)extend(serializeIntersectionEventDetail(detail))}if(typeof TouchEvent!=="undefined"&&event instanceof TouchEvent)extend(serializeTouchEvent(event));if(event.type==="submit"||event.type==="reset"||event.type==="click"||event.type==="change"||event.type==="input")extend(serializeInputEvent(event,target));if(event instanceof DragEvent);return contents}var toSerializableResizeObserverSize=function(size,is_inline_width){return[is_inline_width?size.inlineSize:size.blockSize,is_inline_width?size.blockSize:size.inlineSize]};function serializeResizeEventDetail(detail){let is_inline_width=!0;if(detail.target instanceof HTMLElement){if(window.getComputedStyle(detail.target).getPropertyValue("writing-mode")!=="horizontal-tb")is_inline_width=!1}return{border_box_size:detail.borderBoxSize!==void 0?toSerializableResizeObserverSize(detail.borderBoxSize[0],is_inline_width):detail.contentRect,content_box_size:detail.contentBoxSize!==void 0?toSerializableResizeObserverSize(detail.contentBoxSize[0],is_inline_width):detail.contentRect,content_rect:detail.contentRect}}function serializeIntersectionEventDetail(detail){return{bounding_client_rect:detail.boundingClientRect,intersection_ratio:detail.intersectionRatio,intersection_rect:detail.intersectionRect,is_intersecting:detail.isIntersecting,root_bounds:detail.rootBounds,time_ms:Math.floor(Date.now()+detail.time)}}var serializeInputEvent=function(event,target){let contents={};if(target instanceof HTMLElement){let values=retrieveValues(event,target);contents.values=values.values,contents.valid=values.valid}if(event.target instanceof HTMLInputElement){let target2=event.target,value=target2.value??target2.textContent??"";if(target2.type==="checkbox")value=target2.checked?"true":"false";else if(target2.type==="radio")value=target2.value;contents.value=value}if(event.target instanceof HTMLTextAreaElement)contents.value=event.target.value;if(event.target instanceof HTMLSelectElement)contents.value=retrieveSelectValue(event.target).join(",");if(contents.value===void 0)contents.value="";return contents},serializeWheelEvent=function(event){return{delta_x:event.deltaX,delta_y:event.deltaY,delta_z:event.deltaZ,delta_mode:event.deltaMode}},serializeTouchEvent=function(event){return{alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,shift_key:event.shiftKey,changed_touches:event.changedTouches,target_touches:event.targetTouches,touches:event.touches}},serializePointerEvent=function(event){return{alt_key:event.altKey,button:event.button,buttons:event.buttons,client_x:event.clientX,client_y:event.clientY,ctrl_key:event.ctrlKey,meta_key:event.metaKey,page_x:event.pageX,page_y:event.pageY,screen_x:event.screenX,screen_y:event.screenY,shift_key:event.shiftKey,pointer_id:event.pointerId,width:event.width,height:event.height,pressure:event.pressure,tangential_pressure:event.tangentialPressure,tilt_x:event.tiltX,tilt_y:event.tiltY,twist:event.twist,pointer_type:event.pointerType,is_primary:event.isPrimary}},serializeMouseEvent=function(event){return{alt_key:event.altKey,button:event.button,buttons:event.buttons,client_x:event.clientX,client_y:event.clientY,ctrl_key:event.ctrlKey,meta_key:event.metaKey,offset_x:event.offsetX,offset_y:event.offsetY,page_x:event.pageX,page_y:event.pageY,screen_x:event.screenX,screen_y:event.screenY,shift_key:event.shiftKey}},serializeKeyboardEvent=function(event){return{char_code:event.charCode,is_composing:event.isComposing,key:event.key,alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,key_code:event.keyCode,shift_key:event.shiftKey,location:event.location,repeat:event.repeat,which:event.which,code:event.code}},serializeAnimationEvent=function(event){return{animation_name:event.animationName,elapsed_time:event.elapsedTime,pseudo_element:event.pseudoElement}},serializeDragEvent=function(event){let files=void 0;if(event.dataTransfer&&event.dataTransfer.files&&event.dataTransfer.files.length>0)files={files:{placeholder:[]}};return{mouse:{alt_key:event.altKey,ctrl_key:event.ctrlKey,meta_key:event.metaKey,shift_key:event.shiftKey,...serializeMouseEvent(event)},files}};var handleVirtualdomEventSync=function(endpoint,contents){const xhr=new XMLHttpRequest;return xhr.open("POST",endpoint,!1),xhr.setRequestHeader("Content-Type","application/json"),xhr.setRequestHeader("dioxus-data",contents),xhr.send(contents),JSON.parse(xhr.responseText)},getTargetId=function(target){if(!(target instanceof Node))return null;let ourTarget=target,realId=null;while(realId==null){if(ourTarget===null)return null;if(ourTarget instanceof Element)realId=ourTarget.getAttribute("data-dioxus-id");ourTarget=ourTarget.parentNode}return parseInt(realId)},JSChannel_;if(RawInterpreter!==void 0&&RawInterpreter!==null)JSChannel_=RawInterpreter;class NativeInterpreter extends JSChannel_{intercept_link_redirects;ipc;editsPath;eventsPath;kickStylesheets;queuedBytes=[];liveview;constructor(editsPath,eventsPath){super();this.editsPath=editsPath,this.eventsPath=eventsPath,this.kickStylesheets=!1}initialize(root){this.intercept_link_redirects=!0,this.liveview=!1,window.addEventListener("dragover",function(e){if(e.target instanceof Element&&e.target.tagName!="INPUT")e.preventDefault()},!1),window.addEventListener("drop",function(e){if(!(e.target instanceof Element))return;e.preventDefault()},!1),window.addEventListener("click",(event)=>{const target=event.target;if(target instanceof HTMLInputElement&&target.getAttribute("type")==="file"){let target_id=getTargetId(target);if(target_id!==null){const message=this.serializeIpcMessage("file_dialog",{event:"change&input",accept:target.getAttribute("accept"),directory:target.getAttribute("webkitdirectory")==="true",multiple:target.hasAttribute("multiple"),target:target_id,bubbles:event.bubbles});this.ipc.postMessage(message),event.preventDefault()}}}),this.ipc=window.ipc;const handler=(event)=>this.handleEvent(event,event.type,!0);super.initialize(root,handler)}serializeIpcMessage(method,params={}){return JSON.stringify({method,params})}scrollTo(id,behavior){const node=this.nodes[id];if(node instanceof HTMLElement)node.scrollIntoView({behavior})}getScrollHeight(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollHeight}getScrollLeft(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollLeft}getScrollTop(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollTop}getScrollWidth(id){const node=this.nodes[id];if(node instanceof HTMLElement)return node.scrollWidth}getClientRect(id){const node=this.nodes[id];if(node instanceof HTMLElement){const rect=node.getBoundingClientRect();return{type:"GetClientRect",origin:[rect.x,rect.y],size:[rect.width,rect.height]}}}setFocus(id,focus){const node=this.nodes[id];if(node instanceof HTMLElement)if(focus)node.focus();else node.blur()}handleWindowsDragDrop(){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent);let data=new DataTransfer;const file=new File(["content"],"file.txt",{type:"text/plain"});data.items.add(file);const dragDropEvent=new DragEvent("drop",{bubbles:!0,cancelable:!0,dataTransfer:data});window.dxDragLastElement.dispatchEvent(dragDropEvent),window.dxDragLastElement=null}}handleWindowsDragOver(xPos,yPos){const element=document.elementFromPoint(xPos,yPos);if(element!=window.dxDragLastElement){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent)}const dragOverEvent=new DragEvent("dragover",{bubbles:!0,cancelable:!0});element.dispatchEvent(dragOverEvent),window.dxDragLastElement=element}}handleWindowsDragLeave(){if(window.dxDragLastElement){const dragLeaveEvent=new DragEvent("dragleave",{bubbles:!0,cancelable:!0});window.dxDragLastElement.dispatchEvent(dragLeaveEvent),window.dxDragLastElement=null}}loadChild(array){let node=this.stack[this.stack.length-1];for(let i=0;i0;end--)node=node.nextSibling}return node}appendChildren(id,many){const root=this.nodes[id],els=this.stack.splice(this.stack.length-many);for(let k=0;k{this.flushQueuedBytes(),this.waitForRequest(headless)})}waitForRequest(headless){fetch(new Request(this.editsPath)).then((response)=>response.arrayBuffer()).then((bytes)=>{this.rafEdits(headless,bytes)})}kickAllStylesheetsOnPage(){let stylesheets=document.querySelectorAll("link[rel=stylesheet]");for(let i=0;i { - sheet.href = sheet.href + "?" + Math.random(); - }); + // Split up the url and add a extra random query param to force the browser to reload he asset + const splitByQuery = sheet.href.split("?"); + let url = splitByQuery[0]; + let query = splitByQuery[1]; + if (!query) { + query = ""; + } + let queryParams = new URLSearchParams(query); + // Delete the existing dx_force_reload entry if it exists + queryParams.delete("dx_force_reload"); + // And add a new random dx_force_reload query param to force the browser to reload the asset + queryParams.append("dx_force_reload", Math.random().toString()); + sheet.href = `${url}?${queryParams}`; } } diff --git a/packages/web/src/devtools.rs b/packages/web/src/devtools.rs index 438f9cab40..9a56cb3fa8 100644 --- a/packages/web/src/devtools.rs +++ b/packages/web/src/devtools.rs @@ -233,7 +233,18 @@ pub(crate) fn invalidate_browser_asset_cache() { use wasm_bindgen::JsCast; let link: web_sys::Element = links.get(x).unwrap().unchecked_into(); if let Some(href) = link.get_attribute("href") { - _ = link.set_attribute("href", &format!("{}?{}", href, noise)); + let (url, query) = href.split_once('?').unwrap_or((&href, "")); + let mut query_params: Vec<&str> = query.split('&').collect(); + // Remove the old force reload param + query_params.retain(|param| !param.starts_with("dx_force_reload=")); + // Add the new force reload param + let force_reload = format!("dx_force_reload={noise}"); + query_params.push(&force_reload); + + // Rejoin the query + let query = query_params.join("&"); + + _ = link.set_attribute("href", &format!("{url}?{query}")); } } } From 38cb2759e842780cdcdcf957fce526ed49c5db97 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 9 Dec 2024 13:58:10 -0600 Subject: [PATCH 3/8] Fix enable_out_of_order_streaming doc example and manganis macro remote example (#3317) --- packages/fullstack/src/serve_config.rs | 2 +- packages/manganis/manganis-macro/src/lib.rs | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/fullstack/src/serve_config.rs b/packages/fullstack/src/serve_config.rs index ad392779f9..41dac595cb 100644 --- a/packages/fullstack/src/serve_config.rs +++ b/packages/fullstack/src/serve_config.rs @@ -163,7 +163,7 @@ impl ServeConfigBuilder { /// /// It is equivalent to calling `streaming_mode(StreamingMode::OutOfOrder)` /// - /// /// ```rust, no_run + /// ```rust, no_run /// # use dioxus::prelude::*; /// # fn app() -> Element { todo!() } /// dioxus::LaunchBuilder::new() diff --git a/packages/manganis/manganis-macro/src/lib.rs b/packages/manganis/manganis-macro/src/lib.rs index 078b137ca2..1bab628b22 100644 --- a/packages/manganis/manganis-macro/src/lib.rs +++ b/packages/manganis/manganis-macro/src/lib.rs @@ -19,11 +19,6 @@ use linker::generate_link_section; /// # use manganis::{asset, Asset}; /// const _: Asset = asset!("/assets/asset.txt"); /// ``` -/// Or you can use URLs to read the asset at build time from a remote location -/// ```rust -/// # use manganis::{asset, Asset}; -/// const _: Asset = asset!("/assets/image.png"); -/// ``` /// /// # Images /// From b20c8ac27763fd00600f47c0ed852cac111e7463 Mon Sep 17 00:00:00 2001 From: Miles Murgaw Date: Tue, 10 Dec 2024 19:24:39 -0500 Subject: [PATCH 4/8] Fix: Windows Manganis Asset Hot Reload (#3330) * fix: windows asset hot reload * revision: canonicalize err handling --- packages/cli/src/serve/handle.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs index 4021cb2c85..f5968f3ae2 100644 --- a/packages/cli/src/serve/handle.rs +++ b/packages/cli/src/serve/handle.rs @@ -1,6 +1,7 @@ use crate::{AppBundle, Platform, Result}; use anyhow::Context; use std::{ + fs, net::SocketAddr, path::{Path, PathBuf}, process::Stdio, @@ -187,8 +188,13 @@ impl AppHandle { } } + // Canonicalize the path as Windows may use long-form paths "\\\\?\\C:\\". + let changed_file = fs::canonicalize(changed_file) + .inspect_err(|e| tracing::debug!("Failed to canonicalize hotreloaded asset: {e}")) + .ok()?; + // The asset might've been renamed thanks to the manifest, let's attempt to reload that too - if let Some(resource) = self.app.app.assets.assets.get(changed_file).as_ref() { + if let Some(resource) = self.app.app.assets.assets.get(&changed_file).as_ref() { let res = std::fs::copy(changed_file, asset_dir.join(resource.bundled_path())); bundled_name = Some(PathBuf::from(resource.bundled_path())); if let Err(e) = res { From 6a10fd8d784be609b7723c558633ade4cf0a2d7b Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 10 Dec 2024 16:24:57 -0800 Subject: [PATCH 5/8] fix: drop target list to make docsrs build happy (#3329) --- packages/dioxus/Cargo.toml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/dioxus/Cargo.toml b/packages/dioxus/Cargo.toml index fb4497d049..ca667f0541 100644 --- a/packages/dioxus/Cargo.toml +++ b/packages/dioxus/Cargo.toml @@ -91,10 +91,3 @@ features = [ "liveview", "server" ] -targets = [ - "wasm32-unknown-unknown", - "aarch64-apple-darwin", - "x86_64-unknown-linux-gnu", - "x86_64-pc-windows-msvc", - "aarch64-linux-android", -] From ca70e8660d417daa665a502138b8213d368f957c Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 10 Dec 2024 16:46:30 -0800 Subject: [PATCH 6/8] feat: android asset hotreloading (#3332) --- packages/cli/src/serve/handle.rs | 21 ++++++++++++++++++++- packages/cli/src/serve/mod.rs | 2 +- packages/cli/src/serve/runner.rs | 4 ++-- packages/desktop/src/protocol.rs | 17 +++++++++++++---- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs index f5968f3ae2..dc348a3f55 100644 --- a/packages/cli/src/serve/handle.rs +++ b/packages/cli/src/serve/handle.rs @@ -164,7 +164,7 @@ impl AppHandle { /// This will return the bundled name of the asset such that we can send it to the clients letting /// them know what to reload. It's not super important that this is robust since most clients will /// kick all stylsheets without necessarily checking the name. - pub(crate) fn hotreload_bundled_asset(&self, changed_file: &PathBuf) -> Option { + pub(crate) async fn hotreload_bundled_asset(&self, changed_file: &PathBuf) -> Option { let mut bundled_name = None; // Use the build dir if there's no runtime asset dir as the override. For the case of ios apps, @@ -202,6 +202,25 @@ impl AppHandle { } } + // If the emulator is android, we need to copy the asset to the device with `adb push asset /data/local/tmp/dx/assets/filename.ext` + if self.app.build.build.platform() == Platform::Android { + if let Some(bundled_name) = bundled_name.as_ref() { + let target = format!("/data/local/tmp/dx/{}", bundled_name.display()); + tracing::debug!("Pushing asset to device: {target}"); + let res = tokio::process::Command::new("adb") + .arg("push") + .arg(changed_file) + .arg(target) + .output() + .await + .context("Failed to push asset to device"); + + if let Err(e) = res { + tracing::debug!("Failed to push asset to device: {e}"); + } + } + } + // Now we can return the bundled asset name to send to the hotreload engine bundled_name } diff --git a/packages/cli/src/serve/mod.rs b/packages/cli/src/serve/mod.rs index f8f05e64ab..4f76d19568 100644 --- a/packages/cli/src/serve/mod.rs +++ b/packages/cli/src/serve/mod.rs @@ -91,7 +91,7 @@ pub(crate) async fn serve_all(mut args: ServeArgs) -> Result<()> { // if change is hotreloadable, hotreload it // and then send that update to all connected clients - if let Some(hr) = runner.attempt_hot_reload(files) { + if let Some(hr) = runner.attempt_hot_reload(files).await { // Only send a hotreload message for templates and assets - otherwise we'll just get a full rebuild if hr.templates.is_empty() && hr.assets.is_empty() diff --git a/packages/cli/src/serve/runner.rs b/packages/cli/src/serve/runner.rs index 3e7a49c336..33d173f4f7 100644 --- a/packages/cli/src/serve/runner.rs +++ b/packages/cli/src/serve/runner.rs @@ -157,7 +157,7 @@ impl AppRunner { Ok(()) } - pub(crate) fn attempt_hot_reload( + pub(crate) async fn attempt_hot_reload( &mut self, modified_files: Vec, ) -> Option { @@ -183,7 +183,7 @@ impl AppRunner { // Otherwise, it might be an asset and we should look for it in all the running apps for runner in self.running.values() { - if let Some(bundled_name) = runner.hotreload_bundled_asset(&path) { + if let Some(bundled_name) = runner.hotreload_bundled_asset(&path).await { // todo(jon): don't hardcode this here let asset_relative = PathBuf::from("/assets/").join(bundled_name); assets.push(asset_relative); diff --git a/packages/desktop/src/protocol.rs b/packages/desktop/src/protocol.rs index 1ef240c573..56dd3642e5 100644 --- a/packages/desktop/src/protocol.rs +++ b/packages/desktop/src/protocol.rs @@ -275,6 +275,19 @@ fn get_mime_by_ext(trimmed: &Path) -> &'static str { #[cfg(target_os = "android")] pub(crate) fn to_java_load_asset(filepath: &str) -> Option> { + let normalized = filepath + .trim_start_matches("/assets/") + .trim_start_matches('/'); + + // in debug mode, the asset might be under `/data/local/tmp/dx/` - attempt to read it from there if it exists + #[cfg(debug_assertions)] + { + let path = std::path::PathBuf::from("/data/local/tmp/dx/").join(normalized); + if path.exists() { + return std::fs::read(path).ok(); + } + } + use std::{io::Read, ptr::NonNull}; let ctx = ndk_context::android_context(); @@ -301,10 +314,6 @@ pub(crate) fn to_java_load_asset(filepath: &str) -> Option> { NonNull::new(asset_manager).expect("Invalid asset manager"), ); - let normalized = filepath - .trim_start_matches("/assets/") - .trim_start_matches('/'); - let cstr = std::ffi::CString::new(normalized).unwrap(); let mut asset = asset_manager.open(&cstr)?; From d89ab3cfad59d8c66a3acb7ae2aae3e904f23a3a Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 10 Dec 2024 18:47:51 -0600 Subject: [PATCH 7/8] Always run toast eval inside the runtime (#3313) --- packages/web/src/devtools.rs | 24 ++++++++++++++++++++---- packages/web/src/lib.rs | 6 +++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/web/src/devtools.rs b/packages/web/src/devtools.rs index 9a56cb3fa8..2ea92b91d7 100644 --- a/packages/web/src/devtools.rs +++ b/packages/web/src/devtools.rs @@ -4,9 +4,11 @@ //! We also set up a little recursive timer that will attempt to reconnect if the connection is lost. use std::fmt::Display; +use std::rc::Rc; use std::time::Duration; -use dioxus_core::ScopeId; +use dioxus_core::prelude::RuntimeGuard; +use dioxus_core::{Runtime, ScopeId}; use dioxus_devtools::{DevserverMsg, HotReloadMsg}; use dioxus_document::eval; use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}; @@ -22,17 +24,22 @@ const POLL_INTERVAL_SCALE_FACTOR: i32 = 2; /// Amount of time that toats should be displayed. const TOAST_TIMEOUT: Duration = Duration::from_secs(5); -pub(crate) fn init() -> UnboundedReceiver { +pub(crate) fn init(runtime: Rc) -> UnboundedReceiver { // Create the tx/rx pair that we'll use for the top-level future in the dioxus loop let (tx, rx) = unbounded(); // Wire up the websocket to the devserver - make_ws(tx, POLL_INTERVAL_MIN, false); + make_ws(runtime, tx, POLL_INTERVAL_MIN, false); rx } -fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) { +fn make_ws( + runtime: Rc, + tx: UnboundedSender, + poll_interval: i32, + reload: bool, +) { // Get the location of the devserver, using the current location plus the /_dioxus path // The idea here being that the devserver is always located on the /_dioxus behind a proxy let location = web_sys::window().unwrap().location(); @@ -49,6 +56,7 @@ fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) // Set the onmessage handler to bounce messages off to the main dioxus loop let tx_ = tx.clone(); + let runtime_ = runtime.clone(); ws.set_onmessage(Some( Closure::::new(move |e: MessageEvent| { let Ok(text) = e.data().dyn_into::() else { @@ -72,6 +80,7 @@ fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) // The devserver is telling us that it started a full rebuild. This does not mean that it is ready. Ok(DevserverMsg::FullReloadStart) => show_toast( + runtime_.clone(), "Your app is being rebuilt.", "A non-hot-reloadable change occurred and we must rebuild.", ToastLevel::Info, @@ -80,6 +89,7 @@ fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) ), // The devserver is telling us that the full rebuild failed. Ok(DevserverMsg::FullReloadFailed) => show_toast( + runtime_.clone(), "Oops! The build failed.", "We tried to rebuild your app, but something went wrong.", ToastLevel::Error, @@ -90,6 +100,7 @@ fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) // The devserver is telling us to reload the whole page Ok(DevserverMsg::FullReloadCommand) => { show_toast( + runtime_.clone(), "Successfully rebuilt.", "Your app was rebuilt successfully and without error.", ToastLevel::Success, @@ -121,11 +132,13 @@ fn make_ws(tx: UnboundedSender, poll_interval: i32, reload: bool) // set timeout to reload the page in timeout_ms let tx = tx.clone(); + let runtime = runtime.clone(); web_sys::window() .unwrap() .set_timeout_with_callback_and_timeout_and_arguments_0( Closure::::new(move || { make_ws( + runtime.clone(), tx.clone(), POLL_INTERVAL_MAX.min(poll_interval * POLL_INTERVAL_SCALE_FACTOR), true, @@ -189,6 +202,7 @@ impl Display for ToastLevel { /// Displays a toast to the developer. fn show_toast( + runtime: Rc, header_text: &str, message: &str, level: ToastLevel, @@ -202,6 +216,8 @@ fn show_toast( false => "showDXToast", }; + // Create the guard before running eval which uses the global runtime context + let _guard = RuntimeGuard::new(runtime); ScopeId::ROOT.in_runtime(|| { eval(&format!( r#" diff --git a/packages/web/src/lib.rs b/packages/web/src/lib.rs index 11071d8910..b26bcd3e04 100644 --- a/packages/web/src/lib.rs +++ b/packages/web/src/lib.rs @@ -66,11 +66,11 @@ pub async fn run(mut virtual_dom: VirtualDom, web_config: Config) -> ! { #[cfg(feature = "document")] virtual_dom.in_runtime(document::init_document); - #[cfg(all(feature = "devtools", debug_assertions))] - let mut hotreload_rx = devtools::init(); - let runtime = virtual_dom.runtime(); + #[cfg(all(feature = "devtools", debug_assertions))] + let mut hotreload_rx = devtools::init(runtime.clone()); + let should_hydrate = web_config.hydrate; let mut websys_dom = WebsysDom::new(web_config, runtime); From e598cfe31cd2d00787346a03a65ad3d6fdabf094 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 10 Dec 2024 17:08:45 -0800 Subject: [PATCH 8/8] Fix merge conflict causing CLI lifetime to be wrong --- packages/cli/src/serve/handle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/serve/handle.rs b/packages/cli/src/serve/handle.rs index dc348a3f55..1a722d639f 100644 --- a/packages/cli/src/serve/handle.rs +++ b/packages/cli/src/serve/handle.rs @@ -195,7 +195,7 @@ impl AppHandle { // The asset might've been renamed thanks to the manifest, let's attempt to reload that too if let Some(resource) = self.app.app.assets.assets.get(&changed_file).as_ref() { - let res = std::fs::copy(changed_file, asset_dir.join(resource.bundled_path())); + let res = std::fs::copy(&changed_file, asset_dir.join(resource.bundled_path())); bundled_name = Some(PathBuf::from(resource.bundled_path())); if let Err(e) = res { tracing::debug!("Failed to hotreload asset {e}"); @@ -209,7 +209,7 @@ impl AppHandle { tracing::debug!("Pushing asset to device: {target}"); let res = tokio::process::Command::new("adb") .arg("push") - .arg(changed_file) + .arg(&changed_file) .arg(target) .output() .await