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-02-08 14:34:31 -05:00
|
|
|
use crate::state::State;
|
2020-09-05 20:34:02 -04:00
|
|
|
use deno_core::OpRegistry;
|
2020-08-18 12:30:13 -04:00
|
|
|
use std::rc::Rc;
|
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-05 20:34:02 -04:00
|
|
|
pub fn init(s: &Rc<State>, 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-05 20:34:02 -04:00
|
|
|
s.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-05 20:34:02 -04:00
|
|
|
s.register_op_json_sync("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
|
|
|
}
|