Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie-XIAO committed Sep 1, 2024
0 parents commit 59a0e7d
Show file tree
Hide file tree
Showing 23 changed files with 1,277 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/format-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Format and Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format-and-lint:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies (Ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: ./ -> target

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Node setup and cache
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm

- name: Install frontend dependencies
run: pnpm install --frozen-lockfile

- name: Check code formatting
run: pnpm format:check

- name: Check code linting
run: pnpm lint:check
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: install webkit2gtk
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.1
- uses: Swatinem/rust-cache@v2
- run: cargo test --all-targets --all-features -- -D warnings
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.vs
.DS_Store
.Thumbs.db
*.sublime*
.idea/
debug.log
package-lock.json
.vscode/settings.json
yarn.lock

/.tauri
/target
Cargo.lock
node_modules/

dist-js
dist
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
permissions/schemas/
permissions/autogenerated/
src/
pnpm-lock.yaml
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 88
}
28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "tauri-plugin-desktop-underlay"
version = "0.0.1"
authors = ["Yao Xiao <[email protected]> (https://charlie-xiao.github.io/)"]
description = "Tauri plugin for making a window a desktop underlay, as if it were a wallpaper."
edition = "2021"
exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"]
links = "tauri-plugin-desktop-underlay"

[build-dependencies]
tauri-plugin = { version = "2.0.0-rc.7", features = ["build"] }

[dependencies]
anyhow = "1.0.86"
tauri = { version = "2.0.0-rc.8" }

[target."cfg(target_os = \"linux\")".dependencies]
gtk = "0.18.1"
gdk = "0.18.0"

[target."cfg(target_os = \"macos\")".dependencies]
objc = "0.2.7"

[target."cfg(target_os = \"windows\")".dependencies]
windows = { version = "0.58.0", features = [
"Win32_UI_WindowsAndMessaging",
"Win32_Foundation"
] }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Tauri Plugin desktop-underlay
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const COMMANDS: &[&str] = &["set_desktop_underlay"];

fn main() {
tauri_plugin::Builder::new(COMMANDS).build();
}
12 changes: 12 additions & 0 deletions guest-js/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { invoke } from "@tauri-apps/api/core";

/**
* Determines if the window should be a desktop underlay.
*
* @param desktopUnderlay Whether the window should be a desktop underlay.
*/
export async function setDesktopUnderlay(desktopUnderlay: boolean): Promise<void> {
return await invoke<void>("plugin:desktop-underlay|set_desktop_underlay", {
desktopUnderlay,
});
}
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "tauri-plugin-desktop-underlay-api",
"version": "0.0.1",
"author": "Yao Xiao <[email protected]>",
"description": "Tauri plugin for making a window a desktop underlay, as if it were a wallpaper.",
"type": "module",
"types": "./dist-js/index.d.ts",
"main": "./dist-js/index.cjs",
"module": "./dist-js/index.js",
"exports": {
"types": "./dist-js/index.d.ts",
"import": "./dist-js/index.js",
"require": "./dist-js/index.cjs"
},
"files": [
"dist-js",
"README.md"
],
"scripts": {
"prepublishOnly": "pnpm build",
"pretest": "pnpm build",
"tauri": "tauri",
"build": "rollup -c",
"format": "prettier --write . && cargo fmt",
"format:check": "prettier --check . && cargo fmt -- --check",
"lint": "cargo clippy --fix --allow-dirty --allow-staged -- -D warnings",
"lint:check": "cargo clippy -- -D warnings"
},
"dependencies": {
"@tauri-apps/api": "^2.0.0-rc.4"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"@tauri-apps/cli": "^2.0.0-rc.8",
"prettier": "^3.3.3",
"rollup": "^4.21.2",
"tslib": "^2.7.0",
"typescript": "^5.5.4"
}
}
13 changes: 13 additions & 0 deletions permissions/autogenerated/commands/set_desktop_underlay.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!

"$schema" = "../../schemas/schema.json"

[[permission]]
identifier = "allow-set-desktop-underlay"
description = "Enables the set_desktop_underlay command without any pre-configured scope."
commands.allow = ["set_desktop_underlay"]

[[permission]]
identifier = "deny-set-desktop-underlay"
description = "Denies the set_desktop_underlay command without any pre-configured scope."
commands.deny = ["set_desktop_underlay"]
41 changes: 41 additions & 0 deletions permissions/autogenerated/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Default Permission

Default permissions for the plugin.

- `allow-desktop-underlay`

## Permission Table

<table>
<tr>
<th>Identifier</th>
<th>Description</th>
</tr>


<tr>
<td>

`desktop-underlay:allow-set-desktop-underlay`

</td>
<td>

Enables the set_desktop_underlay command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`desktop-underlay:deny-set-desktop-underlay`

</td>
<td>

Denies the set_desktop_underlay command without any pre-configured scope.

</td>
</tr>
</table>
3 changes: 3 additions & 0 deletions permissions/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default]
description = "Default permissions for the plugin."
permissions = ["allow-desktop-underlay"]
Loading

0 comments on commit 59a0e7d

Please sign in to comment.