2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-09-06 02:34:02 +02:00
|
|
|
|
2020-09-21 18:36:37 +02:00
|
|
|
use deno_core::serde_json::json;
|
2020-07-23 15:29:36 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::Mutex;
|
2019-08-26 14:50:21 +02:00
|
|
|
|
2020-09-10 09:57:45 -04:00
|
|
|
pub fn init(
|
|
|
|
rt: &mut deno_core::JsRuntime,
|
|
|
|
response: Arc<Mutex<Option<String>>>,
|
|
|
|
) {
|
2020-05-18 12:59:29 +02:00
|
|
|
let custom_assets = std::collections::HashMap::new();
|
|
|
|
// TODO(ry) use None.
|
|
|
|
// TODO(bartlomieju): is this op even required?
|
2020-09-10 09:57:45 -04:00
|
|
|
rt.register_op(
|
2020-02-25 09:14:27 -05:00
|
|
|
"op_fetch_asset",
|
2020-07-20 19:49:57 -04:00
|
|
|
crate::op_fetch_asset::op_fetch_asset(custom_assets),
|
2020-02-19 16:34:11 +11:00
|
|
|
);
|
2020-07-23 15:29:36 +02:00
|
|
|
|
2020-09-10 09:57:45 -04:00
|
|
|
super::reg_json_sync(
|
|
|
|
rt,
|
|
|
|
"op_compiler_respond",
|
|
|
|
move |_state, args, _bufs| {
|
|
|
|
let mut response_slot = response.lock().unwrap();
|
|
|
|
let replaced_value = response_slot.replace(args.to_string());
|
|
|
|
assert!(
|
|
|
|
replaced_value.is_none(),
|
|
|
|
"op_compiler_respond found unexpected existing compiler output",
|
|
|
|
);
|
|
|
|
Ok(json!({}))
|
|
|
|
},
|
|
|
|
);
|
2019-10-11 11:41:54 -07:00
|
|
|
}
|