@clean-jsdoc-theme/utils

中文文档
5.2.1发布于 2026/10/24MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2.2万

Shared types and schemas for clean-jsdoc-theme

原始使用文档
文档目录8 节
  1. What's inside
  2. Public API
  3. Slug helpers
  4. Opts validation + report ( config/ )
  5. The i18n / build contract
  6. Why it exists
  7. Contributors
  8. License

@clean-jsdoc-theme/utils

The shared core every other package imports: the type contracts that define the setu→dwar boundary and the slug rules used on both sides, plus one block of pure runtime logic — opts validation, the build report, and the diagnostics spine. It stays browser-safe (rang imports it into the browser) by injection: the network (fetch) and the node:zlib gzip sizer are passed in by the caller, never imported here.

What's inside

src/
├── doclet-schema.ts   # JSDoc doclet shape (TDoclet, kinds, params, meta, …)
├── salty.ts           # salty (taffy) collection helpers + types
├── site/              # the setu↔dwar contract (types-first)
│   ├── page.ts        # Page (+ PageKind, 'source' body), Frontmatter, Heading
│   ├── manifest.ts    # SiteManifest, NavNode, SearchEntry, ExtractManifest, BuildSpec
│   ├── render.ts      # OutputFile, RenderOptions, RenderResult, RenderError, RenderWarning
│   ├── theme.ts       # ThemeTokens, ThemeColors, ThemeConfig, ComponentOverrides
│   ├── site-name.ts   # SiteName (text | logo set) + siteNameText / resolveSiteLogo
│   ├── islands.ts     # IslandName union + IslandPropsMap
│   └── slug-rules.ts  # slugifyHeading / slugifyPath / slugifySourcePath
└── config/            # PURE opts validation + build report (network/zlib injected)
    ├── diagnostics.ts # Diagnostic model + DiagnosticBag + formatDiagnostics
    ├── opts-schema.ts # zod schemas + THEME_OPT_KEYS
    ├── validate-opts.ts # validateThemeOpts → { value, diagnostics }
    ├── site-name.ts   # validateSiteName (shape only)
    ├── fonts.ts       # validateFonts (heading/body existence-checked; per-locale keys)
    ├── locales.ts     # validateLocales (opts.locales/defaultLocale → ValidatedLocales)
    ├── google-fonts.ts# createGoogleFontResolver (injectable fetch; fail-open)
    ├── suggest.ts     # near-miss "did you mean X?" key suggestions
    ├── report.ts      # formatBuildReport (per-route sizes + optional gzip)
    └── format.ts      # humanFileSize, byteLength, ANSI helpers

Public API

The package is types-first; everything is re-exported from the barrel:

import type {
  SiteManifest,
  Page,
  PageKind,
  NavNode,
  SearchEntry,
  Frontmatter,
  Heading,
  OutputFile,
  RenderOptions,
  RenderResult,
  RenderError,
  ThemeConfig,
  ThemeTokens,
  ThemeColors,
  ComponentOverrides,
  SiteName,
  IslandName,
  IslandPropsMap,
  TDoclet,
} from '@clean-jsdoc-theme/utils';

import {
  // slug rules (shared by setu + dwar)
  slugifyHeading,
  slugifyPath,
  slugifySourcePath,
  // opts validation + build report (the bridges call these)
  validateThemeOpts,
  formatBuildReport,
  DiagnosticBag,
  formatDiagnostics,
  // the i18n contract (setu emits, aadesh reads)
  toExtractManifest,
} from '@clean-jsdoc-theme/utils';

Slug helpers

  • slugifyHeading(text, registry?) — heading text → anchor id. Pass a shared Map to dedupe colliding ids on a page (-1, -2).
  • slugifyPath(parts) — longname parts → a URL path segment.
  • slugifySourcePath(path) — a source file path → its source/<file> slug.

Opts validation + report (config/)

  • validateThemeOpts(input) → { value, diagnostics } — normalizes + validates the theme options (zod schemas, a live Google-Font existence check, unknown-key "did you mean?" suggestions). The bridges call this early; a bad font/typo only warns unless strict escalates it.
  • formatBuildReport(input) — the Next.js-style per-route size table (gzip sizer injected, so this module stays browser-safe).
  • DiagnosticBag / formatDiagnostics — the diagnostics spine reused by setu, the bridges, and bhasha's validation primitives.

The i18n / build contract

ExtractManifest + toExtractManifest(manifest) (what aadesh reads in extract mode) and BuildSpec (the per-locale render spec) live here so setu, the bridges, and aadesh all agree on the shape.

Why it exists

The setu↔dwar contract lives here exactly once, so both sides import the same shapes and can never drift. The slug rules are shared for the same reason: setu generates the nav/TOC anchors and dwar emits the rendered heading ids — using one implementation guarantees the two agree. The config/ logic lives here (rather than in a bridge) so JSDoc and TypeDoc validate options and print reports identically.

Contributors

Thanks to everyone who has helped build clean-jsdoc-theme.

Contributors

License

MIT.

版本与发布记录

@clean-jsdoc-theme/utils 共发布 18 个版本,首次发布于 2026/06/10;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/10/2416 天前
5.2.02026/08/282 个月前
5.1.12026/07/293 个月前
5.1.02026/07/243 个月前
5.0.82026/07/183 个月前
5.0.72026/07/074 个月前

其他发布通道:next → 5.0.0-alpha.0。

关于 @clean-jsdoc-theme/utils 的常见问题

@clean-jsdoc-theme/utils 是什么?

Shared types and schemas for clean-jsdoc-theme

如何安装 @clean-jsdoc-theme/utils?

在项目目录运行 npm install @clean-jsdoc-theme/utils,或使用 pnpm add / yarn add / bun add。

@clean-jsdoc-theme/utils 支持 TypeScript 吗?

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

@clean-jsdoc-theme/utils 支持 ESM 还是 CommonJS?

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

@clean-jsdoc-theme/utils 可以商用吗?

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

@clean-jsdoc-theme/utils 的下载量有多少?

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

@clean-jsdoc-theme/utils 还在维护吗?

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