@bysages/core

中文文档
0.6.0发布于 2026/11/07MITTypeScriptES Module近 30 天下载 1864

Shared core of By Sages Elements — theme engine, per-component styles, and the lighting engine, all token-driven

原始使用文档
文档目录5 节
  1. Features
  2. Installation
  3. Quick Start
  4. Architecture
  5. License

@bysages/core

npm version npm downloads npm license

The visual core of By Sages Elements: the only style layer of the design system, the theme engine, and the lighting engine — framework-agnostic, consumed by every wrapper package.

Features

  • 🎨 The only visual layer — every component's stylesheet lives here, native CSS scoped by [data-scope][data-part], so one stylesheet serves React, Vue, Solid, and Svelte alike
  • 🌗 Theme engine — applyTheme() drives light/dark, accent pigments (qinghua / celadon / zhusha), contrast tiers, density tiers, and scene presets, all expressed as data on the document root
  • 💡 Lighting engine — elevation, pigment bleed, and pointer-carried light computed into CSS variables (setLight, attachDynamicLight); component styles only ever consume light (以光为影 — light as shadow)
  • 🖋️ Ink ripple — a press feedback pass that bleeds pigment from the pointer, delegated at the root and tuneable per element
  • 🧩 Style injection — injectComponentStyle() ships each family's stylesheet at import time, guarded by a head marker so SSR builds that inline styles never double-inject
  • 🗂 Icon registry — @bysages/core/icons curates the few glyphs the wrappers draw from @bysages/icons and exposes them through getIcon(); anything beyond the whitelist is a direct named import

Installation

# pnpm
pnpm add @bysages/core @bysages/tokens

# npm
npm install @bysages/core @bysages/tokens

# yarn
yarn add @bysages/core @bysages/tokens

# bun
bun add @bysages/core @bysages/tokens

Quick Start

Load the compiled tokens, theme the document, and the component styles arrive with the wrappers:

import "@bysages/tokens/css";
import { applyTheme, attachDynamicLight } from "@bysages/core";

applyTheme({ mode: "system", accent: "ink", density: "default" });
attachDynamicLight();

Architecture

@bysages/tokens    DTCG source → CSS custom properties
      ↓
@bysages/core      theme engine · lighting engine · per-component styles
      ↓
wrappers           Vue · React · Solid · Svelte — thin adapters over headless machines

The core owns no interaction; it renders nothing but light. Wrappers bring the headless state machines, the core dresses them.

License

版本与发布记录

@bysages/core 共发布 18 个版本,首次发布于 2026/09/16;过去 12 个月发布了 18 个版本。

版本发布日期距今
0.6.0latest2026/11/072 天前
0.5.02026/11/036 天前
0.4.42026/10/1922 天前
0.4.32026/10/1525 天前
0.4.22026/10/1328 天前
0.4.12026/10/1130 天前

关于 @bysages/core 的常见问题

@bysages/core 是什么?

Shared core of By Sages Elements — theme engine, per-component styles, and the lighting engine, all token-driven

如何安装 @bysages/core?

在项目目录运行 npm install @bysages/core,或使用 pnpm add / yarn add / bun add。

@bysages/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bysages/core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bysages/core 可以商用吗?

@bysages/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bysages/core 的下载量有多少?

根据 npm 官方下载统计,@bysages/core 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,864 次,日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bysages/core 还在维护吗?

最新版本 0.6.0 发布于 2026/11/07(2 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/09/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。