crossws 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +155 -56
  2. package/adapters/bun.d.ts +1 -0
  3. package/adapters/cloudflare.d.ts +1 -0
  4. package/adapters/deno.d.ts +1 -0
  5. package/adapters/node.d.ts +1 -0
  6. package/dist/adapters/bun.cjs +44 -29
  7. package/dist/adapters/bun.d.cts +5 -35
  8. package/dist/adapters/bun.d.mts +5 -35
  9. package/dist/adapters/bun.d.ts +5 -35
  10. package/dist/adapters/bun.mjs +44 -26
  11. package/dist/adapters/cloudflare.cjs +52 -0
  12. package/dist/adapters/cloudflare.d.cts +12 -0
  13. package/dist/adapters/cloudflare.d.mts +12 -0
  14. package/dist/adapters/cloudflare.d.ts +12 -0
  15. package/dist/adapters/cloudflare.mjs +50 -0
  16. package/dist/adapters/deno.cjs +20 -29
  17. package/dist/adapters/deno.d.cts +2 -10
  18. package/dist/adapters/deno.d.mts +2 -10
  19. package/dist/adapters/deno.d.ts +2 -10
  20. package/dist/adapters/deno.mjs +20 -26
  21. package/dist/adapters/node.cjs +57 -3891
  22. package/dist/adapters/node.d.cts +36 -37
  23. package/dist/adapters/node.d.mts +36 -37
  24. package/dist/adapters/node.d.ts +36 -37
  25. package/dist/adapters/node.mjs +48 -3872
  26. package/dist/index.cjs +5 -5
  27. package/dist/index.d.cts +40 -10
  28. package/dist/index.d.mts +40 -10
  29. package/dist/index.d.ts +40 -10
  30. package/dist/index.mjs +4 -4
  31. package/dist/shared/{crossws.002417e5.cjs → crossws.21e14e0d.cjs} +7 -4
  32. package/dist/shared/crossws.2ed26345.cjs +3931 -0
  33. package/dist/shared/{crossws.08866fa6.mjs → crossws.9536f626.mjs} +7 -4
  34. package/dist/shared/crossws.a5db571c.mjs +3910 -0
  35. package/dist/websocket/index.cjs +5 -0
  36. package/dist/websocket/index.d.cts +10 -0
  37. package/dist/websocket/index.d.mts +10 -0
  38. package/dist/websocket/index.d.ts +10 -0
  39. package/dist/websocket/index.mjs +3 -0
  40. package/dist/websocket/node.cjs +17 -0
  41. package/dist/websocket/node.d.cts +10 -0
  42. package/dist/websocket/node.d.mts +10 -0
  43. package/dist/websocket/node.d.ts +10 -0
  44. package/dist/websocket/node.mjs +15 -0
  45. package/package.json +44 -17
  46. package/websocket.d.ts +1 -0
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const index = globalThis.WebSocket;
4
+
5
+ module.exports = index;
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,3 @@
1
+ const index = globalThis.WebSocket;
2
+
3
+ export { index as default };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ require('stream');
4
+ const websocket = require('../shared/crossws.2ed26345.cjs');
5
+ require('events');
6
+ require('http');
7
+ require('crypto');
8
+ require('https');
9
+ require('net');
10
+ require('tls');
11
+ require('url');
12
+ require('zlib');
13
+ require('buffer');
14
+
15
+ const node = globalThis.WebSocket || websocket._WebSocket;
16
+
17
+ module.exports = node;
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket;
3
+ prototype: WebSocket;
4
+ readonly CONNECTING: 0;
5
+ readonly OPEN: 1;
6
+ readonly CLOSING: 2;
7
+ readonly CLOSED: 3;
8
+ };
9
+
10
+ export { _default as default };
@@ -0,0 +1,15 @@
1
+ import 'stream';
2
+ import { _ as _WebSocket } from '../shared/crossws.a5db571c.mjs';
3
+ import 'events';
4
+ import 'http';
5
+ import 'crypto';
6
+ import 'https';
7
+ import 'net';
8
+ import 'tls';
9
+ import 'url';
10
+ import 'zlib';
11
+ import 'buffer';
12
+
13
+ const node = globalThis.WebSocket || _WebSocket;
14
+
15
+ export { node as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "crossws",
3
- "version": "0.0.1",
4
- "description": "",
3
+ "version": "0.1.0",
4
+ "description": "Cross-platform WebSocket Servers for Node.js, Deno, Bun and Cloudflare Workers",
5
5
  "repository": "unjs/crossws",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
@@ -12,6 +12,24 @@
12
12
  "import": "./dist/index.mjs",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./websocket": {
16
+ "types": {
17
+ "import": "./dist/websocket/index.d.mts",
18
+ "require": "./dist/websocket/index.d.cts"
19
+ },
20
+ "browser": "./dist/websocket/index.mjs",
21
+ "worker": "./dist/websocket/index.mjs",
22
+ "bun": "./dist/websocket/index.mjs",
23
+ "deno": "./dist/websocket/index.mjs",
24
+ "edge-light": "./dist/websocket/index.mjs",
25
+ "workerd": "./dist/websocket/index.mjs",
26
+ "node": {
27
+ "import": "./dist/websocket/node.mjs",
28
+ "require": "./dist/websocket/node.cjs"
29
+ },
30
+ "import": "./dist/websocket/index.mjs",
31
+ "require": "./dist/websocket/index.cjs"
32
+ },
15
33
  "./adapters/bun": {
16
34
  "types": "./dist/adapters/bun.d.ts",
17
35
  "import": "./dist/adapters/bun.mjs",
@@ -22,6 +40,11 @@
22
40
  "import": "./dist/adapters/deno.mjs",
23
41
  "require": "./dist/adapters/deno.cjs"
24
42
  },
