@citestyle/types

中文文档
1.0.1发布于 2026/04/27MITTypeScriptES Module零依赖近 30 天下载 1864

TypeScript 为 DSL-JSON 定义, 编译样式和注册

中文使用文档
文档目录8 节
  1. 安装
  2. 类型
  3. CSL- JSON 数据
  4. 编译样式模块
  5. 书记官处
  6. 编译器
  7. 格式化帮助
  8. 使用量

@ citetyle/ 类型

Citestyle生态系统的TypeScript类型定义. 覆盖了CSL-JSON数据结构,编译了样式模块,引用注册,以及所有公共API.

当使用任意类型时自动获得这些类型 @citestyle/* 软件包——每个软件包 exports 地图包括 types 条件在这里。 直接安装此软件包, 只当您需要导入类型而无需拖入运行时的软件包 .

安装

npm install -D @citestyle/types

类型

CSL- JSON 数据

类型说明
CslItem包含所有标准 SSL- JSON 字段( 70+) 的引用项, 加 year-suffix 和扩展字段的索引签名
CslName名称对象 : family, (中文(简体) ), given, (中文(简体) ), non-dropping-particle, (中文(简体) ), dropping-particle, (中文(简体) ), suffix, (中文(简体) ), literal
CslDate日期对象 : date-parts, (中文(简体) ), literal, (中文(简体) ), raw, (中文(简体) ), season, (中文(简体) ), circa
CslItemType40+ CPL 项目类型字符串的结合

编译样式模块

类型说明
CompiledStyle编译的样式模块 : meta, (中文(简体) ), bibliography(), (中文(简体) ), citation(), (中文(简体) ), bibliographySort()
StyleMeta样式元数据 : id, (中文(简体) ), title, (中文(简体) ), class,解析设置,崩溃模式,分隔符
FormattedEntry文献目录产出: { text, html, parts, links }
FormattedCitation引用输出 : { text, html }

书记官处

类型说明
Registry登记册接口 : addItems(), (中文(简体) ), getItem(), (中文(简体) ), cite(), (中文(简体) ), getBibliography(), (中文(简体) ), size
RegistryOptions备选方案 createRegistry()数字 : subsequentAuthorSubstitute
CiteRef引文参考: id, (中文(简体) ), item, (中文(简体) ), locator, (中文(简体) ), label, (中文(简体) ), prefix, (中文(简体) ), suffix
FormatContext运行时背景传递到样式函数 : _secOpts, (中文(简体) ), _disambig
DisambiguationContext平地分解状态 : addNames, (中文(简体) ), addGivenname, (中文(简体) ), givenname

编译器

类型说明
CompileOptions备选方案 compile()数字 : locale, (中文(简体) ), format
CompileResult编译器输出 : { code, meta }

格式化帮助

类型说明
NameFormatConfig配置用于 formatNames(): et-al,粒子,排序顺序,初始化
DateFormatConfig配置用于 formatDate(): 日期、月份、范围
ValidationResult产出 validateItem()数字 : { valid, warnings }

使用量

import type { CslItem, CslName, FormattedEntry, CompiledStyle } from '@citestyle/types'

const item: CslItem = {
  id: '1',
  type: 'article-journal',
  title: 'A groundbreaking study',
  author: [{ family: 'Smith', given: 'Jane' }],
  issued: { 'date-parts': [[2024, 6]] },
  'container-title': 'Nature',
  DOI: '10.1038/example',
}

function formatBibliography(style: CompiledStyle, items: CslItem[]): FormattedEntry[] {
  return items.map(item => style.bibliography!(item))
}
import type { Registry, CiteRef, FormattedCitation } from '@citestyle/types'

function citeItems(registry: Registry, ids: string[]): FormattedCitation {
  const cites: CiteRef[] = ids.map(id => ({ id }))
  return registry.cite(cites)
}

版本与发布记录

@citestyle/types 共发布 3 个版本,首次发布于 2026/03/13;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.1latest2026/04/276 个月前
1.0.02026/03/137 个月前
0.0.22026/03/137 个月前

关于 @citestyle/types 的常见问题

@citestyle/types 是什么?

TypeScript 为 DSL-JSON 定义, 编译样式和注册

如何安装 @citestyle/types?

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

@citestyle/types 支持 TypeScript 吗?

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

@citestyle/types 支持 ESM 还是 CommonJS?

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

@citestyle/types 可以商用吗?

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

@citestyle/types 的下载量有多少?

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

@citestyle/types 还在维护吗?

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