Skip to content

Commit

Permalink
refactor: use @deno/types
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 30, 2024
1 parent a607b89 commit 0026087
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10,222 deletions.
2 changes: 1 addition & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineBuildConfig({
rollup: {
inlineDependencies: true,
},
externals: ["@cloudflare/workers-types", "bun"],
externals: ["@cloudflare/workers-types", "bun", "@deno/types"],
hooks: {
async "build:done"(ctx) {
const entries = Object.keys(ctx.pkg.exports || {})
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20240117.0",
"@deno/types": "^0.0.1",
"@types/bun": "^1.0.4",
"@types/node": "^20.11.10",
"@types/web": "^0.0.135",
Expand Down
4 changes: 4 additions & 0 deletions playground/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import type * as _Deno from "../types/lib.deno.d.ts";

import { createDemo, getIndexHTML } from "./_common.ts";

declare global {
const Deno: typeof import("@deno/types").Deno;
}

const adapter = createDemo(denoAdapter);

Deno.serve({ port: 3001 }, async (req) => {
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/adapters/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// https://deno.land/api?s=Deno.upgradeWebSocket
// https://examples.deno.land/http-server-websocket

import "../../types/lib.deno.d.ts";

import { WebSocketMessage } from "../message";
import { WebSocketError } from "../error";
import { WebSocketPeerBase } from "../peer";
Expand All @@ -15,6 +13,10 @@ export interface Adapter {
handleUpgrade(req: Request): Response;
}

declare global {
const Deno: typeof import("@deno/types").Deno;
}

export default defineWebSocketAdapter<Adapter, AdapterOptions>(
(hooks, opts = {}) => {
const handleUpgrade = (request: Request) => {
Expand Down
Loading

0 comments on commit 0026087

Please sign in to comment.