From 6df75089508d20c2df191a37c15b68c77ee88940 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 17 May 2023 18:39:12 -0300 Subject: [PATCH] fix fmt and lint --- examples/api/src-tauri/tauri.conf.json | 74 +++++++++---------- plugins/dialog/src/init.js | 16 ++-- plugins/shell/src/init.js | 49 ++++++------ plugins/window/guest-js/index.ts | 2 +- plugins/window/src/scripts/drag.js | 14 ++-- plugins/window/src/scripts/print.js | 4 +- plugins/window/src/scripts/toggle-devtools.js | 24 +++--- 7 files changed, 91 insertions(+), 92 deletions(-) diff --git a/examples/api/src-tauri/tauri.conf.json b/examples/api/src-tauri/tauri.conf.json index 8fd3fee4..6f5f422d 100644 --- a/examples/api/src-tauri/tauri.conf.json +++ b/examples/api/src-tauri/tauri.conf.json @@ -48,44 +48,44 @@ } }, "fs": { - "scope": { - "allow": ["$APPDATA/db/**", "$DOWNLOAD/**", "$RESOURCE/**"], - "deny": ["$APPDATA/db/*.stronghold"] - } - }, - "shell": { - "open": true, - "scope": [ - { - "name": "sh", - "cmd": "sh", - "args": [ - "-c", - { - "validator": "\\S+" - } - ] - }, - { - "name": "cmd", - "cmd": "cmd", - "args": [ - "/C", - { - "validator": "\\S+" - } - ] - } - ] - }, - "http": { - "scope": ["http://localhost:3003"] - }, - "updater": { - "endpoints": [ - "https://tauri-update-server.vercel.app/update/{{target}}/{{current_version}}" - ] + "scope": { + "allow": ["$APPDATA/db/**", "$DOWNLOAD/**", "$RESOURCE/**"], + "deny": ["$APPDATA/db/*.stronghold"] } + }, + "shell": { + "open": true, + "scope": [ + { + "name": "sh", + "cmd": "sh", + "args": [ + "-c", + { + "validator": "\\S+" + } + ] + }, + { + "name": "cmd", + "cmd": "cmd", + "args": [ + "/C", + { + "validator": "\\S+" + } + ] + } + ] + }, + "http": { + "scope": ["http://localhost:3003"] + }, + "updater": { + "endpoints": [ + "https://tauri-update-server.vercel.app/update/{{target}}/{{current_version}}" + ] + } }, "tauri": { "pattern": { diff --git a/plugins/dialog/src/init.js b/plugins/dialog/src/init.js index 79c9fd8b..62d0b82c 100644 --- a/plugins/dialog/src/init.js +++ b/plugins/dialog/src/init.js @@ -3,13 +3,13 @@ // SPDX-License-Identifier: MIT window.alert = function (message) { - window.__TAURI_INVOKE__('plugin:dialog|message', { - message: message.toString() - }) -} + window.__TAURI_INVOKE__("plugin:dialog|message", { + message: message.toString(), + }); +}; window.confirm = function (message) { - return window.__TAURI_INVOKE__('plugin:dialog|confirm', { - message: message.toString() - }) -} + return window.__TAURI_INVOKE__("plugin:dialog|confirm", { + message: message.toString(), + }); +}; diff --git a/plugins/shell/src/init.js b/plugins/shell/src/init.js index c43f7cdf..61cbe3b4 100644 --- a/plugins/shell/src/init.js +++ b/plugins/shell/src/init.js @@ -2,39 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -;(function () { +(function () { // open links with the API function openLinks() { - document.querySelector('body').addEventListener( - 'click', - function (e) { - var target = e.target - while (target != null) { - if (target.matches('a')) { - if ( - target.href && - (['http://', 'https://', 'mailto:', 'tel:'].some(v => target.href.startsWith(v))) && - target.target === '_blank' - ) { - window.__TAURI_INVOKE__('plugin:shell|open', { - path: target.href - }) - e.preventDefault() - } - break + document.querySelector("body").addEventListener("click", function (e) { + var target = e.target; + while (target != null) { + if (target.matches("a")) { + if ( + target.href && + ["http://", "https://", "mailto:", "tel:"].some((v) => + target.href.startsWith(v) + ) && + target.target === "_blank" + ) { + window.__TAURI_INVOKE__("plugin:shell|open", { + path: target.href, + }); + e.preventDefault(); } - target = target.parentElement + break; } + target = target.parentElement; } - ) + }); } if ( - document.readyState === 'complete' || - document.readyState === 'interactive' + document.readyState === "complete" || + document.readyState === "interactive" ) { - openLinks() + openLinks(); } else { - window.addEventListener('DOMContentLoaded', openLinks, true) + window.addEventListener("DOMContentLoaded", openLinks, true); } -})() +})(); diff --git a/plugins/window/guest-js/index.ts b/plugins/window/guest-js/index.ts index 59e7f77a..6a3a1585 100644 --- a/plugins/window/guest-js/index.ts +++ b/plugins/window/guest-js/index.ts @@ -319,7 +319,7 @@ class WebviewWindowHandle { /** The window label. It is a unique identifier for the window, can be used to reference it later. */ label: WindowLabel; /** Local event listeners. */ - listeners: Record>>; + listeners: Record>>; constructor(label: WindowLabel) { this.label = label; diff --git a/plugins/window/src/scripts/drag.js b/plugins/window/src/scripts/drag.js index b8abeb2c..3b227bc6 100644 --- a/plugins/window/src/scripts/drag.js +++ b/plugins/window/src/scripts/drag.js @@ -2,16 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -document.addEventListener('mousedown', (e) => { - if (e.target.hasAttribute('data-tauri-drag-region') && e.buttons === 1) { +document.addEventListener("mousedown", (e) => { + if (e.target.hasAttribute("data-tauri-drag-region") && e.buttons === 1) { // prevents text cursor - e.preventDefault() + e.preventDefault(); // fix #2549: double click on drag region edge causes content to maximize without window sizing change // https://github.com/tauri-apps/tauri/issues/2549#issuecomment-1250036908 - e.stopImmediatePropagation() + e.stopImmediatePropagation(); // start dragging if the element has a `tauri-drag-region` data attribute and maximize on double-clicking it - const cmd = e.detail === 2 ? 'internal_toggle_maximize' : 'start_dragging' - window.__TAURI_INVOKE__('plugin:window|' + cmd) + const cmd = e.detail === 2 ? "internal_toggle_maximize" : "start_dragging"; + window.__TAURI_INVOKE__("plugin:window|" + cmd); } -}) +}); diff --git a/plugins/window/src/scripts/print.js b/plugins/window/src/scripts/print.js index 2be2e491..1e833766 100644 --- a/plugins/window/src/scripts/print.js +++ b/plugins/window/src/scripts/print.js @@ -3,5 +3,5 @@ // SPDX-License-Identifier: MIT window.print = function () { - return window.__TAURI_INVOKE__('plugin:window|print') -} + return window.__TAURI_INVOKE__("plugin:window|print"); +}; diff --git a/plugins/window/src/scripts/toggle-devtools.js b/plugins/window/src/scripts/toggle-devtools.js index 2bff9d12..42c4bdba 100644 --- a/plugins/window/src/scripts/toggle-devtools.js +++ b/plugins/window/src/scripts/toggle-devtools.js @@ -2,25 +2,25 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -;(function () { +(function () { function toggleDevtoolsHotkey() { - const isHotkey = navigator.appVersion.includes('Mac') - ? event => event.metaKey && event.altKey && event.key === 'I' - : event => event.ctrlKey && event.shiftKey && event.key === 'I' + const isHotkey = navigator.appVersion.includes("Mac") + ? (event) => event.metaKey && event.altKey && event.key === "I" + : (event) => event.ctrlKey && event.shiftKey && event.key === "I"; - document.addEventListener('keydown', event => { + document.addEventListener("keydown", (event) => { if (isHotkey(event)) { - window.__TAURI_INVOKE__('plugin:window|internal_toggle_devtools'); + window.__TAURI_INVOKE__("plugin:window|internal_toggle_devtools"); } - }) + }); } if ( - document.readyState === 'complete' || - document.readyState === 'interactive' + document.readyState === "complete" || + document.readyState === "interactive" ) { - toggleDevtoolsHotkey() + toggleDevtoolsHotkey(); } else { - window.addEventListener('DOMContentLoaded', toggleDevtoolsHotkey, true) + window.addEventListener("DOMContentLoaded", toggleDevtoolsHotkey, true); } -})() +})();