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

@worthy-ventures/metaglotta-incontext

v1.0.1

Published

Screen capture for in-context translation editing: one permission per session, region-cropped to the tab.

Readme

@worthy-ventures/metaglotta-incontext

In-context translation editing: the browser-extension contract, session bootstrapping, and screenshot capture. Consumed by @worthy-ventures/metaglotta-ngx, which is what an application normally installs — you need this package directly only to start a session yourself.

import { provideInContext } from '@worthy-ventures/metaglotta-incontext';

The extension contract is frozen

The browser extension talks to the page through two sessionStorage keys and a small postMessage vocabulary. Those literal values are the extension's own — a protocol this project does not own — and are spelled out in exactly one place each, EXTENSION_STORAGE_PREFIX and EXTENSION_MESSAGES in src/, with tests in src/extension.test.ts pinning them.

| What | Where | Constant | | -------------------------------- | ---------------- | --------------------- | | API key | sessionStorage | API_KEY_STORAGE_KEY | | API url | sessionStorage | API_URL_STORAGE_KEY | | Detection, handshake, screenshot | postMessage | EXTENSION_MESSAGES |

They still carry the upstream project's name, and renaming them to match this project's vocabulary would simply mean the extension never answers. They are the two files the repo's assert:debranded check deliberately exempts.

A translator installs the extension once, generates their own key under their own permissions, and activates it on a tab. The handshake reports uiPresent: true, which tells the extension not to inject its own copy of the editor UI.

Starting a session without the extension

startInContextSession() and bootstrapFromUrl() write the same two sessionStorage keys, so a session started from a bookmarklet or a ?__i18n=1 link is indistinguishable from one the extension started.

If no extension answers the detection ping, this package installs its own responder and captures screenshots with getDisplayMedia:

import { enableScreenshots } from '@worthy-ventures/metaglotta-incontext';

// Must be called from a user gesture. One permission prompt per session.
await enableScreenshots();

It never competes with the extension: the probe runs first, and if a real extension replies this stays silent — two responders on one message would race, and the extension's native tab capture is better anyway.

Chromium only. Safari has no tab capture or ImageCapture; Firefox has no preferCurrentTab.

Why capture is tab-only, and armed once per session

The track is armed once per session rather than prompting per screenshot, because a screenshot request is abandoned after 3000 ms and no one answers a picker that fast. Each capture then grabs a frame in tens of milliseconds.

Capture is constrained to the browser tab and validated afterwards (track.getSettings().displaySurface === 'browser'), with whole monitors removed from the picker. This is load-bearing, not caution: key positions come from getBoundingClientRect() — viewport-relative CSS pixels — and are scaled by imageSize / windowSize per axis with no translation term. A window capture adds browser chrome at the top and shifts every position box, and nothing downstream can correct for it, so a non-tab capture is rejected rather than uploaded misaligned. Where available, Region Capture crops to the layout viewport, which makes both scale factors exactly devicePixelRatio.

A known upstream issue

useGallery.ts in the upstream web SDK computes key positions after reverting the previewed text:

try {
    screenshot = await takeScreenshot();
} finally {
    revert();
    setTakingScreenshot(false);
}
const positions = uiProps.findPositions(key, ns); // runs AFTER revert()

finally runs before the statement following the try, so the boxes are measured against the reverted text while the image shows the new text. It only matters when a screenshot is taken in the same action as a length-changing edit. If it becomes a problem, one patch-package patch on the unminified bundle fixes it — still far cheaper than forking.