chemicaljs 1.3.0 → 1.3.1
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 +13 -1
- package/client/chemical.js +20 -2
- package/example/index.js +1 -1
- package/example/package-lock.json +4 -4
- package/example/package.json +1 -1
- package/example-vite/package-lock.json +4 -4
- package/example-vite/package.json +1 -1
- package/index.js +3 -0
- package/package.json +3 -2
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
|
package/client/chemical.js
CHANGED
|
@@ -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
|
-
|
|
209
|
-
await
|
|
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");
|
package/example/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"version": "1.0.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"chemicaljs": "^1.
|
|
12
|
+
"chemicaljs": "^1.3.0",
|
|
13
13
|
"express": "^4.19.2"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -1146,9 +1146,9 @@
|
|
|
1146
1146
|
}
|
|
1147
1147
|
},
|
|
1148
1148
|
"node_modules/chemicaljs": {
|
|
1149
|
-
"version": "1.
|
|
1150
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1151
|
-
"integrity": "sha512-
|
|
1149
|
+
"version": "1.3.0",
|
|
1150
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.3.0.tgz",
|
|
1151
|
+
"integrity": "sha512-WJf2OA33QuFxhqRJCECk8lh8VWzURVc2CqIPfkAYBBIY/6XO98xvEbsxjkrQoxGegz7ilC7BqvQkV3h2ASIjQQ==",
|
|
1152
1152
|
"dependencies": {
|
|
1153
1153
|
"@mercuryworkshop/bare-mux": "^2.0.1",
|
|
1154
1154
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
package/example/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"": {
|
|
7
7
|
"name": "chemical-example-vite",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"chemicaljs": "^1.
|
|
9
|
+
"chemicaljs": "^1.3.0",
|
|
10
10
|
"express": "^4.19.2",
|
|
11
11
|
"preact": "^10.22.0"
|
|
12
12
|
},
|
|
@@ -1709,9 +1709,9 @@
|
|
|
1709
1709
|
}
|
|
1710
1710
|
},
|
|
1711
1711
|
"node_modules/chemicaljs": {
|
|
1712
|
-
"version": "1.
|
|
1713
|
-
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.
|
|
1714
|
-
"integrity": "sha512-
|
|
1712
|
+
"version": "1.3.0",
|
|
1713
|
+
"resolved": "https://registry.npmjs.org/chemicaljs/-/chemicaljs-1.3.0.tgz",
|
|
1714
|
+
"integrity": "sha512-WJf2OA33QuFxhqRJCECk8lh8VWzURVc2CqIPfkAYBBIY/6XO98xvEbsxjkrQoxGegz7ilC7BqvQkV3h2ASIjQQ==",
|
|
1715
1715
|
"dependencies": {
|
|
1716
1716
|
"@mercuryworkshop/bare-mux": "^2.0.1",
|
|
1717
1717
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
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")));
|
|
@@ -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")));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chemicaljs",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
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.
|
|
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"
|