mirror of
https://github.com/ByteAtATime/raycast-linux.git
synced 2025-08-31 03:07:23 +00:00
chore: fix type errors
This commit is contained in:
parent
1761ccb303
commit
9a176d6590
7 changed files with 31 additions and 19 deletions
|
@ -2,6 +2,7 @@ import { type ImageLike } from '@raycast-linux/protocol';
|
|||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
import { mode } from 'mode-watcher';
|
||||
import path from 'path';
|
||||
import type { ColorLike } from './props';
|
||||
|
||||
// this matches any emoji character (u flag = unicode, \p{Emoji} = any unicode emoji)
|
||||
const EMOJI_REGEX = /\p{Emoji}/u;
|
||||
|
@ -17,16 +18,15 @@ const iconIsEmoji = (icon: string) => {
|
|||
return Array.from(graphemes).length === 1 && EMOJI_REGEX.test(icon);
|
||||
};
|
||||
|
||||
type ImageColor = string | { light: string; dark: string };
|
||||
type ImageMask = 'circle' | 'roundedRectangle';
|
||||
|
||||
export type ResolvedIcon =
|
||||
| { type: 'raycast'; name: string; tintColor?: ImageColor }
|
||||
| { type: 'raycast'; name: string; tintColor?: ColorLike }
|
||||
| {
|
||||
type: 'image';
|
||||
src: string;
|
||||
mask?: ImageMask;
|
||||
tintColor?: ImageColor;
|
||||
tintColor?: ColorLike;
|
||||
}
|
||||
| { type: 'emoji'; emoji: string };
|
||||
|
||||
|
@ -67,7 +67,15 @@ export function resolveIcon(
|
|||
|
||||
// TODO: better heuristic?
|
||||
if (source.endsWith('-16')) {
|
||||
return { type: 'raycast', name: source, tintColor: icon.tintColor };
|
||||
return {
|
||||
type: 'raycast',
|
||||
name: source,
|
||||
tintColor:
|
||||
// TODO: actually handle adjustContrast
|
||||
typeof icon.tintColor === 'object'
|
||||
? { ...icon.tintColor, adjustContrast: false }
|
||||
: icon.tintColor
|
||||
};
|
||||
}
|
||||
|
||||
let src: string;
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
import { Button } from '$lib/components/ui/button';
|
||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import Icon from './Icon.svelte';
|
||||
import type { ImageLike } from '@raycast-linux/protocol';
|
||||
|
||||
type Props = {
|
||||
providerName: string;
|
||||
providerIcon?: string;
|
||||
providerIcon?: ImageLike;
|
||||
description?: string;
|
||||
authUrl: string;
|
||||
status: 'initial' | 'authorizing' | 'success' | 'error';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</script>
|
||||
|
||||
<div class="relative">
|
||||
<Input {...restProps} {value} type={inputType} class="pr-10" />
|
||||
<Input {...restProps} {value} type={inputType} files={undefined} class="pr-10" />
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
|
|
|
@ -18,12 +18,14 @@ export const nodeToActionDefinition = (
|
|||
node: UINode,
|
||||
onDispatch: (instanceId: number, handlerName: string, args: unknown[]) => void
|
||||
): ActionDefinition => {
|
||||
const title = typeof node.props.title === 'string' ? node.props.title : undefined;
|
||||
|
||||
switch (node.type) {
|
||||
case 'Action.CopyToClipboard': {
|
||||
const copyProps = node.props as ActionCopyToClipboardProps;
|
||||
|
||||
return {
|
||||
title: copyProps.title ?? 'Copy to Clipboard',
|
||||
title: title ?? 'Copy to Clipboard',
|
||||
handler: () => {
|
||||
writeText(copyProps.content);
|
||||
onDispatch(node.id, 'onCopy', []);
|
||||
|
@ -43,7 +45,7 @@ export const nodeToActionDefinition = (
|
|||
}
|
||||
case 'Action.SubmitForm': {
|
||||
return {
|
||||
title: node.props.title ?? 'Submit Form',
|
||||
title: title ?? 'Submit Form',
|
||||
handler: () => onDispatch(node.id, 'onSubmit', [])
|
||||
};
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ export const nodeToActionDefinition = (
|
|||
case 'Action':
|
||||
default: {
|
||||
return {
|
||||
title: node.props.title,
|
||||
title: title!,
|
||||
handler: () => onDispatch(node.id, 'onAction', [])
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import type { UINode } from '$lib/types';
|
||||
import { getTypedProps, type ListDropdownItemProps } from '$lib/props';
|
||||
import { getTypedProps, type DropdownItemProps } from '$lib/props';
|
||||
|
||||
export function getDropdownItems(
|
||||
node: UINode,
|
||||
uiTree: Map<number, UINode>
|
||||
): ListDropdownItemProps[] {
|
||||
const items: ListDropdownItemProps[] = [];
|
||||
export function getDropdownItems(node: UINode, uiTree: Map<number, UINode>): DropdownItemProps[] {
|
||||
const items: DropdownItemProps[] = [];
|
||||
if (!node) return items;
|
||||
|
||||
function traverse(children: number[]) {
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
import { Command, type Child, open as shellOpen } from '@tauri-apps/plugin-shell';
|
||||
import { Unpackr } from 'msgpackr';
|
||||
import { uiStore } from '$lib/ui.svelte';
|
||||
import { CommandSchema, SidecarMessageWithPluginsSchema } from '@raycast-linux/protocol';
|
||||
import {
|
||||
CommandSchema,
|
||||
SidecarMessageWithPluginsSchema,
|
||||
type ImageLike
|
||||
} from '@raycast-linux/protocol';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { appCacheDir, appLocalDataDir } from '@tauri-apps/api/path';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
|
@ -11,7 +15,7 @@ import { inflate } from 'pako';
|
|||
type OauthState = {
|
||||
url: string;
|
||||
providerName: string;
|
||||
providerIcon?: string;
|
||||
providerIcon?: ImageLike;
|
||||
description?: string;
|
||||
} | null;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { PluginInfo } from '@raycast-linux/protocol';
|
||||
import type { ImageLike, PluginInfo } from '@raycast-linux/protocol';
|
||||
import { uiStore } from '$lib/ui.svelte';
|
||||
import { sidecarService } from '$lib/sidecar.svelte';
|
||||
import type { Quicklink } from './quicklinks.svelte';
|
||||
|
@ -22,7 +22,7 @@ export type ViewState =
|
|||
type OauthState = {
|
||||
url: string;
|
||||
providerName: string;
|
||||
providerIcon?: string;
|
||||
providerIcon?: ImageLike;
|
||||
description?: string;
|
||||
} | null;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue