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

@kjfsm/musescore-plugin-sdk-types

v2.0.0

Published

TypeScript type definitions for the MuseScore 4 Plugin API.

Readme

@kjfsm/musescore-plugin-sdk-types

MuseScore 4 Plugin API の TypeScript 型定義。

src/generated/ 以下のファイルは @kjfsm/musescore-plugin-sdk-types-generator が公式の musescore/MuseScore C++ ヘッダから生成したもの。手で編集せず、リポジトリのルートで pnpm generate:types を実行すること。

使い方

import type { MuseScore, Score, Cursor, Note } from "@kjfsm/musescore-plugin-sdk-types";

// `MuseScore` は QML の `MuseScore { }` オブジェクト(ホスト)の型。
// curScore・全 enum・メソッド・mscoreMajorVersion 等を 1 つにまとめている。
export function run(host: MuseScore): void {
  const score = host.curScore;
  if (!score) return;
  if (/* el */ null === host.Element.NOTE) {
    // host.Element の値は実行時に解決される
  }
}

実行時 enum とホスト型

apiv1 の element.type は実行時に C++ enum の生の整数を返す。この値は MuseScore のバージョン差で並び替わりうる(例: 4.7.2→4.7.3 で ElementType が再採番)。そのため生成 enum(enums.ts)は値を持たない型のみとして出力される — ElementType.NOTE のように値として使おうとすると、そもそもコンパイルが通らない。

比較には実行時のホスト enumhost.Element など)を使う。型側はキー(メンバ名)だけを生成 enum の <Enum>Name から取り、値はブランド化された生成 enum の型(実行時に解決される)になる:

  • MuseScore — ホスト型(qmlpluginapi.h から自動生成。enum プロパティは RuntimeEnum<Name, Value> 型)。
  • RuntimeEnum<Name, Value> / ElementEnum / NoteTypeEnum / BarLineTypeEnum — 実行時 enum オブジェクトの型。
  • ElementTypeName / NoteTypeName / BarLineTypeName — enum メンバ名のユニオン。
  • generatedFrom — 型を生成した MuseScore バージョン({ repository, tag, commitSha })。バージョン照合に使える。

生成 enum の値はブランド化されている(例: ElementTypeNoteType は互いに代入不可)ため、el.type === host.NoteType.NORMAL のような enum の取り違えも型エラーで検出できる。

エントリ定義・バージョン照合のヘルパ(definePlugin / assertHostVersion 等)は @kjfsm/musescore-plugin-sdk-helpers にある。

globals

@kjfsm/musescore-plugin-sdk-types/globalscurScoreQt をアンビエントグローバルとして宣言する。ただし推奨はホスト経由(host.curScore / host.quit())。