chemicaljs 1.6.1 → 1.6.2

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 (59) hide show
  1. package/README.md +3 -3
  2. package/examples/example/index.js +1 -1
  3. package/examples/example/package-lock.json +4 -4
  4. package/examples/example/package.json +1 -1
  5. package/examples/example-build/index.js +1 -1
  6. package/examples/example-build/package-lock.json +4 -4
  7. package/examples/example-build/package.json +1 -1
  8. package/examples/example-components/index.js +1 -1
  9. package/examples/example-components/package-lock.json +4 -4
  10. package/examples/example-components/package.json +1 -1
  11. package/examples/example-styled/index.js +1 -1
  12. package/examples/example-styled/package-lock.json +4 -4
  13. package/examples/example-styled/package.json +1 -1
  14. package/examples/example-vite/index.js +1 -1
  15. package/examples/example-vite/package-lock.json +4 -4
  16. package/examples/example-vite/package.json +1 -1
  17. package/index.js +30 -23
  18. package/package.json +1 -1
  19. package/update.bash +3 -0
  20. package/dist/baremux/baretypes.d.ts +0 -22
  21. package/dist/baremux/client.d.ts +0 -73
  22. package/dist/baremux/connection.d.ts +0 -43
  23. package/dist/baremux/index.d.ts +0 -9
  24. package/dist/baremux/index.js +0 -542
  25. package/dist/baremux/index.js.map +0 -1
  26. package/dist/baremux/index.mjs +0 -525
  27. package/dist/baremux/index.mjs.map +0 -1
  28. package/dist/baremux/snapshot.d.ts +0 -44
  29. package/dist/baremux/worker.d.ts +0 -1
  30. package/dist/baremux/worker.js +0 -166
  31. package/dist/baremux/worker.js.map +0 -1
  32. package/dist/baremux/workerHandlers.d.ts +0 -5
  33. package/dist/chemical.js +0 -268
  34. package/dist/chemical.sw.js +0 -38
  35. package/dist/epoxy/index.js +0 -1615
  36. package/dist/epoxy/index.mjs +0 -1562
  37. package/dist/libcurl/index.cjs +0 -6634
  38. package/dist/libcurl/index.js +0 -6634
  39. package/dist/libcurl/index.mjs +0 -6589
  40. package/dist/scramjet/scramjet.bundle.js +0 -7
  41. package/dist/scramjet/scramjet.bundle.js.map +0 -7
  42. package/dist/scramjet/scramjet.client.js +0 -1
  43. package/dist/scramjet/scramjet.client.js.map +0 -7
  44. package/dist/scramjet/scramjet.codecs.js +0 -3
  45. package/dist/scramjet/scramjet.codecs.js.map +0 -7
  46. package/dist/scramjet/scramjet.config.js +0 -9
  47. package/dist/scramjet/scramjet.config.js.map +0 -7
  48. package/dist/scramjet/scramjet.worker.js +0 -42
  49. package/dist/scramjet/scramjet.worker.js.map +0 -7
  50. package/dist/uv/sw.js +0 -24
  51. package/dist/uv/uv.bundle.js +0 -8
  52. package/dist/uv/uv.bundle.js.map +0 -7
  53. package/dist/uv/uv.client.js +0 -5
  54. package/dist/uv/uv.client.js.map +0 -7
  55. package/dist/uv/uv.config.js +0 -10
  56. package/dist/uv/uv.handler.js +0 -2
  57. package/dist/uv/uv.handler.js.map +0 -7
  58. package/dist/uv/uv.sw.js +0 -45
  59. package/dist/uv/uv.sw.js.map +0 -7
package/README.md CHANGED
@@ -51,10 +51,10 @@ chemical.app.get("/", function(req, res){
51
51
  });
52
52
  ```
53
53
 
54
- 4. Use `chemical.server` and listen on a port of your choosing.
54
+ 4. Use `chemical.listen` on a port of your choosing.
55
55
 
56
56
  ```js
57
- chemical.server.listen(3000);
57
+ chemical.listen(3000);
58
58
  ```
59
59
 
60
60
  Below is an example of a simple backend. This example will setup Chemical and serve the "public" folder along with the `index.html` file as `/` and `.html` files without the extension.
@@ -71,7 +71,7 @@ chemical.app.use(express.static("public", {
71
71
  extensions: ["html"]
72
72
  }));
73
73
 
74
- chemical.server.listen(port, () => {
74
+ chemical.listen(port, () => {
75
75
  console.log(`Chemical demo listening on port ${port}`);
76
76
  });
77
77
  ```
