2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-09-05 20:34:02 -04:00
|
|
|
|
2020-09-21 12:36:37 -04:00
|
|
|
use deno_core::serde_json::json;
|
2020-07-23 09:29:36 -04:00
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::Mutex;
|
2019-08-26 08:50:21 -04: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 06:59:29 -04: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 00:34:11 -05:00
|
|
|
);
|
2020-07-23 09:29:36 -04: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 14:41:54 -04:00
|
|
|
}
|