fuck
This commit is contained in:
@@ -27,7 +27,7 @@ type EnsureAssetUrl = (
|
||||
options?: { start?: number; limit?: number; [key: string]: unknown },
|
||||
) => Promise<unknown>;
|
||||
|
||||
type GetDocumentAsset = (document: DocumentLike | null | undefined, assetType: string) => AssetLike | null | undefined;
|
||||
type GetDocumentAsset = (document: DocumentLike | null, assetType: string) => AssetLike | null;
|
||||
|
||||
interface NavigatorSnapshot {
|
||||
url: string | null;
|
||||
|
||||
@@ -30,7 +30,7 @@ import '../styles/workspace/workspace-cards.css';
|
||||
|
||||
type Identifier = string | number;
|
||||
|
||||
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null | undefined;
|
||||
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
||||
|
||||
export interface DeskDocument {
|
||||
id?: Identifier | null;
|
||||
@@ -126,7 +126,7 @@ interface DesktopWorkspaceProps {
|
||||
onAssignTagToDocument?: (...args: unknown[]) => void;
|
||||
ensureAssetUrl?: (...args: unknown[]) => Promise<unknown> | unknown;
|
||||
getDocumentAsset?: (...args: unknown[]) => unknown;
|
||||
activeTagIds?: Array<Identifier | null | undefined>;
|
||||
activeTagIds?: Array<Identifier | null>;
|
||||
selectedDocumentIds?: Identifier[];
|
||||
onClearSelection?: () => void;
|
||||
detailPanelOpen?: boolean;
|
||||
@@ -142,7 +142,7 @@ interface DesktopWorkspaceViewProps {
|
||||
handleCanvasDragOver: (event: React.DragEvent<HTMLDivElement>) => void;
|
||||
handleCanvasDragLeave: (event: React.DragEvent<HTMLDivElement>) => void;
|
||||
handleCanvasDrop: (event: React.DragEvent<HTMLDivElement>) => void;
|
||||
ensureDocumentSize: (doc: DeskDocument | null | undefined) => DocumentSizeInfo | null;
|
||||
ensureDocumentSize: (doc: DeskDocument | null) => DocumentSizeInfo | null;
|
||||
layoutSnapshot: Map<string, LayoutEntry>;
|
||||
layoutRef: React.MutableRefObject<Map<string, LayoutEntry>>;
|
||||
dragTransformsRef: React.MutableRefObject<Map<string, DragTransformOverride>>;
|
||||
@@ -176,15 +176,15 @@ interface DesktopWorkspaceViewProps {
|
||||
detailPanelOpen: boolean;
|
||||
onCloseDetailPanel?: DesktopWorkspaceProps['onCloseDetailPanel'];
|
||||
documentLookup: Map<string, DeskDocument>;
|
||||
resolveBaseMetrics: (doc: DeskDocument | null | undefined, cardWidth: number, cardHeight: number) => {
|
||||
resolveBaseMetrics: (doc: DeskDocument | null, cardWidth: number, cardHeight: number) => {
|
||||
baseWidth: number;
|
||||
baseHeight: number;
|
||||
baseScale: number;
|
||||
};
|
||||
bringToFront: (docId: Identifier | null | undefined) => void;
|
||||
bringToFront: (docId: Identifier | null) => void;
|
||||
setDraggingId: (value: string | null) => void;
|
||||
canvasSize: { width: number; height: number };
|
||||
openOverlayForDoc: (docId: Identifier | null | undefined, originInfo?: OverlayOriginHint | null) => void;
|
||||
openOverlayForDoc: (docId: Identifier | null, originInfo?: OverlayOriginHint | null) => void;
|
||||
recalcVisibleDocIds: () => void;
|
||||
dragSettings: DragSettings;
|
||||
onInspectDocument?: DesktopWorkspaceProps['onInspectDocument'];
|
||||
@@ -231,7 +231,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
);
|
||||
const [docSizeVersion, setDocSizeVersion] = useState(0);
|
||||
const docSizeMapRef = useRef<Map<string, DocumentSizeInfo>>(new Map());
|
||||
const ensureDocumentSize = useCallback((doc: DeskDocument | null | undefined): DocumentSizeInfo | null => {
|
||||
const ensureDocumentSize = useCallback((doc: DeskDocument | null): DocumentSizeInfo | null => {
|
||||
if (!doc?.id) {
|
||||
return null;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
const layoutRef = useRef<Map<string, LayoutEntry>>(layoutSnapshot);
|
||||
layoutRef.current = engine.layout as Map<string, LayoutEntry>;
|
||||
|
||||
const bringToFront = useCallback((docId: Identifier | null | undefined) => {
|
||||
const bringToFront = useCallback((docId: Identifier | null) => {
|
||||
engine.bringToFront(docId);
|
||||
}, [engine]);
|
||||
|
||||
@@ -425,7 +425,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
}, [engine]);
|
||||
|
||||
const resolvePreviewDimensions = useCallback(
|
||||
(doc: DeskDocument | null | undefined): PreviewMetadataEntry | null => {
|
||||
(doc: DeskDocument | null): PreviewMetadataEntry | null => {
|
||||
if (!doc?.id) {
|
||||
return null;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
}, [overlayDocId, documentLookup]);
|
||||
|
||||
const resolveBaseMetrics = useCallback(
|
||||
(doc: DeskDocument | null | undefined, cardWidth: number, cardHeight: number) => {
|
||||
(doc: DeskDocument | null, cardWidth: number, cardHeight: number) => {
|
||||
const previewDims = doc ? resolvePreviewDimensions(doc) : null;
|
||||
if (previewDims?.width && previewDims?.height) {
|
||||
const baseWidth = Math.max(previewDims.width, cardWidth);
|
||||
@@ -612,7 +612,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
||||
}, [draggingId, items, setDraggingId]);
|
||||
|
||||
const openOverlayForDoc = useCallback(
|
||||
(docId: Identifier | null | undefined, originInfo: OverlayOriginHint | null = null) => {
|
||||
(docId: Identifier | null, originInfo: OverlayOriginHint | null = null) => {
|
||||
if (!docId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export const preventAll = (event?: PreventableEvent | null): void => {
|
||||
type AnyFn = (...args: unknown[]) => unknown;
|
||||
|
||||
export const safeInvoke = <Fn extends AnyFn>(
|
||||
fn: Fn | null | undefined,
|
||||
fn: Fn | null,
|
||||
...args: Parameters<Fn>
|
||||
): ReturnType<Fn> | undefined =>
|
||||
(fn ? (fn(...args) as ReturnType<Fn>) : undefined);
|
||||
|
||||
@@ -18,11 +18,11 @@ interface PreviewMetadataEntry {
|
||||
height: number;
|
||||
}
|
||||
|
||||
type GetDocumentAsset = (doc: DocumentLike, type: string) => AssetLike | null | undefined;
|
||||
type EnsureAssetUrl = (docId: string | number, asset: AssetLike, options?: { start?: number; limit?: number }) => Promise<AssetLike | null | undefined>;
|
||||
type GetDocumentAsset = (doc: DocumentLike, type: string) => AssetLike | null;
|
||||
type EnsureAssetUrl = (docId: string | number, asset: AssetLike, options?: { start?: number; limit?: number }) => Promise<AssetLike | null>;
|
||||
|
||||
const usePreviewMetadata = (
|
||||
documents: DocumentLike[] | null | undefined,
|
||||
documents: DocumentLike[] | null,
|
||||
getDocumentAsset?: GetDocumentAsset,
|
||||
ensureAssetUrl?: EnsureAssetUrl,
|
||||
) => {
|
||||
@@ -50,7 +50,7 @@ const usePreviewMetadata = (
|
||||
let view = createAssetView(asset);
|
||||
let metadata = view.getPrimaryMetadata();
|
||||
|
||||
const hasDimensions = (meta: { width?: number | string; height?: number | string } | null | undefined) =>
|
||||
const hasDimensions = (meta: { width?: number | string; height?: number | string } | null) =>
|
||||
Number.isFinite(Number(meta?.width)) &&
|
||||
Number.isFinite(Number(meta?.height)) &&
|
||||
Number(meta.width) > 0 &&
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useCallback, useMemo } from 'react';
|
||||
type Identifier = string | number;
|
||||
|
||||
type DocumentEntry = { id?: Identifier } & Record<string, unknown>;
|
||||
type InspectTarget = DocumentEntry | Identifier | null | undefined;
|
||||
type InspectTarget = DocumentEntry | Identifier | null;
|
||||
|
||||
type WorkspaceViewMode = 'desk' | 'grid' | 'list' | string;
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ interface DragGroupItemInternal extends EngineGroupItem {
|
||||
initialRotation?: number;
|
||||
}
|
||||
|
||||
type EnsureDocumentSizeFn = (doc: DocumentLike | null | undefined) => DocumentSizeInfo | null;
|
||||
type EnsureDocumentSizeFn = (doc: DocumentLike | null) => DocumentSizeInfo | null;
|
||||
|
||||
type ResolveBaseMetricsFn = (
|
||||
doc: DocumentLike | null | undefined,
|
||||
doc: DocumentLike | null,
|
||||
width: number,
|
||||
height: number,
|
||||
) => { baseWidth: number; baseHeight: number; baseScale: number };
|
||||
@@ -75,7 +75,7 @@ interface DragSettings {
|
||||
}
|
||||
|
||||
interface PointerDownOptions {
|
||||
stackDocIds?: Array<Identifier | null | undefined>;
|
||||
stackDocIds?: Array<Identifier | null>;
|
||||
stackSelectionApplied?: boolean;
|
||||
wasSelected?: boolean;
|
||||
modifierActive?: boolean;
|
||||
@@ -90,23 +90,23 @@ interface UseDocumentDragOptions {
|
||||
documentLookup: Map<string, DocumentLike>;
|
||||
ensureDocumentSize: EnsureDocumentSizeFn;
|
||||
resolveBaseMetrics: ResolveBaseMetricsFn;
|
||||
bringToFront: (docId: Identifier | null | undefined) => void;
|
||||
bringToFront: (docId: Identifier | null) => void;
|
||||
setDraggingId: (docKey: string | null) => void;
|
||||
canvasSize: { width: number; height: number };
|
||||
openOverlayForDoc?: (
|
||||
docId: Identifier | null | undefined,
|
||||
docId: Identifier | null,
|
||||
originInfo?: { rotation: number; scale: number; width: number; height: number },
|
||||
) => void;
|
||||
recalcVisibleDocIds: () => void;
|
||||
settings?: DragSettings;
|
||||
containerRef?: RefObject<HTMLElement>;
|
||||
onInspectDocument?: (docId: Identifier | null | undefined, event?: PointerEvent | ReactPointerEvent) => void;
|
||||
onInspectDocument?: (docId: Identifier | null, event?: PointerEvent | ReactPointerEvent) => void;
|
||||
onDocumentStackSelect?: (
|
||||
docIds: Identifier[],
|
||||
event: PointerEvent | ReactPointerEvent,
|
||||
options?: { replace?: boolean },
|
||||
) => void;
|
||||
selectedDocumentIds?: Array<Identifier | null | undefined>;
|
||||
selectedDocumentIds?: Array<Identifier | null>;
|
||||
markLayoutDirty?: () => void;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ const useDocumentDrag = (options: UseDocumentDragOptions) => {
|
||||
});
|
||||
const dragStateRef = useRef<DragStateInternal | null>(null);
|
||||
|
||||
const setDragTransform = useCallback((docKey: Identifier | null | undefined, transform: DragTransform | null) => {
|
||||
const setDragTransform = useCallback((docKey: Identifier | null, transform: DragTransform | null) => {
|
||||
if (!docKey) {
|
||||
return;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ const useDocumentDrag = (options: UseDocumentDragOptions) => {
|
||||
map.clear();
|
||||
}, [dragTransformsRef]);
|
||||
|
||||
const commitActiveDragTransforms = useCallback((docIds: Array<Identifier | null | undefined> | null = null) => {
|
||||
const commitActiveDragTransforms = useCallback((docIds: Array<Identifier | null> | null = null) => {
|
||||
const map = dragTransformsRef?.current;
|
||||
if (!map || !map.size) {
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ type WorkspaceSubscriber = () => void;
|
||||
|
||||
type DeskDocument = { id?: string | number | null } & Record<string, unknown>;
|
||||
|
||||
type EnsureDocumentSize = (doc: DeskDocument) => DocumentSize | null | undefined;
|
||||
type EnsureDocumentSize = (doc: DeskDocument) => DocumentSize | null;
|
||||
|
||||
type ResolveBaseMetrics = () => BaseMetrics;
|
||||
|
||||
@@ -144,7 +144,7 @@ export const TORQUE_TO_ACCELERATION = 0.006;
|
||||
export const SETTLE_ANGULAR_VELOCITY = 1.2;
|
||||
|
||||
export const applyDomTransform = (
|
||||
node: HTMLElement | null | undefined,
|
||||
node: HTMLElement | null,
|
||||
{
|
||||
centerX,
|
||||
centerY,
|
||||
@@ -662,7 +662,7 @@ export class WorkspaceEngine {
|
||||
}
|
||||
}
|
||||
|
||||
setItems(items: DeskDocument[] | null | undefined): void {
|
||||
setItems(items: DeskDocument[] | null): void {
|
||||
const normalized = Array.isArray(items) ? items : [];
|
||||
this.items = normalized;
|
||||
const canGenerateLayoutImmediately =
|
||||
@@ -689,7 +689,7 @@ export class WorkspaceEngine {
|
||||
this.resolveBaseMetrics = fn;
|
||||
}
|
||||
|
||||
setItemRefs(ref: ItemRefs | null | undefined): void {
|
||||
setItemRefs(ref: ItemRefs | null): void {
|
||||
this.itemRefs = ref || { current: new Map() };
|
||||
}
|
||||
|
||||
@@ -778,7 +778,7 @@ export class WorkspaceEngine {
|
||||
|
||||
updateLayoutEntry(
|
||||
docId: string | number | null,
|
||||
updater: (previous: LayoutEntry | null) => LayoutEntry | null | undefined,
|
||||
updater: (previous: LayoutEntry | null) => LayoutEntry | null,
|
||||
): void {
|
||||
if (docId == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user