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

ownscope

v0.0.4

Published

Framework-agnostic async scope transformer with optional framework runtime adapters

Readme

ownscope

Framework-agnostic async scope transformation for JavaScript and TypeScript. Mark an async function with "use scope" to restore a captured context around synchronous work after await. Choose a runtime adapter for your framework, or provide your own.

Install

npm install ownscope

Install the relevant framework separately (for example solid-js, @angular/core, or vue). Vite users also install vite.

Transform

import { transform } from 'ownscope';

const source = `async function load() {
  "use scope";
  const data = await fetchData();
  update(data);
}`;

const result = await transform(source, {
  filename: 'app.js',
  runtime: { from: 'ownscope/runtime/solid' }
});
console.log(result.code);

Runtime selection is required. Use an adapter from the table below or a custom createScope() module. The captured context is restored only during synchronous callbacks. This does not preserve a framework's component lifecycle or reactive dependency listener across arbitrary awaits.

Public imports

| Import | API | | --- | --- | | ownscope | Async transform, transformTypescript, transformAcorn, Vite ownerScope | | ownscope/typescript | Synchronous transform(code, options?) | | ownscope/typescript/injected | createTransformer(ts) (reuses a provided TypeScript compiler) | | ownscope/acorn | Async transform(code, options?) | | ownscope/vite | ownerScope(options?) | | ownscope/runtime | Generic createScopeFactory | | ownscope/runtime/core | Generic createScopeFactory alias |

Runtime adapters

| Import | API | Purpose | | --- | --- | --- | | ownscope/runtime/solid | createScope() | Solid owner restoration | | ownscope/runtime/angular | createScope() | Angular injection context | | ownscope/runtime/vue | createScope() | Vue active effect scope (not component instance) | | ownscope/runtime/vue/app | createVueAppScope(app) | Vue app-provided injection context | | ownscope/runtime/nuxt | createScope() | Nuxt app context | | ownscope/runtime/effector | createScope() | Effector fork callback binding | | ownscope/runtime/unctx | createUnctxScopeFactory(context) | Existing unctx context | | ownscope/runtime/mobx | createScope() | Experimental: actions, not context restoration | | ownscope/runtime/node | createScope() | Node async-context snapshot |

Adapters only load when their subpath is imported. For Vue app or unctx, expose an application-specific module exporting the configured factory as createScope and use its path in runtime.from.

Vite

import { defineConfig } from 'vite';
import { ownerScope } from 'ownscope/vite';

export default defineConfig({
  plugins: [ownerScope({
    engine: 'typescript',
    runtime: { from: 'ownscope/runtime/angular' }
  })]
});

Custom scope runtime

// ./my-scope.js
import { createScopeFactory } from 'ownscope/runtime';

export const createScope = createScopeFactory({
  capture: () => getActiveContext(),
  run: (context, callback) => runInContext(context, callback)
});

Your createScope() must synchronously capture the context and return a callback runner that re-enters it, preserving callback return values and exceptions.

Inline factory (without importing a scope module)

const result = await transform(source, {
  runtime: {
    mode: 'inline',
    factory: `function createScope() {
      const context = getCurrentContext();
      return callback => executeWithContext(context, callback);
    }`,
    imports: {
      from: 'my-context-library',
      names: ['getCurrentContext', 'executeWithContext']
    }
  }
});

factory is required in inline mode. It must be a JavaScript function expression that returns a synchronous callback runner. imports is optional and may be a single {from, names} object or an array. runtime.provider no longer selects a built-in Solid inline helper.

Options and result

filename?: string, strict?: boolean, sourceMap?: boolean | 'traced' | 'hybrid', and runtime?: { mode?: 'import' | 'inline'; from?: string; name?: string; factory?: string; imports?: ... }.

Import mode uses runtime.from and defaults to the named export createScope (override with runtime.name). Source maps use exact trace provenance by default; sourceMap: false disables them.

Transforms return TransformResult: { code, changed, transformed, diagnostics, map }. The root and Acorn transform APIs are asynchronous; direct TypeScript transforms are synchronous.

Inject TypeScript

import ts from 'typescript';
import { createTransformer } from 'ownscope/typescript/injected';
const { transform } = createTransformer(ts);
const result = transform(source, { runtime: { from: './my-scope.js' } });

The injected entry does not import TypeScript itself.