@@ -9,6 +9,6 @@ chemical.app.use(express.static("public", {
9
9
  extensions: ["html"]
10
10
  }));
11
11
 
12
- chemical.server.listen(port, () => {
12
+ chemical.listen(port, () => {
13
13
  console.log(`Chemical example listening on port ${port}`);
14
14
  });
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "chemicaljs": "^1.6.0",
12
+ "chemicaljs": "^1.6.1",
13
13
  "express": "^4.19.2"
14
14
  }
15
15
  },
@@ -1167,9 +1167,9 @@
1167
1167
  }
1168
1168
  },
1169
1169
  "node_modules/chemicaljs": {
1170
- "version": "1.6.0",
1171
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.0.tgz",
1172
- "integrity": "sha512-k5TOed003eTwczb88OSMpXl0hFQANvvX+7EHnWZvoe1vdOg2KUeHA40slO+b+cdbiVvL+UAO4b8/E5dqrw6gPA==",
1170
+ "version": "1.6.1",
1171
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
1172
+ "integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
1173
1173
  "dependencies": {
1174
1174
  "@mercuryworkshop/bare-mux": "^2.0.4",
1175
1175
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/chemicaljs/chemical#readme",
20
20
  "dependencies": {
21
- "chemicaljs": "^1.6.0",
21
+ "chemicaljs": "^1.6.1",
22
22
  "express": "^4.19.2"
23
23
  }
24
24
  }
@@ -11,6 +11,6 @@ chemical.app.use(express.static("public", {
11
11
  extensions: ["html"]
12
12
  }));
13
13
 
14
- chemical.server.listen(port, () => {
14
+ chemical.listen(port, () => {
15
15
  console.log(`Chemical example build listening on port ${port}`);
16
16
  });
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "chemicaljs": "^1.6.0",
12
+ "chemicaljs": "^1.6.1",
13
13
  "express": "^4.19.2"
14
14
  }
15
15
  },
@@ -1167,9 +1167,9 @@
1167
1167
  }
1168
1168
  },
1169
1169
  "node_modules/chemicaljs": {
1170
- "version": "1.6.0",
1171
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.0.tgz",
1172
- "integrity": "sha512-k5TOed003eTwczb88OSMpXl0hFQANvvX+7EHnWZvoe1vdOg2KUeHA40slO+b+cdbiVvL+UAO4b8/E5dqrw6gPA==",
1170
+ "version": "1.6.1",
1171
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
1172
+ "integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
1173
1173
  "dependencies": {
1174
1174
  "@mercuryworkshop/bare-mux": "^2.0.4",
1175
1175
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "homepage": "https://github.com/chemicaljs/chemical#readme",
21
21
  "dependencies": {
22
- "chemicaljs": "^1.6.0",
22
+ "chemicaljs": "^1.6.1",
23
23
  "express": "^4.19.2"
24
24
  }
25
25
  }
@@ -9,6 +9,6 @@ chemical.app.use(express.static("public", {
9
9
  extensions: ["html"]
10
10
  }));
11
11
 
12
- chemical.server.listen(port, () => {
12
+ chemical.listen(port, () => {
13
13
  console.log(`Chemical example components listening on port ${port}`);
14
14
  });
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "chemicaljs": "^1.6.0",
12
+ "chemicaljs": "^1.6.1",
13
13
  "express": "^4.19.2"
14
14
  }
15
15
  },
@@ -1167,9 +1167,9 @@
1167
1167
  }
1168
1168
  },
