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

@uppercut-labs/electron-bridge-test-double

v1.0.0

Published

A fake preload bridge for Electron renderers: call log, event emitters, menu hook, fixture selection and safe storage, so the renderer runs in a plain browser.

Readme

@uppercut-labs/electron-bridge-test-double

Building blocks for a fake preload bridge, so an Electron renderer can run in a plain browser. It provides a call log, event emitters, a menu hook, fixture selection from the page address, storage that never throws, and cancellable timers. The methods of the bridge itself are yours to write; this package supplies the parts every fake needs.

npm install --save-dev @uppercut-labs/electron-bridge-test-double
import { createBridgeHarness, installBridgeIfMissing, instrument } from '@uppercut-labs/electron-bridge-test-double';

function createFakeBridge() {
  const h = createBridgeHarness<{ files: string[] }>({
    storagePrefix: 'my-app',
    fixtures: { table: { default: { files: ['a.txt'] }, empty: { files: [] } }, fallback: 'default' },
  });
  const progress = h.channel<number>('progress');
  const saved = h.storage.load();

  return instrument(
    {
      async bootstrap() {
        return { stored: saved, files: h.fixture.data!.files };
      },
      saveState(key: string, json: string) {
        h.storage.save(key, json);
      },
      onProgress: (listener: (n: number) => void) => progress.add(listener),
      onMenuCommand: (listener: (id: string) => void) => h.menuCommands.add(listener),
      setMenuState: (enabled: Record<string, boolean>) => h.menu.setMenuState(enabled),
    },
    h.log,
    { saveState: (args) => [args[0]] },
  );
}

// Uses the fake only when the real preload bridge is missing.
export const desktop = installBridgeIfMissing(createFakeBridge);

Open the page as index.html#fixture=empty&platform=macos to pick a scenario. Scripts and tests can read window.__desktopCalls and window.__menuState, and call window.__menuCommand('file.open') as the application menu would.

Functions

| Function | Meaning | | --- | --- | | createEmitter<T>() | { add(listener) => remove, emit(value), size, clear() }. A listener that throws does not stop the others; the first error is rethrown after all have run | | createCallLog(options?) | { calls, record(name, ...args), callsTo(name), clear() }. Publishes calls as window.__desktopCalls; exposeAs renames it or turns it off with null, target changes the object | | instrument(implementation, log, selectArgs?) | Returns a copy of the implementation in which every function records its call first. selectArgs maps a method name to a function that picks the arguments to log | | installMenuHook(emitter, options?) | Sets window.__menuCommand(id) to emit on emitter and returns { command, setMenuState }, which stores the state on window.__menuState. commandKey, stateKey and target are options | | parseHashParams(source?) | Search params from #a=1&b=2, a URL or a query. Default source is location.hash | | readOption(name, allowed, fallback, source?) | The address option when it is in allowed, otherwise fallback | | defineFixtures(table, fallback) | { names, has(name), get(name), select(source?, param?) }. A table value is data (cloned on every use) or a function that builds it. select reads fixture= and falls back for a missing or unknown name | | createPrefixedStorage(prefix, storage?) | { load(), save(key, json), memory } over localStorage or the storage you pass. load returns entries whose key starts with <prefix>.. Read and write failures are swallowed and values stay in memory | | createScheduler(timers?) | { after(ms, fn) => cancel, wait(ms), cancelAll(), pending }. wait resolves true when the time passes and false when cancelled. Pass your own setTimeout and clearTimeout to control time | | wait(ms) | A promise that resolves after ms | | createBridgeHarness(options) | Creates a call log, menu hook, menuCommands emitter, storage, scheduler, selected fixture, option(name, allowed, fallback) and channel(name) for named emitters. Options: storagePrefix, fixtures, address, target, storage | | installBridgeIfMissing(create, options?) | Sets window.desktop to create() only when it is undefined and returns the bridge in place. name and target are options |

Errors

defineFixtures throws when fallback is not a key of the table, and get throws for an unknown name. Nothing else throws on its own; failures in storage are swallowed on purpose.

License

MIT