@rencomputer/rencal-sdk

中文文档
0.3.0发布于 2026/11/02MITTypeScriptES Module

Build view plugins for renCal: the plugin API, design tokens and a zero-config build.

原始使用文档
文档目录7 节
  1. Setup
  2. Declare the view
  3. Write the view
  4. API
  5. Build
  6. Publish
  7. Source

renCal SDK

Build view plugins for renCal. A view is a React component that renCal shows alongside its built-in week, month and year views. This package has the plugin API, renCal's design tokens for Tailwind, and a build command that needs no configuration.

Setup

pnpm add -D @rencomputer/rencal-sdk @types/react @types/react-dom

Add the scripts to package.json:

{
  "scripts": {
    "build": "rencal-sdk build",
    "dev": "rencal-sdk dev"
  }
}

And extend the shared tsconfig.json:

{ "extends": "@rencomputer/rencal-sdk/tsconfig.json" }

Declare the view

Views are declared in the plugin's rencal-plugin.toml:

id = "alice.upcoming"
name = "Upcoming"
description = "The next seven days as a list."
min_rencal_version = "0.9.1"

[[contributes.views]]
id = "upcoming"
name = "Upcoming"
script = "dist/upcoming.js"
css = "dist/upcoming.css"

css is optional; leave it out if the view has no styles. See Create a plugin for the rest of the manifest.

Write the view

Default-export the component from src/index.tsx, or from src/<view-id>.tsx when the plugin has several views:

import {
  type CalendarEvent,
  useEventProps,
  useEventsInRange,
  useToday,
} from "@rencomputer/rencal-sdk"

export default function UpcomingView() {
  const today = useToday()
  const events = useEventsInRange(today, today.add({ days: 7 }))

  return (
    <ul className="flex flex-col gap-1 p-4">
      {events.map((event) => (
        <EventItem key={event.key} event={event} />
      ))}
    </ul>
  )
}

function EventItem({ event }: { event: CalendarEvent }) {
  return (
    <li {...useEventProps(event)} className="rounded-md px-2 py-1">
      {event.summary}
    </li>
  )
}

Tailwind classes work out of the box and use renCal's theme, so views match whatever theme the user has installed. While the user types a new event in the header, renCal fades events and sets data-dimmed around the view; fade other parts with it too, like in-data-dimmed:opacity-50.

API

Export
useEventsInRange(start, end)Events in visible calendars from start up to, not including, end, plus the event being created and a dragged event's preview, marked by event.transient
useEventProps(event, { drag })Props that make an element behave like a renCal event: calendar color, selection, RSVP and drag state, click to open, the right-click menu, and with drag, drag to reschedule
useEventState(event)Whether an event is selected, showing its menu or being dragged
dayProps(date, zone)Marks an element as a day: dragged events drop there, and dragging, double-clicking or right-clicking it creates an event
useDayGrid()The range being drawn to create an event, and whether anything is being dragged
selectionProps()Marks an element that draws part of that range, so the new-event popover opens beside it
useToday()Today's date, kept current across midnight and timezone changes
useViewerTzid()The user's timezone, kept current when it changes
useNavigation()The active date, and a function to go to another date
useOnNavigate(onNavigate)Calls onNavigate after each deliberate navigation, even to the active date, to bring it into view
useCalendars()The user's calendars
useDisplaySettings()The user's time format, first day of the week and whether to show week numbers
useEventAppearance(event)An event's colour and RSVP, for marks that aren't event elements
TemporalThe Temporal API renCal uses for dates and times
eventsByDay(events, start, end)Events grouped into one entry per day from start up to, not including, end, empty days included
layoutAllDay(items, start, dayCount), layoutTimed(items), isSpanning(event)renCal's layouts: events across days packed into lanes, and a day's overlapping timed events side by side
dateInViewerZone, toViewerZonedDateTime, isAllDay, isSameDay, startOfWeek, isoWeekNumber, epochDayDate helpers
formatTime, formatWallclockTime, formatShortDate, formatLongDate, formatWeekday, formatMonth, getRelativeDayLabelFormatting that follows renCal's
Button, Tooltip, cn, ChevronLeftIcon, ChevronRightIcon, UntitledEventTextComponents and utilities from renCal's UI

React, Temporal and this package are provided by renCal at runtime. Other dependencies are bundled into the view.

Build

pnpm build type-checks the plugin and writes each view to the script and css paths in its manifest. pnpm dev rebuilds on every change.

To try the plugin, add its directory to ~/.config/rencal/plugins.toml. renCal reloads it on every rebuild:

plugins = ["~/dev/rencal-upcoming"]

A local plugin needs nothing else. Keep dist/ out of git: it is build output.

Publish

renCal installs a view plugin from its latest GitHub release, downloading each script and css file from the release asset with the same file name. Add a workflow that builds the plugin and attaches dist/* to a release whenever you push a version tag, as .github/workflows/release.yml:

name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
      attestations: write
    steps:
      - uses: actions/checkout@v7

      - uses: actions/setup-node@v7
        with:
          node-version: 24

      - name: Build
        run: |
          npm ci
          npm run build

      - name: Attest build provenance
        uses: actions/attest@v4
        with:
          subject-path: dist/*

      - name: Create release
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes dist/*

Then push a tag such as v0.1.0 to publish a release. The tag is the version renCal shows. See rencal-view-board for a plugin set up with pnpm, and Publish a plugin to list yours in the plugin directory.

Source

The SDK is developed in the renCal repository.

版本与发布记录

@rencomputer/rencal-sdk 共发布 4 个版本,首次发布于 2026/10/16;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.3.0latest2026/11/021 天前
0.2.02026/10/1618 天前
0.1.02026/10/1618 天前
0.0.0-stage2026/10/1618 天前

关于 @rencomputer/rencal-sdk 的常见问题

@rencomputer/rencal-sdk 是什么?

为renCal构建视图插件:插件API,设计令牌和零配置构建。

如何安装 @rencomputer/rencal-sdk?

在项目目录运行 npm install @rencomputer/rencal-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@types/react(^19.2.0)、@types/react-dom(^19.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 rencal-sdk,可以用 npx rencal-sdk 直接运行。

@rencomputer/rencal-sdk 支持 TypeScript 吗?

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

@rencomputer/rencal-sdk 支持 ESM 还是 CommonJS?

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

@rencomputer/rencal-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@rencomputer/rencal-sdk 可以商用吗?

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

@rencomputer/rencal-sdk 还在维护吗?

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