1169
1169
  "node_modules/chemicaljs": {
1170
- "version": "1.6.0",
1171
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.0.tgz",
1172
- "integrity": "sha512-k5TOed003eTwczb88OSMpXl0hFQANvvX+7EHnWZvoe1vdOg2KUeHA40slO+b+cdbiVvL+UAO4b8/E5dqrw6gPA==",
1170
+ "version": "1.6.1",
1171
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
1172
+ "integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
1173
1173
  "dependencies": {
1174
1174
  "@mercuryworkshop/bare-mux": "^2.0.4",
1175
1175
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/chemicaljs/chemical#readme",
20
20
  "dependencies": {
21
- "chemicaljs": "^1.6.0",
21
+ "chemicaljs": "^1.6.1",
22
22
  "express": "^4.19.2"
23
23
  }
24
24
  }
@@ -9,6 +9,6 @@ chemical.app.use(express.static("public", {
9
9
  extensions: ["html"]
10
10
  }));
11
11
 
12
- chemical.server.listen(port, () => {
12
+ chemical.listen(port, () => {
13
13
  console.log(`Chemical example styled listening on port ${port}`);
14
14
  });
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "chemicaljs": "^1.6.0",
12
+ "chemicaljs": "^1.6.1",
13
13
  "express": "^4.19.2"
14
14
  }
15
15
  },
@@ -1167,9 +1167,9 @@
1167
1167
  }
1168
1168
  },
