startback-websocket 0.14.1 → 0.14.4
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 +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f389c80bf13c6b6858cf1112cbf3195dab2c1770bcd58c9232840967d5ad2dac
|
4
|
+
data.tar.gz: 599326092668b1cfa2e42a8b4c0004a78580f21e35df991c315a8c1f7f447554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a93974b5a5f03ed5ab58f0588ac5cafdbab35e0d83351b782a92c0dadb0bfa6f60035c614bcb386fb3f7d55025ba84a420691d1bfce63e8eb7b7a8cdca26bc
|
7
|
+
data.tar.gz: ccc5e84bd477a06ae3ddbab5d84d8986b05e246860a10d590df991ffb607b9c2eecfd013df218c7288940e4cfee957df23aa69ebabdbdda6d7026905ef72fd48
|
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,14 +1,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: startback
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.14.
|
19
|
+
version: 0.14.4
|
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.4
|
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
|