npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@composy/gantt-core

v0.0.2

Published

企业级甘特图核心库 - 高性能、功能完整

Readme

@composy/gantt-core

企业级甘特图核心库,提供高性能渲染、关键路径分析、资源管理、虚拟滚动等能力。

安装

pnpm add @composy/gantt-core

使用

import { createGantt } from '@composy/gantt-core'
import { injectGanttStyles } from '@composy/gantt-core/styles'

// 注入样式
injectGanttStyles()

// 创建甘特图
const gantt = createGantt(container, {
  tasks: [
    {
      id: 'task-1',
      name: '项目启动',
      startDate: new Date(2026, 0, 1),
      endDate: new Date(2026, 0, 15),
      progress: 50,
      duration: 15,
    },
  ],
  timeScale: 'day',
  enableCriticalPath: true,
})
gantt.render()

日历、关键路径与自动排程

addWorkingDays、getWorkingDatesBetween 和 AutoScheduler 共享同一套工作日与节假日配置。workingDays 必须至少包含一个 0 到 6 的星期值,任务工期和依赖 lag 使用有限整数;空日历、无效日期、孤立依赖和循环依赖会以明确异常或冲突返回,避免调度器静默产生错误日期。

import { AutoScheduler, CPMCalculator } from '@composy/gantt-core'

const calendar = {
  startDate: new Date('2026-01-05'),
  workingDays: [1, 2, 3, 4, 5],
  holidays: [new Date('2026-01-01')],
}

const schedule = new AutoScheduler(tasks, dependencies, resources, calendar).schedule()
const cpm = new CPMCalculator(
  tasks,
  dependencies,
  calendar.workingDays,
  calendar.holidays
).calculate()

void schedule
void cpm

CPM 会合并同一前置任务到目标任务之间的多条约束,criticalDependencies 只包含实际压缩项目工期的紧约束边;projectDuration 使用工作日单位,criticalPath 按最早开始日期稳定排序。

资源容量单位

历史数据不设置 capacityUnit 时仍按百分比容量兼容,例如 capacity: 100 表示 100%。需要以每日小时描述容量时显式设置 capacityUnit: 'hours';资源负载、冲突检测、自动排程和导出统计会统一换算:

const developer = {
  id: 'developer-a',
  name: '开发者 A',
  type: 'person' as const,
  capacity: 4,
  capacityUnit: 'hours' as const,
}

void developer

分配比例仍使用 0..100,更新同一资源分配时会同步刷新 hours,零工期任务也会返回有限的每日负载值。

主题、缩放与样式生命周期

部分 colors 配置会与默认 token 深合并;theme: 'dark' 或 GanttTheme 对象会在首个渲染前应用。minZoom 与 maxZoom 会限制缩放边界。核心样式注入支持 Document、ShadowRoot 和多个实例引用计数:每次 injectGanttStyles 应对应一次 removeGanttStyles。

const gantt = createGantt(container, {
  tasks,
  minZoom: 'day',
  maxZoom: 'month',
  theme: {
    name: 'project',
    colors: { primary: 'var(--ld-primary-600)' },
  },
})

void gantt

Class 命名规范

所有 DOM class 以 ldesign-gantt 为前缀,使用 BEM 风格:

| Class | 说明 | | ------------------------------- | --------------- | | ldesign-gantt | 根块 | | ldesign-gantt__svg | SVG 渲染容器 | | ldesign-gantt__canvas | Canvas 渲染容器 | | ldesign-gantt__task | 任务元素 | | ldesign-gantt__task--critical | 关键路径任务 | | ldesign-gantt__task-bar | 任务条 | | ldesign-gantt__progress-bar | 进度条 |

CSS 变量

所有组件样式通过 --ldesign-gantt-* CSS 变量控制,颜色默认桥接到 LDesign --ld-* 色彩系统:

| 变量 | 默认值 | 说明 | | ---------------------------- | ------------------------ | -------- | | --ldesign-gantt-primary | var(--ld-primary-600) | 主要颜色 | | --ldesign-gantt-bg | var(--ld-bg-page) | 背景色 | | --ldesign-gantt-text | var(--ld-text-primary) | 文本颜色 | | --ldesign-gantt-row-height | var(--ld-px-40) | 行高 | | --ldesign-gantt-font-size | var(--ld-font-sm) | 字体大小 |

构建与检查

Core 使用 @composy/builder 和 rolldown;权威构建、ESLint 与 TypeScript 配置位于 .ldesign/。

命令:pnpm build、pnpm type-check、pnpm lint:check。

产物目录

dist/index.js       # UMD
dist/index.min.js   # UMD minified
es/index.js         # ESM
esm/index.js        # ESM (preserveModules)
lib/index.cjs       # CJS