teardown: remove @gamecult/sai, isolate graph-spa deps, clean mount & OG/tagline

This commit is contained in:
Meta Vens 2026-12-03 21:01:12 +01:00
commit 178f836760
12 changed files with 82 additions and 1369 deletions

View file

@ -16,7 +16,7 @@ Site-specific content, mastheads, sidebars, render hooks, and custom chrome stay
- **Entry points:** `scripts/build-site.mjs` (stage a site repo against this engine), `scripts/build-graph-spa.mjs` (build the shared graph SPA into a consumer), `quartz/graph-spa` (the SPA source) and `.github/workflows/quartz-pages.yml` (the reusable Pages workflow).
- **Live:** the engine and workflow serve `gamecult-site` and `AetheriaLore`; the graph SPA serves the deployed Mimir and gamecult.org sites under its default `epiphany-graph` asset route.
- **Migrating:** that default route is a compatibility contract. New or migrated consumers pass the `norn-graph` asset paths and `gamecult-norn-graph-root` explicitly. Future sprite staging extends Sai rather than adding a site-local player.
- **Migrating:** that default route is a compatibility contract. New or migrated consumers pass the `norn-graph` asset paths and `gamecult-norn-graph-root` explicitly.
## Consumer Repo Shape
@ -74,41 +74,6 @@ and the fullscreen shell. Norn owns graph interaction and rendering. Consumer
sites provide taxonomy, filtering, placement, and presentation through
`GameCultGraphSpaShell` configuration and overlay styles.
## Shared Interactive Embeds
### `Plugin.InkEmbedder`
Use `Plugin.InkEmbedder()` in a consumer site's emitter list to enable reusable
Ink embeds. The plugin copies Sai's packaged browser assets from `@gamecult/sai`
into the built site's `/static/interactive/` directory and injects the player
CSS and script.
Authors embed stories with plain HTML:
```html
<div
class="sai-player"
data-ink-format="visual-novel"
data-ink-story="/static/interactive/example/story.ink.json"
data-visual-manifest="/static/interactive/example/visual-manifest.json"
data-scene-label="Scene Name"
></div>
```
Supported formats:
- `data-ink-format="raven"` or omitted: cheap interactive-fiction transcript
layout for Raven Collective-style Ink.
- `data-ink-format="visual-novel"`: fixed scene view with bottom dialogue bar,
speaker avatar, and choices/continue controls inside the dialogue surface.
- `data-ink-format="cinematic"`: slide/deck layout with background plates,
captions, and optional references.
The legacy `data-ink-mode` attribute still works. Future sprite staging should
extend Sai rather than inventing another site-local player. Existing
`.aetheria-ink-player` containers are still initialised by Sai as a migration
bridge, but new embeds should use `.sai-player`.
## Shared Components
### `AutoIndexFolder`

1252
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -36,11 +36,9 @@
"dependencies": {
"@clack/prompts": "^0.11.0",
"@floating-ui/dom": "^1.7.4",
"@gamecult/sai": "github:GameCult/Sai#d070159ba575b2ee643f44222e89dcbb7ded7c49",
"@myriaddreamin/rehype-typst": "^0.6.0",
"@napi-rs/simple-git": "0.1.22",
"@tweenjs/tween.js": "^25.0.0",
"@vitejs/plugin-react": "^5.2.0",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^5.0.0",
@ -66,8 +64,6 @@
"preact-render-to-string": "^6.6.5",
"pretty-bytes": "^7.1.0",
"pretty-time": "^1.1.0",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"reading-time": "^1.5.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.3.1",
@ -95,7 +91,6 @@
"unified": "^11.0.5",
"unist-util-visit": "^5.1.0",
"vfile": "^6.0.3",
"vite": "^7.3.3",
"workerpool": "^10.0.1",
"ws": "^8.19.0",
"yargs": "^18.0.0"
@ -106,8 +101,6 @@
"@types/js-yaml": "^4.0.9",
"@types/node": "^25.0.10",
"@types/pretty-time": "^1.1.5",
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2",
"@types/source-map-support": "^0.5.10",
"@types/ws": "^8.18.1",
"@types/yargs": "^17.0.35",

View file

@ -7,11 +7,14 @@
"build": "vite build --base ./"
},
"dependencies": {
"@vitejs/plugin-react": "^5.1.1",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"@vitejs/plugin-react": "^5.2.0",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"typescript": "^5.9.3",
"vite": "^7.2.4"
"vite": "^7.3.3"
},
"devDependencies": {}
"devDependencies": {
"@types/react": "^19.2.2",
"@types/react-dom": "^19.2.2"
}
}

View file

