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

@yodaos-pkg/ink-env

v0.20.1

Published

TypeScript definitions for Ink framework

Readme

@yodaos-pkg/ink-env

@yodaos-pkg/ink-env provides TypeScript ambient type definitions for the Ink JavaScript runtime environment.

It is intended for JavaScript and TypeScript application code that runs inside Ink. The package focuses on the API surface available to app code and intentionally does not document runtime implementation details.

What This Package Provides

  • global environment types such as console, timers, fetch, WebSocket, EventSource, navigator, and performance
  • DOM-style event and event target types used by the Ink runtime
  • app-facing framework globals such as getApp(), App, Page, and Component
  • the wx namespace for mini-program style APIs
  • media, speech, sensor, networking, and AI-related API typings exposed to business logic
  • asset module declarations for common image and audio file types

Install

npm install -D @yodaos-pkg/ink-env

This package exposes global declarations. In most cases you do not need to import anything from it.

TypeScript Setup

Add the package to your tsconfig.json so TypeScript can load the ambient declarations explicitly:

{
  "compilerOptions": {
    "types": ["@yodaos-pkg/ink-env"]
  }
}

If your project already loads all installed type packages automatically, this step may not be necessary.

API Overview

Core Globals

The environment includes commonly used global APIs such as:

  • console
  • setTimeout, setInterval, clearTimeout, clearInterval
  • requestAnimationFrame, cancelAnimationFrame
  • atob, btoa
  • fetch, Headers, Request, RequestInit, Response, FormData
  • ReadableStream, WritableStream, TransformStream, and queueing strategies
  • Blob, File, ImageBitmap, ImageData, createImageBitmap
  • window, self, global, performance

Example:

setTimeout(() => {
  console.log('hello from Ink');
}, 16);

App And Page APIs

The package includes framework-facing globals and instance types used by application code:

  • getApp()
  • App
  • Page
  • Component

These types are useful for page logic, component logic, and app-level state access.

DOM-Style Events

Ink application code can use DOM-like event primitives and typed event objects, including:

  • EventTarget
  • Event
  • MessageEvent
  • KeyboardEvent
  • PointerEvent
  • WheelEvent
  • FocusEvent
  • InputEvent

These declarations are designed for app code that listens to runtime-dispatched events or interacts with event-driven APIs.

Networking APIs

The environment includes typed networking surfaces for both promise-based and streaming use cases:

  • fetch()
  • WebSocket
  • EventSource
  • AbortController and AbortSignal

Example:

const response = await fetch('https://example.com/data');
const data = await response.json();
console.log(data);

Navigator And Runtime Information

The navigator typing includes runtime and device-facing information such as:

  • navigator.userAgent
  • navigator.language
  • navigator.languages
  • navigator.region
  • navigator.versions
  • navigator.bluetooth
  • navigator.geolocation

Media And Audio APIs

The package includes types for media-related capabilities exposed to app code, such as:

  • AudioPlayer
  • Sound
  • createImageBitmap
  • recorder and camera APIs under wx.media
  • image and audio library access through navigator.mediaLibrary (list, get, and create-only save)

Sensors And Speech APIs

The environment also includes typed interfaces for selected device capabilities:

  • Accelerometer
  • Gyroscope
  • Magnetometer
  • AbsoluteOrientationSensor
  • SpeechRecognition
  • wx.speech

navigator.geolocation is also available with standard callback signatures and position/error shapes. This API is host-capability driven: the Ink runtime only normalizes the JavaScript surface, permission gate, and IPC payloads, while the actual location provider must be supplied by the host environment.

Availability may depend on the current host environment. The type package describes the supported JavaScript API surface, not host-by-host runtime guarantees.

Payment APIs

The package also includes first-release typings for the standard payment entry points exposed to Ink app code:

  • PaymentRequest
  • PaymentResponse
  • PaymentMethodData
  • PaymentDetailsInit
  • PaymentOptions

Example:

const request = new PaymentRequest(
  [{ supportedMethods: 'basic-card' }],
  {
    total: {
      label: 'Total',
      amount: { currency: 'USD', value: '12.34' },
    },
  },
  {
    requestPayerEmail: true,
  },
);

const canPay = await request.canMakePayment();
if (canPay) {
  const response = await request.show();
  console.log(response.payerEmail, response.shippingOption, response.shippingAddress);
  await response.complete('success');
}

Payment typing notes:

  • these types describe the JavaScript-standard surface available inside the Ink app runtime
  • the actual payment backend is host-capability driven; the host must provide a payment capability bridge
  • PaymentResponse includes top-level payerName, payerEmail, payerPhone, shippingOption, and shippingAddress in addition to details
  • first-release typing and runtime support exclude dynamic update events such as shippingaddresschange, shippingoptionchange, paymentmethodchange, merchantvalidation, and PaymentResponse.retry()

AI APIs

The package includes AI-related types exposed to application code:

  • LanguageModel
  • LanguageModelSession
  • LanguageModelMessage
  • LanguageModelTool

These types are intended for application code that interacts with the host-provided language model capability.

wx Namespace

Mini-program style APIs are exposed under the global wx namespace. Current type coverage includes areas such as:

  • base utilities like wx.canIUse()
  • window and system information such as wx.getWindowInfo()
  • app control such as wx.exitMiniProgram()
  • UI helpers such as wx.setBackgroundColor()
  • networking APIs such as wx.request(), wx.connectSocket(), and wx.createEventSource()
  • media APIs such as recorder and camera helpers under wx.media
  • speech helpers under wx.speech

Example:

const info = wx.getWindowInfo();
console.log(info.windowWidth, info.windowHeight);

What This Package Does Not Cover

This README is intentionally focused on the JavaScript and TypeScript API surface available to application code.

It does not document:

  • runtime internals
  • renderer or engine architecture
  • native bridge details
  • package implementation structure
  • host-specific implementation notes that are not part of the exposed API contract

Files

The published package contains:

  • index.d.ts
  • globals.d.ts
  • modules.d.ts
  • wx.d.ts
  • README.md