1169
1169
  "node_modules/chemicaljs": {
1170
- "version": "1.6.0",
1171
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.0.tgz",
1172
- "integrity": "sha512-k5TOed003eTwczb88OSMpXl0hFQANvvX+7EHnWZvoe1vdOg2KUeHA40slO+b+cdbiVvL+UAO4b8/E5dqrw6gPA==",
1170
+ "version": "1.6.1",
1171
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
1172
+ "integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
1173
1173
  "dependencies": {
1174
1174
  "@mercuryworkshop/bare-mux": "^2.0.4",
1175
1175
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/chemicaljs/chemical#readme",
20
20
  "dependencies": {
21
- "chemicaljs": "^1.6.0",
21
+ "chemicaljs": "^1.6.1",
22
22
  "express": "^4.19.2"
23
23
  }
24
24
  }
@@ -9,6 +9,6 @@ chemical.app.use(express.static("dist", {
9
9
  extensions: ["html"]
10
10
  }));
11
11
 
12
- chemical.server.listen(port, () => {
12
+ chemical.listen(port, () => {
13
13
  console.log(`Chemical example vite listening on port ${port}`);
14
14
  });
@@ -6,7 +6,7 @@
6
6
  "": {
7
7
  "name": "chemical-example-vite",
8
8
  "dependencies": {
9
- "chemicaljs": "^1.6.0",
9
+ "chemicaljs": "^1.6.1",
10
10
  "express": "^4.19.2",
11
11
  "preact": "^10.23.1"
12
12
  },
@@ -1730,9 +1730,9 @@
1730
1730
  }
1731
1731
  },
1732
1732
  "node_modules/chemicaljs": {
1733
- "version": "1.6.0",
1734
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.0.tgz",
1735
- "integrity": "sha512-k5TOed003eTwczb88OSMpXl0hFQANvvX+7EHnWZvoe1vdOg2KUeHA40slO+b+cdbiVvL+UAO4b8/E5dqrw6gPA==",
1733
+ "version": "1.6.1",
1734
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.6.1.tgz",
1735
+ "integrity": "sha512-iolcUgXd4eHC9vB6/7CMXIOpRNEEErO5SMPCv54h0wgPdnoOP/pfZqseYgDfyMl398zKDCWSC5x8GPhLaqNK4g==",
1736
1736
  "dependencies": {
1737
1737
  "@mercuryworkshop/bare-mux": "^2.0.4",
1738
1738
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
@@ -8,7 +8,7 @@
8
8
  "build": "vite build"
9
9
  },
10
10
  "dependencies": {
11
- "chemicaljs": "^1.6.0",
11
+ "chemicaljs": "^1.6.1",
12
12
  "express": "^4.19.2",
13
13
  "preact": "^10.23.1"
14
14
  },
package/index.js CHANGED
@@ -38,6 +38,13 @@ class ChemicalServer {
38
38
  options.rammerhead = true;
39
39
  }
40
40
 
41
+ this.options = options;
42
+
43
+ this.app = express();
44
+ }
45
+ listen(port, callback) {
46
+ const server = createServer();
47
+
41
48
  const rh = createRammerhead()
42
49
 
43
50
  const rammerheadScopes = [
@@ -75,14 +82,12 @@ class ChemicalServer {
75
82
  rh.emit("upgrade", req, socket, head)
76
83
  }
77
84
 
78
- this.server = createServer();
79
- this.app = express();
80
- this.app.get("/chemical.js", async function (req, res) {
85
+ this.app.get("/chemical.js", async (req, res) => {
81
86
  let chemicalMain = await readFileSync(resolve(__dirname, "client/chemical.js"), "utf8");
82
87
 
83
- if (options.default) {
84
- if (["uv", "rammerhead", "scramjet"].includes(options.default)) {
85
- chemicalMain = `const defaultService = "${options.default}";\n\n` + chemicalMain
88
+ if (this.options.default) {
89
+ if (["uv", "rammerhead", "scramjet"].includes(this.options.default)) {
90
+ chemicalMain = `const defaultService = "${this.options.default}";\n\n` + chemicalMain
86
91
  } else {
87
92
  chemicalMain = `const defaultService = "uv";\n\n` + chemicalMain
88
93
  console.error("Error: Chemical default option invalid.")
@@ -91,19 +96,19 @@ class ChemicalServer {
91
96
  chemicalMain = `const defaultService = "uv";\n\n` + chemicalMain;
92
97
  }
93
98
 
94
- chemicalMain = "const uvEnabled = " + String(options.uv) + ";\n" + chemicalMain
95
- chemicalMain = "const scramjetEnabled = " + String(options.scramjet) + ";\n" + chemicalMain
96
- chemicalMain = "const rammerheadEnabled = " + String(options.rammerhead) + ";\n" + chemicalMain
99
+ chemicalMain = "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalMain
100
+ chemicalMain = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalMain
101
+ chemicalMain = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalMain
97
102
 
98
103
  res.type("application/javascript");
99
104
  return res.send(chemicalMain);
100
105
  });
101
- this.app.get("/chemical.sw.js", async function (req, res) {
106
+ this.app.get("/chemical.sw.js", async (req, res) => {
102
107
  let chemicalSW = await readFileSync(resolve(__dirname, "client/chemical.sw.js"), "utf8");
103
108
 
104
- chemicalSW = "const uvEnabled = " + String(options.uv) + ";\n" + chemicalSW
105
- chemicalSW = "const scramjetEnabled = " + String(options.scramjet) + ";\n" + chemicalSW
106
- chemicalSW = "const rammerheadEnabled = " + String(options.rammerhead) + ";\n" + chemicalSW
109
+ chemicalSW = "const uvEnabled = " + String(this.options.uv) + ";\n" + chemicalSW
110
+ chemicalSW = "const scramjetEnabled = " + String(this.options.scramjet) + ";\n" + chemicalSW
111
+ chemicalSW = "const rammerheadEnabled = " + String(this.options.rammerhead) + ";\n" + chemicalSW
107
112
 
108
113
  res.type("application/javascript");
109
114
  return res.send(chemicalSW);
@@ -112,36 +117,38 @@ class ChemicalServer {
112
117
  this.app.use("/baremux/", express.static(baremuxPath));
113
118
  this.app.use("/libcurl/", express.static(libcurlPath));
114
119
  this.app.use("/epoxy/", express.static(epoxyPath));
115
- if (options.uv) {
120
+ if (this.options.uv) {
116
121
  this.app.use("/uv/", express.static(resolve(__dirname, "config/uv")));
117
122
  this.app.use("/uv/", express.static(uvPath));
118
123
  }
119
- if (options.scramjet) {
124
+ if (this.options.scramjet) {
120
125
  this.app.use("/scramjet/", express.static(resolve(__dirname, "config/scramjet")));
121
126
  this.app.use("/scramjet/", express.static(scramjetPath));
122
127
  }
123
- this.server.on("request", (req, res) => {
124
- if (options.rammerhead && shouldRouteRh(req)) {
128
+ server.on("request", (req, res) => {
129
+ if (this.options.rammerhead && shouldRouteRh(req)) {
125
130
  routeRhRequest(req, res);
126
131
  } else {
127
132
  this.app(req, res);
128
133
  }
129
134
  });
130
- this.server.on("upgrade", (req, socket, head) => {
135
+ server.on("upgrade", (req, socket, head) => {
131
136
  if (req.url && req.url.endsWith("/wisp/")) {
132
- if (options.hostname_blacklist) {
133
- wisp.options.hostname_blacklist = options.hostname_blacklist
137
+ if (this.options.hostname_blacklist) {
138
+ wisp.this.options.hostname_blacklist = this.options.hostname_blacklist
134
139
  }
135
- if (options.hostname_whitelist) {
136
- wisp.options.hostname_whitelist = options.hostname_whitelist
140
+ if (this.options.hostname_whitelist) {
141
+ wisp.this.options.hostname_whitelist = this.options.hostname_whitelist
137
142
  }
138
143
  wisp.routeRequest(req, socket, head);
139
- } else if (options.rammerhead && shouldRouteRh(req)) {
144
+ } else if (this.options.rammerhead && shouldRouteRh(req)) {
140
145
  routeRhUpgrade(req, socket, head);
141
146
  } else {
142
147
  socket.end();
143
148
  }
144
149
  });
150
+
151
+ server.listen(port, callback)
145
152
  }
146
153
  }
147
154
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chemicaljs",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Easily create your own web proxy with no experience required.",
5
5
  "repository": {
6
6
  "type": "git",
package/update.bash CHANGED
@@ -10,4 +10,7 @@ npx npm-check-updates -u && npm i
10
10
  cd ../../
11
11
  cd examples/example-styled
12
12
  npx npm-check-updates -u && npm i
13
+ cd ../../
14
+ cd examples/example-build
15
+ npx npm-check-updates -u && npm i
13
16
  cd ../../
@@ -1,22 +0,0 @@
1
- export type BareHeaders = Record<string, string | string[]>;
2
- export type BareMeta = {};
3
- export type TransferrableResponse = {
4
- body: ReadableStream | ArrayBuffer | Blob | string;
5
- headers: BareHeaders;
6
- status: number;
7
- statusText: string;
8
- };
9
- export interface BareTransport {
10
- init: () => Promise<void>;
11
- ready: boolean;
12
- connect: (url: URL, origin: string, protocols: string[], requestHeaders: BareHeaders, onopen: (protocol: string) => void, onmessage: (data: Blob | ArrayBuffer | string) => void, onclose: (code: number, reason: string) => void, onerror: (error: string) => void) => [(data: Blob | ArrayBuffer | string) => void, (code: number, reason: string) => void];
13
- request: (remote: URL, method: string, body: BodyInit | null, headers: BareHeaders, signal: AbortSignal | undefined) => Promise<TransferrableResponse>;
14
- meta: () => BareMeta;
15
- }
16
- export interface BareWebSocketMeta {
17
- protocol: string;
18
- setCookies: string[];
19
- }
20
- export type BareHTTPProtocol = 'blob:' | 'http:' | 'https:' | string;
21
- export type BareWSProtocol = 'ws:' | 'wss:' | string;
22
- export declare const maxRedirects = 20;
@@ -1,73 +0,0 @@
1
- import { BareHeaders, BareTransport } from './baretypes';
2
- import { WorkerConnection } from './connection';
3
- export declare function validProtocol(protocol: string): boolean;
4
- export type WebSocketImpl = {
5
- new (...args: ConstructorParameters<typeof WebSocket>): WebSocket;
6
- };
7
- export declare namespace BareWebSocket {
8
- type GetReadyStateCallback = () => number;
9
- type GetSendErrorCallback = () => Error | undefined;
10
- type GetProtocolCallback = () => string;
11
- type HeadersType = BareHeaders | Headers | undefined;
12
- type HeadersProvider = BareHeaders | (() => BareHeaders | Promise<BareHeaders>);
13
- interface Options {
14
- /**
15
- * A provider of request headers to pass to the remote.
16
- * Usually one of `User-Agent`, `Origin`, and `Cookie`
17
- * Can be just the headers object or an synchronous/asynchronous function that returns the headers object
18
- */
19
- headers?: BareWebSocket.HeadersProvider;
20
- /**
21
- * A hook executed by this function with helper arguments for hooking the readyState property. If a hook isn't provided, bare-client will hook the property on the instance. Hooking it on an instance basis is good for small projects, but ideally the class should be hooked by the user of bare-client.
22
- */
23
- readyStateHook?: ((socket: WebSocket, getReadyState: BareWebSocket.GetReadyStateCallback) => void) | undefined;
24
- /**
25
- * A hook executed by this function with helper arguments for determining if the send function should throw an error. If a hook isn't provided, bare-client will hook the function on the instance.
26
- */
27
- sendErrorHook?: ((socket: WebSocket, getSendError: BareWebSocket.GetSendErrorCallback) => void) | undefined;
28
- /**
29
- * A hook executed by this function with the URL. If a hook isn't provided, bare-client will hook the URL.
30
- */
31
- urlHook?: ((socket: WebSocket, url: URL) => void) | undefined;
32
- /**
33
- * A hook executed by this function with a helper for getting the current fake protocol. If a hook isn't provided, bare-client will hook the protocol.
34
- */
35
- protocolHook?: ((socket: WebSocket, getProtocol: BareWebSocket.GetProtocolCallback) => void) | undefined;
36
- /**
37
- * A callback executed by this function with an array of cookies. This is called once the metadata from the server is received.
38
- */
39
- setCookiesCallback?: ((setCookies: string[]) => void) | undefined;
40
- webSocketImpl?: WebSocket;
41
- }
42
- }
43
- /**
44
- * A Response with additional properties.
45
- */
46
- export interface BareResponse extends Response {
47
- rawResponse: Response;
48
- rawHeaders: BareHeaders;
49
- }
50
- /**
51
- * A BareResponse with additional properties.
52
- */
53
- export interface BareResponseFetch extends BareResponse {
54
- finalURL: string;
55
- }
56
- export declare class BareMuxConnection {
57
- worker: WorkerConnection;
58
- constructor(workerPath: string);
59
- getTransport(): Promise<string>;
60
- setTransport(path: string, options: any[], transferables?: Transferable[]): Promise<void>;
61
- setManualTransport(functionBody: string, options: any[], transferables?: Transferable[]): Promise<void>;
62
- setRemoteTransport(transport: BareTransport, name: string): Promise<void>;
63
- getInnerPort(): MessagePort | Promise<MessagePort>;
64
- }
65
- export declare class BareClient {
66
- worker: WorkerConnection;
67
- /**
68
- * Create a BareClient. Calls to fetch and connect will wait for an implementation to be ready.
69
- */
70
- constructor(worker?: string | MessagePort);
71
- createWebSocket(remote: string | URL, protocols?: string | string[] | undefined, webSocketImpl?: WebSocketImpl, requestHeaders?: BareHeaders, arrayBufferImpl?: ArrayBuffer): WebSocket;
72
- fetch(url: string | URL, init?: RequestInit): Promise<BareResponseFetch>;
73
- }
@@ -1,43 +0,0 @@
1
- import { BareHeaders, TransferrableResponse } from "./baretypes";
2
- export type WorkerMessage = {
3
- type: "fetch" | "websocket" | "set" | "get" | "ping";
4
- fetch?: {
5
- remote: string;
6
- method: string;
7
- headers: BareHeaders;
8
- body: ReadableStream | ArrayBuffer | undefined;
9
- };
10
- websocket?: {
11
- url: string;
12
- origin: string;
13
- protocols: string[];
14
- requestHeaders: BareHeaders;
15
- channel: MessagePort;
16
- };
17
- client?: {
18
- function: string;
19
- args: any[];
20
- };
21
- };
22
- export type WorkerRequest = {
23
- message: WorkerMessage;
24
- port: MessagePort;
25
- };
26
- export type WorkerResponse = {
27
- type: "fetch" | "websocket" | "set" | "get" | "pong" | "error";
28
- fetch?: TransferrableResponse;
29
- name?: string;
30
- error?: Error;
31
- };
32
- export type BroadcastMessage = {
33
- type: "refreshPort";
34
- };
35
- export declare function browserSupportsTransferringStreams(): boolean;
36
- export declare class WorkerConnection {
37
- channel: BroadcastChannel;
38
- port: MessagePort | Promise<MessagePort>;
39
- workerPath: string;
40
- constructor(worker?: string | MessagePort);
41
- createChannel(workerPath?: string, inInit?: boolean): void;
42
- sendMessage(message: WorkerMessage, transferable?: Transferable[]): Promise<WorkerResponse>;
43
- }
@@ -1,9 +0,0 @@
1
- export * from './baretypes';
2
- export * from './client';
3
- export * from './connection';
4
- export { BareClient as default } from './client';
5
- export { WebSocketFields } from "./snapshot";
6
- export type * from './baretypes';
7
- export type * from './client';
8
- export type * from './connection';
9
- export type * from "./snapshot";