MCPcopy Create free account
hub / github.com/Botloader/botloader / compile_add_script

Method compile_add_script

components/vm/src/lib.rs:120–152  ·  view source on GitHub ↗
(&mut self, script: Script)

Source from the content-addressed store, hash-verified

118 }
119
120 pub fn compile_add_script(&mut self, script: Script) -> Result<ScriptState, String> {
121 let prefixed_source = prepend_script_source_header(&script.original_source, Some(&script));
122
123 match tscompiler::compile_typescript(
124 &prefixed_source,
125 script_url(&script, "ts").to_string(),
126 ) {
127 Ok(compiled) => {
128 let item = ScriptState {
129 compiled: Some(compiled),
130 url: script_url(&script, "js"),
131 script,
132 state: ScriptLoadState::Unloaded,
133 };
134
135 self.scripts.push(item.clone());
136
137 Ok(item)
138 }
139 Err(e) => {
140 let item = ScriptState {
141 compiled: None,
142 url: script_url(&script, "js"),
143 script,
144 state: ScriptLoadState::FailedCompilation,
145 };
146
147 self.scripts.push(item.clone());
148
149 Err(e)
150 }
151 }
152 }
153
154 pub fn set_state(&mut self, script_id: u64, new_state: ScriptLoadState) {
155 if let Some(current) = self.get_script_mut(script_id) {

Callers 1

compile_scriptMethod · 0.80

Calls 3

compile_typescriptFunction · 0.85
script_urlFunction · 0.85

Tested by

no test coverage detected