commit
fad6edab71
@ -0,0 +1,159 @@
|
||||
{
|
||||
"gitSiteUrl": "https://github.com/tauri-apps/plugins-workspace/",
|
||||
"pkgManagers": {
|
||||
"javascript": {
|
||||
"version": true,
|
||||
"getPublishedVersion": "pnpm view ${ pkgFile.pkg.name } version",
|
||||
"publish": ["pnpm build", "pnpm publish --access public --no-git-checks"]
|
||||
},
|
||||
"rust": {
|
||||
"version": true,
|
||||
"getPublishedVersion": "cargo search ${ pkgFile.pkg.package.name } --limit 1 | sed -nE 's/^[^\"]*\"//; s/\".*//1p' -",
|
||||
"publish": [
|
||||
{
|
||||
"command": "cargo package --no-verify",
|
||||
"dryRunCommand": true
|
||||
},
|
||||
{
|
||||
"command": "echo '<details>\n<summary><em><h4>Cargo Publish</h4></em></summary>\n\n```'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "cargo publish",
|
||||
"dryRunCommand": "cargo publish --dry-run",
|
||||
"pipe": true
|
||||
},
|
||||
{
|
||||
"command": "echo '```\n\n</details>\n'",
|
||||
"dryRunCommand": true,
|
||||
"pipe": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"packages": {
|
||||
"authenticator": {
|
||||
"path": "./plugins/authenticator",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"authenticator-js": {
|
||||
"path": "./plugins/authenticator",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"autostart": {
|
||||
"path": "./plugins/autostart",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"autostart-js": {
|
||||
"path": "./plugins/autostart",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"fs-extra": {
|
||||
"path": "./plugins/fs-extra",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"fs-extra-js": {
|
||||
"path": "./plugins/fs-extra",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"fs-watch": {
|
||||
"path": "./plugins/fs-watch",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"fs-watch-js": {
|
||||
"path": "./plugins/fs-watch",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"localhost": {
|
||||
"path": "./plugins/localhost",
|
||||
"manager": "rust"
|
||||
},
|
||||
|
||||
"log": {
|
||||
"path": "./plugins/log",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"log-js": {
|
||||
"path": "./plugins/log",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"persisted-scope": {
|
||||
"path": "./plugins/persisted-scope",
|
||||
"manager": "rust"
|
||||
},
|
||||
|
||||
"positioner": {
|
||||
"path": "./plugins/positioner",
|
||||
"manager": "rust"
|
||||
},
|
||||
"positioner-js": {
|
||||
"path": "./plugins/positioner",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"single-instance": {
|
||||
"path": "./plugins/single-instance",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
|
||||
"sql": {
|
||||
"path": "./plugins/sql",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"sql-js": {
|
||||
"path": "./plugins/sql",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"store": {
|
||||
"path": "./plugins/store",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"store-js": {
|
||||
"path": "./plugins/store",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"stronghold": {
|
||||
"path": "./plugins/stronghold",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"stronghold-js": {
|
||||
"path": "./plugins/stronghold",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"upload": {
|
||||
"path": "./plugins/upload",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"upload-js": {
|
||||
"path": "./plugins/upload",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"websocket": {
|
||||
"path": "./plugins/websocket",
|
||||
"manager": "rust-disabled"
|
||||
},
|
||||
"websocket-js": {
|
||||
"path": "./plugins/websocket",
|
||||
"manager": "javascript-disabled"
|
||||
},
|
||||
|
||||
"window-state": {
|
||||
"path": "./plugins/window-state",
|
||||
"manager": "rust"
|
||||
},
|
||||
"window-state-js": {
|
||||
"path": "./plugins/window-state",
|
||||
"manager": "javascript-disabled"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
persisted-scope: patch
|
||||
---
|
||||
|
||||
Recursively unescape saved patterns before allowing/forbidding them. This effectively prevents `.persisted-scope` files from blowing up, which caused Out-Of-Memory issues, while automatically fixing existing broken files seamlessly.
|
@ -0,0 +1,30 @@
|
||||
# Changes
|
||||
|
||||
##### via https://github.com/jbolda/covector
|
||||
|
||||
As you create PRs and make changes that require a version bump, please add a new markdown file in this folder. You do not note the version _number_, but rather the type of bump that you expect: major, minor, or patch. The filename is not important, as long as it is a `.md`, but we recommend that it represents the overall change for organizational purposes.
|
||||
|
||||
When you select the version bump required, you do _not_ need to consider dependencies. Only note the package with the actual change, and any packages that depend on that package will be bumped automatically in the process.
|
||||
|
||||
Use the following format:
|
||||
|
||||
```md
|
||||
---
|
||||
"package-a": patch
|
||||
"package-b": minor
|
||||
---
|
||||
|
||||
Change summary goes here
|
||||
```
|
||||
|
||||
Summaries do not have a specific character limit, but are text only. These summaries are used within the (future implementation of) changelogs. They will give context to the change and also point back to the original PR if more details and context are needed.
|
||||
|
||||
Changes will be designated as a `major`, `minor` or `patch` as further described in [semver](https://semver.org/).
|
||||
|
||||
Given a version number MAJOR.MINOR.PATCH, increment the:
|
||||
|
||||
- MAJOR version when you make incompatible API changes,
|
||||
- MINOR version when you add functionality in a backwards compatible manner, and
|
||||
- PATCH version when you make backwards compatible bug fixes.
|
||||
|
||||
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format, but will be discussed prior to usage (as extra steps will be necessary in consideration of merging and publishing).
|
@ -0,0 +1,16 @@
|
||||
name: covector status
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
covector:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # required for use of git history
|
||||
- name: covector status
|
||||
uses: jbolda/covector/packages/action@covector-v0.8
|
||||
id: covector
|
||||
with:
|
||||
command: "status"
|
@ -0,0 +1,59 @@
|
||||
name: version or publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
version-or-publish:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 65
|
||||
outputs:
|
||||
change: ${{ steps.covector.outputs.change }}
|
||||
commandRan: ${{ steps.covector.outputs.commandRan }}
|
||||
successfulPublish: ${{ steps.covector.outputs.successfulPublish }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # required for use of git history
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "lts/*"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 7.x.x
|
||||
run_install: true
|
||||
|
||||
- name: cargo login
|
||||
run: cargo login ${{ secrets.ORG_CRATES_IO_TOKEN }}
|
||||
|
||||
- name: git config
|
||||
run: |
|
||||
git config --global user.name "${{ github.event.pusher.name }}"
|
||||
git config --global user.email "${{ github.event.pusher.email }}"
|
||||
|
||||
- name: covector version or publish (publish when no change files present)
|
||||
uses: jbolda/covector/packages/action@covector-v0.8
|
||||
id: covector
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: "version-or-publish"
|
||||
createRelease: true
|
||||
|
||||
- name: Create Pull Request With Versions Bumped
|
||||
id: cpr
|
||||
uses: tauri-apps/create-pull-request@v3
|
||||
if: steps.covector.outputs.commandRan == 'version'
|
||||
with:
|
||||
title: "Publish New Versions"
|
||||
commit-message: "publish new versions"
|
||||
labels: "version updates"
|
||||
branch: "release"
|
||||
body: ${{ steps.covector.outputs.change }}
|
@ -0,0 +1,53 @@
|
||||
name: Check MSRV
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- ".github/workflows/msrv-check.yml"
|
||||
- "plugins/*/src/**"
|
||||
- "**/Cargo.toml"
|
||||
- "**/Cargo.lock"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- ".github/workflows/msrv-check.yml"
|
||||
- "plugins/*/src/**"
|
||||
- "**/Cargo.toml"
|
||||
- "**/Cargo.lock"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
msrv:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: install webkit2gtk and libudev for [authenticator]
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y webkit2gtk-4.0 libudev-dev
|
||||
|
||||
- uses: dtolnay/rust-toolchain@1.64.0
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: build
|
||||
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features
|
||||
|
||||
- name: build sql:sqlite
|
||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite
|
||||
|
||||
- name: build sql:mysql
|
||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql
|
||||
|
||||
- name: build sql:postgres
|
||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres
|
@ -0,0 +1,15 @@
|
||||
#[cfg(feature = "mysql")]
|
||||
mod mysql;
|
||||
#[cfg(feature = "postgres")]
|
||||
mod postgres;
|
||||
#[cfg(feature = "sqlite")]
|
||||
mod sqlite;
|
||||
|
||||
#[cfg(feature = "mysql")]
|
||||
pub(crate) use mysql::to_json;
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
pub(crate) use postgres::to_json;
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
pub(crate) use sqlite::to_json;
|
@ -0,0 +1,90 @@
|
||||
use serde_json::Value as JsonValue;
|
||||
use sqlx::{mysql::MySqlValueRef, TypeInfo, Value, ValueRef};
|
||||
use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};
|
||||
|
||||
use crate::Error;
|
||||
|
||||
pub(crate) fn to_json(v: MySqlValueRef) -> Result<JsonValue, Error> {
|
||||
if v.is_null() {
|
||||
return Ok(JsonValue::Null);
|
||||
}
|
||||
|
||||
let res = match v.type_info().name() {
|
||||
"CHAR" | "VARCHAR" | "TINYTEXT" | "TEXT" | "MEDIUMTEXT" | "LONGTEXT" | "ENUM" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode() {
|
||||
JsonValue::String(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"FLOAT" | "DOUBLE" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<f64>() {
|
||||
JsonValue::from(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TINYINT" | "SMALLINT" | "INT" | "MEDIUMINT" | "BIGINT" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<i64>() {
|
||||
JsonValue::Number(v.into())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TINYINT UNSIGNED" | "SMALLINT UNSIGNED" | "INT UNSIGNED" | "MEDIUMINT UNSIGNED"
|
||||
| "BIGINT UNSIGNED" | "YEAR" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<u64>() {
|
||||
JsonValue::Number(v.into())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"BOOLEAN" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode() {
|
||||
JsonValue::Bool(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"DATE" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Date>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIME" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Time>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"DATETIME" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<PrimitiveDateTime>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIMESTAMP" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<OffsetDateTime>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"JSON" => ValueRef::to_owned(&v).try_decode().unwrap_or_default(),
|
||||
"TINIYBLOB" | "MEDIUMBLOB" | "BLOB" | "LONGBLOB" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Vec<u8>>() {
|
||||
JsonValue::Array(v.into_iter().map(|n| JsonValue::Number(n.into())).collect())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"NULL" => JsonValue::Null,
|
||||
_ => return Err(Error::UnsupportedDatatype(v.type_info().name().to_string())),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
use serde_json::Value as JsonValue;
|
||||
use sqlx::{postgres::PgValueRef, TypeInfo, Value, ValueRef};
|
||||
use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};
|
||||
|
||||
use crate::Error;
|
||||
|
||||
pub(crate) fn to_json(v: PgValueRef) -> Result<JsonValue, Error> {
|
||||
if v.is_null() {
|
||||
return Ok(JsonValue::Null);
|
||||
}
|
||||
|
||||
let res = match v.type_info().name() {
|
||||
"CHAR" | "VARCHAR" | "TEXT" | "NAME" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode() {
|
||||
JsonValue::String(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"FLOAT4" | "FLOAT8" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<f64>() {
|
||||
JsonValue::from(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"INT2" | "INT4" | "INT8" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<i64>() {
|
||||
JsonValue::Number(v.into())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"BOOL" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode() {
|
||||
JsonValue::Bool(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"DATE" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Date>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIME" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Time>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIMESTAMP" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<PrimitiveDateTime>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIMESTAMPTZ" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<OffsetDateTime>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"JSON" | "JSONB" => ValueRef::to_owned(&v).try_decode().unwrap_or_default(),
|
||||
"BYTEA" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Vec<u8>>() {
|
||||
JsonValue::Array(v.into_iter().map(|n| JsonValue::Number(n.into())).collect())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"VOID" => JsonValue::Null,
|
||||
_ => return Err(Error::UnsupportedDatatype(v.type_info().name().to_string())),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
use serde_json::Value as JsonValue;
|
||||
use sqlx::{sqlite::SqliteValueRef, TypeInfo, Value, ValueRef};
|
||||
use time::{Date, PrimitiveDateTime, Time};
|
||||
|
||||
use crate::Error;
|
||||
|
||||
pub(crate) fn to_json(v: SqliteValueRef) -> Result<JsonValue, Error> {
|
||||
if v.is_null() {
|
||||
return Ok(JsonValue::Null);
|
||||
}
|
||||
|
||||
let res = match v.type_info().name() {
|
||||
"TEXT" => {
|
||||
if let Ok(v) = v.to_owned().try_decode() {
|
||||
JsonValue::String(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"REAL" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<f64>() {
|
||||
JsonValue::from(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"INTEGER" | "NUMERIC" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<i64>() {
|
||||
JsonValue::Number(v.into())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"BOOLEAN" => {
|
||||
if let Ok(v) = v.to_owned().try_decode() {
|
||||
JsonValue::Bool(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"DATE" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<Date>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"TIME" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<Time>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"DATETIME" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<PrimitiveDateTime>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"BLOB" => {
|
||||
if let Ok(v) = v.to_owned().try_decode::<Vec<u8>>() {
|
||||
JsonValue::Array(v.into_iter().map(|n| JsonValue::Number(n.into())).collect())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"NULL" => JsonValue::Null,
|
||||
_ => return Err(Error::UnsupportedDatatype(v.type_info().name().to_string())),
|
||||
};
|
||||
|
||||
Ok(res)
|
||||
}
|
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,35 @@
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { WindowLabel, getCurrent } from "@tauri-apps/api/window";
|
||||
|
||||
export enum StateFlags {
|
||||
SIZE = 1 << 0,
|
||||
POSITION = 1 << 1,
|
||||
MAXIMIZED = 1 << 2,
|
||||
VISIBLE = 1 << 3,
|
||||
DECORATIONS = 1 << 4,
|
||||
FULLSCREEN = 1 << 5,
|
||||
ALL = SIZE | POSITION | MAXIMIZED | VISIBLE | DECORATIONS | FULLSCREEN,
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the state of all open windows to disk.
|
||||
*/
|
||||
async function saveWindowState(flags: StateFlags) {
|
||||
invoke("plugin:window-state|save_window_state", { flags });
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the state for the specified window from disk.
|
||||
*/
|
||||
async function restoreState(label: WindowLabel, flags: StateFlags) {
|
||||
invoke("plugin:window-state|restore_state", { label, flags });
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the state for the current window from disk.
|
||||
*/
|
||||
async function restoreStateCurrent(flags: StateFlags) {
|
||||
restoreState(getCurrent().label, flags);
|
||||
}
|
||||
|
||||
export { restoreState, restoreStateCurrent, saveWindowState };
|
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "tauri-plugin-window-state-api",
|
||||
"version": "0.0.0",
|
||||
"description": "Save window positions and sizes and restore them when the app is reopened.",
|
||||
"license": "MIT or APACHE-2.0",
|
||||
"authors": [
|
||||
"Tauri Programme within The Commons Conservancy"
|
||||
],
|
||||
"type": "module",
|
||||
"browser": "dist-js/index.min.js",
|
||||
"module": "dist-js/index.mjs",
|
||||
"types": "dist-js/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./dist-js/index.mjs",
|
||||
"types": "./dist-js/index.d.ts",
|
||||
"browser": "./dist-js/index.min.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c"
|
||||
},
|
||||
"files": [
|
||||
"dist-js",
|
||||
"!dist-js/**/*.map",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"devDependencies": {
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.2.0"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
import { createConfig } from "../../shared/rollup.config.mjs";
|
||||
|
||||
export default createConfig({
|
||||
input: "guest-js/index.ts",
|
||||
pkg: JSON.parse(
|
||||
readFileSync(new URL("./package.json", import.meta.url), "utf8")
|
||||
),
|
||||
external: [/^@tauri-apps\/api/],
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
use crate::{AppHandleExt, StateFlags, WindowExt};
|
||||
use tauri::{command, AppHandle, Manager, Runtime};
|
||||
|
||||
#[command]
|
||||
pub async fn save_window_state<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
flags: u32,
|
||||
) -> std::result::Result<(), String> {
|
||||
let flags = StateFlags::from_bits(flags)
|
||||
.ok_or_else(|| format!("Invalid state flags bits: {}", flags))?;
|
||||
app.save_window_state(flags).map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub async fn restore_state<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
label: String,
|
||||
flags: u32,
|
||||
) -> std::result::Result<(), String> {
|
||||
let flags = StateFlags::from_bits(flags)
|
||||
.ok_or_else(|| format!("Invalid state flags bits: {}", flags))?;
|
||||
app.get_window(&label)
|
||||
.ok_or_else(|| format!("Couldn't find window with label: {}", label))?
|
||||
.restore_state(flags)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
@ -0,0 +1 @@
|
||||
../../shared/tsconfig.json
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue