Compare commits
19 commits
main
...
archive/v8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2455e8157 | ||
|
|
3f520528b6 | ||
|
|
c5138d6f06 | ||
|
|
cbf06ad254 | ||
|
|
acd1345934 | ||
|
|
d1f890ca7b | ||
|
|
9267cfedb2 | ||
|
|
065499a041 | ||
|
|
6c77aa0864 | ||
|
|
3f76b7b7a3 | ||
|
|
0fde43f4ff | ||
|
|
6306992e11 | ||
|
|
5992735a51 | ||
|
|
fe93b0d5d5 | ||
|
|
bb8b2b6d60 | ||
|
|
b1ba8502ea | ||
|
|
10e686cd2d | ||
|
|
22d74d484f | ||
|
|
105b6c9796 |
28 changed files with 9792 additions and 855 deletions
11
.astro/astro/env.d.ts
vendored
Normal file
11
.astro/astro/env.d.ts
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
declare module 'astro:env/client' {
|
||||
export const VERSION: string;
|
||||
export const MARKETPLACE_ENABLED: boolean;
|
||||
|
||||
}
|
||||
|
||||
declare module 'astro:env/server' {
|
||||
|
||||
|
||||
export const getSecret: (key: string) => string | undefined;
|
||||
}
|
||||
9167
.astro/icon.d.ts
vendored
Normal file
9167
.astro/icon.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
5
.astro/settings.json
Normal file
5
.astro/settings.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"_variables": {
|
||||
"lastUpdateCheck": 1730783343720
|
||||
}
|
||||
}
|
||||
2
.astro/types.d.ts
vendored
Normal file
2
.astro/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/// <reference types="astro/client" />
|
||||
/// <reference path="astro/env.d.ts" />
|
||||
24
config.toml
Normal file
24
config.toml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[marketplace]
|
||||
enabled = true # Turn on or off the marketplace entirely
|
||||
psk = "CHANGEME" # Change this to something more secure.
|
||||
level = 1
|
||||
|
||||
[db]
|
||||
name = "database" # Your databsae name
|
||||
username = "username" # The username of your DB (SQLITE just ignores this)
|
||||
password = "password" # The password to your DB (SQLITE ignores this)
|
||||
postgres = false # Enable to use postgres over sqlite (recommended for large prod instances)
|
||||
|
||||
[postgres] # Set the "domain" to either and ip address or a actual domain
|
||||
domain = ""
|
||||
port = 5432
|
||||
|
||||
[server.server]
|
||||
port = 8080
|
||||
wisp = true
|
||||
logging = true # Disable for the tons & tons of logs to go away (useful for debugging but otherwise eh)
|
||||
|
||||
[server.rammerhead] # Don't touch this section unless you KNOW what you are doing
|
||||
reverseproxy = true
|
||||
localstorage_sync = true
|
||||
http2 = true
|
||||
BIN
database.sqlite
Normal file
BIN
database.sqlite
Normal file
Binary file not shown.
|
|
@ -3,11 +3,10 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="/transports/bareTransport.js" defer></script>
|
||||
<script src="/uv/uv.bundle.js" defer></script>
|
||||
<script src="/uv/uv.config.js" defer></script>
|
||||
<script src="/dynamic/dynamic.config.js" defer></script>
|
||||
<script src="/localforage/localforage.min.js" defer></script>
|
||||
<script src="/localforage/localforage.min.js" defer></script>
|
||||
</head>
|
||||
<body style="margin: 0">
|
||||
<div id="app"></div>
|
||||
|
|
|
|||
11
package.json
11
package.json
|
|
@ -14,12 +14,13 @@
|
|||
"@fastify/compress": "^6.5.0",
|
||||
"@fastify/cookie": "^9.3.1",
|
||||
"@fastify/static": "^6.12.0",
|
||||
"@mercuryworkshop/bare-mux": "^1.1.1",
|
||||
"@mercuryworkshop/epoxy-transport": "^2.0.1",
|
||||
"@mercuryworkshop/libcurl-transport": "^1.3.1",
|
||||
"@mercuryworkshop/bare-mux": "^2.0.9",
|
||||
"@mercuryworkshop/epoxy-transport": "^2.1.11",
|
||||
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
||||
"@nebula-services/dynamic": "0.7.2-patch.2",
|
||||
"@titaniumnetwork-dev/ultraviolet": "^3.1.2",
|
||||
"@tomphttp/bare-server-node": "2.0.3",
|
||||
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
|
||||
"@mercuryworkshop/bare-as-module3": "^2.2.2",
|
||||
"@nebula-services/bare-server-node": "^2.0.4",
|
||||
"@tsparticles/engine": "^3.4.0",
|
||||
"@tsparticles/react": "^3.0.0",
|
||||
"@tsparticles/slim": "^3.4.0",
|
||||
|
|
|
|||
127
pnpm-lock.yaml
generated
127
pnpm-lock.yaml
generated
|
|
@ -17,24 +17,27 @@ importers:
|
|||
'@fastify/static':
|
||||
specifier: ^6.12.0
|
||||
version: 6.12.0
|
||||
'@mercuryworkshop/bare-as-module3':
|
||||
specifier: ^2.2.2
|
||||
version: 2.2.2
|
||||
'@mercuryworkshop/bare-mux':
|
||||
specifier: ^1.1.1
|
||||
version: 1.1.1
|
||||
specifier: ^2.0.9
|
||||
version: 2.0.9
|
||||
'@mercuryworkshop/epoxy-transport':
|
||||
specifier: ^2.0.1
|
||||
version: 2.0.1(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)
|
||||
specifier: ^2.1.11
|
||||
version: 2.1.11
|
||||
'@mercuryworkshop/libcurl-transport':
|
||||
specifier: ^1.3.1
|
||||
version: 1.3.1(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)
|
||||
specifier: ^1.3.10
|
||||
version: 1.3.10(typescript@5.5.2)
|
||||
'@nebula-services/bare-server-node':
|
||||
specifier: ^2.0.4
|
||||
version: 2.0.4(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
'@nebula-services/dynamic':
|
||||
specifier: 0.7.2-patch.2
|
||||
version: 0.7.2-patch.2(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
'@titaniumnetwork-dev/ultraviolet':
|
||||
specifier: ^3.1.2
|
||||
version: 3.1.2
|
||||
'@tomphttp/bare-server-node':
|
||||
specifier: 2.0.3
|
||||
version: 2.0.3(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
specifier: ^3.2.7
|
||||
version: 3.2.7
|
||||
'@tsparticles/engine':
|
||||
specifier: ^3.4.0
|
||||
version: 3.4.0
|
||||
|
|
@ -797,17 +800,25 @@ packages:
|
|||
'@mdn/browser-compat-data@5.5.35':
|
||||
resolution: {integrity: sha512-APtxt3S+a64EcXpG7E3a0bLx+CPqEcgN45FY/GEmbBBgX51AGIPkkYFy0JQDuOR0MFCozjo50q5Im74jflrkiQ==}
|
||||
|
||||
'@mercuryworkshop/bare-mux@1.1.1':
|
||||
resolution: {integrity: sha512-qKOnTsIjwv4wBvToek3Jm+y3F/BcFtjy6HOsdyzIUemCOw51kodzRsvWvU9Pf/JYDVPV8or0zbsg+qOKtasjhA==}
|
||||
'@mercuryworkshop/bare-as-module3@2.2.2':
|
||||
resolution: {integrity: sha512-Ds8981SmI1DQp1mDCVax1x0I5mH2dR1tYKytW7xTjlnpsfwn3RzQDiVJHUCrpc7cWGCe+7mHCF3EoMjM3hFfvQ==}
|
||||
|
||||
'@mercuryworkshop/epoxy-tls@2.0.0-3':
|
||||
resolution: {integrity: sha512-iC5CViTh2xn44xtjvDW4YW9qoeoJcCBOqcNmffBx3RHdK7FAzAWFHLTUBtdlnMVv6cjYZtV+eUTzxyreqlgOVA==}
|
||||
'@mercuryworkshop/bare-mux@2.0.9':
|
||||
resolution: {integrity: sha512-g+F/Oz33iSQwLf3rJU3Vr1bh5cbxHRKS/Tnr6ayk060UzcJ+EDGad5pUdRJFz1MRyinpYC5MrG67QDA9Dlta9A==}
|
||||
|
||||
'@mercuryworkshop/epoxy-transport@2.0.1':
|
||||
resolution: {integrity: sha512-iGuH/CT5hCVRYBa+5ZrlTG0DWII9VOCMHnmv9CPFLM17obE84y9EUXpTp9hXdfENnuAcNzQVPizjwVas7HiYQA==}
|
||||
'@mercuryworkshop/epoxy-tls@2.1.4-1':
|
||||
resolution: {integrity: sha512-kRbW12tU4TAf9GuoLfyFYvUATqFZq6n9ScRSfwAECceOBWDlr+bACnSH45lLDXvjBKwxZotTyYE5aNc+Ow+M3Q==}
|
||||
|
||||
'@mercuryworkshop/libcurl-transport@1.3.1':
|
||||
resolution: {integrity: sha512-yGt8K7D1j8WLn7LgH6YPnxmHc+JUCB0x/QPIStuRftl0tq3D8uHskRFeOJ8ksTrru7mTAjk5Cpmvix8jNJ+Lug==}
|
||||
'@mercuryworkshop/epoxy-transport@2.1.11':
|
||||
resolution: {integrity: sha512-kp1MDWbrTOr55ZvD4KLbaWcfwwugdhjourBXLh5inJcKFsVKqbbLWMfs/JGGTluwBoTG52UpLUU4OW0suruBwg==}
|
||||
|
||||
'@mercuryworkshop/libcurl-transport@1.3.10':
|
||||
resolution: {integrity: sha512-XLSkk1n4uMu6M0sS5Rh5ZNT7dBGILHDneJYD9oOpWMU5yxzNDlwcmJggNaYqMfH7B8jjLmw5sK2gPU5hDFPAVg==}
|
||||
|
||||
'@nebula-services/bare-server-node@2.0.4':
|
||||
resolution: {integrity: sha512-Jcr+QtkLJVmppdbBarEbRp1TtCsL4pjFIcX6+KPURRqcsOP7hZfYclhjmCserwEC7jT+WBduXpFd3qwqeRBNew==}
|
||||
engines: {node: '>=18.0.0'}
|
||||
hasBin: true
|
||||
|
||||
'@nebula-services/dynamic@0.7.2-patch.2':
|
||||
resolution: {integrity: sha512-0g1ygwVNS0dmT38NIeZYc2Z5HiZKHT3tP7ZagIeWC/VlcZjINIPR4ThNndWVaGiZey2Y2JS2807ABb41OSYTrw==}
|
||||
|
|
@ -946,8 +957,8 @@ packages:
|
|||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@titaniumnetwork-dev/ultraviolet@3.1.2':
|
||||
resolution: {integrity: sha512-PvhyL9IQtSwHTVRRpNGn+YCWkSzP7JEk0wX7M5YfUSobBicoRLOJhCC4u6T9qh/vObDpLDE3TfP4GKqMTSa2rw==}
|
||||
'@titaniumnetwork-dev/ultraviolet@3.2.7':
|
||||
resolution: {integrity: sha512-leR8Cxtgld9NykRbEbYejbD85dOLh0rqQe6tfcsaFEBIChWG9QF10x1qoJBQ3wXSvZ+wqh3cBNYrucYpHOWpUA==}
|
||||
|
||||
'@tomphttp/bare-client@2.2.0-alpha':
|
||||
resolution: {integrity: sha512-xhcflOpwr92tkpp8SoDhB3nK3LHMBIjx+vgow37XobQew2k0/mXSxmaU7BsDFpOIa1CcLCEsR8gWn0v7Cy9+7Q==}
|
||||
|
|
@ -1091,9 +1102,6 @@ packages:
|
|||
'@types/semver@7.5.8':
|
||||
resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==}
|
||||
|
||||
'@types/uuid@9.0.8':
|
||||
resolution: {integrity: sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==}
|
||||
|
||||
'@typescript-eslint/experimental-utils@5.62.0':
|
||||
resolution: {integrity: sha512-RTXpeB3eMkpoclG3ZHft6vG/Z30azNHuqY6wKPBHlVMZFuEvrtlEDe8gMqDb+SO+9hjC/pLekeSCryf9vMZlCw==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
|
|
@ -2508,8 +2516,8 @@ packages:
|
|||
resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==}
|
||||
engines: {node: '>= 0.8.0'}
|
||||
|
||||
libcurl.js@0.6.8:
|
||||
resolution: {integrity: sha512-KYkWFxnSdnIeN00AZRWv1tywDawVqb7VKxw213GjqxehGQDBv0rWAKZ/R/rwEKumVYlPvRNrzZPRa9wlYgEjCg==}
|
||||
libcurl.js@0.6.15:
|
||||
resolution: {integrity: sha512-rKcGhvJiju/V6RoH0mYW0l/w9GnTRFtidp8qC+3cMliHXHEHnbqwpOPzauMeOd2CtcEW5ZPZ29PpXLJ1bdHbyQ==}
|
||||
|
||||
lie@3.1.1:
|
||||
resolution: {integrity: sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==}
|
||||
|
|
@ -3709,6 +3717,11 @@ packages:
|
|||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
typescript@5.5.3:
|
||||
resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
uglify-js@3.18.0:
|
||||
resolution: {integrity: sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==}
|
||||
engines: {node: '>=0.8.0'}
|
||||
|
|
@ -3766,10 +3779,6 @@ packages:
|
|||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
hasBin: true
|
||||
|
||||
uuid@9.0.1:
|
||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||
hasBin: true
|
||||
|
||||
vary@1.1.2:
|
||||
resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
|
@ -3873,8 +3882,8 @@ packages:
|
|||
wrappy@1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
|
||||
ws@8.16.0:
|
||||
resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==}
|
||||
ws@8.17.1:
|
||||
resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
|
|
@ -3885,8 +3894,8 @@ packages:
|
|||
utf-8-validate:
|
||||
optional: true
|
||||
|
||||
ws@8.17.1:
|
||||
resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==}
|
||||
ws@8.18.0:
|
||||
resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
|
|
@ -4473,37 +4482,39 @@ snapshots:
|
|||
|
||||
'@mdn/browser-compat-data@5.5.35': {}
|
||||
|
||||
'@mercuryworkshop/bare-mux@1.1.1':
|
||||
'@mercuryworkshop/bare-as-module3@2.2.2':
|
||||
dependencies:
|
||||
'@types/uuid': 9.0.8
|
||||
uuid: 9.0.1
|
||||
typescript: 5.5.3
|
||||
|
||||
'@mercuryworkshop/epoxy-tls@2.0.0-3': {}
|
||||
'@mercuryworkshop/bare-mux@2.0.9': {}
|
||||
|
||||
'@mercuryworkshop/epoxy-transport@2.0.1(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)':
|
||||
'@mercuryworkshop/epoxy-tls@2.1.4-1': {}
|
||||
|
||||
'@mercuryworkshop/epoxy-transport@2.1.11':
|
||||
dependencies:
|
||||
'@mercuryworkshop/epoxy-tls': 2.1.4-1
|
||||
|
||||
'@mercuryworkshop/libcurl-transport@1.3.10(typescript@5.5.2)':
|
||||
dependencies:
|
||||
'@mercuryworkshop/epoxy-tls': 2.0.0-3
|
||||
esbuild-plugin-umd-wrapper: 2.0.0
|
||||
libcurl.js: 0.6.15
|
||||
rollup: 4.18.0
|
||||
rollup-plugin-node-resolve: 5.2.0(rollup@4.18.0)
|
||||
rollup-plugin-typescript2: 0.36.0(rollup@4.18.0)(typescript@5.5.2)
|
||||
ws: 8.16.0(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- typescript
|
||||
- utf-8-validate
|
||||
|
||||
'@mercuryworkshop/libcurl-transport@1.3.1(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)':
|
||||
'@nebula-services/bare-server-node@2.0.4(bufferutil@4.0.8)(utf-8-validate@6.0.4)':
|
||||
dependencies:
|
||||
esbuild-plugin-umd-wrapper: 2.0.0
|
||||
libcurl.js: 0.6.8
|
||||
rollup: 4.18.0
|
||||
rollup-plugin-node-resolve: 5.2.0(rollup@4.18.0)
|
||||
rollup-plugin-typescript2: 0.36.0(rollup@4.18.0)(typescript@5.5.2)
|
||||
ws: 8.16.0(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
async-exit-hook: 2.0.1
|
||||
commander: 10.0.1
|
||||
dotenv: 16.4.5
|
||||
http-errors: 2.0.0
|
||||
ipaddr.js: 2.2.0
|
||||
source-map-support: 0.5.21
|
||||
ws: 8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.4)
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- typescript
|
||||
- utf-8-validate
|
||||
|
||||
'@nebula-services/dynamic@0.7.2-patch.2(bufferutil@4.0.8)(utf-8-validate@6.0.4)':
|
||||
|
|
@ -4657,7 +4668,7 @@ snapshots:
|
|||
'@rollup/rollup-win32-x64-msvc@4.18.0':
|
||||
optional: true
|
||||
|
||||
'@titaniumnetwork-dev/ultraviolet@3.1.2': {}
|
||||
'@titaniumnetwork-dev/ultraviolet@3.2.7': {}
|
||||
|
||||
'@tomphttp/bare-client@2.2.0-alpha': {}
|
||||
|
||||
|
|
@ -4869,8 +4880,6 @@ snapshots:
|
|||
|
||||
'@types/semver@7.5.8': {}
|
||||
|
||||
'@types/uuid@9.0.8': {}
|
||||
|
||||
'@typescript-eslint/experimental-utils@5.62.0(eslint@8.57.0)(typescript@5.5.2)':
|
||||
dependencies:
|
||||
'@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.5.2)
|
||||
|
|
@ -6541,7 +6550,7 @@ snapshots:
|
|||
prelude-ls: 1.2.1
|
||||
type-check: 0.4.0
|
||||
|
||||
libcurl.js@0.6.8: {}
|
||||
libcurl.js@0.6.15: {}
|
||||
|
||||
lie@3.1.1:
|
||||
dependencies:
|
||||
|
|
@ -7844,6 +7853,8 @@ snapshots:
|
|||
|
||||
typescript@5.5.2: {}
|
||||
|
||||
typescript@5.5.3: {}
|
||||
|
||||
uglify-js@3.18.0: {}
|
||||
|
||||
unbox-primitive@1.0.2:
|
||||
|
|
@ -7898,8 +7909,6 @@ snapshots:
|
|||
|
||||
uuid@8.3.2: {}
|
||||
|
||||
uuid@9.0.1: {}
|
||||
|
||||
vary@1.1.2: {}
|
||||
|
||||
vite-plugin-static-copy@1.0.5(vite@5.3.2(@types/node@20.14.9)):
|
||||
|
|
@ -8007,12 +8016,12 @@ snapshots:
|
|||
|
||||
wrappy@1.0.2: {}
|
||||
|
||||
ws@8.16.0(bufferutil@4.0.8)(utf-8-validate@6.0.4):
|
||||
ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4):
|
||||
optionalDependencies:
|
||||
bufferutil: 4.0.8
|
||||
utf-8-validate: 6.0.4
|
||||
|
||||
ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4):
|
||||
ws@8.18.0(bufferutil@4.0.8)(utf-8-validate@6.0.4):
|
||||
optionalDependencies:
|
||||
bufferutil: 4.0.8
|
||||
utf-8-validate: 6.0.4
|
||||
|
|
|
|||
44
public/sw.js
44
public/sw.js
|
|
@ -1,6 +1,3 @@
|
|||
importScripts("/epoxy/index.js");
|
||||
importScripts("/libcurl/index.js");
|
||||
importScripts("/transports/bareTransport.js");
|
||||
importScripts("/uv/uv.bundle.js");
|
||||
importScripts("/uv/uv.config.js");
|
||||
importScripts(__uv$config.sw || "/uv/uv.sw.js");
|
||||
|
|
@ -30,33 +27,20 @@ const dynPromise = new Promise(async (resolve) => {
|
|||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (
|
||||
event.request.url.startsWith(location.origin + self.__dynamic$config.prefix)
|
||||
) {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
if (uv.route(event)) {
|
||||
return await uv.fetch(event);
|
||||
}
|
||||
if (await dynamic.route(event)) {
|
||||
try {
|
||||
await dynPromise;
|
||||
} catch (error) {}
|
||||
if (await self.dynamic.route(event)) {
|
||||
return await self.dynamic.fetch(event);
|
||||
} catch (e) {
|
||||
console.error(error)
|
||||
}
|
||||
await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
} else if (
|
||||
event.request.url.startsWith(location.origin + __uv$config.prefix)
|
||||
) {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
return await uv.fetch(event);
|
||||
})()
|
||||
);
|
||||
} else {
|
||||
event.respondWith(
|
||||
(async function () {
|
||||
return await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
}
|
||||
});
|
||||
return await dynamic.fetch(event);
|
||||
}
|
||||
return await fetch(event.request);
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
|
@ -1,612 +0,0 @@
|
|||
//Built from: https://github.com/motortruck1221/bare-as-module3 (commit: 36759f801e0009027878edecff156408b06404c6)
|
||||
(function (global, factory) {
|
||||
typeof exports === "object" && typeof module !== "undefined"
|
||||
? factory(exports)
|
||||
: typeof define === "function" && define.amd
|
||||
? define(["exports"], factory)
|
||||
: ((global =
|
||||
typeof globalThis !== "undefined" ? globalThis : global || self),
|
||||
factory((global.BareMod = {})));
|
||||
})(this, function (exports) {
|
||||
"use strict";
|
||||
|
||||
// The user likely has overwritten all networking functions after importing bare-client
|
||||
// It is our responsibility to make sure components of Bare-Client are using native networking functions
|
||||
// These exports are provided to plugins by @rollup/plugin-inject
|
||||
const fetch = globalThis.fetch;
|
||||
const WebSocket = globalThis.WebSocket;
|
||||
const WebSocketFields = {
|
||||
prototype: {
|
||||
send: WebSocket.prototype.send
|
||||
},
|
||||
CLOSED: WebSocket.CLOSED,
|
||||
CLOSING: WebSocket.CLOSING,
|
||||
CONNECTING: WebSocket.CONNECTING,
|
||||
OPEN: WebSocket.OPEN
|
||||
};
|
||||
|
||||
class BareError extends Error {
|
||||
status;
|
||||
body;
|
||||
constructor(status, body) {
|
||||
super(body.message || body.code);
|
||||
this.status = status;
|
||||
this.body = body;
|
||||
}
|
||||
}
|
||||
class Client {
|
||||
base;
|
||||
/**
|
||||
*
|
||||
* @param version Version provided by extension
|
||||
* @param server Bare Server URL provided by BareClient
|
||||
*/
|
||||
constructor(version, server) {
|
||||
this.base = new URL(`./v${version}/`, server);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* JavaScript MD5
|
||||
* Adopted from https://github.com/blueimp/JavaScript-MD5
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
/**
|
||||
* Add integers, wrapping at 2^32.
|
||||
* This uses 16-bit operations internally to work around bugs in interpreters.
|
||||
*
|
||||
* @param x First integer
|
||||
* @param y Second integer
|
||||
* @returns Sum
|
||||
*/
|
||||
function safeAdd(x, y) {
|
||||
const lsw = (x & 0xffff) + (y & 0xffff);
|
||||
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xffff);
|
||||
}
|
||||
/**
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*
|
||||
* @param num 32-bit number
|
||||
* @param cnt Rotation count
|
||||
* @returns Rotated number
|
||||
*/
|
||||
function bitRotateLeft(num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param q q
|
||||
* @param a a
|
||||
* @param b b
|
||||
* @param x x
|
||||
* @param s s
|
||||
* @param t t
|
||||
* @returns Result
|
||||
*/
|
||||
function md5cmn(q, a, b, x, s, t) {
|
||||
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param a a
|
||||
* @param b b
|
||||
* @param c c
|
||||
* @param d d
|
||||
* @param x x
|
||||
* @param s s
|
||||
* @param t t
|
||||
* @returns Result
|
||||
*/
|
||||
function md5ff(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & c) | (~b & d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param a a
|
||||
* @param b b
|
||||
* @param c c
|
||||
* @param d d
|
||||
* @param x x
|
||||
* @param s s
|
||||
* @param t t
|
||||
* @returns Result
|
||||
*/
|
||||
function md5gg(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param a a
|
||||
* @param b b
|
||||
* @param c c
|
||||
* @param d d
|
||||
* @param x x
|
||||
* @param s s
|
||||
* @param t t
|
||||
* @returns Result
|
||||
*/
|
||||
function md5hh(a, b, c, d, x, s, t) {
|
||||
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param a a
|
||||
* @param b b
|
||||
* @param c c
|
||||
* @param d d
|
||||
* @param x x
|
||||
* @param s s
|
||||
* @param t t
|
||||
* @returns Result
|
||||
*/
|
||||
function md5ii(a, b, c, d, x, s, t) {
|
||||
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*
|
||||
* @param x Array of little-endian words
|
||||
* @param len Bit length
|
||||
* @returns MD5 Array
|
||||
*/
|
||||
function binlMD5(x, len) {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << len % 32;
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
let a = 1732584193;
|
||||
let b = -271733879;
|
||||
let c = -1732584194;
|
||||
let d = 271733878;
|
||||
for (let i = 0; i < x.length; i += 16) {
|
||||
const olda = a;
|
||||
const oldb = b;
|
||||
const oldc = c;
|
||||
const oldd = d;
|
||||
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
||||
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
||||
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
||||
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
||||
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
||||
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
||||
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
||||
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
||||
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
||||
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
||||
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
||||
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
||||
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
||||
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
||||
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
||||
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
||||
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
||||
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
||||
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
||||
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
||||
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
||||
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
||||
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
||||
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
||||
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
||||
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
||||
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
||||
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
||||
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
||||
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
||||
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
||||
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
||||
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
||||
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
||||
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
||||
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
||||
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
||||
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
||||
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
||||
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
||||
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
||||
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
||||
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
||||
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
||||
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
||||
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
||||
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
||||
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
||||
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
||||
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
||||
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
||||
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
||||
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
||||
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
||||
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
||||
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
||||
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
||||
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
||||
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
||||
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
||||
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
||||
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
||||
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
||||
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
||||
a = safeAdd(a, olda);
|
||||
b = safeAdd(b, oldb);
|
||||
c = safeAdd(c, oldc);
|
||||
d = safeAdd(d, oldd);
|
||||
}
|
||||
return [a, b, c, d];
|
||||
}
|
||||
/**
|
||||
* Convert an array of little-endian words to a string
|
||||
*
|
||||
* @param input MD5 Array
|
||||
* @returns MD5 string
|
||||
*/
|
||||
function binl2rstr(input) {
|
||||
let output = "";
|
||||
const length32 = input.length * 32;
|
||||
for (let i = 0; i < length32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*
|
||||
* @param input Raw input string
|
||||
* @returns Array of little-endian words
|
||||
*/
|
||||
function rstr2binl(input) {
|
||||
const output = [];
|
||||
const outputLen = input.length >> 2;
|
||||
for (let i = 0; i < outputLen; i += 1) {
|
||||
output[i] = 0;
|
||||
}
|
||||
const length8 = input.length * 8;
|
||||
for (let i = 0; i < length8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Calculate the MD5 of a raw string
|
||||
*
|
||||
* @param s Input string
|
||||
* @returns Raw MD5 string
|
||||
*/
|
||||
function rstrMD5(s) {
|
||||
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
|
||||
}
|
||||
/**
|
||||
* Calculates the HMAC-MD5 of a key and some data (raw strings)
|
||||
*
|
||||
* @param key HMAC key
|
||||
* @param data Raw input string
|
||||
* @returns Raw MD5 string
|
||||
*/
|
||||
function rstrHMACMD5(key, data) {
|
||||
let bkey = rstr2binl(key);
|
||||
const ipad = [];
|
||||
const opad = [];
|
||||
if (bkey.length > 16) {
|
||||
bkey = binlMD5(bkey, key.length * 8);
|
||||
}
|
||||
for (let i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5c5c5c5c;
|
||||
}
|
||||
const hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
||||
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
|
||||
}
|
||||
/**
|
||||
* Convert a raw string to a hex string
|
||||
*
|
||||
* @param input Raw input string
|
||||
* @returns Hex encoded string
|
||||
*/
|
||||
function rstr2hex(input) {
|
||||
const hexTab = "0123456789abcdef";
|
||||
let output = "";
|
||||
for (let i = 0; i < input.length; i += 1) {
|
||||
const x = input.charCodeAt(i);
|
||||
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Encode a string as UTF-8
|
||||
*
|
||||
* @param input Input string
|
||||
* @returns UTF8 string
|
||||
*/
|
||||
function str2rstrUTF8(input) {
|
||||
return unescape(encodeURIComponent(input));
|
||||
}
|
||||
/**
|
||||
* Encodes input string as raw MD5 string
|
||||
*
|
||||
* @param s Input string
|
||||
* @returns Raw MD5 string
|
||||
*/
|
||||
function rawMD5(s) {
|
||||
return rstrMD5(str2rstrUTF8(s));
|
||||
}
|
||||
/**
|
||||
* Encodes input string as Hex encoded string
|
||||
*
|
||||
* @param s Input string
|
||||
* @returns Hex encoded string
|
||||
*/
|
||||
function hexMD5(s) {
|
||||
return rstr2hex(rawMD5(s));
|
||||
}
|
||||
/**
|
||||
* Calculates the raw HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param k HMAC key
|
||||
* @param d Input string
|
||||
* @returns Raw MD5 string
|
||||
*/
|
||||
function rawHMACMD5(k, d) {
|
||||
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
|
||||
}
|
||||
/**
|
||||
* Calculates the Hex encoded HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param k HMAC key
|
||||
* @param d Input string
|
||||
* @returns Raw MD5 string
|
||||
*/
|
||||
function hexHMACMD5(k, d) {
|
||||
return rstr2hex(rawHMACMD5(k, d));
|
||||
}
|
||||
/**
|
||||
* Calculates MD5 value for a given string.
|
||||
* If a key is provided, calculates the HMAC-MD5 value.
|
||||
* Returns a Hex encoded string unless the raw argument is given.
|
||||
*
|
||||
* @param string Input string
|
||||
* @param key HMAC key
|
||||
* @param raw Raw output switch
|
||||
* @returns MD5 output
|
||||
*/
|
||||
function md5(string, key, raw) {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hexMD5(string);
|
||||
}
|
||||
return rawMD5(string);
|
||||
}
|
||||
if (!raw) {
|
||||
return hexHMACMD5(key, string);
|
||||
}
|
||||
return rawHMACMD5(key, string);
|
||||
}
|
||||
|
||||
const MAX_HEADER_VALUE = 3072;
|
||||
/**
|
||||
*
|
||||
* Splits headers according to spec
|
||||
* @param headers
|
||||
* @returns Split headers
|
||||
*/
|
||||
function splitHeaders(headers) {
|
||||
const output = new Headers(headers);
|
||||
if (headers.has("x-bare-headers")) {
|
||||
const value = headers.get("x-bare-headers");
|
||||
if (value.length > MAX_HEADER_VALUE) {
|
||||
output.delete("x-bare-headers");
|
||||
let split = 0;
|
||||
for (let i = 0; i < value.length; i += MAX_HEADER_VALUE) {
|
||||
const part = value.slice(i, i + MAX_HEADER_VALUE);
|
||||
const id = split++;
|
||||
output.set(`x-bare-headers-${id}`, `;${part}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Joins headers according to spec
|
||||
* @param headers
|
||||
* @returns Joined headers
|
||||
*/
|
||||
function joinHeaders(headers) {
|
||||
const output = new Headers(headers);
|
||||
const prefix = "x-bare-headers";
|
||||
if (headers.has(`${prefix}-0`)) {
|
||||
const join = [];
|
||||
for (const [header, value] of headers) {
|
||||
if (!header.startsWith(prefix)) {
|
||||
continue;
|
||||
}
|
||||
if (!value.startsWith(";")) {
|
||||
throw new BareError(400, {
|
||||
code: "INVALID_BARE_HEADER",
|
||||
id: `request.headers.${header}`,
|
||||
message: `Value didn't begin with semi-colon.`
|
||||
});
|
||||
}
|
||||
const id = parseInt(header.slice(prefix.length + 1));
|
||||
join[id] = value.slice(1);
|
||||
output.delete(header);
|
||||
}
|
||||
output.set(prefix, join.join(""));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
class ClientV3 extends Client {
|
||||
ws;
|
||||
http;
|
||||
meta() {
|
||||
return {};
|
||||
}
|
||||
constructor(server) {
|
||||
super(3, server);
|
||||
this.ws = new URL(this.base);
|
||||
this.http = new URL(this.base);
|
||||
if (this.ws.protocol === "https:") {
|
||||
this.ws.protocol = "wss:";
|
||||
} else {
|
||||
this.ws.protocol = "ws:";
|
||||
}
|
||||
}
|
||||
ready = true;
|
||||
async init() {
|
||||
this.ready = true;
|
||||
}
|
||||
connect(
|
||||
url,
|
||||
origin,
|
||||
protocols,
|
||||
requestHeaders,
|
||||
onopen,
|
||||
onmessage,
|
||||
onclose,
|
||||
onerror
|
||||
) {
|
||||
const ws = new WebSocket(this.ws);
|
||||
const cleanup = () => {
|
||||
ws.removeEventListener("close", closeListener);
|
||||
ws.removeEventListener("message", messageListener);
|
||||
};
|
||||
const closeListener = () => {
|
||||
cleanup();
|
||||
};
|
||||
const messageListener = (event) => {
|
||||
cleanup();
|
||||
// ws.binaryType is irrelevant when sending text
|
||||
if (typeof event.data !== "string")
|
||||
throw new TypeError(
|
||||
"the first websocket message was not a text frame"
|
||||
);
|
||||
const message = JSON.parse(event.data);
|
||||
// finally
|
||||
if (message.type !== "open")
|
||||
throw new TypeError("message was not of open type");
|
||||
// onMeta({
|
||||
// protocol: message.protocol,
|
||||
// setCookies: message.setCookies,
|
||||
// });
|
||||
onopen(message.protocol);
|
||||
// TODO
|
||||
ws.addEventListener("message", (ev) => {
|
||||
onmessage(ev.data);
|
||||
});
|
||||
};
|
||||
ws.addEventListener("close", closeListener);
|
||||
ws.addEventListener("message", messageListener);
|
||||
// CONNECTED TO THE BARE SERVER, NOT THE REMOTE
|
||||
ws.addEventListener(
|
||||
"open",
|
||||
(event) => {
|
||||
// getRequestHeaders().then((headers:any) =>
|
||||
WebSocketFields.prototype.send.call(
|
||||
ws,
|
||||
JSON.stringify({
|
||||
type: "connect",
|
||||
remote: url.toString(),
|
||||
protocols,
|
||||
headers: requestHeaders,
|
||||
forwardHeaders: []
|
||||
})
|
||||
);
|
||||
// );
|
||||
},
|
||||
// only block the open event once
|
||||
{ once: true }
|
||||
);
|
||||
return ws.send.bind(ws);
|
||||
}
|
||||
async request(remote, method, body, headers, signal) {
|
||||
const options = {
|
||||
credentials: "omit",
|
||||
method: method,
|
||||
signal
|
||||
};
|
||||
if (body !== undefined) {
|
||||
options.body = body;
|
||||
}
|
||||
options.headers = this.createBareHeaders(remote, headers);
|
||||
const response = await fetch(
|
||||
this.http + "?cache=" + md5(remote.toString()),
|
||||
options
|
||||
);
|
||||
const readResponse = await this.readBareResponse(response);
|
||||
// const result: Response & Partial<BareResponse> = new Response(
|
||||
// statusEmpty.includes(readResponse.status!) ? undefined : response.body,
|
||||
// {
|
||||
// status: readResponse.status,
|
||||
// statusText: readResponse.statusText ?? undefined,
|
||||
// headers: new Headers(readResponse.headers as HeadersInit),
|
||||
// }
|
||||
// );
|
||||
//
|
||||
// result.rawHeaders = readResponse.headers;
|
||||
// result.rawResponse = response;
|
||||
return {
|
||||
body: response.body,
|
||||
headers: readResponse.headers,
|
||||
status: readResponse.status,
|
||||
statusText: readResponse.statusText
|
||||
};
|
||||
}
|
||||
async readBareResponse(response) {
|
||||
if (!response.ok) {
|
||||
throw new BareError(response.status, await response.json());
|
||||
}
|
||||
const responseHeaders = joinHeaders(response.headers);
|
||||
const result = {};
|
||||
const xBareStatus = responseHeaders.get("x-bare-status");
|
||||
if (xBareStatus !== null) result.status = parseInt(xBareStatus);
|
||||
const xBareStatusText = responseHeaders.get("x-bare-status-text");
|
||||
if (xBareStatusText !== null) result.statusText = xBareStatusText;
|
||||
const xBareHeaders = responseHeaders.get("x-bare-headers");
|
||||
if (xBareHeaders !== null) result.headers = JSON.parse(xBareHeaders);
|
||||
return result;
|
||||
}
|
||||
createBareHeaders(
|
||||
remote,
|
||||
bareHeaders,
|
||||
forwardHeaders = [],
|
||||
passHeaders = [],
|
||||
passStatus = []
|
||||
) {
|
||||
const headers = new Headers();
|
||||
headers.set("x-bare-url", remote.toString());
|
||||
headers.set("x-bare-headers", JSON.stringify(bareHeaders));
|
||||
for (const header of forwardHeaders) {
|
||||
headers.append("x-bare-forward-headers", header);
|
||||
}
|
||||
for (const header of passHeaders) {
|
||||
headers.append("x-bare-pass-headers", header);
|
||||
}
|
||||
for (const status of passStatus) {
|
||||
headers.append("x-bare-pass-status", status.toString());
|
||||
}
|
||||
splitHeaders(headers);
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
exports.BareClient = ClientV3;
|
||||
});
|
||||
//# sourceMappingURL=bare.cjs.map
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
self.__uv$config = {
|
||||
prefix: "/~/uv/",
|
||||
bare: "/bare/",
|
||||
encodeUrl: function encode(str) {
|
||||
if (!str) return str;
|
||||
return encodeURIComponent(
|
||||
|
|
@ -30,7 +29,5 @@ self.__uv$config = {
|
|||
client: "/uv/uv.client.js",
|
||||
bundle: "/uv/uv.bundle.js",
|
||||
config: "/uv/uv.config.js",
|
||||
sw: "/uv/uv.sw.js",
|
||||
proxyIp: "",
|
||||
proxyPort: ""
|
||||
sw: "/uv/uv.sw.js"
|
||||
};
|
||||
|
|
|
|||
10
server.ts
10
server.ts
|
|
@ -49,7 +49,7 @@ function routeRhRequest(req, res) {
|
|||
function routeRhUpgrade(req, socket, head) {
|
||||
rh.emit("upgrade", req, socket, head);
|
||||
}
|
||||
|
||||
const port = parseInt(process.env.PORT) || 8080;
|
||||
const serverFactory = (handler, opts) => {
|
||||
return createServer()
|
||||
.on("request", (req, res) => {
|
||||
|
|
@ -101,13 +101,15 @@ app.setNotFoundHandler((req, res) => {
|
|||
});
|
||||
|
||||
console.log(
|
||||
chalk.green(`Server listening on ${chalk.bold("http://localhost:8080")}`)
|
||||
chalk.green(`Server listening on ${chalk.bold(`http://localhost:${port}`)}`)
|
||||
);
|
||||
console.log(
|
||||
chalk.magenta(`Server also listening on ${chalk.bold("http://0.0.0.0:8080")}`)
|
||||
chalk.magenta(
|
||||
`Server also listening on ${chalk.bold(`http://0.0.0.0:${port}`)}`
|
||||
)
|
||||
);
|
||||
|
||||
app.listen({
|
||||
port: 8080,
|
||||
port: port,
|
||||
host: "0.0.0.0"
|
||||
});
|
||||
|
|
|
|||
38
server/config.js
Normal file
38
server/config.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import chalk from "chalk";
|
||||
import { parse } from "smol-toml";
|
||||
let doc = readFileSync(fileURLToPath(new URL("../config.toml", import.meta.url))).toString();
|
||||
const parsedDoc = parse(doc);
|
||||
function verify(t) {
|
||||
for (let i = 0; i !== t.length; i++) {
|
||||
if (typeof t[i].typeOF !== t[i].type) {
|
||||
throw new Error(`Invalid structure: "${t[i].name}" should be a(n) ${t[i].type}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
verify([
|
||||
{ name: "marketplace", typeOF: parsedDoc.marketplace, type: "object" },
|
||||
{ name: "marketplace.enabled", typeOF: parsedDoc.marketplace.enabled, type: "boolean" },
|
||||
{ name: "marketplace.psk", typeOF: parsedDoc.marketplace.psk, type: "string" },
|
||||
{ name: "server", typeOF: parsedDoc.server, type: "object" },
|
||||
{ name: "server.server", typeOF: parsedDoc.server.server, type: "object" },
|
||||
{ name: "server.server.port", typeOF: parsedDoc.server.server.port, type: "number" },
|
||||
{ name: "server.server.wisp", typeOF: parsedDoc.server.server.wisp, type: "boolean" },
|
||||
{ name: "server.server.logging", typeOF: parsedDoc.server.server.logging, type: "boolean" },
|
||||
{ name: "db", typeOF: parsedDoc.db, type: "object" },
|
||||
{ name: "db.name", typeOF: parsedDoc.db.name, type: "string" },
|
||||
{ name: "db.username", typeOF: parsedDoc.db.username, type: "string" },
|
||||
{ name: "db.password", typeOF: parsedDoc.db.password, type: "string" },
|
||||
{ name: "db.postgres", typeOF: parsedDoc.db.postgres, type: "boolean" },
|
||||
{ name: "postgres", typeOF: parsedDoc.postgres, type: "object" },
|
||||
{ name: "postgres.domain", typeOF: parsedDoc.postgres.domain, type: "string" },
|
||||
{ name: "postgres.port", typeOF: parsedDoc.postgres.port, type: "number" }
|
||||
]);
|
||||
if (parsedDoc.marketplace.psk === "CHANGEME") {
|
||||
console.warn(chalk.yellow.bold('PSK should be changed from "CHANGEME"'));
|
||||
}
|
||||
if (parsedDoc.db.password === "password") {
|
||||
console.warn(chalk.red.bold("You should change your DB password!!"));
|
||||
}
|
||||
export { parsedDoc };
|
||||
76
server/dbSetup.js
Normal file
76
server/dbSetup.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
import chalk from "chalk";
|
||||
import ora from "ora";
|
||||
async function installItems(db, items) {
|
||||
items.forEach(async (item) => {
|
||||
await db.create({
|
||||
package_name: item.package_name,
|
||||
title: item.title,
|
||||
image: item.image,
|
||||
author: item.author,
|
||||
version: item.version,
|
||||
description: item.description,
|
||||
tags: item.tags,
|
||||
payload: item.payload,
|
||||
background_video: item.background_video,
|
||||
background_image: item.background_image,
|
||||
type: item.type
|
||||
});
|
||||
});
|
||||
}
|
||||
async function setupDB(db) {
|
||||
//We have some packages that need to be installed if they aren't.
|
||||
const items = [
|
||||
{
|
||||
package_name: "com.nebula.gruvbox",
|
||||
title: "Gruvbox",
|
||||
image: "gruvbox.jpeg",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: "The gruvbox theme",
|
||||
tags: ["Theme", "Simple"],
|
||||
payload: "gruvbox.css",
|
||||
type: "theme"
|
||||
},
|
||||
{
|
||||
package_name: "com.nebula.oled",
|
||||
title: "Oled theme",
|
||||
image: "oled.jpg",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: "A sleek & simple Oled theme for Nebula",
|
||||
tags: ["Theme", "Simple", "Sleek"],
|
||||
payload: "oled.css",
|
||||
type: "theme"
|
||||
},
|
||||
{
|
||||
package_name: "com.nebula.lightTheme",
|
||||
title: "Light Theme",
|
||||
image: "light.png",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: "A sleek light theme for Nebula",
|
||||
tags: ["Theme", "Simple", "Light"],
|
||||
payload: "light.css",
|
||||
type: "theme"
|
||||
},
|
||||
{
|
||||
package_name: "com.nebula.retro",
|
||||
title: "Retro Theme",
|
||||
image: "retro.png",
|
||||
author: "Nebula Services",
|
||||
version: "1.0.0",
|
||||
description: "Give a retro look to Nebula",
|
||||
tags: ["Theme", "Simple", "Dark", "Retro"],
|
||||
payload: "retro.css",
|
||||
type: "theme"
|
||||
}
|
||||
//To add plugins: plugin types consist of plugin-sw (workerware) & plugin-page (uv.config.inject)
|
||||
];
|
||||
const dbItems = await db.findAll();
|
||||
if (dbItems.length === 0) {
|
||||
const spinner = ora(chalk.hex("#7967dd")("Performing DB setup...")).start();
|
||||
await installItems(db, items);
|
||||
spinner.succeed(chalk.hex("#eb6f92")("DB setup complete!"));
|
||||
}
|
||||
}
|
||||
export { setupDB };
|
||||
169
server/marketplace.js
Normal file
169
server/marketplace.js
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
import { createWriteStream } from "node:fs";
|
||||
import { constants, access, mkdir } from "node:fs/promises";
|
||||
import { pipeline } from "node:stream/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { DataTypes, Sequelize } from "sequelize";
|
||||
import { parsedDoc } from "./config.js";
|
||||
const db = new Sequelize(parsedDoc.db.name, parsedDoc.db.username, parsedDoc.db.password, {
|
||||
host: parsedDoc.db.postgres ? `${parsedDoc.postgres.domain}` : "localhost",
|
||||
port: parsedDoc.db.postgres ? parsedDoc.postgres.port : undefined,
|
||||
dialect: parsedDoc.db.postgres ? "postgres" : "sqlite",
|
||||
logging: parsedDoc.server.server.logging,
|
||||
storage: "database.sqlite" //this is sqlite only
|
||||
});
|
||||
const catalogAssets = db.define("catalog_assets", {
|
||||
package_name: { type: DataTypes.STRING, unique: true },
|
||||
title: { type: DataTypes.TEXT },
|
||||
description: { type: DataTypes.TEXT },
|
||||
author: { type: DataTypes.TEXT },
|
||||
image: { type: DataTypes.TEXT },
|
||||
tags: { type: DataTypes.JSON, allowNull: true },
|
||||
version: { type: DataTypes.TEXT },
|
||||
background_image: { type: DataTypes.TEXT, allowNull: true },
|
||||
background_video: { type: DataTypes.TEXT, allowNull: true },
|
||||
payload: { type: DataTypes.TEXT },
|
||||
type: { type: DataTypes.TEXT }
|
||||
});
|
||||
function marketplaceAPI(app) {
|
||||
app.get("/api/catalog-stats/", (request, reply) => {
|
||||
reply.send({
|
||||
version: "1.0.0",
|
||||
spec: "Nebula Services",
|
||||
enabled: true
|
||||
});
|
||||
});
|
||||
app.get("/api/catalog-assets/", async (request, reply) => {
|
||||
try {
|
||||
const { page } = request.query;
|
||||
const pageNum = parseInt(page, 10) || 1;
|
||||
if (pageNum < 1) {
|
||||
reply.status(400).send({ error: "Page must be a positive number!" });
|
||||
}
|
||||
const offset = (pageNum - 1) * 20;
|
||||
const totalItems = await catalogAssets.count();
|
||||
const dbAssets = await catalogAssets.findAll({ offset: offset, limit: 20 });
|
||||
const assets = dbAssets.reduce((acc, asset) => {
|
||||
acc[asset.package_name] = {
|
||||
title: asset.title,
|
||||
description: asset.description,
|
||||
author: asset.author,
|
||||
image: asset.image,
|
||||
tags: asset.tags,
|
||||
version: asset.version,
|
||||
background_image: asset.background_image,
|
||||
background_video: asset.background_video,
|
||||
payload: asset.payload,
|
||||
type: asset.type
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
return reply.send({ assets, pages: Math.ceil(totalItems / 20) });
|
||||
}
|
||||
catch (error) {
|
||||
return reply.status(500).send({ error: "An error occured" });
|
||||
}
|
||||
});
|
||||
app.get("/api/packages/:package", async (request, reply) => {
|
||||
try {
|
||||
const packageRow = await catalogAssets.findOne({
|
||||
where: { package_name: request.params.package }
|
||||
});
|
||||
if (!packageRow)
|
||||
return reply.status(404).send({ error: "Package not found!" });
|
||||
const details = {
|
||||
title: packageRow.get("title"),
|
||||
description: packageRow.get("description"),
|
||||
image: packageRow.get("image"),
|
||||
author: packageRow.get("author"),
|
||||
tags: packageRow.get("tags"),
|
||||
version: packageRow.get("version"),
|
||||
background_image: packageRow.get("background_image"),
|
||||
background_video: packageRow.get("background_video"),
|
||||
payload: packageRow.get("payload"),
|
||||
type: packageRow.get("type")
|
||||
};
|
||||
reply.send(details);
|
||||
}
|
||||
catch (error) {
|
||||
reply.status(500).send({ error: "An unexpected error occured" });
|
||||
}
|
||||
});
|
||||
async function verifyReq(request, upload, data) {
|
||||
if (request.headers.psk !== parsedDoc.marketplace.psk) {
|
||||
return { status: 403, error: new Error("PSK isn't correct!") };
|
||||
}
|
||||
else if (upload && !request.headers.packagename) {
|
||||
return { status: 500, error: new Error("No packagename defined!") };
|
||||
}
|
||||
else if (upload && !data) {
|
||||
return { status: 400, error: new Error("No file uploaded!") };
|
||||
}
|
||||
else {
|
||||
return { status: 200 };
|
||||
}
|
||||
}
|
||||
app.post("/api/upload-asset", async (request, reply) => {
|
||||
const data = await request.file();
|
||||
const verify = await verifyReq(request, true, data);
|
||||
if (verify.error !== undefined) {
|
||||
reply.status(verify.status).send({ status: verify.error.message });
|
||||
}
|
||||
else {
|
||||
try {
|
||||
await pipeline(data.file, createWriteStream(fileURLToPath(new URL(`../database_assets/${request.headers.packagename}/${data.filename}`, import.meta.url))));
|
||||
}
|
||||
catch (error) {
|
||||
return reply.status(500).send({
|
||||
status: `File couldn't be uploaded! (Package most likely doesn't exist)`
|
||||
});
|
||||
}
|
||||
return reply.status(verify.status).send({ status: "File uploaded successfully!" });
|
||||
}
|
||||
});
|
||||
app.post("/api/create-package", async (request, reply) => {
|
||||
const verify = await verifyReq(request, false, undefined);
|
||||
if (verify.error !== undefined) {
|
||||
reply.status(verify.status).send({ status: verify.error.message });
|
||||
}
|
||||
else {
|
||||
const body = {
|
||||
package_name: request.body.uuid,
|
||||
title: request.body.title,
|
||||
image: request.body.image,
|
||||
author: request.body.author,
|
||||
version: request.body.version,
|
||||
description: request.body.description,
|
||||
tags: request.body.tags,
|
||||
payload: request.body.payload,
|
||||
background_video: request.body.background_video,
|
||||
background_image: request.body.background_image,
|
||||
type: request.body.type
|
||||
};
|
||||
await catalogAssets.create({
|
||||
package_name: body.package_name,
|
||||
title: body.title,
|
||||
image: body.image,
|
||||
author: body.author,
|
||||
version: body.version,
|
||||
description: body.description,
|
||||
tags: body.tags,
|
||||
payload: body.payload,
|
||||
background_video: body.background_video,
|
||||
background_image: body.background_image,
|
||||
type: body.type
|
||||
});
|
||||
const assets = fileURLToPath(new URL("../database_assets", import.meta.url));
|
||||
try {
|
||||
await access(`${assets}/${body.package_name}/`, constants.F_OK);
|
||||
return reply.status(500).send({ status: "Package already exists!" });
|
||||
}
|
||||
catch (err) {
|
||||
await mkdir(`${assets}/${body.package_name}/`);
|
||||
return reply
|
||||
.status(verify.status)
|
||||
.send({ status: "Package created successfully!" });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
export { marketplaceAPI, db, catalogAssets };
|
||||
66
server/server.js
Normal file
66
server/server.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import { fileURLToPath } from "node:url";
|
||||
import fastifyCompress from "@fastify/compress";
|
||||
import fastifyHelmet from "@fastify/helmet";
|
||||
import fastifyMiddie from "@fastify/middie";
|
||||
import fastifyMultipart from "@fastify/multipart";
|
||||
import fastifyStatic from "@fastify/static";
|
||||
import chalk from "chalk";
|
||||
import Fastify from "fastify";
|
||||
import gradient from "gradient-string";
|
||||
//@ts-ignore WHY would I want this typechecked AT ALL
|
||||
import { handler as ssrHandler } from "../dist/server/entry.mjs";
|
||||
import { parsedDoc } from "./config.js";
|
||||
import { setupDB } from "./dbSetup.js";
|
||||
import { catalogAssets, marketplaceAPI } from "./marketplace.js";
|
||||
import { serverFactory } from "./serverFactory.js";
|
||||
const app = Fastify({
|
||||
logger: parsedDoc.server.server.logging,
|
||||
ignoreDuplicateSlashes: true,
|
||||
ignoreTrailingSlash: true,
|
||||
serverFactory: serverFactory
|
||||
});
|
||||
await app.register(fastifyCompress, {
|
||||
encodings: ["br", "gzip", "deflate"]
|
||||
});
|
||||
await app.register(fastifyMultipart);
|
||||
await app.register(fastifyHelmet, {
|
||||
xPoweredBy: false,
|
||||
crossOriginEmbedderPolicy: true,
|
||||
crossOriginOpenerPolicy: true,
|
||||
contentSecurityPolicy: false //Disabled because astro DOES NOT LIKE IT
|
||||
});
|
||||
await app.register(fastifyStatic, {
|
||||
root: fileURLToPath(new URL("../dist/client", import.meta.url))
|
||||
});
|
||||
//Our marketplace API. Not middleware as I don't want to deal with that LOL. Just a function that passes our app to it.
|
||||
if (parsedDoc.marketplace.enabled) {
|
||||
await app.register(fastifyStatic, {
|
||||
root: fileURLToPath(new URL("../database_assets", import.meta.url)),
|
||||
prefix: "/packages/",
|
||||
decorateReply: false
|
||||
});
|
||||
marketplaceAPI(app);
|
||||
}
|
||||
await app.register(fastifyMiddie);
|
||||
app.use(ssrHandler);
|
||||
const port = parseInt(process.env.PORT) || parsedDoc.server.server.port || parseInt("8080");
|
||||
const titleText = `
|
||||
_ _ _ _ ____ _
|
||||
| \\ | | ___| |__ _ _| | __ _ / ___| ___ _ ____ _(_) ___ ___ ___
|
||||
| \\| |/ _ \\ '_ \\| | | | |/ _' | \\___ \\ / _ \\ '__\\ \\ / / |/ __/ _ \\/ __|
|
||||
| |\\ | __/ |_) | |_| | | (_| | ___) | __/ | \\ V /| | (_| __/\\__ \\
|
||||
|_| \\_|\\___|_.__/ \\__,_|_|\\__,_| |____/ \\___|_| \\_/ |_|\\___\\___||___/
|
||||
`;
|
||||
const titleColors = {
|
||||
purple: "#7967dd",
|
||||
pink: "#eb6f92"
|
||||
};
|
||||
console.log(gradient(Object.values(titleColors)).multiline(titleText));
|
||||
app.listen({ port: port, host: "0.0.0.0" }).then(async () => {
|
||||
console.log(chalk.hex("#7967dd")(`Server listening on ${chalk.hex("#eb6f92").bold("http://localhost:" + port + "/")}`));
|
||||
console.log(chalk.hex("#7967dd")(`Server also listening on ${chalk.hex("#eb6f92").bold("http://0.0.0.0:" + port + "/")}`));
|
||||
if (parsedDoc.marketplace.enabled) {
|
||||
await catalogAssets.sync();
|
||||
await setupDB(catalogAssets);
|
||||
}
|
||||
});
|
||||
23
server/serverFactory.js
Normal file
23
server/serverFactory.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { createServer } from "node:http";
|
||||
import wisp from "wisp-server-node";
|
||||
import { LOG_LEVEL } from "wisp-server-node/dist/Types.js";
|
||||
import { parsedDoc } from "./config.js";
|
||||
const wispOptions = {
|
||||
logLevel: parsedDoc.server.server.logging ? LOG_LEVEL.DEBUG : LOG_LEVEL.NONE,
|
||||
pingInterval: 30,
|
||||
};
|
||||
const serverFactory = (handler) => {
|
||||
const httpServer = createServer();
|
||||
httpServer.on("request", (req, res) => {
|
||||
handler(req, res);
|
||||
});
|
||||
httpServer.on("upgrade", (req, socket, head) => {
|
||||
if (parsedDoc.server.server.wisp) {
|
||||
if (req.url?.endsWith("/wisp/")) {
|
||||
wisp.routeRequest(req, socket, head, wispOptions);
|
||||
}
|
||||
}
|
||||
});
|
||||
return httpServer;
|
||||
};
|
||||
export { serverFactory };
|
||||
|
|
@ -9,7 +9,7 @@ import { RxMixerVertical, RxHamburgerMenu } from "react-icons/rx";
|
|||
import { RiLinksFill } from "react-icons/ri";
|
||||
import { BsQuestionLg } from "react-icons/bs";
|
||||
import { useState } from "preact/hooks";
|
||||
import { Logo } from "./logo";
|
||||
import { Logo } from "./Logo";
|
||||
|
||||
export function Header() {
|
||||
const { t } = useTranslation();
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
export const Logo = () => {
|
||||
return (
|
||||
<svg
|
||||
version="1.2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 400 400"
|
||||
width="400"
|
||||
height="400"
|
||||
style="width: 100%; height: 100%;"
|
||||
>
|
||||
<title>nebula</title>
|
||||
<g id="svgg">
|
||||
<path
|
||||
id="path0"
|
||||
fill-rule="evenodd"
|
||||
class="s0"
|
||||
d="m213.6 84c1 0.3 3.4 0.7 5.1 1 1.8 0.2 4.1 0.7 5.2 1 13.2 4.1 20.3 6.8 24.5 9.1 0.6 0.3 2.3 1.2 3.8 2 2.8 1.4 13.1 8 14.4 9.2 0.5 0.3 2.3 1.9 4.2 3.5 6.7 5.5 15.5 14.9 19.2 20.4 1 1.4 2 2.7 2.2 2.8 0.3 0.1 0.5 0.5 0.5 0.8 0 0.3 1.2 2.2 2.5 4.3 2.3 3.4 7.8 14.3 9.8 19.3 0.8 2.1 0.9 2.2 10 4.9 5.6 1.6 11.1 3.4 11.7 3.8 0.3 0.2 2.4 1.1 4.7 1.9 11.1 4.1 23 12.5 27.3 19.4 5.5 8.7 3.6 20.5-4.5 28.5-3.1 3-7.5 6.4-8.4 6.4-0.3 0-0.7 0.2-0.8 0.5-1.1 2.3-23.3 11.2-35.9 14.3-3.2 0.9-3.5 1.2-5.7 6.8-7.5 19-25.5 40.6-42.3 51.1-1.6 1-3.1 2-3.3 2.2-0.1 0.2-0.9 0.7-1.7 1.2-0.8 0.4-2.2 1.2-2.9 1.6-0.8 0.4-1.6 1-1.8 1.1-0.5 0.5-4.1 2.2-8.1 3.9-1.8 0.8-3.8 1.6-4.5 2-0.7 0.3-3.1 1.1-5.2 1.8-8.3 2.6-9.8 3-21 4.9-6.4 1.1-25.3 1.3-30.5 0.3-1.9-0.3-5.8-1.1-8.6-1.6-6.8-1.3-12.7-3-20-5.7-3.3-1.2-18-8.8-19.7-10.1-0.9-0.7-4.1-3.1-7.1-5.2-5.7-4.1-17.9-15.9-20.7-20-0.9-1.2-2-2.7-2.5-3.2-3.2-3.3-13.7-21.7-13.7-24.1 0-0.6-0.2-1.2-0.6-1.4-0.3-0.2-0.8-1.2-1-2.3-0.4-1.9-1.7-2.7-6.5-3.8-23.2-5.6-43.1-17.2-48.6-28.5-7.1-14.4 4.5-31.3 27.3-39.7 1.8-0.7 4.1-1.6 5.2-2 3.7-1.5 8-2.9 19.5-6.2 1.6-0.5 2.8-1.2 2.8-1.7 0-2.4 9.8-21.6 13.1-25.7 0.2-0.4 1.4-1.8 2.5-3.2 13.8-18.1 30.2-30.6 50.6-38.8 4.3-1.7 6-2.3 14.3-4.5 5.5-1.6 11.2-2.4 18.4-2.9 7.9-0.5 24-0.2 26.8 0.6zm-29.7 17.3c-0.2 0.1-7.3 1.7-12.9 2.7-1.7 0.4-4.3 1.2-5.8 1.9-1.5 0.6-3.9 1.5-5.5 2-1.5 0.4-3.3 1.3-4 2-0.7 0.7-1.7 1.2-2.3 1.2-1.2 0-9.5 4.5-9.8 5.3-0.2 0.3-0.5 0.6-0.9 0.6-1.9 0-19.6 16-23.8 21.6-9.3 12.2-16.1 27.4-19.2 42.7-2 10.1-1.1 37.5 1.4 41.4 0 0.1 3.7 0.9 8.1 1.8 9.5 1.9 12.8 2.4 34.6 4.9 38.5 4.5 107.9 2.2 138.3-4.5 1.4-0.3 4.1-0.9 6.1-1.3 4.2-0.8 3.4 0.2 4.9-7.1 1.6-8.3 1.7-27 0.1-34.6-1.5-7.1-3.2-13.4-3.7-14.2-0.3-0.4-0.7-1.5-0.9-2.6-2.8-12.1-19.2-34.1-33-44.3-2.9-2.1-5.5-4-5.8-4.3-2.8-2.2-4.9-3.1-7.2-3.1-2.1 0-2.6-0.2-2.7-1.3-0.2-1.5-5.7-4.5-6.3-3.5-0.7 1.1-2.4 0.6-2.7-0.7-0.4-1.3-1.2-1.6-5.8-2.1-1.6-0.2-4-0.9-5.5-1.6-3.9-1.8-5.3-2.2-10.2-2.6-4.6-0.4-25.2-0.7-25.5-0.3zm74.3 42.2c7.4 9.8 4.8 23.5-4.6 24.9-6.9 1-20.9-5.8-21-10.2 0-0.2-0.3-0.8-0.8-1.3-6.4-6.8-5-20.8 2.4-24.1 6.7-2.9 17.2 1.8 24 10.7zm-176.4 36.4c-0.1-0.1-4.6 1.1-5.9 1.6-0.7 0.3-3 1.2-5.1 2-9.9 3.8-15.1 6.8-19.6 11.5-3.4 3.5-3.3 4.5 0.5 8.7 1 1 11.3 7.6 12 7.6 0.2 0 1.7 0.6 3.4 1.3 1.6 0.8 3.6 1.6 4.3 1.9 1.8 0.8 9.3 3.3 9.9 3.3 0.3 0 0.3-2 0-4.4-0.6-5.6-0.6-24.5 0.1-29.6 0.3-2.1 0.5-3.9 0.4-3.9zm229.3-0.3c-0.2 0 0 1 0.2 2.1 0.6 2.8 0.6 31.3 0 34-0.5 2.2-0.4 2.2 1.3 1.8 3.1-0.7 12.9-4.5 18.3-7 8.5-4 14.3-10.1 12.6-13.3-1.1-2.1-6.7-7.2-7.9-7.2-0.4 0-0.9-0.2-1-0.5-0.4-1.1-11.8-6.1-19.2-8.5-2.3-0.7-4.2-1.4-4.3-1.4zm-199.4 63.4l-3.1-0.4 1.8 3.2c0.9 1.8 1.9 3.4 2.2 3.5 0.3 0.1 0.5 0.6 0.5 1.1 0 0.4 0.6 1.5 1.3 2.3 0.7 0.9 1.5 1.9 1.8 2.2 0.3 0.4 0.8 1.2 1.1 1.7 6.2 10.7 35.6 33.5 43.3 33.5 0.2 0 1.3 0.4 2.5 0.9 2.5 1.2 10.6 3.4 15.3 4.2 9.5 1.8 11.6 2.1 17.4 2.1 6.6 0 16.4-1.3 22.9-3 2.2-0.5 5.2-1.3 6.8-1.7 1.6-0.3 3.2-0.9 3.5-1.2 0.4-0.3 1.1-0.6 1.6-0.6 2.3 0 22-10.6 24-12.9 0.2-0.2 2.2-1.9 4.5-3.7 5.7-4.5 11.8-11 17.1-18.4 1.6-2.3 3.2-4.5 3.6-4.9 0.4-0.4 0.7-1 0.7-1.2 0-0.2 0.8-1.9 1.9-3.6 1.1-1.7 1.9-3.2 1.9-3.4 0-0.2-3.8 0.4-11 1.6-31.7 5.4-85.1 6.7-126.9 3.1-9.6-0.8-23.1-2.3-27.8-3.2-2.2-0.4-5.3-0.9-6.9-1.2z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
export const Logo = () => {
|
||||
return (
|
||||
<svg
|
||||
version="1.2"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 400 400"
|
||||
width="400"
|
||||
height="400"
|
||||
style="width: 100%; height: 100%;"
|
||||
>
|
||||
<title>Nebula</title>
|
||||
<g id="svgg">
|
||||
<path
|
||||
id="path0"
|
||||
fill-rule="evenodd"
|
||||
class="s0"
|
||||
d="m213.6 84c1 0.3 3.4 0.7 5.1 1 1.8 0.2 4.1 0.7 5.2 1 13.2 4.1 20.3 6.8 24.5 9.1 0.6 0.3 2.3 1.2 3.8 2 2.8 1.4 13.1 8 14.4 9.2 0.5 0.3 2.3 1.9 4.2 3.5 6.7 5.5 15.5 14.9 19.2 20.4 1 1.4 2 2.7 2.2 2.8 0.3 0.1 0.5 0.5 0.5 0.8 0 0.3 1.2 2.2 2.5 4.3 2.3 3.4 7.8 14.3 9.8 19.3 0.8 2.1 0.9 2.2 10 4.9 5.6 1.6 11.1 3.4 11.7 3.8 0.3 0.2 2.4 1.1 4.7 1.9 11.1 4.1 23 12.5 27.3 19.4 5.5 8.7 3.6 20.5-4.5 28.5-3.1 3-7.5 6.4-8.4 6.4-0.3 0-0.7 0.2-0.8 0.5-1.1 2.3-23.3 11.2-35.9 14.3-3.2 0.9-3.5 1.2-5.7 6.8-7.5 19-25.5 40.6-42.3 51.1-1.6 1-3.1 2-3.3 2.2-0.1 0.2-0.9 0.7-1.7 1.2-0.8 0.4-2.2 1.2-2.9 1.6-0.8 0.4-1.6 1-1.8 1.1-0.5 0.5-4.1 2.2-8.1 3.9-1.8 0.8-3.8 1.6-4.5 2-0.7 0.3-3.1 1.1-5.2 1.8-8.3 2.6-9.8 3-21 4.9-6.4 1.1-25.3 1.3-30.5 0.3-1.9-0.3-5.8-1.1-8.6-1.6-6.8-1.3-12.7-3-20-5.7-3.3-1.2-18-8.8-19.7-10.1-0.9-0.7-4.1-3.1-7.1-5.2-5.7-4.1-17.9-15.9-20.7-20-0.9-1.2-2-2.7-2.5-3.2-3.2-3.3-13.7-21.7-13.7-24.1 0-0.6-0.2-1.2-0.6-1.4-0.3-0.2-0.8-1.2-1-2.3-0.4-1.9-1.7-2.7-6.5-3.8-23.2-5.6-43.1-17.2-48.6-28.5-7.1-14.4 4.5-31.3 27.3-39.7 1.8-0.7 4.1-1.6 5.2-2 3.7-1.5 8-2.9 19.5-6.2 1.6-0.5 2.8-1.2 2.8-1.7 0-2.4 9.8-21.6 13.1-25.7 0.2-0.4 1.4-1.8 2.5-3.2 13.8-18.1 30.2-30.6 50.6-38.8 4.3-1.7 6-2.3 14.3-4.5 5.5-1.6 11.2-2.4 18.4-2.9 7.9-0.5 24-0.2 26.8 0.6zm-29.7 17.3c-0.2 0.1-7.3 1.7-12.9 2.7-1.7 0.4-4.3 1.2-5.8 1.9-1.5 0.6-3.9 1.5-5.5 2-1.5 0.4-3.3 1.3-4 2-0.7 0.7-1.7 1.2-2.3 1.2-1.2 0-9.5 4.5-9.8 5.3-0.2 0.3-0.5 0.6-0.9 0.6-1.9 0-19.6 16-23.8 21.6-9.3 12.2-16.1 27.4-19.2 42.7-2 10.1-1.1 37.5 1.4 41.4 0 0.1 3.7 0.9 8.1 1.8 9.5 1.9 12.8 2.4 34.6 4.9 38.5 4.5 107.9 2.2 138.3-4.5 1.4-0.3 4.1-0.9 6.1-1.3 4.2-0.8 3.4 0.2 4.9-7.1 1.6-8.3 1.7-27 0.1-34.6-1.5-7.1-3.2-13.4-3.7-14.2-0.3-0.4-0.7-1.5-0.9-2.6-2.8-12.1-19.2-34.1-33-44.3-2.9-2.1-5.5-4-5.8-4.3-2.8-2.2-4.9-3.1-7.2-3.1-2.1 0-2.6-0.2-2.7-1.3-0.2-1.5-5.7-4.5-6.3-3.5-0.7 1.1-2.4 0.6-2.7-0.7-0.4-1.3-1.2-1.6-5.8-2.1-1.6-0.2-4-0.9-5.5-1.6-3.9-1.8-5.3-2.2-10.2-2.6-4.6-0.4-25.2-0.7-25.5-0.3zm74.3 42.2c7.4 9.8 4.8 23.5-4.6 24.9-6.9 1-20.9-5.8-21-10.2 0-0.2-0.3-0.8-0.8-1.3-6.4-6.8-5-20.8 2.4-24.1 6.7-2.9 17.2 1.8 24 10.7zm-176.4 36.4c-0.1-0.1-4.6 1.1-5.9 1.6-0.7 0.3-3 1.2-5.1 2-9.9 3.8-15.1 6.8-19.6 11.5-3.4 3.5-3.3 4.5 0.5 8.7 1 1 11.3 7.6 12 7.6 0.2 0 1.7 0.6 3.4 1.3 1.6 0.8 3.6 1.6 4.3 1.9 1.8 0.8 9.3 3.3 9.9 3.3 0.3 0 0.3-2 0-4.4-0.6-5.6-0.6-24.5 0.1-29.6 0.3-2.1 0.5-3.9 0.4-3.9zm229.3-0.3c-0.2 0 0 1 0.2 2.1 0.6 2.8 0.6 31.3 0 34-0.5 2.2-0.4 2.2 1.3 1.8 3.1-0.7 12.9-4.5 18.3-7 8.5-4 14.3-10.1 12.6-13.3-1.1-2.1-6.7-7.2-7.9-7.2-0.4 0-0.9-0.2-1-0.5-0.4-1.1-11.8-6.1-19.2-8.5-2.3-0.7-4.2-1.4-4.3-1.4zm-199.4 63.4l-3.1-0.4 1.8 3.2c0.9 1.8 1.9 3.4 2.2 3.5 0.3 0.1 0.5 0.6 0.5 1.1 0 0.4 0.6 1.5 1.3 2.3 0.7 0.9 1.5 1.9 1.8 2.2 0.3 0.4 0.8 1.2 1.1 1.7 6.2 10.7 35.6 33.5 43.3 33.5 0.2 0 1.3 0.4 2.5 0.9 2.5 1.2 10.6 3.4 15.3 4.2 9.5 1.8 11.6 2.1 17.4 2.1 6.6 0 16.4-1.3 22.9-3 2.2-0.5 5.2-1.3 6.8-1.7 1.6-0.3 3.2-0.9 3.5-1.2 0.4-0.3 1.1-0.6 1.6-0.6 2.3 0 22-10.6 24-12.9 0.2-0.2 2.2-1.9 4.5-3.7 5.7-4.5 11.8-11 17.1-18.4 1.6-2.3 3.2-4.5 3.6-4.9 0.4-0.4 0.7-1 0.7-1.2 0-0.2 0.8-1.9 1.9-3.6 1.1-1.7 1.9-3.2 1.9-3.4 0-0.2-3.8 0.4-11 1.6-31.7 5.4-85.1 6.7-126.9 3.1-9.6-0.8-23.1-2.3-27.8-3.2-2.2-0.4-5.3-0.9-6.9-1.2z"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,28 +1,25 @@
|
|||
import { useState } from "preact/hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { HeaderRoute } from "../components/HeaderRoute";
|
||||
import { LoadSuspense } from "../LoadSuspense";
|
||||
import { set } from "../util/IDB";
|
||||
import { uninstallServiceWorkers } from "../util/SWHelper";
|
||||
import prod from "./config.json"; // Set prod to true if you wish to load balance
|
||||
import { enc } from "../aes";
|
||||
import CloakedHead from "../util/CloakedHead";
|
||||
import { useEffect } from "preact/hooks";
|
||||
import { updateServiceWorkers } from "../util/SWHelper.js";
|
||||
import { setTransport } from "../util/transports";
|
||||
import { registerServiceWorker } from "../util/SWHelper.js";
|
||||
|
||||
export function Home() {
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
const [showSuggestions, setShowSuggestions] = useState(false);
|
||||
const [inputValue, setInputValue] = useState("");
|
||||
const [suggestions, setSuggestions] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
useEffect(() => {
|
||||
const handleLoad = () => {
|
||||
const firstLoad = localStorage.getItem("firstLoad") || "true";
|
||||
console.log(firstLoad);
|
||||
//make sure service workers are updated
|
||||
//updateServiceWorkers();
|
||||
//make sure transport is set
|
||||
//setTransport();
|
||||
if (firstLoad == "true" && prod) {
|
||||
function changeBare(url: string) {
|
||||
set("bare", url);
|
||||
|
|
@ -89,9 +86,13 @@ export function Home() {
|
|||
setSuggestions(newSuggestions);
|
||||
};
|
||||
|
||||
const handleSubmit = (event) => {
|
||||
const handleSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
setTransport();
|
||||
setLoading(true);
|
||||
{
|
||||
loading && <LoadSuspense />;
|
||||
}
|
||||
await registerServiceWorker();
|
||||
window.location.href =
|
||||
"/go/" +
|
||||
encodeURIComponent(
|
||||
|
|
@ -103,24 +104,6 @@ export function Home() {
|
|||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const epoxyScript = document.createElement("script");
|
||||
epoxyScript.src = "/epoxy/index.js";
|
||||
|
||||
epoxyScript.onload = function () {
|
||||
console.log("lazy loaded epoxy");
|
||||
};
|
||||
|
||||
const libcurlScript = document.createElement("script");
|
||||
libcurlScript.src = "/libcurl/index.js";
|
||||
|
||||
libcurlScript.onload = function () {
|
||||
console.log("lazy loaded libcurl");
|
||||
};
|
||||
|
||||
document.body.appendChild(epoxyScript);
|
||||
document.body.appendChild(libcurlScript);
|
||||
}, []);
|
||||
return (
|
||||
<HeaderRoute>
|
||||
<CloakedHead
|
||||
|
|
@ -167,17 +150,24 @@ export function Home() {
|
|||
{showSuggestions &&
|
||||
suggestions.map((suggestion, index) => (
|
||||
<a
|
||||
onClick={() => {setTransport()}}
|
||||
href={
|
||||
"/go/" +
|
||||
encodeURIComponent(
|
||||
//@ts-ignore
|
||||
enc(
|
||||
suggestion,
|
||||
window.location.origin.slice(8) + navigator.userAgent
|
||||
).substring(10)
|
||||
)
|
||||
}
|
||||
onClick={async (event) => {
|
||||
event.preventDefault();
|
||||
setLoading(true);
|
||||
{
|
||||
loading && <LoadSuspense />;
|
||||
}
|
||||
await registerServiceWorker();
|
||||
window.location.href =
|
||||
"/go/" +
|
||||
encodeURIComponent(
|
||||
//@ts-ignore
|
||||
enc(
|
||||
suggestion,
|
||||
window.location.origin.slice(8) +
|
||||
navigator.userAgent
|
||||
).substring(10)
|
||||
);
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className={`font-roboto w-110 flex h-10 flex-none shrink-0 items-center justify-center border border-input-border-color bg-input p-2 text-xl text-input-text hover:bg-dropdown-option-hover-color ${
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { RammerheadEncode } from "../util/RammerheadEncode";
|
||||
import { setTransport } from "../util/transports";
|
||||
import { searchUtil } from "../util/searchUtil";
|
||||
import { LoadSuspense } from "../LoadSuspense";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
|
|
@ -78,8 +79,9 @@ export function ProxyFrame(props: { url: string }) {
|
|||
console.error("Error fetching data:", error);
|
||||
}
|
||||
};
|
||||
|
||||
fetchData();
|
||||
setTransport().then(() => {
|
||||
fetchData();
|
||||
});
|
||||
}, [localProxy, decodedUrl]);
|
||||
|
||||
if (proxyMode == "direct") {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ function BareInput(props: BareInputProps) {
|
|||
function validateUrl(url: string) {
|
||||
let finalUrl = url;
|
||||
if (url === "/bare/" || url === "/bare") {
|
||||
finalUrl = "/bare/";
|
||||
finalUrl = location.origin + "/bare/";
|
||||
return finalUrl;
|
||||
}
|
||||
if (url === null || url === undefined || url === "") {
|
||||
finalUrl = "/bare/";
|
||||
finalUrl = location.origin + "/bare/";
|
||||
return finalUrl;
|
||||
}
|
||||
if (!url.endsWith("/")) {
|
||||
|
|
@ -51,7 +51,7 @@ function BareInput(props: BareInputProps) {
|
|||
window.location.reload();
|
||||
} else {
|
||||
(document.getElementById("input") as HTMLInputElement).value =
|
||||
localStorage.getItem("bare") || "/bare/";
|
||||
localStorage.getItem("bare") || location.origin + "/bare/";
|
||||
toast(t("bareError"), {
|
||||
type: "error"
|
||||
});
|
||||
|
|
|
|||
|
|
@ -117,7 +117,10 @@ const Proxy = ({ id, active }) => {
|
|||
<div className="text-md p-4 font-bold text-input-text">
|
||||
{t("settings.bare.subtitle")}
|
||||
</div>
|
||||
<BareInput placeholder="/bare/" storageKey="bare" />
|
||||
<BareInput
|
||||
placeholder={location.origin + "/bare/"}
|
||||
storageKey="bare"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{transport !== "bare" && (
|
||||
|
|
|
|||
|
|
@ -7,24 +7,10 @@ import { Radon } from "./pages/Radon";
|
|||
import { Settings } from "./pages/Settings/";
|
||||
import { AboutBlank } from "./AboutBlank";
|
||||
import { Faq } from "./pages/Faq";
|
||||
// import { registerRemoteListener } from "@mercuryworkshop/bare-mux";
|
||||
import "./style.css";
|
||||
import "./i18n";
|
||||
|
||||
export default function Routes() {
|
||||
const wispUrl =
|
||||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/"; // @TODO Japan - US ping
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.ready.then(async () => {
|
||||
//await registerRemoteListener(sw.active!)
|
||||
console.log("SW ready")
|
||||
});
|
||||
navigator.serviceWorker.register("/sw.js", {
|
||||
scope: "/"
|
||||
});
|
||||
}
|
||||
return (
|
||||
<LocationProvider>
|
||||
<Router>
|
||||
|
|
|
|||
|
|
@ -1,33 +1,30 @@
|
|||
import { setTransport } from "./transports.ts";
|
||||
|
||||
function updateServiceWorkers() {
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.update();
|
||||
console.log("Service Worker Updated");
|
||||
}
|
||||
});
|
||||
async function updateServiceWorkers() {
|
||||
await navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.update();
|
||||
console.log("Service Worker Updated");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function uninstallServiceWorkers() {
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
console.log("Service Worker Unregistered");
|
||||
}
|
||||
});
|
||||
async function uninstallServiceWorkers() {
|
||||
await navigator.serviceWorker
|
||||
.getRegistrations()
|
||||
.then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
console.log("Service Worker Unregistered");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function registerServiceWorker() {
|
||||
async function registerServiceWorker() {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js", {
|
||||
scope: "/~/"
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Service worker registered successfully");
|
||||
setTransport();
|
||||
});
|
||||
await navigator.serviceWorker.register("/sw.js", {
|
||||
scope: "/~/"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
import {
|
||||
SetTransport,
|
||||
registerRemoteListener
|
||||
} from "@mercuryworkshop/bare-mux";
|
||||
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";
|
||||
//import { isIOS } from "./IosDetector";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
setTransport: () => void;
|
||||
connection: BareMuxConnection
|
||||
}
|
||||
}
|
||||
|
||||
function changeTransport(transport: string, wispUrl: string) {
|
||||
async function changeTransport(transport: string, wispUrl: string) {
|
||||
switch (transport) {
|
||||
case "epoxy":
|
||||
localStorage.setItem("transport", "epoxy");
|
||||
console.log("Setting transport to Epoxy");
|
||||
SetTransport("EpxMod.EpoxyClient", { wisp: wispUrl });
|
||||
await window.connection.setTransport("/epoxy/index.mjs", [{ wisp: wispUrl }]);
|
||||
break;
|
||||
case "libcurl":
|
||||
localStorage.setItem("transport", "libcurl");
|
||||
console.log("Setting transport to Libcurl");
|
||||
SetTransport("CurlMod.LibcurlClient", {
|
||||
wisp: wispUrl
|
||||
});
|
||||
await window.connection.setTransport("/libcurl/index.mjs", [
|
||||
{
|
||||
wisp: wispUrl
|
||||
}
|
||||
]);
|
||||
break;
|
||||
case "bare":
|
||||
localStorage.setItem("transport", "bare");
|
||||
|
|
@ -30,12 +30,14 @@ function changeTransport(transport: string, wispUrl: string) {
|
|||
const bare =
|
||||
localStorage.getItem("bare") || window.location.origin + "/bare/";
|
||||
console.log("Bare URL: " + bare);
|
||||
SetTransport("BareMod.BareClient", bare);
|
||||
await window.connection.setTransport("/baremod/index.mjs", [bare]);
|
||||
break;
|
||||
default:
|
||||
SetTransport("CurlMod.LibcurlClient", {
|
||||
wisp: wispUrl
|
||||
});
|
||||
await window.connection.setTransport("/libcurl/index.mjs", [
|
||||
{
|
||||
wisp: wispUrl
|
||||
}
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,29 +50,11 @@ const wispUrl =
|
|||
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||
location.host +
|
||||
"/wisp/";
|
||||
//registerRemoteListener(navigator.serviceWorker.controller!);
|
||||
|
||||
//if (isIOS) {
|
||||
// console.log("iOS device detected. Bare will be used.");
|
||||
// changeTransport(
|
||||
// localStorage.getItem("transport") || "libcurl",
|
||||
// localStorage.getItem("wispUrl") || wispUrl
|
||||
// );
|
||||
//} else {
|
||||
// changeTransport(
|
||||
// localStorage.getItem("transport") || "bare",
|
||||
// localStorage.getItem("wispUrl") || wispUrl
|
||||
// );
|
||||
//}
|
||||
|
||||
//changeTransport(
|
||||
// localStorage.getItem("transport") || "libcurl",
|
||||
// localStorage.getItem("wispUrl") || wispUrl
|
||||
//);
|
||||
window.connection = new BareMuxConnection("/baremux/worker.js");
|
||||
|
||||
// helper function for ../routes.tsx
|
||||
function setTransport() {
|
||||
changeTransport(
|
||||
async function setTransport() {
|
||||
await changeTransport(
|
||||
localStorage.getItem("transport") || "epoxy",
|
||||
localStorage.getItem("wispUrl") || wispUrl
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import { dynamicPath } from "@nebula-services/dynamic";
|
|||
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
|
||||
//@ts-ignore
|
||||
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
|
||||
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
|
||||
//@ts-ignore
|
||||
import { bareModulePath } from "@mercuryworkshop/bare-as-module3"
|
||||
import path from "path";
|
||||
import { createBareServer } from "@tomphttp/bare-server-node";
|
||||
import wisp from "wisp-server-node";
|
||||
|
|
@ -25,16 +28,27 @@ export default defineConfig({
|
|||
dest: "uv",
|
||||
overwrite: false
|
||||
},
|
||||
{
|
||||
src: `${baremuxPath}/**/*`.replace(/\\/g, "/"),
|
||||
dest: "baremux",
|
||||
overwrite: false
|
||||
},
|
||||
{
|
||||
src: `${epoxyPath}/**/*`.replace(/\\/g, "/"),
|
||||
dest: "epoxy",
|
||||
overwrite: false
|
||||
},
|
||||
|
||||
{
|
||||
src: `${libcurlPath}/**/*`.replace(/\\/g, "/"),
|
||||
dest: "libcurl",
|
||||
overwrite: false
|
||||
},
|
||||
{
|
||||
src: `${bareModulePath}/**/*`.replace(/\\/g, "/"),
|
||||
dest: "baremod",
|
||||
overwrite: false
|
||||
},
|
||||
{
|
||||
src: `${dynamicPath}/dynamic.*.js`.replace(/\\/g, "/"),
|
||||
dest: "dynamic",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue