Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
warfaj committed Oct 28, 2024
1 parent f23eefb commit c6fe936
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/src/fireworks/pax
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ set -e
current_dir=$(pwd)
pushd ../../../pax-cli
cargo build
PUB_PAX_SERVER=http://127.0.0.1:8090 PAX_WORKSPACE_ROOT=.. ../target/debug/pax-cli "$@" --path="$current_dir" --libdev --verbose
../target/debug/pax-cli "$@" --path="$current_dir" --libdev --verbose
popd
12 changes: 6 additions & 6 deletions pax-chassis-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use js_sys::Uint8Array;
use pax_message::ImageLoadInterruptArgs;
use pax_message::ScreenshotData;
use pax_runtime::api::borrow;
use pax_runtime::api::math::Point2;
use pax_runtime::api::use_RefCell;
Expand All @@ -12,7 +13,6 @@ use pax_runtime::api::RenderContext;
use pax_runtime::api::TextboxChange;
use pax_runtime::api::OS;
use pax_runtime::DefinitionToInstanceTraverser;
use pax_message::ScreenshotData;
use pax_runtime_api::borrow_mut;
use pax_runtime_api::Event;
use pax_runtime_api::Focus;
Expand Down Expand Up @@ -147,7 +147,6 @@ impl PaxChassisWeb {
(width, height, os_info, get_time)
}


#[cfg(any(feature = "designtime", feature = "designer"))]
pub fn handle_recv_designtime(&mut self) {
borrow_mut!(self.designtime_manager)
Expand All @@ -160,7 +159,6 @@ impl PaxChassisWeb {
self.handle_recv_designtime();
self.update_userland_component();
}

}

#[wasm_bindgen]
Expand Down Expand Up @@ -607,17 +605,19 @@ impl PaxChassisWeb {
&globals,
&engine.runtime_context,
)
},
}
NativeInterrupt::Screenshot(args) => {
let data = Uint8Array::new(additional_payload).to_vec();
if let ImageLoadInterruptArgs::Data(args) = args {
let screenshot_data : ScreenshotData = ScreenshotData {
let screenshot_data: ScreenshotData = ScreenshotData {
id: args.id,
data,
width: args.width,
height: args.height,
};
engine.runtime_context.load_screenshot(args.id, screenshot_data)
engine
.runtime_context
.load_screenshot(args.id, screenshot_data)
} else {
false
}
Expand Down
3 changes: 1 addition & 2 deletions pax-designer/src/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ pub struct Console {
pub external_message_listener: Property<bool>,
}


#[pax]
#[engine_import_path("pax_engine")]
pub enum MessageType {
Diff,
LLM,
#[default]
Human
Human,
}

#[pax]
Expand Down
6 changes: 4 additions & 2 deletions pax-designtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ impl DesigntimeManager {
&mut self.orm
}

pub fn handle_recv(&mut self, screenshot_map: Rc<RefCell<HashMap<u32, ScreenshotData>>>) -> anyhow::Result<()> {
pub fn handle_recv(
&mut self,
screenshot_map: Rc<RefCell<HashMap<u32, ScreenshotData>>>,
) -> anyhow::Result<()> {
if let Some(mut llm_request) = self.enqueued_llm_request.take() {
let mut screenshot_map = screenshot_map.borrow_mut();
if let Some(screenshot) = screenshot_map.remove(&(llm_request.request_id as u32)) {
Expand All @@ -249,7 +252,6 @@ impl DesigntimeManager {
}
}


self.priv_agent_connection
.borrow_mut()
.handle_recv(&mut self.orm)?;
Expand Down
7 changes: 6 additions & 1 deletion pax-designtime/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ impl Debug for LLMRequest {
}

impl LLMRequest {
pub fn new(manifest: PaxManifest, prompt: String, request_id: u64, screenshot: Option<ScreenshotData>) -> Self {
pub fn new(
manifest: PaxManifest,
prompt: String,
request_id: u64,
screenshot: Option<ScreenshotData>,
) -> Self {
Self {
manifest,
prompt,
Expand Down
2 changes: 1 addition & 1 deletion pax-message/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub enum NativeInterrupt {
FormButtonClick(FormButtonClickArgs),
Scrollbar(ScrollbarInterruptArgs),
DropFile(DropFileArgs),
Screenshot(ImageLoadInterruptArgs)
Screenshot(ImageLoadInterruptArgs),
}

#[derive(Deserialize)]
Expand Down
12 changes: 7 additions & 5 deletions pax-runtime/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::{collections::HashMap, rc::{Rc, Weak}};
use std::{
collections::HashMap,
rc::{Rc, Weak},
};

use_RefCell!();
use crate::{
node_interface::NodeLocal, ExpandedNode, RuntimeContext, RuntimePropertiesStackFrame, TransformAndBounds
node_interface::NodeLocal, ExpandedNode, RuntimeContext, RuntimePropertiesStackFrame,
TransformAndBounds,
};

pub use pax_runtime_api::*;
Expand Down Expand Up @@ -131,9 +135,7 @@ impl NodeContext {

pub fn screenshot(&self, id: u32) {
self.runtime_context
.enqueue_native_message(NativeMessage::Screenshot(ScreenshotPatch {
id,
}));
.enqueue_native_message(NativeMessage::Screenshot(ScreenshotPatch { id }));
}

pub fn get_screenshot_map(&self) -> Rc<RefCell<HashMap<u32, ScreenshotData>>> {
Expand Down
2 changes: 1 addition & 1 deletion pax-runtime/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl RuntimeContext {
borrow!(self.node_cache).eid_to_node.get(&id).cloned()
}

pub fn load_screenshot(&self, id: u32, data: ScreenshotData) -> bool {
pub fn load_screenshot(&self, id: u32, data: ScreenshotData) -> bool {
borrow_mut!(self.screenshot_map).insert(id, data);
true
}
Expand Down

0 comments on commit c6fe936

Please sign in to comment.