1let current_module = ""; 2let current_routine = ""; 3let fetch = null; 4let key = Math.random(); 5let lock = Math.random(); 6 7function getFetch() { 8 if (fetch) { 9 return fetch; 10 } 11 12 if (typeof global !== "undefined") { 13 return import("node-fetch").then(d=>d.default); 14 } else { 15 return window.fetch; 16 } 17} 18 19async function process_rpc_call(mod, name, args) { 20 const fetch = await getFetch(); 21 const rsp = await fetch("/__core__/rpc/", { 22 method: "POST", 23 headers: { 24 "Content-Type": "application/json" 25 }, 26 body: JSON.stringify({ 27 module: mod, 28 name: name, 29 args: args 30 }) 31 }); 32 const result = await rsp.json(); 33 if (result.status === "ok") { 34 return result.result; 35 } else { 36 const err = new Error("rpc request failed with status " + result.status); 37 err.details = result.message; 38 throw err; 39 } 40} 41 42const module_proxy = new Proxy({}, { 43 get(target, prop, receiver) { 44 if (!lock || lock !== key) { 45 lock = null; 46 key = null; 47 throw new Error( 48 "RPC call was interrupted by async event. " + 49 "Please do not break up your rpc calls " + 50 "(e.g. do rpc.module.name() instead of " + 51 "func = rpc.module; ...; func.name();" 52 ); 53 } 54 lock = null; 55 key = null; 56 current_routine = prop; 57 return (...args) => { 58 return process_rpc_call(current_module, current_routine, args); 59 } 60 } 61}); 62 63export const rpc = new Proxy({}, { 64 get(target, prop, receiver) { 65 current_module = prop; 66 key = Math.random(); 67 lock = key; 68 Promise.resolve().then(() => { 69 // break the lock if this process is interrupted asynchronously. 70 // this is a hack but it works. 71 lock = Math.random(); 72 }); 73 return module_proxy; 74 } 75});
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.