From 9fac7a3e021c7d96c4914211e5faa86de083d9db Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Fri, 27 Sep 2024 09:41:00 +0200 Subject: [PATCH] fix: #486 naming conflict for argument `isMac` in the type definitions --- src/lib/components/modals/CopyPasteModal.svelte | 4 ++-- src/lib/utils/keyBindings.ts | 10 +++++++--- src/lib/utils/navigatorUtils.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/components/modals/CopyPasteModal.svelte b/src/lib/components/modals/CopyPasteModal.svelte index ab996fe8..be3da6b8 100644 --- a/src/lib/components/modals/CopyPasteModal.svelte +++ b/src/lib/components/modals/CopyPasteModal.svelte @@ -1,13 +1,13 @@ diff --git a/src/lib/utils/keyBindings.ts b/src/lib/utils/keyBindings.ts index 5b48877a..d46a3633 100644 --- a/src/lib/utils/keyBindings.ts +++ b/src/lib/utils/keyBindings.ts @@ -1,6 +1,6 @@ // inspiration: https://github.com/andrepolischuk/keycomb -import { isMac as _isMac } from './navigatorUtils.js' +import { isMacDevice } from './navigatorUtils.js' // KeyComboEvent is a subset of KeyboardEvent export interface KeyComboEvent { @@ -19,7 +19,11 @@ export interface KeyComboEvent { * meta keys "Ctrl" ("Command" on Mac), and "Alt" ("Alt" or "Option" on Mac) * So pressing "Command" and "A"on Mac will return "Ctrl+A" */ -export function keyComboFromEvent(event: KeyComboEvent, separator = '+', isMac = _isMac): string { +export function keyComboFromEvent( + event: KeyComboEvent, + separator = '+', + isMac = isMacDevice +): string { const combi = [] if (isCtrlKeyDown(event, isMac)) { @@ -48,7 +52,7 @@ export function keyComboFromEvent(event: KeyComboEvent, separator = '+', isMac = */ export function isCtrlKeyDown( event: { ctrlKey: boolean; metaKey: boolean }, - isMac = _isMac + isMac = isMacDevice ): boolean { // metaKey is the Command key ⌘ on a Mac (but the Windows Key ⊞ on Windows) return event.ctrlKey || (event.metaKey && isMac()) diff --git a/src/lib/utils/navigatorUtils.ts b/src/lib/utils/navigatorUtils.ts index e3bc4c4e..cd7f4503 100644 --- a/src/lib/utils/navigatorUtils.ts +++ b/src/lib/utils/navigatorUtils.ts @@ -8,7 +8,7 @@ declare global { } } -export function isMac() { +export function isMacDevice() { return ( typeof navigator !== 'undefined' && (navigator?.platform?.toUpperCase().includes('MAC') ??