libkernel
Advanced tools
Comparing version 0.0.26 to 0.0.27
@@ -40,5 +40,4 @@ // log provides a wrapper for console.log that prefixes 'libkernel'. | ||
// bridge is working. | ||
function handleBridgeTest() { | ||
function handleBridgeResponse() { | ||
if (bridgeExists !== false) { | ||
log("bridge confirmed to be available"); | ||
bridgeExists = true; | ||
@@ -55,3 +54,3 @@ bridgeAvailable.resolve(); | ||
// Check that we have a promise for the provided nonce. | ||
if (!("nonce" in event.data) || !(event.data.nonce in queries)) { | ||
if (!(event.data.nonce in queries)) { | ||
logErr("nonce of kernelResponse not found\n", event, "\n", queries); | ||
@@ -69,7 +68,5 @@ return; | ||
if (event.data.resp !== null) { | ||
console.log("resolving:", event.data); | ||
result.resolve(event.data.resp); | ||
} | ||
else if (event.data.err !== null) { | ||
console.log("rejecting:", event.data); | ||
result.reject(event.data.err); | ||
@@ -93,3 +90,3 @@ } | ||
if (event.data.method === "bridgeTestResponse") { | ||
handleBridgeTest(); | ||
handleBridgeResponse(); | ||
return; | ||
@@ -114,5 +111,8 @@ } | ||
window.addEventListener("message", handleMessage); | ||
// Send a message | ||
// Send a message checking if the bridge is alive and responding. We | ||
// use a fake nonce because we don't care about the nonce for the | ||
// bridge. | ||
window.postMessage({ | ||
method: "bridgeTestQuery", | ||
nonce: 0, | ||
}); | ||
@@ -119,0 +119,0 @@ // After 2 seconds, check whether the bridge has responded. If not, |
{ | ||
"name": "libkernel", | ||
"version": "0.0.26", | ||
"version": "0.0.27", | ||
"description": "helper library to interact with the skynet kernel", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
8422