Compare commits

...

33 commits

Author SHA1 Message Date
ThinLiquid
fa9876cb21
Update bootloader.ts 2024-03-30 12:01:33 +00:00
ThinLiquid
76d60330ea
Update bootloader.ts 2024-03-30 11:59:55 +00:00
ThinLiquid
6bc0694776
Update bootloader.ts 2024-03-30 11:55:05 +00:00
ThinLiquid
a80ba8d598
Update deploy.yml 2024-02-14 18:26:27 +00:00
ThinLiquid
c1bcfe6023
Update deploy.yml 2024-02-14 18:15:16 +00:00
ThinLiquid
c43f16c5a3
Update and rename main.yml to deploy.yml 2024-02-14 18:11:15 +00:00
ThinLiquid
65c7db6793
Rename deploy.yml to main.yml 2024-02-14 18:09:36 +00:00
ThinLiquid
c9cff82d2d
Create deploy.yml 2024-02-14 18:08:24 +00:00
ThinLiquid
2779bac5da
Merge pull request #187 from Flow-Works/revert-167-master
Revert "[] (#166) Gambling added"
2024-02-07 18:18:59 +00:00
ThinLiquid
b44034c114
Revert "[] (#166) Gambling added" 2024-02-07 18:18:47 +00:00
ThinLiquid
8ee0f166ae
Merge pull request #167 from cloudirector/master
[] (#166) Gambling added
2024-02-07 18:18:37 +00:00
cloudirector
cca0087220
Update package-lock.json i think idk 2024-02-07 09:17:55 -06:00
cloudirector
93559fc358
Update version from 1.0.0 💀 2024-02-07 09:10:42 -06:00
semantic-release-bot
f06db1db91 chore(release): 1.0.0 [skip ci]
# 1.0.0 (2024-02-07)

### Bug Fixes

* actually stopped boot overflowing ([4bd8f9b](4bd8f9b058))
* added missing error handling for `fs.exists` ([77c0d57](77c0d57770))
* another strange problem ([12cd47a](12cd47a4b6))
* fixed dropdown styling ([470a1fa](470a1fa1e0))
* fixed input border ([3a64f58](3a64f5801a))
* fixed Theme Maker title and created popup ([e630ae6](e630ae664c)), closes [#157](https://github.com/cloudirector/FlowOS/issues/157)
* FlowOS refusing to load thme ([1aad68f](1aad68f3f4))
* made `flowos-docs` build ([aff12d0](aff12d0ee1))
* made code follow ts-standard ([cf8f1b8](cf8f1b844a))
* made editor use theme colors ([0c2ffbb](0c2ffbbb9f))
* made UAC follow ts-standard ([3ca1e24](3ca1e247b4))
* make tests pass again ([0cf9209](0cf920970f))
* remove duplicate 'overflow' property ([d9ab009](d9ab009afd))
* stop boot div from overflowing ([a08b8d9](a08b8d938f))
* stopped filesystem from breaking at build ([54a92c5](54a92c5d79))
* theme not setting ([568e2f3](568e2f3100))
* upgrade material-symbols from 0.14.1 to 0.14.3 ([3e8fe0b](3e8fe0b024))
* upgrade prism-code-editor from 2.0.1 to 2.1.0 ([026a08b](026a08bd43))
* upgrade prism-code-editor from 2.1.0 to 2.2.0 ([3955b28](3955b2869b))
* upgrade prism-code-editor from 2.2.0 to 2.2.1 ([b3101c8](b3101c8b53))
* upgrade prism-code-editor from 2.2.1 to 2.2.2 ([c00a0f3](c00a0f3f58))
* upgrade prism-code-editor from 2.2.2 to 2.2.4 ([41421d4](41421d4931))
* upgrade prism-code-editor from 2.2.4 to 2.3.0 ([862743e](862743e01a))
* weird error stopping build ([2e208c9](2e208c91e1))

### Features

* add progress indicator to boot sequence ([48294da](48294da1ea))
* added `prependMany` function ([acdba11](acdba11691))
* added a `prepend` function ([f106776](f106776bee))
* added a button component ([8d3b629](8d3b629185))
* added support for new `/apps/list` endpoint ([423dd46](423dd46da0))
* added support for theming ([11540b9](11540b945a)), closes [#155](https://github.com/cloudirector/FlowOS/issues/155)
* added theme maker application ([4e4615e](4e4615ecb1))
* created an actual kernel and bootloader ([04ccdf1](04ccdf1442)), closes [#151](https://github.com/cloudirector/FlowOS/issues/151)
* created start menu ([aa5fb9e](aa5fb9e290)), closes [#183](https://github.com/cloudirector/FlowOS/issues/183)
* made editor use MIME types ([cc3583b](cc3583bfdc))
* made reset filesystem reload [skip ci] ([f207101](f207101c6a))
* make reset filesystem button look better [skip ci] ([10c0dbe](10c0dbe48a))
* minor styling changes ([2dd5b5f](2dd5b5f887))
* overrall ui overhaul ([934d6e8](934d6e80a0))
* use UV version 1.0.11 ([ad38f19](ad38f19f29))

### BREAKING CHANGES

* `process.kernel.loadLibrary('lib/VirtualFS')` replaced by `process.fs`
2024-02-07 14:50:42 +00:00
cloudirector
abbb05f02d death 2024-02-07 14:25:47 +00:00
cloudirector
a1df530743 fix bad code 2024-02-07 14:19:50 +00:00
cloudirector
031f11c456
Merge branch 'master' into master 2024-02-07 07:50:41 -06:00
ThinLiquid
f675f7d8cc
chore: added privacy policy [skip ci] 2024-02-02 04:27:19 +00:00
ThinLiquid
6ccfab84ac
chore: test out ads [skip ci] 2024-02-02 04:26:30 +00:00
semantic-release-bot
ae6866118b chore(release): 2.4.0 [skip ci]
# [2.4.0](https://github.com/Flow-Works/FlowOS/compare/v2.3.0...v2.4.0) (2024-02-02)

### Bug Fixes

* fixed dropdown styling ([470a1fa](470a1fa1e0))
* fixed input border ([3a64f58](3a64f5801a))

### Features

* created start menu ([aa5fb9e](aa5fb9e290)), closes [#183](https://github.com/Flow-Works/FlowOS/issues/183)
2024-02-02 04:04:23 +00:00
ThinLiquid
46f56682f1
Merge pull request #185 from Flow-Works/dev
[🪢] Merge `dev` into `master`
2024-02-02 04:03:51 +00:00
ThinLiquid
5c8eafce99
Merge pull request #184 from Flow-Works/feat/create-a-windows-style-start-menu
Feat/create-a-windows-style-start-menu
2024-02-02 04:03:12 +00:00
ThinLiquid
aa5fb9e290
feat: created start menu
re #183
2024-02-02 04:02:09 +00:00
ThinLiquid
470a1fa1e0
fix: fixed dropdown styling 2024-02-02 03:34:18 +00:00
ThinLiquid
3a64f5801a
fix: fixed input border 2024-02-02 02:35:04 +00:00
ThinLiquid
bc3d82fd56
chore: add google adsense [skip ci] 2024-02-02 02:02:31 +00:00
ThinLiquid
d561cce786
chore: add gtag [skip ci] 2024-02-02 01:57:27 +00:00
cloudirector
3e92a445ec
Merge branch 'master' into master 2024-01-30 09:39:53 -06:00
semantic-release-bot
d84c1c4232 chore(release): 2.3.0 [skip ci]
# [2.3.0](https://github.com/Flow-Works/FlowOS/compare/v2.2.0...v2.3.0) (2024-01-29)

### Features

* use UV version 1.0.11 ([ad38f19](ad38f19f29))
2024-01-29 09:56:00 +00:00
ThinLiquid
608a2733f9
Merge pull request #172 from Flow-Works/dev
[🪢] Merge `dev` into `master`
2024-01-29 09:55:25 +00:00
ThinLiquid
c4018528a8
Merge pull request #171 from Flow-Works/feat/switch-uv-to-version-1011
[] (#168) use UV version 1.0.11
2024-01-29 09:54:40 +00:00
ThinLiquid
ad38f19f29
feat: use UV version 1.0.11 2024-01-29 09:53:13 +00:00
cloudirector
011142dc1a gam·ble : /ˈɡambəl/ : verb
gerund or present participle: gambling

1. play games of chance for money; bet.
"she was fond of gambling on cards and horses"

Similar: bet, wager

place a bet : lay a bet : stake money on something : back the horses : try one's luck on the horses : play the ponies : punt : chance one's arm : have a flutter : game
2. take risky action in the hope of a desired result.
"the British could only gamble that something would turn up"
2024-01-28 00:48:42 -06:00
25 changed files with 43826 additions and 41420 deletions

49
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,49 @@
name: Deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Build project
run: npx vite build --base="/FlowOS/"
- name: Upload production-ready build files
uses: actions/upload-artifact@v3
with:
name: production-files
path: ./dist
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: production-files
path: ./dist
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist

View file

@ -5,6 +5,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FlowOS</title>
<link rel="shortcut icon" href="./src/assets/flow.png" type="image/png">
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9675905177363247" crossorigin="anonymous"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-X4XVQRWEVM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-X4XVQRWEVM');
</script>
</head>
<body>
<script src="./src/bootloader.ts" type="module"></script>

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "flowos",
"version": "2.2.0",
"version": "2.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "flowos",
"version": "2.2.0",
"version": "2.4.0",
"license": "MIT",
"dependencies": {
"ansi-to-html": "^0.7.2",

View file

@ -1,6 +1,6 @@
{
"name": "flowos",
"version": "2.2.0",
"version": "2.4.0",
"description": "The most aesthetic webOS.",
"main": "src/bootloader.ts",
"scripts": {

56
public/privacy.html Normal file
View file

@ -0,0 +1,56 @@
<h1>Privacy Policy for Flow Works</h1>
<p>At FlowOS, accessible from https://flow-works.me, one of our main priorities is the privacy of our visitors. This Privacy Policy document contains types of information that is collected and recorded by FlowOS and how we use it.</p>
<p>If you have additional questions or require more information about our Privacy Policy, do not hesitate to contact us.</p>
<h2>Log Files</h2>
<p>FlowOS follows a standard procedure of using log files. These files log visitors when they visit websites. All hosting companies do this and a part of hosting services' analytics. The information collected by log files include internet protocol (IP) addresses, browser type, Internet Service Provider (ISP), date and time stamp, referring/exit pages, and possibly the number of clicks. These are not linked to any information that is personally identifiable. The purpose of the information is for analyzing trends, administering the site, tracking users' movement on the website, and gathering demographic information.</p>
<h2>Cookies and Web Beacons</h2>
<p>Like any other website, FlowOS uses "cookies". These cookies are used to store information including visitors' preferences, and the pages on the website that the visitor accessed or visited. The information is used to optimize the users' experience by customizing our web page content based on visitors' browser type and/or other information.</p>
<h2>Google DoubleClick DART Cookie</h2>
<p>Google is one of a third-party vendor on our site. It also uses cookies, known as DART cookies, to serve ads to our site visitors based upon their visit to www.website.com and other sites on the internet. However, visitors may choose to decline the use of DART cookies by visiting the Google ad and content network Privacy Policy at the following URL <a href="https://policies.google.com/technologies/ads">https://policies.google.com/technologies/ads</a></p>
<h2>Our Advertising Partners</h2>
<p>Some of advertisers on our site may use cookies and web beacons. Our advertising partners are listed below. Each of our advertising partners has their own Privacy Policy for their policies on user data. For easier access, we hyperlinked to their Privacy Policies below.</p>
<ul>
<li>
<p>Google</p>
<p><a href="https://policies.google.com/technologies/ads">https://policies.google.com/technologies/ads</a></p>
</li>
</ul>
<h2>Privacy Policies</h2>
<P>You may consult this list to find the Privacy Policy for each of the advertising partners of FlowOS.</p>
<p>Third-party ad servers or ad networks uses technologies like cookies, JavaScript, or Web Beacons that are used in their respective advertisements and links that appear on FlowOS, which are sent directly to users' browser. They automatically receive your IP address when this occurs. These technologies are used to measure the effectiveness of their advertising campaigns and/or to personalize the advertising content that you see on websites that you visit.</p>
<p>Note that FlowOS has no access to or control over these cookies that are used by third-party advertisers.</p>
<h2>Third Party Privacy Policies</h2>
<p>FlowOS's Privacy Policy does not apply to other advertisers or websites. Thus, we are advising you to consult the respective Privacy Policies of these third-party ad servers for more detailed information. It may include their practices and instructions about how to opt-out of certain options. </p>
<p>You can choose to disable cookies through your individual browser options. To know more detailed information about cookie management with specific web browsers, it can be found at the browsers' respective websites.</p>
<h2>Children's Information</h2>
<p>Another part of our priority is adding protection for children while using the internet. We encourage parents and guardians to observe, participate in, and/or monitor and guide their online activity.</p>
<p>FlowOS does not knowingly collect any Personal Identifiable Information from children under the age of 13. If you think that your child provided this kind of information on our website, we strongly encourage you to contact us immediately and we will do our best efforts to promptly remove such information from our records.</p>
<h2>Online Privacy Policy Only</h2>
<p>This Privacy Policy applies only to our online activities and is valid for visitors to our website with regards to the information that they shared and/or collect in FlowOS. This policy is not applicable to any information collected offline or via channels other than this website.</p>
<h2>Consent</h2>
<p>By using our website, you hereby consent to our Privacy Policy and agree to its Terms and Conditions.</p>

View file

@ -1,9 +1,21 @@
// @ts-nocheck
/*global UVServiceWorker,__uv$config*/
/*
* Stock service worker script.
* Users can provide their own sw.js if they need to extend the functionality of the service worker.
* Ideally, this will be registered under the scope in uv.config.js so it will not need to be modified.
* However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally.
*/
importScripts('/uv/uv.sw.js');
importScripts(`uv.config.js`);
const params = new URL(self.location.href).searchParams
const serverURL = atob(params.get('url'));
const sw = new UVServiceWorker(serverURL);
self.__uv$config.bare = `${serverURL}/bare/`
self.addEventListener('fetch', event => event.respondWith(sw.fetch(event)));
importScripts('uv.bundle.js');
importScripts(__uv$config.sw || 'uv.sw.js');
const sw = new UVServiceWorker();
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));

39014
public/uv.bundle.js Normal file

File diff suppressed because one or more lines are too long

7
public/uv.bundle.js.map Normal file

File diff suppressed because one or more lines are too long

2939
public/uv.client.js Normal file

File diff suppressed because it is too large Load diff

7
public/uv.client.js.map Normal file

File diff suppressed because one or more lines are too long

40
public/uv.config.js Normal file
View file

@ -0,0 +1,40 @@
/*global Ultraviolet*/
const xor = {
encode: (str) => encodeURIComponent(
str
.toString()
.split('')
.map((char, ind) => {
const indCheck = ind % 2 === 0 ? false : true
return indCheck ? String.fromCharCode(char.charCodeAt(0) ^ 2) : char
})
.join('')
),
decode: (str) => {
const [input, ...search] = str.split('?')
return (
decodeURIComponent(input)
.split('')
.map((char, ind) => {
const indCheck = ind % 2 === 0 ? false : true
return indCheck ? String.fromCharCode(char.charCodeAt(0) ^ 2) : char
})
.join('') + ((search.length > 0) ? `?${search.join('?')}` : '')
)
}
}
self.__uv$config = {
prefix: '/service/',
encodeUrl: xor.encode,
decodeUrl: xor.decode,
handler: '/uv.handler.js',
client: '/uv.client.js',
bundle: '/uv.bundle.js',
config: '/uv.config.js',
sw: '/uv.sw.js',
};

1218
public/uv.handler.js Normal file

File diff suppressed because it is too large Load diff

7
public/uv.handler.js.map Normal file

File diff suppressed because one or more lines are too long

368
public/uv.sw.js Normal file
View file

@ -0,0 +1,368 @@
(() => {
// src/uv.sw.js
var Ultraviolet = self.Ultraviolet;
var cspHeaders = [
"cross-origin-embedder-policy",
"cross-origin-opener-policy",
"cross-origin-resource-policy",
"content-security-policy",
"content-security-policy-report-only",
"expect-ct",
"feature-policy",
"origin-isolation",
"strict-transport-security",
"upgrade-insecure-requests",
"x-content-type-options",
"x-download-options",
"x-frame-options",
"x-permitted-cross-domain-policies",
"x-powered-by",
"x-xss-protection"
];
var emptyMethods = ["GET", "HEAD"];
var UVServiceWorker = class extends Ultraviolet.EventEmitter {
constructor(config = __uv$config) {
super();
if (!config.bare)
config.bare = "/bare/";
if (!config.prefix)
config.prefix = "/service/";
this.config = config;
const addresses = (Array.isArray(config.bare) ? config.bare : [config.bare]).map((str) => new URL(str, location).toString());
this.address = addresses[~~(Math.random() * addresses.length)];
this.bareClient = new Ultraviolet.BareClient(this.address);
}
/**
*
* @param {Event & {request: Request}} param0
* @returns
*/
async fetch({ request }) {
let fetchedURL;
try {
if (!request.url.startsWith(location.origin + this.config.prefix))
return await fetch(request);
const ultraviolet = new Ultraviolet(this.config, this.address);
if (typeof this.config.construct === "function") {
this.config.construct(ultraviolet, "service");
}
const db = await ultraviolet.cookie.db();
ultraviolet.meta.origin = location.origin;
ultraviolet.meta.base = ultraviolet.meta.url = new URL(
ultraviolet.sourceUrl(request.url)
);
const requestCtx = new RequestContext(
request,
this,
ultraviolet,
!emptyMethods.includes(request.method.toUpperCase()) ? await request.blob() : null
);
if (ultraviolet.meta.url.protocol === "blob:") {
requestCtx.blob = true;
requestCtx.base = requestCtx.url = new URL(
requestCtx.url.pathname
);
}
if (request.referrer && request.referrer.startsWith(location.origin)) {
const referer = new URL(
ultraviolet.sourceUrl(request.referrer)
);
if (requestCtx.headers.origin || ultraviolet.meta.url.origin !== referer.origin && request.mode === "cors") {
requestCtx.headers.origin = referer.origin;
}
requestCtx.headers.referer = referer.href;
}
const cookies = await ultraviolet.cookie.getCookies(db) || [];
const cookieStr = ultraviolet.cookie.serialize(
cookies,
ultraviolet.meta,
false
);
requestCtx.headers["user-agent"] = navigator.userAgent;
if (cookieStr)
requestCtx.headers.cookie = cookieStr;
const reqEvent = new HookEvent(requestCtx, null, null);
this.emit("request", reqEvent);
if (reqEvent.intercepted)
return reqEvent.returnValue;
fetchedURL = requestCtx.blob ? "blob:" + location.origin + requestCtx.url.pathname : requestCtx.url;
const response = await this.bareClient.fetch(fetchedURL, {
headers: requestCtx.headers,
method: requestCtx.method,
body: requestCtx.body,
credentials: requestCtx.credentials,
mode: location.origin !== requestCtx.address.origin ? "cors" : requestCtx.mode,
cache: requestCtx.cache,
redirect: requestCtx.redirect
});
const responseCtx = new ResponseContext(requestCtx, response);
const resEvent = new HookEvent(responseCtx, null, null);
this.emit("beforemod", resEvent);
if (resEvent.intercepted)
return resEvent.returnValue;
for (const name of cspHeaders) {
if (responseCtx.headers[name])
delete responseCtx.headers[name];
}
if (responseCtx.headers.location) {
responseCtx.headers.location = ultraviolet.rewriteUrl(
responseCtx.headers.location
);
}
if (request.destination === "document") {
const header = responseCtx.headers["content-disposition"];
if (!/\s*?((inline|attachment);\s*?)filename=/i.test(header)) {
const type = /^\s*?attachment/i.test(header) ? "attachment" : "inline";
const [filename] = new URL(response.finalURL).pathname.split("/").slice(-1);
responseCtx.headers["content-disposition"] = `${type}; filename=${JSON.stringify(filename)}`;
}
}
if (responseCtx.headers["set-cookie"]) {
Promise.resolve(
ultraviolet.cookie.setCookies(
responseCtx.headers["set-cookie"],
db,
ultraviolet.meta
)
).then(() => {
self.clients.matchAll().then(function(clients) {
clients.forEach(function(client) {
client.postMessage({
msg: "updateCookies",
url: ultraviolet.meta.url.href
});
});
});
});
delete responseCtx.headers["set-cookie"];
}
if (responseCtx.body) {
switch (request.destination) {
case "script":
case "worker":
{
const scripts = [
ultraviolet.bundleScript,
ultraviolet.clientScript,
ultraviolet.configScript,
ultraviolet.handlerScript
].map((script) => JSON.stringify(script)).join(",");
responseCtx.body = `if (!self.__uv && self.importScripts) { ${ultraviolet.createJsInject(
this.address,
this.bareClient.manifest,
ultraviolet.cookie.serialize(
cookies,
ultraviolet.meta,
true
),
request.referrer
)} importScripts(${scripts}); }
`;
responseCtx.body += ultraviolet.js.rewrite(
await response.text()
);
}
break;
case "style":
responseCtx.body = ultraviolet.rewriteCSS(
await response.text()
);
break;
case "iframe":
case "document":
if (isHtml(
ultraviolet.meta.url,
responseCtx.headers["content-type"] || ""
)) {
responseCtx.body = ultraviolet.rewriteHtml(
await response.text(),
{
document: true,
injectHead: ultraviolet.createHtmlInject(
ultraviolet.handlerScript,
ultraviolet.bundleScript,
ultraviolet.clientScript,
ultraviolet.configScript,
this.address,
this.bareClient.manifest,
ultraviolet.cookie.serialize(
cookies,
ultraviolet.meta,
true
),
request.referrer
)
}
);
}
}
}
if (requestCtx.headers.accept === "text/event-stream") {
responseCtx.headers["content-type"] = "text/event-stream";
}
if (crossOriginIsolated) {
responseCtx.headers["Cross-Origin-Embedder-Policy"] = "require-corp";
}
this.emit("response", resEvent);
if (resEvent.intercepted)
return resEvent.returnValue;
return new Response(responseCtx.body, {
headers: responseCtx.headers,
status: responseCtx.status,
statusText: responseCtx.statusText
});
} catch (err) {
if (!["document", "iframe"].includes(request.destination))
return new Response(void 0, { status: 500 });
console.error(err);
return renderError(err, fetchedURL, this.address);
}
}
static Ultraviolet = Ultraviolet;
};
self.UVServiceWorker = UVServiceWorker;
var ResponseContext = class {
/**
*
* @param {RequestContext} request
* @param {import("@tomphttp/bare-client").BareResponseFetch} response
*/
constructor(request, response) {
this.request = request;
this.raw = response;
this.ultraviolet = request.ultraviolet;
this.headers = {};
for (const key in response.rawHeaders)
this.headers[key.toLowerCase()] = response.rawHeaders[key];
this.status = response.status;
this.statusText = response.statusText;
this.body = response.body;
}
get url() {
return this.request.url;
}
get base() {
return this.request.base;
}
set base(val) {
this.request.base = val;
}
};
var RequestContext = class {
/**
*
* @param {Request} request
* @param {UVServiceWorker} worker
* @param {Ultraviolet} ultraviolet
* @param {BodyInit} body
*/
constructor(request, worker, ultraviolet, body = null) {
this.ultraviolet = ultraviolet;
this.request = request;
this.headers = Object.fromEntries(request.headers.entries());
this.method = request.method;
this.address = worker.address;
this.body = body || null;
this.cache = request.cache;
this.redirect = request.redirect;
this.credentials = "omit";
this.mode = request.mode === "cors" ? request.mode : "same-origin";
this.blob = false;
}
get url() {
return this.ultraviolet.meta.url;
}
set url(val) {
this.ultraviolet.meta.url = val;
}
get base() {
return this.ultraviolet.meta.base;
}
set base(val) {
this.ultraviolet.meta.base = val;
}
};
function isHtml(url, contentType = "") {
return (Ultraviolet.mime.contentType(contentType || url.pathname) || "text/html").split(";")[0] === "text/html";
}
var HookEvent = class {
#intercepted;
#returnValue;
constructor(data = {}, target = null, that = null) {
this.#intercepted = false;
this.#returnValue = null;
this.data = data;
this.target = target;
this.that = that;
}
get intercepted() {
return this.#intercepted;
}
get returnValue() {
return this.#returnValue;
}
respondWith(input) {
this.#returnValue = input;
this.#intercepted = true;
}
};
function hostnameErrorTemplate(fetchedURL, bareServer) {
const parsedFetchedURL = new URL(fetchedURL);
const script = `remoteHostname.textContent = ${JSON.stringify(
parsedFetchedURL.hostname
)};bareServer.href = ${JSON.stringify(bareServer)};uvHostname.textContent = ${JSON.stringify(location.hostname)};reload.addEventListener("click", () => location.reload());uvVersion.textContent = ${JSON.stringify(
"2.0.0"
)};`;
return `<!DOCTYPE html><html><head><meta charset='utf-8' /><title>Error</title></head><body><h1>This site can\u2019t be reached</h1><hr /><p><b id="remoteHostname"></b>\u2019s server IP address could not be found.</p><p>Try:</p><ul><li>Verifying you entered the correct address</li><li>Clearing the site data</li><li>Contacting <b id="uvHostname"></b>'s administrator</li><li>Verifying the <a id='bareServer' title='Bare server'>${config.bare}</a> isn't censored</li></ul><button id="reload">Reload</button><hr /><p><i>Ultraviolet v<span id="uvVersion"></span></i></p><script src="${"data:application/javascript," + encodeURIComponent(script)}"><\/script></body></html>`;
}
function errorTemplate(title, code, id, message, trace, fetchedURL, bareServer) {
if (message === "The specified host could not be resolved.")
return hostnameErrorTemplate(fetchedURL, bareServer);
const script = `errorTitle.textContent = ${JSON.stringify(title)};errorCode.textContent = ${JSON.stringify(code)};` + (id ? `errorId.textContent = ${JSON.stringify(id)};` : "") + `errorMessage.textContent = ${JSON.stringify(message)};errorTrace.value = ${JSON.stringify(trace)};fetchedURL.textContent = ${JSON.stringify(fetchedURL)};bareServer.href = ${JSON.stringify(bareServer)};for (const node of document.querySelectorAll("#uvHostname")) node.textContent = ${JSON.stringify(
location.hostname
)};reload.addEventListener("click", () => location.reload());uvVersion.textContent = ${JSON.stringify(
"2.0.0"
)};`;
return `<!DOCTYPE html><html><head><meta charset='utf-8' /><title>Error</title></head><body><h1 id='errorTitle'></h1><hr /><p>Failed to load <b id="fetchedURL"></b></p><p id="errorMessage"></p><table><tbody><tr><td>Code:</td><td id="errorCode"></td></tr>` + (id ? '<tr><td>ID:</td><td id="errorId"></td></tr>' : "") + `</tbody></table><textarea id="errorTrace" cols="40" rows="10" readonly></textarea><p>Try:</p><ul><li>Checking your internet connection</li><li>Verifying you entered the correct address</li><li>Clearing the site data</li><li>Contacting <b id="uvHostname"></b>'s administrator</li><li>Verify the <a id='bareServer' title='Bare server'>${config.bare}</a> isn't censored</li></ul><p>If you're the administrator of <b id="uvHostname"></b>, try:</p><ul><li>Restarting your Bare server</li><li>Updating Ultraviolet</li><li>Troubleshooting the error on the <a href="https://github.com/titaniumnetwork-dev/Ultraviolet" target="_blank">GitHub repository</a></li></ul><button id="reload">Reload</button><hr /><p><i>Ultraviolet v<span id="uvVersion"></span></i></p><script src="${"data:application/javascript," + encodeURIComponent(script)}"><\/script></body></html>`;
}
function isBareError(err) {
return err instanceof Error && typeof err.body === "object";
}
function renderError(err, fetchedURL, bareServer) {
let status;
let title;
let code;
let id = "";
let message;
if (isBareError(err)) {
status = err.status;
title = "Error communicating with the Bare server";
message = err.body.message;
code = err.body.code;
id = err.body.id;
} else {
status = 500;
title = "Error processing your request";
message = "Internal Server Error";
code = err instanceof Error ? err.name : "UNKNOWN";
}
return new Response(
errorTemplate(
title,
code,
id,
message,
String(err),
fetchedURL,
bareServer
),
{
status,
headers: {
"content-type": "text/html"
}
}
);
}
})();
//# sourceMappingURL=uv.sw.js.map

7
public/uv.sw.js.map Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,38 +0,0 @@
self.xor = {
randomMax: 100,
randomMin: -100,
encode: (str) => {
if (!str) return str
return encodeURIComponent(
str
.toString()
.split('')
.map((char, ind) =>
ind % 2 ? String.fromCharCode(char.charCodeAt() ^ 2) : char
)
.join('')
)
},
decode: (str) => {
if (!str) return str
const [input, ...search] = str.split('?')
return (
decodeURIComponent(input)
.split('')
.map((char, ind) =>
ind % 2 ? String.fromCharCode(char.charCodeAt(0) ^ 2) : char
)
.join('') + (search.length ? '?' + search.join('?') : '')
)
}
}
self.__uv$config = {
prefix: '/service/',
encodeUrl: self.xor.encode,
decodeUrl: self.xor.decode,
handler: '/uv/uv.handler.js',
bundle: '/uv/uv.bundle.js',
config: '/uv/uv.config.js',
}

File diff suppressed because it is too large Load diff

View file

@ -1,789 +0,0 @@
importScripts('/uv/uv.bundle.js');
importScripts('/uv/uv.config.js');
class UVServiceWorker extends EventEmitter {
constructor(serverURL, config = __uv$config) {
super();
config.bare = serverURL + '/bare/';
this.addresses = typeof config.bare === 'string' ? [ new URL(config.bare, location) ] : config.bare.map(str => new URL(str, location));
this.headers = {
csp: [
'cross-origin-embedder-policy',
'cross-origin-opener-policy',
'cross-origin-resource-policy',
'content-security-policy',
'content-security-policy-report-only',
'expect-ct',
'feature-policy',
'origin-isolation',
'strict-transport-security',
'upgrade-insecure-requests',
'x-content-type-options',
'x-download-options',
'x-frame-options',
'x-permitted-cross-domain-policies',
'x-powered-by',
'x-xss-protection',
],
forward: [
'accept-encoding',
'connection',
'content-length',
],
};
this.method = {
empty: [
'GET',
'HEAD'
]
};
this.statusCode = {
empty: [
204,
304,
],
};
this.config = config;
this.browser = Ultraviolet.Bowser.getParser(self.navigator.userAgent).getBrowserName();
if (this.browser === 'Firefox') {
this.headers.forward.push('user-agent');
this.headers.forward.push('content-type');
};
};
async fetch({ request }) {
if (!request.url.startsWith(location.origin + (this.config.prefix || '/service/'))) {
return fetch(request);
};
try {
const ultraviolet = new Ultraviolet(this.config);
if (typeof this.config.construct === 'function') {
this.config.construct(ultraviolet, 'service');
};
const db = await ultraviolet.cookie.db();
ultraviolet.meta.origin = location.origin;
ultraviolet.meta.base = ultraviolet.meta.url = new URL(ultraviolet.sourceUrl(request.url));
const requestCtx = new RequestContext(
request,
this,
ultraviolet,
!this.method.empty.includes(request.method.toUpperCase()) ? await request.blob() : null
);
if (ultraviolet.meta.url.protocol === 'blob:') {
requestCtx.blob = true;
requestCtx.base = requestCtx.url = new URL(requestCtx.url.pathname);
};
if (request.referrer && request.referrer.startsWith(location.origin)) {
const referer = new URL(ultraviolet.sourceUrl(request.referrer));
if (requestCtx.headers.origin || ultraviolet.meta.url.origin !== referer.origin && request.mode === 'cors') {
requestCtx.headers.origin = referer.origin;
};
requestCtx.headers.referer = referer.href;
};
const cookies = await ultraviolet.cookie.getCookies(db) || [];
const cookieStr = ultraviolet.cookie.serialize(cookies, ultraviolet.meta, false);
if (this.browser === 'Firefox' && !(request.destination === 'iframe' || request.destination === 'document')) {
requestCtx.forward.shift();
};
if (cookieStr) requestCtx.headers.cookie = cookieStr;
requestCtx.headers.Host = requestCtx.url.host;
const reqEvent = new HookEvent(requestCtx, null, null);
this.emit('request', reqEvent);
if (reqEvent.intercepted) return reqEvent.returnValue;
const response = await fetch(requestCtx.send);
if (response.status === 500) {
return Promise.reject('');
};
const responseCtx = new ResponseContext(requestCtx, response, this);
const resEvent = new HookEvent(responseCtx, null, null);
this.emit('beforemod', resEvent);
if (resEvent.intercepted) return resEvent.returnValue;
for (const name of this.headers.csp) {
if (responseCtx.headers[name]) delete responseCtx.headers[name];
};
if (responseCtx.headers.location) {
responseCtx.headers.location = ultraviolet.rewriteUrl(responseCtx.headers.location);
};
if (responseCtx.headers['set-cookie']) {
Promise.resolve(ultraviolet.cookie.setCookies(responseCtx.headers['set-cookie'], db, ultraviolet.meta)).then(() => {
self.clients.matchAll().then(function (clients){
clients.forEach(function(client){
client.postMessage({
msg: 'updateCookies',
url: ultraviolet.meta.url.href,
});
});
});
});
delete responseCtx.headers['set-cookie'];
};
if (responseCtx.body) {
switch(request.destination) {
case 'script':
case 'worker':
responseCtx.body = `if (!self.__uv && self.importScripts) importScripts('${__uv$config.bundle}', '${__uv$config.config}', '${__uv$config.handler}');\n`;
responseCtx.body += ultraviolet.js.rewrite(
await response.text()
);
break;
case 'style':
responseCtx.body = ultraviolet.rewriteCSS(
await response.text()
);
break;
case 'iframe':
case 'document':
if (isHtml(ultraviolet.meta.url, (responseCtx.headers['content-type'] || ''))) {
responseCtx.body = ultraviolet.rewriteHtml(
await response.text(),
{
document: true ,
injectHead: ultraviolet.createHtmlInject(
this.config.handler,
this.config.bundle,
this.config.config,
ultraviolet.cookie.serialize(cookies, ultraviolet.meta, true),
request.referrer
)
}
);
};
};
};
if (requestCtx.headers.accept === 'text/event-stream') {
responseCtx.headers['content-type'] = 'text/event-stream';
};
this.emit('response', resEvent);
if (resEvent.intercepted) return resEvent.returnValue;
return new Response(responseCtx.body, {
headers: responseCtx.headers,
status: responseCtx.status,
statusText: responseCtx.statusText,
});
} catch(err) {
return new Response(err.toString(), {
status: 500,
});
};
};
getBarerResponse(response) {
const headers = {};
const raw = JSON.parse(response.headers.get('x-bare-headers'));
for (const key in raw) {
headers[key.toLowerCase()] = raw[key];
};
return {
headers,
status: +response.headers.get('x-bare-status'),
statusText: response.headers.get('x-bare-status-text'),
body: !this.statusCode.empty.includes(+response.headers.get('x-bare-status')) ? response.body : null,
};
};
get address() {
return this.addresses[Math.floor(Math.random() * this.addresses.length)];
};
static Ultraviolet = Ultraviolet;
};
self.UVServiceWorker = UVServiceWorker;
class ResponseContext {
constructor(request, response, worker) {
const { headers, status, statusText, body } = !request.blob ? worker.getBarerResponse(response) : {
status: response.status,
statusText: response.statusText,
headers: Object.fromEntries([...response.headers.entries()]),
body: response.body,
};
this.request = request;
this.raw = response;
this.ultraviolet = request.ultraviolet;
this.headers = headers;
this.status = status;
this.statusText = statusText;
this.body = body;
};
get url() {
return this.request.url;
}
get base() {
return this.request.base;
};
set base(val) {
this.request.base = val;
};
};
class RequestContext {
constructor(request, worker, ultraviolet, body = null) {
this.ultraviolet = ultraviolet;
this.request = request;
this.headers = Object.fromEntries([...request.headers.entries()]);
this.method = request.method;
this.forward = [...worker.headers.forward];
this.address = worker.address;
this.body = body || null;
this.redirect = request.redirect;
this.credentials = 'omit';
this.mode = request.mode === 'cors' ? request.mode : 'same-origin';
this.blob = false;
};
get send() {
return new Request((!this.blob ? this.address.href + 'v1/' : 'blob:' + location.origin + this.url.pathname), {
method: this.method,
headers: {
'x-bare-protocol': this.url.protocol,
'x-bare-host': this.url.hostname,
'x-bare-path': this.url.pathname + this.url.search,
'x-bare-port': this.url.port || (this.url.protocol === 'https:' ? '443' : '80'),
'x-bare-headers': JSON.stringify(this.headers),
'x-bare-forward-headers': JSON.stringify(this.forward),
},
redirect: this.redirect,
credentials: this.credentials,
mode: location.origin !== this.address.origin ? 'cors' : this.mode,
body: this.body
});
};
get url() {
return this.ultraviolet.meta.url;
};
set url(val) {
this.ultraviolet.meta.url = val;
};
get base() {
return this.ultraviolet.meta.base;
};
set base(val) {
this.ultraviolet.meta.base = val;
};
}
function isHtml(url, contentType = '') {
return (Ultraviolet.mime.contentType((contentType || url.pathname)) || 'text/html').split(';')[0] === 'text/html';
};
class HookEvent {
#intercepted;
#returnValue;
constructor(data = {}, target = null, that = null) {
this.#intercepted = false;
this.#returnValue = null;
this.data = data;
this.target = target;
this.that = that;
};
get intercepted() {
return this.#intercepted;
};
get returnValue() {
return this.#returnValue;
};
respondWith(input) {
this.#returnValue = input;
this.#intercepted = true;
};
};
var R = typeof Reflect === 'object' ? Reflect : null
var ReflectApply = R && typeof R.apply === 'function'
? R.apply
: function ReflectApply(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
}
var ReflectOwnKeys
if (R && typeof R.ownKeys === 'function') {
ReflectOwnKeys = R.ownKeys
} else if (Object.getOwnPropertySymbols) {
ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target)
.concat(Object.getOwnPropertySymbols(target));
};
} else {
ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target);
};
}
function ProcessEmitWarning(warning) {
if (console && console.warn) console.warn(warning);
}
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
return value !== value;
}
function EventEmitter() {
EventEmitter.init.call(this);
}
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== 'function') {
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
}
}
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
enumerable: true,
get: function() {
return defaultMaxListeners;
},
set: function(arg) {
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
}
defaultMaxListeners = arg;
}
});
EventEmitter.init = function() {
if (this._events === undefined ||
this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
this._maxListeners = this._maxListeners || undefined;
};
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
}
this._maxListeners = n;
return this;
};
function _getMaxListeners(that) {
if (that._maxListeners === undefined)
return EventEmitter.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
return _getMaxListeners(this);
};
EventEmitter.prototype.emit = function emit(type) {
var args = [];
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
var doError = (type === 'error');
var events = this._events;
if (events !== undefined)
doError = (doError && events.error === undefined);
else if (!doError)
return false;
// If there is no 'error' event listener then throw.
if (doError) {
var er;
if (args.length > 0)
er = args[0];
if (er instanceof Error) {
// Note: The comments on the `throw` lines are intentional, they show
// up in Node's output if this results in an unhandled exception.
throw er; // Unhandled 'error' event
}
// At least give some kind of context to the user
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
err.context = er;
throw err; // Unhandled 'error' event
}
var handler = events[type];
if (handler === undefined)
return false;
if (typeof handler === 'function') {
ReflectApply(handler, this, args);
} else {
var len = handler.length;
var listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i)
ReflectApply(listeners[i], this, args);
}
return true;
};
function _addListener(target, type, listener, prepend) {
var m;
var events;
var existing;
checkListener(listener);
events = target._events;
if (events === undefined) {
events = target._events = Object.create(null);
target._eventsCount = 0;
} else {
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (events.newListener !== undefined) {
target.emit('newListener', type,
listener.listener ? listener.listener : listener);
// Re-assign `events` because a newListener handler could have caused the
// this._events to be assigned to a new object
events = target._events;
}
existing = events[type];
}
if (existing === undefined) {
// Optimize the case of one listener. Don't need the extra array object.
existing = events[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === 'function') {
// Adding the second element, need to change to array.
existing = events[type] =
prepend ? [listener, existing] : [existing, listener];
// If we've already got an array, just append.
} else if (prepend) {
existing.unshift(listener);
} else {
existing.push(listener);
}
// Check for listener leak
m = _getMaxListeners(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
// No error code for this since it is a Warning
// eslint-disable-next-line no-restricted-syntax
var w = new Error('Possible EventEmitter memory leak detected. ' +
existing.length + ' ' + String(type) + ' listeners ' +
'added. Use emitter.setMaxListeners() to ' +
'increase limit');
w.name = 'MaxListenersExceededWarning';
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning(w);
}
}
return target;
}
EventEmitter.prototype.addListener = function addListener(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.prependListener =
function prependListener(type, listener) {
return _addListener(this, type, listener, true);
};
function onceWrapper() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0)
return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
}
}
function _onceWrap(target, type, listener) {
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter.prototype.once = function once(type, listener) {
checkListener(listener);
this.on(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.prependOnceListener =
function prependOnceListener(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
// Emits a 'removeListener' event if and only if the listener was removed.
EventEmitter.prototype.removeListener =
function removeListener(type, listener) {
var list, events, position, i, originalListener;
checkListener(listener);
events = this._events;
if (events === undefined)
return this;
list = events[type];
if (list === undefined)
return this;
if (list === listener || list.listener === listener) {
if (--this._eventsCount === 0)
this._events = Object.create(null);
else {
delete events[type];
if (events.removeListener)
this.emit('removeListener', type, list.listener || listener);
}
} else if (typeof list !== 'function') {
position = -1;
for (i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
}
if (position < 0)
return this;
if (position === 0)
list.shift();
else {
spliceOne(list, position);
}
if (list.length === 1)
events[type] = list[0];
if (events.removeListener !== undefined)
this.emit('removeListener', type, originalListener || listener);
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners =
function removeAllListeners(type) {
var listeners, events, i;
events = this._events;
if (events === undefined)
return this;
// not listening for removeListener, no need to emit
if (events.removeListener === undefined) {
if (arguments.length === 0) {
this._events = Object.create(null);
this._eventsCount = 0;
} else if (events[type] !== undefined) {
if (--this._eventsCount === 0)
this._events = Object.create(null);
else
delete events[type];
}
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
var keys = Object.keys(events);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = Object.create(null);
this._eventsCount = 0;
return this;
}
listeners = events[type];
if (typeof listeners === 'function') {
this.removeListener(type, listeners);
} else if (listeners !== undefined) {
// LIFO order
for (i = listeners.length - 1; i >= 0; i--) {
this.removeListener(type, listeners[i]);
}
}
return this;
};
function _listeners(target, type, unwrap) {
var events = target._events;
if (events === undefined)
return [];
var evlistener = events[type];
if (evlistener === undefined)
return [];
if (typeof evlistener === 'function')
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ?
unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners(type) {
return _listeners(this, type, true);
};
EventEmitter.prototype.rawListeners = function rawListeners(type) {
return _listeners(this, type, false);
};
EventEmitter.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === 'function') {
return emitter.listenerCount(type);
} else {
return listenerCount.call(emitter, type);
}
};
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
var events = this._events;
if (events !== undefined) {
var evlistener = events[type];
if (typeof evlistener === 'function') {
return 1;
} else if (evlistener !== undefined) {
return evlistener.length;
}
}
return 0;
}
EventEmitter.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
};
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
function spliceOne(list, index) {
for (; index + 1 < list.length; index++)
list[index] = list[index + 1];
list.pop();
}
function unwrapListeners(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) {
ret[i] = arr[i].listener || arr[i];
}
return ret;
}
function once(emitter, name) {
return new Promise(function (resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === 'function') {
emitter.removeListener('error', errorListener);
}
resolve([].slice.call(arguments));
};
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== 'error') {
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
}
});
}
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
if (typeof emitter.on === 'function') {
eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
}
}
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
if (typeof emitter.on === 'function') {
if (flags.once) {
emitter.once(name, listener);
} else {
emitter.on(name, listener);
}
} else if (typeof emitter.addEventListener === 'function') {
// EventTarget does not have `error` event semantics like Node
// EventEmitters, we do not listen for `error` events here.
emitter.addEventListener(name, function wrapListener(arg) {
// IE does not have builtin `{ once: true }` support so we
// have to do it manually.
if (flags.once) {
emitter.removeEventListener(name, wrapListener);
}
listener(arg);
});
} else {
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
}
}

