@wcstack/midi 4.16.0 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +17 -2
- package/README.md +17 -2
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +25 -8
- package/dist/index.esm.js +121 -25
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
MIDI の入力と出力は別機能に見えますが、ページが持つ `MIDIAccess` は**1つだけ**で、両方向はそこから派生します。`<wcs-midi-in>` と `<wcs-midi-out>` に分割しても、同じハンドルを2要素が調停する必要が生まれるだけです。そこで `<wcs-ws>` が WebSocket の送受信を1タグで扱うのと同様に、`<wcs-midi>` が両方向を担います。(`@wcstack/speech` が2タグに分かれているのは、`SpeechSynthesis` と `SpeechRecognition` が**別々の API** だからです。)
|
|
27
27
|
|
|
28
|
-
> **Chromium 限定。** Web MIDI は Chromium 系のみで動きます。Firefox は既定で無効、Safari は未実装です。API が無い環境(非セキュアコンテキストを含む)では、`<wcs-midi>` は throw せず `permission = "unsupported"` を報告します。
|
|
28
|
+
> **Chromium 限定。** Web MIDI は Chromium 系のみで動きます。Firefox は既定で無効、Safari は未実装です。API が無い環境(非セキュアコンテキストを含む)では、`<wcs-midi>` は throw せず `permission = "unsupported"` を報告します。4.17 からは、`auto` の有無にかかわらず接続した時点で報告します — API が無ければプロンプトも無いためです。それまでは `auto` の無い要素が `request()` を呼ぶまで `prompt` のままで、ページは決して働かない「接続」ボタンを出していました。
|
|
29
29
|
|
|
30
30
|
## インストール
|
|
31
31
|
|
|
@@ -75,6 +75,8 @@ npm install @wcstack/midi
|
|
|
75
75
|
<button data-wcs="onclick: $command.connectMidi; hidden: midiReady">MIDI に接続</button>
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
ボタンは `devices` ではなく `connected` で隠してください。`devices` はポートの一覧で、アクセスの有無ではありません。`@wcstack/router` のルートの中では、ルートを出ると要素が文書から外れ、入り直すと戻ります — [外して戻したとき](#外して戻したとき)を参照。
|
|
79
|
+
|
|
78
80
|
### 3. フェーダーで値を駆動する
|
|
79
81
|
|
|
80
82
|
```html
|
|
@@ -114,6 +116,8 @@ state.$command.midiSend.emit([0x90, 60, 100]);
|
|
|
114
116
|
- **velocity 0 の note-on は `noteoff` として報告します。** 多くのコントローラは本来の 0x8n note-off を送らず、note-on のまま扱うと音が鳴りっぱなしになります。生のステータスバイトは `message.data[0]` に残っています。
|
|
115
117
|
- **velocity は 0〜1** なので、そのままゲインに掛けられます。コントローラ値は意味がコントローラ依存なので生の値のままです。
|
|
116
118
|
|
|
119
|
+
**note-on と note-off は `type` で判断し、`message.data[0]` の生のステータスバイトでは判断しないでください。** 1 つ目の正規化は `type` にしか入っていません。velocity 0 の note-on で離された鍵盤は、`data[0]` が `0x9n` で `type` が `"noteoff"` です。`(data[0] & 0xf0) === 0x90` で判断したページは、そうした離鍵をすべてもう一度の打鍵と取り違え、音が止まらず鳴りっぱなしになりました。
|
|
120
|
+
|
|
117
121
|
`message` は状態ではなく **occurrence** です。同じ内容の note-on 2回は別々の打鍵なので、同値ガードは行いません。`data` はメッセージごとに新しい `Uint8Array` で、プラットフォームのバッファをそのまま渡すことはありません(RxJS の replay や React のスナップショットで保持しても安全です)。
|
|
118
122
|
|
|
119
123
|
## ポート
|
|
@@ -140,6 +144,14 @@ state.$command.midiSend.emit([0x90, 60, 100]);
|
|
|
140
144
|
|
|
141
145
|
`sysex` はシステムエクスクルーシブの許可を要求します。これは**別個の、より制限された権限**なので、実際に SysEx が必要でなければ付けないでください。
|
|
142
146
|
|
|
147
|
+
## 外して戻したとき
|
|
148
|
+
|
|
149
|
+
`@wcstack/router` は離れたルートの中身を文書から外し、次に入ったときに同じ要素を `@wcstack/state` の束縛ごと戻します([router README](../router/README.ja.md#ルートの本文はどこに置くか))。ルートの中の `<wcs-midi>` はその両方を経ます。
|
|
150
|
+
|
|
151
|
+
- **外れると**、要素はアクセスを手放します。`connected` が `false` に、4.17 からは `devices` も `[]` になり、どちらも知らせます([タイミング契約](../../docs/timing-and-firing-contract.ja.md) §22)。`close()` も `devices` を空にします。`permission` はそのままです — ブラウザの許可は変わっていません。それまでは `devices` が古い一覧を保ち、その数を出すページは、メッセージが一つも届かないのにキーボードがつながっていると表示していました。
|
|
152
|
+
- **戻ると**、`auto` の要素は最初の接続と同じく要求します。4.17 からは、最後の `request()` でアクセスを取れた要素も、`auto` が無くても要求し直します — ただし**権限がまだ `granted` のときだけ**で、プロンプトは出ません。ブラウザが `navigator.permissions.query({ name: "midi", sysex })` に答えるならその答えで、答えないならその `request()` の結果(同じ `sysex` のもの)で決めます。`sysex` の許可も同じ規則に従います。`auto` が取ったアクセスは数えません — 戻るときに `auto` が外されていれば、何も要求しません(§23)。判断はマイクロタスクを 1 つ待ち、そのときの `sysex` を読みます(§23)。同じタスクの `close()` はそれを取り消し、外す前に `close()` していた要素も取り直しません。
|
|
153
|
+
- **一度も要求していない要素**、最後の要求が拒否された要素、権限がいま `prompt` か `denied` の要素は、戻っても何も要求しません。ページが、最初の訪問と同じくユーザー操作から要求し直す必要があります — 上の「接続」ボタンを `connected` で隠すのはそのためです。4.17 からは、最後の `request()` でアクセスを取れた要素に Permissions API が `prompt` か `denied` と答えたとき(外れている間にサイトの設定で許可が取り消された)は、接続中に見た取り消しと同じく、その答えを `permission` に知らせます — ページは最後に見た `granted` ではなく `denied`(または `prompt`)を読みます。ブラウザが答えないときは新しく分かったことが無いので、`permission` はそのままです。
|
|
154
|
+
|
|
143
155
|
## `:state()` による CSS スタイリング
|
|
144
156
|
|
|
145
157
|
Shell は出力状態を `ElementInternals.states` に反映します。
|
|
@@ -169,6 +181,8 @@ core.send([0x90, 60, 100]);
|
|
|
169
181
|
core.dispose();
|
|
170
182
|
```
|
|
171
183
|
|
|
184
|
+
`observe(options)` は Shell の接続の段階です。オプションを記録し、API が無ければ `unsupported` を報告し、`auto` なら要求します。4.17 からは、`dispose()` の後なら、最後の `request()` が取ったアクセスも[外して戻したとき](#外して戻したとき)の規則で取り直します。`close()` はそのアクセスを忘れ、どちらも `devices` を空にします。
|
|
185
|
+
|
|
172
186
|
別経路で得たバイト列をデコードするために `parseMessage(data)` も単体で export しています。
|
|
173
187
|
|
|
174
188
|
## エラー
|
|
@@ -177,7 +191,7 @@ throw は一切しません。失敗は状態として現れます。
|
|
|
177
191
|
|
|
178
192
|
| 状況 | `permission` | `error` | `errorInfo.code` |
|
|
179
193
|
|---|---|---|---|
|
|
180
|
-
| `navigator.requestMIDIAccess`
|
|
194
|
+
| `navigator.requestMIDIAccess` 不在(4.17 からは `auto` の有無にかかわらず接続時に報告) | `unsupported` | `"unsupported"` | `capability-missing` |
|
|
181
195
|
| ユーザーが拒否 / ポリシーでブロック | `denied` | rejection のメッセージ | `not-allowed` |
|
|
182
196
|
| その他のアクセス失敗 | `denied` | rejection のメッセージ | `access-error` |
|
|
183
197
|
| `send()` の失敗 | 変化なし | throw のメッセージ | `send-failed` |
|
|
@@ -185,6 +199,7 @@ throw は一切しません。失敗は状態として現れます。
|
|
|
185
199
|
## 注意点
|
|
186
200
|
|
|
187
201
|
- **4.8 から、接続時のアクセスの要求はマイクロタスクを 1 つ待ち**、そのときの `auto` / `sysex` を読む([タイミング契約](../../docs/timing-and-firing-contract.ja.md) §23)。`@wcstack/router` はパラメータだけの遷移でルートの要素を入れ直し、`@wcstack/state` が次のルートの入力を書くのはその後で、前のルートの水準で許可を求めていた。`request()` は今の `sysex` を読み、同じタスクの `close()` は待っている要求を取り消す。
|
|
202
|
+
- **4.17 から、外れた要素は `devices` を空にし、戻った要素は要求し直す** — 最後の `request()` でアクセスを取れていて、権限がまだ `granted` のとき([外して戻したとき](#外して戻したとき))。接続と同じタスクの `request()` は待っている判断を引き取り、`auto` でも要求は 1 回。
|
|
188
203
|
- **Chromium 限定**。セキュアコンテキストが必要。
|
|
189
204
|
- **velocity 0 の note-on は note-off**(上記)。
|
|
190
205
|
- **`sysex` は別権限**で、拒否されやすい。
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ This means a MIDI controller can drive your application state declaratively in H
|
|
|
25
25
|
|
|
26
26
|
MIDI input and output look like two features, but a page holds exactly **one** `MIDIAccess` object, and both directions are derived from it. Splitting them into `<wcs-midi-in>` and `<wcs-midi-out>` would only force the two elements to coordinate over the same shared handle — so `<wcs-midi>` covers both, as `<wcs-ws>` does for WebSocket send/receive. (`@wcstack/speech` splits into two tags precisely because `SpeechSynthesis` and `SpeechRecognition` are two *different* APIs.)
|
|
27
27
|
|
|
28
|
-
> **Chromium only.** Web MIDI ships in Chromium-based browsers. Firefox has it behind a pref and Safari does not implement it. Where the API is absent — including any non-secure context — `<wcs-midi>` reports `permission = "unsupported"` instead of throwing.
|
|
28
|
+
> **Chromium only.** Web MIDI ships in Chromium-based browsers. Firefox has it behind a pref and Safari does not implement it. Where the API is absent — including any non-secure context — `<wcs-midi>` reports `permission = "unsupported"` instead of throwing. Since 4.17 it does so as soon as it is connected, with or without `auto`: no prompt is involved when there is no API. Before, an element without `auto` said `prompt` until `request()` was called, so a page offered a Connect button that could never work.
|
|
29
29
|
|
|
30
30
|
## Install
|
|
31
31
|
|
|
@@ -75,6 +75,8 @@ npm install @wcstack/midi
|
|
|
75
75
|
<button data-wcs="onclick: $command.connectMidi; hidden: midiReady">Connect MIDI</button>
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
Hide the button on `connected`, not on `devices`: `devices` lists ports, not access. In a `@wcstack/router` route, the element is taken out when the route is left and put back on the way in — see [Taken out and put back](#taken-out-and-put-back).
|
|
79
|
+
|
|
78
80
|
### 3. Drive a value from a fader
|
|
79
81
|
|
|
80
82
|
```html
|
|
@@ -114,6 +116,8 @@ Two normalizations are applied so every consumer does not have to repeat them:
|
|
|
114
116
|
- **A note-on with velocity 0 is reported as `noteoff`.** Many controllers never emit a real 0x8n note-off; treating those as note-ons leaves stuck notes. The raw status byte is still in `message.data[0]`.
|
|
115
117
|
- **Velocity is 0-1**, so it multiplies straight into a gain. Controller values stay raw, since their meaning is per-controller.
|
|
116
118
|
|
|
119
|
+
**Decide note-on and note-off from `type`, never from the raw status byte in `message.data[0]`.** Only `type` carries the first normalization: a key released as a note-on with velocity 0 has `0x9n` in `data[0]` and `type: "noteoff"`. A page that tested `(data[0] & 0xf0) === 0x90` took every such release for another press, so its notes never stopped: the keys stuck.
|
|
120
|
+
|
|
117
121
|
`message` is an **occurrence**, not a state: two identical note-ons are two distinct presses, so it is never same-value guarded. `data` is a fresh `Uint8Array` on every message — the platform buffer is never handed out, so retaining a message (an RxJS replay, a React snapshot) is safe.
|
|
118
122
|
|
|
119
123
|
## Ports
|
|
@@ -140,6 +144,14 @@ Where the browser answers `navigator.permissions.query({ name: "midi" })`, a gra
|
|
|
140
144
|
|
|
141
145
|
`sysex` requests the system-exclusive grant, which is a **separate and more restricted permission** — leave it off unless you actually need SysEx.
|
|
142
146
|
|
|
147
|
+
## Taken out and put back
|
|
148
|
+
|
|
149
|
+
`@wcstack/router` takes a left route's content out of the document and puts the same elements back on the next entry, with their `@wcstack/state` bindings ([router README](../router/README.md#where-route-content-lives)). A `<wcs-midi>` in a route lives through both.
|
|
150
|
+
|
|
151
|
+
- **Taken out**, the element releases its access: `connected` goes to `false` and, since 4.17, `devices` to `[]`, both published ([timing contract](../../docs/timing-and-firing-contract.md) §22). `close()` empties `devices` too. `permission` stays as it was: the browser's grant has not changed. Before, `devices` kept the old list, and a page that counted it said the keyboard was connected while no message could arrive.
|
|
152
|
+
- **Put back**, an `auto` element requests as on its first connect. Since 4.17, so does an element whose last `request()` got access, without `auto` — but **only while the permission is still `granted`**, so no prompt can appear: where the browser answers `navigator.permissions.query({ name: "midi", sysex })` that answer decides, and where it does not, the outcome of that `request()` stands (for the same `sysex`). A `sysex` grant follows the same rule. An access `auto` got does not count: with `auto` turned off on the way back in, nothing is requested (§23). The decision waits one microtask and reads `sysex` then (§23); `close()` in the same task cancels it, and so does a `close()` before the element was taken out.
|
|
153
|
+
- **An element that never requested**, whose last request was refused, or whose permission is now `prompt` or `denied`, requests nothing when put back. The page must request again, from a user gesture as on the first visit — which is why the Connect button above hides on `connected`. Since 4.17, when the Permissions API answers `prompt` or `denied` to an element whose last `request()` got access (the grant was revoked in site settings while the element was out), that answer is published as `permission`, as a revocation seen while connected is: the page reads `denied` (or `prompt`), not the `granted` it last saw. Where the browser does not answer, nothing new is known, and `permission` stays.
|
|
154
|
+
|
|
143
155
|
## CSS styling with `:state()`
|
|
144
156
|
|
|
145
157
|
The Shell reflects its output state into `ElementInternals.states`:
|
|
@@ -169,6 +181,8 @@ core.send([0x90, 60, 100]);
|
|
|
169
181
|
core.dispose();
|
|
170
182
|
```
|
|
171
183
|
|
|
184
|
+
`observe(options)` is the Shell's connect step: it records the options, reports a missing API as `unsupported`, and requests when `auto` is set. Since 4.17, after `dispose()` it also acquires again the access the last `request()` got, by the rule of [Taken out and put back](#taken-out-and-put-back); `close()` forgets that access, and both empty `devices`.
|
|
185
|
+
|
|
172
186
|
`parseMessage(data)` is exported separately for decoding bytes you obtained some other way.
|
|
173
187
|
|
|
174
188
|
## Errors
|
|
@@ -177,7 +191,7 @@ Nothing throws. Failures surface as state:
|
|
|
177
191
|
|
|
178
192
|
| Situation | `permission` | `error` | `errorInfo.code` |
|
|
179
193
|
|---|---|---|---|
|
|
180
|
-
| `navigator.requestMIDIAccess` absent | `unsupported` | `"unsupported"` | `capability-missing` |
|
|
194
|
+
| `navigator.requestMIDIAccess` absent (reported at connect since 4.17, `auto` or not) | `unsupported` | `"unsupported"` | `capability-missing` |
|
|
181
195
|
| User denied / policy blocked | `denied` | rejection message | `not-allowed` |
|
|
182
196
|
| Other access failure | `denied` | rejection message | `access-error` |
|
|
183
197
|
| `send()` failed | unchanged | throw message | `send-failed` |
|
|
@@ -185,6 +199,7 @@ Nothing throws. Failures surface as state:
|
|
|
185
199
|
## Notes
|
|
186
200
|
|
|
187
201
|
- **Since 4.8, the connect-time access request waits one microtask** and reads `auto` / `sysex` then ([timing contract](../../docs/timing-and-firing-contract.md) §23): `@wcstack/router` puts a route's elements back on a parameter-only navigation before `@wcstack/state` writes the next route's inputs, and the prompt asked for the previous route's level. `request()` reads the current `sysex`; `close()` in the same task cancels the pending request.
|
|
202
|
+
- **Since 4.17, an element taken out empties `devices`, and one put back requests again** when its last `request()` got access and the permission is still `granted` — see [Taken out and put back](#taken-out-and-put-back). A `request()` in the same task as the connect takes the pending decision: one request, `auto` or not.
|
|
188
203
|
- **Chromium only**, and a secure context is required.
|
|
189
204
|
- **Velocity 0 note-ons are note-offs** — see above.
|
|
190
205
|
- **`sysex` is a separate permission** and is often refused.
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tagNames:{midi:"wcs-midi"}};var t="@wcstack/midi",s="4.16.0";const n="capability-missing",i="not-allowed",r="access-error",o="send-failed";const a={type:"other",channel:null,note:null,velocity:null,control:null,value:null};const c="unsupported",u=e=>e.detail,l=e=>t=>u(t)?.[e]??null;class h extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"message",event:"wcs-midi:message",semantics:"event"},{name:"type",event:"wcs-midi:message",semantics:"event",getter:l("type")},{name:"channel",event:"wcs-midi:message",semantics:"event",getter:l("channel")},{name:"note",event:"wcs-midi:message",semantics:"event",getter:l("note")},{name:"velocity",event:"wcs-midi:message",semantics:"event",getter:l("velocity")},{name:"control",event:"wcs-midi:message",semantics:"event",getter:l("control")},{name:"value",event:"wcs-midi:message",semantics:"event",getter:l("value")},{name:"devices",event:"wcs-midi:devices",semantics:"state"},{name:"connected",event:"wcs-midi:statechange",semantics:"state"},{name:"permission",event:"wcs-midi:permission",semantics:"state"},{name:"granted",event:"wcs-midi:permission",semantics:"state",getter:e=>"granted"===u(e)},{name:"denied",event:"wcs-midi:permission",semantics:"state",getter:e=>"denied"===u(e)},{name:"unsupported",event:"wcs-midi:permission",semantics:"state",getter:e=>u(e)===c},{name:"error",event:"wcs-midi:error",semantics:"state"},{name:"errorInfo",event:"wcs-midi:error-info-changed",semantics:"state"}],commands:[{name:"request",async:!0},{name:"close"},{name:"send"}]};_target;_options={};_access=null;_hookedInputs=new Set;_message=null;_devices=[];_connected=!1;_permission="prompt";_error=null;_errorInfo=null;_permissionStatus=null;_gen=0;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._options={...e})}get message(){return this._message}get type(){return this._message?.type??null}get channel(){return this._message?.channel??null}get note(){return this._message?.note??null}get velocity(){return this._message?.velocity??null}get control(){return this._message?.control??null}get value(){return this._message?.value??null}get devices(){return this._devices}get connected(){return this._connected}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get unsupported(){return this._permission===c}get error(){return this._error}get errorInfo(){return this._errorInfo}get ready(){return this._ready}observe(e){const t=null===this._access;return this.setOptions(e),e.auto&&t&&(this._ready=this.request()),this._ready}setOptions(e){this._options={...this._options,...e},this._access&&this._hookInputs(this._access)}request(){const e=this._resolveApi();if(!e)return this._setPermission(c),this._setError(c,c),this._ready=Promise.resolve(),this._ready;const t=++this._gen;return this._probePermission(),this._ready=e({sysex:!0===this._options.sysex}).then(e=>{t===this._gen&&(this._access=e,e.onstatechange=this._onStateChange,this._setError(null),this._setPermission("granted"),this._hookInputs(e),this._publishDevices(e),this._setConnected(!0))},e=>{t===this._gen&&(this._setPermission("denied"),this._setError(this._messageOf(e),e?.name))}),this._ready}close(){this._gen++,this._unhookInputs(),this._access&&(this._access.onstatechange=null,this._access=null),this._setConnected(!1)}send(e,t){const s=this._resolveOutput();if(s)try{s.send(e,t)}catch(e){this._setError(this._messageOf(e),"send")}}dispose(){this.close(),this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_resolveApi(){const e=globalThis.navigator;return e&&"function"==typeof e.requestMIDIAccess?t=>e.requestMIDIAccess(t):null}_messageOf(e){return"string"==typeof e?.message&&""!==e.message?e.message:"MIDI error"}_probePermission(){if(this._permissionStatus)return;const e=globalThis.navigator.permissions;if(!e||"function"!=typeof e.query)return;const t=this._gen;e.query({name:"midi",sysex:!0===this._options.sysex}).then(e=>{t===this._gen&&(this._permissionStatus=e,this._setPermission(e.state),e.addEventListener("change",this._onPermissionChange))},()=>{})}_onPermissionChange=e=>{this._setPermission(e.target.state)};_matches(e,t){if(e.id===t)return!0;return(e.name??"").toLowerCase().startsWith(t.toLowerCase())}_selectedInputs(e){const t=[...e.inputs.values()],s=this._options.input;return null==s||""===s?t:t.filter(e=>this._matches(e,s))}_resolveOutput(){if(!this._access)return null;const e=[...this._access.outputs.values()],t=this._options.output;return null==t||""===t?e[0]??null:e.find(e=>this._matches(e,t))??null}_hookInputs(e){const t=new Set(this._selectedInputs(e));for(const e of this._hookedInputs)t.has(e)||(e.onmidimessage=null,this._hookedInputs.delete(e));for(const e of t)this._hookedInputs.has(e)||(e.onmidimessage=this._onMidiMessage,this._hookedInputs.add(e))}_unhookInputs(){for(const e of this._hookedInputs)e.onmidimessage=null;this._hookedInputs.clear()}_onStateChange=()=>{const e=this._access;this._hookInputs(e),this._publishDevices(e)};_onMidiMessage=e=>{const t=e.data;if(!t)return;const s=function(e){const t=e[0];if("number"!=typeof t)return a;const s="number"==typeof e[1]?e[1]:0,n="number"==typeof e[2]?e[2]:0;if(t>=240)return{...a,type:240===t?"sysex":"other"};if(t<128)return a;const i=1+(15&t);switch(240&t){case 128:return{type:"noteoff",channel:i,note:s,velocity:n/127,control:null,value:null};case 144:return n>0?{type:"noteon",channel:i,note:s,velocity:n/127,control:null,value:null}:{type:"noteoff",channel:i,note:s,velocity:0,control:null,value:null};case 160:return{type:"polyaftertouch",channel:i,note:s,velocity:null,control:null,value:n};case 176:return{type:"controlchange",channel:i,note:null,velocity:null,control:s,value:n};case 192:return{type:"programchange",channel:i,note:null,velocity:null,control:null,value:s};case 208:return{type:"aftertouch",channel:i,note:null,velocity:null,control:null,value:s};default:return{type:"pitchbend",channel:i,note:null,velocity:null,control:null,value:((n<<7|s)-8192)/8192}}}(t),n=this._options.channel;if(null!=n&&null!==s.channel&&s.channel!==n)return;const i=e.target;this._publishMessage({...s,data:new Uint8Array(t),port:i?.id??"",portName:i?.name??"",timestamp:e.timeStamp??0})};_publishMessage(e){this._message=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:message",{detail:e,bubbles:!0}))}_publishDevices(e){const t=this._snapshotDevices(e);this._sameDevices(t)||(this._devices=t,this._target.dispatchEvent(new CustomEvent("wcs-midi:devices",{detail:t,bubbles:!0})))}_snapshotDevices(e){const t=(e,t)=>[...e.values()].map(e=>({id:e.id,name:e.name??"",manufacturer:e.manufacturer??"",direction:t,state:"connected"===e.state?"connected":"disconnected"}));return[...t(e.inputs,"input"),...t(e.outputs,"output")]}_sameDevices(e){return e.length===this._devices.length&&e.every((e,t)=>{const s=this._devices[t];return s.id===e.id&&s.state===e.state&&s.direction===e.direction&&s.name===e.name})}_setConnected(e){this._connected!==e&&(this._connected=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:statechange",{detail:e,bubbles:!0})))}_setPermission(e){this._permission!==e&&(this._permission=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:permission",{detail:e,bubbles:!0})))}_setError(e,t){this._error!==e&&(this._error=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:error",{detail:e,bubbles:!0}))),this._commitErrorInfo(null===e?null:function(e,t){return"unsupported"===e?{code:n,phase:"probe",recoverable:!1,message:t}:"send"===e?{code:o,phase:"execute",recoverable:!0,message:t}:"SecurityError"===e||"NotAllowedError"===e?{code:i,phase:"start",recoverable:!1,message:t}:{code:r,phase:"start",recoverable:!0,message:t}}(t,e))}_commitErrorInfo(e){null===this._errorInfo&&null===e||(this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:error-info-changed",{detail:e,bubbles:!0})))}}function d(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const m=new WeakSet;function _(e,t,s){if(m.has(e))return;m.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const p=new WeakMap;function g(e,t){let s=p.get(e);return void 0===s&&(s=new Map,p.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function v(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function f(e,t,s){const n=g(e,t);v(e,t,void 0===s?n:null===s?null:String(s))}function b(e,t,s){const n=g(e,t);v(e,t,void 0===s?n:s?"":null)}class y extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["input","output","channel"];static wcBindable={...h.wcBindable,inputs:[{name:"input",attribute:"input"},{name:"output",attribute:"output"},{name:"channel",attribute:"channel"},{name:"sysex",attribute:"sysex"},{name:"auto",attribute:"auto"}]};_core;_connectedCallbackPromise=Promise.resolve();_connectResolve=null;_requestPending=!1;_autoCancelled=!1;_internals=null;constructor(){super(),this._core=new h(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-midi:permission":e=>({granted:"granted"===e,denied:"denied"===e,unsupported:"unsupported"===e}),"wcs-midi:statechange":e=>({connected:!0===e}),"wcs-midi:error":e=>({error:null!==e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get input(){return this.getAttribute("input")??""}set input(e){f(this,"input",e)}get output(){return this.getAttribute("output")??""}set output(e){f(this,"output",e)}get channel(){const e=this.getAttribute("channel");if(null===e)return null;const t=Number(e);return Number.isFinite(t)?t:null}set channel(e){f(this,"channel",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){b(this,"sysex",e)}get auto(){return this.hasAttribute("auto")}set auto(e){b(this,"auto",e)}get message(){return this._core.message}get type(){return this._core.type}get note(){return this._core.note}get velocity(){return this._core.velocity}get control(){return this._core.control}get value(){return this._core.value}get devices(){return this._core.devices}get connected(){return this._core.connected}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get core(){return this._core}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.setOptions(this._options()),this._core.request()}close(){null!==this._connectResolve&&(this._autoCancelled=!0),this._core.close()}send(e,t){this._core.send(e,t)}_options(){return{input:this.input,output:this.output,channel:this.channel,sysex:this.sysex,auto:this.auto}}_scheduleRequest(){this._requestPending||(this._requestPending=!0,queueMicrotask(()=>{this._requestPending=!1;const e=this._connectResolve;if(this._connectResolve=null,null===e)return;const t=this._options();this._autoCancelled&&(t.auto=!1),this._autoCancelled=!1,e(this._core.observe(t))}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&_(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!d(e,s))continue;const r=e,o=r[s];delete r[s],r[s]=o}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleRequest()}disconnectedCallback(){this._connectResolve?.(),this._connectResolve=null,this._autoCancelled=!1,this._core.dispose()}attributeChangedCallback(e,t,s){t!==s&&this.isConnected&&this._core.setOptions(this._options())}}const w=Symbol.for("wcstack.package"),I=new WeakSet;function C(e,t){Object.defineProperty(e,w,{value:t,configurable:!0})}function k(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[w];if(r===i||I.has(e))return;I.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function P(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(C(i,t),e.define(n,i)):k(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.midi,y]])}var E;P(E);
|
|
1
|
+
const e={tagNames:{midi:"wcs-midi"}};var t="@wcstack/midi",s="4.17.0";const n="capability-missing",i="not-allowed",r="access-error",o="send-failed";const a={type:"other",channel:null,note:null,velocity:null,control:null,value:null};const c="unsupported",u=e=>e.detail,l=e=>t=>u(t)?.[e]??null;class h extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"message",event:"wcs-midi:message",semantics:"event"},{name:"type",event:"wcs-midi:message",semantics:"event",getter:l("type")},{name:"channel",event:"wcs-midi:message",semantics:"event",getter:l("channel")},{name:"note",event:"wcs-midi:message",semantics:"event",getter:l("note")},{name:"velocity",event:"wcs-midi:message",semantics:"event",getter:l("velocity")},{name:"control",event:"wcs-midi:message",semantics:"event",getter:l("control")},{name:"value",event:"wcs-midi:message",semantics:"event",getter:l("value")},{name:"devices",event:"wcs-midi:devices",semantics:"state"},{name:"connected",event:"wcs-midi:statechange",semantics:"state"},{name:"permission",event:"wcs-midi:permission",semantics:"state"},{name:"granted",event:"wcs-midi:permission",semantics:"state",getter:e=>"granted"===u(e)},{name:"denied",event:"wcs-midi:permission",semantics:"state",getter:e=>"denied"===u(e)},{name:"unsupported",event:"wcs-midi:permission",semantics:"state",getter:e=>u(e)===c},{name:"error",event:"wcs-midi:error",semantics:"state"},{name:"errorInfo",event:"wcs-midi:error-info-changed",semantics:"state"}],commands:[{name:"request",async:!0},{name:"close"},{name:"send"}]};_target;_options={};_access=null;_hookedInputs=new Set;_message=null;_devices=[];_connected=!1;_permission="prompt";_error=null;_errorInfo=null;_permissionStatus=null;_gen=0;_pendingGen=-1;_grantedSysex=null;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._options={...e})}get message(){return this._message}get type(){return this._message?.type??null}get channel(){return this._message?.channel??null}get note(){return this._message?.note??null}get velocity(){return this._message?.velocity??null}get control(){return this._message?.control??null}get value(){return this._message?.value??null}get devices(){return this._devices}get connected(){return this._connected}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get unsupported(){return this._permission===c}get error(){return this._error}get errorInfo(){return this._errorInfo}get ready(){return this._ready}observe(e){return this.setOptions(e),null!==this._access||this._pendingGen===this._gen||(e.auto||null===this._resolveApi()?this._ready=this._request(!1):null!==this._grantedSysex&&(this._ready=this._reacquire())),this._ready}setOptions(e){this._options={...this._options,...e},this._access&&this._hookInputs(this._access)}request(){return this._request(!0)}_request(e){const t=this._resolveApi();if(!t)return this._setPermission(c),this._setError(c,c),this._ready=Promise.resolve(),this._ready;const s=++this._gen;this._pendingGen=s;const n=!0===this._options.sysex;return this._probePermission(),this._ready=t({sysex:n}).then(t=>{s===this._gen&&(this._pendingGen=-1,e&&(this._grantedSysex=n),this._access=t,t.onstatechange=this._onStateChange,this._setError(null),this._setPermission("granted"),this._hookInputs(t),this._publishDevices(t),this._setConnected(!0))},e=>{s===this._gen&&(this._pendingGen=-1,this._grantedSysex=null,this._setPermission("denied"),this._setError(this._messageOf(e),e?.name))}),this._ready}close(){this._release(),this._grantedSysex=null}send(e,t){const s=this._resolveOutput();if(s)try{s.send(e,t)}catch(e){this._setError(this._messageOf(e),"send")}}dispose(){this._release(),this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_release(){this._gen++,this._unhookInputs(),this._access&&(this._access.onstatechange=null,this._access=null),this._setConnected(!1),this._setDevices([])}_reacquire(){const e=this._gen,t=!0===this._options.sysex;return this._queryPermission(t).then(s=>{if(e===this._gen)return null===s?"granted"===this._permission&&this._grantedSysex===t?this.request():void 0:"granted"===s?this.request():void this._setPermission(s)})}_queryPermission(e){const t=globalThis.navigator.permissions;return t&&"function"==typeof t.query?t.query({name:"midi",sysex:e}).then(e=>e.state,()=>null):Promise.resolve(null)}_resolveApi(){const e=globalThis.navigator;return e&&"function"==typeof e.requestMIDIAccess?t=>e.requestMIDIAccess(t):null}_messageOf(e){return"string"==typeof e?.message&&""!==e.message?e.message:"MIDI error"}_probePermission(){if(this._permissionStatus)return;const e=globalThis.navigator.permissions;if(!e||"function"!=typeof e.query)return;const t=this._gen;e.query({name:"midi",sysex:!0===this._options.sysex}).then(e=>{t===this._gen&&(this._permissionStatus=e,this._setPermission(e.state),e.addEventListener("change",this._onPermissionChange))},()=>{})}_onPermissionChange=e=>{this._setPermission(e.target.state)};_matches(e,t){if(e.id===t)return!0;return(e.name??"").toLowerCase().startsWith(t.toLowerCase())}_selectedInputs(e){const t=[...e.inputs.values()],s=this._options.input;return null==s||""===s?t:t.filter(e=>this._matches(e,s))}_resolveOutput(){if(!this._access)return null;const e=[...this._access.outputs.values()],t=this._options.output;return null==t||""===t?e[0]??null:e.find(e=>this._matches(e,t))??null}_hookInputs(e){const t=new Set(this._selectedInputs(e));for(const e of this._hookedInputs)t.has(e)||(e.onmidimessage=null,this._hookedInputs.delete(e));for(const e of t)this._hookedInputs.has(e)||(e.onmidimessage=this._onMidiMessage,this._hookedInputs.add(e))}_unhookInputs(){for(const e of this._hookedInputs)e.onmidimessage=null;this._hookedInputs.clear()}_onStateChange=()=>{const e=this._access;this._hookInputs(e),this._publishDevices(e)};_onMidiMessage=e=>{const t=e.data;if(!t)return;const s=function(e){const t=e[0];if("number"!=typeof t)return a;const s="number"==typeof e[1]?e[1]:0,n="number"==typeof e[2]?e[2]:0;if(t>=240)return{...a,type:240===t?"sysex":"other"};if(t<128)return a;const i=1+(15&t);switch(240&t){case 128:return{type:"noteoff",channel:i,note:s,velocity:n/127,control:null,value:null};case 144:return n>0?{type:"noteon",channel:i,note:s,velocity:n/127,control:null,value:null}:{type:"noteoff",channel:i,note:s,velocity:0,control:null,value:null};case 160:return{type:"polyaftertouch",channel:i,note:s,velocity:null,control:null,value:n};case 176:return{type:"controlchange",channel:i,note:null,velocity:null,control:s,value:n};case 192:return{type:"programchange",channel:i,note:null,velocity:null,control:null,value:s};case 208:return{type:"aftertouch",channel:i,note:null,velocity:null,control:null,value:s};default:return{type:"pitchbend",channel:i,note:null,velocity:null,control:null,value:((n<<7|s)-8192)/8192}}}(t),n=this._options.channel;if(null!=n&&null!==s.channel&&s.channel!==n)return;const i=e.target;this._publishMessage({...s,data:new Uint8Array(t),port:i?.id??"",portName:i?.name??"",timestamp:e.timeStamp??0})};_publishMessage(e){this._message=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:message",{detail:e,bubbles:!0}))}_publishDevices(e){this._setDevices(this._snapshotDevices(e))}_setDevices(e){this._sameDevices(e)||(this._devices=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:devices",{detail:e,bubbles:!0})))}_snapshotDevices(e){const t=(e,t)=>[...e.values()].map(e=>({id:e.id,name:e.name??"",manufacturer:e.manufacturer??"",direction:t,state:"connected"===e.state?"connected":"disconnected"}));return[...t(e.inputs,"input"),...t(e.outputs,"output")]}_sameDevices(e){return e.length===this._devices.length&&e.every((e,t)=>{const s=this._devices[t];return s.id===e.id&&s.state===e.state&&s.direction===e.direction&&s.name===e.name})}_setConnected(e){this._connected!==e&&(this._connected=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:statechange",{detail:e,bubbles:!0})))}_setPermission(e){this._permission!==e&&(this._permission=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:permission",{detail:e,bubbles:!0})))}_setError(e,t){this._error!==e&&(this._error=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:error",{detail:e,bubbles:!0}))),this._commitErrorInfo(null===e?null:function(e,t){return"unsupported"===e?{code:n,phase:"probe",recoverable:!1,message:t}:"send"===e?{code:o,phase:"execute",recoverable:!0,message:t}:"SecurityError"===e||"NotAllowedError"===e?{code:i,phase:"start",recoverable:!1,message:t}:{code:r,phase:"start",recoverable:!0,message:t}}(t,e))}_commitErrorInfo(e){null===this._errorInfo&&null===e||(this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-midi:error-info-changed",{detail:e,bubbles:!0})))}}function d(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const _=new WeakSet;function m(e,t,s){if(_.has(e))return;_.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const p=new WeakMap;function g(e,t){let s=p.get(e);return void 0===s&&(s=new Map,p.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function v(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function f(e,t,s){const n=g(e,t);v(e,t,void 0===s?n:null===s?null:String(s))}function y(e,t,s){const n=g(e,t);v(e,t,void 0===s?n:s?"":null)}class b extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["input","output","channel"];static wcBindable={...h.wcBindable,inputs:[{name:"input",attribute:"input"},{name:"output",attribute:"output"},{name:"channel",attribute:"channel"},{name:"sysex",attribute:"sysex"},{name:"auto",attribute:"auto"}]};_core;_connectedCallbackPromise=Promise.resolve();_connectResolve=null;_requestPending=!1;_autoCancelled=!1;_internals=null;constructor(){super(),this._core=new h(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-midi:permission":e=>({granted:"granted"===e,denied:"denied"===e,unsupported:"unsupported"===e}),"wcs-midi:statechange":e=>({connected:!0===e}),"wcs-midi:error":e=>({error:null!==e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get input(){return this.getAttribute("input")??""}set input(e){f(this,"input",e)}get output(){return this.getAttribute("output")??""}set output(e){f(this,"output",e)}get channel(){const e=this.getAttribute("channel");if(null===e)return null;const t=Number(e);return Number.isFinite(t)?t:null}set channel(e){f(this,"channel",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){y(this,"sysex",e)}get auto(){return this.hasAttribute("auto")}set auto(e){y(this,"auto",e)}get message(){return this._core.message}get type(){return this._core.type}get note(){return this._core.note}get velocity(){return this._core.velocity}get control(){return this._core.control}get value(){return this._core.value}get devices(){return this._core.devices}get connected(){return this._core.connected}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get core(){return this._core}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.setOptions(this._options()),this._core.request()}close(){null!==this._connectResolve&&(this._autoCancelled=!0),this._core.close()}send(e,t){this._core.send(e,t)}_options(){return{input:this.input,output:this.output,channel:this.channel,sysex:this.sysex,auto:this.auto}}_scheduleRequest(){this._requestPending||(this._requestPending=!0,queueMicrotask(()=>{this._requestPending=!1;const e=this._connectResolve;if(this._connectResolve=null,null===e)return;const t=this._options();this._autoCancelled&&(t.auto=!1),this._autoCancelled=!1,e(this._core.observe(t))}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&m(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!d(e,s))continue;const r=e,o=r[s];delete r[s],r[s]=o}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleRequest()}disconnectedCallback(){this._connectResolve?.(),this._connectResolve=null,this._autoCancelled=!1,this._core.dispose()}attributeChangedCallback(e,t,s){t!==s&&this.isConnected&&this._core.setOptions(this._options())}}const w=Symbol.for("wcstack.package"),I=new WeakSet;function C(e,t){Object.defineProperty(e,w,{value:t,configurable:!0})}function P(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[w];if(r===i||I.has(e))return;I.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function k(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(C(i,t),e.define(n,i)):P(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.midi,b]])}var E;k(E);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/midiCapabilities.ts","../../src/midi/parseMessage.ts","../../src/core/MidiCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Midi.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMidi.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n midi: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n midi: \"wcs-midi\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapMidi` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/midi] bootstrapMidi: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * midiCapabilities.ts\n *\n * Web MIDI 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)\n * から import する。\n *\n * この node の失敗は 2 箇所からしか来ない:\n * 1. `requestMIDIAccess()` の rejection — 権限拒否・API 不在・sysex 拒否。\n * 2. `MIDIOutput.send()` の throw — 不正なメッセージ・切断済みポート。\n * `_setError` は screen-orientation と同じ discriminator 技法で、synthetic な\n * `\"unsupported\"` / `\"send\"` ヒントと caught された `Error.name` を弁別する\n * (message の文言に依存した分岐を作らない)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した midi error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MIDI_ERROR_CODE = {\n /** `navigator.requestMIDIAccess` 自体が不在(synthetic \"unsupported\")。 */\n CapabilityMissing: \"capability-missing\",\n /**\n * `SecurityError` / `NotAllowedError` — ユーザーが拒否した、あるいは\n * permissions policy / 非 secure context で許可されない。retry では回復しない。\n */\n NotAllowed: \"not-allowed\",\n /** その他の `requestMIDIAccess()` 失敗。fresh な request は成功しうる。 */\n AccessError: \"access-error\",\n /** `MIDIOutput.send()` の失敗(不正なメッセージ / 切断済みポート)。 */\n SendFailed: \"send-failed\",\n} as const;\n\n/**\n * Web MIDI の失敗を serializable な error taxonomy に写す。\n *\n * `name` は呼び出し側が渡す discriminator:\n * - `\"unsupported\"` — API 不在 → phase=\"probe\" / capability-missing。\n * - `\"send\"` — 送信失敗 → phase=\"execute\" / send-failed。recoverable(ポートが\n * 戻れば成功しうる)。\n * - `SecurityError` / `NotAllowedError` — 拒否 → phase=\"start\" / not-allowed。\n * - それ以外(`AbortError`、生の throw、`.name` 欠如等) → phase=\"start\" /\n * access-error。\n */\nexport function deriveMidiErrorInfo(name: string | undefined, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MIDI_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"send\") {\n return { code: WCS_MIDI_ERROR_CODE.SendFailed, phase: \"execute\", recoverable: true, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MIDI_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n return { code: WCS_MIDI_ERROR_CODE.AccessError, phase: \"start\", recoverable: true, message };\n}\n","import { IMidiParsed, MidiMessageType } from \"../types.js\";\n\n// Channel voice message commands (high nibble of the status byte).\nconst NOTE_OFF = 0x80;\nconst NOTE_ON = 0x90;\nconst POLY_AFTERTOUCH = 0xa0;\nconst CONTROL_CHANGE = 0xb0;\nconst PROGRAM_CHANGE = 0xc0;\nconst AFTERTOUCH = 0xd0;\nconst SYSTEM = 0xf0;\n\nconst SYSEX_START = 0xf0;\n\nconst EMPTY: IMidiParsed = {\n type: \"other\", channel: null, note: null, velocity: null, control: null, value: null,\n};\n\n/**\n * Decode a raw MIDI message into the fields bindings actually want.\n *\n * Two normalizations are deliberate, because every consumer would otherwise\n * repeat them:\n *\n * - **A note-on with velocity 0 is reported as `\"noteoff\"`.** Many controllers\n * send running-status note-ons and never emit 0x8n at all; treating them as\n * note-ons leaves stuck notes. The raw status byte is still available in\n * `data[0]` for callers that care.\n * - **Velocity is normalized to 0-1**, so it multiplies straight into a gain\n * without the caller knowing about the 7-bit MIDI range. Controller values\n * stay raw 0-127 (`value`), since their meaning is per-controller.\n *\n * Never throws: a truncated or nonsensical buffer decodes to `type: \"other\"`\n * with every field `null` (async-io-node-guidelines.md §3.6).\n */\nexport function parseMessage(data: Uint8Array | number[]): IMidiParsed {\n const status = data[0];\n if (typeof status !== \"number\") return EMPTY;\n\n const d1 = typeof data[1] === \"number\" ? data[1] : 0;\n const d2 = typeof data[2] === \"number\" ? data[2] : 0;\n\n // System messages (0xF0-0xFF) carry no channel nibble.\n if (status >= SYSTEM) {\n return { ...EMPTY, type: status === SYSEX_START ? \"sysex\" : \"other\" };\n }\n // Below 0x80 is a data byte, not a status byte: the buffer is malformed or\n // running-status (which the Web MIDI API already expands for us).\n if (status < NOTE_OFF) return EMPTY;\n\n const command = status & 0xf0;\n const channel = (status & 0x0f) + 1;\n\n switch (command) {\n case NOTE_OFF:\n return { type: \"noteoff\", channel, note: d1, velocity: d2 / 127, control: null, value: null };\n case NOTE_ON:\n // velocity 0 == note off (see doc comment).\n return d2 > 0\n ? { type: \"noteon\", channel, note: d1, velocity: d2 / 127, control: null, value: null }\n : { type: \"noteoff\", channel, note: d1, velocity: 0, control: null, value: null };\n case POLY_AFTERTOUCH:\n return { type: \"polyaftertouch\", channel, note: d1, velocity: null, control: null, value: d2 };\n case CONTROL_CHANGE:\n return { type: \"controlchange\", channel, note: null, velocity: null, control: d1, value: d2 };\n case PROGRAM_CHANGE:\n return { type: \"programchange\", channel, note: null, velocity: null, control: null, value: d1 };\n case AFTERTOUCH:\n return { type: \"aftertouch\", channel, note: null, velocity: null, control: null, value: d1 };\n default:\n // 0xE0 pitch bend — the only high nibble left between 0x80 and 0xEF once\n // the six cases above are taken. 14-bit little-endian, centered at 8192,\n // normalized to -1..1.\n return {\n type: \"pitchbend\", channel, note: null, velocity: null, control: null,\n value: (((d2 << 7) | d1) - 8192) / 8192,\n };\n }\n}\n\n/** Message kinds a caller may want to filter on, exported for tooling. */\nexport const MIDI_MESSAGE_TYPES: readonly MidiMessageType[] = [\n \"noteon\", \"noteoff\", \"polyaftertouch\", \"controlchange\",\n \"programchange\", \"aftertouch\", \"pitchbend\", \"sysex\", \"other\",\n];\n","import {\n IMidiDevice, IMidiMessage, IMidiOptions, IWcBindable, MidiMessageType,\n MidiPermissionState,\n} from \"../types.js\";\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMidiErrorInfo } from \"./midiCapabilities.js\";\nimport { parseMessage } from \"../midi/parseMessage.js\";\n\nconst UNSUPPORTED = \"unsupported\";\n\n// Minimal structural types for the Web MIDI API. The DOM lib does not ship them\n// in every TypeScript configuration, and structural types keep the Core testable\n// against a fake without casting through `any` at each use site.\ninterface MidiPortLike extends EventTarget {\n id: string;\n name?: string | null;\n manufacturer?: string | null;\n state: string;\n type?: string;\n}\ninterface MidiInputLike extends MidiPortLike {\n onmidimessage: ((event: any) => void) | null;\n}\ninterface MidiOutputLike extends MidiPortLike {\n send(data: number[] | Uint8Array, timestamp?: number): void;\n}\ninterface MidiAccessLike {\n inputs: Map<string, MidiInputLike>;\n outputs: Map<string, MidiOutputLike>;\n onstatechange: ((event: any) => void) | null;\n sysexEnabled?: boolean;\n}\n\nconst detailOf = (event: Event): any => (event as CustomEvent).detail;\nconst messageField = <K extends keyof IMidiMessage>(key: K) =>\n (event: Event): IMidiMessage[K] | null => detailOf(event)?.[key] ?? null;\n\n/**\n * Headless Web MIDI primitive: a framework-agnostic wrapper around\n * `navigator.requestMIDIAccess()` exposed through the wc-bindable protocol.\n *\n * Direction is genuinely two-way, unlike `@wcstack/permission` (monitor only):\n * incoming messages flow element → state as `event`-semantics occurrences, and\n * `send()` is a command going the other way. Both live on one node because a\n * page holds exactly one `MIDIAccess` — splitting input and output into two tags\n * would only force them to coordinate over the same shared handle.\n *\n * Nothing starts on construction. `requestMIDIAccess()` can raise a permission\n * prompt, so it is deliberately command-driven (`request()`), matching the\n * `idle` / Generic Sensor family. `observe({ auto: true })` opts back into\n * requesting immediately.\n *\n * The `MIDIAccess` handle itself is never published: the Core owns it and drops\n * it in `close()` / `dispose()`, as `worker` / `websocket` / `broadcast` do with\n * theirs. Only values cross the protocol boundary.\n */\nexport class MidiCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n // One occurrence event, decomposed into derived getters\n // (async-io-node-guidelines.md §4.2). Never same-value guarded: two\n // identical note-ons are two distinct presses.\n { name: \"message\", event: \"wcs-midi:message\", semantics: \"event\" },\n { name: \"type\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"type\") },\n { name: \"channel\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"channel\") },\n { name: \"note\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"note\") },\n { name: \"velocity\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"velocity\") },\n { name: \"control\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"control\") },\n { name: \"value\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"value\") },\n { name: \"devices\", event: \"wcs-midi:devices\", semantics: \"state\" },\n { name: \"connected\", event: \"wcs-midi:statechange\", semantics: \"state\" },\n { name: \"permission\", event: \"wcs-midi:permission\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === \"granted\" },\n { name: \"denied\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === \"denied\" },\n { name: \"unsupported\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === UNSUPPORTED },\n { name: \"error\", event: \"wcs-midi:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-midi:error-info-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"close\" },\n { name: \"send\" },\n ],\n };\n\n private _target: EventTarget;\n private _options: IMidiOptions = {};\n\n private _access: MidiAccessLike | null = null;\n private _hookedInputs = new Set<MidiInputLike>();\n\n private _message: IMidiMessage | null = null;\n private _devices: IMidiDevice[] = [];\n private _connected = false;\n private _permission: MidiPermissionState = \"prompt\";\n private _error: string | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n private _permissionStatus: PermissionStatus | null = null;\n\n // Monotonic id bumped by every request(), close() and dispose(). An in-flight\n // requestMIDIAccess() captures it and bails on resolve when superseded, so a\n // rapid disconnect→reconnect (or a close() mid-flight) never hooks listeners\n // onto a torn-down instance.\n private _gen = 0;\n\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(options?: IMidiOptions | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n if (options) this._options = { ...options };\n }\n\n // --- Observable getters ---\n\n get message(): IMidiMessage | null { return this._message; }\n get type(): MidiMessageType | null { return this._message?.type ?? null; }\n get channel(): number | null { return this._message?.channel ?? null; }\n get note(): number | null { return this._message?.note ?? null; }\n get velocity(): number | null { return this._message?.velocity ?? null; }\n get control(): number | null { return this._message?.control ?? null; }\n get value(): number | null { return this._message?.value ?? null; }\n\n get devices(): IMidiDevice[] { return this._devices; }\n get connected(): boolean { return this._connected; }\n get permission(): MidiPermissionState { return this._permission; }\n get granted(): boolean { return this._permission === \"granted\"; }\n get denied(): boolean { return this._permission === \"denied\"; }\n get unsupported(): boolean { return this._permission === UNSUPPORTED; }\n get error(): string | null { return this._error; }\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n\n /** Resolves once the current (or initial) access attempt settles. */\n get ready(): Promise<void> { return this._ready; }\n\n // --- Public API ---\n\n /**\n * Store the options and, when `auto` is set, request access. Idempotent:\n * calling it again with new options re-applies port selection to the live\n * access without re-requesting.\n */\n observe(options: IMidiOptions): Promise<void> {\n const wasIdle = this._access === null;\n this.setOptions(options);\n if (options.auto && wasIdle) {\n this._ready = this.request();\n }\n return this._ready;\n }\n\n /**\n * Re-apply port selection / channel filtering. Cheap and safe at any time —\n * with no access held it only records the options for a later `request()`.\n */\n setOptions(options: IMidiOptions): void {\n this._options = { ...this._options, ...options };\n if (this._access) this._hookInputs(this._access);\n }\n\n /**\n * Acquire MIDI access. Never rejects: a refusal or a missing API surfaces as\n * `permission` / `error` state (async-io-node-guidelines.md §3.6).\n */\n request(): Promise<void> {\n const requestAccess = this._resolveApi();\n if (!requestAccess) {\n this._setPermission(UNSUPPORTED);\n this._setError(UNSUPPORTED, UNSUPPORTED);\n this._ready = Promise.resolve();\n return this._ready;\n }\n const gen = ++this._gen;\n this._probePermission();\n this._ready = requestAccess({ sysex: this._options.sysex === true }).then(\n (access: MidiAccessLike) => {\n if (gen !== this._gen) return;\n this._access = access;\n access.onstatechange = this._onStateChange;\n this._setError(null);\n this._setPermission(\"granted\");\n this._hookInputs(access);\n this._publishDevices(access);\n this._setConnected(true);\n },\n (error: any) => {\n if (gen !== this._gen) return;\n this._setPermission(\"denied\");\n this._setError(this._messageOf(error), error?.name);\n },\n );\n return this._ready;\n }\n\n /**\n * Release the access handle and detach every listener, keeping the observed\n * permission state. A later `request()` re-acquires.\n */\n close(): void {\n this._gen++;\n this._unhookInputs();\n if (this._access) {\n this._access.onstatechange = null;\n this._access = null;\n }\n this._setConnected(false);\n }\n\n /**\n * Send a raw MIDI message to the selected output port (or the first available\n * one). No-op when no output is reachable; a failing `send()` surfaces on\n * `error` rather than throwing.\n *\n * Positional arguments pass through verbatim from command-token\n * (docs/spec-proposal-command-token-arguments.md).\n */\n send(data: number[] | Uint8Array, timestamp?: number): void {\n const port = this._resolveOutput();\n if (!port) return;\n try {\n port.send(data, timestamp);\n } catch (error: any) {\n this._setError(this._messageOf(error), \"send\");\n }\n }\n\n /**\n * Detach everything. Headless callers own this lifecycle themselves: without\n * it the live `onmidimessage` handlers keep this instance reachable for as\n * long as the ports are alive.\n */\n dispose(): void {\n this.close();\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal: API resolution ---\n\n // Resolved at call time, never cached: keeps the unsupported branch honest and\n // lets tests swap the global (async-io-node-guidelines.md §3.7). Read off\n // globalThis rather than the bare identifier so an SSR/worker context with no\n // navigator at all takes the same \"unsupported\" path as Safari.\n private _resolveApi(): ((options: { sysex: boolean }) => Promise<MidiAccessLike>) | null {\n const nav = (globalThis as { navigator?: any }).navigator;\n if (!nav || typeof nav.requestMIDIAccess !== \"function\") return null;\n return (options) => nav.requestMIDIAccess(options);\n }\n\n private _messageOf(error: any): string {\n return typeof error?.message === \"string\" && error.message !== \"\" ? error.message : \"MIDI error\";\n }\n\n // --- Internal: permission monitoring ---\n\n // Optional extra: browsers that answer query({name:\"midi\"}) let a grant flipped\n // in site settings flow into the declarative state without a re-request. Where\n // the descriptor is rejected we simply keep inferring from request() outcomes.\n private _probePermission(): void {\n if (this._permissionStatus) return;\n // Only ever reached after _resolveApi() found navigator.requestMIDIAccess,\n // so navigator itself is known to exist here.\n const permissions = (globalThis as { navigator?: any }).navigator.permissions;\n if (!permissions || typeof permissions.query !== \"function\") return;\n const gen = this._gen;\n permissions.query({ name: \"midi\", sysex: this._options.sysex === true }).then(\n (status: PermissionStatus) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as MidiPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => { /* descriptor not understood — request() outcomes remain the source */ },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n this._setPermission((event.target as PermissionStatus).state as MidiPermissionState);\n };\n\n // --- Internal: ports ---\n\n private _matches(port: MidiPortLike, selector: string): boolean {\n if (port.id === selector) return true;\n const name = port.name ?? \"\";\n return name.toLowerCase().startsWith(selector.toLowerCase());\n }\n\n // Takes the access explicitly rather than reading the field: every call site\n // already holds a non-null handle, and a defensive re-check here would be a\n // branch no test could ever reach.\n private _selectedInputs(access: MidiAccessLike): MidiInputLike[] {\n const all = [...access.inputs.values()];\n const selector = this._options.input;\n // No selector means \"whatever is plugged in\" — the expectation for MIDI is\n // that a controller just works, not that the page names it first.\n if (selector === undefined || selector === null || selector === \"\") return all;\n return all.filter((port) => this._matches(port, selector));\n }\n\n private _resolveOutput(): MidiOutputLike | null {\n if (!this._access) return null;\n const all = [...this._access.outputs.values()];\n const selector = this._options.output;\n if (selector === undefined || selector === null || selector === \"\") return all[0] ?? null;\n return all.find((port) => this._matches(port, selector)) ?? null;\n }\n\n private _hookInputs(access: MidiAccessLike): void {\n const wanted = new Set(this._selectedInputs(access));\n for (const port of this._hookedInputs) {\n if (!wanted.has(port)) {\n port.onmidimessage = null;\n this._hookedInputs.delete(port);\n }\n }\n for (const port of wanted) {\n if (this._hookedInputs.has(port)) continue;\n port.onmidimessage = this._onMidiMessage;\n this._hookedInputs.add(port);\n }\n }\n\n private _unhookInputs(): void {\n for (const port of this._hookedInputs) port.onmidimessage = null;\n this._hookedInputs.clear();\n }\n\n private _onStateChange = (): void => {\n // Port list changed: re-apply selection (a newly plugged input must start\n // delivering) and republish. `onstatechange` is only installed while an\n // access is held and cleared in close(), so the handle is non-null here.\n const access = this._access!;\n this._hookInputs(access);\n this._publishDevices(access);\n };\n\n private _onMidiMessage = (event: { data?: Uint8Array | null; target?: any; timeStamp?: number }): void => {\n const raw = event.data;\n if (!raw) return;\n const parsed = parseMessage(raw);\n const channelFilter = this._options.channel;\n if (channelFilter != null && parsed.channel !== null && parsed.channel !== channelFilter) return;\n const port = event.target as MidiPortLike | undefined;\n this._publishMessage({\n ...parsed,\n // Fresh copy every time: the platform buffer must never be handed out\n // (producer snapshot contract).\n data: new Uint8Array(raw),\n port: port?.id ?? \"\",\n portName: port?.name ?? \"\",\n timestamp: event.timeStamp ?? 0,\n });\n };\n\n // --- Internal: state setters ---\n\n // Occurrence, not state: identical payloads are distinct presses, so there is\n // deliberately no same-value guard here.\n private _publishMessage(message: IMidiMessage): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:message\", { detail: message, bubbles: true }));\n }\n\n private _publishDevices(access: MidiAccessLike): void {\n const next = this._snapshotDevices(access);\n if (this._sameDevices(next)) return;\n // Fresh array assigned before notifying (producer snapshot contract).\n this._devices = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:devices\", { detail: next, bubbles: true }));\n }\n\n private _snapshotDevices(access: MidiAccessLike): IMidiDevice[] {\n const collect = (ports: Map<string, MidiPortLike>, direction: \"input\" | \"output\"): IMidiDevice[] =>\n [...ports.values()].map((port) => ({\n id: port.id,\n name: port.name ?? \"\",\n manufacturer: port.manufacturer ?? \"\",\n direction,\n state: port.state === \"connected\" ? \"connected\" : \"disconnected\",\n }));\n return [\n ...collect(access.inputs as Map<string, MidiPortLike>, \"input\"),\n ...collect(access.outputs as Map<string, MidiPortLike>, \"output\"),\n ];\n }\n\n // Content comparison, not reference: statechange fires separately for the\n // input and the output side of one physical device, so an unfiltered\n // republish would double-notify on every plug.\n private _sameDevices(next: IMidiDevice[]): boolean {\n if (next.length !== this._devices.length) return false;\n return next.every((device, i) => {\n const prev = this._devices[i];\n return prev.id === device.id && prev.state === device.state\n && prev.direction === device.direction && prev.name === device.name;\n });\n }\n\n private _setConnected(connected: boolean): void {\n if (this._connected === connected) return;\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:statechange\", { detail: connected, bubbles: true }));\n }\n\n private _setPermission(permission: MidiPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:permission\", { detail: permission, bubbles: true }));\n }\n\n private _setError(error: string | null, name?: string): void {\n if (this._error !== error) {\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:error\", { detail: error, bubbles: true }));\n }\n this._commitErrorInfo(error === null ? null : deriveMidiErrorInfo(name, error));\n }\n\n // errorInfo transitions exactly when error does (no independent same-value\n // guard: a fresh object is built per transition).\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n if (this._errorInfo === null && info === null) return;\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:error-info-changed\", { detail: info, bubbles: true }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import {\n IMidiDevice, IMidiMessage, IMidiOptions, IWcBindable, MidiMessageType,\n MidiPermissionState, WcsIoErrorInfo,\n} from \"../types.js\";\nimport { MidiCore } from \"../core/MidiCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-midi>` — declarative Web MIDI input/output.\n *\n * Nothing happens on connect: `requestMIDIAccess()` can raise a permission\n * prompt, so access is command-driven (`command.request`). Add the `auto`\n * attribute to opt into requesting as soon as the element connects.\n */\nexport class WcsMidi extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static observedAttributes = [\"input\", \"output\", \"channel\"];\n\n static wcBindable: IWcBindable = {\n ...MidiCore.wcBindable,\n inputs: [\n { name: \"input\", attribute: \"input\" },\n { name: \"output\", attribute: \"output\" },\n { name: \"channel\", attribute: \"channel\" },\n { name: \"sysex\", attribute: \"sysex\" },\n { name: \"auto\", attribute: \"auto\" },\n ],\n };\n\n private _core: MidiCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // connectedCallback が張った connectedCallbackPromise を解く関数。接続時の判断を下す\n // _scheduleRequest のマイクロタスクが(その前に外れたときは disconnectedCallback が)呼ぶ。\n private _connectResolve: ((value: void | PromiseLike<void>) => void) | null = null;\n // _scheduleRequest のマイクロタスクが待っている間 true\n private _requestPending: boolean = false;\n // 接続時の判断待ちに close() が呼ばれたら true — その判断は auto でも要求しない\n private _autoCancelled: boolean = false;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MidiCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-midi:permission\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n unsupported: d === \"unsupported\",\n }),\n \"wcs-midi:statechange\": (d) => ({ connected: d === true }),\n \"wcs-midi:error\": (d) => ({ error: d !== null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects non-dashed\n // state names. Either case silently disables reflection.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" input / output would select a port named \"undefined\", i.e. none),\n // and the booleans do not use toggleAttribute (an `undefined` force flips the\n // attribute): `null` removes the attribute (the default — every port, every\n // channel, off), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not).\n\n get input(): string { return this.getAttribute(\"input\") ?? \"\"; }\n set input(value: string | null | undefined) { reflectAttribute(this, \"input\", value); }\n\n get output(): string { return this.getAttribute(\"output\") ?? \"\"; }\n set output(value: string | null | undefined) { reflectAttribute(this, \"output\", value); }\n\n get channel(): number | null {\n const raw = this.getAttribute(\"channel\");\n if (raw === null) return null;\n const n = Number(raw);\n return Number.isFinite(n) ? n : null;\n }\n\n set channel(value: number | null | undefined) {\n reflectAttribute(this, \"channel\", value);\n }\n\n get sysex(): boolean { return this.hasAttribute(\"sysex\"); }\n set sysex(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"sysex\", value); }\n\n get auto(): boolean { return this.hasAttribute(\"auto\"); }\n set auto(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"auto\", value); }\n\n // --- Core delegated getters ---\n\n get message(): IMidiMessage | null { return this._core.message; }\n get type(): MidiMessageType | null { return this._core.type; }\n get note(): number | null { return this._core.note; }\n get velocity(): number | null { return this._core.velocity; }\n get control(): number | null { return this._core.control; }\n get value(): number | null { return this._core.value; }\n get devices(): IMidiDevice[] { return this._core.devices; }\n get connected(): boolean { return this._core.connected; }\n get permission(): MidiPermissionState { return this._core.permission; }\n get granted(): boolean { return this._core.granted; }\n get denied(): boolean { return this._core.denied; }\n get unsupported(): boolean { return this._core.unsupported; }\n get error(): string | null { return this._core.error; }\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n /** Headless escape hatch: the Core backing this element. */\n get core(): MidiCore { return this._core; }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<void> {\n // 要求の sysex は属性が正本。接続時の判断(マイクロタスク)が Core へ渡すより先の\n // request() でも、接続の後に sysex が変わった後でも、いまの属性で要求するよう渡しておく\n this._core.setOptions(this._options());\n return this._core.request();\n }\n\n close(): void {\n // 接続時の判断待ちなら、その auto の要求を取り消す — 同じタスクの append → close() で、\n // 後のマイクロタスクが要求しないように(判断が同期だった頃は、始めた要求を close() が\n // 捨てていた)。入れ直せば、次の判断は auto に従う\n if (this._connectResolve !== null) this._autoCancelled = true;\n this._core.close();\n }\n send(data: number[] | Uint8Array, timestamp?: number): void { this._core.send(data, timestamp); }\n\n // --- Internal ---\n\n private _options(): IMidiOptions {\n return {\n input: this.input,\n output: this.output,\n channel: this.channel,\n sysex: this.sysex,\n auto: this.auto,\n };\n }\n\n // --- Lifecycle ---\n\n // 接続時の要求の判断はマイクロタスクで、そのときの auto / sysex(と input / output /\n // channel)で 1 回だけ行う(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が入力を書くのはマイクロタスク — その場で\n // 判断すると、前の auto / sysex で requestMIDIAccess を起こしていた(docs/seam-apps.md、\n // shift-desk)。\n private _scheduleRequest(): void {\n if (this._requestPending) return;\n this._requestPending = true;\n queueMicrotask(() => {\n this._requestPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n // 判断の前に外れた要素は何もしない(disconnectedCallback が解いて null にした)\n if (resolveConnect === null) return;\n const options = this._options();\n // 判断待ちに close() が呼ばれていたら、auto でも要求しない\n if (this._autoCancelled) options.auto = false;\n this._autoCancelled = false;\n resolveConnect(this._core.observe(options));\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // connectedCallbackPromise は接続時の判断(auto なら要求の結果)が済むまでを表す。\n // 判断はマイクロタスクなので、ここで張って _scheduleRequest で解く\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleRequest();\n }\n\n disconnectedCallback(): void {\n // 判断の前に外れたら、張った connectedCallbackPromise をここで解く — 同じタスクで\n // 入れ直されると次の connectedCallback が張り替えるので、待つ側が取り残されないように\n this._connectResolve?.();\n this._connectResolve = null;\n this._autoCancelled = false;\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Port selection and channel filtering are live: they re-hook the existing\n // access rather than re-requesting it (no second permission prompt). They only\n // record the options and re-hook (no request), so they stay synchronous; the\n // connect-time decision reads them again.\n if (this.isConnected) this._core.setOptions(this._options());\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.midi, WcsMidi],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMidi(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","midi","WCS_MIDI_ERROR_CODE","EMPTY","type","channel","note","velocity","control","value","UNSUPPORTED","detailOf","event","detail","messageField","key","MidiCore","EventTarget","static","protocol","version","properties","name","semantics","getter","e","commands","async","_target","_options","_access","_hookedInputs","Set","_message","_devices","_connected","_permission","_error","_errorInfo","_permissionStatus","_gen","_ready","Promise","resolve","constructor","options","target","super","this","message","devices","connected","permission","granted","denied","unsupported","error","errorInfo","ready","observe","wasIdle","setOptions","auto","request","_hookInputs","requestAccess","_resolveApi","_setPermission","_setError","gen","_probePermission","sysex","then","access","onstatechange","_onStateChange","_publishDevices","_setConnected","_messageOf","close","_unhookInputs","send","data","timestamp","port","_resolveOutput","dispose","removeEventListener","_onPermissionChange","nav","globalThis","navigator","requestMIDIAccess","permissions","query","status","state","addEventListener","_matches","selector","id","toLowerCase","startsWith","_selectedInputs","all","inputs","values","input","filter","outputs","output","find","wanted","has","onmidimessage","delete","_onMidiMessage","add","clear","raw","parsed","d1","d2","parseMessage","channelFilter","_publishMessage","Uint8Array","portName","timeStamp","dispatchEvent","CustomEvent","bubbles","next","_snapshotDevices","_sameDevices","collect","ports","direction","map","manufacturer","length","every","device","i","prev","_commitErrorInfo","code","phase","recoverable","deriveMidiErrorInfo","info","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsMidi","HTMLElement","wcBindable","attribute","_core","_connectedCallbackPromise","_connectResolve","_requestPending","_autoCancelled","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","toStates","entries","debug","hasAttribute","on","toggleAttribute","n","Number","isFinite","core","connectedCallbackPromise","_scheduleRequest","queueMicrotask","resolveConnect","connectedCallback","declaration","call","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","attributeChangedCallback","_name","oldValue","newValue","isConnected","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,KAAM,8CCQH,MAAMC,EAEQ,qBAFRA,EAOC,cAPDA,EASE,eATFA,EAWC,cC1Bd,MAUMC,EAAqB,CACzBC,KAAM,QAASC,QAAS,KAAMC,KAAM,KAAMC,SAAU,KAAMC,QAAS,KAAMC,MAAO,MCNlF,MAAMC,EAAc,cAyBdC,EAAYC,GAAuBA,EAAsBC,OACzDC,EAA8CC,GACjDH,GAAyCD,EAASC,KAASG,IAAQ,KAqBhE,MAAOC,UAAiBC,YAC5BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CAIV,CAAEC,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,SACzD,CAAED,KAAM,OAAQV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,SACpF,CAAEQ,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,YACvF,CAAEQ,KAAM,OAAQV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,SACpF,CAAEQ,KAAM,WAAYV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,aACxF,CAAEQ,KAAM,UAAWV,MA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aC,GAAOD,EAASvB,qBAAqBwB,GAAM,OAClF,MAAMC,EAAUF,EAAqBX,GACrC,GAAIa,IAAWP,GAAOH,EAAOtH,IAAI6H,GAAW,OAC5CP,EAAOlH,IAAIyH,GACX,MAAMxN,EAAOoN,EAAIQ,MAAM,EAAGR,EAAIS,YAAY,MAC1C7E,QAAQC,KACN,IAAIjJ,2BAA8B8I,4BAC/B6E,GAAU,mBAAmB3N,kDAClBoN,2CAElB,CC5CM,SAAUU,EAAmBN,EAAkCO,0BDoDnEP,EACAJ,EACAY,GAEA,IAAK,MAAOlF,EAAKqE,KAAQa,EAAa,CACpC,MAAMP,EAAWD,EAAShF,IAAIM,QACbP,IAAbkF,GACFP,EAAaC,EAAKC,GAClBI,EAASS,OAAOnF,EAAKqE,IAErBI,EAAkBC,EAAU1E,EAAK2E,EAAUN,EAAKC,EAEpD,CACF,CChEEc,CAAeV,EAAU,GAAGJ,KAAYA,IAAe,CACrD,CAAC3O,EAAOC,SAASC,KAAMqL,IAE3B,CCVM,IAAsDwD,EAI1DM,EAAmBN"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../../src/config.ts","../../src/core/midiCapabilities.ts","../../src/midi/parseMessage.ts","../../src/core/MidiCore.ts","../../src/protocol/upgradeProperties.ts","../../src/protocol/inputAttribute.ts","../../src/components/Midi.ts","../../src/protocol/defineElement.ts","../../src/registerComponents.ts","../../src/bootstrapMidi.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n tagNames: {\n midi: string;\n };\n}\n\nconst _config: IInternalConfig = {\n tagNames: {\n midi: \"wcs-midi\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapMidi` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/midi] bootstrapMidi: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * midiCapabilities.ts\n *\n * Web MIDI 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)\n * から import する。\n *\n * この node の失敗は 2 箇所からしか来ない:\n * 1. `requestMIDIAccess()` の rejection — 権限拒否・API 不在・sysex 拒否。\n * 2. `MIDIOutput.send()` の throw — 不正なメッセージ・切断済みポート。\n * `_setError` は screen-orientation と同じ discriminator 技法で、synthetic な\n * `\"unsupported\"` / `\"send\"` ヒントと caught された `Error.name` を弁別する\n * (message の文言に依存した分岐を作らない)。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した midi error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_MIDI_ERROR_CODE = {\n /** `navigator.requestMIDIAccess` 自体が不在(synthetic \"unsupported\")。 */\n CapabilityMissing: \"capability-missing\",\n /**\n * `SecurityError` / `NotAllowedError` — ユーザーが拒否した、あるいは\n * permissions policy / 非 secure context で許可されない。retry では回復しない。\n */\n NotAllowed: \"not-allowed\",\n /** その他の `requestMIDIAccess()` 失敗。fresh な request は成功しうる。 */\n AccessError: \"access-error\",\n /** `MIDIOutput.send()` の失敗(不正なメッセージ / 切断済みポート)。 */\n SendFailed: \"send-failed\",\n} as const;\n\n/**\n * Web MIDI の失敗を serializable な error taxonomy に写す。\n *\n * `name` は呼び出し側が渡す discriminator:\n * - `\"unsupported\"` — API 不在 → phase=\"probe\" / capability-missing。\n * - `\"send\"` — 送信失敗 → phase=\"execute\" / send-failed。recoverable(ポートが\n * 戻れば成功しうる)。\n * - `SecurityError` / `NotAllowedError` — 拒否 → phase=\"start\" / not-allowed。\n * - それ以外(`AbortError`、生の throw、`.name` 欠如等) → phase=\"start\" /\n * access-error。\n */\nexport function deriveMidiErrorInfo(name: string | undefined, message: string): WcsIoErrorInfo {\n if (name === \"unsupported\") {\n return { code: WCS_MIDI_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n }\n if (name === \"send\") {\n return { code: WCS_MIDI_ERROR_CODE.SendFailed, phase: \"execute\", recoverable: true, message };\n }\n if (name === \"SecurityError\" || name === \"NotAllowedError\") {\n return { code: WCS_MIDI_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n }\n return { code: WCS_MIDI_ERROR_CODE.AccessError, phase: \"start\", recoverable: true, message };\n}\n","import { IMidiParsed, MidiMessageType } from \"../types.js\";\n\n// Channel voice message commands (high nibble of the status byte).\nconst NOTE_OFF = 0x80;\nconst NOTE_ON = 0x90;\nconst POLY_AFTERTOUCH = 0xa0;\nconst CONTROL_CHANGE = 0xb0;\nconst PROGRAM_CHANGE = 0xc0;\nconst AFTERTOUCH = 0xd0;\nconst SYSTEM = 0xf0;\n\nconst SYSEX_START = 0xf0;\n\nconst EMPTY: IMidiParsed = {\n type: \"other\", channel: null, note: null, velocity: null, control: null, value: null,\n};\n\n/**\n * Decode a raw MIDI message into the fields bindings actually want.\n *\n * Two normalizations are deliberate, because every consumer would otherwise\n * repeat them:\n *\n * - **A note-on with velocity 0 is reported as `\"noteoff\"`.** Many controllers\n * send running-status note-ons and never emit 0x8n at all; treating them as\n * note-ons leaves stuck notes. The raw status byte is still available in\n * `data[0]` for callers that care.\n * - **Velocity is normalized to 0-1**, so it multiplies straight into a gain\n * without the caller knowing about the 7-bit MIDI range. Controller values\n * stay raw 0-127 (`value`), since their meaning is per-controller.\n *\n * Never throws: a truncated or nonsensical buffer decodes to `type: \"other\"`\n * with every field `null` (async-io-node-guidelines.md §3.6).\n */\nexport function parseMessage(data: Uint8Array | number[]): IMidiParsed {\n const status = data[0];\n if (typeof status !== \"number\") return EMPTY;\n\n const d1 = typeof data[1] === \"number\" ? data[1] : 0;\n const d2 = typeof data[2] === \"number\" ? data[2] : 0;\n\n // System messages (0xF0-0xFF) carry no channel nibble.\n if (status >= SYSTEM) {\n return { ...EMPTY, type: status === SYSEX_START ? \"sysex\" : \"other\" };\n }\n // Below 0x80 is a data byte, not a status byte: the buffer is malformed or\n // running-status (which the Web MIDI API already expands for us).\n if (status < NOTE_OFF) return EMPTY;\n\n const command = status & 0xf0;\n const channel = (status & 0x0f) + 1;\n\n switch (command) {\n case NOTE_OFF:\n return { type: \"noteoff\", channel, note: d1, velocity: d2 / 127, control: null, value: null };\n case NOTE_ON:\n // velocity 0 == note off (see doc comment).\n return d2 > 0\n ? { type: \"noteon\", channel, note: d1, velocity: d2 / 127, control: null, value: null }\n : { type: \"noteoff\", channel, note: d1, velocity: 0, control: null, value: null };\n case POLY_AFTERTOUCH:\n return { type: \"polyaftertouch\", channel, note: d1, velocity: null, control: null, value: d2 };\n case CONTROL_CHANGE:\n return { type: \"controlchange\", channel, note: null, velocity: null, control: d1, value: d2 };\n case PROGRAM_CHANGE:\n return { type: \"programchange\", channel, note: null, velocity: null, control: null, value: d1 };\n case AFTERTOUCH:\n return { type: \"aftertouch\", channel, note: null, velocity: null, control: null, value: d1 };\n default:\n // 0xE0 pitch bend — the only high nibble left between 0x80 and 0xEF once\n // the six cases above are taken. 14-bit little-endian, centered at 8192,\n // normalized to -1..1.\n return {\n type: \"pitchbend\", channel, note: null, velocity: null, control: null,\n value: (((d2 << 7) | d1) - 8192) / 8192,\n };\n }\n}\n\n/** Message kinds a caller may want to filter on, exported for tooling. */\nexport const MIDI_MESSAGE_TYPES: readonly MidiMessageType[] = [\n \"noteon\", \"noteoff\", \"polyaftertouch\", \"controlchange\",\n \"programchange\", \"aftertouch\", \"pitchbend\", \"sysex\", \"other\",\n];\n","import {\n IMidiDevice, IMidiMessage, IMidiOptions, IWcBindable, MidiMessageType,\n MidiPermissionState,\n} from \"../types.js\";\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveMidiErrorInfo } from \"./midiCapabilities.js\";\nimport { parseMessage } from \"../midi/parseMessage.js\";\n\nconst UNSUPPORTED = \"unsupported\";\n\n// Minimal structural types for the Web MIDI API. The DOM lib does not ship them\n// in every TypeScript configuration, and structural types keep the Core testable\n// against a fake without casting through `any` at each use site.\ninterface MidiPortLike extends EventTarget {\n id: string;\n name?: string | null;\n manufacturer?: string | null;\n state: string;\n type?: string;\n}\ninterface MidiInputLike extends MidiPortLike {\n onmidimessage: ((event: any) => void) | null;\n}\ninterface MidiOutputLike extends MidiPortLike {\n send(data: number[] | Uint8Array, timestamp?: number): void;\n}\ninterface MidiAccessLike {\n inputs: Map<string, MidiInputLike>;\n outputs: Map<string, MidiOutputLike>;\n onstatechange: ((event: any) => void) | null;\n sysexEnabled?: boolean;\n}\n\nconst detailOf = (event: Event): any => (event as CustomEvent).detail;\nconst messageField = <K extends keyof IMidiMessage>(key: K) =>\n (event: Event): IMidiMessage[K] | null => detailOf(event)?.[key] ?? null;\n\n/**\n * Headless Web MIDI primitive: a framework-agnostic wrapper around\n * `navigator.requestMIDIAccess()` exposed through the wc-bindable protocol.\n *\n * Direction is genuinely two-way, unlike `@wcstack/permission` (monitor only):\n * incoming messages flow element → state as `event`-semantics occurrences, and\n * `send()` is a command going the other way. Both live on one node because a\n * page holds exactly one `MIDIAccess` — splitting input and output into two tags\n * would only force them to coordinate over the same shared handle.\n *\n * Nothing starts on construction. `requestMIDIAccess()` can raise a permission\n * prompt, so it is deliberately command-driven (`request()`), matching the\n * `idle` / Generic Sensor family. `observe({ auto: true })` opts back into\n * requesting immediately, and `observe()` after `dispose()` acquires again the\n * access the last `request()` got, when no prompt can appear (an element taken\n * out of the document and put back).\n *\n * The `MIDIAccess` handle itself is never published: the Core owns it and drops\n * it in `close()` / `dispose()`, as `worker` / `websocket` / `broadcast` do with\n * theirs. Only values cross the protocol boundary.\n */\nexport class MidiCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n // One occurrence event, decomposed into derived getters\n // (async-io-node-guidelines.md §4.2). Never same-value guarded: two\n // identical note-ons are two distinct presses.\n { name: \"message\", event: \"wcs-midi:message\", semantics: \"event\" },\n { name: \"type\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"type\") },\n { name: \"channel\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"channel\") },\n { name: \"note\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"note\") },\n { name: \"velocity\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"velocity\") },\n { name: \"control\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"control\") },\n { name: \"value\", event: \"wcs-midi:message\", semantics: \"event\", getter: messageField(\"value\") },\n { name: \"devices\", event: \"wcs-midi:devices\", semantics: \"state\" },\n { name: \"connected\", event: \"wcs-midi:statechange\", semantics: \"state\" },\n { name: \"permission\", event: \"wcs-midi:permission\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === \"granted\" },\n { name: \"denied\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === \"denied\" },\n { name: \"unsupported\", event: \"wcs-midi:permission\", semantics: \"state\", getter: (e: Event) => detailOf(e) === UNSUPPORTED },\n { name: \"error\", event: \"wcs-midi:error\", semantics: \"state\" },\n { name: \"errorInfo\", event: \"wcs-midi:error-info-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"close\" },\n { name: \"send\" },\n ],\n };\n\n private _target: EventTarget;\n private _options: IMidiOptions = {};\n\n private _access: MidiAccessLike | null = null;\n private _hookedInputs = new Set<MidiInputLike>();\n\n private _message: IMidiMessage | null = null;\n private _devices: IMidiDevice[] = [];\n private _connected = false;\n private _permission: MidiPermissionState = \"prompt\";\n private _error: string | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n\n private _permissionStatus: PermissionStatus | null = null;\n\n // Monotonic id bumped by every request(), close() and dispose(). An in-flight\n // requestMIDIAccess() captures it and bails on resolve when superseded, so a\n // rapid disconnect→reconnect (or a close() mid-flight) never hooks listeners\n // onto a torn-down instance.\n private _gen = 0;\n\n // The generation of the request in flight: observe() starts none while it is\n // the current one (a request() before the connect-time decision took it,\n // timing-and-firing-contract §23.3).\n private _pendingGen = -1;\n\n // The sysex of the access the last request() acquired; null before one, after\n // a refused one and after close(). dispose() keeps it: observe() acquires that\n // access again when its permission is still granted (an element taken out of\n // the document and put back, as a route left and entered again does). Only the\n // command's success counts: an access `auto` acquired is `auto`'s to decide on\n // the next connect, so an `auto` the page turns off there still requests\n // nothing. A refused request, `auto`'s included, forgets it.\n private _grantedSysex: boolean | null = null;\n\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(options?: IMidiOptions | null, target?: EventTarget) {\n super();\n this._target = target ?? this;\n if (options) this._options = { ...options };\n }\n\n // --- Observable getters ---\n\n get message(): IMidiMessage | null { return this._message; }\n get type(): MidiMessageType | null { return this._message?.type ?? null; }\n get channel(): number | null { return this._message?.channel ?? null; }\n get note(): number | null { return this._message?.note ?? null; }\n get velocity(): number | null { return this._message?.velocity ?? null; }\n get control(): number | null { return this._message?.control ?? null; }\n get value(): number | null { return this._message?.value ?? null; }\n\n get devices(): IMidiDevice[] { return this._devices; }\n get connected(): boolean { return this._connected; }\n get permission(): MidiPermissionState { return this._permission; }\n get granted(): boolean { return this._permission === \"granted\"; }\n get denied(): boolean { return this._permission === \"denied\"; }\n get unsupported(): boolean { return this._permission === UNSUPPORTED; }\n get error(): string | null { return this._error; }\n get errorInfo(): WcsIoErrorInfo | null { return this._errorInfo; }\n\n /** Resolves once the current (or initial) access attempt settles. */\n get ready(): Promise<void> { return this._ready; }\n\n // --- Public API ---\n\n /**\n * Store the options and decide whether to request access: when `auto` is set,\n * or when `dispose()` dropped an access the last `request()` acquired and its\n * permission is still granted (so no prompt can appear). A missing API is\n * reported as `unsupported` here, `auto` or not. Idempotent: calling it again\n * with new options re-applies port selection to the live access without\n * re-requesting, and it starts nothing while a request is in flight.\n */\n observe(options: IMidiOptions): Promise<void> {\n this.setOptions(options);\n if (this._access !== null || this._pendingGen === this._gen) return this._ready;\n if (options.auto || this._resolveApi() === null) {\n // _request() reports a missing API at once: no prompt is involved, so the\n // page learns it at connect rather than at its first request()\n this._ready = this._request(false);\n } else if (this._grantedSysex !== null) {\n this._ready = this._reacquire();\n }\n return this._ready;\n }\n\n /**\n * Re-apply port selection / channel filtering. Cheap and safe at any time —\n * with no access held it only records the options for a later `request()`.\n */\n setOptions(options: IMidiOptions): void {\n this._options = { ...this._options, ...options };\n if (this._access) this._hookInputs(this._access);\n }\n\n /**\n * Acquire MIDI access. Never rejects: a refusal or a missing API surfaces as\n * `permission` / `error` state (async-io-node-guidelines.md §3.6).\n */\n request(): Promise<void> {\n return this._request(true);\n }\n\n // `remember`: an access the command acquired is what observe() acquires again\n // after dispose(); one `auto` acquired is not. Any refusal forgets it.\n private _request(remember: boolean): Promise<void> {\n const requestAccess = this._resolveApi();\n if (!requestAccess) {\n this._setPermission(UNSUPPORTED);\n this._setError(UNSUPPORTED, UNSUPPORTED);\n this._ready = Promise.resolve();\n return this._ready;\n }\n const gen = ++this._gen;\n this._pendingGen = gen;\n const sysex = this._options.sysex === true;\n this._probePermission();\n this._ready = requestAccess({ sysex }).then(\n (access: MidiAccessLike) => {\n if (gen !== this._gen) return;\n this._pendingGen = -1;\n if (remember) this._grantedSysex = sysex;\n this._access = access;\n access.onstatechange = this._onStateChange;\n this._setError(null);\n this._setPermission(\"granted\");\n this._hookInputs(access);\n this._publishDevices(access);\n this._setConnected(true);\n },\n (error: any) => {\n if (gen !== this._gen) return;\n this._pendingGen = -1;\n this._grantedSysex = null;\n this._setPermission(\"denied\");\n this._setError(this._messageOf(error), error?.name);\n },\n );\n return this._ready;\n }\n\n /**\n * Release the access handle and detach every listener, keeping the observed\n * permission state. `connected` goes to `false` and `devices` to `[]`, both\n * published. A later `request()` re-acquires; `observe()` does not by itself.\n */\n close(): void {\n this._release();\n this._grantedSysex = null;\n }\n\n /**\n * Send a raw MIDI message to the selected output port (or the first available\n * one). No-op when no output is reachable; a failing `send()` surfaces on\n * `error` rather than throwing.\n *\n * Positional arguments pass through verbatim from command-token\n * (docs/spec-proposal-command-token-arguments.md).\n */\n send(data: number[] | Uint8Array, timestamp?: number): void {\n const port = this._resolveOutput();\n if (!port) return;\n try {\n port.send(data, timestamp);\n } catch (error: any) {\n this._setError(this._messageOf(error), \"send\");\n }\n }\n\n /**\n * Detach everything. Headless callers own this lifecycle themselves: without\n * it the live `onmidimessage` handlers keep this instance reachable for as\n * long as the ports are alive.\n */\n dispose(): void {\n // Unlike close(), keeps what the last request() acquired: a later observe()\n // acquires it again when its permission is still granted.\n this._release();\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n }\n\n // --- Internal: access ---\n\n // A disconnect publishes what it changes (timing-and-firing-contract §22).\n // Without the access the ports are no longer tracked, so `devices` is emptied\n // with its event: a page put back must not list a keyboard it cannot hear.\n private _release(): void {\n this._gen++;\n this._unhookInputs();\n if (this._access) {\n this._access.onstatechange = null;\n this._access = null;\n }\n this._setConnected(false);\n this._setDevices([]);\n }\n\n // observe() after dispose(): request again only when the permission for the\n // sysex asked now is granted, so no prompt can appear. A request(), close()\n // or dispose() while the answer is pending takes the decision (_gen).\n //\n // Where the browser answers, its answer decides, and one that is not\n // `granted` is published: the element learned that the grant went away (a\n // page reading `granted` with `connected: false` could not tell it must ask\n // again). Where it does not, the outcome last inferred from request() stands,\n // and only for the sysex it was inferred at (a sysex grant is a separate\n // permission); nothing new is known, so nothing is published.\n private _reacquire(): Promise<void> {\n const gen = this._gen;\n const sysex = this._options.sysex === true;\n return this._queryPermission(sysex).then((answer) => {\n if (gen !== this._gen) return;\n if (answer === null) {\n if (this._permission === \"granted\" && this._grantedSysex === sysex) return this.request();\n return;\n }\n if (answer === \"granted\") return this.request();\n this._setPermission(answer);\n });\n }\n\n // The Permissions API's answer for midi at this sysex; null where the browser\n // gives none (no Permissions API, or the descriptor is not understood).\n private _queryPermission(sysex: boolean): Promise<MidiPermissionState | null> {\n // Only reached after _resolveApi() found navigator.requestMIDIAccess.\n const permissions = (globalThis as { navigator?: any }).navigator.permissions;\n if (!permissions || typeof permissions.query !== \"function\") return Promise.resolve(null);\n return permissions.query({ name: \"midi\", sysex }).then(\n (status: PermissionStatus) => status.state as MidiPermissionState,\n () => null,\n );\n }\n\n // --- Internal: API resolution ---\n\n // Resolved at call time, never cached: keeps the unsupported branch honest and\n // lets tests swap the global (async-io-node-guidelines.md §3.7). Read off\n // globalThis rather than the bare identifier so an SSR/worker context with no\n // navigator at all takes the same \"unsupported\" path as Safari.\n private _resolveApi(): ((options: { sysex: boolean }) => Promise<MidiAccessLike>) | null {\n const nav = (globalThis as { navigator?: any }).navigator;\n if (!nav || typeof nav.requestMIDIAccess !== \"function\") return null;\n return (options) => nav.requestMIDIAccess(options);\n }\n\n private _messageOf(error: any): string {\n return typeof error?.message === \"string\" && error.message !== \"\" ? error.message : \"MIDI error\";\n }\n\n // --- Internal: permission monitoring ---\n\n // Optional extra: browsers that answer query({name:\"midi\"}) let a grant flipped\n // in site settings flow into the declarative state without a re-request. Where\n // the descriptor is rejected we simply keep inferring from request() outcomes.\n private _probePermission(): void {\n if (this._permissionStatus) return;\n // Only ever reached after _resolveApi() found navigator.requestMIDIAccess,\n // so navigator itself is known to exist here.\n const permissions = (globalThis as { navigator?: any }).navigator.permissions;\n if (!permissions || typeof permissions.query !== \"function\") return;\n const gen = this._gen;\n permissions.query({ name: \"midi\", sysex: this._options.sysex === true }).then(\n (status: PermissionStatus) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(status.state as MidiPermissionState);\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => { /* descriptor not understood — request() outcomes remain the source */ },\n );\n }\n\n private _onPermissionChange = (event: Event): void => {\n this._setPermission((event.target as PermissionStatus).state as MidiPermissionState);\n };\n\n // --- Internal: ports ---\n\n private _matches(port: MidiPortLike, selector: string): boolean {\n if (port.id === selector) return true;\n const name = port.name ?? \"\";\n return name.toLowerCase().startsWith(selector.toLowerCase());\n }\n\n // Takes the access explicitly rather than reading the field: every call site\n // already holds a non-null handle, and a defensive re-check here would be a\n // branch no test could ever reach.\n private _selectedInputs(access: MidiAccessLike): MidiInputLike[] {\n const all = [...access.inputs.values()];\n const selector = this._options.input;\n // No selector means \"whatever is plugged in\" — the expectation for MIDI is\n // that a controller just works, not that the page names it first.\n if (selector === undefined || selector === null || selector === \"\") return all;\n return all.filter((port) => this._matches(port, selector));\n }\n\n private _resolveOutput(): MidiOutputLike | null {\n if (!this._access) return null;\n const all = [...this._access.outputs.values()];\n const selector = this._options.output;\n if (selector === undefined || selector === null || selector === \"\") return all[0] ?? null;\n return all.find((port) => this._matches(port, selector)) ?? null;\n }\n\n private _hookInputs(access: MidiAccessLike): void {\n const wanted = new Set(this._selectedInputs(access));\n for (const port of this._hookedInputs) {\n if (!wanted.has(port)) {\n port.onmidimessage = null;\n this._hookedInputs.delete(port);\n }\n }\n for (const port of wanted) {\n if (this._hookedInputs.has(port)) continue;\n port.onmidimessage = this._onMidiMessage;\n this._hookedInputs.add(port);\n }\n }\n\n private _unhookInputs(): void {\n for (const port of this._hookedInputs) port.onmidimessage = null;\n this._hookedInputs.clear();\n }\n\n private _onStateChange = (): void => {\n // Port list changed: re-apply selection (a newly plugged input must start\n // delivering) and republish. `onstatechange` is only installed while an\n // access is held and cleared in close(), so the handle is non-null here.\n const access = this._access!;\n this._hookInputs(access);\n this._publishDevices(access);\n };\n\n private _onMidiMessage = (event: { data?: Uint8Array | null; target?: any; timeStamp?: number }): void => {\n const raw = event.data;\n if (!raw) return;\n const parsed = parseMessage(raw);\n const channelFilter = this._options.channel;\n if (channelFilter != null && parsed.channel !== null && parsed.channel !== channelFilter) return;\n const port = event.target as MidiPortLike | undefined;\n this._publishMessage({\n ...parsed,\n // Fresh copy every time: the platform buffer must never be handed out\n // (producer snapshot contract).\n data: new Uint8Array(raw),\n port: port?.id ?? \"\",\n portName: port?.name ?? \"\",\n timestamp: event.timeStamp ?? 0,\n });\n };\n\n // --- Internal: state setters ---\n\n // Occurrence, not state: identical payloads are distinct presses, so there is\n // deliberately no same-value guard here.\n private _publishMessage(message: IMidiMessage): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:message\", { detail: message, bubbles: true }));\n }\n\n private _publishDevices(access: MidiAccessLike): void {\n this._setDevices(this._snapshotDevices(access));\n }\n\n private _setDevices(next: IMidiDevice[]): void {\n if (this._sameDevices(next)) return;\n // Fresh array assigned before notifying (producer snapshot contract).\n this._devices = next;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:devices\", { detail: next, bubbles: true }));\n }\n\n private _snapshotDevices(access: MidiAccessLike): IMidiDevice[] {\n const collect = (ports: Map<string, MidiPortLike>, direction: \"input\" | \"output\"): IMidiDevice[] =>\n [...ports.values()].map((port) => ({\n id: port.id,\n name: port.name ?? \"\",\n manufacturer: port.manufacturer ?? \"\",\n direction,\n state: port.state === \"connected\" ? \"connected\" : \"disconnected\",\n }));\n return [\n ...collect(access.inputs as Map<string, MidiPortLike>, \"input\"),\n ...collect(access.outputs as Map<string, MidiPortLike>, \"output\"),\n ];\n }\n\n // Content comparison, not reference: statechange fires separately for the\n // input and the output side of one physical device, so an unfiltered\n // republish would double-notify on every plug.\n private _sameDevices(next: IMidiDevice[]): boolean {\n if (next.length !== this._devices.length) return false;\n return next.every((device, i) => {\n const prev = this._devices[i];\n return prev.id === device.id && prev.state === device.state\n && prev.direction === device.direction && prev.name === device.name;\n });\n }\n\n private _setConnected(connected: boolean): void {\n if (this._connected === connected) return;\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:statechange\", { detail: connected, bubbles: true }));\n }\n\n private _setPermission(permission: MidiPermissionState): void {\n if (this._permission === permission) return;\n this._permission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:permission\", { detail: permission, bubbles: true }));\n }\n\n private _setError(error: string | null, name?: string): void {\n if (this._error !== error) {\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:error\", { detail: error, bubbles: true }));\n }\n this._commitErrorInfo(error === null ? null : deriveMidiErrorInfo(name, error));\n }\n\n // errorInfo transitions exactly when error does (no independent same-value\n // guard: a fresh object is built per transition).\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n if (this._errorInfo === null && info === null) return;\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-midi:error-info-changed\", { detail: info, bubbles: true }));\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import {\n IMidiDevice, IMidiMessage, IMidiOptions, IWcBindable, MidiMessageType,\n MidiPermissionState, WcsIoErrorInfo,\n} from \"../types.js\";\nimport { MidiCore } from \"../core/MidiCore.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-midi>` — declarative Web MIDI input/output.\n *\n * Nothing happens on a first connect: `requestMIDIAccess()` can raise a\n * permission prompt, so access is command-driven (`command.request`). Add the\n * `auto` attribute to opt into requesting as soon as the element connects. An\n * element whose last `request()` got access (and not `close()`d since), taken\n * out and put back (a route left and entered again), requests again by itself,\n * only while the permission is still granted, so no prompt can appear. Where\n * the API is absent, `unsupported` is reported at connect, `auto` or not.\n */\nexport class WcsMidi extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static observedAttributes = [\"input\", \"output\", \"channel\"];\n\n static wcBindable: IWcBindable = {\n ...MidiCore.wcBindable,\n inputs: [\n { name: \"input\", attribute: \"input\" },\n { name: \"output\", attribute: \"output\" },\n { name: \"channel\", attribute: \"channel\" },\n { name: \"sysex\", attribute: \"sysex\" },\n { name: \"auto\", attribute: \"auto\" },\n ],\n };\n\n private _core: MidiCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n // connectedCallback が張った connectedCallbackPromise を解く関数。接続時の判断を下す\n // _scheduleRequest のマイクロタスクが(その前に外れたときは disconnectedCallback が)呼ぶ。\n private _connectResolve: ((value: void | PromiseLike<void>) => void) | null = null;\n // _scheduleRequest のマイクロタスクが待っている間 true\n private _requestPending: boolean = false;\n // 接続時の判断待ちに close() が呼ばれたら true — その判断は auto でも要求しない\n private _autoCancelled: boolean = false;\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new MidiCore(null, this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-midi:permission\": (d) => ({\n granted: d === \"granted\",\n denied: d === \"denied\",\n unsupported: d === \"unsupported\",\n }),\n \"wcs-midi:statechange\": (d) => ({ connected: d === true }),\n \"wcs-midi:error\": (d) => ({ error: d !== null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects non-dashed\n // state names. Either case silently disables reflection.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" input / output would select a port named \"undefined\", i.e. none),\n // and the booleans do not use toggleAttribute (an `undefined` force flips the\n // attribute): `null` removes the attribute (the default — every port, every\n // channel, off), `undefined` restores the attribute the element started with\n // (wc-bindable producer guidance P1; React 19 and a direct assignment deliver\n // it, @wcstack/state does not).\n\n get input(): string { return this.getAttribute(\"input\") ?? \"\"; }\n set input(value: string | null | undefined) { reflectAttribute(this, \"input\", value); }\n\n get output(): string { return this.getAttribute(\"output\") ?? \"\"; }\n set output(value: string | null | undefined) { reflectAttribute(this, \"output\", value); }\n\n get channel(): number | null {\n const raw = this.getAttribute(\"channel\");\n if (raw === null) return null;\n const n = Number(raw);\n return Number.isFinite(n) ? n : null;\n }\n\n set channel(value: number | null | undefined) {\n reflectAttribute(this, \"channel\", value);\n }\n\n get sysex(): boolean { return this.hasAttribute(\"sysex\"); }\n set sysex(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"sysex\", value); }\n\n get auto(): boolean { return this.hasAttribute(\"auto\"); }\n set auto(value: boolean | null | undefined) { reflectBooleanAttribute(this, \"auto\", value); }\n\n // --- Core delegated getters ---\n\n get message(): IMidiMessage | null { return this._core.message; }\n get type(): MidiMessageType | null { return this._core.type; }\n get note(): number | null { return this._core.note; }\n get velocity(): number | null { return this._core.velocity; }\n get control(): number | null { return this._core.control; }\n get value(): number | null { return this._core.value; }\n get devices(): IMidiDevice[] { return this._core.devices; }\n get connected(): boolean { return this._core.connected; }\n get permission(): MidiPermissionState { return this._core.permission; }\n get granted(): boolean { return this._core.granted; }\n get denied(): boolean { return this._core.denied; }\n get unsupported(): boolean { return this._core.unsupported; }\n get error(): string | null { return this._core.error; }\n get errorInfo(): WcsIoErrorInfo | null { return this._core.errorInfo; }\n\n /** Headless escape hatch: the Core backing this element. */\n get core(): MidiCore { return this._core; }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<void> {\n // 要求の sysex は属性が正本。接続時の判断(マイクロタスク)が Core へ渡すより先の\n // request() でも、接続の後に sysex が変わった後でも、いまの属性で要求するよう渡しておく。\n // 判断の前の request() は判断を引き取る — 要求中の Core に observe() は要求を重ねない\n // (timing-and-firing-contract §23.3)\n this._core.setOptions(this._options());\n return this._core.request();\n }\n\n close(): void {\n // 接続時の判断待ちなら、その auto の要求を取り消す — 同じタスクの append → close() で、\n // 後のマイクロタスクが要求しないように(判断が同期だった頃は、始めた要求を close() が\n // 捨てていた)。入れ直せば、次の判断は auto に従う。Core の close() は最後の request()\n // が取ったアクセスも忘れるので、入れ直しでも取り直さない(明示の解放)\n if (this._connectResolve !== null) this._autoCancelled = true;\n this._core.close();\n }\n send(data: number[] | Uint8Array, timestamp?: number): void { this._core.send(data, timestamp); }\n\n // --- Internal ---\n\n private _options(): IMidiOptions {\n return {\n input: this.input,\n output: this.output,\n channel: this.channel,\n sysex: this.sysex,\n auto: this.auto,\n };\n }\n\n // --- Lifecycle ---\n\n // 接続時の要求の判断はマイクロタスクで、そのときの auto / sysex(と input / output /\n // channel)で 1 回だけ行う(timing-and-firing-contract §23)。router は遷移で同じノードを\n // 入れ直し、新しいルートの params から state が入力を書くのはマイクロタスク — その場で\n // 判断すると、前の auto / sysex で requestMIDIAccess を起こしていた(docs/seam-apps.md、\n // shift-desk)。判断は Core の observe() が下す: auto なら要求し、auto でなくても、最後の\n // request() でアクセスを取れていた要素は、権限がまだ granted なら取り直す(プロンプトは\n // 出ない。ルートを出て戻った要素が MIDI を失っていた — 音楽室の練習用シンセの継ぎ目アプリ)。\n // API が無ければ auto でなくても unsupported を報告する。\n private _scheduleRequest(): void {\n if (this._requestPending) return;\n this._requestPending = true;\n queueMicrotask(() => {\n this._requestPending = false;\n const resolveConnect = this._connectResolve;\n this._connectResolve = null;\n // 判断の前に外れた要素は何もしない(disconnectedCallback が解いて null にした)\n if (resolveConnect === null) return;\n const options = this._options();\n // 判断待ちに close() が呼ばれていたら、auto でも要求しない\n if (this._autoCancelled) options.auto = false;\n this._autoCancelled = false;\n resolveConnect(this._core.observe(options));\n });\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n // connectedCallbackPromise は接続時の判断(auto なら要求の結果)が済むまでを表す。\n // 判断はマイクロタスクなので、ここで張って _scheduleRequest で解く\n this._connectedCallbackPromise = new Promise<void>((resolve) => {\n this._connectResolve = resolve;\n });\n this._scheduleRequest();\n }\n\n disconnectedCallback(): void {\n // 判断の前に外れたら、張った connectedCallbackPromise をここで解く — 同じタスクで\n // 入れ直されると次の connectedCallback が張り替えるので、待つ側が取り残されないように\n this._connectResolve?.();\n this._connectResolve = null;\n this._autoCancelled = false;\n // connected: false と devices: [] を知らせる(§22)。最後の request() が取ったアクセスは\n // Core が覚えていて、入れ直しの判断が取り直す\n this._core.dispose();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n // Port selection and channel filtering are live: they re-hook the existing\n // access rather than re-requesting it (no second permission prompt). They only\n // record the options and re-hook (no request), so they stay synchronous; the\n // connect-time decision reads them again.\n if (this.isConnected) this._core.setOptions(this._options());\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/define-element.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * One copy of each package on a page (docs/timing-and-firing-contract.md §24). The first copy the\n * page evaluates defines the tags and a second one does nothing, so a copy that finds its tag defined\n * by another copy of the package — not its class, not a subclass of it, not the same version — warns\n * `[wcs/package-twice]` once per registry, naming both versions. The classes it defines carry\n * `\"<package>@<version>\"` under `Symbol.for(\"wcstack.package\")`; a class without it is named\n * \"another copy of <package> that does not name its version\" (an older copy, or one loaded through\n * an entry that does not stamp).\n */\n\n/** The static a class defined through this helper carries: `\"@wcstack/fetch@<version>\"`. */\nexport const PACKAGE_STAMP: unique symbol = Symbol.for(\"wcstack.package\");\n\ntype Stamped = { [PACKAGE_STAMP]?: string };\n\n/** The registries this copy warned about: one warning per package per registry. */\nconst warned = new WeakSet<CustomElementRegistry>();\n\n/**\n * Marks `cls` as defined by `pkg` (`\"@wcstack/fetch@<version>\"`). A subclass inherits the mark, and\n * `defineProperty` writes it even where a parent's mark is read-only.\n */\nexport function stampPackage(cls: CustomElementConstructor, pkg: string): void {\n Object.defineProperty(cls, PACKAGE_STAMP, { value: pkg, configurable: true });\n}\n\n/**\n * Warns when `tag` is defined as `existing` by another copy of the package `pkg` names: `existing`\n * is neither `own` nor a subclass of it (omit `own` when the copy has no class to compare with), and\n * carries another version or none. Once per registry.\n */\nexport function warnIfAnotherCopy(\n registry: CustomElementRegistry,\n tag: string,\n existing: CustomElementConstructor,\n own: CustomElementConstructor | undefined,\n pkg: string,\n): void {\n if (own !== undefined && (existing === own || existing.prototype instanceof own)) return;\n const theirs = (existing as Stamped)[PACKAGE_STAMP];\n if (theirs === pkg || warned.has(registry)) return;\n warned.add(registry);\n const name = pkg.slice(0, pkg.lastIndexOf(\"@\"));\n console.warn(\n `[${name}] [wcs/package-twice] <${tag}> is already defined by ` +\n `${theirs ?? `another copy of ${name} that does not name its version`}; ` +\n `this copy, ${pkg}, does nothing. Load each package once.`,\n );\n}\n\n/**\n * Defines each `[tag, class]` in `registry` unless the tag is already defined, stamping the class\n * with `pkg` (`\"@wcstack/fetch@<version>\"`). A tag another copy of the package defined first is left\n * as it is, with the warning above.\n */\nexport function defineElements(\n registry: CustomElementRegistry,\n pkg: string,\n definitions: readonly (readonly [tag: string, cls: CustomElementConstructor])[],\n): void {\n for (const [tag, cls] of definitions) {\n const existing = registry.get(tag);\n if (existing === undefined) {\n stampPackage(cls, pkg);\n registry.define(tag, cls);\n } else {\n warnIfAnotherCopy(registry, tag, existing, cls, pkg);\n }\n }\n}\n","import pkg from \"../package.json\" with { type: \"json\" };\nimport { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.js\";\nimport { defineElements } from \"./protocol/defineElement.js\";\n\n/**\n * Register this package's tags. Pass a scoped `CustomElementRegistry` to define\n * them for a single shadow tree -- scoped registries do not inherit the global\n * one, so a tree using one needs its own definitions.\n */\nexport function registerComponents(registry: CustomElementRegistry = customElements): void {\n defineElements(registry, `${pkg.name}@${pkg.version}`, [\n [config.tagNames.midi, WcsMidi],\n ]);\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapMidi(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":["config","tagNames","midi","WCS_MIDI_ERROR_CODE","EMPTY","type","channel","note","velocity","control","value","UNSUPPORTED","detailOf","event","detail","messageField","key","MidiCore","EventTarget","static","protocol","version","properties","name","semantics","getter","e","commands","async","_target","_options","_access","_hookedInputs","Set","_message","_devices","_connected","_permission","_error","_errorInfo","_permissionStatus","_gen","_pendingGen","_grantedSysex","_ready","Promise","resolve","constructor","options","target","super","this","message","devices","connected","permission","granted","denied","unsupported","error","errorInfo","ready","observe","setOptions","auto","_resolveApi","_request","_reacquire","_hookInputs","request","remember","requestAccess","_setPermission","_setError","gen","sysex","_probePermission","then","access","onstatechange","_onStateChange","_publishDevices","_setConnected","_messageOf","close","_release","send","data","timestamp","port","_resolveOutput","dispose","removeEventListener","_onPermissionChange","_unhookInputs","_setDevices","_queryPermission","answer","permissions","globalThis","navigator","query","status","state","nav","requestMIDIAccess","addEventListener","_matches","selector","id","toLowerCase","startsWith","_selectedInputs","all","inputs","values","input","filter","outputs","output","find","wanted","has","onmidimessage","delete","_onMidiMessage","add","clear","raw","parsed","d1","d2","parseMessage","channelFilter","_publishMessage","Uint8Array","portName","timeStamp","dispatchEvent","CustomEvent","bubbles","_snapshotDevices","next","_sameDevices","collect","ports","direction","map","manufacturer","length","every","device","i","prev","_commitErrorInfo","code","phase","recoverable","deriveMidiErrorInfo","info","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","get","set","toldObjectAttribute","WeakSet","warnObjectAttribute","element","tag","localName","console","warn","initialAttributes","WeakMap","initialAttribute","el","byName","Map","getAttribute","writeAttribute","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsMidi","HTMLElement","wcBindable","attribute","_core","_connectedCallbackPromise","_connectResolve","_requestPending","_autoCancelled","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","toStates","entries","debug","hasAttribute","on","toggleAttribute","n","Number","isFinite","core","connectedCallbackPromise","_scheduleRequest","queueMicrotask","resolveConnect","connectedCallback","declaration","call","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","attributeChangedCallback","_name","oldValue","newValue","isConnected","PACKAGE_STAMP","Symbol","for","warned","stampPackage","cls","pkg","defineProperty","configurable","warnIfAnotherCopy","registry","existing","own","theirs","slice","lastIndexOf","registerComponents","customElements","definitions","define","defineElements"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,KAAM,8CCQH,MAAMC,EAEQ,qBAFRA,EAOC,cAPDA,EASE,eATFA,EAWC,cC1Bd,MAUMC,EAAqB,CACzBC,KAAM,QAASC,QAAS,KAAMC,KAAM,KAAMC,SAAU,KAAMC,QAAS,KAAMC,MAAO,MCNlF,MAAMC,EAAc,cAyBdC,EAAYC,GAAuBA,EAAsBC,OACzDC,EAA8CC,GACjDH,GAAyCD,EAASC,KAASG,IAAQ,KAuBhE,MAAOC,UAAiBC,YAC5BC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CAIV,CAAEC,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,SACzD,CAAED,KAAM,OAAQV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,SACpF,CAAEQ,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,YACvF,CAAEQ,KAAM,OAAQV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,SACpF,CAAEQ,KAAM,WAAYV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,aACxF,CAAEQ,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,YACvF,CAAEQ,KAAM,QAASV,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,UACrF,CAAEQ,KAAM,UAAWV,MAAO,mBAAoBW,UAAW,SACzD,CAAED,KAAM,YAAaV,MAAO,uBAAwBW,UAAW,SAC/D,CAAED,KAAM,aAAcV,MAAO,sBAAuBW,UAAW,SA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