From fa7f34eb8cec07f4c68ca4e9c46a983bc3e2308f Mon Sep 17 00:00:00 2001 From: Ry Dahl Date: Tue, 21 Jan 2020 14:57:56 -0500 Subject: Revert "Create an old program to be used in snapshot. (#3644)" Ref #3712. This change allowed the deno_typescript crate to reference cli/js/lib.deno_runtime.d.ts which breaks "cargo package". We intend to reintroduce a revised version of this patch later once "cargo package" is working and tested. This reverts commit 737ab94ea1bdf65eeef323ea37e84bcf430fb92c. --- cli/ops/compiler.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'cli/ops/compiler.rs') diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs index e515081df..cb2fb01a0 100644 --- a/cli/ops/compiler.rs +++ b/cli/ops/compiler.rs @@ -17,6 +17,10 @@ pub fn init(i: &mut Isolate, s: &ThreadSafeState) { "fetch_source_files", s.core_op(json_op(s.stateful_op(op_fetch_source_files))), ); + i.register_op( + "fetch_asset", + s.core_op(json_op(s.stateful_op(op_fetch_asset))), + ); } #[derive(Deserialize)] @@ -145,3 +149,21 @@ fn op_fetch_source_files( Ok(JsonOp::Async(future)) } + +#[derive(Deserialize)] +struct FetchAssetArgs { + name: String, +} + +fn op_fetch_asset( + _state: &ThreadSafeState, + args: Value, + _zero_copy: Option, +) -> Result { + let args: FetchAssetArgs = serde_json::from_value(args)?; + if let Some(source_code) = crate::js::get_asset(&args.name) { + Ok(JsonOp::Sync(json!(source_code))) + } else { + panic!("op_fetch_asset bad asset {}", args.name) + } +} -- cgit v1.2.3