← Commit history

Publish 0.1.1

John Lauer ·af02803105 ·3mo ago ·parent 14e7276
5 files changed +32−23
package.json+4−4
@@ -1,8 +1,8 @@ {   "slug": "chaitan-nameplate",-  "title": "Chaitan \u2014 Adom Molecule LED Nameplate",+  "title": "Chaitan — Adom Molecule LED Nameplate",   "type": "component",-  "version": "0.1.0",+  "version": "0.1.1",   "description": "Describe chaitan-nameplate: what it does, who it is for, and how to use it.",   "tags": [     "molecule",@@ -16,5 +16,5 @@   "hero": {     "path": "docs/hero.png"   },-  "brief": "Chaitan's name etched out of the soldermask over the top-layer ground plane, lit by side-view LEDs firing inward across the board. A real Adom molecule: large machine pins on the 32 mm base-scaffold grid, USB-C powered. Every LED returns its current through the letters \u2014 there is no second ground path."-}\ No newline at end of file+  "brief": "Chaitan's name etched out of the soldermask over the top-layer ground plane, lit by side-view LEDs firing inward across the board. A real Adom molecule: large machine pins on the 32 mm base-scaffold grid, USB-C powered. Every LED returns its current through the letters — there is no second ground path."+}
page.json+1−1
@@ -2,7 +2,7 @@   "slug": "chaitan-nameplate",   "title": "Chaitan — Adom Molecule LED Nameplate",   "type": "component",-  "version": "0.1.0",+  "version": "0.1.1",   "description": "Describe chaitan-nameplate: what it does, who it is for, and how to use it.",   "tags": [     "molecule",
src/Nameplate.tsx+10−3
@@ -31,7 +31,7 @@ import { MachinePinLargeStandard } from "@tsci/adom-inc.library" import { SideViewLed } from "./SideViewLed" import { UsbCReceptacle, usbCPadRowForEdge } from "./UsbCReceptacle"-import { modelUrlFor } from "./model-url"+import { modelResolver } from "./model-url"  export type NamePolygon = { x: number; y: number }[] @@ -80,8 +80,15 @@ const rect = (hx: number, hy: number) => [   { x: -hx, y: hy }, ] -export const Nameplate = ({ geometry, slug }: { geometry: NameGeometry; slug: string }) => {-  const modelUrl = modelUrlFor(slug)+export const Nameplate = ({+  geometry,+  modelsBase,+}: {+  geometry: NameGeometry+  /** Absolute URL of this board's models/ dir. See lib/model-url.ts. */+  modelsBase: string+}) => {+  const modelUrl = modelResolver(modelsBase)   const { NAME_TEXT, NAME_INK_WIDTH_MM, NAME_INK_HEIGHT_MM, NAME_POLYGONS } = geometry    // ---- sizing, all derived from the ink box ----
src/model-url.ts+17−15
@@ -1,20 +1,22 @@ /**- * Where a board's generated GLBs live.+ * Resolve a board's generated GLBs to ABSOLUTE URLs.  *- * tscircuit's GLB loader FETCHES `glbUrl` — it does not read it off disk — so a- * relative path like "models/x.glb" 404s at build time and the part silently- * falls back to a plain box. The URL has to be absolute.+ * Two constraints force this shape:  *- * Default: a file:// URL under the board's own directory, so a fresh clone- * builds with no network after `scripts/make-nameplate.sh`.+ * 1. tscircuit's GLB loader FETCHES `glbUrl` — it does not read it off disk —+ *    so a relative path like "models/x.glb" 404s at build time and the part+ *    silently falls back to a plain box.+ * 2. The base cannot be built from `process.cwd()`, because each board is+ *    served from its own directory (`adom-tsci start boards/<slug>`) as well as+ *    built from the repo root. cwd differs between those two, so a cwd-relative+ *    URL works in one and 404s in the other.  *- * Override with ADOM_NAMEPLATE_MODEL_BASE to point at hosted copies (each- * board's wiki page serves both models) when building somewhere the files are- * not on disk.+ * The board passes its own `import.meta.url`-derived base, which is correct+ * from anywhere. ADOM_NAMEPLATE_MODEL_BASE overrides it for hosted copies.  */-const cwd = typeof process !== "undefined" ? process.cwd() : "."--export const modelUrlFor = (slug: string) => (file: string) =>-  process?.env?.ADOM_NAMEPLATE_MODEL_BASE-    ? `${process.env.ADOM_NAMEPLATE_MODEL_BASE}/${slug}/${file}`-    : `file://${cwd}/boards/${slug}/models/${file}`+export const modelResolver = (base: string) => (file: string) => {+  const override =+    typeof process !== "undefined" ? process.env?.ADOM_NAMEPLATE_MODEL_BASE : undefined+  const root = (override ?? base).replace(/\/$/, "")+  return `${root}/${file}`+}
viewer/board.glb
⋯ 1 unchanged line ⋯