diff --git a/src/assets/icons/accessories-screenshot.svg b/src/assets/icons/accessories-screenshot.svg new file mode 100644 index 0000000..c4a40d8 --- /dev/null +++ b/src/assets/icons/accessories-screenshot.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/assets/icons/application-default-icon.svg b/src/assets/icons/application-default-icon.svg new file mode 100644 index 0000000..fcd16a4 --- /dev/null +++ b/src/assets/icons/application-default-icon.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/applications-games.svg b/src/assets/icons/applications-games.svg new file mode 100644 index 0000000..eb1699f --- /dev/null +++ b/src/assets/icons/applications-games.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/applications-system.svg b/src/assets/icons/applications-system.svg new file mode 100644 index 0000000..acc134e --- /dev/null +++ b/src/assets/icons/applications-system.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/calc.svg b/src/assets/icons/calc.svg new file mode 100644 index 0000000..cef2330 --- /dev/null +++ b/src/assets/icons/calc.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/cheese.svg b/src/assets/icons/cheese.svg new file mode 100644 index 0000000..004be69 --- /dev/null +++ b/src/assets/icons/cheese.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/editor.png b/src/assets/icons/editor.png deleted file mode 100644 index ef7780f..0000000 Binary files a/src/assets/icons/editor.png and /dev/null differ diff --git a/src/assets/icons/eog.svg b/src/assets/icons/eog.svg new file mode 100644 index 0000000..12932d3 --- /dev/null +++ b/src/assets/icons/eog.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/file-manager.svg b/src/assets/icons/file-manager.svg new file mode 100644 index 0000000..54549f5 --- /dev/null +++ b/src/assets/icons/file-manager.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/file-roller.svg b/src/assets/icons/file-roller.svg new file mode 100644 index 0000000..7888054 --- /dev/null +++ b/src/assets/icons/file-roller.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/files.png b/src/assets/icons/files.png deleted file mode 100644 index 2d88f8e..0000000 Binary files a/src/assets/icons/files.png and /dev/null differ diff --git a/src/assets/icons/gnome-maps.svg b/src/assets/icons/gnome-maps.svg new file mode 100644 index 0000000..ce20095 --- /dev/null +++ b/src/assets/icons/gnome-maps.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/gnome-music.svg b/src/assets/icons/gnome-music.svg new file mode 100644 index 0000000..d8cecea --- /dev/null +++ b/src/assets/icons/gnome-music.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/gnome-todo.svg b/src/assets/icons/gnome-todo.svg new file mode 100644 index 0000000..628ee87 --- /dev/null +++ b/src/assets/icons/gnome-todo.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/indicator-weather.svg b/src/assets/icons/indicator-weather.svg new file mode 100644 index 0000000..286afc1 --- /dev/null +++ b/src/assets/icons/indicator-weather.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/info.png b/src/assets/icons/info.png deleted file mode 100644 index ddfc507..0000000 Binary files a/src/assets/icons/info.png and /dev/null differ diff --git a/src/assets/icons/internet-mail.svg b/src/assets/icons/internet-mail.svg new file mode 100644 index 0000000..1cd7606 --- /dev/null +++ b/src/assets/icons/internet-mail.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/kvantum.svg b/src/assets/icons/kvantum.svg new file mode 100644 index 0000000..1012ceb --- /dev/null +++ b/src/assets/icons/kvantum.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/manager.png b/src/assets/icons/manager.png deleted file mode 100644 index 1a1ccfd..0000000 Binary files a/src/assets/icons/manager.png and /dev/null differ diff --git a/src/assets/icons/music.png b/src/assets/icons/music.png deleted file mode 100644 index 34b5bb2..0000000 Binary files a/src/assets/icons/music.png and /dev/null differ diff --git a/src/assets/icons/null.png b/src/assets/icons/null.png deleted file mode 100644 index 4cb5fd4..0000000 Binary files a/src/assets/icons/null.png and /dev/null differ diff --git a/src/assets/icons/org.gnome.Totem.svg b/src/assets/icons/org.gnome.Totem.svg new file mode 100644 index 0000000..1cec191 --- /dev/null +++ b/src/assets/icons/org.gnome.Totem.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/polari.svg b/src/assets/icons/polari.svg new file mode 100644 index 0000000..9fa6f15 --- /dev/null +++ b/src/assets/icons/polari.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/preferences-desktop-plasma-theme.svg b/src/assets/icons/preferences-desktop-plasma-theme.svg new file mode 100644 index 0000000..6243474 --- /dev/null +++ b/src/assets/icons/preferences-desktop-plasma-theme.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/preferences-system-time.svg b/src/assets/icons/preferences-system-time.svg new file mode 100644 index 0000000..4d2801a --- /dev/null +++ b/src/assets/icons/preferences-system-time.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/preferences-system.svg b/src/assets/icons/preferences-system.svg new file mode 100644 index 0000000..6000afc --- /dev/null +++ b/src/assets/icons/preferences-system.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/settings.png b/src/assets/icons/settings.png deleted file mode 100644 index 5be6a26..0000000 Binary files a/src/assets/icons/settings.png and /dev/null differ diff --git a/src/assets/icons/shotwell.svg b/src/assets/icons/shotwell.svg new file mode 100644 index 0000000..8da0a90 --- /dev/null +++ b/src/assets/icons/shotwell.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/software-properties.svg b/src/assets/icons/software-properties.svg new file mode 100644 index 0000000..9af8e92 --- /dev/null +++ b/src/assets/icons/software-properties.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/softwarecenter-debian.svg b/src/assets/icons/softwarecenter-debian.svg new file mode 100644 index 0000000..f160f05 --- /dev/null +++ b/src/assets/icons/softwarecenter-debian.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/softwarecenter-manjaro.svg b/src/assets/icons/softwarecenter-manjaro.svg new file mode 100644 index 0000000..b0d547a --- /dev/null +++ b/src/assets/icons/softwarecenter-manjaro.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/softwarecenter-ubuntu.svg b/src/assets/icons/softwarecenter-ubuntu.svg new file mode 100644 index 0000000..c2e830d --- /dev/null +++ b/src/assets/icons/softwarecenter-ubuntu.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/softwarecenter.svg b/src/assets/icons/softwarecenter.svg new file mode 100644 index 0000000..b664220 --- /dev/null +++ b/src/assets/icons/softwarecenter.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/system-software-install.svg b/src/assets/icons/system-software-install.svg new file mode 100644 index 0000000..a5f1f00 --- /dev/null +++ b/src/assets/icons/system-software-install.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/system-software-update.svg b/src/assets/icons/system-software-update.svg new file mode 100644 index 0000000..3f554f9 --- /dev/null +++ b/src/assets/icons/system-software-update.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/terminal.svg b/src/assets/icons/terminal.svg new file mode 100644 index 0000000..47d4e3d --- /dev/null +++ b/src/assets/icons/terminal.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/assets/icons/terminix.svg b/src/assets/icons/terminix.svg new file mode 100644 index 0000000..7db5ed9 --- /dev/null +++ b/src/assets/icons/terminix.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/text-editor.svg b/src/assets/icons/text-editor.svg new file mode 100644 index 0000000..d0ce113 --- /dev/null +++ b/src/assets/icons/text-editor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/theme-config.svg b/src/assets/icons/theme-config.svg new file mode 100644 index 0000000..111f3f8 --- /dev/null +++ b/src/assets/icons/theme-config.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/icons/userinfo.svg b/src/assets/icons/userinfo.svg new file mode 100644 index 0000000..cd6e8a6 --- /dev/null +++ b/src/assets/icons/userinfo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/icons/web-browser.svg b/src/assets/icons/web-browser.svg new file mode 100644 index 0000000..ba44c8d --- /dev/null +++ b/src/assets/icons/web-browser.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/style.less b/src/assets/style.less index 00ccaba..a0956c6 100644 --- a/src/assets/style.less +++ b/src/assets/style.less @@ -98,7 +98,7 @@ toolbar { window-area { position: relative; - width: 100%; + width: calc(100% - 20px); height: 100%; overflow: hidden; margin: 10px; diff --git a/src/builtin/apps/browser.ts b/src/builtin/apps/browser.ts index bcf0bc8..55140a0 100644 --- a/src/builtin/apps/browser.ts +++ b/src/builtin/apps/browser.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/null.png' +import icon from '../../assets/icons/web-browser.svg' import { App } from '../../types' import FlowWindow from '../../structures/FlowWindow' diff --git a/src/builtin/apps/editor.ts b/src/builtin/apps/editor.ts index 498c8b4..5f08f77 100644 --- a/src/builtin/apps/editor.ts +++ b/src/builtin/apps/editor.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/editor.png' +import icon from '../../assets/icons/text-editor.svg' import { App } from '../../types' import { fullEditor } from 'prism-code-editor/setups' diff --git a/src/builtin/apps/files.ts b/src/builtin/apps/files.ts index d4b454c..24202c8 100644 --- a/src/builtin/apps/files.ts +++ b/src/builtin/apps/files.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/files.png' +import icon from '../../assets/icons/file-manager.svg' import { App } from '../../types' import FlowWindow from '../../structures/FlowWindow' diff --git a/src/builtin/apps/info.ts b/src/builtin/apps/info.ts index d191035..1aff69a 100644 --- a/src/builtin/apps/info.ts +++ b/src/builtin/apps/info.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/info.png' +import icon from '../../assets/icons/userinfo.svg' import badge from '../../assets/badge.png' import { App, PackageJSON } from '../../types' diff --git a/src/builtin/apps/manager.ts b/src/builtin/apps/manager.ts index d2829db..14c6d9b 100644 --- a/src/builtin/apps/manager.ts +++ b/src/builtin/apps/manager.ts @@ -1,7 +1,7 @@ -import icon from '../../assets/icons/manager.png' +import icon from '../../assets/icons/software-properties.svg' import { App, LoadedApp, LoadedPlugin } from '../../types' import FlowWindow from '../../structures/FlowWindow' -import nullIcon from '../../assets/icons/null.png' +import nullIcon from '../../assets/icons/application-default-icon.svg' export default class ManagerApp implements App { meta = { diff --git a/src/builtin/apps/music.ts b/src/builtin/apps/music.ts index 72e5cdb..fd55ca3 100644 --- a/src/builtin/apps/music.ts +++ b/src/builtin/apps/music.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/music.png' +import icon from '../../assets/icons/gnome-music.svg' import { App } from '../../types' import FlowWindow from '../../structures/FlowWindow' diff --git a/src/builtin/apps/settings.ts b/src/builtin/apps/settings.ts index d5110e3..c911052 100644 --- a/src/builtin/apps/settings.ts +++ b/src/builtin/apps/settings.ts @@ -1,4 +1,4 @@ -import icon from '../../assets/icons/settings.png' +import icon from '../../assets/icons/preferences-system.svg' import { App } from '../../types' import FlowWindow from '../../structures/FlowWindow' diff --git a/src/builtin/apps/store.ts b/src/builtin/apps/store.ts new file mode 100644 index 0000000..68f4769 --- /dev/null +++ b/src/builtin/apps/store.ts @@ -0,0 +1,100 @@ +import icon from '../../assets/icons/softwarecenter.svg' +import { App, RepoData } from '../../types' +import FlowWindow from '../../structures/FlowWindow' +import { sanitize } from '../../utils' +import nullIcon from '../../assets/icons/application-default-icon.svg' + +export default class MusicApp implements App { + meta = { + name: 'Store', + description: 'A simple store app.', + pkg: 'flow.store', + version: '1.0.0', + icon + } + + async open (): Promise { + const win = window.wm.createWindow({ + title: this.meta.name, + icon: this.meta.icon, + width: 500, + height: 700 + }) + + win.content.style.background = 'var(--base)' + + const config = await window.config() + + fetch(config.SERVER_URL + '/apps/list/') + .then(async (res) => await res.json()) + .then(handle) + .catch(e => console.error(e)) + + function handle (repos: RepoData[]): void { + win.content.innerHTML = ` +
+ ` + + repos.forEach((repo) => { + (win.content.querySelector('.repos') as HTMLElement).innerHTML += ` +
+
+

${sanitize(repo.name)}

+ ${sanitize(repo.id)} +
+
+
+
+ ` + + repo.apps.forEach((app) => { + (win.content.querySelector(`div[data-repo-id="${sanitize(repo.id)}"] > .apps`) as HTMLElement).innerHTML += ` +
+ +
+

${sanitize(app.name)}

+
+ ${sanitize(app.pkg)} + download +
+
+
+ ` + + window.fs.exists(`/Applications/${app.url.split('/').at(-1) as string}`, (exists) => { + if (exists) { + (win.content.querySelector(`div[data-pkg="${sanitize(app.pkg)}"] div > .material-symbols-rounded`) as HTMLElement).innerHTML = 'delete'; + + (win.content.querySelector(`div[data-pkg="${sanitize(app.pkg)}"] div > .material-symbols-rounded`) as HTMLElement).onclick = () => { + window.fs.unlink(`/Applications/${app.url.split('/').at(-1) as string}`, () => { + window.location.reload() + }) + } + } else { + (win.content.querySelector(`div[data-pkg="${sanitize(app.pkg)}"] div > .material-symbols-rounded`) as HTMLElement).onclick = () => { + install(app.url) + } + } + }); + + (win.content.querySelector(`div[data-pkg="${sanitize(app.pkg)}"] div > .material-symbols-rounded`) as HTMLElement).onclick = () => { + install(app.url) + } + }) + }) + } + + function install (url: string): void { + fetch(url).then(async (res) => await res.text()) + .then((data) => { + window.fs.exists('/Applications', (exists) => { + if (!exists) window.fs.promises.mkdir('/Applications').catch(console.error) + + window.fs.promises.writeFile(`/Applications/${url.split('/').at(-1) as string}`, data).then(() => window.location.reload()).catch(console.error) + }) + }).catch(console.error) + } + + return win + } +} diff --git a/src/instances/Flow.ts b/src/instances/Flow.ts index 957ac8c..322e003 100644 --- a/src/instances/Flow.ts +++ b/src/instances/Flow.ts @@ -1,15 +1,17 @@ import { LoadedApp, LoadedPlugin } from '../types' +import nullIcon from '../assets/icons/application-default-icon.svg' class Flow { apps: LoadedApp[] = [] appList: string[] = [ - 'settings', - 'music', - 'files', - 'editor', - 'info', - 'manager', - 'browser' + '../builtin/apps/settings.ts', + '../builtin/apps/music.ts', + '../builtin/apps/files.ts', + '../builtin/apps/editor.ts', + '../builtin/apps/info.ts', + '../builtin/apps/manager.ts', + '../builtin/apps/browser.ts', + '../builtin/apps/store.ts' ] plugins: LoadedPlugin[] = [] @@ -22,15 +24,22 @@ class Flow { window.preloader.setPending('apps') window.preloader.setStatus('importing default apps...') + await (await window.fs.promises.readdir('/Applications')).forEach((file) => { + window.fs.promises.readFile('/Applications/' + file).then(content => { + this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`) + }).catch(console.error) + }) + for (const appPath of this.appList) { window.preloader.setStatus(`importing default apps\n${appPath}`) - const { default: ImportedApp } = await import(`../builtin/apps/${appPath}.ts`).catch(async (e: Error) => { + const { default: ImportedApp } = await import(`${appPath}`).catch(async (e: Error) => { console.error(e) await window.preloader.setError('apps') window.preloader.setStatus(`unable to import ${appPath}\n${e.name}: ${e.message}`) }) const app = new ImportedApp() app.builtin = true + app.meta.icon = app.meta.icon ?? nullIcon this.addApp(app) } diff --git a/src/structures/FlowWindow.ts b/src/structures/FlowWindow.ts index 7124116..97fb99d 100644 --- a/src/structures/FlowWindow.ts +++ b/src/structures/FlowWindow.ts @@ -2,6 +2,7 @@ import { v4 as uuid } from 'uuid' import WindowManager from '../instances/WindowManager' import { FlowWindowConfig } from '../types' import { sanitize } from '../utils' +import nullIcon from '../assets/icons/application-default-icon.svg' /** * Makes an element draggable. @@ -109,9 +110,9 @@ class FlowWindow { this.element.style.height = `${config.height ?? 200}px` this.header = document.createElement('window-header') - this.header.innerHTML = `
${sanitize(config.title)}
minimizeclose` + this.header.innerHTML = `
${sanitize(config.title)}
minimizeclose` if (config.canResize) { - this.header.innerHTML = `
${sanitize(config.title)}
minimizesquareclose` + this.header.innerHTML = `
${sanitize(config.title)}
minimizesquareclose` } (this.header.querySelector('#close') as HTMLElement).onclick = () => { diff --git a/src/types.ts b/src/types.ts index 03317df..d85901c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -30,6 +30,11 @@ export interface PluginMeta extends BaseMeta { icon?: string } +export interface RepoAppMeta extends BaseMeta { + icon?: string + url: string +} + export interface Apps { [key: string]: App } @@ -79,3 +84,9 @@ export interface FlowConfig { USERNAME: string '24HOUR_CLOCK': boolean } + +export interface RepoData { + name: string + id: string + apps: RepoAppMeta[] +} diff --git a/vite.config.js b/vite.config.js index ed22f22..ff70d3f 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,10 +1,8 @@ import { defineConfig } from 'vite' import { nodePolyfills } from 'vite-plugin-node-polyfills' -import dynamicImport from 'vite-plugin-dynamic-import' export default defineConfig({ plugins: [ - nodePolyfills(), - dynamicImport() + nodePolyfills() ] })