diff --git a/build.config.ts b/build.config.ts
index 6e7f730..373fb2c 100644
--- a/build.config.ts
+++ b/build.config.ts
@@ -4,4 +4,5 @@ export default defineBuildConfig({
rollup: {
inlineDependencies: true,
},
+ externals: ["@cloudflare/workers-types"],
});
diff --git a/playground/bun.ts b/playground/bun.ts
index e8b7d58..de69f0b 100644
--- a/playground/bun.ts
+++ b/playground/bun.ts
@@ -1,7 +1,5 @@
// You can run this demo using `bun --bun ./bun.ts` or `npm run play:bun` in repo
-///
-
import bunAdapter from "../src/adapters/bun";
import { createDemo, getIndexHTMLURL } from "./_common";
diff --git a/playground/cloudflare.ts b/playground/cloudflare.ts
index b9b760d..838ebb5 100644
--- a/playground/cloudflare.ts
+++ b/playground/cloudflare.ts
@@ -1,6 +1,6 @@
// You can run this demo using `npm run play:cf` in repo
-///
+import type { Request, ExecutionContext } from "@cloudflare/workers-types";
import cloudflareAdapter from "../src/adapters/cloudflare";
diff --git a/src/adapters/bun.ts b/src/adapters/bun.ts
index fb31e70..5ce2046 100644
--- a/src/adapters/bun.ts
+++ b/src/adapters/bun.ts
@@ -1,6 +1,7 @@
// https://bun.sh/docs/api/websockets
-///
+// @ts-nocheck
+import type * as _bun from "bun-types";
import { WebSocketMessage } from "../message";
// import { WebSocketError } from "../error";
diff --git a/src/adapters/cloudflare.ts b/src/adapters/cloudflare.ts
index 9d79ee8..35b991e 100644
--- a/src/adapters/cloudflare.ts
+++ b/src/adapters/cloudflare.ts
@@ -1,6 +1,6 @@
// https://developers.cloudflare.com/workers/examples/websockets/
-///
+import type * as _cf from "@cloudflare/workers-types";
import { WebSocketPeer } from "../peer";
import { defineWebSocketAdapter } from "../adapter.js";
@@ -9,18 +9,25 @@ import { WebSocketError } from "../error";
type Env = Record;
+declare const WebSocketPair: typeof _cf.WebSocketPair;
+declare const Response: typeof _cf.Response;
+
export interface AdapterOptions {}
export interface Adapter {
- handleUpgrade(req: Request, env: Env, context: ExecutionContext): Response;
+ handleUpgrade(
+ req: _cf.Request,
+ env: Env,
+ context: _cf.ExecutionContext,
+ ): _cf.Response;
}
export default defineWebSocketAdapter(
(handler, opts = {}) => {
const handleUpgrade = (
- req: Request,
+ req: _cf.Request,
env: Env,
- context: ExecutionContext,
+ context: _cf.ExecutionContext,
) => {
const pair = new WebSocketPair();
const client = pair[0];
@@ -60,8 +67,8 @@ export default defineWebSocketAdapter(
class CloudflareWebSocketPeer extends WebSocketPeer {
constructor(
- private _client: WebSocket,
- private _server: WebSocket,
+ private _client: _cf.WebSocket,
+ private _server: _cf.WebSocket,
) {
super();
}
diff --git a/src/adapters/deno.ts b/src/adapters/deno.ts
index 155c782..e9c9f6e 100644
--- a/src/adapters/deno.ts
+++ b/src/adapters/deno.ts
@@ -3,7 +3,7 @@
// https://examples.deno.land/http-server-websocket
// @ts-nocheck
-import type * as _DENO_TYPES_ from "../../types/lib.deno.d.ts";
+import type * as _deno from "../../types/lib.deno.d.ts";
import { WebSocketMessage } from "../message";
import { WebSocketError } from "../error";
diff --git a/tsconfig.json b/tsconfig.json
index e9588d9..424cd44 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,6 +4,7 @@
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true,
+ "skipLibCheck": true,
"strict": true
},
"include": ["src"]