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

@cordis-tavern/ct-index-renderer

v0.1.0-rc.1

Published

cordis-tavern 的 index 注入插件:经 index-inject 事件收集 head/body 片段并向 index 插入

Readme

@cordis-tavern/ct-index-renderer

cordis-tavern 的 index 注入插件:在启动时段经事件 index-inject 收集各插件要插入 index 的片段,由本插件统一控制插入 —— 与 ct-client-found 的 index 职责解耦。

行为

| 步骤 | 说明 | | --- | --- | | 事件 | 固定名 index-inject(INDEX_INJECT_EVENT / event 导出同值) | | 发布 | ctx.emit('index-inject', payload) | | 收集 | indexInject(事件订阅 + 服务方法同一入口);校验失败 TypeError 不入表 | | 插入 | apply(html):global → 文档最前;head → </head> 前;body → </body> 前(同 placement 保持发布序) | | 服务 | indexRenderer(收集 / apply)+ distIndex(见下) |

distIndex 服务

调用后返回自身 index.html 的绝对磁盘路径字符串(发布物内为 <pkg>/dist/index.html)。

// 本插件 apply 同步段
ctx.provide('distIndex', () => distIndexPath())

// 消费方:export const inject = ['distIndex']
const absPath = ctx.distIndex() // string

也可直接 import { distIndexPath } from '@cordis-tavern/ct-index-renderer'。包根 index.html 由构建拷入 dist/。

载荷

{ kind: 'script', placement: 'head', content: '…' }

| 键 | 类型 | 规则 | | --- | --- | --- | | kind | string | 非空;类型提示(script / inline / global / style …),不强制枚举 | | placement | 'head' \| 'body' \| 'global' | 仅这三值;global 无 head/body 位置,前缀到文档首(如 __CT_BOOT__) | | content | string | 非空;浏览器 DOM 片段原文,原样插入不包标签 |

未知键与非法值 → TypeError 指名键名。缺 </head> / </body> 时不丢注入(前缀 / 追加兜底)。

发布序 ≠ 执行序:同一 placement 按收集(发布)顺序插入;浏览器执行顺序由 apply 后的文档位置决定(global 最先)。

配置

本轮无业务键:允许 undefined / null / {};任意未知键 → TypeError。

发布方示例

ctx.emit('index-inject', {
  kind: 'script',
  placement: 'head',
  content: '<script>console.log("startup tool")</script>',
})

装载

  • 包名写进环境级 ct.profile:ct plugin add -p <环境名> @cordis-tavern/ct-index-renderer
  • 包目录须落在 $CT_HOME/profile/<env>/node_modules/ 或 $CT_HOME/node_modules/
  • ct.bundle.path → cordis.patch.yml,insert[].id: indexRenderer

开发

pnpm build    # 根仓库:esbuild → ct-index-renderer/dist/index.js
pnpm typecheck
pnpm test     # 对 dist/ 产物