Skip to content

Commit

Permalink
lint and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Aug 29, 2023
1 parent 2bd395e commit cff777d
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 77 deletions.
4 changes: 4 additions & 0 deletions core/tauri-macros/src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::{
Expand Down
19 changes: 10 additions & 9 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ use std::{
fmt,
ops::Deref,
path::PathBuf,
rc::Rc,
sync::{
mpsc::{channel, Sender},
Arc, Mutex, Weak,
Expand Down Expand Up @@ -227,7 +228,7 @@ impl<T: UserEvent> Context<T> {
pub struct DispatcherMainThreadContext<T: UserEvent> {
pub window_target: EventLoopWindowTarget<Message<T>>,
pub web_context: WebContextStore,
pub windows: Arc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
pub windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
}

impl<T: UserEvent> std::fmt::Debug for DispatcherMainThreadContext<T> {
Expand Down Expand Up @@ -1544,7 +1545,7 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
#[derive(Clone)]
enum WindowHandle {
Webview {
inner: Arc<WebView>,
inner: Rc<WebView>,
context_store: WebContextStore,
// the key of the WebContext if it's not shared
context_key: Option<PathBuf>,
Expand All @@ -1560,7 +1561,7 @@ impl Drop for WindowHandle {
context_key,
} = self
{
if Arc::get_mut(inner).is_some() {
if Rc::get_mut(inner).is_some() {
context_store.lock().unwrap().remove(context_key);
}
}
Expand Down Expand Up @@ -1816,7 +1817,7 @@ impl<T: UserEvent> Wry<T> {
let main_thread_id = current_thread().id();
let web_context = WebContextStore::default();

let windows = Arc::new(RefCell::new(HashMap::default()));
let windows = Rc::new(RefCell::new(HashMap::default()));
let webview_id_map = WebviewIdStore::default();

let context = Context {
Expand Down Expand Up @@ -2056,11 +2057,11 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
pub struct EventLoopIterationContext<'a, T: UserEvent> {
pub callback: &'a mut (dyn FnMut(RunEvent<T>) + 'static),
pub webview_id_map: WebviewIdStore,
pub windows: Arc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
pub windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
}

struct UserMessageContext {
windows: Arc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
webview_id_map: WebviewIdStore,
}

Expand Down Expand Up @@ -2529,7 +2530,7 @@ fn handle_event_loop<T: UserEvent>(
fn on_close_requested<'a, T: UserEvent>(
callback: &'a mut (dyn FnMut(RunEvent<T>) + 'static),
window_id: WebviewId,
windows: Arc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>,
) {
let (tx, rx) = channel();
let windows_ref = windows.borrow();
Expand Down Expand Up @@ -2557,7 +2558,7 @@ fn on_close_requested<'a, T: UserEvent>(
}
}

fn on_window_close(window_id: WebviewId, windows: Arc<RefCell<HashMap<WebviewId, WindowWrapper>>>) {
fn on_window_close(window_id: WebviewId, windows: Rc<RefCell<HashMap<WebviewId, WindowWrapper>>>) {
if let Some(window_wrapper) = windows.borrow_mut().get_mut(&window_id) {
window_wrapper.inner = None;
}
Expand Down Expand Up @@ -2803,7 +2804,7 @@ fn create_webview<T: UserEvent, F: Fn(RawWindow) + Send + 'static>(
Ok(WindowWrapper {
label,
inner: Some(WindowHandle::Webview {
inner: Arc::new(webview),
inner: Rc::new(webview),
context_store: web_context_store.clone(),
context_key: if automation_enabled {
None
Expand Down
4 changes: 2 additions & 2 deletions core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ png = { version = "0.17", optional = true }
ico = { version = "0.3.0", optional = true }

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
muda = { version = "0.8", default-features = false, features = [ "serde" ]}
tray-icon = { version = "0.8", default-features = false, features = [ "serde" ], optional = true }
muda = { path = "../../../muda", default-features = false, features = [ "serde" ]}
tray-icon = { path = "../../../tray-icon", default-features = false, features = [ "serde" ], optional = true }

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
gtk = { version = "0.16", features = [ "v3_24" ] }
Expand Down
1 change: 1 addition & 0 deletions core/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ macro_rules! run_main_thread {
let (tx, rx) = channel();
let self_ = $self.clone();
let task = move || {
#[allow(clippy::redundant_closure_call)]
let _ = tx.send($ex(self_));
};
$self.app_handle.run_on_main_thread(Box::new(task))?;
Expand Down
3 changes: 2 additions & 1 deletion core/tauri/src/menu/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl From<AboutMetadata> for super::AboutMetadata {
}
}

#[allow(clippy::large_enum_variant)]
#[derive(Deserialize)]
enum Predefined {
Separator,
Expand Down Expand Up @@ -202,7 +203,7 @@ fn new<R: Runtime>(
builder = builder.enabled(enabled);
}
if let Some(native_icon) = options.native_icon {
builder = builder.native_icon(native_icon.into());
builder = builder.native_icon(native_icon);
}
if let Some(icon) = options.icon {
builder = builder.icon(icon.into());
Expand Down
4 changes: 4 additions & 0 deletions core/tauri/src/resources/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use crate::{
command,
plugin::{Builder, TauriPlugin},
Expand Down
4 changes: 4 additions & 0 deletions examples/api/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

/// <reference types="svelte" />
/// <reference types="vite/client" />
6 changes: 5 additions & 1 deletion examples/api/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'

export default {
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
// for more information about preprocessors
preprocess: vitePreprocess(),
preprocess: vitePreprocess()
}
16 changes: 12 additions & 4 deletions tooling/api/src/internal/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

import { invoke } from '../tauri'

/**
Expand All @@ -22,24 +26,28 @@ export class Resource {
* Destroys and cleans up this resource from memory.
* **You should not call any method on this object anymore and should drop any reference to it.**
*/
async close() {
async close(): Promise<void> {
return invoke('plugin:resources|close', {
rid: this.rid
})
}
}

/** Extends a base class by other specifed classes */
export function applyMixins(baseClass: any, extendedClasses: any | any[]) {
export function applyMixins(
baseClass: { prototype: any },
extendedClasses: any | any[]
): void {
;(Array.isArray(extendedClasses)
? extendedClasses
: [extendedClasses]
).forEach((extendedClass) => {
).forEach((extendedClass: { prototype: any }) => {
Object.getOwnPropertyNames(extendedClass.prototype).forEach((name) => {
Object.defineProperty(
baseClass.prototype,
name,
Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ||
// eslint-disable-next-line
Object.getOwnPropertyDescriptor(extendedClass.prototype, name) ??
Object.create(null)
)
})
Expand Down
Loading

0 comments on commit cff777d

Please sign in to comment.