Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions src/hooks/useAutoLaunchRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,44 +217,3 @@ export function useAutoLaunchRuntime(
clearError,
};
}

/**
* Higher-order function to wrap execution functions with auto-launch
*
* Usage:
* ```ts
* const { ensureRuntime } = useAutoLaunchRuntime();
* const executeWithAutoLaunch = withAutoLaunch(ensureRuntime, executeCell);
* ```
*/
export function withAutoLaunch<T extends (...args: any[]) => Promise<any>>(
ensureRuntime: () => Promise<boolean>,
executionFn: T
): T {
return (async (...args: Parameters<T>) => {
const runtimeAvailable = await ensureRuntime();

if (!runtimeAvailable) {
console.warn(
"⚠️ Could not ensure runtime availability, proceeding with execution anyway"
);
}

return executionFn(...args);
}) as T;
}

/**
* Simple hook for components that just need basic auto-launch functionality
*/
export function useSimpleAutoLaunch(
runtimeType: AutoLaunchRuntimeType = "html"
) {
const { ensureRuntime, status } = useAutoLaunchRuntime({ runtimeType });

return {
ensureRuntime,
isLaunching: status.isLaunching,
lastError: status.lastError,
};
}