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

@growth-labs/video

v0.3.0

Published

Astro 6 integration for HLS video playback from R2, reusable R2 HLS bundle ingestion, captions/chapters sidecars, YouTube embeds, and optional Worker-proxied premium gating.

Downloads

719

Readme

@growth-labs/video

Astro 6 integration for HLS video playback from R2, reusable R2 HLS bundle ingestion, captions/chapters sidecars, YouTube embeds, and optional Worker-proxied premium gating.

Install

pnpm add @growth-labs/video vidstack

Config

import video from '@growth-labs/video'

video({
  publicDomain: 'media.example.com',
  r2Binding: 'MEDIA_BUCKET',
  admin: {
    importRoute: {
      enabled: true,
      path: '/api/admin/video/import',
      requireAuth: true,
    },
  },
})

Premium playback additionally needs premium.enabled, an accessCheck, and a GL_VIDEO_SESSION_SECRET secret of at least 32 bytes:

video({
  publicDomain: 'media.example.com',
  premium: {
    enabled: true,
    sessionScope: 'per-video',  // default; 'wildcard' opts into the 0.2.x behavior
    sessionTtl: '1h',           // duration string: '1h' | '30m' | '2h30m' | '45s'
  },
  accessCheck: async ({ videoId, request, env }, context) => {
    // Returns { allowed, reason?, subjectId? }
  },
})

per-video scope (the 0.3.0 default) issues a cookie restricted to one videoId, so video status changes propagate within sessionTtl. wildcard issues a cookie that plays every premium video for the cookie's lifetime — cheaper per page but status changes do not propagate until the cookie expires.

R2 Layout

video/<videoId>/hls/master.m3u8
video/<videoId>/hls/<rendition>/index.m3u8
video/<videoId>/hls/<rendition>/init.mp4
video/<videoId>/hls/<rendition>/segment-00001.m4s
video/<videoId>/poster.jpg
video/<videoId>/captions_en.vtt
video/<videoId>/chapters.vtt

Ingest Helpers

import { ingestHlsBundle, writeCaptionsVtt, writeChaptersVtt } from '@growth-labs/video/utils'

await ingestHlsBundle({
  bucket: env.MEDIA_BUCKET,
  publicDomain: 'media.example.com',
  videoId: 'intro-video',
  files: [
    { path: 'master.m3u8', body: masterManifest },
    { path: 'h264/720p/index.m3u8', body: renditionManifest },
    { path: 'h264/720p/init.mp4', body: initBytes },
    { path: 'h264/720p/segment-00001.m4s', body: segmentBytes },
  ],
  poster: { path: 'poster.jpg', body: posterBytes, contentType: 'image/jpeg' },
})

await writeCaptionsVtt({ bucket: env.MEDIA_BUCKET, videoId: 'intro-video', vtt: captionsVtt })
await writeChaptersVtt({ bucket: env.MEDIA_BUCKET, videoId: 'intro-video', vtt: chaptersVtt })

The ingestion helper validates master.m3u8, referenced rendition playlists, segment paths, and local HLS URI="..." attributes such as EXT-X-MAP, EXT-X-MEDIA, EXT-X-I-FRAME-STREAM-INF, and EXT-X-KEY before writing to R2. Absolute/external URLs and unsafe relative paths are rejected. Transcoding is out of scope; pass already-generated HLS and VTT files.

All R2 key helpers normalize videoId with the same safe contract: IDs must start with an ASCII letter or number and then contain only ASCII letters, numbers, _, or -. Text-track helpers write only under video/<videoId>/captions_<lang>.vtt and video/<videoId>/chapters.vtt.

Injected routes read bindings from cloudflare:workers env; no locals.runtime shim is required.