@textile/grpc-connection
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -16,16 +16,7 @@ import { Context } from '@textile/context'; | ||
function createCommonjsModule$1(fn, basedir, module) { | ||
return module = { | ||
path: basedir, | ||
exports: {}, | ||
require: function (path, base) { | ||
return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); | ||
} | ||
}, fn(module, module.exports), module.exports; | ||
function createCommonjsModule$1(fn) { | ||
var module = { exports: {} }; | ||
return fn(module, module.exports), module.exports; | ||
} | ||
function commonjsRequire () { | ||
throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); | ||
} | ||
// https://github.com/maxogden/websocket-stream/blob/48dc3ddf943e5ada668c31ccd94e9186f02fafbd/ws-fallback.js | ||
@@ -49,3 +40,2 @@ | ||
var loglevel = createCommonjsModule$1(function (module) { | ||
/* | ||
@@ -57,2 +47,4 @@ * loglevel - https://github.com/pimterry/loglevel | ||
*/ | ||
var loglevel = createCommonjsModule$1(function (module) { | ||
(function (root, definition) { | ||
@@ -324,3 +316,3 @@ if ( module.exports) { | ||
const { debug } = loglevel.getLogger("grpc-transport"); | ||
const { debug } = loglevel.getLogger('grpc-transport'); | ||
const isAllowedControlChars = (char) => char === 0x9 || char === 0xa || char === 0xd; | ||
@@ -335,3 +327,3 @@ function isValidHeaderAscii(val) { | ||
if (!isValidHeaderAscii(charCode)) { | ||
throw new Error("Metadata contains invalid ASCII"); | ||
throw new Error('Metadata contains invalid ASCII'); | ||
} | ||
@@ -348,14 +340,14 @@ encoded[i] = charCode; | ||
function constructWebSocketAddress(url) { | ||
if (url.substr(0, 8) === "https://") { | ||
if (url.substr(0, 8) === 'https://') { | ||
return `wss://${url.substr(8)}`; | ||
} | ||
else if (url.substr(0, 7) === "http://") { | ||
else if (url.substr(0, 7) === 'http://') { | ||
return `ws://${url.substr(7)}`; | ||
} | ||
throw new Error("Websocket transport constructed with non-https:// or http:// host."); | ||
throw new Error('Websocket transport constructed with non-https:// or http:// host.'); | ||
} | ||
function headersToBytes(headers) { | ||
let asString = ""; | ||
let asString = ''; | ||
headers.forEach((key, values) => { | ||
asString += `${key}: ${values.join(", ")}\r\n`; | ||
asString += `${key}: ${values.join(', ')}\r\n`; | ||
}); | ||
@@ -365,3 +357,3 @@ return encodeASCII(asString); | ||
function websocketRequest(options) { | ||
options.debug && debug("websocketRequest", options); | ||
options.debug && debug('websocketRequest', options); | ||
const webSocketAddress = constructWebSocketAddress(options.url); | ||
@@ -400,6 +392,6 @@ const sendQueue = []; | ||
start: (metadata) => { | ||
ws = new browser(webSocketAddress, ["grpc-websockets"]); | ||
ws.binaryType = "arraybuffer"; | ||
ws = new browser(webSocketAddress, ['grpc-websockets']); | ||
ws.binaryType = 'arraybuffer'; | ||
ws.onopen = function () { | ||
options.debug && debug("websocketRequest.onopen"); | ||
options.debug && debug('websocketRequest.onopen'); | ||
ws.send(headersToBytes(metadata)); | ||
@@ -412,7 +404,7 @@ // send any messages that were passed to sendMessage before the connection was ready | ||
ws.onclose = function (closeEvent) { | ||
options.debug && debug("websocketRequest.onclose", closeEvent); | ||
options.debug && debug('websocketRequest.onclose', closeEvent); | ||
options.onEnd(); | ||
}; | ||
ws.onerror = function (error) { | ||
options.debug && debug("websocketRequest.onerror", error); | ||
options.debug && debug('websocketRequest.onerror', error); | ||
}; | ||
@@ -424,3 +416,3 @@ ws.onmessage = function (e) { | ||
cancel: () => { | ||
options.debug && debug("websocket.abort"); | ||
options.debug && debug('websocket.abort'); | ||
ws.close(); | ||
@@ -427,0 +419,0 @@ }, |
{ | ||
"name": "@textile/grpc-connection", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "web-gRPC state manager for grpc-connection.", | ||
@@ -23,6 +23,6 @@ "main": "dist/cjs/index.js", | ||
"@improbable-eng/grpc-web": "^0.12.0", | ||
"@textile/context": "^0.10.0", | ||
"@textile/grpc-transport": "^0.3.0" | ||
"@textile/context": "^0.11.0", | ||
"@textile/grpc-transport": "^0.4.0" | ||
}, | ||
"gitHead": "be0b7b39158c3ab240cfd3d9495527f1ee670bab" | ||
"gitHead": "50581c7fddd9b3c40377ff78665d64980cc83d25" | ||
} |
49518
592
+ Added@textile/context@0.11.1(transitive)
+ Added@textile/grpc-transport@0.4.0(transitive)
+ Added@textile/security@0.8.1(transitive)
- Removed@textile/context@0.10.0(transitive)
- Removed@textile/grpc-transport@0.3.0(transitive)
- Removed@textile/security@0.7.0(transitive)
Updated@textile/context@^0.11.0