diff --git a/.github/workflows/prod-vite.yml b/.github/workflows/prod-web.yml similarity index 95% rename from .github/workflows/prod-vite.yml rename to .github/workflows/prod-web.yml index be8f3df3..63a313ed 100644 --- a/.github/workflows/prod-vite.yml +++ b/.github/workflows/prod-web.yml @@ -1,4 +1,4 @@ -name: Production Vite workflow +name: Build web on: push: @@ -8,7 +8,7 @@ on: - '**/README.md' jobs: - build: + web-build: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/pull-android.yml b/.github/workflows/pull-android.yml new file mode 100644 index 00000000..56d86088 --- /dev/null +++ b/.github/workflows/pull-android.yml @@ -0,0 +1,46 @@ +name: Check Android + +on: + pull_request: + branches: [ "main" ] + +permissions: + contents: write + +jobs: + android-check: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./materialious/android + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install modules + run: cd ../ && npm install + + - name: Build android nodejs packages + run: cd ../static/nodejs-android && npm install + + - name: Build package + run: cd ../ && npm run build + + - name: Sync package + run: cd ../ && npx cap sync + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + cache: 'gradle' + + - name: Build App + run: | + bash gradlew assembleRelease + bash gradlew bundleRelease diff --git a/.github/workflows/pull-desktop.yml b/.github/workflows/pull-desktop.yml new file mode 100644 index 00000000..183c4f55 --- /dev/null +++ b/.github/workflows/pull-desktop.yml @@ -0,0 +1,56 @@ +name: Check desktop + +on: + pull_request: + branches: ["main"] + + workflow_dispatch: + +permissions: + contents: write + +jobs: + desktop-check: + strategy: + matrix: + node-version: [20] + runtime: + - linux-x64 + - win-x64 + - osx-x64 + + include: + - runtime: linux-x64 + os: ubuntu-latest + - runtime: osx-x64 + os: macOS-latest + - runtime: win-x64 + os: windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install modules + run: cd ./materialious && npm install + + - name: Build package + run: cd ./materialious && npm run build + + - name: Sync electron package + run: cd ./materialious && npx cap sync @capacitor-community/electron + + - name: Patch capacitor plugin + run: cd ./materialious/electron && python patch_capacitor_plugin.py + + - name: Install electron modules + run: cd ./materialious/electron && npm install + + - name: Build desktop packages + run: cd ./materialious/electron && npm run electron:pack diff --git a/.github/workflows/vite-checks.yml b/.github/workflows/pull-web.yml similarity index 85% rename from .github/workflows/vite-checks.yml rename to .github/workflows/pull-web.yml index 2dfdf6f7..ef746d9b 100644 --- a/.github/workflows/vite-checks.yml +++ b/.github/workflows/pull-web.yml @@ -1,13 +1,11 @@ -name: Development Vite workflow +name: Check web on: - push: - branches: [ "main" ] pull_request: branches: [ "main" ] jobs: - build: + web-check: runs-on: ubuntu-latest defaults: run: diff --git a/.vscode/settings.json b/.vscode/settings.json index 794cfe05..df770654 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,6 @@ "i18n-ally.keystyle": "nested", "cSpell.words": [ "Materialious" - ] + ], + "java.configuration.updateBuildConfiguration": "interactive" } \ No newline at end of file diff --git a/README.md b/README.md index 8e34f750..76ea2006 100644 --- a/README.md +++ b/README.md @@ -105,3 +105,7 @@ Due to Google's policies on custom YouTube frontends, Materialious isn't availab - [Vidstack player](https://github.com/vidstack/player) - [Beer CSS](https://github.com/beercss/beercss) (Especially the [YouTube template](https://github.com/beercss/beercss/tree/main/src/youtube) what was used as the base for Materialious.) - Every dependency in [package.json](/materialious/package.json). + +# Developers +- [How Materialious is built](./docs/BUILDING.md) +- [How to contribute to Materialious](./docs/DEV.md) \ No newline at end of file diff --git a/docs/BUILDING.md b/docs/BUILDING.md new file mode 100644 index 00000000..a0e3dbd9 --- /dev/null +++ b/docs/BUILDING.md @@ -0,0 +1,33 @@ +## Work in Progress +This documentation is currently under development and subject to updates. + +## Building +### Web Deployment (via Docker) +Materialious supports web deployment through Docker. + +- The build process starts with the [Dockerfile](../materialious/Dockerfile). +- Placeholder environment variables are injected into a `.env` file, which are later replaced by the [replace_env_vars.sh](../materialious/replace_env_vars.sh) script. +- The application is served using NGINX, configured with [nginx.conf](../materialious/nginx.conf). +- Deployment and building are handled via [docker/build-push-action@v5](https://github.com/docker/build-push-action/tree/v5) using the workflow defined in [prod-web.yml](../.github/workflows/prod-web.yml). + +### Desktop Release (via GitHub Releases) +Materialious desktop builds are handled through GitHub using [prod-desktop.yml](../.github/workflows/prod-desktop.yml). + +- First, the typical build steps are run: `npm install` and `npm run build`. +- We utilize [Capacitor](https://capacitorjs.com) with `@capacitor-community/electron` to integrate Electron into the project. The command `npx cap sync @capacitor-community/electron` is used to synchronize the latest build. +- The [patch_capacitor_plugin.py](../materialious/electron/patch_capacitor_plugin.py) script removes the [Capacitor-NodeJS](https://github.com/hampoelz/Capacitor-NodeJS) plugin from the desktop build, as it's not required and currently has no better alternative. +- From here, the process follows standard [electron-builder](https://www.electron.build/) steps to complete the build. + +### Desktop Release (via Flatpak) +Flatpak builds for desktop releases are managed via [us.materailio.app](../flatpak/us.materialio.app.json). + +- We generate the necessary remote npm packages with `flatpak-node-generator npm -r ../materialious/package-lock.json -R ../materialious/electron/package-lock.json`, which creates [generated-sources.json](../flatpak/generated-sources.json). +- The Linux x64 runtime is downloaded as part of the Flatpak build sources and placed in `main/materialious/electron/.electron-cache`. The [electron-builder.config.json](../materialious/electron/electron-builder.config.json) is configured to use this cache directory to avoid downloading the runtime again during the build. +- The build process is similar to [prod-desktop.yml](../.github/workflows/prod-desktop.yml), following the guidelines for [Flatpak Electron](https://docs.flatpak.org/en/latest/electron.html). + +### Android Release +Android builds are handled using the workflow [prod-android.yml](../.github/workflows/prod-android.yml). + +- After running the standard `npm install` and `npm run build` commands, we install the modules located in [nodejs-android/](../materialious/static/nodejs-android/) for [Capacitor-NodeJS](https://github.com/hampoelz/Capacitor-NodeJS). +- The `npx cap sync` command is used to synchronize with [Capacitor](https://capacitorjs.com). +- The Android build is processed using [setup-java](https://github.com/actions/setup-java/tree/v3/), followed by signing the APK with [sign-android-release](https://github.com/ilharp/sign-android-release/tree/v1.0.4). diff --git a/docs/DEV.md b/docs/DEV.md new file mode 100644 index 00000000..e3b25a80 --- /dev/null +++ b/docs/DEV.md @@ -0,0 +1,134 @@ +## Work in Progress +This documentation is under active development and subject to change. + +### Development Environment Setup + +#### Invidious Deployment +To deploy Invidious, use Docker Compose with the following configuration: + +```yaml +services: + invidious: + image: quay.io/invidious/invidious:latest + # For ARM64/AArch64 devices, uncomment the line below: + # image: quay.io/invidious/invidious:latest-arm64 + restart: unless-stopped + ports: + - "127.0.0.1:3000:3000" + environment: + # Refer to the official Invidious config for all available options: + # https://github.com/iv-org/invidious/blob/master/config/config.example.yml + INVIDIOUS_CONFIG: | + db: + dbname: invidious + user: kemal + password: kemal + host: invidious-db + port: 5432 + check_tables: true + https_only: true + external_port: 443 + use_innertube_for_captions: true + domain: invidious.localhost + hmac_key: "some-insecure-or-secure-key-for-local-development" + healthcheck: + test: wget -nv --tries=1 --spider http://127.0.0.1:3000/api/v1/trending || exit 1 + interval: 30s + timeout: 5s + retries: 2 + logging: + options: + max-size: "1G" + max-file: "4" + depends_on: + - invidious-db + + invidious-db: + image: docker.io/library/postgres:14 + restart: unless-stopped + volumes: + - postgresdata:/var/lib/postgresql/data + - ./config/sql:/config/sql + - ./docker/init-invidious-db.sh:/docker-entrypoint-initdb.d/init-invidious-db.sh + ports: + - 5432:5432 + environment: + POSTGRES_DB: invidious + POSTGRES_USER: kemal + POSTGRES_PASSWORD: kemal + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"] + +volumes: + postgresdata: +``` + +#### Caddy Configuration + +Configure Caddy for reverse proxying Invidious and Materialious with CORS headers: + +```caddy +invidious.localhost { + @cors_preflight { + method OPTIONS + } + respond @cors_preflight 204 + + header Access-Control-Allow-Credentials true + header Access-Control-Allow-Origin "https://materialious.localhost" { + defer + } + header Access-Control-Allow-Methods "GET,POST,OPTIONS,HEAD,PATCH,PUT,DELETE" + header Access-Control-Allow-Headers "User-Agent,Authorization,Content-Type" + + header /ggpht/* Cross-Origin-Resource-Policy cross-origin + + reverse_proxy localhost:3000 +} + +materialious.localhost { + reverse_proxy localhost:5173 + + header { + Cross-Origin-Opener-Policy "same-origin" + Cross-Origin-Embedder-Policy "require-corp" + } +} +``` + +#### Install Materialious + +1. Clone the Materialious repository: + + ```bash + git clone https://github.com/Materialious/Materialious.git + ``` + +2. Navigate into the project directory: + + ```bash + cd Materialious/materialious + ``` + +3. Install dependencies: + + ```bash + npm install + ``` + +4. Create a `.env` file with the following content: + + ```bash + VITE_DEFAULT_INVIDIOUS_INSTANCE="https://invidious.localhost" + ``` + +5. Start the development server: + + ```bash + npm run dev + ``` + +#### Access the Applications + +- Visit `invidious.localhost` in your browser and click "Continue." +- Visit `materialious.localhost` in your browser and click "Continue." diff --git a/flatpak/.gitignore b/flatpak/.gitignore new file mode 100644 index 00000000..9b662c53 --- /dev/null +++ b/flatpak/.gitignore @@ -0,0 +1,3 @@ +.flatpak-builder +build +builddir \ No newline at end of file diff --git a/flatpak/generated-sources.json b/flatpak/generated-sources.json new file mode 100644 index 00000000..06e2b84f --- /dev/null +++ b/flatpak/generated-sources.json @@ -0,0 +1,191 @@ +[ + { + "type": "file", + "url": "https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz", + "sha512": "13a3826919807b858399636c2fff5132a7649330c26357adbad91f95693873e01c8c3534ecf733d5f4304d7d13433f8fc6a9fd8b82f54d4dd41698e7adc0e0c4", + "dest-filename": "826919807b858399636c2fff5132a7649330c26357adbad91f95693873e01c8c3534ecf733d5f4304d7d13433f8fc6a9fd8b82f54d4dd41698e7adc0e0c4", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/13/a3" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/@types/verror/-/verror-1.10.10.tgz", + "sha512": "97830cd09a699f5f216fdc6633ac300f5b937528697fd3e7f346974d2b672b50bde20b4fbc9715d85ac399b39050041f27570a64792d910503c04a9a00a5cc32", + "dest-filename": "0cd09a699f5f216fdc6633ac300f5b937528697fd3e7f346974d2b672b50bde20b4fbc9715d85ac399b39050041f27570a64792d910503c04a9a00a5cc32", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/97/83" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "sha512": "35f27853304271018b0e542aee71f11feb6fde4c99d211d0a85e413ba27bb4d25e3f9768d6594fafc759f331e89df840bb43c701d3244a8fbca34c3183d9595b", + "dest-filename": "7853304271018b0e542aee71f11feb6fde4c99d211d0a85e413ba27bb4d25e3f9768d6594fafc759f331e89df840bb43c701d3244a8fbca34c3183d9595b", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/35/f2" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", + "sha512": "9fc7ce8b1c030fa6ff39b8a7cd3ae9d59285cdb82f299beecff4ef7a39cb9f56907c2eabe765c4c7ce459ae0bedc723e24cedca0145752f36a114d8f1d5ac7a6", + "dest-filename": "ce8b1c030fa6ff39b8a7cd3ae9d59285cdb82f299beecff4ef7a39cb9f56907c2eabe765c4c7ce459ae0bedc723e24cedca0145752f36a114d8f1d5ac7a6", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/9f/c7" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", + "sha512": "897de67e0713308ab764a2c8b151406efefe31cd7493169b00641bf07be3035a374f53c8629adb6a443ae5ddc8fb61c61edea748a90cf4f62382824ed8a70505", + "dest-filename": "e67e0713308ab764a2c8b151406efefe31cd7493169b00641bf07be3035a374f53c8629adb6a443ae5ddc8fb61c61edea748a90cf4f62382824ed8a70505", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/89/7d" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz", + "sha512": "65dce6ab02a6102396269a9e7e5a02e4e272d7e599041b1ee7e311f3ccfd83d667e1563e598524032a239a1cc97241f961b6d919c608b86024639fd8b3938cd9", + "dest-filename": "e6ab02a6102396269a9e7e5a02e4e272d7e599041b1ee7e311f3ccfd83d667e1563e598524032a239a1cc97241f961b6d919c608b86024639fd8b3938cd9", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/65/dc" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz", + "sha512": "5ab937e5ef327422838ff02b0a5a3556b3d598df33a61e55e00b47c08b8786f317b0a7fbdd44f704e0fe6b30485bedf0389e058441fbcf2689085bc286362f30", + "dest-filename": "37e5ef327422838ff02b0a5a3556b3d598df33a61e55e00b47c08b8786f317b0a7fbdd44f704e0fe6b30485bedf0389e058441fbcf2689085bc286362f30", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/5a/b9" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "sha512": "e71a037d7f9f2fb7da0139da82658fa5b16dc21fd1efb5a630caaa1c64bae42defbc1d181eb805f81d58999df8e35b4c8f99fade4d36d765cda09c339617df43", + "dest-filename": "037d7f9f2fb7da0139da82658fa5b16dc21fd1efb5a630caaa1c64bae42defbc1d181eb805f81d58999df8e35b4c8f99fade4d36d765cda09c339617df43", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/e7/1a" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", + "sha512": "4f5d2abe4c34cf3e309e6e7ad253848343e8bd5a945ee3858611c0922c70f3fb32732ed326deeffd1ae410a1109c0c36be23d226eea202412bc67cd1d20f0fa5", + "dest-filename": "2abe4c34cf3e309e6e7ad253848343e8bd5a945ee3858611c0922c70f3fb32732ed326deeffd1ae410a1109c0c36be23d226eea202412bc67cd1d20f0fa5", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/4f/5d" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", + "sha512": "89b3cade203ebda6357848c44a442433405b0aa14e6993225d14ed741d2eedbe1d8ed63a267b23bcf7541d5320eb142ddc1f1fa534d61c8f40f800e333d7ebce", + "dest-filename": "cade203ebda6357848c44a442433405b0aa14e6993225d14ed741d2eedbe1d8ed63a267b23bcf7541d5320eb142ddc1f1fa534d61c8f40f800e333d7ebce", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/89/b3" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", + "sha512": "a52cafedb4930bb8a0f437206f0f40b913546f993957aa03b9d8d9a0c052af5deaa4b046eed07ece00a40118eaef121481dcf93f541ef2efab486768b8e388c9", + "dest-filename": "afedb4930bb8a0f437206f0f40b913546f993957aa03b9d8d9a0c052af5deaa4b046eed07ece00a40118eaef121481dcf93f541ef2efab486768b8e388c9", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/a5/2c" + }, + { + "type": "file", + "url": "https://registry.npmjs.org/verror/-/verror-1.10.1.tgz", + "sha512": "bdeb9f726c6b8b87b75d2ad3d31c1f511ee482e2246b105ea2c0e0d34c835a1938f7077091252bbefb26ee773be5ed4f532bc87998fa9d2f15411633dbf4b85e", + "dest-filename": "9f726c6b8b87b75d2ad3d31c1f511ee482e2246b105ea2c0e0d34c835a1938f7077091252bbefb26ee773be5ed4f532bc87998fa9d2f15411633dbf4b85e", + "dest": "flatpak-node/npm-cache/_cacache/content-v2/sha512/bd/eb" + }, + { + "type": "inline", + "contents": "0e40cbf9308f2e5d26a71e11a284fc81e9f61231\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz\", \"integrity\": \"sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==\", \"time\": 0, \"size\": 2915, \"metadata\": {\"url\": \"https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "a5cf38e6aac27d8eb3fdaf635d75bf88ff4a3f834e89358608c7b67cb33d", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/46/5e" + }, + { + "type": "inline", + "contents": "1d60404b3281c92034abd12e57aa0af0e64aa315\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz\", \"integrity\": \"sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==\", \"time\": 0, \"size\": 22808, \"metadata\": {\"url\": \"https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "c98f1cdf494d5afde6448966f8b5b9ae83d1b42c6702670e15e8a7f68552", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/49/61" + }, + { + "type": "inline", + "contents": "33d1cf24d9a5d9535b6ff1f64b0b5ac9caad0e41\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz\", \"integrity\": \"sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==\", \"time\": 0, \"size\": 3513, \"metadata\": {\"url\": \"https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "4ea6b895c004375f7977d61af095ceeb988964d34da00eb00e2b1cdaa8b6", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/9b/8d" + }, + { + "type": "inline", + "contents": "443377582687c1fe1f77f7b2103e349ed7be2fab\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz\", \"integrity\": \"sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==\", \"time\": 0, \"size\": 143727, \"metadata\": {\"url\": \"https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "40d05a0809760934aebff4c68bc3fd6fb716050dc3e9d5db8756b58a6015", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/b7/b6" + }, + { + "type": "inline", + "contents": "59b3793089a7ffc915399b9b37856c79b865b6db\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/@types/verror/-/verror-1.10.10.tgz\", \"integrity\": \"sha512-l4MM0Jppn18hb9xmM6wwD1uTdShpf9Pn80aXTStnK1C94gtPvJcV2FrDmbOQUAQfJ1cKZHktkQUDwEqaAKXMMg==\", \"time\": 0, \"size\": 2512, \"metadata\": {\"url\": \"https://registry.npmjs.org/@types/verror/-/verror-1.10.10.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "3566db5ab32a9c07496acfa437f7157884ad48d9b5b195ec8315d5042d57", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/07/1d" + }, + { + "type": "inline", + "contents": "6fd8c9fd05891d4503a9d1422f58af31c33e8886\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/verror/-/verror-1.10.1.tgz\", \"integrity\": \"sha512-veufcmxri4e3XSrT0xwfUR7kguIkaxBeosDg00yDWhk49wdwkSUrvvsm7nc75e1PUyvIeZj6nS8VQRYz2/S4Xg==\", \"time\": 0, \"size\": 12165, \"metadata\": {\"url\": \"https://registry.npmjs.org/verror/-/verror-1.10.1.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "d9fc26bbcb7f0d38511edac0ccf198e19a8ab1c6ead330b4e6c1c014fb3f", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/31/ad" + }, + { + "type": "inline", + "contents": "927ac8ab5aca4cf1a40e924e2c16bccc771200d9\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/crc/-/crc-3.8.0.tgz\", \"integrity\": \"sha512-iX3mfgcTMIq3ZKLIsVFAbv7+Mc10kxabAGQb8HvjA1o3T1PIYprbakQ65d3I+2HGHt6nSKkM9PYjgoJO2KcFBQ==\", \"time\": 0, \"size\": 19779, \"metadata\": {\"url\": \"https://registry.npmjs.org/crc/-/crc-3.8.0.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "1c157566e92c1b79d308dc8695d30a603a7a56743acc66e98f644de69286", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/e8/be" + }, + { + "type": "inline", + "contents": "ae24fe580c7218ee63fcc86476862a5db5aa98e8\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz\", \"integrity\": \"sha512-T10qvkw0zz4wnm560lOEg0PovVqUXuOFhhHAkixw8/sycy7TJt7v/RrkEKEQnAw2viPSJu6iAkErxnzR0g8PpQ==\", \"time\": 0, \"size\": 65652, \"metadata\": {\"url\": \"https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "0344c53990466cd8be074a97a885eb0d582fa6f17493f9c2d4b391dda9b6", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/c9/65" + }, + { + "type": "inline", + "contents": "af2f68536060cfd4de974c7e8a56e67964d9f47f\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz\", \"integrity\": \"sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==\", \"time\": 0, \"size\": 3943, \"metadata\": {\"url\": \"https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "319d4064e5cc0deeb236be141e51d18aab0148cb9c7f5794a23936482b09", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/79/e6" + }, + { + "type": "inline", + "contents": "ccf2abb094c4a3a6e197e833c5721d45d856cbbf\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz\", \"integrity\": \"sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==\", \"time\": 0, \"size\": 10978, \"metadata\": {\"url\": \"https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "f9db367edb8f679b11df27b48c582195f79a39a7fece0603ce62a83e26a3", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/b9/1b" + }, + { + "type": "inline", + "contents": "fbbfb091d6d10a4c45453b4df079a750343dd4b1\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz\", \"integrity\": \"sha512-ZdzmqwKmECOWJpqefloC5OJy1+WZBBse5+MR88z9g9Zn4VY+WYUkAyojmhzJckH5YbbZGcYIuGAkY5/Ys5OM2Q==\", \"time\": 0, \"size\": 24561, \"metadata\": {\"url\": \"https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "81e485a43a0d0f46a5fb3aa04dfc18172be68dc872f60402b3933b26db82", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/36/47" + }, + { + "type": "inline", + "contents": "fc73d5c63c85bb39c4dfa330ce4ea29474d5a051\t{\"key\": \"make-fetch-happen:request-cache:https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz\", \"integrity\": \"sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==\", \"time\": 0, \"size\": 1839, \"metadata\": {\"url\": \"https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz\", \"reqHeaders\": {}, \"resHeaders\": {}}}", + "dest-filename": "6fcdb3d537b07f9252dd4a18dc9af81590673f266dd581e7d1e3aabf87c9", + "dest": "flatpak-node/npm-cache/_cacache/index-v5/db/81" + }, + { + "type": "script", + "commands": [], + "dest-filename": "electron.sh", + "dest": "flatpak-node/patch" + }, + { + "type": "script", + "commands": [ + "$FLATPAK_BUILDER_BUILDDIR/flatpak-node/patch/electron.sh" + ], + "dest-filename": "patch-all.sh", + "dest": "flatpak-node" + }, + { + "type": "script", + "commands": [ + "version=$(node --version | sed \"s/^v//\")", + "nodedir=$(dirname \"$(dirname \"$(which node)\")\")", + "mkdir -p \"flatpak-node/cache/node-gyp/$version\"", + "ln -s \"$nodedir/include\" \"flatpak-node/cache/node-gyp/$version/include\"", + "echo 9 > \"flatpak-node/cache/node-gyp/$version/installVersion\"" + ], + "dest-filename": "setup_sdk_node_headers.sh", + "dest": "flatpak-node" + }, + { + "type": "shell", + "commands": [ + "FLATPAK_BUILDER_BUILDDIR=$PWD flatpak-node/patch-all.sh", + "bash flatpak-node/setup_sdk_node_headers.sh" + ] + } +] \ No newline at end of file diff --git a/flatpak/us.materialio.app.json b/flatpak/us.materialio.app.json new file mode 100644 index 00000000..91ebfc60 --- /dev/null +++ b/flatpak/us.materialio.app.json @@ -0,0 +1,65 @@ +{ + "app-id": "us.materialio.app", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "base": "org.electronjs.Electron2.BaseApp", + "base-version": "23.08", + "command": "run.sh", + "finish-args": [ + "--share=ipc", + "--socket=x11", + "--socket=pulseaudio", + "--share=network" + ], + "sdk-extensions": [ + "org.freedesktop.Sdk.Extension.node20" + ], + "build-options": { + "append-path": "/usr/lib/sdk/node20/bin", + "env": { + "XDG_CACHE_HOME": "/run/build/materialious-app/flatpak-node/cache", + "npm_config_cache": "/run/build/materialious-app/flatpak-node/npm-cache", + "npm_config_nodedir": "/usr/lib/sdk/node20", + "npm_config_offline": true + } + }, + "modules": [ + { + "name": "materialious-app", + "buildsystem": "simple", + "build-commands": [ + "cd ./main/materialious && npm install --offline", + "cd ./main/materialious && npm run build", + "cd ./main/materialious && npx cap sync @capacitor-community/electron", + "cd ./main/materialious/electron && python patch_capacitor_plugin.py", + "cd ./main/materialious/electron && npm install --offline", + "cd ./main/materialious/electron && npm run electron:pack", + "cp -a ./main/materialious/electron/dist/linux-unpacked /app/main", + "install -Dm755 -t /app/bin ./run.sh" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/Materialious/Materialious.git", + "dest": "main", + "branch": "main" + }, + { + "type": "script", + "dest-filename": "run.sh", + "commands": [ + "zypak-wrapper.sh /app/main/materialious \"$@\"" + ] + }, + { + "type": "archive", + "url": "https://github.com/electron/electron/releases/download/v33.0.2/electron-v33.0.2-linux-x64.zip", + "sha256": "933dc1eae3f2db67912b3ab056fd15a7ca3e1328fe8dd6a1f5266c5a063b1121", + "dest": "main/materialious/electron/.electron-cache" + }, + "generated-sources.json" + ] + } + ] +} \ No newline at end of file diff --git a/materialious/.gitignore b/materialious/.gitignore index a261d8de..45951eb3 100644 --- a/materialious/.gitignore +++ b/materialious/.gitignore @@ -5,7 +5,6 @@ node_modules /package # Lock files of most package managers bun.lockb -package-lock.json pnpm-lock.yaml yarn.lock .env @@ -15,4 +14,4 @@ vite.config.js.timestamp-* vite.config.ts.timestamp-* resources/android/**/* android/release.jks* -!static/nodejs-android/package-lock.json \ No newline at end of file +.electron-cache \ No newline at end of file diff --git a/materialious/README.md b/materialious/README.md deleted file mode 100644 index 5ce67661..00000000 --- a/materialious/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# create-svelte - -Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte). - -## Creating a project - -If you're seeing this, you've probably already done this step. Congrats! - -```bash -# create a new project in the current directory -npm create svelte@latest - -# create a new project in my-app -npm create svelte@latest my-app -``` - -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: - -```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open -``` - -## Building - -To create a production version of your app: - -```bash -npm run build -``` - -You can preview the production build with `npm run preview`. - -> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. diff --git a/materialious/android/app/build.gradle b/materialious/android/app/build.gradle index a5620235..1a5b7987 100644 --- a/materialious/android/app/build.gradle +++ b/materialious/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "us.materialio.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 66 - versionName "1.6.15" + versionCode 67 + versionName "1.6.16" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. @@ -37,6 +37,7 @@ dependencies { implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" implementation project(':capacitor-android') testImplementation "junit:junit:$junitVersion" + implementation 'com.google.android.material:material:1.12.0' androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" implementation project(':capacitor-cordova-android-plugins') diff --git a/materialious/android/app/src/main/java/us/materialio/app/ColorTheme.java b/materialious/android/app/src/main/java/us/materialio/app/ColorTheme.java new file mode 100644 index 00000000..abd91466 --- /dev/null +++ b/materialious/android/app/src/main/java/us/materialio/app/ColorTheme.java @@ -0,0 +1,47 @@ +package us.materialio.app; + +import android.content.Context; +import android.content.res.TypedArray; + +import com.getcapacitor.annotation.CapacitorPlugin; +import com.getcapacitor.PluginMethod; +import com.getcapacitor.PluginCall; +import com.getcapacitor.Plugin; +import com.getcapacitor.JSObject; +import com.google.android.material.color.DynamicColors; + +@CapacitorPlugin(name = "ColorTheme") +public class ColorTheme extends Plugin { + @PluginMethod() + public void getColorPalette(PluginCall call) { + JSObject colorPalette = new JSObject(); + + if (DynamicColors.isDynamicColorAvailable()) { + Context dynamicColorContext = DynamicColors.wrapContextIfAvailable(getContext(), com.google.android.material.R.style.ThemeOverlay_Material3_DynamicColors_DayNight); + + int[] attrsToResolve = { + com.google.android.material.R.attr.colorPrimary, + com.google.android.material.R.attr.colorOnPrimary, + com.google.android.material.R.attr.colorSecondary, + com.google.android.material.R.attr.colorAccent + }; + + try { + TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve); + + colorPalette.put("primary", ta.getColor(0,0)); + colorPalette.put("onPrimary", ta.getColor(1,0)); + colorPalette.put("secondary", ta.getColor(2,0)); + colorPalette.put("accent", ta.getColor(3,0)); + + ta.recycle(); + + call.resolve(colorPalette); + } catch (Exception e) { + call.reject("Unable to fetch dynamic color"); + } + } else { + call.reject("Dynamic color not available"); + } + } +} diff --git a/materialious/android/app/src/main/java/us/materialio/app/MainActivity.java b/materialious/android/app/src/main/java/us/materialio/app/MainActivity.java index 9171d44e..feee75e4 100644 --- a/materialious/android/app/src/main/java/us/materialio/app/MainActivity.java +++ b/materialious/android/app/src/main/java/us/materialio/app/MainActivity.java @@ -1,5 +1,13 @@ package us.materialio.app; +import android.os.Bundle; + import com.getcapacitor.BridgeActivity; -public class MainActivity extends BridgeActivity {} +public class MainActivity extends BridgeActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + registerPlugin(ColorTheme.class); + super.onCreate(savedInstanceState); + } +} diff --git a/materialious/android/app/src/main/res/values/styles.xml b/materialious/android/app/src/main/res/values/styles.xml index be874e54..e07ee615 100644 --- a/materialious/android/app/src/main/res/values/styles.xml +++ b/materialious/android/app/src/main/res/values/styles.xml @@ -2,11 +2,7 @@ -