feat: libs 0003 — remote provider + example backend serving; bump kicad, shared

standalone: LibsSource abstraction (remote over the contract + static fallback),
generic window.kicadLibs provider, sym-lib-table generated from the backend's
lib list at boot (replaces the spike). backend: serve pre-built self-contained
symbol bodies from LIBS_DIR (listLibs/listLibItems + raw item-body route).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Gergő Törcsvári 2026-06-12 19:15:37 +02:00
commit d2d2c19a8c
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322
12 changed files with 447 additions and 145 deletions

View file

@ -9,6 +9,9 @@ export const WASM_ASSET_BASE_URL =
import.meta.env.VITE_WASM_ASSET_BASE_URL ?? "/wasm";
import type { ProviderConfig, ProviderKind } from "@/wasm/collab";
import { remoteLibsSource } from "@/wasm/libs/remote-source";
import type { LibsSource } from "@/wasm/libs/source";
import { staticLibsSource } from "@/wasm/libs/static-source";
/**
* Which Yjs collab provider this deployment uses (one active per env), and its
@ -43,3 +46,18 @@ export type DocSource = "api" | "ydoc";
export function docSourceConfig(): DocSource {
return import.meta.env.VITE_DOC_SOURCE === "ydoc" ? "ydoc" : "api";
}
/**
* Which library source backs the editor's symbol chooser (env `VITE_LIBS_SOURCE`):
* "remote" (default) — fetch from the backend at `API_BASE_URL` over the
* shared contract (origins served by the registry, or the
* GPL example backend).
* "static" — built-in offline example symbols (no backend).
* "off" — disable libs (empty sym-lib-table).
*/
export function libsSourceConfig(): LibsSource | null {
const kind = import.meta.env.VITE_LIBS_SOURCE ?? "remote";
if (kind === "off") return null;
if (kind === "static") return staticLibsSource();
return remoteLibsSource(API_BASE_URL);
}