From 57c8903159c8b20ef072c64dca585d7a7fe137a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ade=E3=80=8C=E3=81=82=E3=81=A7=E3=80=8DFisher?= Date: Mon, 16 Dec 2024 15:29:35 +0100 Subject: [PATCH] chore: update version to 0.2.1 and refactor HTML rendering logic in build script --- package.json | 2 +- scripts/build.spa.tsx | 23 ++++++++--------------- src/entry/_handlers.tsx | 6 +++--- src/state/common.ts | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 45036b2..8c09ce8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "🔬 Experiment is a simple tool to facilitate prompt engineering.", "keywords": ["inference", "experiment-tracking", "llm"], "repository": "github:actualwitch/experiment", - "version": "0.2.0", + "version": "0.2.1", "author": "Ade あで Fisher", "license": "MIT", "private": true, diff --git a/scripts/build.spa.tsx b/scripts/build.spa.tsx index 8034a8c..e3fdf5b 100644 --- a/scripts/build.spa.tsx +++ b/scripts/build.spa.tsx @@ -1,7 +1,5 @@ import { $ } from "bun"; -import { renderToString } from "react-dom/server"; -import { StaticRouter } from "react-router"; -import { Shell } from "../src/root"; +import { getHtml } from "../src/entry/_handlers"; import { assignToWindow } from "../src/utils/hydration"; // why does this work but running it from Bun.build fails? #justbunthings @@ -14,18 +12,13 @@ await $`bun build ./src/entry/client.tsx --outdir ./spa`; // throw new AggregateError(buildResult.logs, "Build failed"); // } +const html = getHtml( + `${process.env.BASE_URL ?? ""}/`, + [assignToWindow("REALM", `"SPA"`), process.env.BASE_URL && assignToWindow("BASE_URL", `"${process.env.BASE_URL}"`)], + process.env.BASE_URL, +); + await Bun.write( "./spa/index.html", - renderToString( - - - , - ), + html, ); diff --git a/src/entry/_handlers.tsx b/src/entry/_handlers.tsx index cf6b787..c835708 100644 --- a/src/entry/_handlers.tsx +++ b/src/entry/_handlers.tsx @@ -7,10 +7,10 @@ import { publish, subscribe, type Update } from "../state/æther"; import { eventStream } from "../utils/eventStream"; import { getClientAsString } from "./_macro" with { type: "macro" }; -export const getHtml = (location: string, additionalScripts?: string[]) => { +export const getHtml = (location: string, additionalScripts?: string[], baseUrl?: string) => { const html = renderToString( - - + + , ); return `${html}`; diff --git a/src/state/common.ts b/src/state/common.ts index aa41d45..4614e05 100644 --- a/src/state/common.ts +++ b/src/state/common.ts @@ -150,5 +150,5 @@ export const parentAtom = entangledAtom("parent", atom(undef export const rendererModeAtom = entangledAtom( "rendererMode", - focusAtom(storeAtom, (o) => o.prop("rendererMode")), + focusAtom(storeAtom, (o) => o.prop("rendererMode").valueOr("markdown")), );