@dugyu/luna-core

中文文档
0.5.0发布于 2026/05/17Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5300

Core constants, types, and utilities for the L.U.N.A project

原始使用文档
文档目录7 节
  1. Installation
  2. What’s Inside
  3. Usage
  4. Pair With Tokens (Get Concrete Color Values)
  5. ColorId / ColorKey
  6. Theme Resolver (Pick the Best Match From an Allowlist)
  7. LUNA Packages

luna-core

The foundational types package for the LUNA theming system. It provides theme types, color ID/key constants and conversion utilities, and theme resolution (resolver) APIs.

This package does not ship any concrete color values. Color values live in @dugyu/luna-tokens as the single source of truth.

Installation

pnpm add @dugyu/luna-core

What’s Inside

  • Theme keys: LunaThemeKey / LunaThemeVariant / LunaThemeMode, plus extensible custom space via LunaCustomThemeKey
  • Theme token types: LunaThemeTokens / LunaCustomThemeTokens / LunaCustomThemeMeta
  • Color system: LunaColorId (kebab-case), LunaColorKey (camelCase), LUNA_COLOR_IDS / LUNA_COLOR_KEYS, and colorIdToColorKey / colorKeyToColorId
  • Theme resolver: resolveThemeKeyFromList / resolveThemeObjectFromList / inferThemeMode

Usage

Pair With Tokens (Get Concrete Color Values)

import type { LunaThemeTokens } from '@dugyu/luna-core';
import { lunarisDarkTokens } from '@dugyu/luna-tokens';

const theme: LunaThemeTokens = lunarisDarkTokens;

const primary = theme.colors['primary'];
const contentMuted = theme.colors['content-muted'];

ColorId / ColorKey

LunaColorId is the color id used in tokens (kebab-case), e.g. primary-content. LunaColorKey is the camelCase variant intended for runtime components/hooks, e.g. primaryContent.

import {
  LUNA_COLOR_IDS,
  LUNA_COLOR_KEYS,
  colorIdToColorKey,
  colorKeyToColorId,
  createEmptyLunaColors,
} from '@dugyu/luna-core';

const firstId = LUNA_COLOR_IDS[0];
const key = colorIdToColorKey('primary-content');
const id = colorKeyToColorId('primaryContent');

const emptyColors = createEmptyLunaColors();
emptyColors.primary = '#ff8ab5';

Theme Resolver (Pick the Best Match From an Allowlist)

import { resolveThemeKeyFromList } from '@dugyu/luna-core';

const allowed = ['luna-light', 'lunaris-dark'] as const;

const resolved1 = resolveThemeKeyFromList(allowed, 'lunaris-light');
const resolved2 = resolveThemeKeyFromList(allowed, 'luna-dark');

LUNA Packages

  • @dugyu/luna-tokens — source of truth for token values
  • @dugyu/luna-core — token and theme type definitions (this package)
  • @dugyu/luna-styles — CSS variables output
  • @dugyu/luna-tailwind — Tailwind utilities output
  • @dugyu/luna-reactlynx — ReactLynx runtime integration

版本与发布记录

@dugyu/luna-core 共发布 8 个版本,首次发布于 2026/03/03;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.0latest2026/05/175 个月前
0.4.02026/05/066 个月前
0.3.12026/04/027 个月前
0.3.02026/04/027 个月前
0.2.02026/04/017 个月前
0.1.12026/04/017 个月前

其他发布通道:oidc-bootstrap → 0.0.0-oidc-bootstrap.0。

关于 @dugyu/luna-core 的常见问题

@dugyu/luna-core 是什么?

Core constants, types, and utilities for the L.U.N.A project

如何安装 @dugyu/luna-core?

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

@dugyu/luna-core 支持 TypeScript 吗?

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

@dugyu/luna-core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dugyu/luna-core 可以商用吗?

@dugyu/luna-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dugyu/luna-core 的下载量有多少?

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

@dugyu/luna-core 还在维护吗?

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