mirror of
https://github.com/tale/headplane.git
synced 2026-08-27 15:37:04 +00:00
fix: prefix hp_wasm paths correctly
Co-authored-by: palchrb <Breyholtz@gmail.com>
This commit is contained in:
+2
-2
@@ -32,8 +32,8 @@ RUN corepack enable
|
|||||||
COPY patches ./patches
|
COPY patches ./patches
|
||||||
COPY package.json pnpm-lock.yaml build.sh ./
|
COPY package.json pnpm-lock.yaml build.sh ./
|
||||||
|
|
||||||
COPY --from=go-base /bin/hp_ssh.wasm /run/app/hp_ssh.wasm
|
COPY --from=go-base /bin/hp_ssh.wasm /run/public/hp_ssh.wasm
|
||||||
COPY --from=go-base /bin/wasm_exec.js /run/app/wasm_exec.js
|
COPY --from=go-base /bin/wasm_exec.js /run/public/wasm_exec.js
|
||||||
RUN ./build.sh --app --app-install-only
|
RUN ./build.sh --app --app-install-only
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
+42
-40
@@ -19,7 +19,7 @@ export const shouldRevalidate: ShouldRevalidateFunction = () => {
|
|||||||
|
|
||||||
export async function loader({ request, context }: Route.LoaderArgs) {
|
export async function loader({ request, context }: Route.LoaderArgs) {
|
||||||
const origin = new URL(request.url).origin;
|
const origin = new URL(request.url).origin;
|
||||||
const assets = ["/wasm_exec.js", "/hp_ssh.wasm"];
|
const assets = [`${__PREFIX__}/wasm_exec.js`, `${__PREFIX__}/hp_ssh.wasm`];
|
||||||
const missing: string[] = [];
|
const missing: string[] = [];
|
||||||
|
|
||||||
for (const file of assets) {
|
for (const file of assets) {
|
||||||
@@ -180,7 +180,7 @@ export async function action({ request, context }: Route.ActionArgs) {
|
|||||||
export const links: Route.LinksFunction = () => [
|
export const links: Route.LinksFunction = () => [
|
||||||
{
|
{
|
||||||
rel: "preload",
|
rel: "preload",
|
||||||
href: "/hp_ssh.wasm",
|
href: `${__PREFIX__}/hp_ssh.wasm`,
|
||||||
as: "fetch",
|
as: "fetch",
|
||||||
type: "application/wasm",
|
type: "application/wasm",
|
||||||
crossOrigin: "anonymous",
|
crossOrigin: "anonymous",
|
||||||
@@ -190,7 +190,7 @@ export const links: Route.LinksFunction = () => [
|
|||||||
export const handle: ExternalScriptsHandle = {
|
export const handle: ExternalScriptsHandle = {
|
||||||
scripts: [
|
scripts: [
|
||||||
{
|
{
|
||||||
src: "/wasm_exec.js",
|
src: `${__PREFIX__}/wasm_exec.js`,
|
||||||
crossOrigin: "anonymous",
|
crossOrigin: "anonymous",
|
||||||
preload: true,
|
preload: true,
|
||||||
},
|
},
|
||||||
@@ -211,44 +211,46 @@ export default function Page({ loaderData: { ipnDetails, sshDetails } }: Route.C
|
|||||||
|
|
||||||
pause();
|
pause();
|
||||||
const go = new Go(); // Go is defined by wasm_exec.js
|
const go = new Go(); // Go is defined by wasm_exec.js
|
||||||
WebAssembly.instantiateStreaming(fetch("/hp_ssh.wasm"), go.importObject).then((value) => {
|
WebAssembly.instantiateStreaming(fetch(`${__PREFIX__}/hp_ssh.wasm`), go.importObject).then(
|
||||||
go.run(value.instance);
|
(value) => {
|
||||||
const handle = TsWasmNet(ipnDetails, {
|
go.run(value.instance);
|
||||||
NotifyState: (state) => {
|
const handle = TsWasmNet(ipnDetails, {
|
||||||
console.log("State changed:", state);
|
NotifyState: (state) => {
|
||||||
if (state === "Running") {
|
console.log("State changed:", state);
|
||||||
setIpn(handle);
|
if (state === "Running") {
|
||||||
}
|
setIpn(handle);
|
||||||
},
|
}
|
||||||
NotifyNetMap: (netmap) => {
|
},
|
||||||
// Only set NodeKey if it is not already set and then
|
NotifyNetMap: (netmap) => {
|
||||||
// also dispatch that to the backend to track the
|
// Only set NodeKey if it is not already set and then
|
||||||
// ephemeral node.
|
// also dispatch that to the backend to track the
|
||||||
//
|
// ephemeral node.
|
||||||
// We open an SSE connection to the backend
|
//
|
||||||
// so that when the connection is closed,
|
// We open an SSE connection to the backend
|
||||||
// the backend can delete the ephemeral node.
|
// so that when the connection is closed,
|
||||||
if (nodeKey === null) {
|
// the backend can delete the ephemeral node.
|
||||||
setNodeKey(netmap.NodeKey);
|
if (nodeKey === null) {
|
||||||
submit(
|
setNodeKey(netmap.NodeKey);
|
||||||
{
|
submit(
|
||||||
node_key: netmap.NodeKey,
|
{
|
||||||
auth_key: ipnDetails.PreAuthKey,
|
node_key: netmap.NodeKey,
|
||||||
},
|
auth_key: ipnDetails.PreAuthKey,
|
||||||
{ method: "POST" },
|
},
|
||||||
);
|
{ method: "POST" },
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
NotifyBrowseToURL: (url) => {
|
},
|
||||||
console.log("Browse to URL:", url);
|
NotifyBrowseToURL: (url) => {
|
||||||
},
|
console.log("Browse to URL:", url);
|
||||||
NotifyPanicRecover: (message) => {
|
},
|
||||||
console.error("Panic recover:", message);
|
NotifyPanicRecover: (message) => {
|
||||||
},
|
console.error("Panic recover:", message);
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
handle.Start();
|
handle.Start();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (!sshDetails.username) {
|
if (!sshDetails.username) {
|
||||||
|
|||||||
Reference in New Issue
Block a user