API reference

petty.fileActions

capability: file-actions

petty.fileActions.register

register(config: FileActionConfig): void

petty.fileActions.unregister

unregister(id: string): void

Types referenced

FileActionConfig

interface FileActionConfig {
  id: string;
  title: string;
  categories?: FileCategory[];
  matchMultiple?: boolean;
  handler: (context: DropContext, done: (result: DropResult) => void) => void;
}

FileCategory

type FileCategory =
  | "image" | "video" | "audio" | "pdf"
  | "sourceCode" | "plainText" | "markdown"
  | "archive" | "folder" | "spreadsheet"
  | "mixed" | "unknown" | "*";

DropContext

interface DropContext {
  urls: string[];
  category: FileCategory;
  modifiers: DropModifier[];
  clipboardHint?:
    | { type: "text"; value: string }
    | { type: "image" }
    | { type: "filePath"; value: string };
}

DropResult

type DropResult =
  | { kind: "success"; message: string }
  | { kind: "info"; message: string }
  | { kind: "error"; message: string }
  | { kind: "cancelled" };

DropModifier

type DropModifier = "option" | "shift" | "command" | "control";