Socket
Socket
Sign inDemoInstall

graphql-ws

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-ws - npm Package Compare versions

Comparing version 4.1.5 to 4.1.6

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [4.1.6](https://github.com/enisdenjo/graphql-ws/compare/v4.1.5...v4.1.6) (2021-02-18)
### Bug Fixes
* Add `browser` export map ([ea306db](https://github.com/enisdenjo/graphql-ws/commit/ea306db45a05ab712782b17c5a3a1ec60537eaa4))
* Add `package.json` to exports map ([#119](https://github.com/enisdenjo/graphql-ws/issues/119)) ([1f09863](https://github.com/enisdenjo/graphql-ws/commit/1f09863de6b8731980dfc513708cd144a0d5bfbe)), closes [#118](https://github.com/enisdenjo/graphql-ws/issues/118)
## [4.1.5](https://github.com/enisdenjo/graphql-ws/compare/v4.1.4...v4.1.5) (2021-02-12)

@@ -2,0 +10,0 @@

26

package.json
{
"name": "graphql-ws",
"version": "4.1.5",
"version": "4.1.6",
"description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client",

@@ -29,6 +29,8 @@ "keywords": [

"module": "lib/index.mjs",
"browser": "umd/graphql-ws.js",
"exports": {
".": {
"require": "./lib/index.js",
"import": "./lib/index.mjs"
"import": "./lib/index.mjs",
"browser": "./umd/graphql-ws.js"
},

@@ -38,6 +40,6 @@ "./lib/use/ws": {

"import": "./lib/use/ws.mjs"
}
},
"./package.json": "./package.json"
},
"types": "lib/index.d.ts",
"browser": "umd/graphql-ws.js",
"files": [

@@ -75,3 +77,3 @@ "lib",

"@babel/preset-typescript": "^7.12.16",
"@rollup/plugin-typescript": "^8.1.1",
"@rollup/plugin-typescript": "^8.2.0",
"@semantic-release/changelog": "^5.0.1",

@@ -81,6 +83,6 @@ "@semantic-release/git": "^9.0.0",

"@types/ws": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.15.0",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"babel-jest": "^26.6.3",
"eslint": "^7.19.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",

@@ -93,8 +95,8 @@ "eslint-plugin-prettier": "^3.3.1",

"replacestream": "^4.0.3",
"rollup": "^2.38.5",
"rollup": "^2.39.0",
"rollup-plugin-terser": "^7.0.2",
"semantic-release": "^17.3.8",
"semantic-release": "^17.3.9",
"tslib": "^2.1.0",
"typedoc": "^0.20.24",
"typedoc-plugin-markdown": "^3.4.5",
"typedoc": "^0.20.25",
"typedoc-plugin-markdown": "^3.5.0",
"typescript": "^4.1.5",

@@ -101,0 +103,0 @@ "ws": "^7.4.3"

@@ -42,2 +42,4 @@ (function (global, factory) {

*/
/** Types of messages allowed to be sent by the client/server over the WS protocol. */
exports.MessageType = void 0;
(function (MessageType) {

@@ -44,0 +46,0 @@ MessageType["ConnectionInit"] = "connection_init";

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";const n="graphql-transport-ws",t=Object.prototype.hasOwnProperty;function o(e){return"object"==typeof e&&null!==e}function r(e,n){return t.call(e,n)}function a(e,n){return t.call(e,n)&&o(e[n])}function i(e,n){return t.call(e,n)&&"string"==typeof e[n]}var s;function c(n){if(o(n)){if(!i(n,"type"))return!1;switch(n.type){case e.MessageType.ConnectionInit:case e.MessageType.ConnectionAck:return!r(n,"payload")||void 0===n.payload||o(n.payload);case e.MessageType.Subscribe:return i(n,"id")&&a(n,"payload")&&(!r(n.payload,"operationName")||void 0===n.payload.operationName||null===n.payload.operationName||"string"==typeof n.payload.operationName)&&i(n.payload,"query")&&(!r(n.payload,"variables")||void 0===n.payload.variables||null===n.payload.variables||a(n.payload,"variables"));case e.MessageType.Next:return i(n,"id")&&a(n,"payload");case e.MessageType.Error:return i(n,"id")&&(t=n.payload,Array.isArray(t)&&t.length>0&&t.every((e=>"message"in e)));case e.MessageType.Complete:return i(n,"id");default:return!1}}var t;return!1}function l(e){if(c(e))return e;if("string"!=typeof e)throw new Error("Message not parsable");const n=JSON.parse(e);if(!c(n))throw new Error("Invalid message");return n}function d(e){if(!c(e))throw new Error("Cannot stringify invalid message");return JSON.stringify(e)}(s=e.MessageType||(e.MessageType={})).ConnectionInit="connection_init",s.ConnectionAck="connection_ack",s.Subscribe="subscribe",s.Next="next",s.Error="error",s.Complete="complete",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=n,e.createClient=function(t){const{url:r,connectionParams:a,lazy:i=!0,onNonLazyError:s=console.error,keepAlive:c=0,retryAttempts:u=5,retryWait:p=async function(e){let n=1e3;for(let t=0;t<e;t++)n*=2;await new Promise((e=>setTimeout(e,n+Math.floor(2700*Math.random()+300))))},on:y,webSocketImpl:f,generateID:g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const n=16*Math.random()|0;return("x"==e?n:3&n|8).toString(16)}))}}=t;let m;if(f){if(!("function"==typeof(w=f)&&"constructor"in w&&"CLOSED"in w&&"CLOSING"in w&&"CONNECTING"in w&&"OPEN"in w))throw new Error("Invalid WebSocket implementation provided");m=f}else"undefined"!=typeof WebSocket?m=WebSocket:"undefined"!=typeof global?m=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(m=window.WebSocket||window.MozWebSocket);var w;if(!m)throw new Error("WebSocket implementation missing");const x=m,b=(()=>{const e={connecting:(null==y?void 0:y.connecting)?[y.connecting]:[],connected:(null==y?void 0:y.connected)?[y.connected]:[],closed:(null==y?void 0:y.closed)?[y.closed]:[]};return{on(n,t){const o=e[n];return o.push(t),()=>{o.splice(o.indexOf(t),1)}},emit(n,...t){for(const o of e[n])o(...t)}}})();let v,h,M,T=0,E=!1,S=0,N=!1;async function C(){T++;const t=await(null!=v?v:v=new Promise(((t,o)=>(async()=>{E&&(await p(S),S++),b.emit("connecting");const i=new x(r,n);i.onclose=e=>{v=void 0,b.emit("closed",e),o(e)},i.onopen=async()=>{try{i.send(d({type:e.MessageType.ConnectionInit,payload:"function"==typeof a?await a():a}))}catch(e){i.close(4400,e instanceof Error?e.message:new Error(e).message)}},i.onmessage=({data:n})=>{i.onmessage=null;try{const o=l(n);if(o.type!==e.MessageType.ConnectionAck)throw new Error(`First message cannot be of type ${o.type}`);b.emit("connected",i,o.payload),S=0,t(i)}catch(e){i.close(4400,e instanceof Error?e.message:new Error(e).message)}}})())));let o=()=>{};const i=new Promise((e=>o=e));return[t,o,Promise.race([i.then((()=>{if(0==--T){const e=()=>t.close(1e3,"Normal Closure");isFinite(c)&&c>0?setTimeout((()=>{T||t.readyState!==x.OPEN||e()}),c):e()}})),new Promise(((e,n)=>t.addEventListener("close",n,{once:!0})))])]}function O(e){if(!function(e){return o(e)&&"code"in e&&"reason"in e}(e))throw e;if([1002,1011,4400,4401,4409,4429].includes(e.code))throw e;if(N||1e3===e.code)return!1;if(!u||S>=u)throw e;return E=!0,!0}return i||(async()=>{for(;;)try{const[,,e]=await C();return void await e}catch(e){try{if(!O(e))return null==s?void 0:s(e)}catch(n){return null==s?void 0:s(e)}}})(),{on:b.on,subscribe(n,t){const o=g();let r=!1;const a={current:()=>{r=!0}};function i({data:n}){const i=function(e){return e!==h&&(M=l(e),h=e),M}(n);switch(i.type){case e.MessageType.Next:return void(i.id===o&&t.next(i.payload));case e.MessageType.Error:return void(i.id===o&&(r=!0,t.error(i.payload),a.current()));case e.MessageType.Complete:return void(i.id===o&&(r=!0,a.current()))}}return(async()=>{for(;;)try{const[t,s,c]=await C();return r?s():(t.addEventListener("message",i),t.send(d({id:o,type:e.MessageType.Subscribe,payload:n})),a.current=()=>{r||t.readyState!==x.OPEN||t.send(d({id:o,type:e.MessageType.Complete})),s()},await c,void t.removeEventListener("message",i))}catch(e){if(!O(e))return}})().catch(t.error).then(t.complete),()=>a.current()},async dispose(){if(N=!0,v){(await v).close(1e3,"Normal Closure")}}}},e.isMessage=c,e.parseMessage=l,e.stringifyMessage=d,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).graphqlWs={})}(this,(function(e){"use strict";const n="graphql-transport-ws",t=Object.prototype.hasOwnProperty;function o(e){return"object"==typeof e&&null!==e}function r(e,n){return t.call(e,n)}function a(e,n){return t.call(e,n)&&o(e[n])}function i(e,n){return t.call(e,n)&&"string"==typeof e[n]}var s;function c(n){if(o(n)){if(!i(n,"type"))return!1;switch(n.type){case e.MessageType.ConnectionInit:case e.MessageType.ConnectionAck:return!r(n,"payload")||void 0===n.payload||o(n.payload);case e.MessageType.Subscribe:return i(n,"id")&&a(n,"payload")&&(!r(n.payload,"operationName")||void 0===n.payload.operationName||null===n.payload.operationName||"string"==typeof n.payload.operationName)&&i(n.payload,"query")&&(!r(n.payload,"variables")||void 0===n.payload.variables||null===n.payload.variables||a(n.payload,"variables"));case e.MessageType.Next:return i(n,"id")&&a(n,"payload");case e.MessageType.Error:return i(n,"id")&&(t=n.payload,Array.isArray(t)&&t.length>0&&t.every((e=>"message"in e)));case e.MessageType.Complete:return i(n,"id");default:return!1}}var t;return!1}function l(e){if(c(e))return e;if("string"!=typeof e)throw new Error("Message not parsable");const n=JSON.parse(e);if(!c(n))throw new Error("Invalid message");return n}function d(e){if(!c(e))throw new Error("Cannot stringify invalid message");return JSON.stringify(e)}e.MessageType=void 0,(s=e.MessageType||(e.MessageType={})).ConnectionInit="connection_init",s.ConnectionAck="connection_ack",s.Subscribe="subscribe",s.Next="next",s.Error="error",s.Complete="complete",e.GRAPHQL_TRANSPORT_WS_PROTOCOL=n,e.createClient=function(t){const{url:r,connectionParams:a,lazy:i=!0,onNonLazyError:s=console.error,keepAlive:c=0,retryAttempts:u=5,retryWait:p=async function(e){let n=1e3;for(let t=0;t<e;t++)n*=2;await new Promise((e=>setTimeout(e,n+Math.floor(2700*Math.random()+300))))},on:y,webSocketImpl:f,generateID:g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const n=16*Math.random()|0;return("x"==e?n:3&n|8).toString(16)}))}}=t;let m;if(f){if(!("function"==typeof(w=f)&&"constructor"in w&&"CLOSED"in w&&"CLOSING"in w&&"CONNECTING"in w&&"OPEN"in w))throw new Error("Invalid WebSocket implementation provided");m=f}else"undefined"!=typeof WebSocket?m=WebSocket:"undefined"!=typeof global?m=global.WebSocket||global.MozWebSocket:"undefined"!=typeof window&&(m=window.WebSocket||window.MozWebSocket);var w;if(!m)throw new Error("WebSocket implementation missing");const x=m,b=(()=>{const e={connecting:(null==y?void 0:y.connecting)?[y.connecting]:[],connected:(null==y?void 0:y.connected)?[y.connected]:[],closed:(null==y?void 0:y.closed)?[y.closed]:[]};return{on(n,t){const o=e[n];return o.push(t),()=>{o.splice(o.indexOf(t),1)}},emit(n,...t){for(const o of e[n])o(...t)}}})();let v,h,M,T=0,E=!1,S=0,N=!1;async function C(){T++;const t=await(null!=v?v:v=new Promise(((t,o)=>(async()=>{E&&(await p(S),S++),b.emit("connecting");const i=new x(r,n);i.onclose=e=>{v=void 0,b.emit("closed",e),o(e)},i.onopen=async()=>{try{i.send(d({type:e.MessageType.ConnectionInit,payload:"function"==typeof a?await a():a}))}catch(e){i.close(4400,e instanceof Error?e.message:new Error(e).message)}},i.onmessage=({data:n})=>{i.onmessage=null;try{const o=l(n);if(o.type!==e.MessageType.ConnectionAck)throw new Error(`First message cannot be of type ${o.type}`);b.emit("connected",i,o.payload),S=0,t(i)}catch(e){i.close(4400,e instanceof Error?e.message:new Error(e).message)}}})())));let o=()=>{};const i=new Promise((e=>o=e));return[t,o,Promise.race([i.then((()=>{if(0==--T){const e=()=>t.close(1e3,"Normal Closure");isFinite(c)&&c>0?setTimeout((()=>{T||t.readyState!==x.OPEN||e()}),c):e()}})),new Promise(((e,n)=>t.addEventListener("close",n,{once:!0})))])]}function O(e){if(!function(e){return o(e)&&"code"in e&&"reason"in e}(e))throw e;if([1002,1011,4400,4401,4409,4429].includes(e.code))throw e;if(N||1e3===e.code)return!1;if(!u||S>=u)throw e;return E=!0,!0}return i||(async()=>{for(;;)try{const[,,e]=await C();return void await e}catch(e){try{if(!O(e))return null==s?void 0:s(e)}catch(n){return null==s?void 0:s(e)}}})(),{on:b.on,subscribe(n,t){const o=g();let r=!1;const a={current:()=>{r=!0}};function i({data:n}){const i=function(e){return e!==h&&(M=l(e),h=e),M}(n);switch(i.type){case e.MessageType.Next:return void(i.id===o&&t.next(i.payload));case e.MessageType.Error:return void(i.id===o&&(r=!0,t.error(i.payload),a.current()));case e.MessageType.Complete:return void(i.id===o&&(r=!0,a.current()))}}return(async()=>{for(;;)try{const[t,s,c]=await C();return r?s():(t.addEventListener("message",i),t.send(d({id:o,type:e.MessageType.Subscribe,payload:n})),a.current=()=>{r||t.readyState!==x.OPEN||t.send(d({id:o,type:e.MessageType.Complete})),s()},await c,void t.removeEventListener("message",i))}catch(e){if(!O(e))return}})().catch(t.error).then(t.complete),()=>a.current()},async dispose(){if(N=!0,v){(await v).close(1e3,"Normal Closure")}}}},e.isMessage=c,e.parseMessage=l,e.stringifyMessage=d,Object.defineProperty(e,"__esModule",{value:!0})}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc