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

@sentinel-lab/video-embed-helper

v4.0.0

Published

Sentinel Video Player 静态 iframe 辅助库:CMS / Markdown 等只能嵌 URL 场景的宿主侧事件监听

Readme

@sentinel-lab/video-embed-helper

Sentinel Video Player 的静态 iframe 场景 host 侧辅助(L7)

给 CMS / Markdown / 论坛 / 邮件模板这类「只能嵌一个 URL、跑不了 npm 包」的场景用:让宿主页面能订阅 iframe 里播放器广播出来的契约事件。

只依赖 @sentinel-lab/video-protocol,无框架依赖。

两种用法

1. <script> 标签(无构建工具)

helper.js 和 iframe src 同目录——把 URL 末尾换成 helper.js 即可,版本锁定自动跟随,不用另记地址:

<iframe src="https://sentinel-video.pages.dev/embed/v4/?src=...&autoplay=1"></iframe>
<script src="https://sentinel-video.pages.dev/embed/v4/helper.js"></script>
<script>
  SentinelEmbed.on('ended', () => { location.href = nextUrl })
</script>

2. npm(有构建工具)

pnpm add @sentinel-lab/video-embed-helper
import { createEmbedListener } from '@sentinel-lab/video-embed-helper'

const player = createEmbedListener({
  // 生产环境建议配上播放器 CDN origin,避免收到同页无关 iframe 的消息
  origin: 'https://sentinel-video.pages.dev',
})

const unsubscribe = player.on('timeupdate', ({ time, duration }) => {
  progressBar.style.width = `${(time / duration) * 100}%`
})

player.on('error', (err) => {
  // err.code 是 protocol 注册的 E_* 错误码
})

// 清理
unsubscribe()
player.destroy()

API

| 成员 | 说明 | |:---|:---| | createEmbedListener(options?) | 创建监听器。options.origin 白名单(省略=接受任意 origin,仍过 schema 校验);options.target 挂载目标,默认 window | | listener.on(event, handler) | 订阅事件,返回退订函数 | | listener.off(event, handler) | 退订(需传订阅时的同一 handler 引用) | | listener.destroy() | 卸载 message 监听并清空所有订阅 |

事件名与 payload 形状对齐 protocol 的 PlayerEvent

边界

  • 只收不发——本包只订阅事件,不下发命令。静态 iframe 场景没有命令通道,要控制播放请改用 @sentinel-lab/video-react-frame@sentinel-lab/video-vue-frame
  • 所有消息过 Zod schema 校验,非法消息静默丢弃
  • SSR 安全——取不到 window 时整体 no-op,不抛错

相关

MIT