@gjsify/ws 0.4.43 → 0.5.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/README.md +38 -0
- package/package.json +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @gjsify/ws
|
|
2
|
+
|
|
3
|
+
Drop-in implementation of the npm `ws` WebSocket library for GJS, built on `@gjsify/websocket` (Soup.WebsocketConnection) for the client side and `Soup.Server` for `WebSocketServer`. Aliases both `ws` and `isomorphic-ws` so existing npm packages that depend on either resolve to this implementation automatically when bundled for GJS.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gjsify install @gjsify/ws
|
|
11
|
+
|
|
12
|
+
# npm or yarn also work (e.g. adding it to an existing project):
|
|
13
|
+
npm install @gjsify/ws
|
|
14
|
+
yarn add @gjsify/ws
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import WebSocket, { WebSocketServer } from '@gjsify/ws';
|
|
21
|
+
|
|
22
|
+
// Client
|
|
23
|
+
const ws = new WebSocket('wss://echo.websocket.org');
|
|
24
|
+
ws.on('open', () => ws.send('hello'));
|
|
25
|
+
ws.on('message', (data) => console.log('received:', data));
|
|
26
|
+
|
|
27
|
+
// Server
|
|
28
|
+
const wss = new WebSocketServer({ port: 8080 });
|
|
29
|
+
wss.on('connection', (client) => {
|
|
30
|
+
client.on('message', (msg) => client.send(`echo: ${msg}`));
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`WebSocketServer` supports `{ port }`, `{ server }` shared-port, and `{ noServer: true }` + `handleUpgrade()` modes, as well as `verifyClient`, `handleProtocols`, and `createWebSocketStream` (Duplex bridge). Validated against the Autobahn test suite: 510 OK / 4 NON-STRICT / 3 INFO / 0 FAILED.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/ws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Drop-in replacement for the `ws` npm package on Gjs — wraps globalThis.WebSocket (Soup.WebsocketConnection) and Soup.Server for the WebSocketServer side",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"@girs/gio-2.0": "2.88.0-4.0.4",
|
|
42
42
|
"@girs/glib-2.0": "2.88.0-4.0.4",
|
|
43
43
|
"@girs/soup-3.0": "3.6.6-4.0.4",
|
|
44
|
-
"@gjsify/buffer": "^0.
|
|
45
|
-
"@gjsify/crypto": "^0.
|
|
46
|
-
"@gjsify/events": "^0.
|
|
47
|
-
"@gjsify/utils": "^0.
|
|
48
|
-
"@gjsify/websocket": "^0.
|
|
44
|
+
"@gjsify/buffer": "^0.5.0",
|
|
45
|
+
"@gjsify/crypto": "^0.5.0",
|
|
46
|
+
"@gjsify/events": "^0.5.0",
|
|
47
|
+
"@gjsify/utils": "^0.5.0",
|
|
48
|
+
"@gjsify/websocket": "^0.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@gjsify/cli": "^0.
|
|
52
|
-
"@gjsify/unit": "^0.
|
|
53
|
-
"@types/node": "^25.9.
|
|
51
|
+
"@gjsify/cli": "^0.5.0",
|
|
52
|
+
"@gjsify/unit": "^0.5.0",
|
|
53
|
+
"@types/node": "^25.9.2",
|
|
54
54
|
"typescript": "^6.0.3"
|
|
55
55
|
},
|
|
56
56
|
"gjsify": {
|