1let current_module = ""; 2let current_routine = ""; 3let key = Math.random(); 4let lock = Math.random(); 5 6async function process_rpc_call(mod, name, args) { 7 const rsp = await fetch("/__core__/rpc/", { 8 method: "POST", 9 headers: { 10 "Content-Type": "application/json" 11 }, 12 body: JSON.stringify({ 13 module: mod, 14 name: name, 15 args: args 16 }) 17 }); 18 const result = await rsp.json(); 19 if (result.status === "ok") { 20 return result.result; 21 } else { 22 const err = new Error("rpc request failed with status " + result.status); 23 err.details = result.message; 24 throw err; 25 } 26} 27 28const module_proxy = new Proxy({}, { 29 get(target, prop, receiver) { 30 if (!lock || lock !== key) { 31 lock = null; 32 key = null; 33 throw new Error( 34 "RPC call was interrupted by async event. " + 35 "Please do not break up your rpc calls " + 36 "(e.g. do rpc.module.name() instead of " + 37 "func = rpc.module; ...; func.name();" 38 ); 39 } 40 lock = null; 41 key = null; 42 current_routine = prop; 43 return (...args) => { 44 return process_rpc_call(current_module, current_routine, args); 45 } 46 } 47}); 48 49export const rpc = new Proxy({}, { 50 get(target, prop, receiver) { 51 current_module = prop; 52 key = Math.random(); 53 lock = key; 54 Promise.resolve().then(() => { 55 // break the lock if this process is interrupted asynchronously. 56 // this is a hack but it works. 57 lock = Math.random(); 58 }); 59 return module_proxy; 60 } 61});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.