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.
|
* below MAX_CHUNK_SIZE.
|
||||||
*/
|
*/
|
||||||
function createBodyStream(
|
function createBodyStream(
|
||||||
body: BodyInit | null
|
body: BodyInit | null,
|
||||||
|
arrayBufferImpl: ArrayBufferConstructor
|
||||||
): ReadableStream<ArrayBuffer | Uint8Array> | null {
|
): ReadableStream<ArrayBuffer | Uint8Array> | null {
|
||||||
if (body === null || typeof body === "undefined") return null;
|
if (body === null || typeof body === "undefined") return null;
|
||||||
|
|
||||||
|
@ -113,9 +114,10 @@ export class AdriftBareClient extends Client {
|
||||||
remote: URL,
|
remote: URL,
|
||||||
cache: string | undefined,
|
cache: string | undefined,
|
||||||
duplex: string | undefined,
|
duplex: string | undefined,
|
||||||
signal: AbortSignal | undefined
|
signal: AbortSignal | undefined,
|
||||||
|
arrayBufferImpl: ArrayBufferConstructor,
|
||||||
): Promise<BareResponse> {
|
): Promise<BareResponse> {
|
||||||
const bodyStream = createBodyStream(body);
|
const bodyStream = createBodyStream(body, arrayBufferImpl);
|
||||||
let { payload, body: respRawBody } = await this.connection.httprequest(
|
let { payload, body: respRawBody } = await this.connection.httprequest(
|
||||||
{
|
{
|
||||||
method,
|
method,
|
||||||
|
@ -152,7 +154,8 @@ export class AdriftBareClient extends Client {
|
||||||
getRequestHeaders: GetRequestHeadersCallback,
|
getRequestHeaders: GetRequestHeadersCallback,
|
||||||
onMeta: MetaCallback,
|
onMeta: MetaCallback,
|
||||||
onReadyState: ReadyStateCallback,
|
onReadyState: ReadyStateCallback,
|
||||||
webSocketImpl: WebSocketImpl
|
webSocketImpl: WebSocketImpl,
|
||||||
|
arrayBufferImpl: ArrayBufferConstructor,
|
||||||
): WebSocket {
|
): WebSocket {
|
||||||
const ws = new webSocketImpl("ws:null", protocols);
|
const ws = new webSocketImpl("ws:null", protocols);
|
||||||
// this will error. that's okay
|
// this will error. that's okay
|
||||||
|
@ -188,6 +191,10 @@ export class AdriftBareClient extends Client {
|
||||||
},
|
},
|
||||||
(data) => {
|
(data) => {
|
||||||
console.log({ data, binaryType: ws.binaryType });
|
console.log({ data, binaryType: ws.binaryType });
|
||||||
|
if (data instanceof ArrayBuffer) {
|
||||||
|
(data as any).__proto__ = arrayBufferImpl.prototype;
|
||||||
|
}
|
||||||
|
|
||||||
ws.dispatchEvent(
|
ws.dispatchEvent(
|
||||||
new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
data,
|
data,
|
||||||
|
@ -197,7 +204,8 @@ export class AdriftBareClient extends Client {
|
||||||
(message: string) => {
|
(message: string) => {
|
||||||
console.log({ message });
|
console.log({ message });
|
||||||
ws.dispatchEvent(new ErrorEvent("error", { message }));
|
ws.dispatchEvent(new ErrorEvent("error", { message }));
|
||||||
}
|
},
|
||||||
|
arrayBufferImpl
|
||||||
);
|
);
|
||||||
|
|
||||||
ws.send = (data: any) => {
|
ws.send = (data: any) => {
|
||||||
|
|
|
@ -106,7 +106,8 @@ export class Connection {
|
||||||
case S2CRequestTypes.WSDataBinary: {
|
case S2CRequestTypes.WSDataBinary: {
|
||||||
const socketMeta = this.openSockets[requestID];
|
const socketMeta = this.openSockets[requestID];
|
||||||
if (!socketMeta) return;
|
if (!socketMeta) return;
|
||||||
setTimeout(() => socketMeta.onmessage(data.slice(cursor)));
|
let slice = data.slice(cursor);
|
||||||
|
setTimeout(() => socketMeta.onmessage(slice));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +201,8 @@ export class Connection {
|
||||||
onopen: () => void,
|
onopen: () => void,
|
||||||
onclose: (code: number, reason: string, wasClean: boolean) => void,
|
onclose: (code: number, reason: string, wasClean: boolean) => void,
|
||||||
onmessage: (data: any) => void,
|
onmessage: (data: any) => void,
|
||||||
onerror: (message: string) => void
|
onerror: (message: string) => void,
|
||||||
|
arrayBufferImpl: ArrayBufferConstructor,
|
||||||
): {
|
): {
|
||||||
send: (data: any) => void;
|
send: (data: any) => void;
|
||||||
close: (code?: number, reason?: string) => void;
|
close: (code?: number, reason?: string) => void;
|
||||||
|
@ -245,11 +247,11 @@ export class Connection {
|
||||||
).catch(cleanup);
|
).catch(cleanup);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data instanceof window.ArrayBuffer) {
|
if (data instanceof arrayBufferImpl) {
|
||||||
this.send(seq, C2SRequestTypes.WSSendBinary, data).catch(cleanup);
|
this.send(seq, C2SRequestTypes.WSSendBinary, data).catch(cleanup);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.ArrayBuffer.isView(data)) {
|
if (arrayBufferImpl.isView(data)) {
|
||||||
this.send(
|
this.send(
|
||||||
seq,
|
seq,
|
||||||
C2SRequestTypes.WSSendBinary,
|
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:
|
settings:
|
||||||
autoInstallPeers: true
|
autoInstallPeers: true
|
||||||
|
@ -85,10 +85,14 @@ importers:
|
||||||
version: 4.9.4
|
version: 4.9.4
|
||||||
|
|
||||||
Ultraviolet:
|
Ultraviolet:
|
||||||
|
dependencies:
|
||||||
|
bare-client-custom:
|
||||||
|
specifier: workspace:2.2.0-alpha
|
||||||
|
version: link:../bare-client-custom
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@tomphttp/bare-client':
|
'@tomphttp/bare-client':
|
||||||
specifier: ^2.2.0-alpha
|
specifier: file:../bare-client-custom/
|
||||||
version: 2.2.0-alpha
|
version: file:bare-client-custom
|
||||||
css-tree:
|
css-tree:
|
||||||
specifier: ^2.3.1
|
specifier: ^2.3.1
|
||||||
version: 2.3.1
|
version: 2.3.1
|
||||||
|
@ -185,7 +189,7 @@ importers:
|
||||||
corium:
|
corium:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/browser':
|
'@rollup/browser':
|
||||||
specifier: ^3.17.2
|
specifier: ^3.28.0
|
||||||
version: 3.28.0
|
version: 3.28.0
|
||||||
'@swc/helpers':
|
'@swc/helpers':
|
||||||
specifier: ^0.4.14
|
specifier: ^0.4.14
|
||||||
|
@ -3730,6 +3734,7 @@ packages:
|
||||||
|
|
||||||
/@tomphttp/bare-client@2.2.0-alpha:
|
/@tomphttp/bare-client@2.2.0-alpha:
|
||||||
resolution: {integrity: sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==}
|
resolution: {integrity: sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@tomphttp/bare-server-node@2.0.1:
|
/@tomphttp/bare-server-node@2.0.1:
|
||||||
resolution: {integrity: sha512-L42TC/AldYRFBRZSxhkI0FC5TL8EC/NAsepNC/cWYTTiHQJ7mGg/vdTqNz8ShTYHr6LTHYkuD3/81nhX55SYtA==}
|
resolution: {integrity: sha512-L42TC/AldYRFBRZSxhkI0FC5TL8EC/NAsepNC/cWYTTiHQJ7mGg/vdTqNz8ShTYHr6LTHYkuD3/81nhX55SYtA==}
|
||||||
|
@ -3971,7 +3976,6 @@ packages:
|
||||||
|
|
||||||
/@types/uuid@9.0.2:
|
/@types/uuid@9.0.2:
|
||||||
resolution: {integrity: sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==}
|
resolution: {integrity: sha512-kNnC1GFBLuhImSnV7w4njQkUiJi0ZXUycu1rUaouPqiKlXkh77JKgdRnTAp1x5eBwcIwbtI+3otwzuIDEuDoxQ==}
|
||||||
dev: false
|
|
||||||
|
|
||||||
/@types/webrtc@0.0.36:
|
/@types/webrtc@0.0.36:
|
||||||
resolution: {integrity: sha512-tYFarc92EluXU7XyRmWbkQXSbZIOHTdDOudFPal9u/TNTQuouWpIHV/2o9bNAdqvTJFjLJh/zflCOLWbL30tEQ==}
|
resolution: {integrity: sha512-tYFarc92EluXU7XyRmWbkQXSbZIOHTdDOudFPal9u/TNTQuouWpIHV/2o9bNAdqvTJFjLJh/zflCOLWbL30tEQ==}
|
||||||
|
@ -10906,7 +10910,6 @@ packages:
|
||||||
/uuid@9.0.0:
|
/uuid@9.0.0:
|
||||||
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
|
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: false
|
|
||||||
|
|
||||||
/v8-compile-cache-lib@3.0.1:
|
/v8-compile-cache-lib@3.0.1:
|
||||||
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
|
||||||
|
@ -11377,14 +11380,15 @@ packages:
|
||||||
file:bare-client-custom:
|
file:bare-client-custom:
|
||||||
resolution: {directory: bare-client-custom, type: directory}
|
resolution: {directory: bare-client-custom, type: directory}
|
||||||
name: bare-client-custom
|
name: bare-client-custom
|
||||||
|
version: 2.2.0-alpha
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/uuid': 9.0.2
|
'@types/uuid': 9.0.2
|
||||||
uuid: 9.0.0
|
uuid: 9.0.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
file:corium:
|
file:corium:
|
||||||
resolution: {directory: corium, type: directory}
|
resolution: {directory: corium, type: directory}
|
||||||
name: corium
|
name: corium
|
||||||
|
version: 1.0.0-alpha.2
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/browser': 3.28.0
|
'@rollup/browser': 3.28.0
|
||||||
'@swc/helpers': 0.4.14
|
'@swc/helpers': 0.4.14
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue