chore: bump toolchain & fix lint

This commit is contained in:
DarkSky
2026-05-24 06:47:17 +08:00
parent adfa51a372
commit 2aa56cbccd
39 changed files with 151 additions and 130 deletions
@@ -374,10 +374,10 @@ export class CopilotEmbeddingJob {
const docContent = await this.doc.getFullDocContent(workspaceId, docId);
const authors = await this.models.doc.getAuthors(workspaceId, docId);
if (docContent && authors) {
const { title = 'Untitled', summary } = docContent;
const { title, summary } = docContent;
const { createdAt, updatedAt, createdByUser, updatedByUser } = authors;
return {
title,
title: title || 'Untitled',
summary,
createdAt: createdAt.toDateString(),
updatedAt: updatedAt.toDateString(),
@@ -255,9 +255,7 @@ export class LiveData<T = unknown>
constructor(
initialValue: T,
upstream:
| ((upstream: Observable<LiveDataOperation>) => Observable<T>)
| undefined = undefined
upstream?: (upstream: Observable<LiveDataOperation>) => Observable<T>
) {
super();
this.raw$ = new BehaviorSubject(initialValue);
@@ -37,6 +37,8 @@ impl PartialEq for Item {
}
}
impl Eq for Item {}
impl std::fmt::Debug for Item {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut dbg = f.debug_struct("Item");
@@ -44,9 +44,7 @@ impl PartialEq for Node {
}
}
impl Eq for Node {
fn assert_receiver_is_total_eq(&self) {}
}
impl Eq for Node {}
impl From<Item> for Node {
fn from(value: Item) -> Self {
@@ -299,9 +299,7 @@ impl<T: PartialEq> PartialEq for SomrInner<T> {
}
}
impl<T: PartialEq> Eq for Somr<T> {
fn assert_receiver_is_total_eq(&self) {}
}
impl<T: Eq> Eq for Somr<T> {}
impl<T: PartialOrd> PartialOrd for Somr<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
@@ -64,7 +64,7 @@ impl StoreHistory {
// make items as reference
let mut store_items = store_items.iter().collect::<Vec<_>>();
store_items.sort_by(|a, b| a.id.clock.cmp(&b.id.clock));
store_items.sort_by_key(|item| item.id.clock);
self.parse_items(store_items)
}
@@ -126,7 +126,7 @@ impl StoreHistory {
// make items as reference
let mut store_items = store_items.iter().collect::<Vec<_>>();
store_items.sort_by(|a, b| a.id.clock.cmp(&b.id.clock));
store_items.sort_by_key(|item| item.id.clock);
self.parse_items(store_items)
}
@@ -266,11 +266,7 @@ fn advance_text_position(store: &mut DocStore, pos: &mut TextPosition, mut remai
}
fn minimize_attribute_changes(pos: &mut TextPosition, attrs: &TextAttributes) {
loop {
let Some(item) = pos.right.get() else {
break;
};
while let Some(item) = pos.right.get() {
if item.deleted() {
pos.forward();
continue;
@@ -345,11 +341,7 @@ fn insert_negated_attributes(
pos: &mut TextPosition,
mut negated: TextAttributes,
) -> JwstCodecResult {
loop {
let Some(item) = pos.right.get() else {
break;
};
while let Some(item) = pos.right.get() {
if item.deleted() {
pos.forward();
continue;
@@ -61,6 +61,11 @@ export type AvatarProps = {
removeButtonProps?: HTMLAttributes<HTMLButtonElement>;
} & HTMLAttributes<HTMLSpanElement>;
const EMPTY_STYLE: CSSProperties = {};
const EMPTY_FALLBACK_PROPS: AvatarFallbackProps = {};
const EMPTY_HOVER_WRAPPER_PROPS: HTMLAttributes<HTMLDivElement> = {};
const EMPTY_REMOVE_BUTTON_PROPS: HTMLAttributes<HTMLButtonElement> = {};
function drawImageFit(
img: ImageBitmap,
ctx: CanvasRenderingContext2D,
@@ -88,32 +93,32 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
(
{
size = 20,
style: propsStyles = {},
style: propsStyles = EMPTY_STYLE,
url,
image,
name,
className,
colorfulFallback = false,
hoverIcon,
fallbackProps: { className: fallbackClassName, ...fallbackProps } = {},
fallbackProps = EMPTY_FALLBACK_PROPS,
imageProps,
avatarProps,
rounded = '50%',
onRemove,
hoverWrapperProps: {
className: hoverWrapperClassName,
...hoverWrapperProps
} = {},
hoverWrapperProps = EMPTY_HOVER_WRAPPER_PROPS,
avatarTooltipOptions,
removeTooltipOptions,
removeButtonProps: {
className: removeButtonClassName,
...removeButtonProps
} = {},
removeButtonProps = EMPTY_REMOVE_BUTTON_PROPS,
...props
},
ref
) => {
const { className: fallbackClassName, ...otherFallbackProps } =
fallbackProps;
const { className: hoverWrapperClassName, ...otherHoverWrapperProps } =
hoverWrapperProps;
const { className: removeButtonClassName, ...otherRemoveButtonProps } =
removeButtonProps;
const firstCharOfName = useMemo(() => {
return name?.slice(0, 1);
}, [name]);
@@ -180,7 +185,7 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
<AvatarFallback
className={clsx(style.avatarFallback, fallbackClassName)}
delayMs={url ? 600 : undefined}
{...fallbackProps}
{...otherFallbackProps}
>
{colorfulFallback ? (
<ColorfulFallback char={firstCharOfName} />
@@ -196,7 +201,7 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
fallbackClassName
)}
delayMs={url ? 600 : undefined}
{...fallbackProps}
{...otherFallbackProps}
>
<DefaultFallbackSvg />
</AvatarFallback>
@@ -204,7 +209,7 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
{hoverIcon ? (
<div
className={clsx(style.hoverWrapper, hoverWrapperClassName)}
{...hoverWrapperProps}
{...otherHoverWrapperProps}
>
{hoverIcon}
</div>
@@ -223,7 +228,7 @@ export const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(
className={clsx(style.removeButton, removeButtonClassName)}
onClick={onRemove}
ref={setRemoveButtonDom}
{...removeButtonProps}
{...otherRemoveButtonProps}
>
<CloseIcon />
</IconButton>
@@ -27,6 +27,8 @@ export type InputProps = {
onEnter?: (value: string) => void;
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size' | 'onBlur'>;
const EMPTY_STYLE: CSSProperties = {};
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
{
disabled,
@@ -34,8 +36,8 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
noBorder = false,
className,
status = 'default',
style = {},
inputStyle = {},
style = EMPTY_STYLE,
inputStyle = EMPTY_STYLE,
size = 'default',
preFix,
endFix,
@@ -25,6 +25,8 @@ export type RowInputProps = {
debounce?: number;
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size' | 'onBlur'>;
const EMPTY_STYLE: CSSProperties = {};
// RowInput component that is used in the selector layout for search input
// handles composition events and enter key press
export const RowInput = forwardRef<HTMLInputElement, RowInputProps>(
@@ -33,7 +35,7 @@ export const RowInput = forwardRef<HTMLInputElement, RowInputProps>(
disabled,
onChange: propsOnChange,
className,
style = {},
style = EMPTY_STYLE,
onEnter,
onKeyDown,
onBlur,
@@ -11,26 +11,26 @@ const MenuContextValue = {
type: 'dropdown-menu',
} as const;
const EMPTY_ROOT_OPTIONS: NonNullable<MenuProps['rootOptions']> = {};
const EMPTY_CONTENT_OPTIONS: NonNullable<MenuProps['contentOptions']> = {};
const EMPTY_CONTENT_STYLE: React.CSSProperties = {};
export const DesktopMenu = ({
children,
items,
noPortal,
portalOptions,
rootOptions: {
defaultOpen,
modal,
open,
onOpenChange,
onClose,
...rootOptions
} = {},
contentOptions: {
className = '',
style: contentStyle = {},
...otherContentOptions
} = {},
rootOptions: rawRootOptions,
contentOptions: rawContentOptions,
ref,
}: MenuProps) => {
const { defaultOpen, modal, open, onOpenChange, onClose, ...rootOptions } =
rawRootOptions ?? EMPTY_ROOT_OPTIONS;
const {
className = '',
style: contentStyle = EMPTY_CONTENT_STYLE,
...otherContentOptions
} = rawContentOptions ?? EMPTY_CONTENT_OPTIONS;
const [innerOpen, setInnerOpen] = useState(defaultOpen);
const finalOpen = open ?? innerOpen;
@@ -9,18 +9,25 @@ import * as styles from '../styles.css';
import { useMenuItem } from '../use-menu-item';
import { DesktopMenuContext } from './context';
const EMPTY_SUB_OPTIONS: NonNullable<MenuSubProps['subOptions']> = {};
const EMPTY_SUB_CONTENT_OPTIONS: NonNullable<
MenuSubProps['subContentOptions']
> = {};
export const DesktopMenuSub = ({
children: propsChildren,
items,
portalOptions,
subOptions: { defaultOpen, ...otherSubOptions } = {},
subOptions,
triggerOptions,
subContentOptions: {
subContentOptions,
}: MenuSubProps) => {
const { defaultOpen, ...otherSubOptions } = subOptions ?? EMPTY_SUB_OPTIONS;
const {
className: subContentClassName = '',
style: contentStyle,
...otherSubContentOptions
} = {},
}: MenuSubProps) => {
} = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS;
const { type } = useContext(DesktopMenuContext);
const { className, children, otherProps } = useMenuItem({
children: propsChildren,
@@ -24,11 +24,18 @@ import {
import * as styles from './styles.css';
import { MobileMenuSubRaw } from './sub';
const EMPTY_CONTENT_OPTIONS: NonNullable<MenuProps['contentOptions']> = {};
export const MobileMenu = ({
children,
items,
title,
contentOptions: {
contentOptions,
contentWrapperStyle,
rootOptions,
ref,
}: MenuProps) => {
const {
className,
onPointerDownOutside,
onInteractOutside,
@@ -38,11 +45,7 @@ export const MobileMenu = ({
align: _align,
...otherContentOptions
} = {},
contentWrapperStyle,
rootOptions,
ref,
}: MenuProps) => {
} = contentOptions ?? EMPTY_CONTENT_OPTIONS;
const [subMenus, setSubMenus] = useState<SubMenuContent[]>([]);
const [open, setOpen] = useState(false);
const mobileContextValue = useMemo(
@@ -6,13 +6,18 @@ import type { MenuSubProps } from '../menu.types';
import { useMenuItem } from '../use-menu-item';
import { useMobileSubMenuHelper } from './context';
const EMPTY_SUB_CONTENT_OPTIONS: NonNullable<
MenuSubProps['subContentOptions']
> = {};
export const MobileMenuSub = ({
title,
children: propsChildren,
items,
triggerOptions,
subContentOptions: contentOptions = {},
subContentOptions,
}: MenuSubProps & { title?: string }) => {
const contentOptions = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS;
const {
className,
children,
@@ -43,11 +48,12 @@ export const MobileMenuSubRaw = ({
children,
items,
subOptions,
subContentOptions: contentOptions = {},
subContentOptions,
}: MenuSubProps & {
onClick?: (e: MouseEvent<HTMLDivElement>) => void;
title?: string;
}) => {
const contentOptions = subContentOptions ?? EMPTY_SUB_CONTENT_OPTIONS;
const id = useId();
const { addSubMenu } = useMobileSubMenuHelper();
@@ -15,17 +15,21 @@ export interface PopoverProps extends PopoverPrimitiveProps {
portalOptions?: PopoverPortalProps;
contentOptions?: PopoverContentProps;
}
const EMPTY_CONTENT_OPTIONS: NonNullable<PopoverProps['contentOptions']> = {};
export const Popover = ({
content,
children,
portalOptions,
contentOptions: {
contentOptions,
...props
}: PopoverProps) => {
const {
className: contentClassName,
style: contentStyle,
...otherContentOptions
} = {},
...props
}: PopoverProps) => {
} = contentOptions ?? EMPTY_CONTENT_OPTIONS;
return (
<PopoverPrimitive.Root {...props}>
<PopoverPrimitive.Trigger asChild>{children}</PopoverPrimitive.Trigger>
@@ -428,13 +428,8 @@ export class AIChatComposer extends SignalWatcher(
};
private readonly addSelectedContextChip = async () => {
const {
attachments = [],
snapshot,
combinedElementsMarkdown,
docs = [],
html,
} = this.chatContextValue;
const { attachments, snapshot, combinedElementsMarkdown, docs, html } =
this.chatContextValue;
await this.removeSelectedContextChip();
const chip: SelectedContextChip = {
uuid: uuidv4(),
@@ -23,7 +23,7 @@ export interface AIPanelErrorConfig {
}
export interface AIPanelGeneratingConfig {
generatingIcon: TemplateResult<1>;
generatingIcon?: TemplateResult<1>;
height?: number;
stages?: string[];
}
@@ -67,11 +67,14 @@ interface ErrorBaseProps {
buttons?: ReactElement[];
}
const DEFAULT_ICON = <FileIcon />;
const EMPTY_BUTTONS: ReactElement[] = [];
const ErrorBase = ({
title,
subtitle,
icon = <FileIcon />,
buttons = [],
icon = DEFAULT_ICON,
buttons = EMPTY_BUTTONS,
}: ErrorBaseProps) => {
return (
<div className={clsx([styles.viewer, styles.error])}>
@@ -20,8 +20,10 @@ import { AffineShapeIcon } from '..';
import { SelectorLayout } from '../selector/selector-layout';
import * as styles from './select-page.css';
const EMPTY_INIT: string[] = [];
export const SelectPage = memo(function SelectPage({
init = [],
init = EMPTY_INIT,
onConfirm,
onCancel,
onChange: propsOnChange,
@@ -48,6 +48,8 @@ import { DropEffect } from './drop-effect';
import * as styles from './node.css';
import type { NodeOperation } from './types';
const EMPTY_OPERATIONS: NodeOperation[] = [];
export type NavigationPanelTreeNodeDropEffectData = {
source: { data: AffineDNDData['draggable'] };
treeInstruction: DropTargetTreeInstruction | null;
@@ -190,9 +192,9 @@ export const NavigationPanelTreeNode = ({
collapsible = true,
canDrop,
reorderable = true,
operations = [],
operations = EMPTY_OPERATIONS,
postfix,
childrenOperations = [],
childrenOperations = EMPTY_OPERATIONS,
childrenPlaceholder,
linkComponent: LinkComponent = WorkbenchLink,
dndData,
@@ -4,9 +4,11 @@ import { NavigationPanelTreeContext } from './context';
import * as styles from './root.css';
import type { NodeOperation } from './types';
const EMPTY_OPERATIONS: NodeOperation[] = [];
export const NavigationPanelTreeRoot = ({
children,
childrenOperations = [],
childrenOperations = EMPTY_OPERATIONS,
placeholder,
}: {
children?: React.ReactNode;
@@ -1,4 +1,4 @@
export function BulledListIcon({ color = 'currentColor' }: { color: string }) {
export function BulledListIcon({ color = 'currentColor' }: { color?: string }) {
return (
<svg
width="16"
@@ -13,10 +13,12 @@ export interface AddItemPlaceholderProps extends HTMLAttributes<HTMLDivElement>
icon?: React.ReactNode;
}
const DEFAULT_ICON = <PlusIcon />;
export const AddItemPlaceholder = ({
onClick,
label = 'Add Item',
icon = <PlusIcon />,
icon = DEFAULT_ICON,
className,
...attrs
}: AddItemPlaceholderProps) => {
@@ -22,6 +22,8 @@ import * as styles from './node.css';
interface NavigationPanelTreeNodeProps extends BaseNavigationPanelTreeNodeProps {}
const EMPTY_OPERATIONS: BaseNavigationPanelTreeNodeProps['operations'] = [];
export const NavigationPanelTreeNode = ({
children,
icon: Icon,
@@ -33,9 +35,9 @@ export const NavigationPanelTreeNode = ({
collapsed,
extractEmojiAsIcon,
setCollapsed,
operations = [],
operations = EMPTY_OPERATIONS,
postfix,
childrenOperations = [],
childrenOperations = EMPTY_OPERATIONS,
childrenPlaceholder,
linkComponent: LinkComponent = WorkbenchLink,
...otherProps
@@ -6,9 +6,11 @@ import { useMemo, useState } from 'react';
import * as styles from './root.css';
const EMPTY_OPERATIONS: NodeOperation[] = [];
export const NavigationPanelTreeRoot = ({
children,
childrenOperations = [],
childrenOperations = EMPTY_OPERATIONS,
placeholder,
}: {
children?: React.ReactNode;
@@ -33,11 +33,13 @@ export interface SettingDropdownSelectProps<
native?: boolean;
}
const EMPTY_OPTIONS: DropdownItem<string>[] = [];
export const SettingDropdownSelect = <
V extends string = string,
E extends boolean | undefined = true,
>({
options = [],
options = EMPTY_OPTIONS as DropdownItem<V>[],
value,
emitValue = true,
onChange,
@@ -98,7 +100,7 @@ export const NativeSettingDropdownSelect = <
V extends string = string,
E extends boolean | undefined = true,
>({
options = [],
options = EMPTY_OPTIONS as DropdownItem<V>[],
value,
emitValue = true,
onChange,
@@ -85,7 +85,7 @@ const DatabaseBacklinkRow = ({
row$,
onChange,
}: {
defaultOpen: boolean;
defaultOpen?: boolean;
row$: Observable<DatabaseRow | undefined>;
onChange?: (
row: DatabaseRow,
@@ -20,10 +20,12 @@ import { HighlightText } from './highlight-text';
type Groups = { group?: QuickSearchGroup; items: QuickSearchItem[] }[];
const EMPTY_GROUPS: Groups = [];
export const CMDK = ({
className,
query,
groups: newGroups = [],
groups: newGroups = EMPTY_GROUPS,
error,
inputLabel,
placeholder,
@@ -3,7 +3,7 @@ import { Fragment, useMemo } from 'react';
import * as styles from './highlight-text.css';
type HighlightProps = {
text: string;
text?: string;
start: string;
end: string;
};
@@ -192,5 +192,5 @@ export const SUPPORTED_LANGUAGES: Record<
originalName: 'Türkçe',
flagEmoji: '🇹🇷',
resource: () => import('./tr.json'),
}
},
};
+1 -1
View File
@@ -1584,7 +1584,7 @@
"com.affine.settings.workspace.experimental-features.enable-mind-map-import.name": "Zihin Haritası İçe Aktarımı",
"com.affine.settings.workspace.experimental-features.enable-mind-map-import.description": "Zihin haritasının içe aktarılmasını etkinleştirir.",
"com.affine.settings.workspace.experimental-features.enable-block-meta.name": "Blok Metaverisi",
"com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Etkinleştirildiğinde, tüm bloklar için oluşturulma zamanı, güncellenme zamanı ile oluşturan ve güncelleyen bilgileri gösterilir.",
"com.affine.settings.workspace.experimental-features.enable-block-meta.description": "Etkinleştirildiğinde, tüm bloklar için oluşturulma zamanı, güncellenme zamanı ile oluşturan ve güncelleyen bilgileri gösterilir.",
"com.affine.settings.workspace.experimental-features.enable-callout.name": "Belirtme çizgisi",
"com.affine.settings.workspace.experimental-features.enable-callout.description": "Sözleriniz öne çıksın. Bu aynı zamanda transkripsiyon bloğundaki belirtme çizgisini de içerir.",
"com.affine.settings.workspace.experimental-features.enable-embed-iframe-block.name": "Iframe Bloğunu Göm",
@@ -1,8 +1,8 @@
export function createWavBuffer(
samples: Float32Array,
options: {
sampleRate: number;
numChannels: number;
sampleRate?: number;
numChannels?: number;
}
) {
const { sampleRate = 44100, numChannels = 1 } = options;