@phreshos/client 0.1.34 → 0.1.35
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/dist/system.js +4 -0
- package/dist/websocket.d.ts +2 -0
- package/dist/websocket.js +13 -0
- package/package.json +3 -3
package/dist/system.js
CHANGED
|
@@ -7,6 +7,7 @@ import controlledStream from "./controlled-stream.js";
|
|
|
7
7
|
import Events from "./events.js";
|
|
8
8
|
import { exit, process, program } from "./domain.js";
|
|
9
9
|
import { systemStorage } from "./storage.js";
|
|
10
|
+
import websocket from "./websocket.js";
|
|
10
11
|
class ClientSystem {
|
|
11
12
|
storage = systemStorage();
|
|
12
13
|
appearance = new ClientAppearance();
|
|
@@ -73,6 +74,9 @@ class ClientSystem {
|
|
|
73
74
|
});
|
|
74
75
|
return response;
|
|
75
76
|
}
|
|
77
|
+
websocket(url, protocols) {
|
|
78
|
+
return websocket(url, protocols);
|
|
79
|
+
}
|
|
76
80
|
async *shell(command, options = {}) {
|
|
77
81
|
const { signal, ...settings } = options;
|
|
78
82
|
for await (const event of wire.stream(["shell", command, settings], undefined, signal))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import wire from "./wire.js";
|
|
2
|
+
/** Acquire permission, then open the browser's native WebSocket. */
|
|
3
|
+
export default async function websocket(url, protocols) {
|
|
4
|
+
const address = new URL(String(url), document.baseURI);
|
|
5
|
+
if (address.protocol === "http:")
|
|
6
|
+
address.protocol = "ws:";
|
|
7
|
+
if (address.protocol === "https:")
|
|
8
|
+
address.protocol = "wss:";
|
|
9
|
+
await wire.request(["websocket", address.href, protocols]);
|
|
10
|
+
return protocols === undefined
|
|
11
|
+
? new WebSocket(address.href)
|
|
12
|
+
: new WebSocket(address.href, protocols);
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "The SDK used by a Program's client endpoint.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"prepack": "node --run build"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@phreshos/core": "^0.1.
|
|
50
|
+
"@phreshos/core": "^0.1.39"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@the-link/messagepack": "^0.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@phreshos/core": "^0.1.
|
|
56
|
+
"@phreshos/core": "^0.1.39",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
}
|
|
59
59
|
}
|