mirror of
https://github.com/tale/headplane.git
synced 2026-08-31 09:18:29 +00:00
fix: remove unnecessary remix-utils dependency
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import type { MetaFunction } from "react-router";
|
import type { MetaFunction } from "react-router";
|
||||||
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
|
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
|
||||||
import { ExternalScripts } from "remix-utils/external-scripts";
|
|
||||||
|
|
||||||
import { LiveDataProvider } from "~/utils/live-data";
|
import { LiveDataProvider } from "~/utils/live-data";
|
||||||
import ToastProvider from "~/utils/toast-provider";
|
import ToastProvider from "~/utils/toast-provider";
|
||||||
@@ -38,7 +37,6 @@ export function Layout({ children }: { readonly children: React.ReactNode }) {
|
|||||||
<ToastProvider />
|
<ToastProvider />
|
||||||
<ScrollRestoration />
|
<ScrollRestoration />
|
||||||
<Scripts />
|
<Scripts />
|
||||||
<ExternalScripts />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</LiveDataProvider>
|
</LiveDataProvider>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Loader2, WifiOff } from "lucide-react";
|
import { Loader2, WifiOff } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { data, isRouteErrorResponse, type ShouldRevalidateFunction } from "react-router";
|
import { data, isRouteErrorResponse, type ShouldRevalidateFunction } from "react-router";
|
||||||
import { ExternalScriptsHandle } from "remix-utils/external-scripts";
|
|
||||||
|
|
||||||
import Button from "~/components/button";
|
import Button from "~/components/button";
|
||||||
import Card from "~/components/card";
|
import Card from "~/components/card";
|
||||||
@@ -112,16 +111,6 @@ export const links: Route.LinksFunction = () => [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const handle: ExternalScriptsHandle = {
|
|
||||||
scripts: [
|
|
||||||
{
|
|
||||||
src: WASM_HELPER_URL,
|
|
||||||
crossOrigin: "anonymous",
|
|
||||||
preload: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Page({ loaderData }: Route.ComponentProps) {
|
export default function Page({ loaderData }: Route.ComponentProps) {
|
||||||
const { hostname, username, offline, node } = loaderData;
|
const { hostname, username, offline, node } = loaderData;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const WASM_MODULE_URL = `${__PREFIX__}/hp_ssh.wasm`;
|
const WASM_MODULE_URL = `${__PREFIX__}/hp_ssh.wasm`;
|
||||||
|
const WASM_HELPER_URL = `${__PREFIX__}/wasm_exec.js`;
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
type HeadplaneSSHFactory = (config: HeadplaneSSHConfig) => HeadplaneSSH;
|
type HeadplaneSSHFactory = (config: HeadplaneSSHConfig) => HeadplaneSSH;
|
||||||
@@ -44,12 +45,29 @@ export interface TunnelSession {
|
|||||||
|
|
||||||
let resolvedFactory: Promise<HeadplaneSSHFactory> | null = null;
|
let resolvedFactory: Promise<HeadplaneSSHFactory> | null = null;
|
||||||
|
|
||||||
|
function loadGoHelper(): Promise<void> {
|
||||||
|
if (typeof globalThis.Go !== "undefined") {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const script = document.createElement("script");
|
||||||
|
script.src = WASM_HELPER_URL;
|
||||||
|
script.crossOrigin = "anonymous";
|
||||||
|
script.onload = () => resolve();
|
||||||
|
script.onerror = () => reject(new Error("Failed to load Go WASM helper"));
|
||||||
|
document.head.appendChild(script);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One-shot function that loads the Go WASM binary and returns the SSH factory.
|
* One-shot function that loads the Go WASM binary and returns the SSH factory.
|
||||||
* It expects the Go WASM helper to be loaded, and will error if called before.
|
* Automatically loads the Go JS helper if it hasn't been loaded yet.
|
||||||
*/
|
*/
|
||||||
export async function loadHeadplaneWASM(): Promise<HeadplaneSSHFactory> {
|
export async function loadHeadplaneWASM(): Promise<HeadplaneSSHFactory> {
|
||||||
if (!resolvedFactory) {
|
if (!resolvedFactory) {
|
||||||
|
await loadGoHelper();
|
||||||
|
|
||||||
const go = new Go();
|
const go = new Go();
|
||||||
const result = await WebAssembly.instantiateStreaming(fetch(WASM_MODULE_URL), go.importObject);
|
const result = await WebAssembly.instantiateStreaming(fetch(WASM_MODULE_URL), go.importObject);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
"react-router": "^7.14.0",
|
"react-router": "^7.14.0",
|
||||||
"react-router-dom": "^7.14.0",
|
"react-router-dom": "^7.14.0",
|
||||||
"react-router-hono-server": "2.25.2",
|
"react-router-hono-server": "2.25.2",
|
||||||
"remix-utils": "^9.3.1",
|
|
||||||
"restty": "^0.1.35",
|
"restty": "^0.1.35",
|
||||||
"tailwind-merge": "3.5.0",
|
"tailwind-merge": "3.5.0",
|
||||||
"ulidx": "2.4.1",
|
"ulidx": "2.4.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user