View file

@ -49,9 +49,6 @@ html {
color: var(--text);
}
.bx {
font-size: 25px;
}
toolbar {
width: 100%;
@ -64,6 +61,8 @@ toolbar {
border: 1px solid var(--surface-0);
box-shadow: 1px 3px 10px rgba(0, 0, 0, 0.2), 0 0px 10px rgba(0, 0, 0, 0.2);
user-select: none;
position: relvative;
z-index: 1001;
& > div {
&.outlined {
@ -168,128 +167,9 @@ window-area {
}
}
launcher {
position: absolute;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
top: 0;
background: color-mix(in srgb, var(--crust) 20%, transparent);
z-index: 99999999999999999999999;
width: calc(100vw + 20px);
height: calc(100vh + 20px);
gap: 20px;
transition: 0.2s opacity, 0.2s backdrop-filter;
margin: 0;
left: 0;
&[style*="opacity: 1;"] {
apps * {
pointer-events: all;
}
}
apps {
max-height: 70vh;
padding: 20px;
margin: 40px;
justify-content: center;
display: flex;
flex-wrap: wrap;
gap: 40px;
overflow: scroll;
pointer-events: none;
app {
flex: 1 0 21%;
flex-grow: 0;
align-items: center;
justify-content: center;
display: flex;
flex-direction: column;
gap: 10px;
min-width: 125px;
max-width: 125px;
text-align: center;
overflow: visible;
transition: transform 0.1s ease-in-out;
cursor: pointer;
&:hover {
transform: scale(1.1);
div {
background: var(--surface-0);
}
img {
filter: drop-shadow(0px 2px 10px rgba(0, 0, 0, 0.75));
}
}
img {
width: 100%;
border-radius: var(--app-radius);
aspect-ratio: 1 / 1;
}
div {
overflow: hidden;
text-overflow: ellipsis;
width: fit-content;
height: 100%;
white-space: nowrap;
padding: 5px 10px;
border-radius: 5px;
transition: background 0.1s ease-in-out;
}
}
}
input {
background: var(--mantle);
border: 2px solid var(--crust);
border-radius: 10px;
padding: 10px;
width: 300px;
max-width: 100vw;
text-align: center;
transition: border 0.2s;
&:focus {
outline: none;
border: 2px solid var(--text);
}
}
}
preloader {
position: absolute;
z-index: 9999999;
top: 0;
left: 0;
background: var(--crust);
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: opacity 1s;
.status, .done {
text-align: center;
}
.done div {
display: flex;
align-items: center;
gap: 2px;
}
}
flex {
flex: 1;
.gradient-blur {
mask: linear-gradient(to bottom, transparent, black 5%), linear-gradient(to top, transparent, black 35%);
mask-size: 100% 50%;
mask-repeat: no-repeat;
mask-position: top, bottom;
}

View file

@ -116,7 +116,12 @@ window.console.group = (...args: any) => {
try {
const args = new URLSearchParams(window.location.search)
const kernel = new Kernel()
await kernel.boot(boot, progress, args)
writeln('/-----------------------------------------------\\')
writeln('| FlowOS is now discontinued. Starting in 10s...|')
writeln('\\-----------------------------------------------/')
setTimeout(() => {
kernel.boot(boot, progress, args).catch(e => console.error(e))
}, 10000)
} catch (e) {
writeln()
writeln('An error occured while booting FlowOS.')

View file

@ -16,15 +16,34 @@ const BootLoader: Process = {
const { fs } = process
const wm = await process.loadLibrary('lib/WindowManager')
const launcher = await process.loadLibrary('lib/Launcher')
const { Input } = await process.loadLibrary('lib/Components')
const input = new HTML('input').attr({
const input = Input.new().attr({
type: 'text',
placeholder: 'Search'
}).style({
width: '100%',
'border-radius': '10px',
padding: '5px',
'margin-bottom': '10px',
position: 'sticky',
top: '0'
}).on('keyup', () => {
apps.elm.innerHTML = ''
renderApps().catch(e => console.error(e))
}).appendTo(launcher.element)
const apps = new HTML('apps').appendTo(launcher.element)
const apps = new HTML('div').style({
overflow: 'scroll',
height: 'max-content',
position: 'relative'
})
new HTML('div').style({
height: '100%',
overflow: 'scroll',
'padding-bottom': '30px'
}).append(apps).appendTo(launcher.element).class('gradient-blur')
const renderApps = async (): Promise<void> => {
apps.html('')
@ -36,13 +55,21 @@ const BootLoader: Process = {
const path = Buffer.from(data).toString()
const executable = await process.kernel.getExecutable(path) as Process
const appElement = new HTML('app').on('click', () => {
const appElement = new HTML('div').style({
display: 'flex',
'align-items': 'center',
padding: '5px',
cursor: 'pointer',
gap: '10px',
'border-bottom': '1px solid var(--surface-0)'
}).on('click', () => {
process.launch(path).catch((e: any) => console.error(e))
launcher.toggle()
}).appendTo(apps)
new HTML('img').attr({
src: executable.config.icon ?? nullIcon,
alt: `${executable.config.name} icon`
alt: `${executable.config.name} icon`,
height: '40px'
}).appendTo(appElement)
new HTML('div').text(executable.config.name).appendTo(appElement)
}).catch((e: any) => console.error(e))
@ -72,6 +99,19 @@ const BootLoader: Process = {
await wm.windowArea.appendTo(document.body)
splashElement.cleanup()
launcher.element.prepend(new HTML('div')
.html(`
<ins class="adsbygoogle"
style="display:block"
data-ad-format="fluid"
data-ad-layout-key="-if+5+1+2-3"
data-ad-client="ca-pub-9675905177363247"
data-ad-slot="2569234651"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
`))
}
}

View file

@ -20,7 +20,7 @@ const Components: Library = {
padding: '2.5px',
outline: 'none',
background: 'transparent',
border: '1px solid const(--surface-0)'
border: '1px solid var(--surface-0)'
})
return input
}
@ -30,8 +30,8 @@ const Components: Library = {
function shiftColor (col: string, amt: number): string {
const num = parseInt(col, 16)
const r = (num >> 16) + amt
const b = ((num >> 8) & 0x00FF) + amt
const g = (num & 0x0000FF) + amt
const b = ((num >> 8) & 0x00_FF) + amt
const g = (num & 0x00_00_FF) + amt
const newColor = g | (b << 8) | (r << 16)
return newColor.toString(16)
}
@ -52,7 +52,7 @@ const Components: Library = {
button.style({
background: 'var(--primary)',
color: 'var(--base)',
border: '1px solid #' + shiftColor(document.documentElement.style.getPropertyValue('--primary').replace('#', ''), -40) + ''
border: `1px solid #${shiftColor(document.documentElement.style.getPropertyValue('--primary').replace('#', ''), -40)}`
})
}
return button
@ -77,11 +77,9 @@ const Components: Library = {
'border-radius': '5px',
padding: '2.5px',
background: 'var(--base)',
border: '1px solid const(--surface-1)'
border: '1px solid var(--surface-1)'
}).appendMany(
...options.map((option) => {
return new HTML('option').text(option)
})
...options.map((option) => new HTML('option').text(option))
)
return dropdown
}

View file

@ -9,25 +9,34 @@ const Launcher: Library = {
targetVer: '1.0.0-indev.0'
},
init: (l, k) => {
Launcher.data.element = new l.HTML('launcher').style({
opacity: '0',
'backdrop-filter': 'blur(0px)',
'pointer-events': 'none'
Launcher.data.element = new l.HTML('div').style({
background: `${document.documentElement.style.getPropertyValue('--mantle')}E0`,
width: '350px',
height: '500px',
margin: '20px',
padding: '10px',
overflow: 'hidden',
'border-radius': '20px',
border: '1px solid var(--surface-0)',
position: 'fixed',
bottom: '-500px',
left: '0',
transition: 'bottom 0.5s cubic-bezier(1,0,0,1)',
'z-index': '1000',
'box-shadow': '0 0 10px 0 rgba(0,0,0,0.5)',
'user-select': 'none',
'backdrop-filter': 'blur(10px)'
})
},
data: {
toggle: () => {
if (isLauncherOpen) {
Launcher.data.element.style({
opacity: '0',
'backdrop-filter': 'blur(0px)',
'pointer-events': 'none'
bottom: '-500px'
})
} else {
Launcher.data.element.style({
opacity: '1',
'backdrop-filter': 'blur(10px)',
'pointer-events': 'all'
bottom: '68px'
})
}

View file

@ -14,7 +14,7 @@ const StatusBar: Library = {
<div class="outlined" data-toolbar-id="start"><span class="material-symbols-rounded">space_dashboard</span></div>
<div data-toolbar-id="apps"></div>
<flex></flex>
<div style="flex:1;"></div>
<div class="outlined" data-toolbar-id="plugins"><span class="material-symbols-rounded">expand_less</span></div>
<div class="outlined" data-toolbar-id="controls">
<span class="material-symbols-rounded battery">battery_2_bar</span>