aether-mrralex-demo 0.0.0-stage → 1.0.0
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/NOTICE.md +11 -0
- package/README.md +8 -2
- package/adblock-count.json +1 -0
- package/adblock-rules.js +68 -0
- package/app.html +315 -0
- package/baremux/index.js +2 -0
- package/baremux/index.mjs +2 -0
- package/baremux/worker.js +2 -0
- package/css/app.css +1769 -0
- package/favicon-browser.svg +1 -0
- package/favicon-games.svg +1 -0
- package/favicon.svg +1 -0
- package/games/game.css +260 -0
- package/games/index.html +126 -0
- package/games/list.json +1 -0
- package/games/play.html +91 -0
- package/index.html +123 -0
- package/js/assistant.js +318 -0
- package/js/boot-screen.js +35 -0
- package/js/browser.js +1274 -0
- package/js/config.js +9 -0
- package/js/landing.js +90 -0
- package/js/shortcuts.js +136 -0
- package/js/space.js +135 -0
- package/js/static-engine.js +28 -0
- package/js/static-games-worker.js +51 -0
- package/js/theme.js +45 -0
- package/js/transport-core.js +56 -0
- package/js/transport.js +139 -0
- package/js/url.js +22 -0
- package/libcurl/libcurl_full.mjs +1521 -0
- package/licenses/baremux.txt +7 -0
- package/licenses/libcurl.txt +165 -0
- package/licenses/scramjet.txt +661 -0
- package/package.json +25 -4
- package/scramjet/scramjet.all.js +196 -0
- package/scramjet/scramjet.sync.js +2 -0
- package/scramjet/scramjet.wasm.wasm +0 -0
- package/shared.js +20 -0
- package/source/package-lock.json +1237 -0
- package/source/package.json +25 -0
- package/source/public/adblock-rules.js +68 -0
- package/source/public/app.html +315 -0
- package/source/public/css/app.css +1769 -0
- package/source/public/favicon-browser.svg +1 -0
- package/source/public/favicon-games.svg +1 -0
- package/source/public/favicon.svg +1 -0
- package/source/public/games/game.css +260 -0
- package/source/public/games/index.html +125 -0
- package/source/public/games/play.html +90 -0
- package/source/public/index.html +123 -0
- package/source/public/js/assistant.js +317 -0
- package/source/public/js/boot-screen.js +35 -0
- package/source/public/js/browser.js +1274 -0
- package/source/public/js/config.js +18 -0
- package/source/public/js/landing.js +90 -0
- package/source/public/js/shortcuts.js +136 -0
- package/source/public/js/space.js +135 -0
- package/source/public/js/theme.js +45 -0
- package/source/public/js/transport.js +56 -0
- package/source/public/js/url.js +22 -0
- package/source/public/shared.js +18 -0
- package/source/public/sw.js +208 -0
- package/source/scripts/build-unpkg.mjs +131 -0
- package/source/scripts/unpkg/static-engine.js +28 -0
- package/source/scripts/unpkg/static-games-worker.js +51 -0
- package/source/scripts/unpkg/transport.js +139 -0
- package/source/server/vendor.js +39 -0
- package/sw.js +210 -0
package/NOTICE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Bundled components retain their respective licenses:
|
|
4
|
+
|
|
5
|
+
- Scramjet 1.1.0: https://github.com/MercuryWorkshop/scramjet . The distributed LICENSE file is AGPL-3.0 and is reproduced in licenses/scramjet.txt; its npm metadata labels it MIT.
|
|
6
|
+
- BareMux 2.1.9, MIT: https://github.com/MercuryWorkshop/bare-mux
|
|
7
|
+
- libcurl.js 0.7.5, LGPL-3.0-or-later: https://github.com/ading2210/libcurl.js (source and build instructions). The libcurl module is unmodified and dynamically imported.
|
|
8
|
+
|
|
9
|
+
License texts are in licenses/. Scramjet and BareMux JS bundles have only their storage/channel names changed to isolate this package on a shared origin. Editable frontend source, the modification/build script, and the dependency lockfile are included in source/. To reproduce: cd source, npm ci, then npm run build:unpkg -- aether-mrralex-demo 1.0.0. Upstream component source is available from the linked repositories and the exact versions in source/package-lock.json.
|
|
10
|
+
|
|
11
|
+
Game catalogue metadata comes from https://github.com/gn-math/assets; game files remain upstream and are not bundled.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Aether demo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Open https://unpkg.com/aether-mrralex-demo@1.0.0/index.html
|
|
4
|
+
|
|
5
|
+
Static frontend with bundled browser runtimes. Uses wisp.mercurywork.shop first, then anura.pro; stops if both are unavailable. Community relays have no uptime guarantee. Game files are fetched on demand through Wisp. The optional assistant is unavailable without a separate API.
|
|
6
|
+
|
|
7
|
+
Use the exact versioned URL above so the service-worker scope and asset paths agree. This is a public demo package; publishing does not automatically expire it after two days.
|
|
8
|
+
|
|
9
|
+
See NOTICE.md and licenses/ for third-party components.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"hosts":48}
|
package/adblock-rules.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ad and tracker hosts blocked by the service worker.
|
|
3
|
+
*
|
|
4
|
+
* Matching is suffix based, so "doubleclick.net" also blocks
|
|
5
|
+
* "ad.doubleclick.net". Keep this list focused on advertising and analytics
|
|
6
|
+
* infrastructure; blocking everyday CDNs breaks far more than it fixes.
|
|
7
|
+
*
|
|
8
|
+
* YouTube's ads are served from the same hosts as its video streams, so they
|
|
9
|
+
* cannot be blocked here without breaking playback. The player skips them
|
|
10
|
+
* client-side instead (see skipVideoAds in js/browser.js).
|
|
11
|
+
*/
|
|
12
|
+
self.AETHER_ADBLOCK_DOMAINS = [
|
|
13
|
+
// Google advertising and analytics
|
|
14
|
+
"doubleclick.net",
|
|
15
|
+
"googleadservices.com",
|
|
16
|
+
"googlesyndication.com",
|
|
17
|
+
"googletagmanager.com",
|
|
18
|
+
"googletagservices.com",
|
|
19
|
+
"google-analytics.com",
|
|
20
|
+
"2mdn.net",
|
|
21
|
+
"admob.com",
|
|
22
|
+
"adservice.google.com",
|
|
23
|
+
|
|
24
|
+
// Ad exchanges and networks
|
|
25
|
+
"adnxs.com",
|
|
26
|
+
"adsrvr.org",
|
|
27
|
+
"adform.net",
|
|
28
|
+
"adroll.com",
|
|
29
|
+
"amazon-adsystem.com",
|
|
30
|
+
"bidswitch.net",
|
|
31
|
+
"casalemedia.com",
|
|
32
|
+
"criteo.com",
|
|
33
|
+
"criteo.net",
|
|
34
|
+
"media.net",
|
|
35
|
+
"moatads.com",
|
|
36
|
+
"openx.net",
|
|
37
|
+
"outbrain.com",
|
|
38
|
+
"pubmatic.com",
|
|
39
|
+
"rubiconproject.com",
|
|
40
|
+
"sharethrough.com",
|
|
41
|
+
"smartadserver.com",
|
|
42
|
+
"taboola.com",
|
|
43
|
+
"teads.tv",
|
|
44
|
+
"yieldmo.com",
|
|
45
|
+
"zergnet.com",
|
|
46
|
+
|
|
47
|
+
// Data brokers and behavioural tracking
|
|
48
|
+
"bluekai.com",
|
|
49
|
+
"demdex.net",
|
|
50
|
+
"everesttech.net",
|
|
51
|
+
"exelator.com",
|
|
52
|
+
"krxd.net",
|
|
53
|
+
"omtrdc.net",
|
|
54
|
+
"quantcount.com",
|
|
55
|
+
"quantserve.com",
|
|
56
|
+
"scorecardresearch.com",
|
|
57
|
+
"tapad.com",
|
|
58
|
+
|
|
59
|
+
// Session recording and product analytics
|
|
60
|
+
"amplitude.com",
|
|
61
|
+
"clarity.ms",
|
|
62
|
+
"fullstory.com",
|
|
63
|
+
"hotjar.com",
|
|
64
|
+
"mixpanel.com",
|
|
65
|
+
"mouseflow.com",
|
|
66
|
+
"segment.io",
|
|
67
|
+
"smartlook.com",
|
|
68
|
+
];
|
package/app.html
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
|
6
|
+
<meta name="color-scheme" content="dark light">
|
|
7
|
+
<title>Browser — Aether</title>
|
|
8
|
+
<link rel="icon" href="/aether-mrralex-demo@1.0.0/favicon-browser.svg?v=2" type="image/svg+xml">
|
|
9
|
+
<link rel="stylesheet" href="/aether-mrralex-demo@1.0.0/css/app.css">
|
|
10
|
+
<script>
|
|
11
|
+
(function () {
|
|
12
|
+
try {
|
|
13
|
+
var theme = localStorage.getItem("aether-mrralex-demo@1.0.0:theme");
|
|
14
|
+
if (theme === "light" || theme === "dark") document.documentElement.dataset.theme = theme;
|
|
15
|
+
} catch (error) {}
|
|
16
|
+
})();
|
|
17
|
+
</script>
|
|
18
|
+
</head>
|
|
19
|
+
<body class="shell">
|
|
20
|
+
<div class="browser">
|
|
21
|
+
<div class="tabstrip">
|
|
22
|
+
<div class="tabs" id="tabs" role="tablist" aria-label="Open tabs"></div>
|
|
23
|
+
<button class="icon-btn" id="new-tab" type="button" aria-label="New tab" title="New tab (Ctrl+T)">
|
|
24
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true">
|
|
25
|
+
<path d="M12 5v14M5 12h14"/>
|
|
26
|
+
</svg>
|
|
27
|
+
</button>
|
|
28
|
+
<span class="strip-divider" aria-hidden="true"></span>
|
|
29
|
+
<button class="icon-btn" id="history-btn" type="button" aria-label="Recently visited" aria-expanded="false" title="Recently visited">
|
|
30
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
31
|
+
<circle cx="12" cy="12" r="8.4"/>
|
|
32
|
+
<path d="M12 7.4V12l3.1 1.9"/>
|
|
33
|
+
</svg>
|
|
34
|
+
</button>
|
|
35
|
+
|
|
36
|
+
<div class="history-pop" id="history-pop" hidden>
|
|
37
|
+
<div class="history-head">
|
|
38
|
+
<span>Recently visited</span>
|
|
39
|
+
<button class="history-clear" id="history-clear" type="button">Clear</button>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="history-list" id="history-list"></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div class="toolbar">
|
|
46
|
+
<div class="nav-group">
|
|
47
|
+
<button class="icon-btn" id="back" type="button" aria-label="Back" title="Back (Alt+Left)">
|
|
48
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
49
|
+
<path d="M15 18l-6-6 6-6"/>
|
|
50
|
+
</svg>
|
|
51
|
+
</button>
|
|
52
|
+
<button class="icon-btn" id="forward" type="button" aria-label="Forward" title="Forward (Alt+Right)">
|
|
53
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
54
|
+
<path d="M9 6l6 6-6 6"/>
|
|
55
|
+
</svg>
|
|
56
|
+
</button>
|
|
57
|
+
<button class="icon-btn" id="reload" type="button" aria-label="Reload" title="Reload">
|
|
58
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
59
|
+
<path d="M20 12a8 8 0 1 1-2.6-5.9"/>
|
|
60
|
+
<path d="M20 4.5V10h-5.5"/>
|
|
61
|
+
</svg>
|
|
62
|
+
</button>
|
|
63
|
+
<button class="icon-btn" id="home" type="button" aria-label="Home" title="Home">
|
|
64
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
65
|
+
<path d="M4 11l8-7 8 7"/>
|
|
66
|
+
<path d="M6.5 9.8V20h11V9.8"/>
|
|
67
|
+
</svg>
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<form class="address" id="address-form" role="search" autocomplete="off">
|
|
72
|
+
<input id="address" type="text" aria-label="Address and search"
|
|
73
|
+
placeholder="Search or enter a URL" spellcheck="false"
|
|
74
|
+
autocapitalize="off" autocorrect="off">
|
|
75
|
+
<button class="go" type="submit">Go</button>
|
|
76
|
+
</form>
|
|
77
|
+
|
|
78
|
+
<div class="toolbar-actions">
|
|
79
|
+
<button class="icon-btn" id="toggle-adblock" type="button" aria-pressed="true" aria-label="Ad blocking" title="Ad blocking is on">
|
|
80
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
81
|
+
<path d="M12 3l7 2.8v5.9c0 4.1-3 6.8-7 9.3-4-2.5-7-5.2-7-9.3V5.8z"/>
|
|
82
|
+
<path d="M9 12l2.2 2.2L15.5 10"/>
|
|
83
|
+
</svg>
|
|
84
|
+
</button>
|
|
85
|
+
<button class="icon-btn" id="settings" type="button" aria-label="Settings" title="Settings">
|
|
86
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" aria-hidden="true">
|
|
87
|
+
<path d="M4 7h9M17 7h3M4 17h3M11 17h9"/>
|
|
88
|
+
<circle cx="15" cy="7" r="2.2"/>
|
|
89
|
+
<circle cx="9" cy="17" r="2.2"/>
|
|
90
|
+
</svg>
|
|
91
|
+
</button>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<main class="viewport" id="viewport">
|
|
96
|
+
<div class="load-line" id="load-line" hidden aria-hidden="true"></div>
|
|
97
|
+
<div class="frames" id="frames"></div>
|
|
98
|
+
|
|
99
|
+
<div class="loading-screen" id="loading-screen" hidden aria-live="polite">
|
|
100
|
+
<div class="loading-card">
|
|
101
|
+
<span class="loading-kicker">Initializing the UI</span>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<section class="start" id="start" aria-label="New tab">
|
|
106
|
+
<svg class="start-mark" viewBox="0 0 24 24" aria-hidden="true">
|
|
107
|
+
<path d="M12 2.6l1.8 5.6 5.6 1.8-5.6 1.8L12 17.4l-1.8-5.6L4.6 10l5.6-1.8z" fill="currentColor"/>
|
|
108
|
+
</svg>
|
|
109
|
+
<h2>New Tab</h2>
|
|
110
|
+
<p>Enter an address above, or start somewhere familiar.</p>
|
|
111
|
+
<nav class="quick-links" aria-label="Quick links">
|
|
112
|
+
<a class="quick-link" href="https://www.youtube.com" data-quick-link="https://www.youtube.com" title="YouTube" aria-label="Open YouTube">
|
|
113
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
|
|
114
|
+
</a>
|
|
115
|
+
<a class="quick-link" href="https://discord.com/app" data-quick-link="https://discord.com/app" title="Discord" aria-label="Open Discord">
|
|
116
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20.317 4.37a19.79 19.79 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.865-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.058a.082.082 0 0 0 .031.056 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.873-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.1 13.1 0 0 1-1.872-.892.077.077 0 0 1-.008-.128c.126-.094.252-.192.372-.291a.074.074 0 0 1 .078-.01c3.928 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .079.009c.12.099.246.198.373.292a.077.077 0 0 1-.007.128 12.3 12.3 0 0 1-1.873.891.077.077 0 0 0-.04.107c.36.698.772 1.363 1.225 1.993a.076.076 0 0 0 .084.029 19.84 19.84 0 0 0 6.002-3.03.077.077 0 0 0 .032-.055c.5-5.177-.838-9.674-3.549-13.66a.06.06 0 0 0-.031-.029zM8.02 15.331c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.211 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.211 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>
|
|
117
|
+
</a>
|
|
118
|
+
<a class="quick-link" href="https://www.reddit.com" data-quick-link="https://www.reddit.com" title="Reddit" aria-label="Open Reddit">
|
|
119
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 0C5.373 0 0 5.373 0 12c0 3.314 1.343 6.314 3.515 8.485l-2.286 2.286C.775 23.225 1.097 24 1.738 24H12c6.627 0 12-5.373 12-12S18.627 0 12 0zm4.388 3.199c1.104 0 1.999.895 1.999 1.999 0 1.105-.895 2-1.999 2-.946 0-1.739-.657-1.947-1.539v.002c-1.147.162-2.032 1.15-2.032 2.341v.007c1.776.067 3.4.567 4.686 1.363.473-.363 1.064-.58 1.707-.58 1.547 0 2.802 1.254 2.802 2.802 0 1.117-.655 2.081-1.601 2.531-.088 3.256-3.637 5.876-7.997 5.876-4.361 0-7.905-2.617-7.998-5.87-.954-.447-1.614-1.415-1.614-2.538 0-1.548 1.255-2.802 2.803-2.802.645 0 1.239.218 1.712.585 1.275-.79 2.881-1.291 4.64-1.365v-.01c0-1.663 1.263-3.034 2.88-3.207.188-.911.993-1.595 1.959-1.595zm-8.085 8.376c-.784 0-1.459.78-1.506 1.797-.047 1.016.64 1.429 1.426 1.429.786 0 1.371-.369 1.418-1.385.047-1.017-.553-1.841-1.338-1.841zm7.406 0c-.786 0-1.385.824-1.338 1.841.047 1.017.634 1.385 1.418 1.385.785 0 1.473-.413 1.426-1.429-.046-1.017-.721-1.797-1.506-1.797zm-3.703 4.013c-.974 0-1.907.048-2.77.135-.147.015-.241.168-.183.305.483 1.154 1.622 1.964 2.953 1.964 1.33 0 2.47-.81 2.953-1.964.057-.137-.037-.29-.184-.305-.863-.087-1.795-.135-2.769-.135z"/></svg>
|
|
120
|
+
</a>
|
|
121
|
+
<a class="quick-link" href="https://www.google.com" data-quick-link="https://www.google.com" title="Google" aria-label="Open Google">
|
|
122
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"/></svg>
|
|
123
|
+
</a>
|
|
124
|
+
<a class="quick-link" href="https://open.spotify.com" data-quick-link="https://open.spotify.com" title="Spotify" aria-label="Open Spotify">
|
|
125
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z"/></svg>
|
|
126
|
+
</a>
|
|
127
|
+
</nav>
|
|
128
|
+
<p class="start-hint">Ctrl+L focuses the address bar. Ctrl+T opens a tab.</p>
|
|
129
|
+
|
|
130
|
+
</section>
|
|
131
|
+
|
|
132
|
+
<div class="launcher" data-launcher>
|
|
133
|
+
<div class="launcher-menu" data-launcher-menu hidden aria-label="Shortcuts"></div>
|
|
134
|
+
<button class="launcher-trigger" type="button" aria-expanded="false" aria-label="Shortcuts" title="Shortcuts">
|
|
135
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="4.5" width="18" height="15" rx="2.5"/><path d="M3 9h18"/><circle cx="6.5" cy="6.8" r=".7" fill="currentColor" stroke="none"/><circle cx="9" cy="6.8" r=".7" fill="currentColor" stroke="none"/></svg>
|
|
136
|
+
</button>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<section class="fault" id="fault" hidden>
|
|
140
|
+
<h2>The proxy didn't start</h2>
|
|
141
|
+
<p id="fault-detail">Something went wrong before the first page could load.</p>
|
|
142
|
+
<button class="btn btn-secondary" id="fault-retry" type="button">Try again</button>
|
|
143
|
+
</section>
|
|
144
|
+
</main>
|
|
145
|
+
|
|
146
|
+
<button class="ai-trigger" id="ai-trigger" type="button" aria-label="Open assistant" aria-expanded="false" title="Assistant">
|
|
147
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
148
|
+
<path d="M12 2.6l1.8 5.6 5.6 1.8-5.6 1.8L12 17.4l-1.8-5.6L4.6 10l5.6-1.8z" fill="currentColor"/>
|
|
149
|
+
<path d="M19 15.2l.8 2.5 2.5.8-2.5.8-.8 2.5-.8-2.5-2.5-.8 2.5-.8z" fill="currentColor" opacity=".55"/>
|
|
150
|
+
</svg>
|
|
151
|
+
</button>
|
|
152
|
+
|
|
153
|
+
<aside class="ai-panel" id="ai-panel" aria-label="Assistant" aria-hidden="true">
|
|
154
|
+
<header class="ai-head">
|
|
155
|
+
<div class="ai-title">
|
|
156
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
157
|
+
<path d="M12 2.6l1.8 5.6 5.6 1.8-5.6 1.8L12 17.4l-1.8-5.6L4.6 10l5.6-1.8z" fill="currentColor"/>
|
|
158
|
+
</svg>
|
|
159
|
+
<span>Assistant</span>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="ai-head-actions">
|
|
162
|
+
<button class="chip" id="ai-page-toggle" type="button" aria-pressed="true" title="Include the current page's text in messages">Page</button>
|
|
163
|
+
<button class="icon-btn" id="ai-close" type="button" aria-label="Close assistant">
|
|
164
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true">
|
|
165
|
+
<path d="M6 6l12 12M18 6L6 18"/>
|
|
166
|
+
</svg>
|
|
167
|
+
</button>
|
|
168
|
+
</div>
|
|
169
|
+
</header>
|
|
170
|
+
|
|
171
|
+
<div class="ai-log" id="ai-log" role="log" aria-live="off">
|
|
172
|
+
<p class="ai-intro">Ask anything. Turn on <strong>Page</strong> to give the assistant the text of the page you're on.</p>
|
|
173
|
+
<div class="ai-suggestions" id="ai-suggestions">
|
|
174
|
+
<button class="chip" type="button" data-ai-prompt="Summarize this page.">Summarize page</button>
|
|
175
|
+
<button class="chip" type="button" data-ai-prompt="What are the key points on this page?">Key points</button>
|
|
176
|
+
<button class="chip" type="button" data-ai-prompt="Find a video about ">Find a video</button>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<p class="ai-notice" id="ai-notice" hidden></p>
|
|
181
|
+
|
|
182
|
+
<form class="ai-compose" id="ai-form">
|
|
183
|
+
<textarea id="ai-input" rows="1" placeholder="Message the assistant" aria-label="Message the assistant"></textarea>
|
|
184
|
+
<button class="ai-send" id="ai-send" type="submit" aria-label="Send message">
|
|
185
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
186
|
+
<path d="M12 19V5M6 11l6-6 6 6"/>
|
|
187
|
+
</svg>
|
|
188
|
+
</button>
|
|
189
|
+
</form>
|
|
190
|
+
<footer class="ai-foot" id="ai-foot" aria-live="polite"></footer>
|
|
191
|
+
</aside>
|
|
192
|
+
|
|
193
|
+
<dialog class="sheet settings-sheet" id="settings-dialog" aria-label="Settings">
|
|
194
|
+
<div class="sheet-head">
|
|
195
|
+
<h2>Settings</h2>
|
|
196
|
+
<button class="icon-btn" id="settings-close" type="button" aria-label="Close settings">
|
|
197
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true">
|
|
198
|
+
<path d="M6 6l12 12M18 6L6 18"/>
|
|
199
|
+
</svg>
|
|
200
|
+
</button>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div class="settings-body">
|
|
204
|
+
<nav class="settings-nav" aria-label="Settings sections">
|
|
205
|
+
<button class="settings-tab is-active" type="button" data-settings-tab="appearance">Appearance</button>
|
|
206
|
+
<button class="settings-tab" type="button" data-settings-tab="privacy">Privacy</button>
|
|
207
|
+
<button class="settings-tab" type="button" data-settings-tab="proxy">Proxy</button>
|
|
208
|
+
<button class="settings-tab" type="button" data-settings-tab="advanced">Advanced</button>
|
|
209
|
+
</nav>
|
|
210
|
+
|
|
211
|
+
<div class="settings-panes">
|
|
212
|
+
<section class="settings-pane" data-settings-pane="appearance">
|
|
213
|
+
<div class="setting">
|
|
214
|
+
<div>
|
|
215
|
+
<div class="setting-label">Theme</div>
|
|
216
|
+
<div class="setting-hint">Dark by default.</div>
|
|
217
|
+
</div>
|
|
218
|
+
<div class="seg" role="group" aria-label="Theme">
|
|
219
|
+
<button type="button" data-theme-set="light" aria-pressed="false">Light</button>
|
|
220
|
+
<button type="button" data-theme-set="dark" aria-pressed="true">Dark</button>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div class="setting">
|
|
225
|
+
<div>
|
|
226
|
+
<div class="setting-label">Animations</div>
|
|
227
|
+
<div class="setting-hint">Soft transitions across the interface.</div>
|
|
228
|
+
</div>
|
|
229
|
+
<input class="switch" id="motion-switch" type="checkbox" role="switch" aria-label="Animations" checked>
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
<div class="setting setting-stack">
|
|
233
|
+
<div>
|
|
234
|
+
<div class="setting-label">Shortcuts</div>
|
|
235
|
+
<div class="setting-hint">What the launcher offers. Home and Games always stay.</div>
|
|
236
|
+
</div>
|
|
237
|
+
<div class="shortcut-chips" id="shortcut-chips"></div>
|
|
238
|
+
</div>
|
|
239
|
+
</section>
|
|
240
|
+
|
|
241
|
+
<section class="settings-pane" data-settings-pane="privacy" hidden>
|
|
242
|
+
<div class="setting">
|
|
243
|
+
<div>
|
|
244
|
+
<div class="setting-label">Ad blocking</div>
|
|
245
|
+
<div class="setting-hint">Filters ad and tracking hosts, and skips YouTube ads where possible.</div>
|
|
246
|
+
</div>
|
|
247
|
+
<input class="switch" id="adblock-switch" type="checkbox" role="switch" aria-label="Ad blocking" checked>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
<div class="setting">
|
|
251
|
+
<div>
|
|
252
|
+
<div class="setting-label">Browsing data</div>
|
|
253
|
+
<div class="setting-hint">Clears proxied cookies, storage and cached files.</div>
|
|
254
|
+
</div>
|
|
255
|
+
<button class="btn btn-quiet" id="clear-data" type="button">Clear</button>
|
|
256
|
+
</div>
|
|
257
|
+
</section>
|
|
258
|
+
|
|
259
|
+
<section class="settings-pane" data-settings-pane="proxy" hidden>
|
|
260
|
+
<div class="setting">
|
|
261
|
+
<div>
|
|
262
|
+
<div class="setting-label">Search engine</div>
|
|
263
|
+
<div class="setting-hint">Used when the address bar gets words instead of an address.</div>
|
|
264
|
+
</div>
|
|
265
|
+
<select class="field-select" id="engine-select" aria-label="Search engine"></select>
|
|
266
|
+
</div>
|
|
267
|
+
|
|
268
|
+
<div class="setting">
|
|
269
|
+
<div>
|
|
270
|
+
<div class="setting-label">Transport</div>
|
|
271
|
+
<div class="setting-hint">Libcurl over Wisp, served by this instance.</div>
|
|
272
|
+
</div>
|
|
273
|
+
<span class="setting-value">libcurl</span>
|
|
274
|
+
</div>
|
|
275
|
+
</section>
|
|
276
|
+
|
|
277
|
+
<section class="settings-pane" data-settings-pane="advanced" hidden>
|
|
278
|
+
<div class="setting">
|
|
279
|
+
<div>
|
|
280
|
+
<div class="setting-label">Force update</div>
|
|
281
|
+
<div class="setting-hint">Drops cached engine files and restarts the proxy.</div>
|
|
282
|
+
</div>
|
|
283
|
+
<button class="btn btn-quiet" id="force-update" type="button">Clear</button>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<div class="setting">
|
|
287
|
+
<div>
|
|
288
|
+
<div class="setting-label">Assistant</div>
|
|
289
|
+
<div class="setting-hint" id="settings-ai">Configured on this server.</div>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
<div class="setting about">
|
|
294
|
+
<div>
|
|
295
|
+
<div class="setting-label">Aether</div>
|
|
296
|
+
<div class="setting-hint">Proxy engine: Scramjet 1.1.0. Transport: libcurl over Wisp.</div>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
</section>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</dialog>
|
|
303
|
+
|
|
304
|
+
<div class="toast" id="toast" role="status" aria-live="polite"></div>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<script src="/aether-mrralex-demo@1.0.0/shared.js"></script>
|
|
308
|
+
<script src="/aether-mrralex-demo@1.0.0/scramjet/scramjet.all.js"></script>
|
|
309
|
+
<script src="/aether-mrralex-demo@1.0.0/js/config.js"></script>
|
|
310
|
+
<script src="/aether-mrralex-demo@1.0.0/js/theme.js"></script>
|
|
311
|
+
<script src="/aether-mrralex-demo@1.0.0/js/url.js"></script>
|
|
312
|
+
<script src="/aether-mrralex-demo@1.0.0/js/shortcuts.js"></script>
|
|
313
|
+
<script type="module" src="/aether-mrralex-demo@1.0.0/js/browser.js"></script>
|
|
314
|
+
</body>
|
|
315
|
+
</html>
|
package/baremux/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BareMux={})}(this,(function(e){"use strict";const t=globalThis.fetch,r=globalThis.SharedWorker,a=globalThis.localStorage,s=globalThis.navigator.serviceWorker,o=MessagePort.prototype.postMessage,n={prototype:{send:WebSocket.prototype.send},CLOSED:WebSocket.CLOSED,CLOSING:WebSocket.CLOSING,CONNECTING:WebSocket.CONNECTING,OPEN:WebSocket.OPEN};async function c(){const e=(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).map((async e=>{const t=await function(e){let t=new MessageChannel;return new Promise((r=>{e.postMessage({type:"getPort:aether-mrralex-demo@1.0.0",port:t.port2},[t.port2]),t.port1.onmessage=e=>{r(e.data)}}))}(e);return await i(t),t})),t=Promise.race([Promise.any(e),new Promise(((e,t)=>setTimeout(t,1e3,new TypeError("timeout"))))]);try{return await t}catch(e){if(e instanceof AggregateError)throw console.error("bare-mux: failed to get a bare-mux SharedWorker MessagePort as all clients returned an invalid MessagePort."),new Error("All clients returned an invalid MessagePort.",{cause:e});return console.warn("bare-mux: failed to get a bare-mux SharedWorker MessagePort within 1s, retrying"),await c()}}function i(e){const t=new MessageChannel,r=new Promise(((e,r)=>{t.port1.onmessage=t=>{"pong"===t.data.type&&e()},setTimeout(r,1500)}));return o.call(e,{message:{type:"ping"},port:t.port2},[t.port2]),r}function l(e,t){const a=new r(e,"bare-mux-worker:aether-mrralex-demo@1.0.0");return t&&s.addEventListener("message",(t=>{if("getPort:aether-mrralex-demo@1.0.0"===t.data.type&&t.data.port){console.debug("bare-mux: recieved request for port from sw");const a=new r(e,"bare-mux-worker:aether-mrralex-demo@1.0.0");o.call(t.data.port,a.port,[a.port])}})),a.port}let h=null;function d(){if(null===h){const e=new MessageChannel,t=new ReadableStream;let r;try{o.call(e.port1,t,[t]),r=!0}catch(e){r=!1}return h=r,r}return h}class p{channel;port;workerPath;constructor(e){this.channel=new BroadcastChannel("bare-mux:aether-mrralex-demo@1.0.0"),e instanceof MessagePort||e instanceof Promise?this.port=e:this.createChannel(e,!0)}createChannel(e,t){if(self.clients)this.port=c(),this.channel.onmessage=e=>{"refreshPort"===e.data.type&&(this.port=c())};else if(e&&SharedWorker){if(!e.startsWith("/")&&!e.includes(":"))throw new Error("Invalid URL. Must be absolute or start at the root.");this.port=l(e,t),console.debug("bare-mux: setting localStorage bare-mux-path to",e),a["bare-mux-path:aether-mrralex-demo@1.0.0"]=e}else{if(!SharedWorker)throw new Error("Unable to get a channel to the SharedWorker.");{const e=a["bare-mux-path:aether-mrralex-demo@1.0.0"];if(console.debug("bare-mux: got localStorage bare-mux-path:",e),!e)throw new Error("Unable to get bare-mux workerPath from localStorage.");this.port=l(e,t)}}}async sendMessage(e,t){this.port instanceof Promise&&(this.port=await this.port);try{await i(this.port)}catch{return console.warn("bare-mux: Failed to get a ping response from the worker within 1.5s. Assuming port is dead."),this.createChannel(),await this.sendMessage(e,t)}const r=new MessageChannel,a=[r.port2,...t||[]],s=new Promise(((e,t)=>{r.port1.onmessage=r=>{const a=r.data;"error"===a.type?t(a.error):e(a)}}));return o.call(this.port,{message:e,port:r.port2},a),await s}}class u extends EventTarget{protocols;url;readyState=n.CONNECTING;channel;constructor(e,t=[],r,a){super(),this.protocols=t,this.url=e.toString(),this.protocols=t;const s=e=>{this.protocols=e,this.readyState=n.OPEN;const t=new Event("open");this.dispatchEvent(t)},o=async e=>{const t=new MessageEvent("message",{data:e});this.dispatchEvent(t)},c=(e,t)=>{this.readyState=n.CLOSED;const r=new CloseEvent("close",{code:e,reason:t});this.dispatchEvent(r)},i=()=>{this.readyState=n.CLOSED;const e=new Event("error");this.dispatchEvent(e)};this.channel=new MessageChannel,this.channel.port1.onmessage=e=>{"open"===e.data.type?s(e.data.args[0]):"message"===e.data.type?o(e.data.args[0]):"close"===e.data.type?c(e.data.args[0],e.data.args[1]):"error"===e.data.type&&i()},r.sendMessage({type:"websocket",websocket:{url:e.toString(),protocols:t,requestHeaders:a,channel:this.channel.port2}},[this.channel.port2])}send(...e){if(this.readyState===n.CONNECTING)throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.");let t=e[0];t.buffer&&(t=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),o.call(this.channel.port1,{type:"data",data:t},t instanceof ArrayBuffer?[t]:[])}close(e,t){o.call(this.channel.port1,{type:"close",closeCode:e,closeReason:t})}}function w(e,t,r){console.error(`error while processing '${r}': `,t),e.postMessage({type:"error",error:t})}function f(e){for(let t=0;t<e.length;t++){const r=e[t];if(!"!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz|~".includes(r))return!1}return!0}const g=["ws:","wss:"],b=[101,204,205,304],y=[301,302,303,307,308];class m{worker;constructor(e){this.worker=new p(e)}createWebSocket(e,t=[],r,a){try{e=new URL(e)}catch(t){throw new DOMException(`Faiiled to construct 'WebSocket': The URL '${e}' is invalid.`)}if(!g.includes(e.protocol))throw new DOMException(`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${e.protocol}' is not allowed.`);Array.isArray(t)||(t=[t]),t=t.map(String);for(const e of t)if(!f(e))throw new DOMException(`Failed to construct 'WebSocket': The subprotocol '${e}' is invalid.`);a=a||{};return new u(e,t,this.worker,a)}async fetch(e,r){const a=new Request(e,r),s=r?.headers||a.headers,o=s instanceof Headers?Object.fromEntries(s):s,n=a.body;let c=new URL(a.url);if(c.protocol.startsWith("blob:")){const e=await t(c),r=new Response(e.body,e);return r.rawHeaders=Object.fromEntries(e.headers),r.rawResponse={body:e.body,headers:Object.fromEntries(e.headers),status:e.status,statusText:e.statusText},r.finalURL=c.toString(),r}for(let e=0;;e++){let t=(await this.worker.sendMessage({type:"fetch",fetch:{remote:c.toString(),method:a.method,headers:o,body:n||void 0}},n?[n]:[])).fetch,s=new Response(b.includes(t.status)?void 0:t.body,{headers:new Headers(t.headers),status:t.status,statusText:t.statusText});s.rawHeaders=t.headers,s.rawResponse=t,s.finalURL=c.toString();const i=r?.redirect||a.redirect;if(!y.includes(s.status))return s;switch(i){case"follow":{const t=s.headers.get("location");if(20>e&&null!==t){c=new URL(t,c);continue}throw new TypeError("Failed to fetch")}case"error":throw new TypeError("Failed to fetch");case"manual":return s}}}}console.debug("bare-mux: running v2.1.9 (build dc9dc6e)"),e.BareClient=m,e.BareMuxConnection=class{worker;constructor(e){this.worker=new p(e)}async getTransport(){return(await this.worker.sendMessage({type:"get"})).name}async setTransport(e,t,r){await this.setManualTransport(`\n\t\t\tconst { default: BareTransport } = await import("${e}");\n\t\t\treturn [BareTransport, "${e}"];\n\t\t`,t,r)}async setManualTransport(e,t,r){if("bare-mux-remote"===e)throw new Error("Use setRemoteTransport.");await this.worker.sendMessage({type:"set",client:{function:e,args:t}},r)}async setRemoteTransport(e,t){const r=new MessageChannel;r.port1.onmessage=async t=>{const r=t.data.port,a=t.data.message;if("fetch"===a.type)try{e.ready||await e.init(),await async function(e,t,r){const a=await r.request(new URL(e.fetch.remote),e.fetch.method,e.fetch.body,e.fetch.headers,null);if(!d()&&a.body instanceof ReadableStream){const e=new Response(a.body);a.body=await e.arrayBuffer()}a.body instanceof ReadableStream||a.body instanceof ArrayBuffer?o.call(t,{type:"fetch",fetch:a},[a.body]):o.call(t,{type:"fetch",fetch:a})}(a,r,e)}catch(e){w(r,e,"fetch")}else if("websocket"===a.type)try{e.ready||await e.init(),await async function(e,t,r){const[a,s]=r.connect(new URL(e.websocket.url),e.websocket.protocols,e.websocket.requestHeaders,(t=>{o.call(e.websocket.channel,{type:"open",args:[t]})}),(t=>{t instanceof ArrayBuffer?o.call(e.websocket.channel,{type:"message",args:[t]},[t]):o.call(e.websocket.channel,{type:"message",args:[t]})}),((t,r)=>{o.call(e.websocket.channel,{type:"close",args:[t,r]})}),(t=>{o.call(e.websocket.channel,{type:"error",args:[t]})}));e.websocket.channel.onmessage=e=>{"data"===e.data.type?a(e.data.data):"close"===e.data.type&&s(e.data.closeCode,e.data.closeReason)},o.call(t,{type:"websocket"})}(a,r,e)}catch(e){w(r,e,"websocket")}},await this.worker.sendMessage({type:"set",client:{function:"bare-mux-remote",args:[r.port2,t]}},[r.port2])}getInnerPort(){return this.worker.port}},e.BareWebSocket=u,e.WebSocketFields=n,e.WorkerConnection=p,e.browserSupportsTransferringStreams=d,e.default=m,e.maxRedirects=20,e.validProtocol=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=20,t=globalThis.fetch,r=globalThis.SharedWorker,a=globalThis.localStorage,s=globalThis.navigator.serviceWorker,o=MessagePort.prototype.postMessage,n={prototype:{send:WebSocket.prototype.send},CLOSED:WebSocket.CLOSED,CLOSING:WebSocket.CLOSING,CONNECTING:WebSocket.CONNECTING,OPEN:WebSocket.OPEN};async function c(){const e=(await self.clients.matchAll({type:"window",includeUncontrolled:!0})).map((async e=>{const t=await function(e){let t=new MessageChannel;return new Promise((r=>{e.postMessage({type:"getPort:aether-mrralex-demo@1.0.0",port:t.port2},[t.port2]),t.port1.onmessage=e=>{r(e.data)}}))}(e);return await i(t),t})),t=Promise.race([Promise.any(e),new Promise(((e,t)=>setTimeout(t,1e3,new TypeError("timeout"))))]);try{return await t}catch(e){if(e instanceof AggregateError)throw console.error("bare-mux: failed to get a bare-mux SharedWorker MessagePort as all clients returned an invalid MessagePort."),new Error("All clients returned an invalid MessagePort.",{cause:e});return console.warn("bare-mux: failed to get a bare-mux SharedWorker MessagePort within 1s, retrying"),await c()}}function i(e){const t=new MessageChannel,r=new Promise(((e,r)=>{t.port1.onmessage=t=>{"pong"===t.data.type&&e()},setTimeout(r,1500)}));return o.call(e,{message:{type:"ping"},port:t.port2},[t.port2]),r}function l(e,t){const a=new r(e,"bare-mux-worker:aether-mrralex-demo@1.0.0");return t&&s.addEventListener("message",(t=>{if("getPort:aether-mrralex-demo@1.0.0"===t.data.type&&t.data.port){console.debug("bare-mux: recieved request for port from sw");const a=new r(e,"bare-mux-worker:aether-mrralex-demo@1.0.0");o.call(t.data.port,a.port,[a.port])}})),a.port}let h=null;function d(){if(null===h){const e=new MessageChannel,t=new ReadableStream;let r;try{o.call(e.port1,t,[t]),r=!0}catch(e){r=!1}return h=r,r}return h}class p{channel;port;workerPath;constructor(e){this.channel=new BroadcastChannel("bare-mux:aether-mrralex-demo@1.0.0"),e instanceof MessagePort||e instanceof Promise?this.port=e:this.createChannel(e,!0)}createChannel(e,t){if(self.clients)this.port=c(),this.channel.onmessage=e=>{"refreshPort"===e.data.type&&(this.port=c())};else if(e&&SharedWorker){if(!e.startsWith("/")&&!e.includes(":"))throw new Error("Invalid URL. Must be absolute or start at the root.");this.port=l(e,t),console.debug("bare-mux: setting localStorage bare-mux-path to",e),a["bare-mux-path:aether-mrralex-demo@1.0.0"]=e}else{if(!SharedWorker)throw new Error("Unable to get a channel to the SharedWorker.");{const e=a["bare-mux-path:aether-mrralex-demo@1.0.0"];if(console.debug("bare-mux: got localStorage bare-mux-path:",e),!e)throw new Error("Unable to get bare-mux workerPath from localStorage.");this.port=l(e,t)}}}async sendMessage(e,t){this.port instanceof Promise&&(this.port=await this.port);try{await i(this.port)}catch{return console.warn("bare-mux: Failed to get a ping response from the worker within 1.5s. Assuming port is dead."),this.createChannel(),await this.sendMessage(e,t)}const r=new MessageChannel,a=[r.port2,...t||[]],s=new Promise(((e,t)=>{r.port1.onmessage=r=>{const a=r.data;"error"===a.type?t(a.error):e(a)}}));return o.call(this.port,{message:e,port:r.port2},a),await s}}class w extends EventTarget{protocols;url;readyState=n.CONNECTING;channel;constructor(e,t=[],r,a){super(),this.protocols=t,this.url=e.toString(),this.protocols=t;const s=e=>{this.protocols=e,this.readyState=n.OPEN;const t=new Event("open");this.dispatchEvent(t)},o=async e=>{const t=new MessageEvent("message",{data:e});this.dispatchEvent(t)},c=(e,t)=>{this.readyState=n.CLOSED;const r=new CloseEvent("close",{code:e,reason:t});this.dispatchEvent(r)},i=()=>{this.readyState=n.CLOSED;const e=new Event("error");this.dispatchEvent(e)};this.channel=new MessageChannel,this.channel.port1.onmessage=e=>{"open"===e.data.type?s(e.data.args[0]):"message"===e.data.type?o(e.data.args[0]):"close"===e.data.type?c(e.data.args[0],e.data.args[1]):"error"===e.data.type&&i()},r.sendMessage({type:"websocket",websocket:{url:e.toString(),protocols:t,requestHeaders:a,channel:this.channel.port2}},[this.channel.port2])}send(...e){if(this.readyState===n.CONNECTING)throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.");let t=e[0];t.buffer&&(t=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)),o.call(this.channel.port1,{type:"data",data:t},t instanceof ArrayBuffer?[t]:[])}close(e,t){o.call(this.channel.port1,{type:"close",closeCode:e,closeReason:t})}}function u(e,t,r){console.error(`error while processing '${r}': `,t),e.postMessage({type:"error",error:t})}function f(e){for(let t=0;t<e.length;t++){const r=e[t];if(!"!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz|~".includes(r))return!1}return!0}const g=["ws:","wss:"],y=[101,204,205,304],b=[301,302,303,307,308];class m{worker;constructor(e){this.worker=new p(e)}async getTransport(){return(await this.worker.sendMessage({type:"get"})).name}async setTransport(e,t,r){await this.setManualTransport(`\n\t\t\tconst { default: BareTransport } = await import("${e}");\n\t\t\treturn [BareTransport, "${e}"];\n\t\t`,t,r)}async setManualTransport(e,t,r){if("bare-mux-remote"===e)throw new Error("Use setRemoteTransport.");await this.worker.sendMessage({type:"set",client:{function:e,args:t}},r)}async setRemoteTransport(e,t){const r=new MessageChannel;r.port1.onmessage=async t=>{const r=t.data.port,a=t.data.message;if("fetch"===a.type)try{e.ready||await e.init(),await async function(e,t,r){const a=await r.request(new URL(e.fetch.remote),e.fetch.method,e.fetch.body,e.fetch.headers,null);if(!d()&&a.body instanceof ReadableStream){const e=new Response(a.body);a.body=await e.arrayBuffer()}a.body instanceof ReadableStream||a.body instanceof ArrayBuffer?o.call(t,{type:"fetch",fetch:a},[a.body]):o.call(t,{type:"fetch",fetch:a})}(a,r,e)}catch(e){u(r,e,"fetch")}else if("websocket"===a.type)try{e.ready||await e.init(),await async function(e,t,r){const[a,s]=r.connect(new URL(e.websocket.url),e.websocket.protocols,e.websocket.requestHeaders,(t=>{o.call(e.websocket.channel,{type:"open",args:[t]})}),(t=>{t instanceof ArrayBuffer?o.call(e.websocket.channel,{type:"message",args:[t]},[t]):o.call(e.websocket.channel,{type:"message",args:[t]})}),((t,r)=>{o.call(e.websocket.channel,{type:"close",args:[t,r]})}),(t=>{o.call(e.websocket.channel,{type:"error",args:[t]})}));e.websocket.channel.onmessage=e=>{"data"===e.data.type?a(e.data.data):"close"===e.data.type&&s(e.data.closeCode,e.data.closeReason)},o.call(t,{type:"websocket"})}(a,r,e)}catch(e){u(r,e,"websocket")}},await this.worker.sendMessage({type:"set",client:{function:"bare-mux-remote",args:[r.port2,t]}},[r.port2])}getInnerPort(){return this.worker.port}}class k{worker;constructor(e){this.worker=new p(e)}createWebSocket(e,t=[],r,a){try{e=new URL(e)}catch(t){throw new DOMException(`Faiiled to construct 'WebSocket': The URL '${e}' is invalid.`)}if(!g.includes(e.protocol))throw new DOMException(`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${e.protocol}' is not allowed.`);Array.isArray(t)||(t=[t]),t=t.map(String);for(const e of t)if(!f(e))throw new DOMException(`Failed to construct 'WebSocket': The subprotocol '${e}' is invalid.`);a=a||{};return new w(e,t,this.worker,a)}async fetch(e,r){const a=new Request(e,r),s=r?.headers||a.headers,o=s instanceof Headers?Object.fromEntries(s):s,n=a.body;let c=new URL(a.url);if(c.protocol.startsWith("blob:")){const e=await t(c),r=new Response(e.body,e);return r.rawHeaders=Object.fromEntries(e.headers),r.rawResponse={body:e.body,headers:Object.fromEntries(e.headers),status:e.status,statusText:e.statusText},r.finalURL=c.toString(),r}for(let e=0;;e++){let t=(await this.worker.sendMessage({type:"fetch",fetch:{remote:c.toString(),method:a.method,headers:o,body:n||void 0}},n?[n]:[])).fetch,s=new Response(y.includes(t.status)?void 0:t.body,{headers:new Headers(t.headers),status:t.status,statusText:t.statusText});s.rawHeaders=t.headers,s.rawResponse=t,s.finalURL=c.toString();const i=r?.redirect||a.redirect;if(!b.includes(s.status))return s;switch(i){case"follow":{const t=s.headers.get("location");if(20>e&&null!==t){c=new URL(t,c);continue}throw new TypeError("Failed to fetch")}case"error":throw new TypeError("Failed to fetch");case"manual":return s}}}}console.debug("bare-mux: running v2.1.9 (build dc9dc6e)");export{k as BareClient,m as BareMuxConnection,w as BareWebSocket,n as WebSocketFields,p as WorkerConnection,d as browserSupportsTransferringStreams,k as default,e as maxRedirects,f as validProtocol};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(){"use strict";const e=MessagePort.prototype.postMessage;let t=null;function a(e,t,a){console.error(`error while processing '${a}': `,t),e.postMessage({type:"error",error:t})}async function n(a,n,s){const o=await s.request(new URL(a.fetch.remote),a.fetch.method,a.fetch.body,a.fetch.headers,null);if(!function(){if(null===t){const a=new MessageChannel,n=new ReadableStream;let s;try{e.call(a.port1,n,[n]),s=!0}catch(e){s=!1}return t=s,s}return t}()&&o.body instanceof ReadableStream){const e=new Response(o.body);o.body=await e.arrayBuffer()}o.body instanceof ReadableStream||o.body instanceof ArrayBuffer?e.call(n,{type:"fetch",fetch:o},[o.body]):e.call(n,{type:"fetch",fetch:o})}let s=null,o="";function c(){return new Error("there are no bare clients",{cause:"No BareTransport was set. Try creating a BareMuxConnection and calling `setTransport()` or `setManualTransport()` on it before using BareClient."})}function r(t,a){const n=s;let o=[a];t.fetch?.body&&o.push(t.fetch.body),t.websocket?.channel&&o.push(t.websocket.channel),e.call(n,{message:t,port:a},o)}function l(t){t.onmessage=async t=>{const l=t.data.port,i=t.data.message;if("ping"===i.type)e.call(l,{type:"pong"});else if("set"===i.type)try{const t=async function(){}.constructor;if("bare-mux-remote"===i.client.function)s=i.client.args[0],o=`bare-mux-remote (${i.client.args[1]})`;else try{const e=new t(i.client.function),[a,n]=await e();s=new a(...i.client.args),o=n}catch(e){throw e.cause="The BareTransport provided was invalid. Common causes of this are a default export that is not a class that implements BareTransport if you are using `setTransport()`",e}console.log("set transport to ",s,o),e.call(l,{type:"set"})}catch(e){a(l,e,"set")}else if("get"===i.type)l.postMessage({type:"get",name:o});else if("fetch"===i.type)try{if(!s)throw c();if(s instanceof MessagePort)return void r(i,l);s.ready||await s.init(),await n(i,l,s)}catch(e){a(l,e,"fetch")}else if("websocket"===i.type)try{if(!s)throw c();if(s instanceof MessagePort)return void r(i,l);s.ready||await s.init(),await async function(t,a,n){const[s,o]=n.connect(new URL(t.websocket.url),t.websocket.protocols,t.websocket.requestHeaders,(a=>{e.call(t.websocket.channel,{type:"open",args:[a]})}),(a=>{a instanceof ArrayBuffer?e.call(t.websocket.channel,{type:"message",args:[a]},[a]):e.call(t.websocket.channel,{type:"message",args:[a]})}),((a,n)=>{e.call(t.websocket.channel,{type:"close",args:[a,n]})}),(a=>{e.call(t.websocket.channel,{type:"error",args:[a]})}));t.websocket.channel.onmessage=e=>{"data"===e.data.type?s(e.data.data):"close"===e.data.type&&o(e.data.closeCode,e.data.closeReason)},e.call(a,{type:"websocket"})}(i,l,s)}catch(e){a(l,e,"websocket")}}}new BroadcastChannel("bare-mux:aether-mrralex-demo@1.0.0").postMessage({type:"refreshPort"}),self.onconnect=e=>{l(e.ports[0])},console.debug("bare-mux: running v2.1.9 (build dc9dc6e)")}();
|
|
2
|
+
//# sourceMappingURL=worker.js.map
|