startback-websocket 0.14.1 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/client.js +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b07db278f362ba2bda41774609852035adc0a96e17360567fab8286ea8c8815
|
4
|
+
data.tar.gz: '038f3196d208256340ecfff8fa9f7c714c03a683563022145f8c1b14b7380684'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0763bf69657b5eef2f78a0c97765a688846634f7f30f60f6040e7f75a0daae6ec96a25b6b763cdcd0d64c9f57abb9f7fefabb2fa75579ab342f7000c2bcb24c0
|
7
|
+
data.tar.gz: d0b1d68d972d5276f6dc15b6e1719bce58523fec6d81e6021b3dc6322d579fe5a9be24582e9360c934e7f21341ac0e515f8bdb6ea10d046911c1f0dc56e92e4f
|
data/dist/client.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
var StartbackWebsocket;(()=>{"use strict";var e,r={d:(e,s)=>{for(var t in s)r.o(s,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:s[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},s={};r.r(s),r.d(s,{Client:()=>t,HubClient:()=>l});class t extends class{#e;constructor(){this.#e={}}on(e,r){this.#e[e]||=[],this.#e[e].push(r)}emit(e,r){this.#e[e]||=[],this.#e[e].forEach((s=>{if(s)try{s(r)}catch(r){console.error("Error while calling event handler for",e),console.error(r)}}))}}{#r;#s;constructor(e){super(),this.#r=e}send(e){this.#s.send(e)}connect(){if(this.#s)throw new Error("Already connected");this.#s=new WebSocket(this.#r),["close","error","message","open"].forEach((e=>{this.#s.addEventListener(e,(r=>{this.emit(e,r)}))}))}}class o{#t;#o;#n;constructor(e,r){this.#t=e,this.#o=r,this.#n={}}send(e,r={}){this.#o.send(e,{...r,room:this.#t})}on(e,r){if(["message"].indexOf(e)<0)throw new Error("You can only subscribe to the 'message' event on rooms");this.#n[e]||=[],this.#n[e].push(r)}execute(e,r,s={}){return this.#o.execute(e,r,{...s,room:this.#t})}process(e){this.#n.message||=[],this.#n.message.forEach((r=>{r(e)}))}}var n=new Uint8Array(16);function i(){if(!e&&!(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(n)}const a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,c=function(e){return"string"==typeof e&&a.test(e)};for(var d=[],h=0;h<256;++h)d.push((h+256).toString(16).substr(1));const u=function(e,r,s){var t=(e=e||{}).random||(e.rng||i)();if(t[6]=15&t[6]|64,t[8]=63&t[8]|128,r){s=s||0;for(var o=0;o<16;++o)r[s+o]=t[o];return r}return function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=(d[e[r+0]]+d[e[r+1]]+d[e[r+2]]+d[e[r+3]]+"-"+d[e[r+4]]+d[e[r+5]]+"-"+d[e[r+6]]+d[e[r+7]]+"-"+d[e[r+8]]+d[e[r+9]]+"-"+d[e[r+10]]+d[e[r+11]]+d[e[r+12]]+d[e[r+13]]+d[e[r+14]]+d[e[r+15]]).toLowerCase();if(!c(s))throw TypeError("Stringified UUID is invalid");return s}(t)};class l extends t{#i;#a;constructor(e){super(e),this.#i={},this.#a={}}send(e,r={}){super.send(JSON.stringify({headers:r,body:e}))}connect(){super.connect(),this.on("message",(e=>{const r=JSON.parse(e.data);if(!r.headers)return;const s=r.headers["in-reply-to"];if(s){const e=this.#a[s];e&&(e.resolve(r),delete this.#a[s])}return r.headers.room?this.#i[r.headers.room].process(r):void 0}))}execute(e,r={},s={}){const t=u();return new Promise(((o,n)=>{this.#a[t]={resolve:o,reject:n},this.send(r,{...s,command:e,"reply-to":t})}))}room(e){return this.#i[e]||=new o(e,this)}}StartbackWebsocket=s})();
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: startback-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.14.
|
19
|
+
version: 0.14.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.14.
|
26
|
+
version: 0.14.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faye-websocket
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- Gemfile
|
122
122
|
- README.md
|
123
123
|
- Rakefile
|
124
|
+
- dist/client.js
|
124
125
|
- lib/startback/ext.rb
|
125
126
|
- lib/startback/ext/context.rb
|
126
127
|
- lib/startback/websocket.rb
|