import SparkBunEvent from "./event";

type DetailData = { detail: string };
type NewWindowOpenData = {
	detail:
		| string
		| {
				url: string;
				isCmdClick: boolean;
				modifierFlags?: number;
				targetDisposition?: number;
				userGesture?: boolean;
		  };
};

export default {
	willNavigate: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("will-navigate", data),
	didNavigate: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("did-navigate", data),
	didNavigateInPage: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("did-navigate-in-page", data),
	didCommitNavigation: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("did-commit-navigation", data),
	domReady: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("dom-ready", data),
	newWindowOpen: (data: NewWindowOpenData) =>
		new SparkBunEvent<NewWindowOpenData, {}>("new-window-open", data),
	hostMessage: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("host-message", data),
	downloadStarted: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("download-started", data),
	downloadProgress: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("download-progress", data),
	downloadCompleted: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("download-completed", data),
	downloadFailed: (data: DetailData) =>
		new SparkBunEvent<DetailData, {}>("download-failed", data),
};
