From efeabd32d38eeff3566556423c8927bcd964d65e Mon Sep 17 00:00:00 2001 From: Jack Steam Date: Tue, 17 Nov 2026 15:29:05 -0600 Subject: [PATCH 1/3] feat: import interactive birth-chart homepage hero --- scripts/home-chart.ts | 70 +++ src/lib/ExplorerChart.svelte | 17 +- src/lib/Wheel.svelte | 415 ++++++++-------- src/lib/home/chart.json | 824 ++++++++++++++++++++++++++++++++ src/lib/home/visible.ts | 29 ++ src/lib/selection.ts | 2 + src/lib/wheel/events.ts | 15 + src/routes/+page.svelte | 347 +++++++++----- tests/exploration.spec.ts | 16 + tests/home.spec.ts | 157 +++++- verification/home-chart.test.ts | 60 +++ 11 files changed, 1578 insertions(+), 374 deletions(-) create mode 100644 scripts/home-chart.ts create mode 100644 src/lib/home/chart.json create mode 100644 src/lib/home/visible.ts create mode 100644 src/lib/wheel/events.ts create mode 100644 verification/home-chart.test.ts diff --git a/scripts/home-chart.ts b/scripts/home-chart.ts new file mode 100644 index 0000000..8475239 --- /dev/null +++ b/scripts/home-chart.ts @@ -0,0 +1,70 @@ +// Generates the homepage's sample chart (src/lib/home/chart.json) with the +// app's engine and settings. The moment is anonymous on the page; it was +// chosen so a few major planets sit in the visible bottom-left quarter. +// +// bun scripts/home-chart.ts +import { spawnSync } from "node:child_process"; +import { readFileSync, writeFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; +import { chartSchema, deriveAstrology } from "../src/lib/calculation/chart"; +import { initialSettings } from "../src/lib/domain"; + +export const SAMPLE = { + utc: "2014-06-06T03:00:00Z", + latitude: 51.5074, + longitude: -0.1278, +}; + +const root = fileURLToPath(new URL("../static/engine/", import.meta.url)); +const engine = await import(`${root}chart.js`); +engine.initSync({ module: readFileSync(`${root}chart_bg.wasm`) }); +const index = JSON.parse( + readFileSync(`${root}ephemeris/index.json`, "utf8"), +) as { segments: { year: number; url: string }[] }; +const slices = new Map(); +const slice = (year: number) => { + let bytes = slices.get(year); + if (!bytes) { + const segment = index.segments.find((s) => s.year === year); + if (!segment) throw new Error(`No ephemeris for ${year}`); + bytes = readFileSync(`${root}ephemeris/${segment.url}`); + slices.set(year, bytes); + } + return bytes; +}; + +/** The chart and aspects the app would show for this moment and place. */ +export const calculate = ({ utc, latitude, longitude }: typeof SAMPLE) => { + const { reference, divisions, houses } = initialSettings; + const chart = chartSchema.parse( + JSON.parse( + engine.calculate( + slice(new Date(utc).getUTCFullYear()), + JSON.stringify({ + instant: { scale: "utc", value: utc }, + latitude, + longitude, + house_system: houses, + configuration: { reference, divisions, ophiuchus: null }, + }), + ), + ), + ); + const { aspects } = deriveAstrology(chart, chart, initialSettings.atmakaraka); + return { chart, aspects }; +}; + +if (import.meta.main) { + const out = fileURLToPath( + new URL("../src/lib/home/chart.json", import.meta.url), + ); + writeFileSync(out, JSON.stringify(calculate(SAMPLE)) + "\n"); + // Keep the file in the repository's format. + const format = spawnSync( + "bun", + ["x", "oxfmt", "--disable-nested-config", out], + { stdio: "inherit" }, + ); + if (format.status !== 0) throw new Error("oxfmt failed"); + console.log(`Wrote ${out}`); +} diff --git a/src/lib/ExplorerChart.svelte b/src/lib/ExplorerChart.svelte index dfab538..fa823e7 100644 --- a/src/lib/ExplorerChart.svelte +++ b/src/lib/ExplorerChart.svelte @@ -202,24 +202,19 @@ + choose(glyph, origin, keyboard)} onexposeGroup={() => measurement?.expose("body_picker")} onopenGroup={() => { measurement?.use("body_picker"); measurement?.interaction("navigation"); }} - onselectAspects={(near, target) => + onaspectclick={({ aspects: near, origin }) => openPicker( near, - target, + origin, body && near.some((a) => a.planetA === body.name || a.planetB === body.name) ? body.name diff --git a/src/lib/Wheel.svelte b/src/lib/Wheel.svelte index 7893479..b3c6b6b 100644 --- a/src/lib/Wheel.svelte +++ b/src/lib/Wheel.svelte @@ -1,5 +1,5 @@ - { - if (event.key === "Escape" && !event.defaultPrevented && selected) { - selected = null; - } - }} -/> +
{ if (!(e.target instanceof Element) || !e.target.closest("[data-glyph]")) { const svg = e.currentTarget; const matrix = svg.getScreenCTM(); - if (matrix && onselectAspects) { + if (matrix && onaspectclick) { const p = new DOMPoint(e.clientX, e.clientY).matrixTransform( matrix.inverse(), ); @@ -232,15 +253,21 @@ .filter((line) => distance(line) < 11) .map((line) => line.aspect); if (near.length) { - onselectAspects(near, svg, false); + onaspectclick({ + aspects: near, + origin: svg, + keyboard: false, + x: e.pageX, + y: e.pageY, + }); return; } } - clear(); + onblank(); } }} onkeydown={(e) => { - if (e.target === e.currentTarget && e.key === "Escape") clear(); + if (e.target === e.currentTarget && e.key === "Escape") onblank(); }} > - {#if onselectHouse} - {#each chart.cusps as cusp, i (i)} + {#each chart.cusps as cusp, i (i)} + {@const glyph = { kind: "house", number: i + 1 } as const} + {#if isOn(glyph)} {@const next = chart.cusps[(i + 1) % 12]} onselectHouse?.(i + 1, e.currentTarget, false)} - onkeydown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - onselectHouse?.(i + 1, e.currentTarget, true); - } - }} + {...handlers(glyph)} /> - {/each} - {/if} + {/if} + {/each} {#each chart.zodiac_sectors as sign (sign.sign)} {@const a = point(sign.start_degrees, 231)}{@const b = point( sign.start_degrees, @@ -377,15 +399,13 @@ y2={b.y} stroke="var(--w-faint)" /> - {#if onselectSign} + {@const glyph = { kind: "sign", name: sign.sign } as const} + {#if isOn(glyph)} onselectSign?.(sign.sign, e.currentTarget, false)} - onkeydown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - onselectSign?.(sign.sign, e.currentTarget, true); - } - }} /> {/if} - onselectSign - ? onselectSign(sign.sign, e.currentTarget, false) - : select(sign.sign, p.x, p.y)} - onkeydown={(e) => { - if (onselectSign && (e.key === "Enter" || e.key === " ")) { - e.preventDefault(); - onselectSign(sign.sign, e.currentTarget, true); - } else if (!onselectSign) keySelect(e, sign.sign, p.x, p.y); - }} > {/each} - {#if onselectAngle} - {#each ["ASCENDANT_SYMBOL", "MIDHEAVEN", "DESCENDANT", "IMUM_COELI"].map( (body) => ({ body, name: copy().pointName(body) }) ) as angle (angle.body)} + {#each angleIds as name (name)} + {@const glyph = { kind: "angle", name } as const} + {#if isOn(glyph)} {@const p = point( - chart.bodies.find((b) => b.name === angle.body)!.longitude, + chart.bodies.find((b) => b.name === name)!.longitude, 293, )} - - onselectAngle?.( - angle.body as Chart["bodies"][number]["name"], - e.currentTarget, - false, - )} - onkeydown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - onselectAngle?.( - angle.body as Chart["bodies"][number]["name"], - e.currentTarget, - true, - ); - } - }}> - {/each} - {/if} + {/if} + {/each}
{#if picker} circle:first-of-type { + stroke: var(--glyph-focus, var(--w-strong)); + stroke-width: 2.5; + } + path[role="button"]:hover { + fill: color-mix(in srgb, var(--w-strong) 7%, transparent); + } } diff --git a/src/lib/home/chart.json b/src/lib/home/chart.json new file mode 100644 index 0000000..d3a9707 --- /dev/null +++ b/src/lib/home/chart.json @@ -0,0 +1,824 @@ +{ + "chart": { + "configuration": { + "reference": "tropical", + "divisions": "equal", + "ophiuchus": null + }, + "convention_revision": "astrology-engine-conventions-v1", + "reference_offset_degrees": 0, + "speed_reference": "tropical", + "bodies": [ + { + "name": "SUN", + "longitude": 75.35692435875339, + "speed": 0.9571389887736359, + "declination": 22.630656047492874, + "sign": { + "sign": "gemini", + "degrees_in_sign": 15.356924358753389, + "width_degrees": 30 + } + }, + { + "name": "EARTH", + "longitude": 255.3569243587534, + "speed": 0.9571389887736359, + "declination": 22.630656047492874, + "sign": { + "sign": "sagittarius", + "degrees_in_sign": 15.356924358753389, + "width_degrees": 30 + } + }, + { + "name": "MOON", + "longitude": 168.29875797577108, + "speed": 12.098271373742818, + "declination": 1.6452104896722504, + "sign": { + "sign": "virgo", + "degrees_in_sign": 18.298757975771082, + "width_degrees": 30 + } + }, + { + "name": "NORTH_NODE", + "longitude": 207.20767909723023, + "speed": 0.005221937927672116, + "declination": -10.476891288437802, + "sign": { + "sign": "libra", + "degrees_in_sign": 27.207679097230226, + "width_degrees": 30 + } + }, + { + "name": "SOUTH_NODE", + "longitude": 27.207679097230198, + "speed": 0.005221937927672116, + "declination": -10.476891288437802, + "sign": { + "sign": "aries", + "degrees_in_sign": 27.207679097230198, + "width_degrees": 30 + } + }, + { + "name": "MERCURY", + "longitude": 93.09599564929756, + "speed": 0.10460808552818435, + "declination": 23.257732642620084, + "sign": { + "sign": "cancer", + "degrees_in_sign": 3.0959956492975635, + "width_degrees": 30 + } + }, + { + "name": "VENUS", + "longitude": 39.4355340059789, + "speed": 1.1751035517437458, + "declination": 12.743594283716874, + "sign": { + "sign": "taurus", + "degrees_in_sign": 9.435534005978901, + "width_degrees": 30 + } + }, + { + "name": "MARS", + "longitude": 190.77756472856265, + "speed": 0.19763595589222405, + "declination": -4.103057516079762, + "sign": { + "sign": "libra", + "degrees_in_sign": 10.777564728562652, + "width_degrees": 30 + } + }, + { + "name": "JUPITER", + "longitude": 111.3837180860551, + "speed": 0.20019821234893698, + "declination": 22.068516445647354, + "sign": { + "sign": "cancer", + "degrees_in_sign": 21.383718086055097, + "width_degrees": 30 + } + }, + { + "name": "SATURN", + "longitude": 228.1507893318557, + "speed": -0.06231641702538582, + "declination": -14.888522897054736, + "sign": { + "sign": "scorpio", + "degrees_in_sign": 18.15078933185569, + "width_degrees": 30 + } + }, + { + "name": "URANUS", + "longitude": 15.677386524069638, + "speed": 0.034790388006285866, + "declination": 5.561697139316441, + "sign": { + "sign": "aries", + "degrees_in_sign": 15.677386524069638, + "width_degrees": 30 + } + }, + { + "name": "NEPTUNE", + "longitude": 337.59201856616374, + "speed": 0.001978159769123522, + "declination": -9.383853581056195, + "sign": { + "sign": "pisces", + "degrees_in_sign": 7.592018566163745, + "width_degrees": 30 + } + }, + { + "name": "PLUTO", + "longitude": 282.9631839236673, + "speed": -0.021453688967540074, + "declination": -20.17400273473094, + "sign": { + "sign": "capricorn", + "degrees_in_sign": 12.963183923667316, + "width_degrees": 30 + } + }, + { + "name": "CHIRON", + "longitude": 347.6636680830835, + "speed": 0.013106537051953637, + "declination": -0.34062602287363264, + "sign": { + "sign": "pisces", + "degrees_in_sign": 17.663668083083508, + "width_degrees": 30 + } + }, + { + "name": "CERES", + "longitude": 198.59835401163164, + "speed": 0.02773184743296042, + "declination": 1.8428660884346484, + "sign": { + "sign": "libra", + "degrees_in_sign": 18.598354011631642, + "width_degrees": 30 + } + }, + { + "name": "ASCENDANT_SYMBOL", + "longitude": 58.52870552091943, + "speed": 0, + "declination": 0, + "sign": { + "sign": "taurus", + "degrees_in_sign": 28.52870552091943, + "width_degrees": 30 + } + }, + { + "name": "MIDHEAVEN", + "longitude": 297.2686115650516, + "speed": 0, + "declination": 0, + "sign": { + "sign": "capricorn", + "degrees_in_sign": 27.26861156505157, + "width_degrees": 30 + } + }, + { + "name": "DESCENDANT", + "longitude": 238.52870552091943, + "speed": 0, + "declination": 0, + "sign": { + "sign": "scorpio", + "degrees_in_sign": 28.52870552091943, + "width_degrees": 30 + } + }, + { + "name": "IMUM_COELI", + "longitude": 117.26861156505157, + "speed": 0, + "declination": 0, + "sign": { + "sign": "cancer", + "degrees_in_sign": 27.26861156505157, + "width_degrees": 30 + } + } + ], + "zodiac_sectors": [ + { "sign": "aries", "start_degrees": 0, "width_degrees": 30 }, + { "sign": "taurus", "start_degrees": 30, "width_degrees": 30 }, + { "sign": "gemini", "start_degrees": 60, "width_degrees": 30 }, + { "sign": "cancer", "start_degrees": 90, "width_degrees": 30 }, + { "sign": "leo", "start_degrees": 120, "width_degrees": 30 }, + { "sign": "virgo", "start_degrees": 150, "width_degrees": 30 }, + { "sign": "libra", "start_degrees": 180, "width_degrees": 30 }, + { "sign": "scorpio", "start_degrees": 210, "width_degrees": 30 }, + { "sign": "sagittarius", "start_degrees": 240, "width_degrees": 30 }, + { "sign": "capricorn", "start_degrees": 270, "width_degrees": 30 }, + { "sign": "aquarius", "start_degrees": 300, "width_degrees": 30 }, + { "sign": "pisces", "start_degrees": 330, "width_degrees": 30 } + ], + "house_sectors": [ + { "sign": "aries", "start_degrees": 0, "width_degrees": 30 }, + { "sign": "taurus", "start_degrees": 30, "width_degrees": 30 }, + { "sign": "gemini", "start_degrees": 60, "width_degrees": 30 }, + { "sign": "cancer", "start_degrees": 90, "width_degrees": 30 }, + { "sign": "leo", "start_degrees": 120, "width_degrees": 30 }, + { "sign": "virgo", "start_degrees": 150, "width_degrees": 30 }, + { "sign": "libra", "start_degrees": 180, "width_degrees": 30 }, + { "sign": "scorpio", "start_degrees": 210, "width_degrees": 30 }, + { "sign": "sagittarius", "start_degrees": 240, "width_degrees": 30 }, + { "sign": "capricorn", "start_degrees": 270, "width_degrees": 30 }, + { "sign": "aquarius", "start_degrees": 300, "width_degrees": 30 }, + { "sign": "pisces", "start_degrees": 330, "width_degrees": 30 } + ], + "cusps": [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 0], + "requested_house_system": "whole-sign", + "house_system": "whole-sign" + }, + "aspects": [ + { + "planetA": "SUN", + "planetB": "EARTH", + "type": "Opposition", + "angle": 180, + "orb": 0, + "status": "separating" + }, + { + "planetA": "SUN", + "planetB": "MOON", + "type": "Square", + "angle": 92.94183361701769, + "orb": 2.941833617017693, + "status": "separating" + }, + { + "planetA": "SUN", + "planetB": "MARS", + "type": "Trine", + "angle": 115.42064036980926, + "orb": 4.579359630190737, + "status": "separating" + }, + { + "planetA": "SUN", + "planetB": "SATURN", + "type": "Quincunx", + "angle": 152.7938649731023, + "orb": 2.793864973102302, + "status": "applying" + }, + { + "planetA": "SUN", + "planetB": "URANUS", + "type": "Sextile", + "angle": 59.67953783468375, + "orb": 0.3204621653162505, + "status": "applying" + }, + { + "planetA": "SUN", + "planetB": "NEPTUNE", + "type": "Square", + "angle": 97.76490579258962, + "orb": 7.764905792589616, + "status": "separating" + }, + { + "planetA": "SUN", + "planetB": "PLUTO", + "type": "Quincunx", + "angle": 152.39374043508607, + "orb": 2.393740435086073, + "status": "separating" + }, + { + "planetA": "SUN", + "planetB": "CHIRON", + "type": "Square", + "angle": 87.69325627566991, + "orb": 2.30674372433009, + "status": "applying" + }, + { + "planetA": "SUN", + "planetB": "CERES", + "type": "Trine", + "angle": 123.24142965287825, + "orb": 3.241429652878253, + "status": "applying" + }, + { + "planetA": "EARTH", + "planetB": "MOON", + "type": "Square", + "angle": 87.05816638298231, + "orb": 2.941833617017693, + "status": "separating" + }, + { + "planetA": "EARTH", + "planetB": "MARS", + "type": "Sextile", + "angle": 64.57935963019074, + "orb": 4.579359630190737, + "status": "separating" + }, + { + "planetA": "EARTH", + "planetB": "URANUS", + "type": "Trine", + "angle": 120.32046216531626, + "orb": 0.3204621653162576, + "status": "applying" + }, + { + "planetA": "EARTH", + "planetB": "NEPTUNE", + "type": "Square", + "angle": 82.23509420741036, + "orb": 7.764905792589644, + "status": "separating" + }, + { + "planetA": "EARTH", + "planetB": "CHIRON", + "type": "Square", + "angle": 92.30674372433012, + "orb": 2.3067437243301185, + "status": "applying" + }, + { + "planetA": "EARTH", + "planetB": "CERES", + "type": "Sextile", + "angle": 56.75857034712175, + "orb": 3.241429652878253, + "status": "applying" + }, + { + "planetA": "MOON", + "planetB": "JUPITER", + "type": "Sextile", + "angle": 56.915039889715985, + "orb": 3.0849601102840154, + "status": "applying" + }, + { + "planetA": "MOON", + "planetB": "SATURN", + "type": "Sextile", + "angle": 59.85203135608461, + "orb": 0.14796864391539089, + "status": "separating" + }, + { + "planetA": "MOON", + "planetB": "URANUS", + "type": "Quincunx", + "angle": 152.62137145170144, + "orb": 2.6213714517014353, + "status": "separating" + }, + { + "planetA": "MOON", + "planetB": "PLUTO", + "type": "Trine", + "angle": 114.66442594789623, + "orb": 5.335574052103766, + "status": "separating" + }, + { + "planetA": "MOON", + "planetB": "CHIRON", + "type": "Opposition", + "angle": 179.36491010731243, + "orb": 0.6350898926875743, + "status": "separating" + }, + { + "planetA": "MOON", + "planetB": "CERES", + "type": "Semisextile", + "angle": 30.29959603586056, + "orb": 0.29959603586056005, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "SOUTH_NODE", + "type": "Opposition", + "angle": 179.99999999999997, + "orb": 2.842170943040401e-14, + "status": "separating" + }, + { + "planetA": "NORTH_NODE", + "planetB": "MERCURY", + "type": "Trine", + "angle": 114.11168344793266, + "orb": 5.888316552067337, + "status": "separating" + }, + { + "planetA": "NORTH_NODE", + "planetB": "JUPITER", + "type": "Square", + "angle": 95.82396101117513, + "orb": 5.823961011175129, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "CERES", + "type": "Conjunction", + "angle": 8.609325085598584, + "orb": 8.609325085598584, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "ASCENDANT_SYMBOL", + "type": "Quincunx", + "angle": 148.6789735763108, + "orb": 1.3210264236892044, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "MIDHEAVEN", + "type": "Square", + "angle": 90.06093246782135, + "orb": 0.060932467821345426, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "DESCENDANT", + "type": "Semisextile", + "angle": 31.321026423689204, + "orb": 1.3210264236892044, + "status": "applying" + }, + { + "planetA": "NORTH_NODE", + "planetB": "IMUM_COELI", + "type": "Square", + "angle": 89.93906753217865, + "orb": 0.060932467821345426, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "MERCURY", + "type": "Sextile", + "angle": 65.88831655206737, + "orb": 5.888316552067366, + "status": "separating" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "JUPITER", + "type": "Square", + "angle": 84.1760389888249, + "orb": 5.823961011175101, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "CERES", + "type": "Opposition", + "angle": 171.39067491440144, + "orb": 8.609325085598556, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "ASCENDANT_SYMBOL", + "type": "Semisextile", + "angle": 31.321026423689233, + "orb": 1.3210264236892328, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "MIDHEAVEN", + "type": "Square", + "angle": 89.93906753217863, + "orb": 0.06093246782137385, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "DESCENDANT", + "type": "Quincunx", + "angle": 148.67897357631077, + "orb": 1.3210264236892328, + "status": "applying" + }, + { + "planetA": "SOUTH_NODE", + "planetB": "IMUM_COELI", + "type": "Square", + "angle": 90.06093246782137, + "orb": 0.06093246782137385, + "status": "applying" + }, + { + "planetA": "MERCURY", + "planetB": "MARS", + "type": "Square", + "angle": 97.68156907926509, + "orb": 7.681569079265088, + "status": "separating" + }, + { + "planetA": "MERCURY", + "planetB": "NEPTUNE", + "type": "Trine", + "angle": 115.5039770831338, + "orb": 4.496022916866195, + "status": "applying" + }, + { + "planetA": "MERCURY", + "planetB": "PLUTO", + "type": "Opposition", + "angle": 170.13281172563023, + "orb": 9.867188274369767, + "status": "applying" + }, + { + "planetA": "VENUS", + "planetB": "MARS", + "type": "Quincunx", + "angle": 151.34203072258376, + "orb": 1.3420307225837576, + "status": "applying" + }, + { + "planetA": "VENUS", + "planetB": "SATURN", + "type": "Opposition", + "angle": 171.2847446741232, + "orb": 8.715255325876797, + "status": "applying" + }, + { + "planetA": "VENUS", + "planetB": "NEPTUNE", + "type": "Sextile", + "angle": 61.84351543981518, + "orb": 1.843515439815178, + "status": "separating" + }, + { + "planetA": "VENUS", + "planetB": "PLUTO", + "type": "Trine", + "angle": 116.47235008231158, + "orb": 3.5276499176884215, + "status": "applying" + }, + { + "planetA": "MARS", + "planetB": "URANUS", + "type": "Opposition", + "angle": 175.100178204493, + "orb": 4.899821795506995, + "status": "applying" + }, + { + "planetA": "MARS", + "planetB": "PLUTO", + "type": "Square", + "angle": 92.18561919510466, + "orb": 2.185619195104664, + "status": "applying" + }, + { + "planetA": "MARS", + "planetB": "CERES", + "type": "Conjunction", + "angle": 7.82078928306899, + "orb": 7.82078928306899, + "status": "applying" + }, + { + "planetA": "JUPITER", + "planetB": "SATURN", + "type": "Trine", + "angle": 116.7670712458006, + "orb": 3.2329287541994063, + "status": "separating" + }, + { + "planetA": "JUPITER", + "planetB": "URANUS", + "type": "Square", + "angle": 95.70633156198546, + "orb": 5.706331561985465, + "status": "separating" + }, + { + "planetA": "JUPITER", + "planetB": "PLUTO", + "type": "Opposition", + "angle": 171.57946583761222, + "orb": 8.420534162387781, + "status": "separating" + }, + { + "planetA": "JUPITER", + "planetB": "CHIRON", + "type": "Trine", + "angle": 123.72005000297159, + "orb": 3.7200500029715897, + "status": "separating" + }, + { + "planetA": "JUPITER", + "planetB": "CERES", + "type": "Square", + "angle": 87.21463592557654, + "orb": 2.7853640744234553, + "status": "separating" + }, + { + "planetA": "JUPITER", + "planetB": "MIDHEAVEN", + "type": "Opposition", + "angle": 174.11510652100353, + "orb": 5.884893478996474, + "status": "applying" + }, + { + "planetA": "JUPITER", + "planetB": "DESCENDANT", + "type": "Trine", + "angle": 127.14498743486433, + "orb": 7.144987434864333, + "status": "applying" + }, + { + "planetA": "JUPITER", + "planetB": "IMUM_COELI", + "type": "Conjunction", + "angle": 5.884893478996474, + "orb": 5.884893478996474, + "status": "applying" + }, + { + "planetA": "SATURN", + "planetB": "URANUS", + "type": "Quincunx", + "angle": 147.52659719221396, + "orb": 2.4734028077860444, + "status": "applying" + }, + { + "planetA": "SATURN", + "planetB": "PLUTO", + "type": "Sextile", + "angle": 54.812394591811625, + "orb": 5.187605408188375, + "status": "applying" + }, + { + "planetA": "SATURN", + "planetB": "CHIRON", + "type": "Trine", + "angle": 119.51287875122782, + "orb": 0.48712124877218343, + "status": "applying" + }, + { + "planetA": "SATURN", + "planetB": "CERES", + "type": "Semisextile", + "angle": 29.55243532022405, + "orb": 0.44756467977595094, + "status": "separating" + }, + { + "planetA": "URANUS", + "planetB": "PLUTO", + "type": "Square", + "angle": 92.7142026004023, + "orb": 2.7142026004023023, + "status": "separating" + }, + { + "planetA": "URANUS", + "planetB": "CHIRON", + "type": "Semisextile", + "angle": 28.01371844098611, + "orb": 1.9862815590138894, + "status": "applying" + }, + { + "planetA": "URANUS", + "planetB": "CERES", + "type": "Opposition", + "angle": 177.079032512438, + "orb": 2.9209674875619953, + "status": "applying" + }, + { + "planetA": "NEPTUNE", + "planetB": "PLUTO", + "type": "Sextile", + "angle": 54.62883464249643, + "orb": 5.371165357503571, + "status": "applying" + }, + { + "planetA": "PLUTO", + "planetB": "CHIRON", + "type": "Sextile", + "angle": 64.70048415941619, + "orb": 4.700484159416192, + "status": "separating" + }, + { + "planetA": "PLUTO", + "planetB": "CERES", + "type": "Square", + "angle": 84.36482991203567, + "orb": 5.635170087964326, + "status": "separating" + }, + { + "planetA": "CHIRON", + "planetB": "CERES", + "type": "Quincunx", + "angle": 149.06531407145187, + "orb": 0.9346859285481344, + "status": "separating" + }, + { + "planetA": "ASCENDANT_SYMBOL", + "planetB": "MIDHEAVEN", + "type": "Trine", + "angle": 121.26009395586786, + "orb": 1.260093955867859, + "status": "separating" + }, + { + "planetA": "ASCENDANT_SYMBOL", + "planetB": "DESCENDANT", + "type": "Opposition", + "angle": 180, + "orb": 0, + "status": "separating" + }, + { + "planetA": "ASCENDANT_SYMBOL", + "planetB": "IMUM_COELI", + "type": "Sextile", + "angle": 58.73990604413214, + "orb": 1.260093955867859, + "status": "separating" + }, + { + "planetA": "MIDHEAVEN", + "planetB": "DESCENDANT", + "type": "Sextile", + "angle": 58.73990604413214, + "orb": 1.260093955867859, + "status": "separating" + }, + { + "planetA": "MIDHEAVEN", + "planetB": "IMUM_COELI", + "type": "Opposition", + "angle": 180, + "orb": 0, + "status": "separating" + }, + { + "planetA": "DESCENDANT", + "planetB": "IMUM_COELI", + "type": "Trine", + "angle": 121.26009395586786, + "orb": 1.260093955867859, + "status": "separating" + } + ] +} diff --git a/src/lib/home/visible.ts b/src/lib/home/visible.ts new file mode 100644 index 0000000..a07cff8 --- /dev/null +++ b/src/lib/home/visible.ts @@ -0,0 +1,29 @@ +import type { Chart } from "../calculation/chart"; +import type { Glyph } from "../selection"; + +/** + * Glyphs in the wheel's bottom-left quarter, the part the homepage shows in + * full: 0–90° past the Ascendant. Signs and houses count by their midpoint. + */ +export const inVisibleQuarter = (chart: Chart) => { + const longitude = (name: string) => + chart.bodies.find((body) => body.name === name)!.longitude; + const asc = longitude("ASCENDANT_SYMBOL"); + const visible = (at: number) => (at - asc + 720) % 360 <= 90; + return (glyph: Glyph) => { + switch (glyph.kind) { + case "body": + case "angle": + return visible(longitude(glyph.name)); + case "sign": { + const sign = chart.zodiac_sectors.find((s) => s.sign === glyph.name)!; + return visible(sign.start_degrees + sign.width_degrees / 2); + } + case "house": { + const start = chart.cusps[glyph.number - 1]!; + const end = chart.cusps[glyph.number % chart.cusps.length]!; + return visible(start + ((end - start + 360) % 360) / 2); + } + } + }; +}; diff --git a/src/lib/selection.ts b/src/lib/selection.ts index 065f5f5..4b7c43d 100644 --- a/src/lib/selection.ts +++ b/src/lib/selection.ts @@ -14,6 +14,8 @@ export type Selection = second: BodyName; aspectType: Aspect["type"]; }; +/** A clickable point on the wheel: everything selectable except aspects. */ +export type Glyph = Exclude; export const samePair = (aspect: Aspect, a: BodyName, b: BodyName) => (aspect.planetA === a && aspect.planetB === b) || (aspect.planetA === b && aspect.planetB === a); diff --git a/src/lib/wheel/events.ts b/src/lib/wheel/events.ts new file mode 100644 index 0000000..5a2b2a4 --- /dev/null +++ b/src/lib/wheel/events.ts @@ -0,0 +1,15 @@ +import type { Aspect, Glyph } from "../selection"; + +/** + * How a wheel item was activated. `x`/`y` are page coordinates: the pointer + * for mouse, touch and hover; the item's centre for keyboard activation. + */ +type Activation = { + origin: Element; + keyboard: boolean; + x: number; + y: number; +}; +export type GlyphEvent = Activation & { glyph: Glyph }; +/** Aspect lines near a click on the wheel's open space. */ +export type AspectEvent = Activation & { aspects: Aspect[] }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7642dd8..579b7f9 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,118 +1,160 @@ + { + if (event.key === "Escape" && info) info = null; + }} + onclick={(event) => { + // Clicks on the chart open, switch or close the card themselves. + if (event.target instanceof Node && !chartElement?.contains(event.target)) + info = null; + }} + onresize={() => { + // Width changes move the wheel; mobile toolbars only change the height. + if (info && window.innerWidth !== openedWidth) info = null; + }} +/> + {t("landing.meta.title")} -
-
- - {t("brand.name")} - {t("brand.beta")} - -
-
-
-

{t("landing.hero.eyebrow")}

-

- {#each copy().lines("landing.hero.title") as line, i (i)}{#if i}
{/if}{line}{/each} -

-

{t("landing.hero.description")}

- {t("landing.hero.cta")} -

{t("landing.hero.note")}

-
-
-
- {t("landing.sample.index")}{t("landing.sample.label")} +
+
+ + {t("brand.name")} + {t("brand.beta")} + +
+
+
+

{t("landing.hero.eyebrow")}

+

+ {#each copy().lines("landing.hero.title") as line, i (i)}{#if i}
{/if}{line}{/each} +

+

{t("landing.hero.description")}

+ {t("landing.hero.cta")} +

{t("landing.hero.note")}

+
+
+
+ hydrated && visible(glyph)} + crowding={false} + onglyphclick={({ glyph, x, y }) => show(glyph, x, y)} + onaspectclick={({ aspects: [aspect], x, y }) => + show( + { + kind: "aspect", + first: aspect.planetA, + second: aspect.planetB, + aspectType: aspect.type, + }, + x, + y, + )} + onblank={() => (info = null)} + /> +
- +
+ {t("landing.footer.brand")} +
{t("landing.footer.tagline")} ✳ + +
+
+ {#if info && content && position} +
- - - - - - - - - - - - - - - - 123 - - -
{t("landing.sample.caption")}
-
+ {content[0]} + {#if content[1]}

{content[1]}

{/if} +
+ {/if} -
- {t("landing.footer.brand")} - {t("landing.footer.tagline")} ✳ -
-
+ diff --git a/tests/exploration.spec.ts b/tests/exploration.spec.ts index 5f344a4..1d55d99 100644 --- a/tests/exploration.spec.ts +++ b/tests/exploration.spec.ts @@ -13,6 +13,22 @@ test("a visitor selects a body and reads its placement", async ({ page }) => { await expect(page.getByText("Retrograde", { exact: true })).toBeVisible(); }); +test("hovering a chart glyph highlights it without selecting it", async ({ + page, +}) => { + await page.goto("/app"); + await enterBirth(page); + const chart = page.getByRole("group", { name: /natal chart/i }); + const sun = chart.getByRole("button", { name: "Sun", exact: true }); + const ring = sun.locator("circle").first(); + await expect(ring).toHaveCSS("stroke", "none"); + await sun.hover(); + await expect(ring).toHaveCSS("stroke-width", "2.5px"); + await expect(sun).toHaveAttribute("aria-pressed", "false"); + await page.mouse.move(0, 0); + await expect(ring).toHaveCSS("stroke", "none"); +}); + test("keyboard selection focuses details and Escape returns to its origin", async ({ page, }) => { diff --git a/tests/home.spec.ts b/tests/home.spec.ts index 7917833..5b9439e 100644 --- a/tests/home.spec.ts +++ b/tests/home.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from "@playwright/test"; +import { test, expect, type Page } from "@playwright/test"; import { birthDialog, birthField, @@ -8,6 +8,15 @@ import { reopenBirth, } from "./helpers"; +const sampleChart = (page: Page) => + page.getByRole("group", { name: "SAMPLE CHART" }); +const glyph = (page: Page, name: string) => + sampleChart(page).getByRole("button", { name, exact: true }); +const SUN = + "The Sun symbolizes identity, purpose and the wish to express yourself."; +const JUPITER = + "Jupiter symbolizes growth through exploration, belief and a search for meaning."; + for (const viewport of [ { width: 1280, height: 800 }, { width: 390, height: 844 }, @@ -20,12 +29,8 @@ for (const viewport of [ await expect( page.getByRole("heading", { name: /explore your birth chart/i }), ).toBeVisible(); - await expect(page.getByText(/sample chart/i)).toBeVisible(); - await expect( - page.getByRole("img", { - name: /sample.*aries.*taurus.*gemini.*houses 1.*3/i, - }), - ).toBeVisible(); + for (const name of ["Sun", "Mercury", "Jupiter"]) + await expect(glyph(page, name)).toBeInViewport(); const start = page.getByRole("link", { name: /start exploring/i }); await start.focus(); await page.keyboard.press("Enter"); @@ -38,6 +43,144 @@ for (const viewport of [ }); } +test("sample chart glyphs open a card with their name and description", async ({ + page, +}) => { + await page.goto("/"); + const sun = glyph(page, "Sun"); + await sun.click(); + await expect(page.getByText(SUN)).toBeVisible(); + await expect(sun).toHaveAttribute("aria-pressed", "true"); + // Choosing it again closes the card; another glyph replaces it. + await sun.click(); + await expect(page.getByText(SUN)).toHaveCount(0); + await glyph(page, "Jupiter").click(); + await expect(page.getByText(JUPITER)).toBeVisible(); + await glyph(page, "Cancer").click(); + await expect( + page.getByText(/Cancer symbolizes emotional attachment/), + ).toBeVisible(); + await glyph(page, "House 3").click(); + await expect(page.getByText("House 3", { exact: true })).toBeVisible(); + await expect(page.getByText(/The third house represents/)).toBeVisible(); + await page.keyboard.press("Escape"); + await expect(page.getByText(/The third house represents/)).toHaveCount(0); + await glyph(page, "Imum Coeli").click(); + await expect(page.getByText(/The Imum Coeli is the point/)).toBeVisible(); + // A click outside the chart closes it. + await page + .getByRole("heading", { name: /explore your birth chart/i }) + .click(); + await expect(page.getByText(/The Imum Coeli is the point/)).toHaveCount(0); +}); + +test("a sample chart glyph opens from the keyboard and keeps focus", async ({ + page, +}) => { + await page.goto("/"); + const mercury = glyph(page, "Mercury"); + await mercury.focus(); + await page.keyboard.press("Enter"); + await expect(page.getByText(/Mercury symbolizes learning/)).toBeVisible(); + await expect(mercury).toBeFocused(); + await page.keyboard.press("Escape"); + await expect(page.getByText(/Mercury symbolizes learning/)).toHaveCount(0); + await expect(mercury).toBeFocused(); +}); + +test("hover highlights a sample chart glyph and aspect lines open a card", async ({ + page, +}) => { + await page.setViewportSize({ width: 1440, height: 900 }); + await page.goto("/"); + const jupiter = glyph(page, "Jupiter"); + await jupiter.hover(); + await expect(jupiter.locator("circle").first()).toHaveCSS( + "stroke-width", + "2.5px", + ); + // A visible point on an aspect line, away from any glyph. + const point = await sampleChart(page).evaluate((svg: SVGSVGElement) => { + const matrix = svg.getScreenCTM()!; + for (const line of svg.querySelectorAll( + 'line[stroke="var(--w-hard)"], line[stroke="var(--w-soft)"]', + )) + for (const t of [0.3, 0.5, 0.7]) { + const [x1, y1, x2, y2] = ["x1", "y1", "x2", "y2"].map( + (name) => +line.getAttribute(name)!, + ); + const p = new DOMPoint( + x1! + (x2! - x1!) * t, + y1! + (y2! - y1!) * t, + ).matrixTransform(matrix); + if (p.x > 0 && p.x < innerWidth && p.y > 0 && p.y < innerHeight) { + const hit = document.elementFromPoint(p.x, p.y); + if (hit && !hit.closest("[data-glyph]")) return { x: p.x, y: p.y }; + } + } + return null; + }); + expect(point).not.toBeNull(); + await page.mouse.click(point!.x, point!.y); + await expect( + page.getByText(/^(Sextile|Square|Trine|Opposition)$/), + ).toBeVisible(); +}); + +test("clicking the sample chart draws no focus outline; keys still show focus", async ({ + page, +}) => { + await page.setViewportSize({ width: 1440, height: 900 }); + await page.goto("/"); + for (const name of ["House 4", "Leo sign region", "Sun"]) { + const target = glyph(page, name); + // Sectors are rings: click a point that hits them, not their box centre. + const point = await target.evaluate((el) => { + const box = el.getBoundingClientRect(); + for (let fy = 0.1; fy < 1; fy += 0.1) + for (let fx = 0.1; fx < 1; fx += 0.1) { + const x = box.left + box.width * fx, + y = box.top + box.height * fy; + const hit = document.elementFromPoint(x, y); + if (hit && el.contains(hit)) return { x, y }; + } + return null; + }); + expect(point).not.toBeNull(); + await page.mouse.click(point!.x, point!.y); + await expect(target).toBeFocused(); + await expect(target).toHaveCSS("outline-style", "none"); + await page.keyboard.press("Escape"); + } + const sector = glyph(page, "House 4"); + await page.keyboard.press("Tab"); + await sector.focus(); + await expect(sector).toHaveCSS("stroke-width", "2.5px"); +}); + +test("only glyphs in the visible quarter are buttons", async ({ page }) => { + await page.setViewportSize({ width: 1440, height: 900 }); + await page.goto("/"); + // Glyphs become buttons once the page is interactive. + await expect(glyph(page, "Sun")).toBeVisible(); + for (const name of ["Moon", "Venus", "Mars", "Saturn", "Earth", "Midheaven"]) + await expect(glyph(page, name)).toHaveCount(0); + const buttons = await sampleChart(page).getByRole("button").all(); + expect(buttons.length).toBeGreaterThan(3); + for (const button of buttons) await expect(button).toBeInViewport(); + // On phones none of them sit behind the text above the chart. + await page.setViewportSize({ width: 390, height: 844 }); + const note = (await page.getByText(/Your chart begins with/).boundingBox())!; + for (const button of buttons) + expect((await button.boundingBox())!.y).toBeGreaterThan( + note.y + note.height, + ); + await glyph(page, "Jupiter").click(); + const card = (await page.getByText(JUPITER).boundingBox())!; + expect(card.x).toBeGreaterThanOrEqual(0); + expect(card.x + card.width).toBeLessThanOrEqual(390); +}); + test("visitor creates a personal chart from birth details", async ({ page, }) => { diff --git a/verification/home-chart.test.ts b/verification/home-chart.test.ts new file mode 100644 index 0000000..1c9bb5b --- /dev/null +++ b/verification/home-chart.test.ts @@ -0,0 +1,60 @@ +import { describe, expect, test } from "bun:test"; +import sample from "../src/lib/home/chart.json"; +import { chartSchema } from "../src/lib/calculation/chart"; +import { astrologySchema } from "../src/lib/calculation/snapshot"; +import { inVisibleQuarter } from "../src/lib/home/visible"; +import { layoutBodyPositions } from "../src/lib/wheel/geometry"; +import { angleIds, bodyIds } from "../src/lib/identities"; + +const chart = chartSchema.parse(sample.chart); +const visible = inVisibleQuarter(chart); +const asc = chart.bodies.find((b) => b.name === "ASCENDANT_SYMBOL")!.longitude; +/** Degrees past the Ascendant, from -180 to 180. */ +const offset = (longitude: number) => ((longitude - asc + 540) % 360) - 180; + +describe("homepage sample chart", () => { + test("is a chart the wheel can draw", () => { + expect(() => chartSchema.parse(sample.chart)).not.toThrow(); + expect(() => + astrologySchema.shape.aspects.parse(sample.aspects), + ).not.toThrow(); + }); + + test("shows only the Sun, Mercury and Jupiter, with the ASC and IC", () => { + expect(bodyIds.filter((name) => visible({ kind: "body", name }))).toEqual([ + "SUN", + "MERCURY", + "JUPITER", + ]); + expect(angleIds.filter((name) => visible({ kind: "angle", name }))).toEqual( + ["ASCENDANT_SYMBOL", "IMUM_COELI"], + ); + }); + + test("draws no other body at the edges of the visible quarter", () => { + const drawn = layoutBodyPositions( + chart.bodies.filter((b) => bodyIds.includes(b.name as never)), + ); + const near = drawn.filter((b) => { + const label = offset(b.labelLongitude), + tip = offset(b.longitude); + return (label > -12 && label < 102) || (tip > -12 && tip < 102); + }); + expect(near.map((b) => b.name).sort()).toEqual([ + "JUPITER", + "MERCURY", + "SUN", + ]); + }); + + test("counts signs and houses by their midpoint", () => { + const signs = chart.zodiac_sectors + .filter((s) => visible({ kind: "sign", name: s.sign })) + .map((s) => s.sign); + expect(signs).toEqual(["gemini", "cancer", "leo"]); + const houses = chart.cusps + .map((_, i) => i + 1) + .filter((number) => visible({ kind: "house", number })); + expect(houses).toEqual([2, 3, 4]); + }); +}); From 4dfa982628de844b19ae20b1a164b7a74ea29bf3 Mon Sep 17 00:00:00 2001 From: Jack Steam Date: Tue, 17 Nov 2026 15:59:14 -0600 Subject: [PATCH 2/3] chore: remove obsolete review runner --- README.md | 3 +-- scripts/review.sh | 55 ----------------------------------------------- 2 files changed, 1 insertion(+), 57 deletions(-) delete mode 100755 scripts/review.sh diff --git a/README.md b/README.md index 8fb9a82..3621697 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,7 @@ The launcher installs frozen dependencies, migrates/seeds persistent local D1, watches and temporarily links the local contract, and starts CMS then web. Ctrl+C stops its processes and restores the pinned package. Each service can also run separately: start CMS there, then set `CMS_ORIGIN` when starting web -(default `http://127.0.0.1:8787`). `scripts/review.sh` runs checks and browser -tests before starting the same stack; `--serve` starts it without checks. +(default `http://127.0.0.1:8787`). Before committing: `bun run sync`, `bun run check`, `bun run check:ts`, `bun run lint`, `bun run format:check`, `node --test scripts/*.test.mjs`, diff --git a/scripts/review.sh b/scripts/review.sh deleted file mode 100755 index 02aa9f2..0000000 --- a/scripts/review.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." -usage() { - cat <<'USAGE' -Usage: scripts/review.sh [--serve] - - (default) Install dependencies, run every automated check and browser test, - then start the review stack (web + CMS) for manual review. - --serve Skip checks and tests: install dependencies, prepare the local CMS, - and start the review stack only. - -Ctrl+C stops the stack. If either service stops, the other is stopped too. -USAGE -} -REVIEW_SERVE_ONLY=0 -for arg in "$@"; do - case "$arg" in - --serve) REVIEW_SERVE_ONLY=1 ;; - -h|--help) usage; exit 0 ;; - *) echo "Unknown option: $arg" >&2; usage >&2; exit 2 ;; - esac -done -export REVIEW_SERVE_ONLY -# Use the pinned Node/Bun versions on PATH. Set PLAYWRIGHT_CHROMIUM_EXECUTABLE -# only when using an existing local browser instead of a Playwright download. -# Manual QA for the birth details modal and variant A layout ({WEB} is the web URL). -MANUAL_REVIEW_TASKS=( - "Birth entry: open {WEB}/app in a desktop-width window. The birth details modal opens with the field focused and an empty wheel behind it. Escape, clicking outside the modal and Done do nothing yet." - "Live preview: type \"June 21, 2000 at 1pm in London\" slowly. The date, time and place tags update as results arrive (they are not reset while typing), Done shows a spinner while parsing, and the chart appears behind the open modal. Done then closes the modal and focus lands on the birth line in the header." - "Later editing: hover the birth line (tooltip \"Edit birth details\") and click it. The modal reopens as \"Edit birth details\", prefilled, with the cursor at the end. Change 1pm to 3pm: the chart updates behind the modal." - "Discarding: in the reopened modal, delete the place so the details are incomplete, then press Escape (and, separately, click outside the modal). The modal closes and the chart and header keep the last complete birth." - "Choices: enter \"03/04/2000 at 1pm in London\", choose \"Mar 4, 2000\" and check that the chart updates." - "Layout: a sticky header, the Tropical / Vedic / True Sky pill above the wheel, system help in the right-hand panel, and the \"Choose a ... by name\" lists below the fold. Scroll down: the header and right-hand panel stay in place." - "Selection: click the Sun on the wheel. Its details appear in the right-hand panel. Close, Escape or \"?\" return the panel to system help." - "House system: click \"...\" next to the pill. Choose Placidus (it applies immediately), then switch presets: Placidus is kept. With the keyboard, the arrow keys move without applying, Enter applies and Escape closes without changes." - "Errors: in DevTools > Network, block requests matching \"ephemeris\", then edit the birth to \"January 2, 1980 at 3pm in Paris\". The modal shows \"Whoops, chart data couldn't be downloaded. Retry\". Unblock, then click Retry: the chart updates." - "Mobile: switch to a 390px-wide device in DevTools and reload. One column, a two-line truncated birth line, a full-width modal, and a details bottom sheet after choosing a body from the lists." - "Reload: the page starts fresh, with the modal open and an empty field." -) -command -v node >/dev/null || { echo 'Install Node 24.10.0 first.' >&2; exit 1; } -command -v bun >/dev/null || { echo 'Install Bun 1.3.14 first.' >&2; exit 1; } -[[ "$(node --version)" == v24.10.0 && "$(bun --version)" == 1.3.14 ]] || { - echo 'Use Node 24.10.0 and Bun 1.3.14.' >&2; exit 1; -} -export REVIEW_MANUAL_TASKS_JSON="$(node -e 'console.log(JSON.stringify(process.argv.slice(1)))' "${MANUAL_REVIEW_TASKS[@]+"${MANUAL_REVIEW_TASKS[@]}"}")" -exec node --input-type=module <<'JS' -import { runStack } from './scripts/dev-stack.mjs'; -try { - await runStack({ review: true, serveOnly: process.env.REVIEW_SERVE_ONLY === '1' }); -} catch (error) { - console.error(`Review stopped: ${error.message}`); - process.exitCode = 1; -} -JS From 5a96db31abb74a82b4feb47a2b7ea32d2b5edbeb Mon Sep 17 00:00:00 2001 From: Jack Steam Date: Wed, 18 Nov 2026 14:46:30 -0600 Subject: [PATCH 3/3] Remove unused development stack review mode --- scripts/dev-stack.mjs | 60 ++++++++++--------------------------------- scripts/processes.mjs | 4 +-- 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/scripts/dev-stack.mjs b/scripts/dev-stack.mjs index 79b9f99..c247b38 100644 --- a/scripts/dev-stack.mjs +++ b/scripts/dev-stack.mjs @@ -13,25 +13,15 @@ const port = (value, fallback) => { return number; }; -export const runStack = async ({ review = false, serveOnly = false } = {}) => { +const runStack = async () => { const root = fileURLToPath(new URL("..", import.meta.url)); const cms = cmsRepoPath(); - const wp = port(process.env.WEB_PORT ?? process.env.REVIEW_WEB_PORT, 5173); - const cp = port(process.env.CMS_PORT ?? process.env.REVIEW_CMS_PORT, 8787); - const tp = port(process.env.PLAYWRIGHT_PORT, 4173); - const ports = [ - wp, - cp, - cp + 10000, - ...(review && !serveOnly - ? [tp, tp + 1, tp + 2, tp + 4614, tp + 4615, tp + 14614, tp + 14615] - : []), - ]; - if (new Set([wp, cp, cp + 10000]).size !== 3 || ports.some((p) => p > 65535)) - throw new Error( - "Stack and browser-test ports must be distinct and at most 65535", - ); - for (const p of new Set(ports)) await availablePort(p); + const wp = port(process.env.WEB_PORT, 5173); + const cp = port(process.env.CMS_PORT, 8787); + const ports = [wp, cp, cp + 10000]; + if (new Set(ports).size !== ports.length || ports.some((p) => p > 65535)) + throw new Error("Stack ports must be distinct and at most 65535"); + for (const p of ports) await availablePort(p); const releaseLock = await acquireStackLock(root); const supervisor = createSupervisor(); let linkSetup, seedWatcher, stopping; @@ -61,9 +51,9 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => { assertRunning(); return supervisor.start(...args); }; - const run = async (args, cwd = root, vars = env) => { + const run = async (args, cwd = root) => { assertRunning(); - await supervisor.run("bun", args, cwd, vars); + await supervisor.run("bun", args, cwd, env); assertRunning(); }; try { @@ -74,24 +64,6 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => { linkSetup = linkLocalContract({ root, cms }); await linkSetup; assertRunning(); - if (review && !serveOnly) { - if (!process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE) - await run(["x", "playwright", "install", "chromium"]); - for (const check of ["sync", "check", "check:ts", "lint", "format:check"]) - await run(["run", check]); - await supervisor.run( - "bash", - ["-c", "node --test scripts/*.test.mjs"], - root, - env, - ); - await run(["test", "verification"]); - await run(["run", "validate"], cms); - await run(["run", "build"]); - const localEnv = { ...env }; - delete localEnv.E2E_BASE_URL; - await run(["run", "test:browser"], root, localEnv); - } await run(["run", "migrate:local"], cms); await run(["run", "seed:local"], cms); const contract = start("bun", ["run", "contract:watch"], cms, env); @@ -144,10 +116,6 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => { console.log( `\nWeb: ${wu}\nCMS: ${cu}\nLocal data persists in the CMS checkout. Ctrl+C stops this stack.`, ); - const tasks = JSON.parse(process.env.REVIEW_MANUAL_TASKS_JSON || "[]"); - tasks.forEach((task, i) => - console.log(`${i + 1}. ${task.replaceAll("{WEB}", wu)}`), - ); const name = await Promise.race( [ ["CMS", cs], @@ -163,9 +131,7 @@ export const runStack = async ({ review = false, serveOnly = false } = {}) => { } }; -if (process.argv[1] === fileURLToPath(import.meta.url)) { - runStack().catch((error) => { - console.error(error.message); - process.exitCode = 1; - }); -} +runStack().catch((error) => { + console.error(error.message); + process.exitCode = 1; +}); diff --git a/scripts/processes.mjs b/scripts/processes.mjs index 2d223ce..6dfe678 100644 --- a/scripts/processes.mjs +++ b/scripts/processes.mjs @@ -60,9 +60,7 @@ export const availablePort = (port) => const server = createServer(); server.once("error", () => reject( - new Error( - `Port ${port} is unavailable; set WEB_PORT, CMS_PORT or PLAYWRIGHT_PORT.`, - ), + new Error(`Port ${port} is unavailable; set WEB_PORT or CMS_PORT.`), ), ); server.listen(port, "127.0.0.1", () => server.close(resolve));