43
+ "./adapters/cloudflare": {
44
+ "types": "./dist/adapters/cloudflare.d.ts",
45
+ "import": "./dist/adapters/cloudflare.mjs",
46
+ "require": "./dist/adapters/cloudflare.cjs"
47
+ },
25
48
  "./adapters/node": {
26
49
  "types": "./dist/adapters/node.d.ts",
27
50
  "import": "./dist/adapters/node.mjs",
@@ -32,36 +55,40 @@
32
55
  "module": "./dist/index.mjs",
33
56
  "types": "./dist/index.d.ts",
34
57
  "files": [
35
- "dist"
58
+ "dist",
59
+ "adapters",
60
+ "*.d.ts"
36
61
  ],
37
62
  "scripts": {
38
63
  "build": "unbuild",
39
- "dev": "vitest dev",
40
64
  "play:node": "jiti playground/node.ts",
41
65
  "play:bun": "bun playground/bun.ts",
42
66
  "play:deno": "deno run -A playground/deno.ts",
43
- "lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
44
- "lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w",
67
+ "play:cf": "wrangler dev --port 3001",
68
+ "lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src",
69
+ "lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src -w",
45
70
  "prepack": "pnpm run build",
46
71
  "release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
47
- "test": "pnpm lint && pnpm test:types && vitest run --coverage",
72
+ "test": "pnpm lint && pnpm test:types",
48
73
  "test:types": "tsc --noEmit --skipLibCheck"
49
74
  },
50
75
  "devDependencies": {
51
- "@types/node": "^20.10.3",
52
- "@types/web": "^0.0.125",
76
+ "@cloudflare/workers-types": "^4.20240117.0",
77
+ "@types/node": "^20.11.10",
78
+ "@types/web": "^0.0.135",
53
79
  "@types/ws": "^8.5.10",
54
- "@vitest/coverage-v8": "^1.0.1",
80
+ "bun-types": "^1.0.25",
55
81
  "changelogen": "^0.5.5",
56
- "eslint": "^8.55.0",
82
+ "consola": "^3.2.3",
83
+ "eslint": "^8.56.0",
57
84
  "eslint-config-unjs": "^0.2.1",
58
85
  "jiti": "^1.21.0",
59
- "prettier": "^3.1.0",
60
- "typescript": "^5.3.2",
86
+ "prettier": "^3.2.4",
87
+ "typescript": "^5.3.3",
61
88
  "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.33.0",
62
89
  "unbuild": "^2.0.0",
63
- "vitest": "^1.0.1",
64
- "ws": "^8.14.2"
90
+ "wrangler": "^3.25.0",
91
+ "ws": "^8.16.0"
65
92
  },
66
- "packageManager": "pnpm@8.11.0"
67
- }
93
+ "packageManager": "pnpm@8.15.0"
94
+ }
package/websocket.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/websocket";