chemicaljs 1.3.0 → 1.3.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Easily create your own web proxy with no experience required.
5
5
 
6
6
  A simple example can be found in [`/example/`](https://github.com/chemicaljs/chemical/tree/main/example).
7
7
 
8
- A example with the vite plugin can be found in [`/example-vite/`](https://github.com/chemicaljs/chemical/tree/main/example).
8
+ A example with the vite plugin can be found in [`/example-vite/`](https://github.com/chemicaljs/chemical/tree/main/example-vite).
9
9
 
10
10
  ### Server
11
11
 
@@ -81,6 +81,12 @@ If you want to set the wisp server to an external server just change the `wisp`
81
81
  <script wisp="wss://wisp.mercurywork.shop" src="/chemical.js"></script>
82
82
  ```
83
83
 
84
+ If you want to set the transport just change the `transport` attribute. Choose `libcurl` (default becuase it supports Firefox) or `epoxy`.
85
+
86
+ ```html
87
+ <script transport="epoxy" src="/chemical.js"></script>
88
+ ```
89
+
84
90
  2. In a inline script or javascript file, encode a URL with Chemical using the async function `window.chemicalEncode`.
85
91
 
86
92
  ```js
@@ -107,6 +113,12 @@ window.addEventListener("chemicalLoaded", function(e) {
107
113
  });
108
114
  ```
109
115
 
116
+ 4. Change the transport and Wisp URL with `chemicalTransport`
117
+
118
+ ```js
119
+ await chemicalTransport("libcurl", "wss://wisp.mercurywork.shop")
120
+ ```
121
+
110
122
  Below is a simple example of a simple input that redirects to the encoded URL when the user presses enter. It checks if there is any input and if Chemical has loaded before loading.
111
123
 
112
124
  ```html
@@ -129,14 +141,14 @@ Below is a simple example of a simple input that redirects to the encoded URL wh
129
141
 
130
142
  1. Create a new vite app and open `vite.config.js` or `vite.config.ts`
131
143
 
132
- 2. Import `ChemicalPluginVite` and add it to plugins.
144
+ 2. Import `ChemicalVitePlugin` and add it to plugins.
133
145
 
134
146
  ```js
135
147
  import { defineConfig } from "vite"
136
- import { ChemicalPluginVite } from "chemicaljs"
148
+ import { ChemicalVitePlugin } from "chemicaljs"
137
149
 
138
150
  export default defineConfig({
139
- plugins: [/*Other plugins*/ChemicalPluginVite()],
151
+ plugins: [/*Other plugins*/ChemicalVitePlugin()],
140
152
  })
141
153
  ```
142
154
 
@@ -145,7 +157,7 @@ You can pass options to just like on the main server.
145
157
  ```js
146
158
  export default defineConfig({
147
159
  plugins: [
148
- ChemicalPluginVite({
160
+ ChemicalVitePlugin({
149
161
  default: "rammerhead",
150
162
  uv: true,
151
163
  scramjet: false,
@@ -202,11 +202,29 @@ async function chemicalEncode(url, service = defaultService) {
202
202
  }
203
203
  }
204
204
 
205
+ function getTransport(transport) {
206
+ switch (transport) {
207
+ case "libcurl":
208
+ return "/libcurl/index.mjs"
209
+ break;
210
+ case "epoxy":
211
+ return "/epoxy/index.mjs"
212
+ break;
213
+ }
214
+ }
215
+
216
+ let connection;
217
+
205
218
  let wispURL = document.currentScript.getAttribute("wisp");
219
+ let transport = document.currentScript.getAttribute("transport");
220
+
221
+ async function chemicalTransport(transport, wisp) {
222
+ await connection.setTransport(getTransport(transport) || "/libcurl/index.mjs", [{ wisp: wisp || (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/" }]);
223
+ }
206
224
 
207
225
  async function registerSW() {
208
- const connection = new window.BareMux.BareMuxConnection("/baremux/worker.js");
209
- await connection.setTransport("/epoxy/index.mjs", [{ wisp: wispURL || (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/" }]);
226
+ connection = new window.BareMux.BareMuxConnection("/baremux/worker.js");
227
+ await chemicalTransport();
210
228
 
211
229
  if ("serviceWorker" in navigator) {
212
230
  await navigator.serviceWorker.register("/chemical.sw.js");
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "chemicaljs": "^1.2.5",
12
+ "chemicaljs": "^1.3.1",
13
13
  "express": "^4.19.2"
14
14
  }
15
15
  },
@@ -425,6 +425,18 @@
425
425
  "rollup-plugin-typescript2": "^0.36.0"
426
426
  }
427
427
  },
428
+ "node_modules/@mercuryworkshop/libcurl-transport": {
429
+ "version": "1.3.6",
430
+ "resolved": "https://registry.npmjs.org/@mercuryworkshop/libcurl-transport/-/libcurl-transport-1.3.6.tgz",
431
+ "integrity": "sha512-K4/TSfHlkjuzY6j0XXFmIbG8m3tpMoTxLga46fhmeuX8k3EJR/FVbW8JTXOD34Iofu0vCZuuY8n/ywNCcB6XjA==",
432
+ "dependencies": {
433
+ "esbuild-plugin-umd-wrapper": "^2.0.0",
434
+ "libcurl.js": "^0.6.10",
435
+ "rollup": "^4.12.0",
436
+ "rollup-plugin-node-resolve": "^5.2.0",
437
+ "rollup-plugin-typescript2": "^0.36.0"
438
+ }
439
+ },
428
440
  "node_modules/@mercuryworkshop/scramjet": {
429
441
  "version": "1.0.2",
430
442
  "resolved": "https://registry.npmjs.org/@mercuryworkshop/scramjet/-/scramjet-1.0.2.tgz",
@@ -692,9 +704,9 @@
692
704
  ]
693
705
  },
694
706
  "node_modules/@titaniumnetwork-dev/ultraviolet": {
695
- "version": "3.2.1",
696
- "resolved": "https://registry.npmjs.org/@titaniumnetwork-dev/ultraviolet/-/ultraviolet-3.2.1.tgz",
697
- "integrity": "sha512-J8WsR0LzZp9jFu9ghEpczRpzK9dzdlB5/DjvsCvcD1zJSP17DC3+pVhQaGvLCBqHw+KS06srhFLJMkZqg8I51A=="
707
+ "version": "3.2.2",
708
+ "resolved": "https://registry.npmjs.org/@titaniumnetwork-dev/ultraviolet/-/ultraviolet-3.2.2.tgz",
709
+ "integrity": "sha512-W5QMiSkG46JudHJRnyMxuXQXyCQHp+K3gsb0ZH+GM1jaufVawkRuh//37M0EYoI8xIiYGYT4rsRX1bKrHR937Q=="
698
710
  },
699
711
  "node_modules/@tootallnate/once": {
700
712
  "version": "1.1.2",
@@ -1146,14 +1158,15 @@
1146
1158
  }
1147
1159
  },
1148
1160
  "node_modules/chemicaljs": {
1149
- "version": "1.2.5",
1150
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.2.5.tgz",
1151
- "integrity": "sha512-MHCs5CDzzwKwdT9ce2ZRdaod0+LoDmtbK7bkyl1I0dfg9Xt8rFeR+dyum4JnYJPHXfwgP86KgHTvSkDEVakT6Q==",
1161
+ "version": "1.3.1",
1162
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.3.1.tgz",
1163
+ "integrity": "sha512-F0c930sI2hTzvLrbSxtVGonCFsATFlXEZkFo74y+ZUVFAF3TaYGRIi0d2tPa0ZZGrJeJlbx43JASRIMGLSTH6w==",
1152
1164
  "dependencies": {
1153
1165
  "@mercuryworkshop/bare-mux": "^2.0.1",
1154
1166
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
1167
+ "@mercuryworkshop/libcurl-transport": "^1.3.6",
1155
1168
  "@mercuryworkshop/scramjet": "^1.0.2",
1156
- "@titaniumnetwork-dev/ultraviolet": "^3.2.1",
1169
+ "@titaniumnetwork-dev/ultraviolet": "^3.2.2",
1157
1170
  "express": "^4.19.2",
1158
1171
  "rammerhead": "https://github.com/chemicaljs/chemical/raw/main/rammerhead.tgz",
1159
1172
  "wisp-server-node": "^1.1.0"
@@ -2181,6 +2194,11 @@
2181
2194
  "sqlite3": "^5.0.6"
2182
2195
  }
2183
2196
  },
2197
+ "node_modules/libcurl.js": {
2198
+ "version": "0.6.10",
2199
+ "resolved": "https://registry.npmjs.org/libcurl.js/-/libcurl.js-0.6.10.tgz",
2200
+ "integrity": "sha512-GDyxCRi7+R7XFhcCRFAsNYxg3x91LiwiBISo+pWfUXfgO45J/9ZWcHqjKQg8/FbWHRkV1wwSCyPOZ8pLlbdivg=="
2201
+ },
2184
2202
  "node_modules/locate-path": {
2185
2203
  "version": "5.0.0",
2186
2204
  "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/chemicaljs/chemical#readme",
20
20
  "dependencies": {
21
- "chemicaljs": "^1.2.5",
21
+ "chemicaljs": "^1.3.1",
22
22
  "express": "^4.19.2"
23
23
  }
24
24
  }
@@ -6,7 +6,7 @@
6
6
  "": {
7
7
  "name": "chemical-example-vite",
8
8
  "dependencies": {
9
- "chemicaljs": "^1.2.5",
9
+ "chemicaljs": "^1.3.1",
10
10
  "express": "^4.19.2",
11
11
  "preact": "^10.22.0"
12
12
  },
@@ -812,6 +812,18 @@
812
812
  "rollup-plugin-typescript2": "^0.36.0"
813
813
  }
814
814
  },
815
+ "node_modules/@mercuryworkshop/libcurl-transport": {
816
+ "version": "1.3.6",
817
+ "resolved": "https://registry.npmjs.org/@mercuryworkshop/libcurl-transport/-/libcurl-transport-1.3.6.tgz",
818
+ "integrity": "sha512-K4/TSfHlkjuzY6j0XXFmIbG8m3tpMoTxLga46fhmeuX8k3EJR/FVbW8JTXOD34Iofu0vCZuuY8n/ywNCcB6XjA==",
819
+ "dependencies": {
820
+ "esbuild-plugin-umd-wrapper": "^2.0.0",
821
+ "libcurl.js": "^0.6.10",
822
+ "rollup": "^4.12.0",
823
+ "rollup-plugin-node-resolve": "^5.2.0",
824
+ "rollup-plugin-typescript2": "^0.36.0"
825
+ }
826
+ },
815
827
  "node_modules/@mercuryworkshop/scramjet": {
816
828
  "version": "1.0.2",
817
829
  "resolved": "https://registry.npmjs.org/@mercuryworkshop/scramjet/-/scramjet-1.0.2.tgz",
@@ -1709,14 +1721,15 @@
1709
1721
  }
1710
1722
  },
1711
1723
  "node_modules/chemicaljs": {
1712
- "version": "1.2.5",
1713
- "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.2.5.tgz",
1714
- "integrity": "sha512-MHCs5CDzzwKwdT9ce2ZRdaod0+LoDmtbK7bkyl1I0dfg9Xt8rFeR+dyum4JnYJPHXfwgP86KgHTvSkDEVakT6Q==",
1724
+ "version": "1.3.1",
1725
+ "resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.3.1.tgz",
1726
+ "integrity": "sha512-F0c930sI2hTzvLrbSxtVGonCFsATFlXEZkFo74y+ZUVFAF3TaYGRIi0d2tPa0ZZGrJeJlbx43JASRIMGLSTH6w==",
1715
1727
  "dependencies": {
1716
1728
  "@mercuryworkshop/bare-mux": "^2.0.1",
1717
1729
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
1730
+ "@mercuryworkshop/libcurl-transport": "^1.3.6",
1718
1731
  "@mercuryworkshop/scramjet": "^1.0.2",
1719
- "@titaniumnetwork-dev/ultraviolet": "^3.2.1",
1732
+ "@titaniumnetwork-dev/ultraviolet": "^3.2.2",
1720
1733
  "express": "^4.19.2",
1721
1734
  "rammerhead": "https://github.com/chemicaljs/chemical/raw/main/rammerhead.tgz",
1722
1735
  "wisp-server-node": "^1.1.0"
@@ -2878,6 +2891,11 @@
2878
2891
  "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==",
2879
2892
  "dev": true
2880
2893
  },
2894
+ "node_modules/libcurl.js": {
2895
+ "version": "0.6.10",
2896
+ "resolved": "https://registry.npmjs.org/libcurl.js/-/libcurl.js-0.6.10.tgz",
2897
+ "integrity": "sha512-GDyxCRi7+R7XFhcCRFAsNYxg3x91LiwiBISo+pWfUXfgO45J/9ZWcHqjKQg8/FbWHRkV1wwSCyPOZ8pLlbdivg=="
2898
+ },
2881
2899
  "node_modules/locate-path": {
2882
2900
  "version": "5.0.0",
2883
2901
  "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
@@ -8,7 +8,7 @@
8
8
  "build": "vite build"
9
9
  },
10
10
  "dependencies": {
11
- "chemicaljs": "^1.2.5",
11
+ "chemicaljs": "^1.3.1",
12
12
  "express": "^4.19.2",
13
13
  "preact": "^10.22.0"
14
14
  },
@@ -1,10 +1,10 @@
1
1
  import { defineConfig } from "vite"
2
2
  import preact from "@preact/preset-vite"
3
- import { ChemicalPluginVite } from "chemicaljs"
3
+ import { ChemicalVitePlugin } from "chemicaljs"
4
4
 
5
5
  export default defineConfig({
6
6
  plugins: [
7
7
  preact(),
8
- ChemicalPluginVite()
8
+ ChemicalVitePlugin()
9
9
  ],
10
10
  })
package/index.js CHANGED
@@ -4,6 +4,7 @@ import { createServer } from "node:http";
4
4
  import express from "express";
5
5
  import wisp from "wisp-server-node";
6
6
  import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
7
+ import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
7
8
  import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
8
9
  import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
9
10
  import { scramjetPath } from "@mercuryworkshop/scramjet";
@@ -104,6 +105,7 @@ class ChemicalServer {
104
105
  });
105
106
  this.app.use(express.static(resolve(import.meta.dirname, "client")));
106
107
  this.app.use("/baremux/", express.static(baremuxPath));
108
+ this.app.use("/libcurl/", express.static(libcurlPath));
107
109
  this.app.use("/epoxy/", express.static(epoxyPath));
108
110
  if (options.uv) {
109
111
  this.app.use("/uv/", express.static(resolve(import.meta.dirname, "config/uv")));
@@ -132,8 +134,8 @@ class ChemicalServer {
132
134
  }
133
135
  }
134
136
 
135
- const ChemicalPluginVite = (options) => ({
136
- name: "chemical-plugin-vite",
137
+ const ChemicalVitePlugin = (options) => ({
138
+ name: "chemical-vite-plugin",
137
139
  configureServer(server) {
138
140
  if (options) {
139
141
  if (typeof options !== "object" || Array.isArray(options)) {
@@ -227,6 +229,7 @@ const ChemicalPluginVite = (options) => ({
227
229
  });
228
230
  app.use(express.static(resolve(import.meta.dirname, "client")));
229
231
  app.use("/baremux/", express.static(baremuxPath));
232
+ app.use("/libcurl/", express.static(libcurlPath));
230
233
  app.use("/epoxy/", express.static(epoxyPath));
231
234
  if (options.uv) {
232
235
  app.use("/uv/", express.static(resolve(import.meta.dirname, "config/uv")));
@@ -267,4 +270,4 @@ const ChemicalPluginVite = (options) => ({
267
270
  }
268
271
  })
269
272
 
270
- export { ChemicalServer, ChemicalPluginVite };
273
+ export { ChemicalServer, ChemicalVitePlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chemicaljs",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Easily create your own web proxy with no experience required.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,8 +13,9 @@
13
13
  "dependencies": {
14
14
  "@mercuryworkshop/bare-mux": "^2.0.1",
15
15
  "@mercuryworkshop/epoxy-transport": "^2.1.3",
16
+ "@mercuryworkshop/libcurl-transport": "^1.3.6",
16
17
  "@mercuryworkshop/scramjet": "^1.0.2",
17
- "@titaniumnetwork-dev/ultraviolet": "^3.2.1",
18
+ "@titaniumnetwork-dev/ultraviolet": "^3.2.2",
18
19
  "express": "^4.19.2",
19
20
  "rammerhead": "https://github.com/chemicaljs/chemical/raw/main/rammerhead.tgz",
20
21
  "wisp-server-node": "^1.1.0"