iosignal 3.0.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{docs/README.ko.md → README.ko.md} +204 -9
- package/README.md +424 -8
- package/dist/io.js +1 -1
- package/dist/io.js.map +1 -1
- package/dist/io.min.js +1 -1
- package/dist/io.min.js.map +1 -1
- package/dist/iosignal.js +19 -6
- package/examples/react-chat-js/package-lock.json +311 -216
- package/examples/react-chat-js/package.json +6 -6
- package/examples/react-chat-js/src/App.jsx +4 -4
- package/examples/server/package-lock.json +47 -0
- package/examples/svelte-chat-js/.devtools +3 -0
- package/examples/svelte-chat-js/README.md +38 -0
- package/examples/svelte-chat-js/package-lock.json +1505 -0
- package/examples/svelte-chat-js/package.json +22 -0
- package/examples/svelte-chat-js/src/app.css +105 -0
- package/examples/svelte-chat-js/src/app.d.ts +13 -0
- package/examples/svelte-chat-js/src/app.html +12 -0
- package/examples/svelte-chat-js/src/lib/images/github.svg +1 -0
- package/examples/svelte-chat-js/src/lib/images/svelte-logo.svg +1 -0
- package/examples/svelte-chat-js/src/lib/images/svelte-welcome.png +0 -0
- package/examples/svelte-chat-js/src/lib/images/svelte-welcome.webp +0 -0
- package/examples/svelte-chat-js/src/lib/shared_io.js +12 -0
- package/examples/svelte-chat-js/src/routes/+layout.svelte +9 -0
- package/examples/svelte-chat-js/src/routes/+page.js +3 -0
- package/examples/svelte-chat-js/src/routes/+page.svelte +162 -0
- package/examples/svelte-chat-js/static/favicon.svg +1 -0
- package/examples/svelte-chat-js/static/global.css +19 -0
- package/examples/svelte-chat-js/static/robots.txt +3 -0
- package/examples/svelte-chat-js/svelte.config.js +15 -0
- package/examples/svelte-chat-js/vite.config.js +6 -0
- package/package.json +1 -1
- package/src/client/IOCore.js +18 -5
- package/src/client/browser/IOWebSocket.js +1 -16
package/dist/iosignal.js
CHANGED
|
@@ -13,7 +13,7 @@ import require$$2 from 'os';
|
|
|
13
13
|
import require$$0$1 from 'buffer';
|
|
14
14
|
import { memoryUsage } from 'process';
|
|
15
15
|
|
|
16
|
-
var version = "3.0
|
|
16
|
+
var version = "3.1.0";
|
|
17
17
|
|
|
18
18
|
var t$1,e$1={},r$1={};var n$1,i$1,o$1={};
|
|
19
19
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function f$1(){return n$1||(n$1=1,o$1.read=function(t,e,r,n,i){var o,f,u=8*i-n-1,s=(1<<u)-1,h=s>>1,a=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-a)-1,p>>=-a,a+=u;a>0;o=256*o+t[e+c],c+=l,a-=8);for(f=o&(1<<-a)-1,o>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===o)o=1-h;else {if(o===s)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),o-=h;}return (p?-1:1)*f*Math.pow(2,o-n)},o$1.write=function(t,e,r,n,i,o){var f,u,s,h=8*o-i-1,a=(1<<h)-1,c=a>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-f))<1&&(f--,s*=2),(e+=f+c>=1?l/s:l*Math.pow(2,1-c))*s>=2&&(f++,s/=2),f+c>=a?(u=0,f=a):f+c>=1?(u=(e*s-1)*Math.pow(2,i),f+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),f=0));i>=8;t[r+p]=255&u,p+=y,u/=256,i-=8);for(f=f<<i|u,h+=i;h>0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g;}),o$1}
|
|
@@ -992,9 +992,22 @@ class IOCore extends EventEmitter {
|
|
|
992
992
|
|
|
993
993
|
// socket clean
|
|
994
994
|
if (this.socket) {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
995
|
+
// For WebSockets, readyState are: 0-CONNECTING, 1-OPEN, 2-CLOSING, 3-CLOSED
|
|
996
|
+
// Calling close() on a CONNECTING socket will cause a browser error.
|
|
997
|
+
if (this.socket.readyState === 0) { // 0 is WebSocket.CONNECTING
|
|
998
|
+
// To avoid the error, we wait for the connection to open, then immediately close it.
|
|
999
|
+
// We also clear other handlers to prevent any other logic from running.
|
|
1000
|
+
const socket = this.socket;
|
|
1001
|
+
socket.onopen = () => { if(socket) socket.close(); };
|
|
1002
|
+
socket.onmessage = null;
|
|
1003
|
+
socket.onerror = null;
|
|
1004
|
+
socket.onclose = null;
|
|
1005
|
+
} else {
|
|
1006
|
+
try {
|
|
1007
|
+
// For other sockets (like TCP) or other WebSocket states, close directly.
|
|
1008
|
+
this.socket.close?.();
|
|
1009
|
+
} catch {}
|
|
1010
|
+
}
|
|
998
1011
|
this.socket = null;
|
|
999
1012
|
}
|
|
1000
1013
|
this.promiseMap.clear();
|
|
@@ -1159,8 +1172,8 @@ class IOCore extends EventEmitter {
|
|
|
1159
1172
|
// console.log( 'ENC_E2E decoded ', decoded )
|
|
1160
1173
|
msgType = decoded[0];
|
|
1161
1174
|
// decoded has msg_header only.
|
|
1162
|
-
buffer.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
|
|
1163
|
-
buffer = buffer.subarray(tt.MetaSize.ENC_488); // reset offset.
|
|
1175
|
+
buffer.set(decoded, tt.MetaSize.ENC_488); // set decoded signal_e2e headaer.
|
|
1176
|
+
buffer = buffer.subarray(tt.MetaSize.ENC_488); // reset offset.
|
|
1164
1177
|
// console.log('DECODED MsgType:', IOMsg[ msgType ] )
|
|
1165
1178
|
} else {
|
|
1166
1179
|
// console.log('488 DEC_FAIL', buffer)
|