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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webgpu/types

v0.1.52

Published

This package defines Typescript types (`.d.ts`) for the upcoming [WebGPU standard](https://github.com/gpuweb/gpuweb/wiki/Implementation-Status).

Downloads

3,159,898

Readme

Typescript Type Definitions for WebGPU

This package defines Typescript types (.d.ts) for the upcoming WebGPU standard.

Use this package to augment the ambient "dom" type definitions with the new definitions for WebGPU.

API style docs

This repo also generates typedoc docs here: https://gpuweb.github.io/types

What are declaration files?

See the TypeScript handbook.

How can I use them?

Install

  • npm: npm install --save-dev @webgpu/types
  • yarn: yarn add --dev @webgpu/types
  • pnpm: pnpm add -D @webgpu/types

If you are on TypeScript < 5.1, you will also need to install @types/dom-webcodecs as a sibling dependency. The version you need depends on the TypeScript version; see the tests for examples.

Configure

Since this package is outside DefinitelyTyped, the dependency won't be picked up automatically. There are several ways to add a additional TypeScript type definition dependencies to your TypeScript project:

TypeScript tsc and tsc-based bundlers

In tsconfig.json:

{
  // ...
  "compilerOptions": {
    // ...
    "types": ["@webgpu/types"]
  }
}

Or you can use typeRoots:

{
  // ...
  "compilerOptions": {
    // ...
    "typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@types"]
  }
}

Inline in TypeScript

This may work better if your toolchain doesn't read tsconfig.json.

/// <reference types="@webgpu/types" />

Webpack

If you use Webpack and the options above aren't sufficient (this has not been verified), you may need the following in webpack.config.js:

"types": ["@webgpu/types"]

Others?

Please contribute a PR to add instructions for other setups or improve existing instructions. :)

How to update these types

  • Make sure the submodule is checked out: git submodule update --init
  • Pull gpuweb changes: pushd gpuweb && git checkout main && git pull && popd
  • Install dependencies: npm ci
  • Bug workaround: paste the copies.bs contents in place of its include in index.bs (generator doesn't support includes).
  • Generate generated/index.d.ts: npm run generate
  • Open a diff between generated/index.d.ts and dist/index.d.ts. The generated file is tracked by Git so you can see what has changed. Update the latter according to changes from the former. Note the generated/ and dist/ files are not the same. See below for intentional differences.
  • Format the result: npm run format

Intentional differences between generator output and final result

Most or all of these should be fixed in the generator over time.

  • Array changed to Iterable for WebIDL sequences in argument positions (but not in return positions).
  • any changed to object for WebIDL object.
  • | SharedArrayBuffer added for [AllowShared] BufferSource.
  • | null changed to | null | undefined for WebIDL nullable items (T?).

The following differences are TODO: should be changed in the final result.

  • Deprecated items should be removed.

The following differences will remain.

  • onuncapturederror strongly typed.
  • getContext definitions.
  • GPUExtent3DStrict and GPUOrigin2DStrict.

Publish a new npm package version

(only for people who have npm publish access)

  • One line cmd to copy-n-paste (for ssh git user, and you'd better know what you are doing, if it failed at certain steps, you might need to clean up git tags before trying again)
    • git checkout main && git pull [email protected]:gpuweb/types.git main && git submodule update --init && npm version patch && git push [email protected]:gpuweb/types.git main --tags && npm publish
  • Separate steps (better for publishing for the first time)
    • Make sure you are in the upstream repo, not your forked one. And make sure you are synced to latest commit intended for publish
      • git checkout main
      • git pull https://github.com/gpuweb/types.git main
        • (If you are using HTTPS regularly. You can use remote names like origin, just make sure you are referring to the right repo)
      • git submodule update --init
    • Create the version tag and commit, and push
      • npm version patch
      • git push https://github.com/gpuweb/types.git main --tags
    • publish the package
      • npm publish --otp=<code>
        • Replace <code> with the one-time password from your authenticator, since two-factors authentication is required to publish.
        • If you are doing for the first time, you will do npm adduser first and it will guide you through adding the npm account.