diff --git a/astro.config.ts b/astro.config.ts
index b06d79d3..bb04d7cd 100644
--- a/astro.config.ts
+++ b/astro.config.ts
@@ -2,12 +2,12 @@ import { fileURLToPath } from "node:url";
import node from "@astrojs/node";
import svelte from "@astrojs/svelte";
import tailwind from "@astrojs/tailwind";
-import sitemap from "@astrojs/sitemap";
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
import playformCompress from "@playform/compress";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
+import { scramjetPath } from "@mercuryworkshop/scramjet";
import icon from "astro-icon";
import { defineConfig, envField } from "astro/config";
import { viteStaticCopy } from "vite-plugin-static-copy";
@@ -74,6 +74,11 @@ export default defineConfig({
dest: "libcurl",
overwrite: false
},
+ {
+ src: `${scramjetPath}/**/*`.replace(/\\/g, "/"),
+ dest: "scram",
+ overwrite: false
+ },
{
src: `${baremuxPath}/**/*`.replace(/\\/g, "/"),
dest: "baremux",
diff --git a/package.json b/package.json
index e86c2b15..e842f881 100644
--- a/package.json
+++ b/package.json
@@ -34,6 +34,7 @@
"@mercuryworkshop/libcurl-transport": "^1.3.15",
"@playform/compress": "^0.1.6",
"@titaniumnetwork-dev/ultraviolet": "^3.2.10",
+ "@mercuryworkshop/scramjet": "https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz",
"@types/node": "^22.10.2",
"@types/sequelize": "^4.28.20",
"astro": "^5.1.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a56bcacb..24b3db82 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -50,6 +50,9 @@ importers:
'@mercuryworkshop/libcurl-transport':
specifier: ^1.3.15
version: 1.3.15
+ '@mercuryworkshop/scramjet':
+ specifier: https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz
+ version: https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz
'@playform/compress':
specifier: ^0.1.6
version: 0.1.6(@types/node@22.10.2)(jiti@1.21.7)(rollup@4.29.1)(tsx@4.19.2)(typescript@5.7.2)(yaml@2.6.1)
@@ -1009,6 +1012,10 @@ packages:
'@mercuryworkshop/libcurl-transport@1.3.15':
resolution: {integrity: sha512-lmFoTovP2L519S+KjAfvUy8QQa4mM+/HCcO+wx0jsd43xOrFxwYIvRLKAEJgW9Wk1MBy2FNwYsarv/teUlc3VA==}
+ '@mercuryworkshop/scramjet@https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz':
+ resolution: {tarball: https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz}
+ version: 1.0.2-dev
+
'@nodelib/fs.scandir@2.1.5':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -1196,8 +1203,8 @@ packages:
'@types/cookie@0.6.0':
resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==}
- '@types/css-tree@2.3.9':
- resolution: {integrity: sha512-g1FE6xkPDP4tsccmTd6jIugjKZdxIDqAf9h2pc+4LsGgYbOyfa9phNjBHYbm6FtwIlNfT1NBx3f2zSeqO7aRAw==}
+ '@types/css-tree@2.3.10':
+ resolution: {integrity: sha512-WcaBazJ84RxABvRttQjjFWgTcHvZR9jGr0Y3hccPkHjFyk/a3N8EuxjKr+QfrwjoM5b1yI1Uj1i7EzOAAwBwag==}
'@types/csso@5.0.4':
resolution: {integrity: sha512-W/FsRkm/9c04x9ON+bj+HQ0cSgNkG1LvcfuBCpkP7cpikM7+RkrNFLGtiofb++xBG6KGMUycLoDbi9/K621ZCw==}
@@ -1312,8 +1319,8 @@ packages:
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
engines: {node: '>= 6.0.0'}
- agentkeepalive@4.5.0:
- resolution: {integrity: sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==}
+ agentkeepalive@4.6.0:
+ resolution: {integrity: sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==}
engines: {node: '>= 8.0.0'}
aggregate-error@3.1.0:
@@ -1583,6 +1590,10 @@ packages:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
+ clone-regexp@3.0.0:
+ resolution: {integrity: sha512-ujdnoq2Kxb8s3ItNBtnYeXdm07FcU0u8ARAT1lQ2YdMwQC+cdiXX8KoqMVuglztILivceTtp4ivqGSmEmhBUJw==}
+ engines: {node: '>=12'}
+
clsx@2.1.1:
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
engines: {node: '>=6'}
@@ -1651,6 +1662,10 @@ packages:
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
engines: {node: '>= 0.6'}
+ convert-hrtime@5.0.0:
+ resolution: {integrity: sha512-lOETlkIeYSJWcbbcvjRKGxVMXJR+8+OQb/mTPbA4ObPMytYIsUbuOE0Jzy60hjARYszq1id0j8KgVhC+WGZVTg==}
+ engines: {node: '>=12'}
+
cookie-es@1.2.2:
resolution: {integrity: sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==}
@@ -1867,6 +1882,10 @@ packages:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
+ entities@6.0.0:
+ resolution: {integrity: sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw==}
+ engines: {node: '>=0.12'}
+
env-paths@2.2.1:
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
engines: {node: '>=6'}
@@ -2076,6 +2095,10 @@ packages:
function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
+ function-timeout@0.1.1:
+ resolution: {integrity: sha512-0NVVC0TaP7dSTvn1yMiy6d6Q8gifzbvQafO46RtLG/kHJUBNd+pVRGOBoK44wNBvtSPUJRfdVvkFdD3p0xvyZg==}
+ engines: {node: '>=14.16'}
+
gauge@4.0.4:
resolution: {integrity: sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==}
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
@@ -2193,6 +2216,9 @@ packages:
html-void-elements@3.0.0:
resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}
+ htmlparser2@10.0.0:
+ resolution: {integrity: sha512-TwAZM+zE5Tq3lrEHvOlvwgj1XLWQCtaaibSN11Q+gGBAS7Y1uZSWwXXRe4iF6OXnaq1riyQAPFOBtYc77Mxq0g==}
+
htmlparser2@9.1.0:
resolution: {integrity: sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==}
@@ -2267,6 +2293,10 @@ packages:
resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==}
engines: {node: '>= 12'}
+ ip-regex@5.0.0:
+ resolution: {integrity: sha512-fOCG6lhoKKakwv+C6KdsOnGvgXnmgfmp0myi3bcNwj3qfwPAxRKWEuFhvEFF7ceYIz6+1jRZ+yguLFAmUNPEfw==}
+ engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
+
ipaddr.js@1.9.1:
resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==}
engines: {node: '>= 0.10'}
@@ -2311,6 +2341,10 @@ packages:
resolution: {integrity: sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==}
engines: {node: '>=12'}
+ is-ip@5.0.1:
+ resolution: {integrity: sha512-FCsGHdlrOnZQcp0+XT5a+pYowf33itBalCl+7ovNXC/7o5BhIpG14M3OrpPPdBSIQJCm+0M5+9mO7S9VVTTCFw==}
+ engines: {node: '>=14.16'}
+
is-lambda@1.0.1:
resolution: {integrity: sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==}
@@ -2325,6 +2359,10 @@ packages:
is-reference@3.0.3:
resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==}
+ is-regexp@3.1.0:
+ resolution: {integrity: sha512-rbku49cWloU5bSMI+zaRaXdQHXnthP6DZ/vLnfdSKyL4zUzuWnomtOEiZZOd+ioQ+avFo/qau3KPTc7Fjy1uPA==}
+ engines: {node: '>=12'}
+
is-subdir@1.2.0:
resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==}
engines: {node: '>=4'}
@@ -2945,6 +2983,10 @@ packages:
param-case@3.0.4:
resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==}
+ parse-domain@8.2.2:
+ resolution: {integrity: sha512-CoksenD3UDqphCHlXIcNh/TX0dsYLHo6dSAUC/QBcJRWJXcV5rc1mwsS4WbhYGu4LD4Uxc0v3ZzGo+OHCGsLcw==}
+ hasBin: true
+
parse-latin@7.0.0:
resolution: {integrity: sha512-mhHgobPPua5kZ98EF4HWiH167JWBfl4pvAIXXdbaVohtK7a6YBOy56kvhCqduqyo/f3yrHFWmqmiMg/BkBkYYQ==}
@@ -3599,6 +3641,10 @@ packages:
engines: {node: '>=16 || 14 >=14.17'}
hasBin: true
+ super-regex@0.2.0:
+ resolution: {integrity: sha512-WZzIx3rC1CvbMDloLsVw0lkZVKJWbrkJ0k1ghKFmcnPrW1+jWbgTkTEWVtD9lMdmI4jZEz40+naBxl1dCUhXXw==}
+ engines: {node: '>=14.16'}
+
supports-preserve-symlinks-flag@1.0.0:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
@@ -3666,11 +3712,15 @@ packages:
through2@2.0.5:
resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==}
+ time-span@5.1.0:
+ resolution: {integrity: sha512-75voc/9G4rDIJleOo4jPvN4/YC4GRZrY8yy1uU4lwrB3XEQbWve8zXoO5No4eFrGcTAMYyoY67p8jRQdtA1HbA==}
+ engines: {node: '>=12'}
+
tinycolor2@1.6.0:
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
- tinyexec@0.3.1:
- resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==}
+ tinyexec@0.3.2:
+ resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
tinygradient@1.1.5:
resolution: {integrity: sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==}
@@ -4203,7 +4253,7 @@ snapshots:
'@antfu/install-pkg@0.4.1':
dependencies:
package-manager-detector: 0.2.8
- tinyexec: 0.3.1
+ tinyexec: 0.3.2
'@antfu/utils@0.7.10': {}
@@ -5030,6 +5080,16 @@ snapshots:
dependencies:
libcurl.js: 0.6.21
+ '@mercuryworkshop/scramjet@https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz':
+ dependencies:
+ '@mercuryworkshop/bare-mux': 2.1.7
+ dom-serializer: 2.0.0
+ domhandler: 5.0.3
+ domutils: 3.2.1
+ htmlparser2: 10.0.0
+ parse-domain: 8.2.2
+ set-cookie-parser: 2.7.1
+
'@nodelib/fs.scandir@2.1.5':
dependencies:
'@nodelib/fs.stat': 2.0.5
@@ -5250,11 +5310,11 @@ snapshots:
'@types/cookie@0.6.0': {}
- '@types/css-tree@2.3.9': {}
+ '@types/css-tree@2.3.10': {}
'@types/csso@5.0.4':
dependencies:
- '@types/css-tree': 2.3.9
+ '@types/css-tree': 2.3.10
'@types/debug@4.1.12':
dependencies:
@@ -5393,7 +5453,7 @@ snapshots:
- supports-color
optional: true
- agentkeepalive@4.5.0:
+ agentkeepalive@4.6.0:
dependencies:
humanize-ms: 1.2.1
optional: true
@@ -5526,7 +5586,7 @@ snapshots:
rehype: 13.0.2
semver: 7.6.3
shiki: 1.24.4
- tinyexec: 0.3.1
+ tinyexec: 0.3.2
tsconfck: 3.1.4(typescript@5.7.2)
ultrahtml: 1.5.3
unist-util-visit: 5.0.0
@@ -5797,6 +5857,10 @@ snapshots:
strip-ansi: 6.0.1
wrap-ansi: 7.0.0
+ clone-regexp@3.0.0:
+ dependencies:
+ is-regexp: 3.1.0
+
clsx@2.1.1: {}
color-convert@2.0.1:
@@ -5850,6 +5914,8 @@ snapshots:
dependencies:
safe-buffer: 5.2.1
+ convert-hrtime@5.0.0: {}
+
cookie-es@1.2.2: {}
cookie@0.7.2: {}
@@ -6040,6 +6106,8 @@ snapshots:
entities@4.5.0: {}
+ entities@6.0.0: {}
+
env-paths@2.2.1:
optional: true
@@ -6316,6 +6384,8 @@ snapshots:
function-bind@1.1.2: {}
+ function-timeout@0.1.1: {}
+
gauge@4.0.4:
dependencies:
aproba: 2.0.0
@@ -6521,6 +6591,13 @@ snapshots:
html-void-elements@3.0.0: {}
+ htmlparser2@10.0.0:
+ dependencies:
+ domelementtype: 2.3.0
+ domhandler: 5.0.3
+ domutils: 3.2.1
+ entities: 6.0.0
+
htmlparser2@9.1.0:
dependencies:
domelementtype: 2.3.0
@@ -6605,6 +6682,8 @@ snapshots:
sprintf-js: 1.1.3
optional: true
+ ip-regex@5.0.0: {}
+
ipaddr.js@1.9.1: {}
iron-webcrypto@1.2.1: {}
@@ -6635,6 +6714,11 @@ snapshots:
is-interactive@2.0.0: {}
+ is-ip@5.0.1:
+ dependencies:
+ ip-regex: 5.0.0
+ super-regex: 0.2.0
+
is-lambda@1.0.1:
optional: true
@@ -6646,6 +6730,8 @@ snapshots:
dependencies:
'@types/estree': 1.0.6
+ is-regexp@3.1.0: {}
+
is-subdir@1.2.0:
dependencies:
better-path-resolve: 1.0.0
@@ -6825,7 +6911,7 @@ snapshots:
make-fetch-happen@9.1.0:
dependencies:
- agentkeepalive: 4.5.0
+ agentkeepalive: 4.6.0
cacache: 15.3.0
http-cache-semantics: 4.1.1
http-proxy-agent: 4.0.1
@@ -7435,6 +7521,10 @@ snapshots:
dot-case: 3.0.4
tslib: 2.8.1
+ parse-domain@8.2.2:
+ dependencies:
+ is-ip: 5.0.1
+
parse-latin@7.0.0:
dependencies:
'@types/nlcst': 2.0.3
@@ -8190,6 +8280,12 @@ snapshots:
pirates: 4.0.6
ts-interface-checker: 0.1.13
+ super-regex@0.2.0:
+ dependencies:
+ clone-regexp: 3.0.0
+ function-timeout: 0.1.1
+ time-span: 5.1.0
+
supports-preserve-symlinks-flag@1.0.0: {}
svelte-french-toast@1.2.0(svelte@5.16.0):
@@ -8312,9 +8408,13 @@ snapshots:
readable-stream: 2.3.8
xtend: 4.0.2
+ time-span@5.1.0:
+ dependencies:
+ convert-hrtime: 5.0.0
+
tinycolor2@1.6.0: {}
- tinyexec@0.3.1: {}
+ tinyexec@0.3.2: {}
tinygradient@1.1.5:
dependencies:
diff --git a/public/sw.js b/public/sw.js
index 0e18e2de..4a72486c 100644
--- a/public/sw.js
+++ b/public/sw.js
@@ -1,10 +1,16 @@
importScripts("/uv/uv.bundle.js");
importScripts("/uv/uv.config.js");
+importScripts('/scram/scramjet.wasm.js');
+importScripts('/scram/scramjet.shared.js');
+importScripts('/scram/scramjet.worker.js');
importScripts("/workerware/workerware.js");
importScripts(__uv$config.sw || "/uv/uv.sw.js");
const uv = new UVServiceWorker();
const ww = new WorkerWare({ debug: false });
-
+const sj = new ScramjetServiceWorker();
+(async function () {
+ await sj.loadConfig();
+})();
//me when Firefox (thanks vk6)
if (navigator.userAgent.includes("Firefox")) {
Object.defineProperty(globalThis, "crossOriginIsolated", {
@@ -57,7 +63,11 @@ self.addEventListener("fetch", function (event) {
}
if (event.request.url.startsWith(location.origin + __uv$config.prefix)) {
return await uv.fetch(event);
- } else {
+ }
+ else if (sj.route(event)) {
+ return await sj.fetch(event);
+ }
+ else {
return await fetch(event.request);
}
})()
diff --git a/src/components/settings/Loader.astro b/src/components/settings/Loader.astro
index 9827cf38..d1bb11a2 100644
--- a/src/components/settings/Loader.astro
+++ b/src/components/settings/Loader.astro
@@ -20,6 +20,6 @@
localStorage.getItem(Settings.ProxySettings.transport) as string
);
const sw = await initSw();
- await setSWStuff({sw, conn});
+ await setSWStuff({sw: sw.sw, conn, sj: sw.sj });
});
diff --git a/src/env.d.ts b/src/env.d.ts
index c6214926..1cbecdbb 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -1,3 +1,45 @@
///
///
///
+interface SJOptions {
+ prefix: string;
+ globals?: {
+ wrapfn: string;
+ wrapthisfn: string;
+ trysetfn: string;
+ importfn: string;
+ rewritefn: string;
+ metafn: string;
+ setrealmfn: string;
+ pushsourcemapfn: string;
+ };
+ files: {
+ wasm: string;
+ shared: string;
+ worker: string;
+ client: string;
+ sync: string;
+ };
+ flags?: {
+ serviceworkers: boolean;
+ syncxhr: boolean;
+ naiiveRewriter: boolean;
+ strictRewrites: boolean;
+ rewriterLogs: boolean;
+ captureErrors: boolean;
+ cleanErrors: boolean;
+ scramitize: boolean;
+ sourcemaps: boolean;
+ };
+ siteFlags?: {};
+ codec?: {
+ encode: string;
+ decode: string;
+ };
+}
+
+declare class ScramjetController {
+ constructor(opts: SJOptions);
+ async init(sw: string): any;
+ encodeUrl(term: string): string;
+}
diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro
index d08a5f7e..7d48e901 100644
--- a/src/pages/[lang]/index.astro
+++ b/src/pages/[lang]/index.astro
@@ -63,44 +63,33 @@ import { VERSION } from "astro:env/client";
type Suggestion = {
phrase: string;
};
- async function proxy(term: string) {
- const searchEngine = localStorage.getItem(
- Settings.ProxySettings.searchEngine
- );
- const openIn = localStorage.getItem(Settings.ProxySettings.openIn);
- let proxyUrl: any =
- __uv$config!.prefix +
- __uv$config.encodeUrl!(
- search(
- term,
- searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg
- )
- );
- if (openIn === "a:b" || openIn === "blob") {
- return cloak(
- openIn as string,
- "https://google.com",
- `${window.location.origin}${proxyUrl}`
- );
- } else if (openIn === "direct") {
- return (window.location.href = proxyUrl as string);
- } else {
- return proxyUrl;
- }
+ function proxy(term: string, scram: typeof ScramjetController, pr: "uv" | "sj"): string {
+ const searchEngine = localStorage.getItem(Settings.ProxySettings.searchEngine);
+ const openIn = localStorage.getItem(Settings.ProxySettings.openIn);
+ return pr === "uv" ? `${__uv$config!.prefix}${__uv$config.encodeUrl!(search(term, searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg))}` : scram.encodeUrl(search(term, searchEngine ? SearchEngines[searchEngine] : SearchEngines.ddg ))
}
async function uv(iframe: HTMLIFrameElement, term: string) {
- const { sw, conn } = getSWStuff();
+ const { sw, conn, sj } = getSWStuff();
await setTransport(
conn,
localStorage.getItem(Settings.ProxySettings.transport) as string
);
await settings.marketPlaceSettings.handlePlugins(sw);
iframe.classList.remove("hidden");
- const url = await proxy(term);
+ const url = proxy(term, sj, "uv");
if (url) {
iframe.src = url;
}
}
+ async function sj(iframe: HTMLIFrameElement, term: string) {
+ const { sw, conn, sj } = getSWStuff();
+ await setTransport(conn, localStorage.getItem(Settings.ProxySettings.transport) as string);
+ iframe.classList.remove("hidden");
+ const url = proxy(term, sj, "sj");
+ if (url) {
+ iframe.src = url;
+ }
+ }
//we need to rerun this on every page load
pageLoad(async () => {
const input = document.getElementById("nebula-input") as HTMLInputElement;
@@ -111,9 +100,7 @@ import { VERSION } from "astro:env/client";
input?.addEventListener("keypress", async function (event: any) {
if (event.key === "Enter") {
copyright.classList.add("hidden");
- if (
- localStorage.getItem(Settings.ProxySettings.proxy) === "automatic"
- ) {
+ if (localStorage.getItem(Settings.ProxySettings.proxy) === "automatic") {
const key = SupportedSites[input?.value];
switch (key) {
case "uv":
@@ -123,11 +110,13 @@ import { VERSION } from "astro:env/client";
uv(iframe, input?.value);
break;
}
- } else if (
- localStorage.getItem(Settings.ProxySettings.proxy) === "uv"
- ) {
+ }
+ else if (localStorage.getItem(Settings.ProxySettings.proxy) === "uv") {
uv(iframe, input?.value);
}
+ else if (localStorage.getItem(Settings.ProxySettings.proxy) === "sj") {
+ sj(iframe, input?.value);
+ }
}
});
input?.addEventListener("input", async function () {
@@ -195,5 +184,5 @@ import { VERSION } from "astro:env/client";
}
}
});
- });
+ }, true);
diff --git a/src/pages/[lang]/settings/pr.astro b/src/pages/[lang]/settings/pr.astro
index 1cf1f45d..0a31405f 100644
--- a/src/pages/[lang]/settings/pr.astro
+++ b/src/pages/[lang]/settings/pr.astro
@@ -34,7 +34,7 @@ import { MARKETPLACE_ENABLED } from "astro:env/client";
options: [
{ name: "Automatic", value: "automatic", disabled: false },
{ name: "Ultraviolet", value: "uv", disabled: false },
- { name: "Scramjet (COMING SOON)", value: "sj", disabled: true },
+ { name: "Scramjet (BETA)", value: "sj", disabled: false },
],
}}
both={{enabled: false}}
diff --git a/src/utils/registerSW.ts b/src/utils/registerSW.ts
index 36908613..0bf2ab01 100644
--- a/src/utils/registerSW.ts
+++ b/src/utils/registerSW.ts
@@ -1,8 +1,8 @@
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";
import { Settings, WispServerURLS } from "./settings/index";
-
let baremuxConn: BareMuxConnection;
let swReg: ServiceWorkerRegistration;
+let sj: typeof ScramjetController;
function loadProxyScripts() {
//wrap everything in a promise to avoid race conditions
@@ -19,8 +19,12 @@ function loadProxyScripts() {
uvConfig.src = "/uv/uv.config.js";
uvConfig.defer = true;
document.body.appendChild(uvConfig);
+ const sj = document.createElement('script');
+ sj.src = "/scram/scramjet.controller.js";
+ sj.defer = true;
+ document.body.appendChild(sj);
const checkScript = setInterval(() => {
- if (typeof __uv$config !== "undefined") {
+ if (typeof __uv$config !== "undefined" && typeof ScramjetController !== "undefined") {
clearInterval(checkScript);
resolve(conn);
}
@@ -50,14 +54,30 @@ function setTransport(conn: BareMuxConnection, transport?: string) {
}
function initSw() {
+ type SWPromise = {
+ sw: ServiceWorkerRegistration,
+ sj: ScramjetController
+ }
//this is wrapped in a promise to mostly solve the bare-mux v1 problems
- return new Promise((resolve) => {
+ return new Promise(async (resolve) => {
if ("serviceWorker" in navigator) {
+ const sjOpts = {
+ prefix: "/~/scramjet/",
+ files: {
+ wasm: "/scram/scramjet.wasm.js",
+ worker: "/scram/scramjet.worker.js",
+ client: "/scram/scramjet.client.js",
+ shared: "/scram/scramjet.shared.js",
+ sync: "/scram/scramjet.sync.js"
+ }
+ }
+ const sj = new ScramjetController(sjOpts);
navigator.serviceWorker.ready.then(async (reg) => {
console.debug("Service worker ready!");
- resolve(reg);
+ resolve({ sw: reg, sj: sj });
});
- navigator.serviceWorker.register("/sw.js", { scope: "/" });
+ await sj.init('/sw.js');
+ //navigator.serviceWorker.register("/sw.js", { scope: "/" });
}
});
}
@@ -65,12 +85,14 @@ function initSw() {
interface SWStuff {
sw: ServiceWorkerRegistration;
conn: BareMuxConnection;
+ sj: typeof ScramjetController;
}
function setSWStuff(stuff: SWStuff): Promise {
return new Promise((resolve) => {
swReg = stuff.sw;
baremuxConn = stuff.conn;
+ sj = stuff.sj;
resolve();
});
}
@@ -78,7 +100,8 @@ function setSWStuff(stuff: SWStuff): Promise {
function getSWStuff(): SWStuff {
const stuff: SWStuff = {
sw: swReg,
- conn: baremuxConn
+ conn: baremuxConn,
+ sj: sj
};
return stuff;
}