update bare-client

new api changes
This commit is contained in:
David Reed 2023-06-09 21:32:58 -04:00
parent c03c5ffb20
commit 96130ccdfc
No known key found for this signature in database
GPG key ID: 2211691D8A1EE72F
3 changed files with 40 additions and 26 deletions

14
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "2.0.0-beta",
"license": "MIT",
"dependencies": {
"@tomphttp/bare-client": "^2.0.0-beta",
"@tomphttp/bare-client": "^2.0.0-beta.1",
"css-tree": "^2.0.4",
"esotope-hammerhead": "^0.6.1",
"events": "^3.3.0",
@ -190,9 +190,9 @@
}
},
"node_modules/@tomphttp/bare-client": {
"version": "2.0.0-beta",
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.0.0-beta.tgz",
"integrity": "sha512-M2ap0V4DwIdc+gtiiAN8GFqiXDi81iOc+fu4JZGQTIa4Y4gIQVN9bFybFm0hz23QjfqSiFYfHO9o/BhQOo5bSQ=="
"version": "2.0.0-beta.1",
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.0.0-beta.1.tgz",
"integrity": "sha512-5bEfQoybliRCffK4JvDKW6ACbItksowdVI1y0WScYrSsAYydwh0YJ7kUR0y/jMiXBqeRob6s2txLQdgK+98R/A=="
},
"node_modules/@types/eslint": {
"version": "8.4.6",
@ -2964,9 +2964,9 @@
}
},
"@tomphttp/bare-client": {
"version": "2.0.0-beta",
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.0.0-beta.tgz",
"integrity": "sha512-M2ap0V4DwIdc+gtiiAN8GFqiXDi81iOc+fu4JZGQTIa4Y4gIQVN9bFybFm0hz23QjfqSiFYfHO9o/BhQOo5bSQ=="
"version": "2.0.0-beta.1",
"resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-2.0.0-beta.1.tgz",
"integrity": "sha512-5bEfQoybliRCffK4JvDKW6ACbItksowdVI1y0WScYrSsAYydwh0YJ7kUR0y/jMiXBqeRob6s2txLQdgK+98R/A=="
},
"@types/eslint": {
"version": "8.4.6",

View file

@ -19,7 +19,7 @@
"watch": "cross-env NODE_ENV=development webpack-cli --watch"
},
"dependencies": {
"@tomphttp/bare-client": "^2.0.0-beta",
"@tomphttp/bare-client": "^2.0.0-beta.1",
"css-tree": "^2.0.4",
"esotope-hammerhead": "^0.6.1",
"events": "^3.3.0",

View file

@ -1025,14 +1025,28 @@ function __uvHook(window) {
const socket = bareClient.createWebSocket(
event.data.args[0],
event.data.args[1],
requestHeaders,
(socket, getReadyState) => {
{
headers: requestHeaders,
readyStateHook: (socket, getReadyState) => {
socket.__uv$getReadyState = getReadyState;
},
(socket, getSendError) => {
sendErrorHook: (socket, getSendError) => {
socket.__uv$getSendError = getSendError;
},
event.target
urlHook: (socket, url) => {
socket.__uv$socketUrl = url;
},
protocolHook: (socket, getProtocol) => {
socket.__uv$getProtocol = getProtocol;
},
setCookiesCallback: (setCookies) => {
// document.cookie is hooked
// so we can just call it
for (const cookie of setCookies)
window.document.cookie = cookie;
},
webSocketImpl: event.target,
}
);
socket.addEventListener('meta', (event) => {
@ -1045,16 +1059,6 @@ function __uvHook(window) {
event.respondWith(socket);
});
client.websocket.on('url', (event) => {
if ('__uv$socketMeta' in event.that)
event.data.value = event.that.__uv$socketMeta.url;
});
client.websocket.on('protocol', (event) => {
if ('__uv$socketMeta' in event.that)
event.data.value = event.that.__uv$socketMeta.protocol;
});
client.websocket.on('readyState', (event) => {
if ('__uv$getReadyState' in event.that)
event.data.value = event.that.__uv$getReadyState();
@ -1067,6 +1071,16 @@ function __uvHook(window) {
}
});
client.websocket.on('url', (event) => {
if ('__uv$socketUrl' in event.that)
event.data.value = event.that.__uv$socketUrl.toString();
});
client.websocket.on('protocol', (event) => {
if ('__uv$getProtocol' in event.that)
event.data.value = event.that.__uv$getProtocol();
});
client.function.on('function', (event) => {
event.data.script = __uv.rewriteJS(event.data.script);
});