示例工程 62-workspace-shell-sandbox

62-workspace-shell-sandbox/app/src/api.d.ts

typescript · 0.9 KB

import type { RunReq, Snapshot } from "../shared/ipc";
import type { SandboxResult } from "../shared/sandbox";

type DemoState = {
  score: number;
  checks: number;
  passed: number;
  scenarios: number;
  audit: number;
  inside: boolean;
  outside: boolean;
  absolute: boolean;
  symlink: boolean;
  blocked: boolean;
  metachar: boolean;
  timeout: boolean;
  truncated: boolean;
};

declare global {
  interface Window {
    api: {
      sandbox: {
        snapshot: () => Promise<Snapshot>;
        run: (
          request: RunReq,
        ) => Promise<{ entry: SandboxResult; snapshot: Snapshot }>;
        reset: () => Promise<Snapshot>;
        onChanged: (callback: (event: { at: number }) => void) => () => void;
      };
    };
    __demo?: () => Promise<DemoState>;
    __prepareShots?: (stage: "workspace" | "shell" | "audit") => Promise<void>;
  }
}

export {};