diff --git a/app/package.json b/app/package.json index 485bb09..1955d0b 100644 --- a/app/package.json +++ b/app/package.json @@ -12,7 +12,10 @@ "test": "tsx --test tests/*.test.ts", "build:solver": "node scripts/build-solver.mjs", "test:solver-native": "node scripts/test-solver-native.mjs", - "bench:solver": "tsx scripts/bench-solver.ts" + "bench:solver": "tsx scripts/bench-solver.ts", + "demo:planner": "vite --config tests/vite.semester.config.ts --host 127.0.0.1 --port 5190", + "build:planner-demo": "vite build --config tests/vite.semester.config.ts", + "pack:planner-demo": "npm run build:planner-demo && node scripts/pack-planner-demo.mjs" }, "dependencies": { "@ai-sdk/anthropic": "^4.0.0", diff --git a/app/scripts/pack-planner-demo.mjs b/app/scripts/pack-planner-demo.mjs new file mode 100644 index 0000000..6f7df4a --- /dev/null +++ b/app/scripts/pack-planner-demo.mjs @@ -0,0 +1,30 @@ +import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; +import { gzipSync } from "node:zlib"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); +const dist = join(root, "dist/semester-preview"); +const entry = readFileSync(join(dist, "tests/semester-lab.html"), "utf8"); +const jsPath = entry.match(/src="([^\"]+\.js)"/)?.[1]; +const cssPath = entry.match(/href="([^\"]+\.css)"/)?.[1]; +if (!jsPath || !cssPath) + throw new Error("Build the planner demo before packing it."); +const js = readFileSync(join(dist, jsPath.replace(/^\//, "")), "utf8"); +let css = readFileSync(join(dist, cssPath.replace(/^\//, "")), "utf8"); +const font = readFileSync( + join(root, "public/fonts/caveat-latin.woff2"), +).toString("base64"); +css = css.replaceAll("/fonts/caveat-latin.woff2", `data:font/woff2;base64,${font}`); +const zipped = gzipSync(js, { level: 9 }).toString("base64"); +const html = `PI. Semester Lab
`; +mkdirSync(join(root, ".artifacts"), { recursive: true }); +const target = join(root, ".artifacts/semester-lab.html"); +writeFileSync(target, html); +console.log( + `Packed standalone demo. ${Buffer.byteLength(html).toLocaleString()} bytes. ${target}`, +); diff --git a/app/solver/README.md b/app/solver/README.md index c7e630d..7d9f088 100644 --- a/app/solver/README.md +++ b/app/solver/README.md @@ -94,3 +94,35 @@ schedule, registers courses, or reserves seats. The component is lazy-loaded only when the lab is opened. While a constraint change is being solved, the previous timetable is labeled as previous and its controls are unavailable. No obsolete worker result can replace newer input. + +## Offline presentation and development demo + +Run these commands from `app`. + +``` +npm run demo:planner +``` + +Open `http://127.0.0.1:5190/tests/semester-lab.html`. This Vite entry uses the real +component, worker, and Wasm engine with explicitly synthetic section times. It +makes no model or Junction API calls and requires no sign-in. The production +planner still uses its existing authentication. + +``` +npm run pack:planner-demo +``` + +This builds the demo and creates `.artifacts/semester-lab.html`. Open the file +directly in a modern browser supporting WebAssembly, workers, and +`DecompressionStream`. React, CSS, fonts, worker code, and Wasm are embedded in +one file. No HTTP requests are needed to run the planner. The GitHub link in the +header opens the repository only when clicked. Generated output stays ignored. + +Presentation sequence. Pin the initial week, protect Friday, move the earliest +start to 10am, compare another plan, and click a class to lock it. Undo a change. +Then open the impossible-week example. Three courses each have two slots, every +pair fits, but there is no assignment for all three. Finally set an impossible +start time in the normal semester and use a verified relaxation to recover. + +Keep the SAMPLE DATA label visible. A successful demo does not validate real +Junction records, registration eligibility, or production account integration. diff --git a/app/tests/semester-lab-demo.css b/app/tests/semester-lab-demo.css new file mode 100644 index 0000000..d6faade --- /dev/null +++ b/app/tests/semester-lab-demo.css @@ -0,0 +1,81 @@ +body { + background: #f6f5ef; +} +.lab-demo-shell { + max-width: 1250px; + margin: 0 auto; + padding: 0 44px 45px; +} +.lab-demo-bar { + height: 73px; + display: flex; + justify-content: space-between; + align-items: center; + gap: 18px; + margin-bottom: 31px; + border-bottom: 1px solid #dedfd2; +} +.lab-demo-bar > a { + color: #2c3932; + display: inline-flex; + gap: 9px; + align-items: center; + text-decoration: none; + font-size: 14px; +} +.lab-demo-pi { + font-family: Georgia, serif; + font-size: 29px; + color: #21786c; + line-height: 1; +} +.lab-demo-bar > a > span:last-child { + padding-left: 10px; + border-left: 1px solid #d5d7c9; + font-size: 11px; + color: #6b7565; +} +.lab-demo-bar > div { + display: flex; + align-items: center; + gap: 15px; +} +.lab-demo-label { + font-size: 8px; + font-weight: 650; + letter-spacing: 0.12em; + color: #69705f; +} +.lab-demo-bar button { + font-size: 10px; + color: #466551; + border-bottom: 1px solid #b8c7b6; + padding: 3px 0; +} +@media (max-width: 1000px) { + .lab-demo-shell { + padding: 0 24px 32px; + } + .lab-demo-label { + display: none; + } +} +@media (max-width: 700px) { + .lab-demo-shell { + padding: 0 16px 25px; + } + .lab-demo-bar { + height: auto; + min-height: 67px; + margin-bottom: 23px; + flex-wrap: wrap; + gap: 8px; + padding: 12px 0; + } + .lab-demo-bar > div { + gap: 10px; + } + .lab-demo-bar > a > span:last-child { + display: none; + } +} diff --git a/app/tests/semester-lab.html b/app/tests/semester-lab.html new file mode 100644 index 0000000..f84adce --- /dev/null +++ b/app/tests/semester-lab.html @@ -0,0 +1,2 @@ + +PI. Semester Lab prototype
diff --git a/app/tests/semester-lab.tsx b/app/tests/semester-lab.tsx new file mode 100644 index 0000000..1c58d3b --- /dev/null +++ b/app/tests/semester-lab.tsx @@ -0,0 +1,53 @@ +import { useState } from "react"; +import { createRoot } from "react-dom/client"; +import { SemesterLab } from "../src/client/components/SemesterLab"; +import { impossible, semester } from "./fixtures/semester"; +import "../src/client/styles.css"; +import "./semester-lab-demo.css"; + +function Demo() { + const [scenario, setScenario] = useState<"semester" | "impossible">( + "semester", + ); + const [version, setVersion] = useState(0); + return ( +
+
+ + π + PI + TigerApps + +
+ + WORKING PROTOTYPE · SAMPLE DATA + + + +
+
+ +
+ ); +} +createRoot(document.getElementById("root")!).render(); diff --git a/app/tests/vite.semester.config.ts b/app/tests/vite.semester.config.ts new file mode 100644 index 0000000..899f848 --- /dev/null +++ b/app/tests/vite.semester.config.ts @@ -0,0 +1,17 @@ +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; +import { fileURLToPath } from "node:url"; + +export default defineConfig({ + root: fileURLToPath(new URL("..", import.meta.url)), + plugins: [react()], + worker: { format: "iife" }, + build: { + outDir: "dist/semester-preview", + assetsInlineLimit: 1000000, + rollupOptions: { + input: "tests/semester-lab.html", + output: { inlineDynamicImports: true }, + }, + }, +});