@ -874,14 +874,9 @@ function mountGameCultGraph() {
})
}
function scheduleGameCultGraphMount() {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => mountGameCultGraph())
} else {
mountGameCultGraph()
window.setTimeout(mountGameCultGraph, 50)
window.setTimeout(mountGameCultGraph, 300)
window.setTimeout(mountGameCultGraph, 1000)
window.setTimeout(mountGameCultGraph, 2000)
}
document.addEventListener("nav", scheduleGameCultGraphMount)
document.addEventListener("DOMContentLoaded", scheduleGameCultGraphMount)
scheduleGameCultGraphMount()
document.addEventListener("nav", () => mountGameCultGraph())

View file

@ -7,7 +7,6 @@ export { Assets } from "./assets"
export { Static } from "./static"
export { Favicon } from "./favicon"
export { ComponentResources } from "./componentResources"
export { InkEmbedder } from "./inkEmbedder"
export { NotFoundPage } from "./404"
export { CNAME } from "./cname"
export { CustomOgImages } from "./ogImage"

View file

@ -1,7 +1,7 @@
import { QuartzEmitterPlugin } from "../types"
import { i18n } from "../../i18n"
import { unescapeHTML } from "../../util/escape"
import { FullSlug, getFileExtension, isAbsoluteURL, joinSegments, QUARTZ } from "../../util/path"
import { FullSlug, getFileExtension, isAbsoluteURL } from "../../util/path"
import { ImageOptions, SocialImageOptions, defaultImage, getSatoriFonts } from "../../util/og"
import sharp from "sharp"
import satori, { SatoriOptions } from "satori"
@ -12,12 +12,12 @@ import { BuildCtx } from "../../util/ctx"
import { QuartzPluginData } from "../vfile"
import fs from "node:fs/promises"
import { styleText } from "util"
import { SiteSocialMetadata } from "../../util/siteOg"
import {
resolveSocialDeck,
resolveSocialDescription,
resolveSocialImage,
resolveSocialMetadata,
resolveSocialSection,
socialImageLocalPath,
socialImageUrl,
} from "../../util/social"
@ -51,21 +51,13 @@ function imageMimeType(filePath: string) {
* @param opts options for generating image
*/
async function generateSocialImage(
{ cfg, description, deck, section, fonts, title, fileData }: ImageOptions,
{ cfg, description, deck, fonts, title, fileData }: ImageOptions,
userOpts: SocialImageOptions,
socialMetadata: SiteSocialMetadata = resolveSocialMetadata(fileData),
): Promise<Readable> {
const { width, height } = userOpts
const iconPath = joinSegments(QUARTZ, "static", "icon.png")
let iconBase64: string | undefined = undefined
let imageBase64: string | undefined = undefined
try {
const iconData = await fs.readFile(iconPath)
iconBase64 = `data:image/png;base64,${iconData.toString("base64")}`
} catch (err) {
console.warn(styleText("yellow", `Warning: Could not find icon at ${iconPath}`))
}
const socialMetadata = resolveSocialMetadata(fileData)
const socialImage = resolveSocialImage(fileData, socialMetadata)
const localImagePath = socialImageLocalPath(fileData, socialImage)
@ -91,10 +83,8 @@ async function generateSocialImage(
title,
description,
deck,
section,
fonts,
fileData,
iconBase64,
imageBase64,
})
@ -129,21 +119,20 @@ async function processOgImage(
fileData,
unescapeHTML(i18n(cfg.locale).propertyDefaults.description),
)
const siteMetadata = resolveSocialMetadata(fileData)
const deck = resolveSocialDeck(fileData, description, siteMetadata)
const section = resolveSocialSection(fileData, siteMetadata)
const socialMetadata = resolveSocialMetadata(fileData)
const deck = resolveSocialDeck(fileData, description, socialMetadata)
const stream = await generateSocialImage(
{
title,
description,
deck,
section,
fonts,
cfg,
fileData,
},
fullOptions,
socialMetadata,
)
return write({
@ -204,11 +193,15 @@ export const CustomOgImages: QuartzEmitterPlugin<Partial<SocialImageOptions>> =
const generatedOgImagePath = useGeneratedCard
? `https://${baseUrl}/${pageData.slug!}-og-image.webp`
: undefined
const pageSiteMetadata = resolveSocialMetadata(pageData)
const pageSocialImage = resolveSocialImage(pageData, pageSiteMetadata)
const imageFromMetadata = socialImageUrl(baseUrl, pageData, pageSocialImage)
const defaultOgImagePath = `https://${baseUrl}/static/og-image.png`
const ogImagePath = generatedOgImagePath ?? imageFromMetadata ?? defaultOgImagePath
const ogImagePath =
generatedOgImagePath ??
socialImageUrl(
baseUrl,
pageData,
resolveSocialImage(pageData, resolveSocialMetadata(pageData)),
) ??
defaultOgImagePath
const ogImageMimeType = imageMimeType(ogImagePath)
return (
<>

View file

@ -107,3 +107,35 @@ test("extractDescriptionText keeps the first paragraph when it is normal content
"This first paragraph is the actual summary, not decorative throat-clearing.",
)
})
test("extractDescriptionText keeps an unquoted emphasized opening paragraph", () => {
const tree: Root = {
type: "root",
children: [
{
type: "element",
tagName: "h1",
properties: {},
children: [{ type: "text", value: "Why Aetheria Went Quiet" }],
},
{
type: "element",
tagName: "p",
properties: {},
children: [
{
type: "element",
tagName: "em",
properties: {},
children: [{ type: "text", value: "This opening note is emphasized, not a tagline." }],
},
],
},
],
}
assert.equal(
extractDescriptionText(tree, "Why Aetheria Went Quiet"),
"This opening note is emphasized, not a tagline.",
)
})

View file

@ -2,6 +2,7 @@ import { Element, Root as HTMLRoot, RootContent } from "hast"
import { toString } from "hast-util-to-string"
import { QuartzTransformerPlugin } from "../types"
import { escapeHTML } from "../../util/escape"
import { isStandaloneTagline } from "../../util/social"
export interface Options {
descriptionLength: number
@ -36,23 +37,6 @@ function isMeaningfulNode(node: RootContent): boolean {
return normalizeWhitespace(toString(node)).length > 0
}
function isStandalonePreviewTagline(node: RootContent): boolean {
if (!isElementNode(node) || node.tagName !== "p") {
return false
}
const meaningfulChildren = node.children.filter(
(child) => !(child.type === "text" && normalizeWhitespace(child.value).length === 0),
)
if (meaningfulChildren.length !== 1) {
return false
}
const onlyChild = meaningfulChildren[0]
return isElementNode(onlyChild) && ["em", "strong"].includes(onlyChild.tagName)
}
function isStructuredMetadataParagraph(node: RootContent): boolean {
if (!isElementNode(node) || node.tagName !== "p") {
return false
@ -80,7 +64,7 @@ export function extractDescriptionText(tree: HTMLRoot, pageTitle?: string): stri
startIdx++
}
if (startIdx < children.length && pageTitle && isStandalonePreviewTagline(children[startIdx])) {
if (startIdx < children.length && pageTitle && isStandaloneTagline(children[startIdx])) {
startIdx++
}

View file

@ -26,7 +26,7 @@ function stripSurroundingQuotes(value: string) {
.trim()
}
function isStandaloneTagline(node: RootContent) {
export function isStandaloneTagline(node: RootContent): boolean {
if (!isElementNode(node) || node.tagName !== "p") {
return false
}
@ -44,7 +44,7 @@ function isStandaloneTagline(node: RootContent) {
return taglinePattern.test(normalizeWhitespace(toString(child)))
}
function extractTopTagline(root?: HtmlRoot): string | undefined {
export function extractTopTagline(root?: HtmlRoot): string | undefined {
if (!root) {
return undefined
}

View file

@ -40,20 +40,6 @@ async function exists(targetPath) {
}
}
async function linkNodeModules(graphRoot) {
const source = path.join(engineRoot, "node_modules")
const dest = path.join(graphRoot, "node_modules")
if (!(await exists(source))) {
throw new Error(
"GameCult-Quartz dependencies are missing. Run `npm ci` in the GameCult-Quartz repo first.",
)
}
await fs.rm(dest, { recursive: true, force: true })
await fs.symlink(source, dest, "junction")
}
async function prepareNorn(nornRoot) {
const viewerRoot = path.join(nornRoot, "web", "norn-viewer")
const revisionPath = path.join(engineRoot, "quartz", "graph-spa", "norn-revision.txt")
@ -186,7 +172,10 @@ async function main() {
}
await buildNorn(norn)
await linkNodeModules(graphRoot)
const vitePath = path.join(graphRoot, "node_modules", "vite", "bin", "vite.js")
if (!(await exists(vitePath))) {
throw new Error(`Graph SPA dependencies are missing. Run npm install in '${graphRoot}'.`)
}
await runProcess(
process.execPath,
["./node_modules/vite/bin/vite.js", "build", "--base", "./"],

View file

@ -74,7 +74,7 @@ async function copyEngineScaffold(runtimeRoot) {
recursive: true,
filter: (candidate) => {
const relative = path.relative(engineRoot, candidate).split(path.sep).join("/")
return relative !== "quartz/graph-spa/node_modules"
return relative !== "quartz/graph-spa"
},
})
} else {