From 81887685b9f67bce0d2efc245446347f94508273 Mon Sep 17 00:00:00 2001 From: Percs <83934299+Percslol@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:47:24 -0600 Subject: [PATCH] prettier --- .github/workflows/build.yaml | 140 +- CREDITS.md | 80 +- apps/ashell.app/manifest.json | 22 +- apps/ashell.app/term.html | 14 +- apps/ashell.app/term.js | 196 +- apps/fsapp.app/GUI.js | 191 +- apps/fsapp.app/appview.html | 502 ++-- apps/fsapp.app/components/File.mjs | 194 +- apps/fsapp.app/components/Selector.mjs | 26 +- apps/fsapp.app/components/SideBar.mjs | 75 +- apps/fsapp.app/components/TopBar.mjs | 44 +- apps/fsapp.app/index.html | 244 +- apps/fsapp.app/index.mjs | 98 +- apps/fsapp.app/manifest.json | 20 +- apps/fsapp.app/operations.js | 1511 +++++----- apps/libfilepicker.lib/handler.js | 187 +- apps/libfilepicker.lib/install.js | 94 +- apps/libfilepicker.lib/manifest.json | 16 +- apps/libfileview.lib/fileHandler.js | 387 ++- apps/libfileview.lib/icons.json | 276 +- apps/libfileview.lib/install.js | 38 +- apps/libfileview.lib/manifest.json | 16 +- .../pages/appview/appview.html | 502 ++-- apps/libfileview.lib/pages/appview/appview.js | 466 ++- apps/libpersist.lib/install.js | 45 +- apps/libpersist.lib/manifest.json | 18 +- apps/libpersist.lib/src/index.js | 193 +- apps/libstore.lib/index.js | 995 ++++--- apps/libstore.lib/manifest.json | 16 +- apps/marketplace.app/index.html | 82 +- apps/marketplace.app/index.mjs | 427 ++- apps/marketplace.app/manifest.json | 20 +- apps/marketplace.app/screens/ItemList.mjs | 236 +- apps/marketplace.app/screens/Overview.mjs | 123 +- apps/marketplace.app/screens/RepoList.mjs | 240 +- apps/term.app/index.css | 24 +- apps/term.app/manifest.json | 22 +- apps/term.app/term.html | 16 +- apps/term.app/term.js | 118 +- config.default.json | 98 +- documentation/Anura-API.md | 120 +- documentation/appdevt.md | 301 +- documentation/marketplace.md | 128 +- .../templates/dreamlanddemo.app/index.html | 18 +- .../templates/dreamlanddemo.app/index.js | 38 +- .../templates/dreamlanddemo.app/manifest.json | 20 +- .../templates/template.app/index.html | 12 +- .../templates/template.app/manifest.json | 20 +- eslint.config.mjs | 112 +- package.json | 92 +- public/anura-sw.js | 713 +++-- public/assets/materialsymbols.css | 34 +- .../bundled_wallpapers/manifest.json | 172 +- public/index.html | 255 +- public/manifest.json | 40 +- public/theme.css | 50 +- server/package.json | 34 +- server/server.js | 14 +- src/AliceWM.css | 272 +- src/AliceWM.tsx | 2514 ++++++++--------- src/AltTabView.css | 88 +- src/AltTabView.tsx | 210 +- src/Anura.ts | 505 ++-- src/Boot.tsx | 1448 +++++----- src/Bootsplash.tsx | 68 +- src/Calendar.tsx | 689 +++-- src/Launcher.css | 66 +- src/Launcher.tsx | 758 +++-- src/Notifications.css | 36 +- src/QuickSettings.tsx | 1308 ++++----- src/Taskbar.css | 174 +- src/Taskbar.tsx | 939 +++--- src/Utils.ts | 14 +- src/anura.css | 226 +- src/anurad.tsx | 379 ++- src/api/ContextMenu.tsx | 173 +- src/api/FilerFS.ts | 639 +++-- src/api/Files.ts | 310 +- src/api/Filesystem.ts | 2353 ++++++++------- src/api/LocalFS.ts | 2489 ++++++++-------- src/api/Networking.ts | 288 +- src/api/NotificationService.tsx | 473 ++-- src/api/Platform.ts | 96 +- src/api/Processes.tsx | 422 ++- src/api/Settings.ts | 190 +- src/api/Systray.tsx | 148 +- src/api/Theme.ts | 378 ++- src/api/UI.tsx | 424 +-- src/api/URIHandler.ts | 128 +- src/api/WmApi.ts | 174 +- src/bcc.ts | 164 +- src/coreapps/AboutApp.css | 102 +- src/coreapps/AboutApp.tsx | 264 +- src/coreapps/App.tsx | 20 +- src/coreapps/BrowserApp.tsx | 248 +- src/coreapps/Dialog.tsx | 330 ++- src/coreapps/ExploreApp.tsx | 648 ++--- src/coreapps/ExternalApp.tsx | 595 ++-- src/coreapps/GenericApp.tsx | 26 +- src/coreapps/RecoveryApp.tsx | 400 ++- src/coreapps/RegEdit.tsx | 632 ++--- src/coreapps/SettingsApp.tsx | 1415 +++++----- src/coreapps/TaskManager.tsx | 654 ++--- src/coreapps/WallpaperSelector.tsx | 1495 +++++----- src/coreapps/XAppStub.tsx | 34 +- src/coreapps/XFrogApp.tsx | 287 +- src/coreapps/x86MgrApp.tsx | 36 +- src/fonts/roboto.css | 97 +- src/libs/AnuradHelpersLib.tsx | 150 +- src/libs/BrowserLib.tsx | 80 +- src/libs/ExternalLib.tsx | 122 +- src/libs/Lib.tsx | 12 +- src/libs/NodePolyfills/NodeFS.ts | 20 +- src/libs/NodePolyfills/NodePrelude.ts | 44 +- src/libs/Vendored/Comlink.tsx | 40 +- src/libs/Vendored/Fflate.tsx | 40 +- src/libs/Vendored/Mime.tsx | 40 +- src/oobe/OobeView.tsx | 856 +++--- src/types/Filer.d.ts | 653 +++-- src/v86.tsx | 1636 ++++++----- tsconfig.json | 78 +- types-package.json | 20 +- 122 files changed, 19427 insertions(+), 20375 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d5a044c4..514bc2f7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,84 +3,84 @@ name: CI on: [push, pull_request, workflow_dispatch] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - build: - name: Build Anura - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: "20.x" - - run: sudo apt update - - run: sudo apt install -y git build-essential clang default-jre - - run: git submodule update --init - - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - - run: source "$HOME/.cargo/env" && make static + build: + name: Build Anura + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.x" + - run: sudo apt update + - run: sudo apt install -y git build-essential clang default-jre + - run: git submodule update --init + - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + - run: source "$HOME/.cargo/env" && make static - - name: Upload Anura Artifact - uses: actions/upload-artifact@v4 - with: - name: Anura static build - path: static/* - retention-days: 90 + - name: Upload Anura Artifact + uses: actions/upload-artifact@v4 + with: + name: Anura static build + path: static/* + retention-days: 90 - upload: - name: Upload release - runs-on: ubuntu-latest - needs: build - permissions: write-all - if: github.ref == 'refs/heads/main' + upload: + name: Upload release + runs-on: ubuntu-latest + needs: build + permissions: write-all + if: github.ref == 'refs/heads/main' - steps: - - name: Delete old release and tag - uses: dev-drprasad/delete-tag-and-release@v1.0.1 - with: - delete_release: true - tag_name: latest - github_token: ${{ github.token }} + steps: + - name: Delete old release and tag + uses: dev-drprasad/delete-tag-and-release@v1.0.1 + with: + delete_release: true + tag_name: latest + github_token: ${{ github.token }} - - name: Get artifacts - uses: actions/download-artifact@v4 - with: - name: Anura static build - path: ./static + - name: Get artifacts + uses: actions/download-artifact@v4 + with: + name: Anura static build + path: ./static - - name: Zip anura Release - run: cd static && zip -r ../anura.zip . && cd .. + - name: Zip anura Release + run: cd static && zip -r ../anura.zip . && cd .. - - name: Release to GitHub - uses: ncipollo/release-action@v1 - with: - name: Continuous Build - tag: latest - commit: main - body: "${{ github.event.head_commit.url }} ${{ github.event.head_commit.message }}" - artifacts: "anura.zip" - prerelease: true + - name: Release to GitHub + uses: ncipollo/release-action@v1 + with: + name: Continuous Build + tag: latest + commit: main + body: "${{ github.event.head_commit.url }} ${{ github.event.head_commit.message }}" + artifacts: "anura.zip" + prerelease: true - pages: - name: Upload to Github Pages - runs-on: ubuntu-latest - needs: build - permissions: write-all - if: github.ref == 'refs/heads/main' - steps: - - name: Get artifacts - uses: actions/download-artifact@v4 - with: - name: Anura static build - path: ./static + pages: + name: Upload to Github Pages + runs-on: ubuntu-latest + needs: build + permissions: write-all + if: github.ref == 'refs/heads/main' + steps: + - name: Get artifacts + uses: actions/download-artifact@v4 + with: + name: Anura static build + path: ./static - - name: upload pages artifact - uses: actions/upload-pages-artifact@v3 - with: - path: "./static" + - name: upload pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: "./static" - - name: deploy to github - id: deployment - uses: actions/deploy-pages@v4 + - name: deploy to github + id: deployment + uses: actions/deploy-pages@v4 diff --git a/CREDITS.md b/CREDITS.md index eb97f996..fd33118e 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -2,58 +2,58 @@ - Contributors - - Project Name: @ember3141 - - Project Maintainers: - - @ProgrammerIn-wonderland - - @Endercass - - @Percslol - - Large contributors + - Project Name: @ember3141 + - Project Maintainers: + - @ProgrammerIn-wonderland + - @Endercass + - @Percslol + - Large contributors - - @CoolElectronics - - @r58playz - - @MadjikDotPng - - @BomberFish + - @CoolElectronics + - @r58playz + - @MadjikDotPng + - @BomberFish - - A full list of contributors can be found [here](https://github.com/MercuryWorkshop/anuraOS/graphs/contributors) + - A full list of contributors can be found [here](https://github.com/MercuryWorkshop/anuraOS/graphs/contributors) - Libraries and applications sources - - Filesystem base - [Filer.js](https://filer.js.org/) - - Formerly the only filesystem library used in the project, now the default filesystem library and the base of the Anura Filesystem API - - MIME type detection - [mime-db](https://github.com/broofa/mime) - - Service Worker <-> Main Thread communication - [Comlink](https://github.com/GoogleChromeLabs/comlink) - - Service worker library - [Workbox](https://developers.google.com/web/tools/workbox) - - Anura Shell is a heavily modified version of [Puter's Phoenix Shell](https://github.com/HeyPuter/phoenix) - - This shell was implemented so that Anura users could have a more traditional shell experience, and if they had experience with Puter's Phoenix Shell, they could easily transfer that knowledge to Anura. - - Replaces the original Anura Shell, which was a modified eval-based shell. - - JS Framework - [dreamland.js](https://github.com/MercuryWorkshop/dreamlandjs) - - TCP Networking support [wisp-server-node](https://github.com/MercuryWorkshop/wisp-server-node) - - x86 Emulation - [v86](https://copy.sh/v86/) - - Service worker web proxy - [Ultraviolet](https://github.com/titaniumnetwork-dev/Ultraviolet) - - Material Components - [Matter CSS](https://github.com/finnhvman/matter) - - Default networking stack- [libcurl.js with WolfSSL](https://github.com/ading2210/libcurl.js) - - A full list of dependencies can be found [here](https://github.com/MercuryWorkshop/anuraOS/network/dependencies) + - Filesystem base - [Filer.js](https://filer.js.org/) + - Formerly the only filesystem library used in the project, now the default filesystem library and the base of the Anura Filesystem API + - MIME type detection - [mime-db](https://github.com/broofa/mime) + - Service Worker <-> Main Thread communication - [Comlink](https://github.com/GoogleChromeLabs/comlink) + - Service worker library - [Workbox](https://developers.google.com/web/tools/workbox) + - Anura Shell is a heavily modified version of [Puter's Phoenix Shell](https://github.com/HeyPuter/phoenix) + - This shell was implemented so that Anura users could have a more traditional shell experience, and if they had experience with Puter's Phoenix Shell, they could easily transfer that knowledge to Anura. + - Replaces the original Anura Shell, which was a modified eval-based shell. + - JS Framework - [dreamland.js](https://github.com/MercuryWorkshop/dreamlandjs) + - TCP Networking support [wisp-server-node](https://github.com/MercuryWorkshop/wisp-server-node) + - x86 Emulation - [v86](https://copy.sh/v86/) + - Service worker web proxy - [Ultraviolet](https://github.com/titaniumnetwork-dev/Ultraviolet) + - Material Components - [Matter CSS](https://github.com/finnhvman/matter) + - Default networking stack- [libcurl.js with WolfSSL](https://github.com/ading2210/libcurl.js) + - A full list of dependencies can be found [here](https://github.com/MercuryWorkshop/anuraOS/network/dependencies) - Retired Libraries and applications sources - - Old Websocket to TCP Bridge - [WSProxy](https://github.com/herenow/wsProxy) - - Old Filesystem HTTP bridge - [MercuryWorkshop Nohost](https://github.com/MercuryWorkshop/nohost) (Fork of [Humphd Nohost](https://github.com/humphd/nohost)) - - Now the functionality is provided by a fully rewritten version of the original code, using the Anura Filesystem API - - VNC Client [noVNC](https://github.com/novnc/noVNC) - - No longer vendored in this repository, moved to the [Anura App Repository](https://github.com/MercuryWorkshop/anura-repo) - - SSH Client [sshy](https://github.com/stuicey/SSHy) - - No longer vendored in this repository, moved to the [Anura App Repository](https://github.com/MercuryWorkshop/anura-repo) + - Old Websocket to TCP Bridge - [WSProxy](https://github.com/herenow/wsProxy) + - Old Filesystem HTTP bridge - [MercuryWorkshop Nohost](https://github.com/MercuryWorkshop/nohost) (Fork of [Humphd Nohost](https://github.com/humphd/nohost)) + - Now the functionality is provided by a fully rewritten version of the original code, using the Anura Filesystem API + - VNC Client [noVNC](https://github.com/novnc/noVNC) + - No longer vendored in this repository, moved to the [Anura App Repository](https://github.com/MercuryWorkshop/anura-repo) + - SSH Client [sshy](https://github.com/stuicey/SSHy) + - No longer vendored in this repository, moved to the [Anura App Repository](https://github.com/MercuryWorkshop/anura-repo) - Code snippets used - Note: This list is non-exhaustive and may not contain all of the code snippets used in production of this software. + Note: This list is non-exhaustive and may not contain all of the code snippets used in production of this software. - - [original base](https://gist.github.com/chwkai/290488) - - Resizable Table columns in fsapp [codepen](https://codepen.io/adam-lynch/pen/GaqgXP) - - [Calendar panel](https://www.geeksforgeeks.org/how-to-design-a-simple-calendar-using-javascript/) + - [original base](https://gist.github.com/chwkai/290488) + - Resizable Table columns in fsapp [codepen](https://codepen.io/adam-lynch/pen/GaqgXP) + - [Calendar panel](https://www.geeksforgeeks.org/how-to-design-a-simple-calendar-using-javascript/) - Design & Assets - - UI design inspiration - [Google ChromeOS](https://www.google.com/chromebook/chrome-os/) - - Various icons - [papirus icon theme](https://github.com/PapirusDevelopmentTeam/papirus-icon-theme) - - Various assets - [Google ChromeOS](https://www.google.com/chromebook/chrome-os/) + - UI design inspiration - [Google ChromeOS](https://www.google.com/chromebook/chrome-os/) + - Various icons - [papirus icon theme](https://github.com/PapirusDevelopmentTeam/papirus-icon-theme) + - Various assets - [Google ChromeOS](https://www.google.com/chromebook/chrome-os/) diff --git a/apps/ashell.app/manifest.json b/apps/ashell.app/manifest.json index 0045cc56..5ba2a947 100644 --- a/apps/ashell.app/manifest.json +++ b/apps/ashell.app/manifest.json @@ -1,13 +1,13 @@ { - "name": "Anura Shell", - "type": "auto", - "package": "anura.ashell", - "index": "term.html", - "icon": "term.png", - "wininfo": { - "title": "Terminal", - "allowMultipleInstance": "true", - "width": "680px", - "height": "440px" - } + "name": "Anura Shell", + "type": "auto", + "package": "anura.ashell", + "index": "term.html", + "icon": "term.png", + "wininfo": { + "title": "Terminal", + "allowMultipleInstance": "true", + "width": "680px", + "height": "440px" + } } diff --git a/apps/ashell.app/term.html b/apps/ashell.app/term.html index 75b7ff8e..d025aaa0 100644 --- a/apps/ashell.app/term.html +++ b/apps/ashell.app/term.html @@ -1,11 +1,11 @@ -
- - - + + + + - - - + + + diff --git a/apps/ashell.app/term.js b/apps/ashell.app/term.js index 5a60a397..1830a60c 100644 --- a/apps/ashell.app/term.js +++ b/apps/ashell.app/term.js @@ -13,105 +13,105 @@ const encoder = new TextEncoder(); term.decorate($term); term.onTerminalReady = async () => { - $term - .querySelector("iframe") - .contentDocument.querySelector("x-screen").style.overflow = "hidden"; - term.setBackgroundColor(anura.ui.theme.darkBackground); - term.setCursorColor(anura.ui.theme.foreground); - - if (anura.settings.get("transparent-ashell")) { - frameElement.style.backgroundColor = "rgba(0, 0, 0, 0)"; - frameElement.parentNode.parentNode.style.backgroundColor = - "rgba(0, 0, 0, 0)"; - frameElement.parentNode.parentNode.style.backdropFilter = "blur(5px)"; - document - .querySelector("iframe") - .contentDocument.querySelector("x-screen").style.backgroundColor = - anura.ui.theme.background + "d9"; - Array.from(frameElement.parentNode.parentNode.children).filter((e) => - e.classList.contains("title"), - )[0].style.backgroundColor = anura.ui.theme.background + "d9"; - } - - let io = term.io.push(); - - const proc = await anura.processes.execute(shell); - - const stdinWriter = proc.stdin.getWriter(); - - io.onVTKeystroke = (key) => { - stdinWriter.write(key); - }; - - io.sendString = (str) => { - stdinWriter.write(str); - }; - - io.onTerminalResize = (cols, rows) => { - proc.window.postMessage({ - type: "ioctl.set", - windowSize: { - rows, - cols, - }, - }); - }; - - proc.window.addEventListener("message", (event) => { - if (event.data.type === "ready") { - io.onTerminalResize(term.screenSize.width, term.screenSize.height); - } - }); - - term.installKeyboard(); - - proc.stdout.pipeTo( - new WritableStream({ - write: (chunk) => { - io.writeUTF8(LF_to_CRLF(chunk)); - }, - }), - ); - - proc.stderr.pipeTo( - new WritableStream({ - write: (chunk) => { - io.writeUTF8(LF_to_CRLF(chunk)); - }, - }), - ); - const oldProcKill = proc.kill.bind(proc); - - proc.kill = () => { - oldProcKill(); - instanceWindow.close(); - }; - - instanceWindow.addEventListener("close", () => { - proc.kill(); - }); - - proc.exit = proc.kill.bind(proc); + $term + .querySelector("iframe") + .contentDocument.querySelector("x-screen").style.overflow = "hidden"; + term.setBackgroundColor(anura.ui.theme.darkBackground); + term.setCursorColor(anura.ui.theme.foreground); + + if (anura.settings.get("transparent-ashell")) { + frameElement.style.backgroundColor = "rgba(0, 0, 0, 0)"; + frameElement.parentNode.parentNode.style.backgroundColor = + "rgba(0, 0, 0, 0)"; + frameElement.parentNode.parentNode.style.backdropFilter = "blur(5px)"; + document + .querySelector("iframe") + .contentDocument.querySelector("x-screen").style.backgroundColor = + anura.ui.theme.background + "d9"; + Array.from(frameElement.parentNode.parentNode.children).filter((e) => + e.classList.contains("title"), + )[0].style.backgroundColor = anura.ui.theme.background + "d9"; + } + + let io = term.io.push(); + + const proc = await anura.processes.execute(shell); + + const stdinWriter = proc.stdin.getWriter(); + + io.onVTKeystroke = (key) => { + stdinWriter.write(key); + }; + + io.sendString = (str) => { + stdinWriter.write(str); + }; + + io.onTerminalResize = (cols, rows) => { + proc.window.postMessage({ + type: "ioctl.set", + windowSize: { + rows, + cols, + }, + }); + }; + + proc.window.addEventListener("message", (event) => { + if (event.data.type === "ready") { + io.onTerminalResize(term.screenSize.width, term.screenSize.height); + } + }); + + term.installKeyboard(); + + proc.stdout.pipeTo( + new WritableStream({ + write: (chunk) => { + io.writeUTF8(LF_to_CRLF(chunk)); + }, + }), + ); + + proc.stderr.pipeTo( + new WritableStream({ + write: (chunk) => { + io.writeUTF8(LF_to_CRLF(chunk)); + }, + }), + ); + const oldProcKill = proc.kill.bind(proc); + + proc.kill = () => { + oldProcKill(); + instanceWindow.close(); + }; + + instanceWindow.addEventListener("close", () => { + proc.kill(); + }); + + proc.exit = proc.kill.bind(proc); }; function LF_to_CRLF(input) { - let lfCount = 0; - for (let i = 0; i < input.length; i++) { - if (input[i] === 0x0a) { - lfCount++; - } - } - - const output = new Uint8Array(input.length + lfCount); - - let outputIndex = 0; - for (let i = 0; i < input.length; i++) { - // If LF is encountered, insert CR (0x0D) before LF (0x0A) - if (input[i] === 0x0a) { - output[outputIndex++] = 0x0d; - } - output[outputIndex++] = input[i]; - } - - return output; + let lfCount = 0; + for (let i = 0; i < input.length; i++) { + if (input[i] === 0x0a) { + lfCount++; + } + } + + const output = new Uint8Array(input.length + lfCount); + + let outputIndex = 0; + for (let i = 0; i < input.length; i++) { + // If LF is encountered, insert CR (0x0D) before LF (0x0A) + if (input[i] === 0x0a) { + output[outputIndex++] = 0x0d; + } + output[outputIndex++] = input[i]; + } + + return output; } diff --git a/apps/fsapp.app/GUI.js b/apps/fsapp.app/GUI.js index 1f85efa5..c87ee663 100644 --- a/apps/fsapp.app/GUI.js +++ b/apps/fsapp.app/GUI.js @@ -9,70 +9,70 @@ const emptycontextmenu = new anura.ContextMenu(); // Helper to add context menu items to both menus function addContextMenuItem(name, func) { - newcontextmenu.addItem(name, func); - appcontextmenu.addItem(name, func); + newcontextmenu.addItem(name, func); + appcontextmenu.addItem(name, func); } // addContextMenuItem("Get Info", function () {}); // addContextMenuItem("Pin to Shelf", function () {}); addContextMenuItem("Cut", function () { - cut(); + cut(); }); addContextMenuItem("Copy", function () { - copy(); + copy(); }); addContextMenuItem("Paste", function () { - paste(); + paste(); }); addContextMenuItem("Delete", function () { - deleteFile(); + deleteFile(); }); addContextMenuItem("Rename", function () { - rename(); + rename(); }); addContextMenuItem("Refresh", function () { - reload(); + reload(); }); newcontextmenu.addItem("Download", function () { - download(); + download(); }); appcontextmenu.addItem("Install (Session)", function () { - installSession(); + installSession(); }); appcontextmenu.addItem("Install (Permanent)", function () { - installPermanent(); + installPermanent(); }); appcontextmenu.addItem("Navigate", function () { - navigate(); + navigate(); }); emptycontextmenu.addItem("Upload from PC", function () { - upload(); + upload(); }); emptycontextmenu.addItem("New folder", function () { - newFolder(); + newFolder(); }); emptycontextmenu.addItem("New file", function () { - newFile(); + newFile(); }); emptycontextmenu.addItem("Paste", function () { - paste(); + paste(); }); emptycontextmenu.addItem("Refresh", function () { - reload(); + reload(); }); const min = 150; const columnTypeToRatioMap = { - icon: 0.1, - name: 3, - size: 1, - type: 1, - modified: 1, + icon: 0.1, + name: 3, + size: 1, + type: 1, + modified: 1, }; const table = document.querySelector("table"); @@ -87,100 +87,89 @@ let headerBeingResized; // Where the magic happens. I.e. when they're actually resizing const onMouseMove = (e) => - requestAnimationFrame(() => { - (window.getSelection - ? window.getSelection() - : document.selection - ).empty(); - - // Calculate the desired width - horizontalScrollOffset = document.documentElement.scrollLeft; - const width = - horizontalScrollOffset + e.clientX - headerBeingResized.offsetLeft; - - // Update the column object with the new size value - const column = columns.find( - ({ header }) => header === headerBeingResized, - ); - column.size = Math.max(min, width) + "px"; // Enforce our minimum - - // For the other headers which don't have a set width, fix it to their computed width - columns.forEach((column) => { - if (column.size.startsWith("minmax")) { - // isn't fixed yet (it would be a pixel value otherwise) - column.size = parseInt(column.header.clientWidth, 10) + "px"; - } - }); - - /* + requestAnimationFrame(() => { + (window.getSelection ? window.getSelection() : document.selection).empty(); + + // Calculate the desired width + horizontalScrollOffset = document.documentElement.scrollLeft; + const width = + horizontalScrollOffset + e.clientX - headerBeingResized.offsetLeft; + + // Update the column object with the new size value + const column = columns.find(({ header }) => header === headerBeingResized); + column.size = Math.max(min, width) + "px"; // Enforce our minimum + + // For the other headers which don't have a set width, fix it to their computed width + columns.forEach((column) => { + if (column.size.startsWith("minmax")) { + // isn't fixed yet (it would be a pixel value otherwise) + column.size = parseInt(column.header.clientWidth, 10) + "px"; + } + }); + + /* Update the column sizes Reminder: grid-template-columns sets the width for all columns in one value */ - table.style.gridTemplateColumns = columns - .map(({ header, size }) => size) - .join(" "); - }); + table.style.gridTemplateColumns = columns + .map(({ header, size }) => size) + .join(" "); + }); const onMouseUp = () => { - window.removeEventListener("mousemove", onMouseMove); - window.removeEventListener("mouseup", onMouseUp); - headerBeingResized.classList.remove("header--being-resized"); - headerBeingResized = null; + window.removeEventListener("mousemove", onMouseMove); + window.removeEventListener("mouseup", onMouseUp); + headerBeingResized.classList.remove("header--being-resized"); + headerBeingResized = null; }; const initResize = ({ target }) => { - headerBeingResized = target.parentNode; - window.addEventListener("mousemove", onMouseMove); - window.addEventListener("mouseup", onMouseUp); - headerBeingResized.classList.add("header--being-resized"); + headerBeingResized = target.parentNode; + window.addEventListener("mousemove", onMouseMove); + window.addEventListener("mouseup", onMouseUp); + headerBeingResized.classList.add("header--being-resized"); }; document.querySelectorAll("th").forEach((header) => { - const max = columnTypeToRatioMap[header.dataset.type] + "fr"; - columns.push({ - header, - size: `minmax(${min}px, ${max})`, - }); - header - .querySelector(".resize-handle") - .addEventListener("mousedown", initResize); + const max = columnTypeToRatioMap[header.dataset.type] + "fr"; + columns.push({ + header, + size: `minmax(${min}px, ${max})`, + }); + header + .querySelector(".resize-handle") + .addEventListener("mousedown", initResize); }); document.addEventListener("contextmenu", (e) => { - if (e.shiftKey) { - return; - } - e.preventDefault(); - const boundingRect = window.frameElement.getBoundingClientRect(); - - const containsApps = - currentlySelected - .map( - (item) => - item.getAttribute("data-path").split(".").slice("-1")[0], - ) - .filter((item) => item === "app" || item === "lib").length > 0; - - if (containsApps) { - appcontextmenu.show(e.pageX + boundingRect.x, e.pageY + boundingRect.y); - newcontextmenu.hide(); - emptycontextmenu.hide(); - } else if (currentlySelected.length !== 0) { - newcontextmenu.show(e.pageX + boundingRect.x, e.pageY + boundingRect.y); - appcontextmenu.hide(); - emptycontextmenu.hide(); - } else { - emptycontextmenu.show( - e.pageX + boundingRect.x, - e.pageY + boundingRect.y, - ); - newcontextmenu.hide(); - appcontextmenu.hide(); - } + if (e.shiftKey) { + return; + } + e.preventDefault(); + const boundingRect = window.frameElement.getBoundingClientRect(); + + const containsApps = + currentlySelected + .map((item) => item.getAttribute("data-path").split(".").slice("-1")[0]) + .filter((item) => item === "app" || item === "lib").length > 0; + + if (containsApps) { + appcontextmenu.show(e.pageX + boundingRect.x, e.pageY + boundingRect.y); + newcontextmenu.hide(); + emptycontextmenu.hide(); + } else if (currentlySelected.length !== 0) { + newcontextmenu.show(e.pageX + boundingRect.x, e.pageY + boundingRect.y); + appcontextmenu.hide(); + emptycontextmenu.hide(); + } else { + emptycontextmenu.show(e.pageX + boundingRect.x, e.pageY + boundingRect.y); + newcontextmenu.hide(); + appcontextmenu.hide(); + } }); document.addEventListener("click", (e) => { - newcontextmenu.hide(); - appcontextmenu.hide(); - emptycontextmenu.hide(); + newcontextmenu.hide(); + appcontextmenu.hide(); + emptycontextmenu.hide(); }); diff --git a/apps/fsapp.app/appview.html b/apps/fsapp.app/appview.html index 7a150629..86e34fbe 100644 --- a/apps/fsapp.app/appview.html +++ b/apps/fsapp.app/appview.html @@ -1,289 +1,275 @@ - - -