3
3
/// <reference path="../../core/internal.d.ts" />
4
4
5
5
const core = globalThis . Deno . core ;
6
- const ops = core . ops ;
6
+ const { opAsync, opAsync2 } = core ;
7
+ // deno-lint-ignore camelcase
8
+ const op_ws_check_permission_and_cancel_handle =
9
+ core . ops . op_ws_check_permission_and_cancel_handle ;
7
10
import { URL } from "ext:deno_url/00_url.js" ;
8
11
import * as webidl from "ext:deno_webidl/00_webidl.js" ;
9
12
import { HTTP_TOKEN_CODE_POINT_RE } from "ext:deno_web/00_infra.js" ;
@@ -210,7 +213,7 @@ class WebSocket extends EventTarget {
210
213
this [ _url ] = wsURL . href ;
211
214
this [ _role ] = CLIENT ;
212
215
213
- ops . op_ws_check_permission_and_cancel_handle (
216
+ op_ws_check_permission_and_cancel_handle (
214
217
"WebSocket.abort()" ,
215
218
this [ _url ] ,
216
219
false ,
@@ -247,7 +250,7 @@ class WebSocket extends EventTarget {
247
250
}
248
251
249
252
PromisePrototypeThen (
250
- core . opAsync (
253
+ opAsync (
251
254
"op_ws_create" ,
252
255
"new WebSocket()" ,
253
256
wsURL . href ,
@@ -260,7 +263,7 @@ class WebSocket extends EventTarget {
260
263
261
264
if ( this [ _readyState ] === CLOSING ) {
262
265
PromisePrototypeThen (
263
- core . opAsync ( "op_ws_close" , this [ _rid ] ) ,
266
+ opAsync ( "op_ws_close" , this [ _rid ] ) ,
264
267
( ) => {
265
268
this [ _readyState ] = CLOSED ;
266
269
@@ -316,7 +319,7 @@ class WebSocket extends EventTarget {
316
319
const sendTypedArray = ( view , byteLength ) => {
317
320
this [ _bufferedAmount ] += byteLength ;
318
321
PromisePrototypeThen (
319
- core . opAsync2 (
322
+ opAsync2 (
320
323
"op_ws_send_binary" ,
321
324
this [ _rid ] ,
322
325
view ,
@@ -345,16 +348,13 @@ class WebSocket extends EventTarget {
345
348
sendTypedArray ( data , TypedArrayPrototypeGetByteLength ( data ) ) ;
346
349
}
347
350
} else if ( ObjectPrototypeIsPrototypeOf ( ArrayBufferPrototype , data ) ) {
348
- sendTypedArray (
349
- new DataView ( data ) ,
350
- ArrayBufferPrototypeGetByteLength ( data ) ,
351
- ) ;
351
+ sendTypedArray ( data , ArrayBufferPrototypeGetByteLength ( data ) ) ;
352
352
} else {
353
353
const string = String ( data ) ;
354
354
const d = core . encode ( string ) ;
355
355
this [ _bufferedAmount ] += TypedArrayPrototypeGetByteLength ( d ) ;
356
356
PromisePrototypeThen (
357
- core . opAsync2 (
357
+ opAsync2 (
358
358
"op_ws_send_text" ,
359
359
this [ _rid ] ,
360
360
string ,
@@ -413,7 +413,7 @@ class WebSocket extends EventTarget {
413
413
this [ _readyState ] = CLOSING ;
414
414
415
415
PromisePrototypeCatch (
416
- core . opAsync (
416
+ opAsync (
417
417
"op_ws_close" ,
418
418
this [ _rid ] ,
419
419
code ,
@@ -438,7 +438,7 @@ class WebSocket extends EventTarget {
438
438
439
439
async [ _eventLoop ] ( ) {
440
440
while ( this [ _readyState ] !== CLOSED ) {
441
- const { 0 : kind , 1 : value } = await core . opAsync2 (
441
+ const { 0 : kind , 1 : value } = await opAsync2 (
442
442
"op_ws_next_event" ,
443
443
this [ _rid ] ,
444
444
) ;
@@ -501,7 +501,7 @@ class WebSocket extends EventTarget {
501
501
502
502
if ( prevState === OPEN ) {
503
503
try {
504
- await core . opAsync (
504
+ await opAsync (
505
505
"op_ws_close" ,
506
506
this [ _rid ] ,
507
507
code ,
@@ -530,12 +530,12 @@ class WebSocket extends EventTarget {
530
530
clearTimeout ( this [ _idleTimeoutTimeout ] ) ;
531
531
this [ _idleTimeoutTimeout ] = setTimeout ( async ( ) => {
532
532
if ( this [ _readyState ] === OPEN ) {
533
- await core . opAsync ( "op_ws_send_ping" , this [ _rid ] ) ;
533
+ await opAsync ( "op_ws_send_ping" , this [ _rid ] ) ;
534
534
this [ _idleTimeoutTimeout ] = setTimeout ( async ( ) => {
535
535
if ( this [ _readyState ] === OPEN ) {
536
536
this [ _readyState ] = CLOSING ;
537
537
const reason = "No response from ping frame." ;
538
- await core . opAsync (
538
+ await opAsync (
539
539
"op_ws_close" ,
540
540
this [ _rid ] ,
541
541
1001 ,
0 commit comments