Skip to content

@xtandard/kit/build

@xtandard/kit/build — build tooling shared by the xtandard products (also behind the xtandard-kit bin):

  • scopeCss / findUnscopedLeaks / scopeCssFile: scope the React-embed stylesheet under the wrapper class (xtandard-kit scope-embed-css);
  • fixElysia2Types: rewrite the elysia-v2 alias in the Elysia 2 declarations;
  • apiSurface / diffApiSurface: API-surface snapshots and the no-removals gate (ADR 0003);
  • defineXtandardConfig, defineUiConfig, defineEmbedConfig, definePlaywrightConfig;
  • createExampleRunner (the scripts/example.ts runner);
  • runEmbedCssSuite / runEmbedThemeE2e: reusable test suites, test API injected.

The shipped tsconfig bases live at @xtandard/kit/tsconfig/base.json and react.json.

Optional peers: postcss, postcss-prefix-selector, typescript, vite-plus, vite, @vitejs/plugin-react, @tailwindcss/vite, @playwright/test — each loaded only by the helper that needs it.

import { … } from "@xtandard/kit/build";
Name Summary
apiSurface Snapshot the API surface of the built package at dir (the package root, or its dist/). Wildcard, CSS, JSON and ./package.json exports are skipped.
createExampleRunner Build the runner for a product’s EXAMPLES table.
defineEmbedConfig The React embed library build: ESM, React external, everything else (the kit UI, TanStack Query, Base UI, styles) bundled so the components are self-contained. The emitted CSS is a full Tailwind build; run xtandard-kit scope-embed-css on it afterwards.
definePlaywrightConfig The browser e2e config: chromium, PORT passed to the server, retries and the GitHub reporter on CI, an existing local server reused.
defineUiConfig The bundled admin SPA build. base: "./" keeps asset URLs relative so the SPA works under any mount path (the panel injects a <base> tag); the output directory is emptied first, since it only ever holds the SPA.
defineXtandardConfig The vite-plus config every product shares. Pass the result to defineConfig from vite-plus:
diffApiSurface Compare two snapshots. Anything in before but not in after is a removal.
exportTarget Resolve an exports value to its ESM runtime file and declaration file (paths as written in package.json). .d.mts is derived from an .mjs target when no types condition is given.
findFreePort The first free TCP port in [preferred, preferred + range].
findUnscopedLeaks Rules that would restyle the host document if they escaped the scope: preflight resets, the universal custom-property rule, and token blocks left on :root/html/body. Returns the offending rule fragments (empty when fully scoped).
fixElysia2Types Rewrite the alias in every .d.ts/.d.mts/.d.cts under dir (recursively). Resolves to the number of files changed.
luminance Relative luminance (0 = black, 1 = white) of an element’s computed colour property.
normalizeScope ".xtandard-flags" → ".xtandard-flags"; a bare "xtandard-flags" gets its dot.
packageRoot Locate the package root: dir itself, or its parent when dir is the dist/ folder.
rewriteSpecifiers Rewrite "<from>" / "<from>/…" module specifiers to <to> in a string.
runEmbedCssSuite The embed-CSS scoping regression cases, for one product’s scope.
runEmbedThemeE2e The embed theme e2e cases, for one product.
scopeCss Prefix every rule in css with scope (a class, e.g. ".xtandard-flags"), re-homing :root/html/:host/body onto the wrapper and leaving keyframe steps alone. Pure.
scopeCssFile Scope a stylesheet on disk in place (xtandard-kit scope-embed-css --scope … --css …), then check it for leaks.
Name Summary
ApiSurface A package’s API surface, as written by xtandard-kit api-surface.
ApiSurfaceDiff The result of diffApiSurface: one line per change, e.g. "./storage: runtime foo".
CoverageThresholds Coverage thresholds (percent).
EmbedConfigOptions Options for defineEmbedConfig.
EmbedCssSuiteOptions Options for runEmbedCssSuite.
EmbedHostOptions What the host page should look like for one theme case.
EmbedThemeE2eOptions Options for runEmbedThemeE2e.
ExampleConfig How one example is run.
ExampleRunner What createExampleRunner returns.
ExampleRunnerOptions Options for createExampleRunner.
ExportTarget The ESM runtime file and declaration file an exports entry points at.
FixElysia2TypesOptions Options for fixElysia2Types.
PlaywrightApi The injected Playwright API for runEmbedThemeE2e.
PlaywrightConfigOptions Options for definePlaywrightConfig.
ScopeCssFileResult What scopeCssFile did.
SubpathSurface The surface of one subpath.
SuiteApi The describe/it/expect subset the suites use (vitest, bun:test and Playwright fit).
UiConfigOptions Options for defineUiConfig.
XtandardConfigOptions Options for defineXtandardConfig.
Name Summary
Conditions
SpawnLike Run cmd in cwd with extra env, inheriting stdio; resolve with the exit code.
Name Summary
DEFAULT_THRESHOLDS The family’s coverage thresholds (en, and the kit).
EMBED_CSS_SAMPLE A representative slice of the real Tailwind v4 embed output.