chemicaljs 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nebelung
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # Chemical
2
+ Create your own web proxy using Ultraviolet fast, easy, and no experience required.
3
+
4
+ ## Setup
5
+
6
+ ### Server
7
+
8
+ Create a new node.js project and create a script file for the server.
9
+
10
+ 1. Install Chemical `npm install chemicaljs`.
11
+
12
+ 2. Import `ChemicalServer` and create a new server.
13
+
14
+ ```js
15
+ import { ChemicalServer } from "chemicaljs";
16
+
17
+ const chemical = new ChemicalServer();
18
+ ```
19
+
20
+ 3. Use `chemical.app` which is an express app. You may need to import express for certen APIs.
21
+
22
+ ```js
23
+ chemical.app.get("/", function(req, res){
24
+ res.send("Hello World");
25
+ });
26
+ ```
27
+
28
+ 4. Use `chemical.server` and listen on a port of your choosing.
29
+
30
+ ```js
31
+ chemical.server.listen(3000);
32
+ ```
33
+
34
+ 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.
35
+
36
+ ```js
37
+ import { ChemicalServer } from "chemicaljs";
38
+ import express from "express";
39
+
40
+ const chemical = new ChemicalServer();
41
+ const port = process.env.PORT || 3000;
42
+
43
+ chemical.app.use(express.static("public", {
44
+ index: "index.html",
45
+ extensions: ["html"]
46
+ }));
47
+
48
+ chemical.server.listen(port, () => {
49
+ console.log(`Chemical demo listening on port ${port}`);
50
+ });
51
+ ```
52
+
53
+ ### Client
54
+
55
+ In your project create a folder to store your static assets. Create an index.html file which will be the homepage of your website.
56
+
57
+ 1. Add the Chemical script to the top of your page. This will load all needed scripts for Ultraviolet and Chemical.
58
+
59
+ ```html
60
+ <script src="/chemical.js"></script>
61
+ ```
62
+
63
+ 2. Encode a URL with Chemical using `window.chemicalEncode`.
64
+
65
+ ```js
66
+ window.chemicalEncode("https://example.com")
67
+ ```
68
+
69
+ 3. You may want to check if Chemical has loaded before encoding a URL.
70
+
71
+ ```js
72
+ window.chemicalLoaded //true or false
73
+ ```
74
+
75
+ ```js
76
+ window.addEventListener("chemicalLoaded", function (e) {
77
+ //Chemical has loaded
78
+ });
79
+ ```
80
+
81
+ 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.
82
+
83
+ ```html
84
+ <h1>Chemical Demo</h1>
85
+ <input id="search" placeholder="Enter URL">
86
+
87
+ <script src="/chemical.js"></script>
88
+ <script>
89
+ const search = document.getElementById("search");
90
+
91
+ search.addEventListener("keydown", function (e) {
92
+ if (e.key == "Enter" && window.chemicalLoaded && e.target.value) {
93
+ window.location = window.chemicalEncode(e.target.value)
94
+ }
95
+ })
96
+ </script>
97
+ ```
98
+
99
+ ## Future Addition
100
+
101
+ Some features that may come in the future are:
102
+
103
+ - More proxy services.
104
+ - Easy client components.
105
+ - Easy tab cloaking components.
106
+
107
+ ## License
108
+ Chemical Uses the MIT license.
@@ -0,0 +1,3 @@
1
+ # Chemical Example
2
+
3
+ Run `npm install` to install dependencies and then `npm start` to start.
@@ -0,0 +1,14 @@
1
+ import { ChemicalServer } from "chemicaljs";
2
+ import express from "express";
3
+
4
+ const chemical = new ChemicalServer();
5
+ const port = process.env.PORT || 3000;
6
+
7
+ chemical.app.use(express.static("public", {
8
+ index: "index.html",
9
+ extensions: ["html"]
10
+ }));
11
+
12
+ chemical.server.listen(port, () => {
13
+ console.log(`Chemical example listening on port ${port}`);
14
+ });
@@ -0,0 +1,697 @@
1
+ {
2
+ "name": "chemical-example",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "chemical-example",
9
+ "version": "1.0.0",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "express": "^4.19.2"
13
+ }
14
+ },
15
+ "node_modules/accepts": {
16
+ "version": "1.3.8",
17
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
18
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
19
+ "dependencies": {
20
+ "mime-types": "~2.1.34",
21
+ "negotiator": "0.6.3"
22
+ },
23
+ "engines": {
24
+ "node": ">= 0.6"
25
+ }
26
+ },
27
+ "node_modules/array-flatten": {
28
+ "version": "1.1.1",
29
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
30
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
31
+ },
32
+ "node_modules/body-parser": {
33
+ "version": "1.20.2",
34
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
35
+ "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
36
+ "dependencies": {
37
+ "bytes": "3.1.2",
38
+ "content-type": "~1.0.5",
39
+ "debug": "2.6.9",
40
+ "depd": "2.0.0",
41
+ "destroy": "1.2.0",
42
+ "http-errors": "2.0.0",
43
+ "iconv-lite": "0.4.24",
44
+ "on-finished": "2.4.1",
45
+ "qs": "6.11.0",
46
+ "raw-body": "2.5.2",
47
+ "type-is": "~1.6.18",
48
+ "unpipe": "1.0.0"
49
+ },
50
+ "engines": {
51
+ "node": ">= 0.8",
52
+ "npm": "1.2.8000 || >= 1.4.16"
53
+ }
54
+ },
55
+ "node_modules/bytes": {
56
+ "version": "3.1.2",
57
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
58
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
59
+ "engines": {
60
+ "node": ">= 0.8"
61
+ }
62
+ },
63
+ "node_modules/call-bind": {
64
+ "version": "1.0.7",
65
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
66
+ "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
67
+ "dependencies": {
68
+ "es-define-property": "^1.0.0",
69
+ "es-errors": "^1.3.0",
70
+ "function-bind": "^1.1.2",
71
+ "get-intrinsic": "^1.2.4",
72
+ "set-function-length": "^1.2.1"
73
+ },
74
+ "engines": {
75
+ "node": ">= 0.4"
76
+ },
77
+ "funding": {
78
+ "url": "https://github.com/sponsors/ljharb"
79
+ }
80
+ },
81
+ "node_modules/content-disposition": {
82
+ "version": "0.5.4",
83
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
84
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
85
+ "dependencies": {
86
+ "safe-buffer": "5.2.1"
87
+ },
88
+ "engines": {
89
+ "node": ">= 0.6"
90
+ }
91
+ },
92
+ "node_modules/content-type": {
93
+ "version": "1.0.5",
94
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
95
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
96
+ "engines": {
97
+ "node": ">= 0.6"
98
+ }
99
+ },
100
+ "node_modules/cookie": {
101
+ "version": "0.6.0",
102
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
103
+ "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
104
+ "engines": {
105
+ "node": ">= 0.6"
106
+ }
107
+ },
108
+ "node_modules/cookie-signature": {
109
+ "version": "1.0.6",
110
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
111
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
112
+ },
113
+ "node_modules/debug": {
114
+ "version": "2.6.9",
115
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
116
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
117
+ "dependencies": {
118
+ "ms": "2.0.0"
119
+ }
120
+ },
121
+ "node_modules/define-data-property": {
122
+ "version": "1.1.4",
123
+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
124
+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
125
+ "dependencies": {
126
+ "es-define-property": "^1.0.0",
127
+ "es-errors": "^1.3.0",
128
+ "gopd": "^1.0.1"
129
+ },
130
+ "engines": {
131
+ "node": ">= 0.4"
132
+ },
133
+ "funding": {
134
+ "url": "https://github.com/sponsors/ljharb"
135
+ }
136
+ },
137
+ "node_modules/depd": {
138
+ "version": "2.0.0",
139
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
140
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
141
+ "engines": {
142
+ "node": ">= 0.8"
143
+ }
144
+ },
145
+ "node_modules/destroy": {
146
+ "version": "1.2.0",
147
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
148
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
149
+ "engines": {
150
+ "node": ">= 0.8",
151
+ "npm": "1.2.8000 || >= 1.4.16"
152
+ }
153
+ },
154
+ "node_modules/ee-first": {
155
+ "version": "1.1.1",
156
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
157
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
158
+ },
159
+ "node_modules/encodeurl": {
160
+ "version": "1.0.2",
161
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
162
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
163
+ "engines": {
164
+ "node": ">= 0.8"
165
+ }
166
+ },
167
+ "node_modules/es-define-property": {
168
+ "version": "1.0.0",
169
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
170
+ "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
171
+ "dependencies": {
172
+ "get-intrinsic": "^1.2.4"
173
+ },
174
+ "engines": {
175
+ "node": ">= 0.4"
176
+ }
177
+ },
178
+ "node_modules/es-errors": {
179
+ "version": "1.3.0",
180
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
181
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
182
+ "engines": {
183
+ "node": ">= 0.4"
184
+ }
185
+ },
186
+ "node_modules/escape-html": {
187
+ "version": "1.0.3",
188
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
189
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
190
+ },
191
+ "node_modules/etag": {
192
+ "version": "1.8.1",
193
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
194
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
195
+ "engines": {
196
+ "node": ">= 0.6"
197
+ }
198
+ },
199
+ "node_modules/express": {
200
+ "version": "4.19.2",
201
+ "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
202
+ "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
203
+ "dependencies": {
204
+ "accepts": "~1.3.8",
205
+ "array-flatten": "1.1.1",
206
+ "body-parser": "1.20.2",
207
+ "content-disposition": "0.5.4",
208
+ "content-type": "~1.0.4",
209
+ "cookie": "0.6.0",
210
+ "cookie-signature": "1.0.6",
211
+ "debug": "2.6.9",
212
+ "depd": "2.0.0",
213
+ "encodeurl": "~1.0.2",
214
+ "escape-html": "~1.0.3",
215
+ "etag": "~1.8.1",
216
+ "finalhandler": "1.2.0",
217
+ "fresh": "0.5.2",
218
+ "http-errors": "2.0.0",
219
+ "merge-descriptors": "1.0.1",
220
+ "methods": "~1.1.2",
221
+ "on-finished": "2.4.1",
222
+ "parseurl": "~1.3.3",
223
+ "path-to-regexp": "0.1.7",
224
+ "proxy-addr": "~2.0.7",
225
+ "qs": "6.11.0",
226
+ "range-parser": "~1.2.1",
227
+ "safe-buffer": "5.2.1",
228
+ "send": "0.18.0",
229
+ "serve-static": "1.15.0",
230
+ "setprototypeof": "1.2.0",
231
+ "statuses": "2.0.1",
232
+ "type-is": "~1.6.18",
233
+ "utils-merge": "1.0.1",
234
+ "vary": "~1.1.2"
235
+ },
236
+ "engines": {
237
+ "node": ">= 0.10.0"
238
+ }
239
+ },
240
+ "node_modules/finalhandler": {
241
+ "version": "1.2.0",
242
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
243
+ "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
244
+ "dependencies": {
245
+ "debug": "2.6.9",
246
+ "encodeurl": "~1.0.2",
247
+ "escape-html": "~1.0.3",
248
+ "on-finished": "2.4.1",
249
+ "parseurl": "~1.3.3",
250
+ "statuses": "2.0.1",
251
+ "unpipe": "~1.0.0"
252
+ },
253
+ "engines": {
254
+ "node": ">= 0.8"
255
+ }
256
+ },
257
+ "node_modules/forwarded": {
258
+ "version": "0.2.0",
259
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
260
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
261
+ "engines": {
262
+ "node": ">= 0.6"
263
+ }
264
+ },
265
+ "node_modules/fresh": {
266
+ "version": "0.5.2",
267
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
268
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
269
+ "engines": {
270
+ "node": ">= 0.6"
271
+ }
272
+ },
273
+ "node_modules/function-bind": {
274
+ "version": "1.1.2",
275
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
276
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
277
+ "funding": {
278
+ "url": "https://github.com/sponsors/ljharb"
279
+ }
280
+ },
281
+ "node_modules/get-intrinsic": {
282
+ "version": "1.2.4",
283
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
284
+ "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
285
+ "dependencies": {
286
+ "es-errors": "^1.3.0",
287
+ "function-bind": "^1.1.2",
288
+ "has-proto": "^1.0.1",
289
+ "has-symbols": "^1.0.3",
290
+ "hasown": "^2.0.0"
291
+ },
292
+ "engines": {
293
+ "node": ">= 0.4"
294
+ },
295
+ "funding": {
296
+ "url": "https://github.com/sponsors/ljharb"
297
+ }
298
+ },
299
+ "node_modules/gopd": {
300
+ "version": "1.0.1",
301
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
302
+ "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
303
+ "dependencies": {
304
+ "get-intrinsic": "^1.1.3"
305
+ },
306
+ "funding": {
307
+ "url": "https://github.com/sponsors/ljharb"
308
+ }
309
+ },
310
+ "node_modules/has-property-descriptors": {
311
+ "version": "1.0.2",
312
+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
313
+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
314
+ "dependencies": {
315
+ "es-define-property": "^1.0.0"
316
+ },
317
+ "funding": {
318
+ "url": "https://github.com/sponsors/ljharb"
319
+ }
320
+ },
321
+ "node_modules/has-proto": {
322
+ "version": "1.0.3",
323
+ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
324
+ "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
325
+ "engines": {
326
+ "node": ">= 0.4"
327
+ },
328
+ "funding": {
329
+ "url": "https://github.com/sponsors/ljharb"
330
+ }
331
+ },
332
+ "node_modules/has-symbols": {
333
+ "version": "1.0.3",
334
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
335
+ "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
336
+ "engines": {
337
+ "node": ">= 0.4"
338
+ },
339
+ "funding": {
340
+ "url": "https://github.com/sponsors/ljharb"
341
+ }
342
+ },
343
+ "node_modules/hasown": {
344
+ "version": "2.0.2",
345
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
346
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
347
+ "dependencies": {
348
+ "function-bind": "^1.1.2"
349
+ },
350
+ "engines": {
351
+ "node": ">= 0.4"
352
+ }
353
+ },
354
+ "node_modules/http-errors": {
355
+ "version": "2.0.0",
356
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
357
+ "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
358
+ "dependencies": {
359
+ "depd": "2.0.0",
360
+ "inherits": "2.0.4",
361
+ "setprototypeof": "1.2.0",
362
+ "statuses": "2.0.1",
363
+ "toidentifier": "1.0.1"
364
+ },
365
+ "engines": {
366
+ "node": ">= 0.8"
367
+ }
368
+ },
369
+ "node_modules/iconv-lite": {
370
+ "version": "0.4.24",
371
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
372
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
373
+ "dependencies": {
374
+ "safer-buffer": ">= 2.1.2 < 3"
375
+ },
376
+ "engines": {
377
+ "node": ">=0.10.0"
378
+ }
379
+ },
380
+ "node_modules/inherits": {
381
+ "version": "2.0.4",
382
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
383
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
384
+ },
385
+ "node_modules/ipaddr.js": {
386
+ "version": "1.9.1",
387
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
388
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
389
+ "engines": {
390
+ "node": ">= 0.10"
391
+ }
392
+ },
393
+ "node_modules/media-typer": {
394
+ "version": "0.3.0",
395
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
396
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
397
+ "engines": {
398
+ "node": ">= 0.6"
399
+ }
400
+ },
401
+ "node_modules/merge-descriptors": {
402
+ "version": "1.0.1",
403
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
404
+ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
405
+ },
406
+ "node_modules/methods": {
407
+ "version": "1.1.2",
408
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
409
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
410
+ "engines": {
411
+ "node": ">= 0.6"
412
+ }
413
+ },
414
+ "node_modules/mime": {
415
+ "version": "1.6.0",
416
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
417
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
418
+ "bin": {
419
+ "mime": "cli.js"
420
+ },
421
+ "engines": {
422
+ "node": ">=4"
423
+ }
424
+ },
425
+ "node_modules/mime-db": {
426
+ "version": "1.52.0",
427
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
428
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
429
+ "engines": {
430
+ "node": ">= 0.6"
431
+ }
432
+ },
433
+ "node_modules/mime-types": {
434
+ "version": "2.1.35",
435
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
436
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
437
+ "dependencies": {
438
+ "mime-db": "1.52.0"
439
+ },
440
+ "engines": {
441
+ "node": ">= 0.6"
442
+ }
443
+ },
444
+ "node_modules/ms": {
445
+ "version": "2.0.0",
446
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
447
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
448
+ },
449
+ "node_modules/negotiator": {
450
+ "version": "0.6.3",
451
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
452
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
453
+ "engines": {
454
+ "node": ">= 0.6"
455
+ }
456
+ },
457
+ "node_modules/object-inspect": {
458
+ "version": "1.13.2",
459
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz",
460
+ "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==",
461
+ "engines": {
462
+ "node": ">= 0.4"
463
+ },
464
+ "funding": {
465
+ "url": "https://github.com/sponsors/ljharb"
466
+ }
467
+ },
468
+ "node_modules/on-finished": {
469
+ "version": "2.4.1",
470
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
471
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
472
+ "dependencies": {
473
+ "ee-first": "1.1.1"
474
+ },
475
+ "engines": {
476
+ "node": ">= 0.8"
477
+ }
478
+ },
479
+ "node_modules/parseurl": {
480
+ "version": "1.3.3",
481
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
482
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
483
+ "engines": {
484
+ "node": ">= 0.8"
485
+ }
486
+ },
487
+ "node_modules/path-to-regexp": {
488
+ "version": "0.1.7",
489
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
490
+ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
491
+ },
492
+ "node_modules/proxy-addr": {
493
+ "version": "2.0.7",
494
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
495
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
496
+ "dependencies": {
497
+ "forwarded": "0.2.0",
498
+ "ipaddr.js": "1.9.1"
499
+ },
500
+ "engines": {
501
+ "node": ">= 0.10"
502
+ }
503
+ },
504
+ "node_modules/qs": {
505
+ "version": "6.11.0",
506
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
507
+ "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
508
+ "dependencies": {
509
+ "side-channel": "^1.0.4"
510
+ },
511
+ "engines": {
512
+ "node": ">=0.6"
513
+ },
514
+ "funding": {
515
+ "url": "https://github.com/sponsors/ljharb"
516
+ }
517
+ },
518
+ "node_modules/range-parser": {
519
+ "version": "1.2.1",
520
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
521
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
522
+ "engines": {
523
+ "node": ">= 0.6"
524
+ }
525
+ },
526
+ "node_modules/raw-body": {
527
+ "version": "2.5.2",
528
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
529
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
530
+ "dependencies": {
531
+ "bytes": "3.1.2",
532
+ "http-errors": "2.0.0",
533
+ "iconv-lite": "0.4.24",
534
+ "unpipe": "1.0.0"
535
+ },
536
+ "engines": {
537
+ "node": ">= 0.8"
538
+ }
539
+ },
540
+ "node_modules/safe-buffer": {
541
+ "version": "5.2.1",
542
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
543
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
544
+ "funding": [
545
+ {
546
+ "type": "github",
547
+ "url": "https://github.com/sponsors/feross"
548
+ },
549
+ {
550
+ "type": "patreon",
551
+ "url": "https://www.patreon.com/feross"
552
+ },
553
+ {
554
+ "type": "consulting",
555
+ "url": "https://feross.org/support"
556
+ }
557
+ ]
558
+ },
559
+ "node_modules/safer-buffer": {
560
+ "version": "2.1.2",
561
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
562
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
563
+ },
564
+ "node_modules/send": {
565
+ "version": "0.18.0",
566
+ "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
567
+ "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
568
+ "dependencies": {
569
+ "debug": "2.6.9",
570
+ "depd": "2.0.0",
571
+ "destroy": "1.2.0",
572
+ "encodeurl": "~1.0.2",
573
+ "escape-html": "~1.0.3",
574
+ "etag": "~1.8.1",
575
+ "fresh": "0.5.2",
576
+ "http-errors": "2.0.0",
577
+ "mime": "1.6.0",
578
+ "ms": "2.1.3",
579
+ "on-finished": "2.4.1",
580
+ "range-parser": "~1.2.1",
581
+ "statuses": "2.0.1"
582
+ },
583
+ "engines": {
584
+ "node": ">= 0.8.0"
585
+ }
586
+ },
587
+ "node_modules/send/node_modules/ms": {
588
+ "version": "2.1.3",
589
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
590
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
591
+ },
592
+ "node_modules/serve-static": {
593
+ "version": "1.15.0",
594
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
595
+ "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
596
+ "dependencies": {
597
+ "encodeurl": "~1.0.2",
598
+ "escape-html": "~1.0.3",
599
+ "parseurl": "~1.3.3",
600
+ "send": "0.18.0"
601
+ },
602
+ "engines": {
603
+ "node": ">= 0.8.0"
604
+ }
605
+ },
606
+ "node_modules/set-function-length": {
607
+ "version": "1.2.2",
608
+ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
609
+ "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
610
+ "dependencies": {
611
+ "define-data-property": "^1.1.4",
612
+ "es-errors": "^1.3.0",
613
+ "function-bind": "^1.1.2",
614
+ "get-intrinsic": "^1.2.4",
615
+ "gopd": "^1.0.1",
616
+ "has-property-descriptors": "^1.0.2"
617
+ },
618
+ "engines": {
619
+ "node": ">= 0.4"
620
+ }
621
+ },
622
+ "node_modules/setprototypeof": {
623
+ "version": "1.2.0",
624
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
625
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
626
+ },
627
+ "node_modules/side-channel": {
628
+ "version": "1.0.6",
629
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
630
+ "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
631
+ "dependencies": {
632
+ "call-bind": "^1.0.7",
633
+ "es-errors": "^1.3.0",
634
+ "get-intrinsic": "^1.2.4",
635
+ "object-inspect": "^1.13.1"
636
+ },
637
+ "engines": {
638
+ "node": ">= 0.4"
639
+ },
640
+ "funding": {
641
+ "url": "https://github.com/sponsors/ljharb"
642
+ }
643
+ },
644
+ "node_modules/statuses": {
645
+ "version": "2.0.1",
646
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
647
+ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
648
+ "engines": {
649
+ "node": ">= 0.8"
650
+ }
651
+ },
652
+ "node_modules/toidentifier": {
653
+ "version": "1.0.1",
654
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
655
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
656
+ "engines": {
657
+ "node": ">=0.6"
658
+ }
659
+ },
660
+ "node_modules/type-is": {
661
+ "version": "1.6.18",
662
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
663
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
664
+ "dependencies": {
665
+ "media-typer": "0.3.0",
666
+ "mime-types": "~2.1.24"
667
+ },
668
+ "engines": {
669
+ "node": ">= 0.6"
670
+ }
671
+ },
672
+ "node_modules/unpipe": {
673
+ "version": "1.0.0",
674
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
675
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
676
+ "engines": {
677
+ "node": ">= 0.8"
678
+ }
679
+ },
680
+ "node_modules/utils-merge": {
681
+ "version": "1.0.1",
682
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
683
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
684
+ "engines": {
685
+ "node": ">= 0.4.0"
686
+ }
687
+ },
688
+ "node_modules/vary": {
689
+ "version": "1.1.2",
690
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
691
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
692
+ "engines": {
693
+ "node": ">= 0.8"
694
+ }
695
+ }
696
+ }
697
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "chemical-example",
3
+ "version": "1.0.0",
4
+ "description": "This is an example project for Chemical.",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "node index.js"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/chemicaljs/chemical.git"
13
+ },
14
+ "author": "Nebelung",
15
+ "license": "MIT",
16
+ "bugs": {
17
+ "url": "https://github.com/chemicaljs/chemical/issues"
18
+ },
19
+ "homepage": "https://github.com/chemicaljs/chemical#readme",
20
+ "dependencies": {
21
+ "express": "^4.19.2"
22
+ }
23
+ }
@@ -0,0 +1,13 @@
1
+ <h1>Chemical Example</h1>
2
+ <input id="search" placeholder="Enter URL">
3
+
4
+ <script src="/chemical.js"></script>
5
+ <script>
6
+ const search = document.getElementById("search");
7
+
8
+ search.addEventListener("keydown", function (e) {
9
+ if (e.key == "Enter" && window.chemicalLoaded && e.target.value) {
10
+ window.location = window.chemicalEncode(e.target.value)
11
+ }
12
+ })
13
+ </script>
package/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { resolve } from "node:path";
2
+ import { createServer } from "node:http";
3
+ import express from "express";
4
+ import wisp from "wisp-server-node";
5
+ import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
6
+ import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
7
+ import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
8
+
9
+ class ChemicalServer {
10
+ constructor() {
11
+ this.server = createServer();
12
+ this.app = express();
13
+ this.app.use(express.static(resolve(import.meta.dirname, "public")));
14
+ this.app.use("/baremux/", express.static(baremuxPath));
15
+ this.app.use("/epoxy/", express.static(epoxyPath));
16
+ this.app.use("/uv/", express.static(uvPath));
17
+ this.server.on("request", (req, res) => {
18
+ this.app(req, res);
19
+ });
20
+ this.server.on("upgrade", (req, socket, head) => {
21
+ if (req.url && req.url.endsWith("/wisp/")) {
22
+ wisp.routeRequest(req, socket, head);
23
+ } else {
24
+ socket.end();
25
+ }
26
+ });
27
+ }
28
+ }
29
+
30
+ export { ChemicalServer };
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "chemicaljs",
3
+ "version": "1.0.1",
4
+ "description": "Create your own web proxy using Ultraviolet fast, easy, and no experience required.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/chemicaljs/chemical.git"
8
+ },
9
+ "main": "index.js",
10
+ "type": "module",
11
+ "author": "Nebelung",
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "@mercuryworkshop/bare-mux": "^1.1.4",
15
+ "@mercuryworkshop/epoxy-transport": "^2.0.6",
16
+ "@titaniumnetwork-dev/ultraviolet": "^3.1.5",
17
+ "express": "^4.19.2",
18
+ "wisp-server-node": "^1.1.0"
19
+ }
20
+ }
@@ -0,0 +1,43 @@
1
+ window.chemicalLoaded = false;
2
+
3
+ function chemicalEncode(url) {
4
+ return window.location.origin + window.__uv$config.prefix + window.__uv$config.encodeUrl(url)
5
+ }
6
+
7
+ let wispURL = document.currentScript.getAttribute("wisp");
8
+
9
+ async function registerSW() {
10
+ if ("serviceWorker" in navigator) {
11
+ await navigator.serviceWorker.register("/chemical.sw.js");
12
+
13
+ await window.BareMux.SetTransport("EpxMod.EpoxyClient", {
14
+ wisp: wispURL || (location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/",
15
+ });
16
+ } else {
17
+ console.error("Service worker failed to register.")
18
+ }
19
+ }
20
+
21
+ async function loadScript(src) {
22
+ await new Promise((resolve, reject) => {
23
+ const script = document.createElement("script");
24
+ script.src = src;
25
+ script.onload = () => {
26
+ resolve();
27
+ };
28
+ script.onerror = () => {
29
+ reject();
30
+ };
31
+ document.head.appendChild(script);
32
+ });
33
+ }
34
+
35
+ (async () => {
36
+ await loadScript("/baremux/bare.cjs");
37
+ await loadScript("/epoxy/index.js");
38
+ await loadScript("/uv/uv.bundle.js");
39
+ await loadScript("/uv/uv.config.js");
40
+ await registerSW();
41
+ chemicalLoaded = true;
42
+ window.dispatchEvent(new Event("chemicalLoaded"));
43
+ })();
@@ -0,0 +1,17 @@
1
+ importScripts("/epoxy/index.js");
2
+ importScripts("/uv/uv.bundle.js");
3
+ importScripts("/uv/uv.config.js");
4
+ importScripts(__uv$config.sw || "/uv/uv.sw.js");
5
+
6
+ const uv = new UVServiceWorker();
7
+
8
+ self.addEventListener("fetch", (event) => {
9
+ event.respondWith(
10
+ (async () => {
11
+ if (uv.route(event)) {
12
+ return await uv.fetch(event);
13
+ }
14
+ return await fetch(event.request);
15
+ })(),
16
+ );
17
+ });
@@ -0,0 +1,10 @@
1
+ self.__uv$config = {
2
+ prefix: "/~/",
3
+ encodeUrl: Ultraviolet.codec.xor.encode,
4
+ decodeUrl: Ultraviolet.codec.xor.decode,
5
+ handler: "/uv/uv.handler.js",
6
+ client: "/uv/uv.client.js",
7
+ bundle: "/uv/uv.bundle.js",
8
+ config: "/uv/uv.config.js",
9
+ sw: "/uv/uv.sw.js",
10
+ };