chemicaljs 2.6.4 → 3.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/.gitignore +23 -0
- package/AdblockPlugin.js +166 -0
- package/Chemical.svelte +248 -0
- package/Frame.svelte +102 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/blacklist.txt +230974 -0
- package/index.js +115 -0
- package/package.json +28 -44
- package/pnpm-workspace.yaml +3 -0
- package/sw.js +7 -0
- package/client/chemical.cloaking.js +0 -48
- package/client/chemical.components.js +0 -214
- package/client/chemical.demo.html +0 -43
- package/client/chemical.js +0 -494
- package/client/chemical.sw.js +0 -43
- package/config/uv/uv.config.js +0 -10
- package/dist/index.cjs +0 -462
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -58
- package/dist/index.d.ts +0 -58
- package/dist/index.js +0 -435
- package/dist/index.js.map +0 -1
- package/ultraviolet/dist/_hPRTiIRrX.bundle.js +0 -7
- package/ultraviolet/dist/_hPRTiIRrX.client.js +0 -4
- package/ultraviolet/dist/_hPRTiIRrX.config.js +0 -10
- package/ultraviolet/dist/_hPRTiIRrX.handler.js +0 -1
- package/ultraviolet/dist/_hPRTiIRrX.sw.js +0 -47
- package/ultraviolet/index.js +0 -8
- package/ultraviolet/path.js +0 -3
package/client/chemical.js
DELETED
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
const currentScript = document.currentScript;
|
|
2
|
-
|
|
3
|
-
window.chemical = {
|
|
4
|
-
loaded: false,
|
|
5
|
-
demoMode,
|
|
6
|
-
transport:
|
|
7
|
-
currentScript.dataset.transportStore !== undefined
|
|
8
|
-
? localStorage.getItem("@chemical/transport") ||
|
|
9
|
-
currentScript.dataset.transport ||
|
|
10
|
-
"libcurl"
|
|
11
|
-
: currentScript.dataset.transport || "libcurl",
|
|
12
|
-
wisp:
|
|
13
|
-
currentScript.dataset.wispStore !== undefined
|
|
14
|
-
? localStorage.getItem("@chemical/wisp") ||
|
|
15
|
-
currentScript.dataset.wisp ||
|
|
16
|
-
(location.protocol === "https:" ? "wss" : "ws") +
|
|
17
|
-
"://" +
|
|
18
|
-
location.host +
|
|
19
|
-
"/wisp/"
|
|
20
|
-
: currentScript.dataset.wisp ||
|
|
21
|
-
(location.protocol === "https:" ? "wss" : "ws") +
|
|
22
|
-
"://" +
|
|
23
|
-
location.host +
|
|
24
|
-
"/wisp/",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function rammerheadEncode(baseUrl, decode = false) {
|
|
28
|
-
const mod = (n, m) => ((n % m) + m) % m;
|
|
29
|
-
const baseDictionary =
|
|
30
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~-";
|
|
31
|
-
const shuffledIndicator = "_rhs";
|
|
32
|
-
|
|
33
|
-
const generateDictionary = function () {
|
|
34
|
-
let str = "";
|
|
35
|
-
const split = baseDictionary.split("");
|
|
36
|
-
while (split.length > 0) {
|
|
37
|
-
str += split.splice(Math.floor(Math.random() * split.length), 1)[0];
|
|
38
|
-
}
|
|
39
|
-
return str;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
class StrShuffler {
|
|
43
|
-
constructor(dictionary = generateDictionary()) {
|
|
44
|
-
this.dictionary = dictionary;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
shuffle(str) {
|
|
48
|
-
if (str.startsWith(shuffledIndicator)) {
|
|
49
|
-
return str;
|
|
50
|
-
}
|
|
51
|
-
let shuffledStr = "";
|
|
52
|
-
for (let i = 0; i < str.length; i++) {
|
|
53
|
-
const char = str.charAt(i);
|
|
54
|
-
const idx = baseDictionary.indexOf(char);
|
|
55
|
-
if (char === "%" && str.length - i >= 3) {
|
|
56
|
-
shuffledStr += char;
|
|
57
|
-
shuffledStr += str.charAt(++i);
|
|
58
|
-
shuffledStr += str.charAt(++i);
|
|
59
|
-
} else if (idx === -1) {
|
|
60
|
-
shuffledStr += char;
|
|
61
|
-
} else {
|
|
62
|
-
shuffledStr += this.dictionary.charAt(
|
|
63
|
-
mod(idx + i, baseDictionary.length)
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return shuffledIndicator + shuffledStr;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
unshuffle(str) {
|
|
71
|
-
if (!str.startsWith(shuffledIndicator)) {
|
|
72
|
-
return str;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
str = str.slice(shuffledIndicator.length);
|
|
76
|
-
|
|
77
|
-
let unshuffledStr = "";
|
|
78
|
-
for (let i = 0; i < str.length; i++) {
|
|
79
|
-
const char = str.charAt(i);
|
|
80
|
-
const idx = this.dictionary.indexOf(char);
|
|
81
|
-
if (char === "%" && str.length - i >= 3) {
|
|
82
|
-
unshuffledStr += char;
|
|
83
|
-
unshuffledStr += str.charAt(++i);
|
|
84
|
-
unshuffledStr += str.charAt(++i);
|
|
85
|
-
} else if (idx === -1) {
|
|
86
|
-
unshuffledStr += char;
|
|
87
|
-
} else {
|
|
88
|
-
unshuffledStr += baseDictionary.charAt(
|
|
89
|
-
mod(idx - i, baseDictionary.length)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return unshuffledStr;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function get(url, callback, shush = false) {
|
|
98
|
-
var request = new XMLHttpRequest();
|
|
99
|
-
request.open("GET", url, true);
|
|
100
|
-
request.send();
|
|
101
|
-
|
|
102
|
-
request.onerror = function () {
|
|
103
|
-
if (!shush) console.log("Cannot communicate with the server");
|
|
104
|
-
};
|
|
105
|
-
request.onload = function () {
|
|
106
|
-
if (request.status === 200) {
|
|
107
|
-
callback(request.responseText);
|
|
108
|
-
} else {
|
|
109
|
-
if (!shush)
|
|
110
|
-
console.log(
|
|
111
|
-
'unexpected server response to not match "200". Server says "' +
|
|
112
|
-
request.responseText +
|
|
113
|
-
'"'
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
var api = {
|
|
120
|
-
newsession(callback) {
|
|
121
|
-
get("/newsession", callback);
|
|
122
|
-
},
|
|
123
|
-
sessionexists(id, callback) {
|
|
124
|
-
get("/sessionexists?id=" + encodeURIComponent(id), function (res) {
|
|
125
|
-
if (res === "exists") return callback(true);
|
|
126
|
-
if (res === "not found") return callback(false);
|
|
127
|
-
console.log("unexpected response from server. received" + res);
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
shuffleDict(id, callback) {
|
|
131
|
-
console.log("Shuffling", id);
|
|
132
|
-
get("/api/shuffleDict?id=" + encodeURIComponent(id), function (res) {
|
|
133
|
-
callback(JSON.parse(res));
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
var localStorageKey = "rammerhead_sessionids";
|
|
139
|
-
var localStorageKeyDefault = "rammerhead_default_sessionid";
|
|
140
|
-
var sessionIdsStore = {
|
|
141
|
-
get() {
|
|
142
|
-
var rawData = localStorage.getItem(localStorageKey);
|
|
143
|
-
if (!rawData) return [];
|
|
144
|
-
try {
|
|
145
|
-
var data = JSON.parse(rawData);
|
|
146
|
-
if (!Array.isArray(data)) throw "getout";
|
|
147
|
-
return data;
|
|
148
|
-
} catch (e) {
|
|
149
|
-
return [];
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
set(data) {
|
|
153
|
-
if (!data || !Array.isArray(data)) throw new TypeError("must be array");
|
|
154
|
-
localStorage.setItem(localStorageKey, JSON.stringify(data));
|
|
155
|
-
},
|
|
156
|
-
getDefault() {
|
|
157
|
-
var sessionId = localStorage.getItem(localStorageKeyDefault);
|
|
158
|
-
if (sessionId) {
|
|
159
|
-
var data = sessionIdsStore.get();
|
|
160
|
-
data.filter(function (e) {
|
|
161
|
-
return e.id === sessionId;
|
|
162
|
-
});
|
|
163
|
-
if (data.length) return data[0];
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
},
|
|
167
|
-
setDefault(id) {
|
|
168
|
-
localStorage.setItem(localStorageKeyDefault, id);
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
function addSession(id) {
|
|
173
|
-
var data = sessionIdsStore.get();
|
|
174
|
-
data.unshift({ id: id, createdOn: new Date().toLocaleString() });
|
|
175
|
-
sessionIdsStore.set(data);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function getSessionId() {
|
|
179
|
-
return new Promise((resolve) => {
|
|
180
|
-
var id = localStorage.getItem("session-string");
|
|
181
|
-
api.sessionexists(id, function (value) {
|
|
182
|
-
if (!value) {
|
|
183
|
-
console.log("Session validation failed");
|
|
184
|
-
api.newsession(function (id) {
|
|
185
|
-
addSession(id);
|
|
186
|
-
localStorage.setItem("session-string", id);
|
|
187
|
-
console.log(id);
|
|
188
|
-
console.log("^ new id");
|
|
189
|
-
resolve(id);
|
|
190
|
-
});
|
|
191
|
-
} else {
|
|
192
|
-
resolve(id);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
var ProxyHref;
|
|
199
|
-
|
|
200
|
-
return getSessionId().then((id) => {
|
|
201
|
-
return new Promise((resolve) => {
|
|
202
|
-
api.shuffleDict(id, function (shuffleDict) {
|
|
203
|
-
var shuffler = new StrShuffler(shuffleDict);
|
|
204
|
-
if (decode) {
|
|
205
|
-
ProxyHref = shuffler.unshuffle(baseUrl.split(id + "/")[1]);
|
|
206
|
-
} else {
|
|
207
|
-
ProxyHref = "/" + id + "/" + shuffler.shuffle(baseUrl);
|
|
208
|
-
}
|
|
209
|
-
resolve(ProxyHref);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async function encodeService(url, service) {
|
|
216
|
-
switch (service) {
|
|
217
|
-
case "uv":
|
|
218
|
-
if (uvEnabled) {
|
|
219
|
-
return (
|
|
220
|
-
window.location.origin +
|
|
221
|
-
__uv$config.prefix +
|
|
222
|
-
__uv$config.encodeUrl(url)
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
case "rh":
|
|
227
|
-
if (rammerheadEnabled) {
|
|
228
|
-
return window.location.origin + (await rammerheadEncode(url));
|
|
229
|
-
}
|
|
230
|
-
break;
|
|
231
|
-
case "scramjet":
|
|
232
|
-
if (scramjetEnabled) {
|
|
233
|
-
return window.location.origin + chemical.scramjet.encodeUrl(url);
|
|
234
|
-
}
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
window.chemical.encode = async function (url, config) {
|
|
240
|
-
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
241
|
-
config = {
|
|
242
|
-
service: defaultService,
|
|
243
|
-
autoHttps: false,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (config.service === undefined) {
|
|
248
|
-
config.service = defaultService;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (config.autoHttps === undefined) {
|
|
252
|
-
config.autoHttps = false;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (demoMode) {
|
|
256
|
-
return "/chemical.demo.html";
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (url.match(/^https?:\/\//)) {
|
|
260
|
-
return await encodeService(url, config.service);
|
|
261
|
-
} else if (
|
|
262
|
-
config.autoHttps === true &&
|
|
263
|
-
url.includes(".") &&
|
|
264
|
-
!url.includes(" ")
|
|
265
|
-
) {
|
|
266
|
-
return await encodeService("https://" + url, config.service);
|
|
267
|
-
} else if (config.searchEngine) {
|
|
268
|
-
return await encodeService(
|
|
269
|
-
config.searchEngine.replace("%s", encodeURIComponent(url)),
|
|
270
|
-
config.service
|
|
271
|
-
);
|
|
272
|
-
} else {
|
|
273
|
-
return await encodeService(url, config.service);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
window.chemical.decode = async function (url, config) {
|
|
278
|
-
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
279
|
-
config = {
|
|
280
|
-
service: defaultService,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
switch (config.service) {
|
|
285
|
-
case "uv":
|
|
286
|
-
if (uvEnabled) {
|
|
287
|
-
return __uv$config.decodeUrl(url.split(__uv$config.prefix)[1]);
|
|
288
|
-
}
|
|
289
|
-
break;
|
|
290
|
-
case "rh":
|
|
291
|
-
if (rammerheadEnabled) {
|
|
292
|
-
return await rammerheadEncode(
|
|
293
|
-
url.split(window.location.origin)[1],
|
|
294
|
-
true
|
|
295
|
-
);
|
|
296
|
-
}
|
|
297
|
-
break;
|
|
298
|
-
case "scramjet":
|
|
299
|
-
if (scramjetEnabled) {
|
|
300
|
-
return $scramjet.codec.decode(url.split($scramjet.config.prefix)[1]);
|
|
301
|
-
}
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
window.chemical.setStore = function (key, value) {
|
|
307
|
-
const allowed = [
|
|
308
|
-
"transport",
|
|
309
|
-
"wisp",
|
|
310
|
-
"service",
|
|
311
|
-
"autoHttps",
|
|
312
|
-
"searchEngine",
|
|
313
|
-
"title",
|
|
314
|
-
"icon",
|
|
315
|
-
];
|
|
316
|
-
|
|
317
|
-
if (allowed.includes(key)) {
|
|
318
|
-
localStorage.setItem("@chemical/" + key, String(value));
|
|
319
|
-
if (key === "transport") {
|
|
320
|
-
window.chemical.setTransport(value);
|
|
321
|
-
}
|
|
322
|
-
if (key === "wisp") {
|
|
323
|
-
window.chemical.setWisp(value);
|
|
324
|
-
}
|
|
325
|
-
if (key === "title") {
|
|
326
|
-
const titleElement = document.querySelector("title[is='chemical-title']");
|
|
327
|
-
|
|
328
|
-
if (titleElement) {
|
|
329
|
-
titleElement.innerText =
|
|
330
|
-
value || titleElement.getAttribute("data-title");
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
if (key === "icon") {
|
|
334
|
-
const iconElement = document.querySelector("link[is='chemical-icon']");
|
|
335
|
-
|
|
336
|
-
if (iconElement) {
|
|
337
|
-
iconElement.setAttribute(
|
|
338
|
-
"href",
|
|
339
|
-
value || iconElement.getAttribute("data-icon")
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
window.dispatchEvent(
|
|
344
|
-
new CustomEvent("chemicalStoreChange", {
|
|
345
|
-
detail: { key, value },
|
|
346
|
-
})
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
window.chemical.getStore = function (key) {
|
|
352
|
-
const value =
|
|
353
|
-
key === "autoHttps"
|
|
354
|
-
? localStorage.getItem("@chemical/" + key) === "true"
|
|
355
|
-
: localStorage.getItem("@chemical/" + key);
|
|
356
|
-
|
|
357
|
-
const defaults = {
|
|
358
|
-
transport: window.chemical.transport,
|
|
359
|
-
wisp: window.chemical.wisp,
|
|
360
|
-
service: "uv",
|
|
361
|
-
autoHttps: false,
|
|
362
|
-
title: document.querySelector("title[is='chemical-title']")?.innerText,
|
|
363
|
-
icon: document
|
|
364
|
-
.querySelector("link[is='chemical-icon']")
|
|
365
|
-
?.getAttribute("href"),
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
return value || defaults[key];
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
function getTransport(transport) {
|
|
372
|
-
switch (transport) {
|
|
373
|
-
default:
|
|
374
|
-
case "libcurl":
|
|
375
|
-
return "/libcurl/index.mjs";
|
|
376
|
-
break;
|
|
377
|
-
case "epoxy":
|
|
378
|
-
return "/epoxy/index.mjs";
|
|
379
|
-
break;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
window.chemical.setTransport = async function (newTransport) {
|
|
384
|
-
newTransport = newTransport || currentScript.dataset.transport || "libcurl";
|
|
385
|
-
await window.chemical.connection.setTransport(getTransport(newTransport), [
|
|
386
|
-
{ wisp: window.chemical.wisp },
|
|
387
|
-
]);
|
|
388
|
-
window.chemical.transport = newTransport;
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
window.chemical.setWisp = async function (wisp) {
|
|
392
|
-
wisp =
|
|
393
|
-
wisp ||
|
|
394
|
-
currentScript.dataset.wisp ||
|
|
395
|
-
(location.protocol === "https:" ? "wss" : "ws") +
|
|
396
|
-
"://" +
|
|
397
|
-
location.host +
|
|
398
|
-
"/wisp/";
|
|
399
|
-
await window.chemical.connection.setTransport(
|
|
400
|
-
getTransport(window.chemical.transport),
|
|
401
|
-
[{ wisp: wisp }]
|
|
402
|
-
);
|
|
403
|
-
window.chemical.wisp = wisp;
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
async function registerSW() {
|
|
407
|
-
if ("serviceWorker" in navigator) {
|
|
408
|
-
await navigator.serviceWorker.register("/chemical.sw.js");
|
|
409
|
-
} else {
|
|
410
|
-
console.error("Service worker failed to register.");
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
async function loadScript(src) {
|
|
415
|
-
await new Promise((resolve, reject) => {
|
|
416
|
-
const script = document.createElement("script");
|
|
417
|
-
script.src = src;
|
|
418
|
-
script.onload = () => {
|
|
419
|
-
resolve();
|
|
420
|
-
};
|
|
421
|
-
script.onerror = () => {
|
|
422
|
-
reject();
|
|
423
|
-
};
|
|
424
|
-
document.head.appendChild(script);
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
function setupFetch() {
|
|
429
|
-
const client = new window.BareMux.BareClient();
|
|
430
|
-
window.chemical.fetch = client.fetch.bind(client);
|
|
431
|
-
|
|
432
|
-
window.chemical.getSuggestions = async function (query) {
|
|
433
|
-
if (!query) {
|
|
434
|
-
return [];
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
try {
|
|
438
|
-
const DDGSuggestions = await window.chemical.fetch(
|
|
439
|
-
"https://duckduckgo.com/ac/?q=" + query + "&type=list"
|
|
440
|
-
);
|
|
441
|
-
const suggestions = await DDGSuggestions.json();
|
|
442
|
-
return suggestions[1].slice(0, 9);
|
|
443
|
-
} catch {
|
|
444
|
-
return [];
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
window.chemical.createDataURL = async function (url) {
|
|
449
|
-
return new Promise(async (resolve, reject) => {
|
|
450
|
-
try {
|
|
451
|
-
const response = await window.chemical.fetch(url);
|
|
452
|
-
const blob = await response.blob();
|
|
453
|
-
const reader = new FileReader();
|
|
454
|
-
|
|
455
|
-
reader.onloadend = function () {
|
|
456
|
-
resolve(reader.result);
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
reader.readAsDataURL(blob);
|
|
460
|
-
} catch {
|
|
461
|
-
resolve(undefined);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
await loadScript("/baremux/index.js");
|
|
468
|
-
if (uvEnabled) {
|
|
469
|
-
await loadScript(`/${uvRandomPath}/${uvRandomPath}.bundle.js`);
|
|
470
|
-
await loadScript(`/${uvRandomPath}/${uvRandomPath}.config.js`);
|
|
471
|
-
}
|
|
472
|
-
if (scramjetEnabled) {
|
|
473
|
-
await loadScript("/scramjet/scramjet.shared.js");
|
|
474
|
-
await loadScript("/scramjet/scramjet.controller.js");
|
|
475
|
-
chemical.scramjet = new ScramjetController({
|
|
476
|
-
prefix: "/~/scramjet/",
|
|
477
|
-
files: {
|
|
478
|
-
wasm: "/scramjet/scramjet.wasm.js",
|
|
479
|
-
worker: "/scramjet/scramjet.worker.js",
|
|
480
|
-
client: "/scramjet/scramjet.client.js",
|
|
481
|
-
shared: "/scramjet/scramjet.shared.js",
|
|
482
|
-
sync: "/scramjet/scramjet.sync.js",
|
|
483
|
-
},
|
|
484
|
-
});
|
|
485
|
-
chemical.scramjet.init("/chemical.sw.js");
|
|
486
|
-
}
|
|
487
|
-
window.chemical.connection = new window.BareMux.BareMuxConnection(
|
|
488
|
-
"/baremux/worker.js"
|
|
489
|
-
);
|
|
490
|
-
await window.chemical.setTransport(window.chemical.transport);
|
|
491
|
-
setupFetch();
|
|
492
|
-
await registerSW();
|
|
493
|
-
window.chemical.loaded = true;
|
|
494
|
-
window.dispatchEvent(new Event("chemicalLoaded"));
|
package/client/chemical.sw.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
if (uvEnabled) {
|
|
2
|
-
importScripts(`/${uvRandomPath}/${uvRandomPath}.bundle.js`);
|
|
3
|
-
importScripts(`/${uvRandomPath}/${uvRandomPath}.config.js`);
|
|
4
|
-
importScripts(__uv$config.sw || `/${uvRandomPath}/${uvRandomPath}.sw.js`);
|
|
5
|
-
}
|
|
6
|
-
if (scramjetEnabled) {
|
|
7
|
-
importScripts("/scramjet/scramjet.wasm.js");
|
|
8
|
-
importScripts("/scramjet/scramjet.shared.js");
|
|
9
|
-
importScripts("/scramjet/scramjet.worker.js");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (navigator.userAgent.includes("Firefox")) {
|
|
13
|
-
Object.defineProperty(globalThis, "crossOriginIsolated", {
|
|
14
|
-
value: true,
|
|
15
|
-
writable: false,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let uv, scramjet;
|
|
20
|
-
|
|
21
|
-
if (uvEnabled) {
|
|
22
|
-
uv = new UVServiceWorker();
|
|
23
|
-
}
|
|
24
|
-
if (scramjetEnabled) {
|
|
25
|
-
scramjet = new ScramjetServiceWorker();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
self.addEventListener("fetch", (event) => {
|
|
29
|
-
event.respondWith(
|
|
30
|
-
(async () => {
|
|
31
|
-
if (scramjetEnabled) {
|
|
32
|
-
await scramjet.loadConfig();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (uvEnabled && uv.route(event)) {
|
|
36
|
-
return await uv.fetch(event);
|
|
37
|
-
} else if (scramjetEnabled && scramjet.route(event)) {
|
|
38
|
-
return await scramjet.fetch(event);
|
|
39
|
-
}
|
|
40
|
-
return await fetch(event.request);
|
|
41
|
-
})()
|
|
42
|
-
);
|
|
43
|
-
});
|
package/config/uv/uv.config.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
self.__uv$config = {
|
|
2
|
-
prefix: "/~/uv/",
|
|
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
|
-
};
|