File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ type ContextData = {
2626
2727// https://bun.sh/docs/api/websockets
2828const bunAdapter : Adapter < BunAdapter , BunOptions > = ( options = { } ) => {
29+ if ( typeof Bun === "undefined" ) {
30+ // eslint-disable-next-line unicorn/prefer-type-error
31+ throw new Error (
32+ "[crossws] Using Bun adapter in an incompatible environment. (https://srvx.h3.dev/guide/bundler)" ,
33+ ) ;
34+ }
35+
2936 const hooks = new AdapterHookable ( options ) ;
3037 const peers = new Set < BunPeer > ( ) ;
3138 return {
Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ type ServeHandlerInfo = {
2525// https://deno.land/api?s=Deno.upgradeWebSocket
2626// https://examples.deno.land/http-server-websocket
2727const denoAdapter : Adapter < DenoAdapter , DenoOptions > = ( options = { } ) => {
28+ if ( typeof Deno === "undefined" ) {
29+ // eslint-disable-next-line unicorn/prefer-type-error
30+ throw new Error (
31+ "[crossws] Using Deno adapter in an incompatible environment (https://srvx.h3.dev/guide/bundler)." ,
32+ ) ;
33+ }
34+
2835 const hooks = new AdapterHookable ( options ) ;
2936 const peers = new Set < DenoPeer > ( ) ;
3037 return {
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ export interface NodeOptions extends AdapterOptions {
4444// https://github.com/websockets/ws
4545// https://github.com/websockets/ws/blob/master/doc/ws.md
4646const nodeAdapter : Adapter < NodeAdapter , NodeOptions > = ( options = { } ) => {
47+ if ( "Deno" in globalThis || "Bun" in globalThis ) {
48+ throw new Error (
49+ "[crossws] Using Node.js adapter in an incompatible environment (https://srvx.h3.dev/guide/bundler)." ,
50+ ) ;
51+ }
52+
4753 const hooks = new AdapterHookable ( options ) ;
4854 const peers = new Set < NodePeer > ( ) ;
4955
You can’t perform that action at this time.
0 commit comments