How 0xgf/boneyard works
1. Repository shape
- This is a monorepo with two main products: a reusable package in packages/boneyard and a documentation/demo site in apps/docs.
- The root bones/ directory holds example/generated skeleton definitions used across the docs and package tests.
2. Core product: packages/boneyard
- The package is the actual boneyard-js library.
- Its job is to capture UI layouts as “bones” and render those bones back into framework-specific skeleton loaders.
- The package exposes multiple entrypoints for different runtimes: React, Preact, Vue, Svelte 5, Angular, React Native, plus a Vite plugin and CLI.
3. Shared capture and layout engine
- The center of the package is framework-agnostic logic in files like shared.ts, layout.ts, extract.ts, responsive.ts, and runtime.ts.
- This layer is responsible for turning measured component geometry into a normalized bones format, then adapting that format to different viewport sizes and themes.
4. Web capture pipeline
- For web frameworks, the CLI or Vite plugin opens a browser session, scans the app for <Skeleton name="..."> usage, and snapshots the rendered layout at configured breakpoints.
- That output is written as .bones.json files, which are the main interchange format used everywhere else in the repo.
5. Native capture pipeline
- React Native uses a different path: the <Skeleton> component can scan the live UI tree in dev mode while the CLI is running.
- The native side measures views through React Native internals, then sends the captured layout back to the CLI so it can be serialized into the same bones format as web.
6. Framework adapters
- The package is split into thin adapters for each runtime: react.tsx, preact.tsx, vue.tsx, svelte.*, angular.ts, and react-native.tsx.
- These adapters share the same underlying bones data model but provide the correct component syntax, loading behavior, and framework integration for each ecosystem.
7. Distribution and entrypoints
- packages/boneyard/bin/cli.js is the command-line entry point for capture/build workflows.
- The package also ships compiled artifacts in dist/, suggesting it is published as a consumable library rather than only used locally.
- The native*.js and native-scan.* files indicate separate runtime support for device scanning and native execution.
8. Bones as the architectural boundary
- A bones file is the key boundary between “measured UI” and “rendered skeleton.”
- Generated bones are stored per component name, and the runtime resolves them through a registry import such as ./bones/registry.
- This keeps capture-time concerns separate from render-time concerns.
9. Docs site as the integration showcase
- apps/docs is a Next.js app that serves both product documentation and live examples.
- Its routes map directly to product capabilities: install, config, CLI, output, performance, SSR, and framework-specific pages for React, Vue, Svelte, Preact, Angular, and React Native.
- This app is the clearest place to see the package integrated end-to-end.
10. Docs app structure
- The docs site contains reusable UI pieces like sidebar, toc, page-skeleton-wrapper, skeleton-demo, and shared UI controls under components/ui.
- It also includes many local bone definitions under apps/docs/src/bones, which power the examples and interactive previews on the site.
11. Generated content and registry loading
- Both the docs app and the package include registry.js files that act as the lookup table for named skeletons.
- The architecture assumes a one-time registry import in the app entry so components can resolve their matching skeleton metadata at runtime.
12. Deployment and tooling
- The docs app has a vercel.json, so the public documentation site is deployed as a Vercel-hosted Next.js app.
- The repo uses a workspace-based setup (pnpm-workspace.yaml) and includes tests and a benchmark script inside the package, indicating the package layer is meant to be performance-sensitive and cross-framework stable.
13. Overall data flow
- Author UI in a supported framework → run CLI or Vite plugin to capture layout → write .bones.json files → import the registry into the app → <Skeleton name="..."> renders either the real content or the generated skeleton.
- The same bones format flows across web and React Native, which is the main architectural idea tying the repo together.
Main entry points: index.ts Public API · shared.ts Shared engine · page.tsx Docs site · extract.ts Extractor
Components 17
Monorepo
Workspace root tying the published package to the docs/demo app and shared bones assets.
- Workspace · Root workspace and dependency boundary for the repo.
boneyard package
Reusable library that captures layouts and renders skeleton loaders across runtimes.
- boneyard · Published cross-framework skeleton library.
packages/boneyard - Public API · Main package exports and framework-specific entrypoints.
packages/boneyard/src/index.ts - Shared engine · Framework-agnostic capture, normalization, and runtime helpers.
packages/boneyard/src/shared.ts - Layout model · Converts measured UI into normalized bones layout data.
packages/boneyard/src/layout.ts - Extractor · Finds skeleton usage and extracts measurements from rendered apps.
packages/boneyard/src/extract.ts - Responsive · Adapts bones data across breakpoints and themes.
packages/boneyard/src/responsive.ts - Runtime · Resolves named bones at render time and coordinates loader behavior.
packages/boneyard/src/runtime.ts - Adapters · Thin framework wrappers for React, Preact, Vue, Svelte, Angular, and React Native.
packages/boneyard/src/react.tsx - Web capture · Browser-based capture flow used by the CLI and Vite plugin for web frameworks.
packages/boneyard/bin/cli.js - Native capture · Dev-mode React Native scanning path that captures live UI through native internals.
packages/boneyard/src/native-scan.tsx - Published builds · Compiled distributable artifacts shipped for consumer runtimes.
packages/boneyard/dist/react.js
Docs app
Next.js documentation and showcase site for the package.
- Docs site · Documentation and interactive showcase for the package.
apps/docs/src/app/page.tsx - Docs pages · Capability-focused routes for install, config, CLI, output, performance, SSR, and framework pages.
apps/docs/src/app/overview/page.tsx - Docs UI · Reusable site chrome, demos, and controls used throughout the docs app.
apps/docs/src/components/sidebar.tsx - Docs bones · Local example bones and registry used to power demos and previews.
apps/docs/src/bones/registry.js
Shared bones
Generated skeleton definitions and registries used by the package and docs.
- Bone registry · Runtime import surface that maps component names to generated bones metadata.
packages/boneyard/src/bones/registry.js
Connections 20
- Workspace → boneyard: contains · Workspace hosts the reusable package.
- Workspace → Docs site: contains · Workspace hosts the documentation app.
- boneyard → Public API: exports · Package entrypoints expose the consumer API.
- Public API → Shared engine: uses · Public adapters build on the shared core.
- Shared engine → Layout model: normalizes · Measured geometry is converted into bones layout.
- Shared engine → Extractor: extracts · Shared logic drives capture and parsing.
- Shared engine → Responsive: adapts · Bones are reshaped for viewport and theme variants.
- Shared engine → Runtime: resolves · Render-time lookup and loader behavior use the runtime layer.
- Public API → Adapters: adapts · Framework-specific wrappers sit on top of the common model.
- Public API → Web capture: captures · CLI and Vite flows collect browser layouts.
- Public API → Native capture: captures · React Native uses a separate scanning path.
- Web capture → Extractor: feeds · Browser snapshots are parsed into bones data.
- Native capture → Extractor: feeds · Native measurements are serialized through the same format.
- Extractor → Bone registry: writes · Captured components are stored as named bones entries.
- Runtime → Bone registry: imports · App runtime resolves named skeletons through the registry.
- Public API → Published builds: ships · Built artifacts are published for consumption.
- Docs site → Docs pages: serves · The app exposes capability-specific documentation pages.
- Docs site → Docs UI: composes · Shared UI pieces build the docs experience and live demos.
- Docs site → Docs bones: demonstrates · Local bones definitions power examples and previews.
- Docs bones → Bone registry: mirrors · Docs use the same registry-based lookup pattern as the package.