This commit is contained in:
Mike Farrell
2024-10-10 11:52:33 -07:00
parent c017847d7b
commit b11e8af9c7
2 changed files with 22 additions and 24 deletions

View File

@ -1,4 +1,4 @@
import * as EngineUtils from './engine-utils/engine.js'
import EngineUtils from './engine-utils/engine.js'
type KCEngineUtilsEvaluatePath = {
(sketch: string, t: number): string
@ -8,19 +8,14 @@ let kcEngineUtilsEvaluatePath: KCEngineUtilsEvaluatePath
export async function init() {
return await new Promise((resolve, reject) => {
try {
kcEngineUtilsEvaluatePath = (s: string, t: number) => {
return 'it works'
}
resolve(true)
// EngineUtils.Module().then(() => {
// kcEngineUtilsEvaluatePath = EngineUtils.Module.cwrap(
// 'kcEngineCalcPathEndpoint',
// 'string',
// ['string', 'number']
// )
// resolve(true)
// })
EngineUtils().then((module) => {
kcEngineUtilsEvaluatePath = module.cwrap(
'kcEngineCalcPathEndpoint',
'string',
['string', 'number']
)
resolve(true)
})
} catch (e) {
reject(e)
}

View File

@ -1548,16 +1548,19 @@ pub(crate) async fn inner_arc(
})
})?;
//let str_result: Rc<RefCell<Option<String>>> = Rc::new(RefCell::new(None));
//let str_result0 = Rc::clone(&str_result);
//wasm_bindgen_futures::spawn_local(async move {
let promise = get_true_path_end_pos(sketch_json_value.into()).unwrap();
let result = crate::wasm::JsFuture::from(promise).await.unwrap();
web_sys::console::log_1(&format!("Inside here {result:?}").into());
//*str_result0.borrow_mut() = Some(result);
//});
//web_sys::console::log_1(&format!("Did this work? {str_result:?}").into());
let promise = get_true_path_end_pos(sketch_json_value.into()).map_err(|e| {
KclError::Internal(KclErrorDetails {
message: format!("{:?}", e),
source_ranges: vec![args.source_range],
})
})?;
let result = crate::wasm::JsFuture::from(promise).await.map_err(|e| {
KclError::Internal(KclErrorDetails {
message: format!("{:?}", e),
source_ranges: vec![args.source_range],
})
})?;
web_sys::console::log_1(&format!("Testing here {result:?}").into());
}
//duplicating engine logic to make sure this is _exactly_ what engine is doing - mike