mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-12 13:50:01 -04:00
bump UV, implement arraybufferimpl
This commit is contained in:
parent
0e1410bb95
commit
b638ab7c98
7 changed files with 35 additions and 21 deletions
2
Dynamic
2
Dynamic
|
@ -1 +1 @@
|
|||
Subproject commit 37f8c264f4998bf19c6b3fd67c4fda36d4428a1e
|
||||
Subproject commit 3680d531ababfe3dab998b9cf29cc9e570f865e2
|
|
@ -1 +1 @@
|
|||
Subproject commit e5d41a5e9b1fc8b8b485223378d10311d57cb81e
|
||||
Subproject commit 9f86dcd073755aefd70aa9f1d5aee08364958961
|
|
@ -18,7 +18,8 @@ const NULL_BODY_STATUSES = [101, 103, 204, 205, 304];
|
|||
* below MAX_CHUNK_SIZE.
|
||||
*/
|
||||
function createBodyStream(
|
||||
body: BodyInit | null
|
||||
body: BodyInit | null,
|
||||
arrayBufferImpl: ArrayBufferConstructor
|
||||
): ReadableStream<ArrayBuffer | Uint8Array> | null {
|
||||
if (body === null || typeof body === "undefined") return null;
|
||||
|
||||
|
@ -113,9 +114,10 @@ export class AdriftBareClient extends Client {
|
|||
remote: URL,
|
||||
cache: string | undefined,
|
||||
duplex: string | undefined,
|
||||
signal: AbortSignal | undefined
|
||||
signal: AbortSignal | undefined,
|
||||
arrayBufferImpl: ArrayBufferConstructor,
|
||||
): Promise<BareResponse> {
|
||||
const bodyStream = createBodyStream(body);
|
||||
const bodyStream = createBodyStream(body, arrayBufferImpl);
|
||||
let { payload, body: respRawBody } = await this.connection.httprequest(
|
||||
{
|
||||
method,
|
||||
|
@ -152,7 +154,8 @@ export class AdriftBareClient extends Client {
|
|||
getRequestHeaders: GetRequestHeadersCallback,
|
||||
onMeta: MetaCallback,
|
||||
onReadyState: ReadyStateCallback,
|
||||
webSocketImpl: WebSocketImpl
|
||||
webSocketImpl: WebSocketImpl,
|
||||
arrayBufferImpl: ArrayBufferConstructor,
|
||||
): WebSocket {
|
||||
const ws = new webSocketImpl("ws:null", protocols);
|
||||
// this will error. that's okay
|
||||
|
@ -188,6 +191,10 @@ export class AdriftBareClient extends Client {
|
|||
},
|
||||
(data) => {
|
||||
console.log({ data, binaryType: ws.binaryType });
|
||||
if (data instanceof ArrayBuffer) {
|
||||
(data as any).__proto__ = arrayBufferImpl.prototype;
|
||||
}
|
||||
|
||||
ws.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
data,
|
||||
|
@ -197,7 +204,8 @@ export class AdriftBareClient extends Client {
|
|||
(message: string) => {
|
||||
console.log({ message });
|
||||
ws.dispatchEvent(new ErrorEvent("error", { message }));
|
||||
}
|
||||
},
|
||||
arrayBufferImpl
|
||||
);
|
||||
|
||||
ws.send = (data: any) => {
|
||||
|
|
|
@ -106,7 +106,8 @@ export class Connection {
|
|||
case S2CRequestTypes.WSDataBinary: {
|
||||
const socketMeta = this.openSockets[requestID];
|
||||
if (!socketMeta) return;
|
||||
setTimeout(() => socketMeta.onmessage(data.slice(cursor)));
|
||||
let slice = data.slice(cursor);
|
||||
setTimeout(() => socketMeta.onmessage(slice));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,8 @@ export class Connection {
|
|||
onopen: () => void,
|
||||
onclose: (code: number, reason: string, wasClean: boolean) => void,
|
||||
onmessage: (data: any) => void,
|
||||
onerror: (message: string) => void
|
||||
onerror: (message: string) => void,
|
||||
arrayBufferImpl: ArrayBufferConstructor,
|
||||
): {
|
||||
send: (data: any) => void;
|
||||
close: (code?: number, reason?: string) => void;
|
||||
|
@ -245,11 +247,11 @@ export class Connection {
|
|||
).catch(cleanup);
|
||||
return;
|
||||
}
|
||||
if (data instanceof window.ArrayBuffer) {
|
||||
if (data instanceof arrayBufferImpl) {
|
||||
this.send(seq, C2SRequestTypes.WSSendBinary, data).catch(cleanup);
|
||||
return;
|
||||
}
|
||||
if (window.ArrayBuffer.isView(data)) {
|
||||
if (arrayBufferImpl.isView(data)) {
|
||||
this.send(
|
||||
seq,
|
||||
C2SRequestTypes.WSSendBinary,
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
|
@ -1,4 +1,4 @@
|
|||
lockfileVersion: '6.0'
|
||||
lockfileVersion: '6.1'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
|
@ -85,10 +85,14 @@ importers:
|
|||
version: 4.9.4
|
||||
|
||||
Ultraviolet:
|
||||
dependencies:
|
||||
bare-client-custom:
|
||||
specifier: workspace:2.2.0-alpha
|
||||
version: link:../bare-client-custom
|
||||
devDependencies:
|
||||
'@tomphttp/bare-client':
|
||||
specifier: ^2.2.0-alpha
|
||||
version: 2.2.0-alpha
|
||||
specifier: file:../bare-client-custom/
|
||||
version: file:bare-client-custom
|
||||
css-tree:
|
||||
specifier: ^2.3.1
|
||||
version: 2.3.1
|
||||
|
@ -185,7 +189,7 @@ importers:
|
|||
corium:
|
||||
dependencies:
|
||||
'@rollup/browser':
|
||||
specifier: ^3.17.2
|
||||
specifier: ^3.28.0
|
||||
version: 3.28.0
|
||||
'@swc/helpers':
|
||||
specifier: ^0.4.14
|
||||
|
@ -3730,6 +3734,7 @@ packages:
|
|||
|
||||
/@tomphttp/bare-client@2.2.0-alpha:
|
||||
resolution: {integrity: sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==}
|
||||
dev: false
|
||||
|
||||
/@tomphttp/bare-server-node@2.0.1:
|
||||
resolution: {integrity: sha512-L42TC/AldYRFBRZSxhkI0FC5TL8EC/NAsepNC/cWYTTiHQJ7mGg/vdTqNz8ShTYHr6LTHYkuD3/81nhX55SYtA==}
|
||||
|
@ -3971,7 +3976,6 @@ packages:
|
|||
|
||||
/@types/uuid@9.0.2:
|
||||
resolution: {integrity: sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==}
|
||||
dev: false
|
||||
|
||||
/@types/webrtc@0.0.36:
|
||||
resolution: {integrity: sha512-tYFarc92EluXU7XyRmWbkQXSbZIOHTdDOudFPal9u/TNTQuouWpIHV/2o9bNAdqvTJFjLJh/zflCOLWbL30tEQ==}
|
||||
|
@ -10906,7 +10910,6 @@ packages:
|
|||
/uuid@9.0.0:
|
||||
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/v8-compile-cache-lib@3.0.1:
|
||||
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
||||
|
@ -11377,14 +11380,15 @@ packages:
|
|||
file:bare-client-custom:
|
||||
resolution: {directory: bare-client-custom, type: directory}
|
||||
name: bare-client-custom
|
||||
version: 2.2.0-alpha
|
||||
dependencies:
|
||||
'@types/uuid': 9.0.2
|
||||
uuid: 9.0.0
|
||||
dev: false
|
||||
|
||||
file:corium:
|
||||
resolution: {directory: corium, type: directory}
|
||||
name: corium
|
||||
version: 1.0.0-alpha.2
|
||||
dependencies:
|
||||
'@rollup/browser': 3.28.0
|
||||
'@swc/helpers': 0.4.14
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue