@wcstack/midi 4.6.2 → 4.8.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 +1 -0
- package/README.md +1 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +59 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -184,6 +184,7 @@ throw は一切しません。失敗は状態として現れます。
|
|
|
184
184
|
|
|
185
185
|
## 注意点
|
|
186
186
|
|
|
187
|
+
- **4.8 から、接続時のアクセスの要求はマイクロタスクを 1 つ待ち**、そのときの `auto` / `sysex` を読む([タイミング契約](../../docs/timing-and-firing-contract.ja.md) §23)。`@wcstack/router` はパラメータだけの遷移でルートの要素を入れ直し、`@wcstack/state` が次のルートの入力を書くのはその後で、前のルートの水準で許可を求めていた。`request()` は今の `sysex` を読み、同じタスクの `close()` は待っている要求を取り消す。
|
|
187
188
|
- **Chromium 限定**。セキュアコンテキストが必要。
|
|
188
189
|
- **velocity 0 の note-on は note-off**(上記)。
|
|
189
190
|
- **`sysex` は別権限**で、拒否されやすい。
|
package/README.md
CHANGED
|
@@ -184,6 +184,7 @@ Nothing throws. Failures surface as state:
|
|
|
184
184
|
|
|
185
185
|
## Notes
|
|
186
186
|
|
|
187
|
+
- **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.
|
|
187
188
|
- **Chromium only**, and a secure context is required.
|
|
188
189
|
- **Velocity 0 note-ons are note-offs** — see above.
|
|
189
190
|
- **`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"}},t="capability-missing",s="not-allowed",n="access-error",i="send-failed";const r={type:"other",channel:null,note:null,velocity:null,control:null,value:null};const o="unsupported",a=e=>e.detail,c=e=>t=>a(t)?.[e]??null;class u 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:c("type")},{name:"channel",event:"wcs-midi:message",semantics:"event",getter:c("channel")},{name:"note",event:"wcs-midi:message",semantics:"event",getter:c("note")},{name:"velocity",event:"wcs-midi:message",semantics:"event",getter:c("velocity")},{name:"control",event:"wcs-midi:message",semantics:"event",getter:c("control")},{name:"value",event:"wcs-midi:message",semantics:"event",getter:c("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"===a(e)},{name:"denied",event:"wcs-midi:permission",semantics:"state",getter:e=>"denied"===a(e)},{name:"unsupported",event:"wcs-midi:permission",semantics:"state",getter:e=>a(e)===o},{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===o}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(o),this._setError(o,o),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 r;const s="number"==typeof e[1]?e[1]:0,n="number"==typeof e[2]?e[2]:0;if(t>=240)return{...r,type:240===t?"sysex":"other"};if(t<128)return r;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,r){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,r){return"unsupported"===e?{code:t,phase:"probe",recoverable:!1,message:r}:"send"===e?{code:i,phase:"execute",recoverable:!0,message:r}:"SecurityError"===e||"NotAllowedError"===e?{code:s,phase:"start",recoverable:!1,message:r}:{code:n,phase:"start",recoverable:!0,message:r}}(r,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 l(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 h=new WeakSet;function d(e,t,s){if(h.has(e))return;h.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 m=new WeakMap;function p(e,t){let s=m.get(e);return void 0===s&&(s=new Map,m.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function _(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function g(e,t,s){const n=p(e,t);_(e,t,void 0===s?n:null===s?null:String(s))}function v(e,t,s){const n=p(e,t);_(e,t,void 0===s?n:s?"":null)}class f extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["input","output","channel"];static wcBindable={...u.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();_internals=null;constructor(){super(),this._core=new u(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){g(this,"input",e)}get output(){return this.getAttribute("output")??""}set output(e){g(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){g(this,"channel",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){v(this,"sysex",e)}get auto(){return this.hasAttribute("auto")}set auto(e){v(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.request()}close(){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}}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 ")&&d(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!l(e,s))continue;const r=e,o=r[s];delete r[s],r[s]=o}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe(this._options())}disconnectedCallback(){this._core.dispose()}attributeChangedCallback(e,t,s){t!==s&&this.isConnected&&this._core.setOptions(this._options())}}var b;!function(t=customElements){t.get(e.tagNames.midi)||t.define(e.tagNames.midi,f)}(b);
|
|
1
|
+
const e={tagNames:{midi:"wcs-midi"}},t="capability-missing",s="not-allowed",n="access-error",i="send-failed";const r={type:"other",channel:null,note:null,velocity:null,control:null,value:null};const o="unsupported",a=e=>e.detail,c=e=>t=>a(t)?.[e]??null;class u 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:c("type")},{name:"channel",event:"wcs-midi:message",semantics:"event",getter:c("channel")},{name:"note",event:"wcs-midi:message",semantics:"event",getter:c("note")},{name:"velocity",event:"wcs-midi:message",semantics:"event",getter:c("velocity")},{name:"control",event:"wcs-midi:message",semantics:"event",getter:c("control")},{name:"value",event:"wcs-midi:message",semantics:"event",getter:c("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"===a(e)},{name:"denied",event:"wcs-midi:permission",semantics:"state",getter:e=>"denied"===a(e)},{name:"unsupported",event:"wcs-midi:permission",semantics:"state",getter:e=>a(e)===o},{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===o}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(o),this._setError(o,o),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 r;const s="number"==typeof e[1]?e[1]:0,n="number"==typeof e[2]?e[2]:0;if(t>=240)return{...r,type:240===t?"sysex":"other"};if(t<128)return r;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,r){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,r){return"unsupported"===e?{code:t,phase:"probe",recoverable:!1,message:r}:"send"===e?{code:i,phase:"execute",recoverable:!0,message:r}:"SecurityError"===e||"NotAllowedError"===e?{code:s,phase:"start",recoverable:!1,message:r}:{code:n,phase:"start",recoverable:!0,message:r}}(r,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 l(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 h=new WeakSet;function d(e,t,s){if(h.has(e))return;h.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 m=new WeakMap;function _(e,t){let s=m.get(e);return void 0===s&&(s=new Map,m.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function p(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function g(e,t,s){const n=_(e,t);p(e,t,void 0===s?n:null===s?null:String(s))}function v(e,t,s){const n=_(e,t);p(e,t,void 0===s?n:s?"":null)}class f extends HTMLElement{static hasConnectedCallbackPromise=!0;static observedAttributes=["input","output","channel"];static wcBindable={...u.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 u(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){g(this,"input",e)}get output(){return this.getAttribute("output")??""}set output(e){g(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){g(this,"channel",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){v(this,"sysex",e)}get auto(){return this.hasAttribute("auto")}set auto(e){v(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 ")&&d(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!l(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())}}var b;!function(t=customElements){t.get(e.tagNames.midi)||t.define(e.tagNames.midi,f)}(b);
|
|
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/bootstrapMidi.ts","../src/registerComponents.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 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> { return this._core.request(); }\n close(): void { this._core.close(); }\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 connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this._options());\n }\n\n disconnectedCallback(): void {\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).\n if (this.isConnected) this._core.setOptions(this._options());\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","import { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.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 if (!registry.get(config.tagNames.midi)) {\n registry.define(config.tagNames.midi, WcsMidi);\n }\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","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","toStates","entries","debug","hasAttribute","on","toggleAttribute","n","Number","isFinite","core","connectedCallbackPromise","connectedCallback","declaration","call","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","attributeChangedCallback","_name","oldValue","newValue","isConnected","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,KAAM,aCQGC,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,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,SAC/D,CAAED,KAAM,UAAWV,MAAO,sBAAuBW,UAAW,QAASC,OAASC,GAA6B,YAAhBd,EAASc,IACpG,CAAEH,KAAM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,IAAaC,GAGb5K,KAAK6K,aAAa7K,KAAK0I,MAAM7H,WAAWb,KAAKnB,WACnD,EC9KI,IAAsDiM,GCItD,SAA6BA,EAAkCC,gBAC9DD,EAAShE,IAAI/J,EAAOC,SAASC,OAChC6N,EAASE,OAAOjO,EAAOC,SAASC,KAAMqL,EAE1C,CDJE2C,CAAmBH"}
|
|
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/bootstrapMidi.ts","../src/registerComponents.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","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","import { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.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 if (!registry.get(config.tagNames.midi)) {\n registry.define(config.tagNames.midi, WcsMidi);\n }\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","registry","customElements","define","registerComponents"],"mappings":"AAQA,MA0BaA,EA1BoB,CAC/BC,SAAU,CACRC,KAAM,aCQGC,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,MAAO,mBAAoBW,UAAW,QAASC,OAAQV,EAAa,YACvF,CAAEQ,KAAM,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BAAAwK,IFzII,SAA4BlD,GAChC,MAAMmD,EAAenD,EAA2DvH,aAAa4I,WACvF/E,EAAS6G,GAAa7G,OAC5B,QAAeoD,IAAXpD,EAAsB,OAC1B,MAAMqE,EAAgBX,EAA+DW,aACrF,IAAK,MAAMnE,KAASF,EAAQ,CAC1B,MAAMnF,EAAOqF,EAAMrF,KACbmK,EAAoC,mBAAjBX,EAA8BA,EAAayC,KAAKpD,EAAS7I,EAAK+E,eAAiB,KAExG,GADkB,OAAdoF,GAAsBA,EAAUnF,WAAW,aAAa4D,EAAoBC,EAAS7I,EAAMmK,IAC1FhC,OAAO+D,UAAUC,eAAeF,KAAKpD,EAAS7I,GAAO,SAC1D,IAAKiI,EAAuBY,EAAS7I,GAAO,SAC5C,MAAMoM,EAASvD,EACT1J,EAAQiN,EAAOpM,UACdoM,EAAOpM,GACdoM,EAAOpM,GAAQb,CACjB,CACF,CE2HIkN,CAAkB3K,MAClBA,KAAK4K,MAAMC,QAAU,OAGrB7K,KAAK2I,0BAA4B,IAAIjJ,QAAeC,IAClDK,KAAK4I,gBAAkBjJ,IAEzBK,KAAKkK,kBACP,CAEA,oBAAAY,GAGE9K,KAAK4I,oBACL5I,KAAK4I,gBAAkB,KACvB5I,KAAK8I,gBAAiB,EACtB9I,KAAK0I,MAAMpG,SACb,CAEA,wBAAAyI,CAAyBC,EAAeC,EAAyBC,GAC3DD,IAAaC,GAKblL,KAAKmL,aAAanL,KAAK0I,MAAM7H,WAAWb,KAAKnB,WACnD,ECnOI,IAAsDuM,GCItD,SAA6BA,EAAkCC,gBAC9DD,EAAStE,IAAI/J,EAAOC,SAASC,OAChCmO,EAASE,OAAOvO,EAAOC,SAASC,KAAMqL,EAE1C,CDJEiD,CAAmBH"}
|
package/dist/index.d.ts
CHANGED
|
@@ -299,6 +299,9 @@ declare class WcsMidi extends HTMLElement {
|
|
|
299
299
|
static wcBindable: IWcBindable;
|
|
300
300
|
private _core;
|
|
301
301
|
private _connectedCallbackPromise;
|
|
302
|
+
private _connectResolve;
|
|
303
|
+
private _requestPending;
|
|
304
|
+
private _autoCancelled;
|
|
302
305
|
private _internals;
|
|
303
306
|
constructor();
|
|
304
307
|
get debugStates(): string[];
|
|
@@ -335,6 +338,7 @@ declare class WcsMidi extends HTMLElement {
|
|
|
335
338
|
close(): void;
|
|
336
339
|
send(data: number[] | Uint8Array, timestamp?: number): void;
|
|
337
340
|
private _options;
|
|
341
|
+
private _scheduleRequest;
|
|
338
342
|
connectedCallback(): void;
|
|
339
343
|
disconnectedCallback(): void;
|
|
340
344
|
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -700,6 +700,13 @@ class WcsMidi extends HTMLElement {
|
|
|
700
700
|
};
|
|
701
701
|
_core;
|
|
702
702
|
_connectedCallbackPromise = Promise.resolve();
|
|
703
|
+
// connectedCallback が張った connectedCallbackPromise を解く関数。接続時の判断を下す
|
|
704
|
+
// _scheduleRequest のマイクロタスクが(その前に外れたときは disconnectedCallback が)呼ぶ。
|
|
705
|
+
_connectResolve = null;
|
|
706
|
+
// _scheduleRequest のマイクロタスクが待っている間 true
|
|
707
|
+
_requestPending = false;
|
|
708
|
+
// 接続時の判断待ちに close() が呼ばれたら true — その判断は auto でも要求しない
|
|
709
|
+
_autoCancelled = false;
|
|
703
710
|
_internals = null;
|
|
704
711
|
constructor() {
|
|
705
712
|
super();
|
|
@@ -806,8 +813,20 @@ class WcsMidi extends HTMLElement {
|
|
|
806
813
|
return this._connectedCallbackPromise;
|
|
807
814
|
}
|
|
808
815
|
// --- Commands ---
|
|
809
|
-
request() {
|
|
810
|
-
|
|
816
|
+
request() {
|
|
817
|
+
// 要求の sysex は属性が正本。接続時の判断(マイクロタスク)が Core へ渡すより先の
|
|
818
|
+
// request() でも、接続の後に sysex が変わった後でも、いまの属性で要求するよう渡しておく
|
|
819
|
+
this._core.setOptions(this._options());
|
|
820
|
+
return this._core.request();
|
|
821
|
+
}
|
|
822
|
+
close() {
|
|
823
|
+
// 接続時の判断待ちなら、その auto の要求を取り消す — 同じタスクの append → close() で、
|
|
824
|
+
// 後のマイクロタスクが要求しないように(判断が同期だった頃は、始めた要求を close() が
|
|
825
|
+
// 捨てていた)。入れ直せば、次の判断は auto に従う
|
|
826
|
+
if (this._connectResolve !== null)
|
|
827
|
+
this._autoCancelled = true;
|
|
828
|
+
this._core.close();
|
|
829
|
+
}
|
|
811
830
|
send(data, timestamp) { this._core.send(data, timestamp); }
|
|
812
831
|
// --- Internal ---
|
|
813
832
|
_options() {
|
|
@@ -820,20 +839,56 @@ class WcsMidi extends HTMLElement {
|
|
|
820
839
|
};
|
|
821
840
|
}
|
|
822
841
|
// --- Lifecycle ---
|
|
842
|
+
// 接続時の要求の判断はマイクロタスクで、そのときの auto / sysex(と input / output /
|
|
843
|
+
// channel)で 1 回だけ行う(timing-and-firing-contract §23)。router は遷移で同じノードを
|
|
844
|
+
// 入れ直し、新しいルートの params から state が入力を書くのはマイクロタスク — その場で
|
|
845
|
+
// 判断すると、前の auto / sysex で requestMIDIAccess を起こしていた(docs/seam-apps.md、
|
|
846
|
+
// shift-desk)。
|
|
847
|
+
_scheduleRequest() {
|
|
848
|
+
if (this._requestPending)
|
|
849
|
+
return;
|
|
850
|
+
this._requestPending = true;
|
|
851
|
+
queueMicrotask(() => {
|
|
852
|
+
this._requestPending = false;
|
|
853
|
+
const resolveConnect = this._connectResolve;
|
|
854
|
+
this._connectResolve = null;
|
|
855
|
+
// 判断の前に外れた要素は何もしない(disconnectedCallback が解いて null にした)
|
|
856
|
+
if (resolveConnect === null)
|
|
857
|
+
return;
|
|
858
|
+
const options = this._options();
|
|
859
|
+
// 判断待ちに close() が呼ばれていたら、auto でも要求しない
|
|
860
|
+
if (this._autoCancelled)
|
|
861
|
+
options.auto = false;
|
|
862
|
+
this._autoCancelled = false;
|
|
863
|
+
resolveConnect(this._core.observe(options));
|
|
864
|
+
});
|
|
865
|
+
}
|
|
823
866
|
connectedCallback() {
|
|
824
867
|
// upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)
|
|
825
868
|
upgradeProperties(this);
|
|
826
869
|
this.style.display = "none";
|
|
827
|
-
|
|
870
|
+
// connectedCallbackPromise は接続時の判断(auto なら要求の結果)が済むまでを表す。
|
|
871
|
+
// 判断はマイクロタスクなので、ここで張って _scheduleRequest で解く
|
|
872
|
+
this._connectedCallbackPromise = new Promise((resolve) => {
|
|
873
|
+
this._connectResolve = resolve;
|
|
874
|
+
});
|
|
875
|
+
this._scheduleRequest();
|
|
828
876
|
}
|
|
829
877
|
disconnectedCallback() {
|
|
878
|
+
// 判断の前に外れたら、張った connectedCallbackPromise をここで解く — 同じタスクで
|
|
879
|
+
// 入れ直されると次の connectedCallback が張り替えるので、待つ側が取り残されないように
|
|
880
|
+
this._connectResolve?.();
|
|
881
|
+
this._connectResolve = null;
|
|
882
|
+
this._autoCancelled = false;
|
|
830
883
|
this._core.dispose();
|
|
831
884
|
}
|
|
832
885
|
attributeChangedCallback(_name, oldValue, newValue) {
|
|
833
886
|
if (oldValue === newValue)
|
|
834
887
|
return;
|
|
835
888
|
// Port selection and channel filtering are live: they re-hook the existing
|
|
836
|
-
// access rather than re-requesting it (no second permission prompt).
|
|
889
|
+
// access rather than re-requesting it (no second permission prompt). They only
|
|
890
|
+
// record the options and re-hook (no request), so they stay synchronous; the
|
|
891
|
+
// connect-time decision reads them again.
|
|
837
892
|
if (this.isConnected)
|
|
838
893
|
this._core.setOptions(this._options());
|
|
839
894
|
}
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.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/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 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> { return this._core.request(); }\n close(): void { this._core.close(); }\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 connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n this._connectedCallbackPromise = this._core.observe(this._options());\n }\n\n disconnectedCallback(): void {\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).\n if (this.isConnected) this._core.setOptions(this._options());\n }\n}\n","import { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.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 if (!registry.get(config.tagNames.midi)) {\n registry.define(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":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,UAAU;AACjB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GA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G,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACvC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAChD;AACF;;ACRM,SAAU,aAAa,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC1F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.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/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","import { WcsMidi } from \"./components/Midi.js\";\nimport { config } from \"./config.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 if (!registry.get(config.tagNames.midi)) {\n registry.define(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":[],"mappings":"AAQA,MAAM,OAAO,GAAoB;AAC/B,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE,UAAU;AACjB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,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