@wcstack/websocket 4.2.0 → 4.4.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 -1
- package/README.md +1 -1
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +14 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -203,7 +203,7 @@ HTML、JS、または `@wcstack/state` バインディングから接続とメ
|
|
|
203
203
|
|------------|------|------|
|
|
204
204
|
| `url` | `string` | WebSocket エンドポイント URL |
|
|
205
205
|
| `trigger` | `boolean` | 単方向の接続トリガー |
|
|
206
|
-
| `send` | `any` |
|
|
206
|
+
| `send` | `any` | 値を設定するとデータを送信(オブジェクトは自動文字列化)。ソケットが開く前は拒まれる: `error`(`invalid-state`)に流れ、メッセージは失われ、要素が `[wcs/command-not-ready]` で警告する(1 要素につき 1 回) |
|
|
207
207
|
| `manual` | `boolean` | DOM 接続時の自動接続を無効化 |
|
|
208
208
|
|
|
209
209
|
**`null` と `undefined`。** 属性に対応する入力(`url`・`protocols`・`autoReconnect`・`reconnectInterval`・`maxReconnects`・`binaryType`・`manual` — [要素一覧](#要素一覧)参照)は、`null` を「クリア」として扱います。属性を外し、入力は既定値に戻ります。`undefined` は「値が無い」で、属性を最初の書き込みの前の状態 — マークアップに書かれた値、無ければ属性なし — に戻します。どちらも文字列 `"null"` / `"undefined"` として書くことはありません(`@wcstack/state` は `undefined` を書きませんが、React 19 は値のあった prop を外したときに書き、直接の代入でも届きます)。こうして戻った `url` はほかの `url` 変更と同じく接続し直し、クリアした `url` では接続しません。`trigger` と `send` はどちらも無視します。
|
package/README.md
CHANGED
|
@@ -203,7 +203,7 @@ These properties control connection and messaging from HTML, JS, or `@wcstack/st
|
|
|
203
203
|
|----------|------|-------------|
|
|
204
204
|
| `url` | `string` | WebSocket endpoint URL |
|
|
205
205
|
| `trigger` | `boolean` | One-way connection trigger |
|
|
206
|
-
| `send` | `any` | Set to transmit data (auto-stringifies objects) |
|
|
206
|
+
| `send` | `any` | Set to transmit data (auto-stringifies objects). Before the socket is open it is refused: it goes to `error` (`invalid-state`), the message is lost, and the element warns `[wcs/command-not-ready]` (once per element) |
|
|
207
207
|
| `manual` | `boolean` | Disables auto-connect on DOM attach |
|
|
208
208
|
|
|
209
209
|
**`null` and `undefined`.** The inputs backed by an attribute (`url`, `protocols`, `autoReconnect`, `reconnectInterval`, `maxReconnects`, `binaryType`, `manual` — see [Elements](#elements)) take `null` as "clear": the attribute is removed and the input falls back to its default. `undefined` means "no value supplied": the attribute goes back to what it was before the first write — the value written in the markup, or none. Neither is ever written as the string `"null"` / `"undefined"`. (`@wcstack/state` never writes `undefined`; React 19 does when a prop that had a value is removed, and so can a direct assignment.) A `url` restored this way reconnects like any other `url` change; a cleared `url` does not connect. `trigger` and `send` ignore both.
|
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={triggerAttribute:"data-wstarget",tagNames:{ws:"wcs-ws"}},t="invalid-argument",n="invalid-state",s="connection-error";class r extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"message",event:"wcs-ws:message",semantics:"event"},{name:"connected",event:"wcs-ws:connected-changed",semantics:"state"},{name:"loading",event:"wcs-ws:loading-changed",semantics:"state"},{name:"error",event:"wcs-ws:error",semantics:"state"},{name:"errorInfo",event:"wcs-ws:error-info-changed",semantics:"state"},{name:"readyState",event:"wcs-ws:readystate-changed",semantics:"state"}],commands:[{name:"connect"},{name:"send"},{name:"close"}]};_target;_ws=null;_message=null;_connected=!1;_loading=!1;_error=null;_errorInfo=null;_readyState=3;_autoReconnect=!1;_reconnectInterval=3e3;_maxReconnects=1/0;_reconnectCount=0;_reconnectTimer=null;_url="";_protocols=void 0;_binaryType="blob";_intentionalClose=!1;_gen=0;_socketGen=0;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.close()}get message(){return this._message}get connected(){return this._connected}get loading(){return this._loading}get error(){return this._error}get errorInfo(){return this._errorInfo}get readyState(){return this._readyState}_setMessage(e){this._message=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:message",{detail:e,bubbles:!0}))}_setConnected(e){this._connected=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:connected-changed",{detail:e,bubbles:!0}))}_setLoading(e){this._loading=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:loading-changed",{detail:e,bubbles:!0}))}_setError(e,r){this._error!==e&&(this._error=e,this._commitErrorInfo(null===e?null:function(e,r){const i=e.message,o="string"==typeof i?i:"WebSocket connection error";return r===t?{code:t,phase:"start",recoverable:!1,message:o}:r===n?{code:n,phase:"execute",recoverable:!1,message:o}:{code:s,phase:"execute",recoverable:!0,message:o}}(e,r)),this._target.dispatchEvent(new CustomEvent("wcs-ws:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:error-info-changed",{detail:e,bubbles:!0}))}_setReadyState(e){this._readyState=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:readystate-changed",{detail:e,bubbles:!0}))}connect(e,n={}){e?(this._gen++,this._intentionalClose=!0,this._closeInternal(),this._url=e,this._protocols=n.protocols,this._autoReconnect=n.autoReconnect??!1,this._reconnectInterval=n.reconnectInterval??3e3,this._maxReconnects=n.maxReconnects??1/0,this._binaryType=n.binaryType??"blob",this._reconnectCount=0,this._intentionalClose=!1,this._doConnect()):this._setError({message:"url is required."},t)}send(e){this._ws&&1===this._ws.readyState?this._ws.send(e):this._setError({message:"WebSocket is not connected."},n)}close(e,t){this._intentionalClose=!0,this._clearReconnectTimer(),this._ws&&this._ws.close(e,t)}_doConnect(){this._setLoading(!0),this._setError(null),this._socketGen=this._gen;try{this._ws=this._protocols?new WebSocket(this._url,this._protocols):new WebSocket(this._url)}catch(e){return this._setLoading(!1),void this._setError(e,s)}this._ws.binaryType=this._binaryType,this._setReadyState(0),this._ws.addEventListener("open",this._onOpen),this._ws.addEventListener("message",this._onMessage),this._ws.addEventListener("error",this._onError),this._ws.addEventListener("close",this._onClose)}_onOpen=()=>{this._socketGen===this._gen&&(this._reconnectCount=0,this._setLoading(!1),this._setConnected(!0),this._setReadyState(1))};_onMessage=e=>{if(this._socketGen!==this._gen)return;let t=e.data;if("string"==typeof t)try{t=JSON.parse(t)}catch{}this._setMessage(t)};_onError=e=>{this._socketGen===this._gen&&this._setError(e,s)};_onClose=e=>{this._removeListeners(),this._ws=null,this._socketGen===this._gen&&(this._setConnected(!1),this._setLoading(!1),this._setReadyState(3),!this._intentionalClose&&this._autoReconnect&&1e3!==e.code&&this._reconnectCount<this._maxReconnects&&this._scheduleReconnect())};_scheduleReconnect(){const e=this._gen;this._clearReconnectTimer(),this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,e===this._gen&&(this._reconnectCount++,this._doConnect())},this._reconnectInterval)}_clearReconnectTimer(){null!==this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}_removeListeners(){this._ws&&(this._ws.removeEventListener("open",this._onOpen),this._ws.removeEventListener("message",this._onMessage),this._ws.removeEventListener("error",this._onError),this._ws.removeEventListener("close",this._onClose))}_closeInternal(){this._clearReconnectTimer(),this._ws&&(this._removeListeners(),1!==this._ws.readyState&&0!==this._ws.readyState||this._ws.close(),this._ws=null),this._connected&&this._setConnected(!1),3!==this._readyState&&this._setReadyState(3)}}let i=!1;function o(t){const n=t.target;if(!(n instanceof Element))return;const s=n.closest(`[${e.triggerAttribute}]`);if(!s)return;const r=s.getAttribute(e.triggerAttribute);if(!r)return;const i=customElements.get(e.tagNames.ws),o=document.getElementById(r);i&&o instanceof i&&(t.preventDefault(),o.connect())}function c(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const a=new WeakMap;function h(e,t){let n=a.get(e);return void 0===n&&(n=new Map,a.set(e,n)),n.has(t)||n.set(t,e.getAttribute(t)),n.get(t)}function l(e,t,n){null===n?e.removeAttribute(t):e.setAttribute(t,n)}function _(e,t,n){const s=h(e,t);l(e,t,void 0===n?s:null===n?null:String(n))}function u(e,t,n){const s=h(e,t);l(e,t,void 0===n?s:n?"":null)}class d extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...r.wcBindable,properties:[...r.wcBindable.properties,{name:"trigger",event:"wcs-ws:trigger-changed",semantics:"state"},{name:"send",event:"wcs-ws:send-changed",semantics:"state"}],inputs:[{name:"url",attribute:"url"},{name:"protocols",attribute:"protocols"},{name:"autoReconnect",attribute:"auto-reconnect"},{name:"reconnectInterval",attribute:"reconnect-interval"},{name:"maxReconnects",attribute:"max-reconnects"},{name:"binaryType",attribute:"binary-type"},{name:"manual",attribute:"manual"},{name:"trigger"},{name:"send"}],commands:[{name:"connect"},{name:"sendMessage"},{name:"close"}]};static get observedAttributes(){return["url"]}_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;_attached=!1;constructor(){super(),this._core=new r(this),this._internals=this._initInternals(),this._wireStates({"wcs-ws:connected-changed":e=>({connected:!0===e}),"wcs-ws:loading-changed":e=>({loading:!0===e}),"wcs-ws:error":e=>({error:null!=e})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}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[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[r,i]of Object.entries(s(e.detail))){try{i?t.add(r):t.delete(r)}catch{}n&&this.toggleAttribute(`data-wcs-state-${r}`,i)}})}get url(){return this.getAttribute("url")||""}set url(e){_(this,"url",e)}get protocols(){return this.getAttribute("protocols")||""}set protocols(e){_(this,"protocols",e)}get autoReconnect(){return this.hasAttribute("auto-reconnect")}set autoReconnect(e){u(this,"auto-reconnect",e)}get reconnectInterval(){const e=this.getAttribute("reconnect-interval"),t=e?parseInt(e,10):3e3;return Number.isNaN(t)?3e3:t}set reconnectInterval(e){_(this,"reconnect-interval",e)}get maxReconnects(){const e=this.getAttribute("max-reconnects"),t=e?parseInt(e,10):1/0;return Number.isNaN(t)?1/0:t}set maxReconnects(e){_(this,"max-reconnects",e)}get binaryType(){return"arraybuffer"===this.getAttribute("binary-type")?"arraybuffer":"blob"}set binaryType(e){_(this,"binary-type",e)}get manual(){return this.hasAttribute("manual")}set manual(e){u(this,"manual",e)}get message(){return this._core.message}get connected(){return this._core.connected}get loading(){return this._core.loading}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get readyState(){return this._core.readyState}get trigger(){return this._trigger}set trigger(e){!!e&&(this._trigger=!0,this.connect(),this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-ws:trigger-changed",{detail:!1,bubbles:!0})))}get send(){return null}set send(e){if(null==e)return;const t="string"==typeof e?e:JSON.stringify(e);this._core.send(t),this.dispatchEvent(new CustomEvent("wcs-ws:send-changed",{detail:null,bubbles:!0}))}connect(){const e=this.protocols?this.protocols.split(",").map(e=>e.trim()).filter(Boolean):void 0;this._core.connect(this.url,{protocols:e&&1===e.length?e[0]:e,autoReconnect:this.autoReconnect,reconnectInterval:this.reconnectInterval,maxReconnects:this.maxReconnects,binaryType:this.binaryType})}sendMessage(e){this._core.send(e)}close(e,t){this._core.close(e,t)}attributeChangedCallback(e,t,n){"url"===e&&t!==n&&this._attached&&!this.manual&&n&&this.connect()}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0!==n)for(const t of n){const n=t.name;if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!c(e,n))continue;const s=e,r=s[n];delete s[n],s[n]=r}}(this),this.style.display="none",i||(i=!0,document.addEventListener("click",o)),this._connectedCallbackPromise=this._core.observe(),!this.manual&&this.url&&this.connect(),this._attached=!0}disconnectedCallback(){this._attached=!1,this._core.dispose()}}var g;!function(t=customElements){t.get(e.tagNames.ws)||t.define(e.tagNames.ws,d)}(g);
|
|
1
|
+
const e={triggerAttribute:"data-wstarget",tagNames:{ws:"wcs-ws"}},t="invalid-argument",n="invalid-state",s="connection-error";class r extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"message",event:"wcs-ws:message",semantics:"event"},{name:"connected",event:"wcs-ws:connected-changed",semantics:"state"},{name:"loading",event:"wcs-ws:loading-changed",semantics:"state"},{name:"error",event:"wcs-ws:error",semantics:"state"},{name:"errorInfo",event:"wcs-ws:error-info-changed",semantics:"state"},{name:"readyState",event:"wcs-ws:readystate-changed",semantics:"state"}],commands:[{name:"connect"},{name:"send"},{name:"close"}]};_target;_ws=null;_message=null;_connected=!1;_loading=!1;_error=null;_errorInfo=null;_readyState=3;_autoReconnect=!1;_reconnectInterval=3e3;_maxReconnects=1/0;_reconnectCount=0;_reconnectTimer=null;_url="";_protocols=void 0;_binaryType="blob";_intentionalClose=!1;_gen=0;_socketGen=0;_ready=Promise.resolve();_toldNotReady=!1;constructor(e){super(),this._target=e??this}get ready(){return this._ready}observe(){return this._ready}dispose(){this._gen++,this.close()}get message(){return this._message}get connected(){return this._connected}get loading(){return this._loading}get error(){return this._error}get errorInfo(){return this._errorInfo}get readyState(){return this._readyState}_setMessage(e){this._message=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:message",{detail:e,bubbles:!0}))}_setConnected(e){this._connected=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:connected-changed",{detail:e,bubbles:!0}))}_setLoading(e){this._loading=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:loading-changed",{detail:e,bubbles:!0}))}_setError(e,r){this._error!==e&&(this._error=e,this._commitErrorInfo(null===e?null:function(e,r){const o=e.message,i="string"==typeof o?o:"WebSocket connection error";return r===t?{code:t,phase:"start",recoverable:!1,message:i}:r===n?{code:n,phase:"execute",recoverable:!1,message:i}:{code:s,phase:"execute",recoverable:!0,message:i}}(e,r)),this._target.dispatchEvent(new CustomEvent("wcs-ws:error",{detail:e,bubbles:!0})))}_commitErrorInfo(e){this._errorInfo=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:error-info-changed",{detail:e,bubbles:!0}))}_setReadyState(e){this._readyState=e,this._target.dispatchEvent(new CustomEvent("wcs-ws:readystate-changed",{detail:e,bubbles:!0}))}connect(e,n={}){e?(this._gen++,this._intentionalClose=!0,this._closeInternal(),this._url=e,this._protocols=n.protocols,this._autoReconnect=n.autoReconnect??!1,this._reconnectInterval=n.reconnectInterval??3e3,this._maxReconnects=n.maxReconnects??1/0,this._binaryType=n.binaryType??"blob",this._reconnectCount=0,this._intentionalClose=!1,this._doConnect()):this._setError({message:"url is required."},t)}send(e){if(!this._ws||1!==this._ws.readyState)return this._setError({message:"WebSocket is not connected."},n),void this._warnNotReady();this._ws.send(e)}_warnNotReady(){this._toldNotReady||(this._toldNotReady=!0,console.warn("[@wcstack/websocket] [wcs/command-not-ready] send() was refused: the WebSocket is not connected, so the message is lost. It goes to `error` too. Send once `connected` is true. (Said once per element.)",this._target))}close(e,t){this._intentionalClose=!0,this._clearReconnectTimer(),this._ws&&this._ws.close(e,t)}_doConnect(){this._setLoading(!0),this._setError(null),this._socketGen=this._gen;try{this._ws=this._protocols?new WebSocket(this._url,this._protocols):new WebSocket(this._url)}catch(e){return this._setLoading(!1),void this._setError(e,s)}this._ws.binaryType=this._binaryType,this._setReadyState(0),this._ws.addEventListener("open",this._onOpen),this._ws.addEventListener("message",this._onMessage),this._ws.addEventListener("error",this._onError),this._ws.addEventListener("close",this._onClose)}_onOpen=()=>{this._socketGen===this._gen&&(this._reconnectCount=0,this._setLoading(!1),this._setConnected(!0),this._setReadyState(1))};_onMessage=e=>{if(this._socketGen!==this._gen)return;let t=e.data;if("string"==typeof t)try{t=JSON.parse(t)}catch{}this._setMessage(t)};_onError=e=>{this._socketGen===this._gen&&this._setError(e,s)};_onClose=e=>{this._removeListeners(),this._ws=null,this._socketGen===this._gen&&(this._setConnected(!1),this._setLoading(!1),this._setReadyState(3),!this._intentionalClose&&this._autoReconnect&&1e3!==e.code&&this._reconnectCount<this._maxReconnects&&this._scheduleReconnect())};_scheduleReconnect(){const e=this._gen;this._clearReconnectTimer(),this._reconnectTimer=setTimeout(()=>{this._reconnectTimer=null,e===this._gen&&(this._reconnectCount++,this._doConnect())},this._reconnectInterval)}_clearReconnectTimer(){null!==this._reconnectTimer&&(clearTimeout(this._reconnectTimer),this._reconnectTimer=null)}_removeListeners(){this._ws&&(this._ws.removeEventListener("open",this._onOpen),this._ws.removeEventListener("message",this._onMessage),this._ws.removeEventListener("error",this._onError),this._ws.removeEventListener("close",this._onClose))}_closeInternal(){this._clearReconnectTimer(),this._ws&&(this._removeListeners(),1!==this._ws.readyState&&0!==this._ws.readyState||this._ws.close(),this._ws=null),this._connected&&this._setConnected(!1),3!==this._readyState&&this._setReadyState(3)}}let o=!1;function i(t){const n=t.target;if(!(n instanceof Element))return;const s=n.closest(`[${e.triggerAttribute}]`);if(!s)return;const r=s.getAttribute(e.triggerAttribute);if(!r)return;const o=customElements.get(e.tagNames.ws),i=document.getElementById(r);o&&i instanceof o&&(t.preventDefault(),i.connect())}function c(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const a=new WeakMap;function h(e,t){let n=a.get(e);return void 0===n&&(n=new Map,a.set(e,n)),n.has(t)||n.set(t,e.getAttribute(t)),n.get(t)}function l(e,t,n){null===n?e.removeAttribute(t):e.setAttribute(t,n)}function _(e,t,n){const s=h(e,t);l(e,t,void 0===n?s:null===n?null:String(n))}function d(e,t,n){const s=h(e,t);l(e,t,void 0===n?s:n?"":null)}class u extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...r.wcBindable,properties:[...r.wcBindable.properties,{name:"trigger",event:"wcs-ws:trigger-changed",semantics:"state"},{name:"send",event:"wcs-ws:send-changed",semantics:"state"}],inputs:[{name:"url",attribute:"url"},{name:"protocols",attribute:"protocols"},{name:"autoReconnect",attribute:"auto-reconnect"},{name:"reconnectInterval",attribute:"reconnect-interval"},{name:"maxReconnects",attribute:"max-reconnects"},{name:"binaryType",attribute:"binary-type"},{name:"manual",attribute:"manual"},{name:"trigger"},{name:"send"}],commands:[{name:"connect"},{name:"sendMessage"},{name:"close"}]};static get observedAttributes(){return["url"]}_core;_trigger=!1;_connectedCallbackPromise=Promise.resolve();_internals=null;_attached=!1;constructor(){super(),this._core=new r(this),this._internals=this._initInternals(),this._wireStates({"wcs-ws:connected-changed":e=>({connected:!0===e}),"wcs-ws:loading-changed":e=>({loading:!0===e}),"wcs-ws:error":e=>({error:null!=e})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}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[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[r,o]of Object.entries(s(e.detail))){try{o?t.add(r):t.delete(r)}catch{}n&&this.toggleAttribute(`data-wcs-state-${r}`,o)}})}get url(){return this.getAttribute("url")||""}set url(e){_(this,"url",e)}get protocols(){return this.getAttribute("protocols")||""}set protocols(e){_(this,"protocols",e)}get autoReconnect(){return this.hasAttribute("auto-reconnect")}set autoReconnect(e){d(this,"auto-reconnect",e)}get reconnectInterval(){const e=this.getAttribute("reconnect-interval"),t=e?parseInt(e,10):3e3;return Number.isNaN(t)?3e3:t}set reconnectInterval(e){_(this,"reconnect-interval",e)}get maxReconnects(){const e=this.getAttribute("max-reconnects"),t=e?parseInt(e,10):1/0;return Number.isNaN(t)?1/0:t}set maxReconnects(e){_(this,"max-reconnects",e)}get binaryType(){return"arraybuffer"===this.getAttribute("binary-type")?"arraybuffer":"blob"}set binaryType(e){_(this,"binary-type",e)}get manual(){return this.hasAttribute("manual")}set manual(e){d(this,"manual",e)}get message(){return this._core.message}get connected(){return this._core.connected}get loading(){return this._core.loading}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get readyState(){return this._core.readyState}get trigger(){return this._trigger}set trigger(e){!!e&&(this._trigger=!0,this.connect(),this._trigger=!1,this.dispatchEvent(new CustomEvent("wcs-ws:trigger-changed",{detail:!1,bubbles:!0})))}get send(){return null}set send(e){if(null==e)return;const t="string"==typeof e?e:JSON.stringify(e);this._core.send(t),this.dispatchEvent(new CustomEvent("wcs-ws:send-changed",{detail:null,bubbles:!0}))}connect(){const e=this.protocols?this.protocols.split(",").map(e=>e.trim()).filter(Boolean):void 0;this._core.connect(this.url,{protocols:e&&1===e.length?e[0]:e,autoReconnect:this.autoReconnect,reconnectInterval:this.reconnectInterval,maxReconnects:this.maxReconnects,binaryType:this.binaryType})}sendMessage(e){this._core.send(e)}close(e,t){this._core.close(e,t)}attributeChangedCallback(e,t,n){"url"===e&&t!==n&&this._attached&&!this.manual&&n&&this.connect()}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0!==n)for(const t of n){const n=t.name;if(!Object.prototype.hasOwnProperty.call(e,n))continue;if(!c(e,n))continue;const s=e,r=s[n];delete s[n],s[n]=r}}(this),this.style.display="none",o||(o=!0,document.addEventListener("click",i)),this._connectedCallbackPromise=this._core.observe(),!this.manual&&this.url&&this.connect(),this._attached=!0}disconnectedCallback(){this._attached=!1,this._core.dispose()}}var g;!function(t=customElements){t.get(e.tagNames.ws)||t.define(e.tagNames.ws,u)}(g);
|
|
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/websocketCapabilities.ts","../src/core/WebSocketCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/WebSocket.ts","../src/bootstrapWebSocket.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n ws: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-wstarget\",\n tagNames: {\n ws: \"wcs-ws\",\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: `bootstrapWebSocket` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/websocket] bootstrapWebSocket: \"${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 [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * websocketCapabilities.ts\n *\n * WebSocket node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。WebSocket は持続的な session / monitor node(1 本の接続を張り続ける)で、\n * 競合する operation を持たないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * この node の `_setError` は 4 形態の非 null 入力を受ける(いずれも公開 `error` shape は不変):\n * 1. synthetic な `{ message: \"url is required.\" }`(`.name` 無し)— connect() の引数不備。\n * 2. synthetic な `{ message: \"WebSocket is not connected.\" }`(`.name` 無し)— open 前の send()。\n * 3. caught された生の構築例外 `e`(`new WebSocket()` の同期 throw)。\n * 4. platform の WebSocket `error` Event(`Event`。`.name`/`.message` を持たない)。\n *\n * これらは shape がバラバラで、message からの分類は脆い。そこで呼び出し側が明示的な\n * taxonomy code を discriminator として渡す(storage の `deriveStorageErrorInfo(error, name)`\n * と同じ技法)。derive 側は synthetic / Event / Error を reverse-engineer せず、渡された\n * code で phase / recoverable を決め、message だけを防御的に抽出する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した websocket error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WEBSOCKET_ERROR_CODE = {\n /** connect() の `url` 未指定 — 開始前の入力不備。retry では回復しない。 */\n InvalidArgument: \"invalid-argument\",\n /** open 前の send() — 接続が OPEN でない状態での送信。retry では回復しない(先に connect が要る)。 */\n InvalidState: \"invalid-state\",\n /**\n * 接続の確立 / 維持に失敗(`new WebSocket()` の同期例外、または platform の error Event)。\n * WebSocket のエラーは通常一過性で、再接続で回復しうる(recoverable=true)。\n */\n ConnectionError: \"connection-error\",\n} as const;\n\n/**\n * websocket の失敗を serializable な error taxonomy に写す。`code` は呼び出し側が渡す\n * discriminator(公開 `error` shape からは復元しない)。`message` は入力から防御的に抽出し、\n * message を持たない error Event 等では安定した fallback を使う。\n *\n * - `invalid-argument`(url 未指定)は開始前の入力不備 → phase=\"start\" / recoverable=false。\n * - `invalid-state`(open 前 send)は接続状態が満たされない実行時失敗 → phase=\"execute\" /\n * recoverable=false(先に connect() が必要)。\n * - `connection-error`(構築例外 / error Event)は接続の確立 / 維持失敗 → phase=\"execute\" /\n * recoverable=true(再接続で回復しうる)。\n */\nexport function deriveWebSocketErrorInfo(error: unknown, code: string): WcsIoErrorInfo {\n // error は非 null(_setError は error===null を derive 前に分岐する)だが、synthetic /\n // Event / caught 例外 / 生 throw と shape がバラバラなので message は防御的に抽出する。\n // error Event は message を持たないため安定した fallback に落とす。\n const raw = (error as { message?: unknown }).message;\n const message = typeof raw === \"string\" ? raw : \"WebSocket connection error\";\n\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidArgument) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidState) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidState, phase: \"execute\", recoverable: false, message };\n }\n // connection-error(構築例外 / error Event): 接続の確立/維持失敗、再接続で回復しうる。\n return { code: WCS_WEBSOCKET_ERROR_CODE.ConnectionError, phase: \"execute\", recoverable: true, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWebSocketErrorInfo, WCS_WEBSOCKET_ERROR_CODE } from \"./websocketCapabilities.js\";\n\n// WebSocket readyState values. Hardcoded rather than read from the global\n// WebSocket so the Core does not require WebSocket to exist at module load\n// (referencing `WebSocket.CLOSED` in a field initializer evaluates at class\n// definition time; tests inject a mock). Mirrors SseCore's SSE_CLOSED.\nconst WS_CONNECTING = 0;\nconst WS_OPEN = 1;\nconst WS_CLOSED = 3;\n\nexport interface WebSocketConnectOptions {\n protocols?: string | string[];\n autoReconnect?: boolean;\n reconnectInterval?: number;\n maxReconnects?: number;\n // How incoming binary frames are surfaced on `message`. \"blob\" (the platform\n // default) or \"arraybuffer\" for direct byte processing. Applied to every\n // socket this connection spawns, including auto-reconnects.\n binaryType?: BinaryType;\n}\n\nexport class WebSocketCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"message\", event: \"wcs-ws:message\", semantics: \"event\" },\n { name: \"connected\", event: \"wcs-ws:connected-changed\", semantics: \"state\" },\n { name: \"loading\", event: \"wcs-ws:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-ws:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (invalid-argument / invalid-state\n // / connection-error); the existing `error` property/event are unchanged. Fires\n // wcs-ws:error-info-changed. No lane — WebSocket is a persistent session/monitor\n // node, not a competing operation.\n { name: \"errorInfo\", event: \"wcs-ws:error-info-changed\", semantics: \"state\" },\n { name: \"readyState\", event: \"wcs-ws:readystate-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"send\" },\n { name: \"close\" },\n ],\n };\n\n private _target: EventTarget;\n private _ws: WebSocket | null = null;\n private _message: any = null;\n private _connected: boolean = false;\n private _loading: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readyState: number = WS_CLOSED;\n\n // 自動再接続\n private _autoReconnect: boolean = false;\n private _reconnectInterval: number = 3000;\n private _maxReconnects: number = Infinity;\n private _reconnectCount: number = 0;\n private _reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n private _url: string = \"\";\n private _protocols: string | string[] | undefined = undefined;\n private _binaryType: BinaryType = \"blob\";\n private _intentionalClose: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and at every connect(). A socket\n // event (open/message/error/close) or a scheduled reconnect that fires after\n // dispose / a superseding connect() carries a stale `gen` and MUST NOT write\n // state onto a torn-down element. A boolean flag is insufficient (dispose→observe\n // would let stale work slip through).\n private _gen = 0;\n // Generation captured when the current socket was opened. The shared socket\n // event handlers compare it against _gen to drop events from a superseded /\n // disposed connection.\n private _socketGen = 0;\n // SSR (§3.8): WebSocket is command-driven with no asynchronous probe to await,\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). WebSocket connections are command-driven (connect()), so\n // observe() is an idempotent no-op that resolves once ready; the Shell's\n // connectedCallback does not auto-establish a subscription here. dispose()\n // invalidates any in-flight socket / pending reconnect and closes the socket.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.close();\n }\n\n get message(): any {\n return this._message;\n }\n\n get connected(): boolean {\n return this._connected;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-ws:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readyState(): number {\n return this._readyState;\n }\n\n // --- State setters with event dispatch ---\n\n private _setMessage(message: any): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:message\", {\n detail: message,\n bubbles: true,\n }));\n }\n\n private _setConnected(connected: boolean): void {\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:connected-changed\", {\n detail: connected,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n // `code` is an explicit taxonomy discriminator (WCS_WEBSOCKET_ERROR_CODE), passed\n // only from the non-null failure call sites. It stays out of the public `error`\n // shape and is used solely to classify errorInfo without reverse-engineering the\n // heterogeneous `error` values (synthetic {message} / caught Error / raw Event).\n // The clear path passes null and no code.\n private _setError(error: any, code?: string): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every connect/send start\n // clears a usually-already-null error) avoids a spurious wcs-ws:error per\n // successful operation. Reference identity is sufficient: each failure builds\n // a fresh object (or the platform's own error Event), and the clear path\n // always passes null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // explicit `code` (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. Every non-null error carries a code (the clear path is the only\n // caller without one, and it is short-circuited here), so `code!` holds.\n this._commitErrorInfo(error === null ? null : deriveWebSocketErrorInfo(error, code!));\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadyState(readyState: number): void {\n this._readyState = readyState;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:readystate-changed\", {\n detail: readyState,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n connect(url: string, options: WebSocketConnectOptions = {}): void {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(なにもしない)を返す。command-token 経路(set trigger →\n // connect())からの呼び出しが state 更新サイクルを壊さないようにする。\n if (!url) {\n this._setError({ message: \"url is required.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidArgument);\n return;\n }\n\n // 新しい接続を開始するため世代を更新し、進行中のソケット/再接続を無効化する。\n this._gen++;\n\n // 既存の接続をクローズ\n this._intentionalClose = true;\n this._closeInternal();\n\n this._url = url;\n this._protocols = options.protocols;\n this._autoReconnect = options.autoReconnect ?? false;\n this._reconnectInterval = options.reconnectInterval ?? 3000;\n this._maxReconnects = options.maxReconnects ?? Infinity;\n this._binaryType = options.binaryType ?? \"blob\";\n this._reconnectCount = 0;\n this._intentionalClose = false;\n\n this._doConnect();\n }\n\n send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n // never-throw (§3.6): 未接続での送信は例外ではなく error に流す。set send の\n // fire-and-forget 経路で例外が伝播するのを防ぐ。\n if (!this._ws || this._ws.readyState !== WS_OPEN) {\n this._setError({ message: \"WebSocket is not connected.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidState);\n return;\n }\n this._ws.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._intentionalClose = true;\n this._clearReconnectTimer();\n if (this._ws) {\n this._ws.close(code, reason);\n }\n }\n\n // --- Internal ---\n\n private _doConnect(): void {\n this._setLoading(true);\n this._setError(null);\n\n // 接続開始時点の世代を捕捉。dispose()/再 connect() 後に発火した古いソケット\n // イベントはこの gen が stale になり、状態を書き換えない(_onOpen ほかが\n // _socketGen と this._gen を突き合わせて判定する)。\n this._socketGen = this._gen;\n\n try {\n this._ws = this._protocols\n ? new WebSocket(this._url, this._protocols)\n : new WebSocket(this._url);\n } catch (e) {\n this._setLoading(false);\n this._setError(e, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n return;\n }\n\n // Binary frames default to Blob; opt into ArrayBuffer for direct byte access.\n this._ws.binaryType = this._binaryType;\n\n this._setReadyState(WS_CONNECTING);\n\n this._ws.addEventListener(\"open\", this._onOpen);\n this._ws.addEventListener(\"message\", this._onMessage);\n this._ws.addEventListener(\"error\", this._onError);\n this._ws.addEventListener(\"close\", this._onClose);\n }\n\n private _onOpen = (): void => {\n if (this._socketGen !== this._gen) return;\n this._reconnectCount = 0;\n this._setLoading(false);\n this._setConnected(true);\n this._setReadyState(WS_OPEN);\n };\n\n private _onMessage = (event: MessageEvent): void => {\n if (this._socketGen !== this._gen) return;\n let data = event.data;\n // JSONの自動パース\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch {\n // テキストのまま\n }\n }\n this._setMessage(data);\n };\n\n private _onError = (event: Event): void => {\n if (this._socketGen !== this._gen) return;\n this._setError(event, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n };\n\n private _onClose = (event: CloseEvent): void => {\n this._removeListeners();\n this._ws = null;\n if (this._socketGen !== this._gen) return;\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\n\n // 異常クローズ時の自動再接続(正常終了 1000 は除外)\n if (!this._intentionalClose && this._autoReconnect && event.code !== 1000 && this._reconnectCount < this._maxReconnects) {\n this._scheduleReconnect();\n }\n };\n\n private _scheduleReconnect(): void {\n const gen = this._gen;\n this._clearReconnectTimer();\n this._reconnectTimer = setTimeout(() => {\n this._reconnectTimer = null;\n // dispose()/再 connect() でこの再接続が無効化されていたら何もしない。\n if (gen !== this._gen) return;\n this._reconnectCount++;\n this._doConnect();\n }, this._reconnectInterval);\n }\n\n private _clearReconnectTimer(): void {\n if (this._reconnectTimer !== null) {\n clearTimeout(this._reconnectTimer);\n this._reconnectTimer = null;\n }\n }\n\n private _removeListeners(): void {\n if (!this._ws) {\n return;\n }\n\n this._ws.removeEventListener(\"open\", this._onOpen);\n this._ws.removeEventListener(\"message\", this._onMessage);\n this._ws.removeEventListener(\"error\", this._onError);\n this._ws.removeEventListener(\"close\", this._onClose);\n }\n\n private _closeInternal(): void {\n this._clearReconnectTimer();\n if (this._ws) {\n this._removeListeners();\n if (this._ws.readyState === WS_OPEN || this._ws.readyState === WS_CONNECTING) {\n this._ws.close();\n }\n this._ws = null;\n }\n // 旧接続の状態をリセット(コンストラクタ例外時に stale 状態が残るのを防止)\n if (this._connected) {\n this._setConnected(false);\n }\n if (this._readyState !== WS_CLOSED) {\n this._setReadyState(WS_CLOSED);\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsWebSocket } from \"./components/WebSocket.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const wsId = triggerElement.getAttribute(config.triggerAttribute);\n if (!wsId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsWebSocket as a value. The value import created a components/WebSocket.ts ⇄\n // autoTrigger.ts cycle (WcsWebSocket.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-ws> class\n // matches — without the import cycle.\n const WsCtor = customElements.get(config.tagNames.ws);\n const wsElement = document.getElementById(wsId);\n if (!WsCtor || !(wsElement instanceof WsCtor)) return;\n\n event.preventDefault();\n (wsElement as WcsWebSocket).connect();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { WebSocketCore } from \"../core/WebSocketCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nexport class WcsWebSocket extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...WebSocketCore.wcBindable,\n properties: [\n ...WebSocketCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-ws:trigger-changed\", semantics: \"state\" },\n { name: \"send\", event: \"wcs-ws:send-changed\", semantics: \"state\" },\n ],\n inputs: [\n { name: \"url\", attribute: \"url\" },\n { name: \"protocols\", attribute: \"protocols\" },\n { name: \"autoReconnect\", attribute: \"auto-reconnect\" },\n { name: \"reconnectInterval\", attribute: \"reconnect-interval\" },\n { name: \"maxReconnects\", attribute: \"max-reconnects\" },\n { name: \"binaryType\", attribute: \"binary-type\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n { name: \"send\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"sendMessage\" },\n { name: \"close\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: WebSocketCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // connectedCallback が接続の判断を終えてから disconnectedCallback までの間だけ true。\n // url 属性の変化による再接続はこの間に限る — upgrade 時は attributeChangedCallback が\n // connectedCallback より先に(isConnected のまま)呼ばれるので、そこで接続すると\n // connectedCallback の接続と合わせて 2 本になる。初回の接続は connectedCallback が持つ。\n private _attached = false;\n\n constructor() {\n super();\n this._core = new WebSocketCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-ws:connected-changed\": (d) => ({ connected: d === true }),\n \"wcs-ws:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-ws:error\": (d) => ({ error: d != null }),\n });\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\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\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\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 //\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" url would reconnect to \"undefined\"): `null` removes the\n // attribute (the documented default; an empty url does not connect),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null | undefined) {\n reflectAttribute(this, \"url\", value);\n }\n\n get protocols(): string {\n return this.getAttribute(\"protocols\") || \"\";\n }\n\n set protocols(value: string | null | undefined) {\n reflectAttribute(this, \"protocols\", value);\n }\n\n get autoReconnect(): boolean {\n return this.hasAttribute(\"auto-reconnect\");\n }\n\n set autoReconnect(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"auto-reconnect\", value);\n }\n\n get reconnectInterval(): number {\n const attr = this.getAttribute(\"reconnect-interval\");\n const parsed = attr ? parseInt(attr, 10) : 3000;\n return Number.isNaN(parsed) ? 3000 : parsed;\n }\n\n set reconnectInterval(value: number | null | undefined) {\n reflectAttribute(this, \"reconnect-interval\", value);\n }\n\n get maxReconnects(): number {\n const attr = this.getAttribute(\"max-reconnects\");\n const parsed = attr ? parseInt(attr, 10) : Infinity;\n return Number.isNaN(parsed) ? Infinity : parsed;\n }\n\n set maxReconnects(value: number | null | undefined) {\n reflectAttribute(this, \"max-reconnects\", value);\n }\n\n // Incoming binary frame representation. Backed by the `binary-type` attribute;\n // any value other than \"arraybuffer\" normalizes to the platform default \"blob\".\n get binaryType(): BinaryType {\n return this.getAttribute(\"binary-type\") === \"arraybuffer\" ? \"arraybuffer\" : \"blob\";\n }\n\n set binaryType(value: string | null | undefined) {\n reflectAttribute(this, \"binary-type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get message(): any {\n return this._core.message;\n }\n\n get connected(): boolean {\n return this._core.connected;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readyState(): number {\n return this._core.readyState;\n }\n\n // --- Command properties ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n this._trigger = true;\n this.connect();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-ws:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // `send` is a write-only command surface: assigning transmits immediately.\n // Reading always returns null (no payload is retained) — consistent with the\n // null carried by wcs-ws:send-changed and the documented \"resets to null\".\n get send(): any {\n return null;\n }\n\n set send(data: any) {\n if (data === null || data === undefined) return;\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n this._core.send(payload);\n this.dispatchEvent(new CustomEvent(\"wcs-ws:send-changed\", {\n detail: null,\n bubbles: true,\n }));\n }\n\n // --- Public methods ---\n\n connect(): void {\n const protocols = this.protocols\n ? this.protocols.split(\",\").map(p => p.trim()).filter(Boolean)\n : undefined;\n\n this._core.connect(this.url, {\n protocols: protocols && protocols.length === 1 ? protocols[0] : protocols,\n autoReconnect: this.autoReconnect,\n reconnectInterval: this.reconnectInterval,\n maxReconnects: this.maxReconnects,\n binaryType: this.binaryType,\n });\n }\n\n sendMessage(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n this._core.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._core.close(code, reason);\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n // 再接続するのは url が「変わった」ときだけ。同じ値の書き込み(url の setter 自身の\n // setAttribute の後に、属性も書く binder — @wcstack/state 3.x の inputs[].attribute ミラー —\n // が同じ値を書く、など)\n // は何もしない。connectedCallback より前(upgrade 中・DOM の外)の変化は、\n // connectedCallback がそのときの url で 1 回だけ接続する。\n if (name === \"url\" && oldValue !== newValue && this._attached && !this.manual && newValue) {\n this.connect();\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)。\n // ここで url の setter が走っても _attached はまだ false なので接続しない —\n // 接続は下で、取り込み後の url / manual を見て 1 回だけ行う。\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() は command-driven node では ready を返す no-op(§3.5)。SSR は\n // connectedCallbackPromise を await して初期スナップショットを取れる。\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.url) {\n this.connect();\n }\n this._attached = true;\n }\n\n disconnectedCallback(): void {\n this._attached = false;\n // dispose() が _gen を bump して進行中のソケット/再接続を無効化し、close() する。\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWebSocket(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsWebSocket } from \"./components/WebSocket.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.ws)) {\n registry.define(config.tagNames.ws, WcsWebSocket);\n }\n}\n"],"names":["config","triggerAttribute","tagNames","ws","WCS_WEBSOCKET_ERROR_CODE","WebSocketCore","EventTarget","static","protocol","version","properties","name","event","semantics","commands","_target","_ws","_message","_connected","_loading","_error","_errorInfo","_readyState","_autoReconnect","_reconnectInterval","_maxReconnects","Infinity","_reconnectCount","_reconnectTimer","_url","_protocols","undefined","_binaryType","_intentionalClose","_gen","_socketGen","_ready","Promise","resolve","constructor","target","super","this","ready","observe","dispose","close","message","connected","loading","error","errorInfo","readyState","_setMessage","dispatchEvent","CustomEvent","detail","bubbles","_setConnected","_setLoading","_setError","code","_commitErrorInfo","raw","phase","recoverable","deriveWebSocketErrorInfo","info","_setReadyState","connect","url","options","_closeInternal","protocols","autoReconnect","reconnectInterval","maxReconnects","binaryType","_doConnect","send","data","reason","_clearReconnectTimer","WebSocket","e","addEventListener","_onOpen","_onMessage","_onError","_onClose","JSON","parse","_removeListeners","_scheduleReconnect","gen","setTimeout","clearTimeout","removeEventListener","registered","handleClick","Element","triggerElement","closest","wsId","getAttribute","WsCtor","customElements","get","wsElement","document","getElementById","preventDefault","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","set","initialAttributes","WeakMap","initialAttribute","el","byName","Map","has","writeAttribute","value","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsWebSocket","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_trigger","_connectedCallbackPromise","_internals","_attached","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","attr","parsed","parseInt","Number","isNaN","manual","trigger","payload","stringify","split","p","trim","filter","Boolean","length","sendMessage","attributeChangedCallback","oldValue","newValue","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","define","registerComponents"],"mappings":"AAUA,MA4BaA,EA5BoB,CAE/BC,iBAAkB,gBAClBC,SAAU,CACRC,GAAI,WCSKC,EAEM,mBAFNA,EAIG,gBAJHA,EASM,mBCTb,MAAOC,UAAsBC,YACjCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,UAAWC,MAAO,iBAAkBC,UAAW,SACvD,CAAEF,KAAM,YAAaC,MAAO,2BAA4BC,UAAW,SACnE,CAAEF,KAAM,UAAWC,MAAO,yBAA0BC,UAAW,SAC/D,CAAEF,KAAM,QAASC,MAAO,eAAgBC,UAAW,SAMnD,CAAEF,KAAM,YAAaC,MAAO,4BAA6BC,UAAW,SACpE,CAAEF,KAAM,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6D,CAAmBF"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/websocketCapabilities.ts","../src/core/WebSocketCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/WebSocket.ts","../src/bootstrapWebSocket.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n ws: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-wstarget\",\n tagNames: {\n ws: \"wcs-ws\",\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: `bootstrapWebSocket` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/websocket] bootstrapWebSocket: \"${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 [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * websocketCapabilities.ts\n *\n * WebSocket node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。WebSocket は持続的な session / monitor node(1 本の接続を張り続ける)で、\n * 競合する operation を持たないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * この node の `_setError` は 4 形態の非 null 入力を受ける(いずれも公開 `error` shape は不変):\n * 1. synthetic な `{ message: \"url is required.\" }`(`.name` 無し)— connect() の引数不備。\n * 2. synthetic な `{ message: \"WebSocket is not connected.\" }`(`.name` 無し)— open 前の send()。\n * 3. caught された生の構築例外 `e`(`new WebSocket()` の同期 throw)。\n * 4. platform の WebSocket `error` Event(`Event`。`.name`/`.message` を持たない)。\n *\n * これらは shape がバラバラで、message からの分類は脆い。そこで呼び出し側が明示的な\n * taxonomy code を discriminator として渡す(storage の `deriveStorageErrorInfo(error, name)`\n * と同じ技法)。derive 側は synthetic / Event / Error を reverse-engineer せず、渡された\n * code で phase / recoverable を決め、message だけを防御的に抽出する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した websocket error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WEBSOCKET_ERROR_CODE = {\n /** connect() の `url` 未指定 — 開始前の入力不備。retry では回復しない。 */\n InvalidArgument: \"invalid-argument\",\n /** open 前の send() — 接続が OPEN でない状態での送信。retry では回復しない(先に connect が要る)。 */\n InvalidState: \"invalid-state\",\n /**\n * 接続の確立 / 維持に失敗(`new WebSocket()` の同期例外、または platform の error Event)。\n * WebSocket のエラーは通常一過性で、再接続で回復しうる(recoverable=true)。\n */\n ConnectionError: \"connection-error\",\n} as const;\n\n/**\n * websocket の失敗を serializable な error taxonomy に写す。`code` は呼び出し側が渡す\n * discriminator(公開 `error` shape からは復元しない)。`message` は入力から防御的に抽出し、\n * message を持たない error Event 等では安定した fallback を使う。\n *\n * - `invalid-argument`(url 未指定)は開始前の入力不備 → phase=\"start\" / recoverable=false。\n * - `invalid-state`(open 前 send)は接続状態が満たされない実行時失敗 → phase=\"execute\" /\n * recoverable=false(先に connect() が必要)。\n * - `connection-error`(構築例外 / error Event)は接続の確立 / 維持失敗 → phase=\"execute\" /\n * recoverable=true(再接続で回復しうる)。\n */\nexport function deriveWebSocketErrorInfo(error: unknown, code: string): WcsIoErrorInfo {\n // error は非 null(_setError は error===null を derive 前に分岐する)だが、synthetic /\n // Event / caught 例外 / 生 throw と shape がバラバラなので message は防御的に抽出する。\n // error Event は message を持たないため安定した fallback に落とす。\n const raw = (error as { message?: unknown }).message;\n const message = typeof raw === \"string\" ? raw : \"WebSocket connection error\";\n\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidArgument) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidState) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidState, phase: \"execute\", recoverable: false, message };\n }\n // connection-error(構築例外 / error Event): 接続の確立/維持失敗、再接続で回復しうる。\n return { code: WCS_WEBSOCKET_ERROR_CODE.ConnectionError, phase: \"execute\", recoverable: true, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWebSocketErrorInfo, WCS_WEBSOCKET_ERROR_CODE } from \"./websocketCapabilities.js\";\n\n// WebSocket readyState values. Hardcoded rather than read from the global\n// WebSocket so the Core does not require WebSocket to exist at module load\n// (referencing `WebSocket.CLOSED` in a field initializer evaluates at class\n// definition time; tests inject a mock). Mirrors SseCore's SSE_CLOSED.\nconst WS_CONNECTING = 0;\nconst WS_OPEN = 1;\nconst WS_CLOSED = 3;\n\nexport interface WebSocketConnectOptions {\n protocols?: string | string[];\n autoReconnect?: boolean;\n reconnectInterval?: number;\n maxReconnects?: number;\n // How incoming binary frames are surfaced on `message`. \"blob\" (the platform\n // default) or \"arraybuffer\" for direct byte processing. Applied to every\n // socket this connection spawns, including auto-reconnects.\n binaryType?: BinaryType;\n}\n\nexport class WebSocketCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"message\", event: \"wcs-ws:message\", semantics: \"event\" },\n { name: \"connected\", event: \"wcs-ws:connected-changed\", semantics: \"state\" },\n { name: \"loading\", event: \"wcs-ws:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-ws:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (invalid-argument / invalid-state\n // / connection-error); the existing `error` property/event are unchanged. Fires\n // wcs-ws:error-info-changed. No lane — WebSocket is a persistent session/monitor\n // node, not a competing operation.\n { name: \"errorInfo\", event: \"wcs-ws:error-info-changed\", semantics: \"state\" },\n { name: \"readyState\", event: \"wcs-ws:readystate-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"send\" },\n { name: \"close\" },\n ],\n };\n\n private _target: EventTarget;\n private _ws: WebSocket | null = null;\n private _message: any = null;\n private _connected: boolean = false;\n private _loading: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readyState: number = WS_CLOSED;\n\n // 自動再接続\n private _autoReconnect: boolean = false;\n private _reconnectInterval: number = 3000;\n private _maxReconnects: number = Infinity;\n private _reconnectCount: number = 0;\n private _reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n private _url: string = \"\";\n private _protocols: string | string[] | undefined = undefined;\n private _binaryType: BinaryType = \"blob\";\n private _intentionalClose: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and at every connect(). A socket\n // event (open/message/error/close) or a scheduled reconnect that fires after\n // dispose / a superseding connect() carries a stale `gen` and MUST NOT write\n // state onto a torn-down element. A boolean flag is insufficient (dispose→observe\n // would let stale work slip through).\n private _gen = 0;\n // Generation captured when the current socket was opened. The shared socket\n // event handlers compare it against _gen to drop events from a superseded /\n // disposed connection.\n private _socketGen = 0;\n // SSR (§3.8): WebSocket is command-driven with no asynchronous probe to await,\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n /**\n * Whether `[wcs/command-not-ready]` was said for this element: a `send()` refused because the\n * element is not ready loses what it carried, and `error` alone told only a page that binds it.\n * Said once per element (docs/v4-direction-2026-10.md, the I/O command policy).\n */\n private _toldNotReady = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). WebSocket connections are command-driven (connect()), so\n // observe() is an idempotent no-op that resolves once ready; the Shell's\n // connectedCallback does not auto-establish a subscription here. dispose()\n // invalidates any in-flight socket / pending reconnect and closes the socket.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.close();\n }\n\n get message(): any {\n return this._message;\n }\n\n get connected(): boolean {\n return this._connected;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-ws:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readyState(): number {\n return this._readyState;\n }\n\n // --- State setters with event dispatch ---\n\n private _setMessage(message: any): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:message\", {\n detail: message,\n bubbles: true,\n }));\n }\n\n private _setConnected(connected: boolean): void {\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:connected-changed\", {\n detail: connected,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n // `code` is an explicit taxonomy discriminator (WCS_WEBSOCKET_ERROR_CODE), passed\n // only from the non-null failure call sites. It stays out of the public `error`\n // shape and is used solely to classify errorInfo without reverse-engineering the\n // heterogeneous `error` values (synthetic {message} / caught Error / raw Event).\n // The clear path passes null and no code.\n private _setError(error: any, code?: string): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every connect/send start\n // clears a usually-already-null error) avoids a spurious wcs-ws:error per\n // successful operation. Reference identity is sufficient: each failure builds\n // a fresh object (or the platform's own error Event), and the clear path\n // always passes null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // explicit `code` (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. Every non-null error carries a code (the clear path is the only\n // caller without one, and it is short-circuited here), so `code!` holds.\n this._commitErrorInfo(error === null ? null : deriveWebSocketErrorInfo(error, code!));\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadyState(readyState: number): void {\n this._readyState = readyState;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:readystate-changed\", {\n detail: readyState,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n connect(url: string, options: WebSocketConnectOptions = {}): void {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(なにもしない)を返す。command-token 経路(set trigger →\n // connect())からの呼び出しが state 更新サイクルを壊さないようにする。\n if (!url) {\n this._setError({ message: \"url is required.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidArgument);\n return;\n }\n\n // 新しい接続を開始するため世代を更新し、進行中のソケット/再接続を無効化する。\n this._gen++;\n\n // 既存の接続をクローズ\n this._intentionalClose = true;\n this._closeInternal();\n\n this._url = url;\n this._protocols = options.protocols;\n this._autoReconnect = options.autoReconnect ?? false;\n this._reconnectInterval = options.reconnectInterval ?? 3000;\n this._maxReconnects = options.maxReconnects ?? Infinity;\n this._binaryType = options.binaryType ?? \"blob\";\n this._reconnectCount = 0;\n this._intentionalClose = false;\n\n this._doConnect();\n }\n\n send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n // never-throw (§3.6): 未接続での送信は例外ではなく error に流す。set send の\n // fire-and-forget 経路で例外が伝播するのを防ぐ。\n if (!this._ws || this._ws.readyState !== WS_OPEN) {\n this._setError({ message: \"WebSocket is not connected.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidState);\n this._warnNotReady();\n return;\n }\n this._ws.send(data);\n }\n\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n \"[@wcstack/websocket] [wcs/command-not-ready] send() was refused: the WebSocket is not connected, so the message is lost. \" +\n \"It goes to `error` too. Send once `connected` is true. (Said once per element.)\",\n this._target,\n );\n }\n\n close(code?: number, reason?: string): void {\n this._intentionalClose = true;\n this._clearReconnectTimer();\n if (this._ws) {\n this._ws.close(code, reason);\n }\n }\n\n // --- Internal ---\n\n private _doConnect(): void {\n this._setLoading(true);\n this._setError(null);\n\n // 接続開始時点の世代を捕捉。dispose()/再 connect() 後に発火した古いソケット\n // イベントはこの gen が stale になり、状態を書き換えない(_onOpen ほかが\n // _socketGen と this._gen を突き合わせて判定する)。\n this._socketGen = this._gen;\n\n try {\n this._ws = this._protocols\n ? new WebSocket(this._url, this._protocols)\n : new WebSocket(this._url);\n } catch (e) {\n this._setLoading(false);\n this._setError(e, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n return;\n }\n\n // Binary frames default to Blob; opt into ArrayBuffer for direct byte access.\n this._ws.binaryType = this._binaryType;\n\n this._setReadyState(WS_CONNECTING);\n\n this._ws.addEventListener(\"open\", this._onOpen);\n this._ws.addEventListener(\"message\", this._onMessage);\n this._ws.addEventListener(\"error\", this._onError);\n this._ws.addEventListener(\"close\", this._onClose);\n }\n\n private _onOpen = (): void => {\n if (this._socketGen !== this._gen) return;\n this._reconnectCount = 0;\n this._setLoading(false);\n this._setConnected(true);\n this._setReadyState(WS_OPEN);\n };\n\n private _onMessage = (event: MessageEvent): void => {\n if (this._socketGen !== this._gen) return;\n let data = event.data;\n // JSONの自動パース\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch {\n // テキストのまま\n }\n }\n this._setMessage(data);\n };\n\n private _onError = (event: Event): void => {\n if (this._socketGen !== this._gen) return;\n this._setError(event, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n };\n\n private _onClose = (event: CloseEvent): void => {\n this._removeListeners();\n this._ws = null;\n if (this._socketGen !== this._gen) return;\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\n\n // 異常クローズ時の自動再接続(正常終了 1000 は除外)\n if (!this._intentionalClose && this._autoReconnect && event.code !== 1000 && this._reconnectCount < this._maxReconnects) {\n this._scheduleReconnect();\n }\n };\n\n private _scheduleReconnect(): void {\n const gen = this._gen;\n this._clearReconnectTimer();\n this._reconnectTimer = setTimeout(() => {\n this._reconnectTimer = null;\n // dispose()/再 connect() でこの再接続が無効化されていたら何もしない。\n if (gen !== this._gen) return;\n this._reconnectCount++;\n this._doConnect();\n }, this._reconnectInterval);\n }\n\n private _clearReconnectTimer(): void {\n if (this._reconnectTimer !== null) {\n clearTimeout(this._reconnectTimer);\n this._reconnectTimer = null;\n }\n }\n\n private _removeListeners(): void {\n if (!this._ws) {\n return;\n }\n\n this._ws.removeEventListener(\"open\", this._onOpen);\n this._ws.removeEventListener(\"message\", this._onMessage);\n this._ws.removeEventListener(\"error\", this._onError);\n this._ws.removeEventListener(\"close\", this._onClose);\n }\n\n private _closeInternal(): void {\n this._clearReconnectTimer();\n if (this._ws) {\n this._removeListeners();\n if (this._ws.readyState === WS_OPEN || this._ws.readyState === WS_CONNECTING) {\n this._ws.close();\n }\n this._ws = null;\n }\n // 旧接続の状態をリセット(コンストラクタ例外時に stale 状態が残るのを防止)\n if (this._connected) {\n this._setConnected(false);\n }\n if (this._readyState !== WS_CLOSED) {\n this._setReadyState(WS_CLOSED);\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsWebSocket } from \"./components/WebSocket.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const wsId = triggerElement.getAttribute(config.triggerAttribute);\n if (!wsId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsWebSocket as a value. The value import created a components/WebSocket.ts ⇄\n // autoTrigger.ts cycle (WcsWebSocket.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-ws> class\n // matches — without the import cycle.\n const WsCtor = customElements.get(config.tagNames.ws);\n const wsElement = document.getElementById(wsId);\n if (!WsCtor || !(wsElement instanceof WsCtor)) return;\n\n event.preventDefault();\n (wsElement as WcsWebSocket).connect();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { WebSocketCore } from \"../core/WebSocketCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nexport class WcsWebSocket extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...WebSocketCore.wcBindable,\n properties: [\n ...WebSocketCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-ws:trigger-changed\", semantics: \"state\" },\n { name: \"send\", event: \"wcs-ws:send-changed\", semantics: \"state\" },\n ],\n inputs: [\n { name: \"url\", attribute: \"url\" },\n { name: \"protocols\", attribute: \"protocols\" },\n { name: \"autoReconnect\", attribute: \"auto-reconnect\" },\n { name: \"reconnectInterval\", attribute: \"reconnect-interval\" },\n { name: \"maxReconnects\", attribute: \"max-reconnects\" },\n { name: \"binaryType\", attribute: \"binary-type\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n { name: \"send\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"sendMessage\" },\n { name: \"close\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: WebSocketCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // connectedCallback が接続の判断を終えてから disconnectedCallback までの間だけ true。\n // url 属性の変化による再接続はこの間に限る — upgrade 時は attributeChangedCallback が\n // connectedCallback より先に(isConnected のまま)呼ばれるので、そこで接続すると\n // connectedCallback の接続と合わせて 2 本になる。初回の接続は connectedCallback が持つ。\n private _attached = false;\n\n constructor() {\n super();\n this._core = new WebSocketCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-ws:connected-changed\": (d) => ({ connected: d === true }),\n \"wcs-ws:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-ws:error\": (d) => ({ error: d != null }),\n });\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\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\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\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 //\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" url would reconnect to \"undefined\"): `null` removes the\n // attribute (the documented default; an empty url does not connect),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null | undefined) {\n reflectAttribute(this, \"url\", value);\n }\n\n get protocols(): string {\n return this.getAttribute(\"protocols\") || \"\";\n }\n\n set protocols(value: string | null | undefined) {\n reflectAttribute(this, \"protocols\", value);\n }\n\n get autoReconnect(): boolean {\n return this.hasAttribute(\"auto-reconnect\");\n }\n\n set autoReconnect(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"auto-reconnect\", value);\n }\n\n get reconnectInterval(): number {\n const attr = this.getAttribute(\"reconnect-interval\");\n const parsed = attr ? parseInt(attr, 10) : 3000;\n return Number.isNaN(parsed) ? 3000 : parsed;\n }\n\n set reconnectInterval(value: number | null | undefined) {\n reflectAttribute(this, \"reconnect-interval\", value);\n }\n\n get maxReconnects(): number {\n const attr = this.getAttribute(\"max-reconnects\");\n const parsed = attr ? parseInt(attr, 10) : Infinity;\n return Number.isNaN(parsed) ? Infinity : parsed;\n }\n\n set maxReconnects(value: number | null | undefined) {\n reflectAttribute(this, \"max-reconnects\", value);\n }\n\n // Incoming binary frame representation. Backed by the `binary-type` attribute;\n // any value other than \"arraybuffer\" normalizes to the platform default \"blob\".\n get binaryType(): BinaryType {\n return this.getAttribute(\"binary-type\") === \"arraybuffer\" ? \"arraybuffer\" : \"blob\";\n }\n\n set binaryType(value: string | null | undefined) {\n reflectAttribute(this, \"binary-type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get message(): any {\n return this._core.message;\n }\n\n get connected(): boolean {\n return this._core.connected;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readyState(): number {\n return this._core.readyState;\n }\n\n // --- Command properties ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n this._trigger = true;\n this.connect();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-ws:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // `send` is a write-only command surface: assigning transmits immediately.\n // Reading always returns null (no payload is retained) — consistent with the\n // null carried by wcs-ws:send-changed and the documented \"resets to null\".\n get send(): any {\n return null;\n }\n\n set send(data: any) {\n if (data === null || data === undefined) return;\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n this._core.send(payload);\n this.dispatchEvent(new CustomEvent(\"wcs-ws:send-changed\", {\n detail: null,\n bubbles: true,\n }));\n }\n\n // --- Public methods ---\n\n connect(): void {\n const protocols = this.protocols\n ? this.protocols.split(\",\").map(p => p.trim()).filter(Boolean)\n : undefined;\n\n this._core.connect(this.url, {\n protocols: protocols && protocols.length === 1 ? protocols[0] : protocols,\n autoReconnect: this.autoReconnect,\n reconnectInterval: this.reconnectInterval,\n maxReconnects: this.maxReconnects,\n binaryType: this.binaryType,\n });\n }\n\n sendMessage(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n this._core.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._core.close(code, reason);\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n // 再接続するのは url が「変わった」ときだけ。同じ値の書き込み(url の setter 自身の\n // setAttribute の後に、属性も書く binder — @wcstack/state 3.x の inputs[].attribute ミラー —\n // が同じ値を書く、など)\n // は何もしない。connectedCallback より前(upgrade 中・DOM の外)の変化は、\n // connectedCallback がそのときの url で 1 回だけ接続する。\n if (name === \"url\" && oldValue !== newValue && this._attached && !this.manual && newValue) {\n this.connect();\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)。\n // ここで url の setter が走っても _attached はまだ false なので接続しない —\n // 接続は下で、取り込み後の url / manual を見て 1 回だけ行う。\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() は command-driven node では ready を返す no-op(§3.5)。SSR は\n // connectedCallbackPromise を await して初期スナップショットを取れる。\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.url) {\n this.connect();\n }\n this._attached = true;\n }\n\n disconnectedCallback(): void {\n this._attached = false;\n // dispose() が _gen を bump して進行中のソケット/再接続を無効化し、close() する。\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWebSocket(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsWebSocket } from \"./components/WebSocket.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.ws)) {\n registry.define(config.tagNames.ws, WcsWebSocket);\n }\n}\n"],"names":["config","triggerAttribute","tagNames","ws","WCS_WEBSOCKET_ERROR_CODE","WebSocketCore","EventTarget","static","protocol","version","properties","name","event","semantics","commands","_target","_ws","_message","_connected","_loading","_error","_errorInfo","_readyState","_autoReconnect","_reconnectInterval","_maxReconnects","Infinity","_reconnectCount","_reconnectTimer","_url","_protocols","undefined","_binaryType","_intentionalClose","_gen","_socketGen","_ready","Promise","resolve","_toldNotReady","constructor","target","super","this","ready","observe","dispose","close","message","connected","loading","error","errorInfo","readyState","_setMessage","dispatchEvent","CustomEvent","detail","bubbles","_setConnected","_setLoading","_setError","code","_commitErrorInfo","raw","phase","recoverable","deriveWebSocketErrorInfo","info","_setReadyState","connect","url","options","_closeInternal","protocols","autoReconnect","reconnectInterval","maxReconnects","binaryType","_doConnect","send","data","_warnNotReady","console","warn","reason","_clearReconnectTimer","WebSocket","e","addEventListener","_onOpen","_onMessage","_onError","_onClose","JSON","parse","_removeListeners","_scheduleReconnect","gen","setTimeout","clearTimeout","removeEventListener","registered","handleClick","Element","triggerElement","closest","wsId","getAttribute","WsCtor","customElements","get","wsElement","document","getElementById","preventDefault","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","set","initialAttributes","WeakMap","initialAttribute","el","byName","Map","has","writeAttribute","value","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsWebSocket","HTMLElement","wcBindable","inputs","attribute","observedAttributes","_core","_trigger","_connectedCallbackPromise","_internals","_attached","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","attr","parsed","parseInt","Number","isNaN","manual","trigger","payload","stringify","split","p","trim","filter","Boolean","length","sendMessage","attributeChangedCallback","oldValue","newValue","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","define","registerComponents"],"mappings":"AAUA,MA4BaA,EA5BoB,CAE/BC,iBAAkB,gBAClBC,SAAU,CACRC,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5C,MAAMqL,EAASN,EACTvD,EAAQ6D,EAAOrL,UACdqL,EAAOrL,GACdqL,EAAOrL,GAAQwH,CACjB,CACF,CEyNI8D,CAAkBtJ,MAClBA,KAAKuJ,MAAMC,QAAU,OHvPnB7F,IACJA,GAAa,EACbW,SAASxB,iBAAiB,QAASc,IG2PjC5D,KAAKuG,0BAA4BvG,KAAKqG,MAAMnG,WACvCF,KAAKgI,QAAUhI,KAAK4B,KACvB5B,KAAK2B,UAEP3B,KAAKyG,WAAY,CACnB,CAEA,oBAAAgD,GACEzJ,KAAKyG,WAAY,EAEjBzG,KAAKqG,MAAMlG,SACb,EClSI,IAA2DuJ,GCI3D,SAA6BA,EAAkCvF,gBAC9DuF,EAAStF,IAAI/G,EAAOE,SAASC,KAChCkM,EAASC,OAAOtM,EAAOE,SAASC,GAAIuI,EAExC,CDJE6D,CAAmBF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,12 @@ declare class WebSocketCore extends EventTarget {
|
|
|
153
153
|
private _gen;
|
|
154
154
|
private _socketGen;
|
|
155
155
|
private _ready;
|
|
156
|
+
/**
|
|
157
|
+
* Whether `[wcs/command-not-ready]` was said for this element: a `send()` refused because the
|
|
158
|
+
* element is not ready loses what it carried, and `error` alone told only a page that binds it.
|
|
159
|
+
* Said once per element (docs/v4-direction-2026-10.md, the I/O command policy).
|
|
160
|
+
*/
|
|
161
|
+
private _toldNotReady;
|
|
156
162
|
constructor(target?: EventTarget);
|
|
157
163
|
get ready(): Promise<void>;
|
|
158
164
|
observe(): Promise<void>;
|
|
@@ -177,6 +183,7 @@ declare class WebSocketCore extends EventTarget {
|
|
|
177
183
|
private _setReadyState;
|
|
178
184
|
connect(url: string, options?: WebSocketConnectOptions): void;
|
|
179
185
|
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
|
|
186
|
+
private _warnNotReady;
|
|
180
187
|
close(code?: number, reason?: string): void;
|
|
181
188
|
private _doConnect;
|
|
182
189
|
private _onOpen;
|
package/dist/index.esm.js
CHANGED
|
@@ -184,6 +184,12 @@ class WebSocketCore extends EventTarget {
|
|
|
184
184
|
// SSR (§3.8): WebSocket is command-driven with no asynchronous probe to await,
|
|
185
185
|
// so readiness is immediate.
|
|
186
186
|
_ready = Promise.resolve();
|
|
187
|
+
/**
|
|
188
|
+
* Whether `[wcs/command-not-ready]` was said for this element: a `send()` refused because the
|
|
189
|
+
* element is not ready loses what it carried, and `error` alone told only a page that binds it.
|
|
190
|
+
* Said once per element (docs/v4-direction-2026-10.md, the I/O command policy).
|
|
191
|
+
*/
|
|
192
|
+
_toldNotReady = false;
|
|
187
193
|
constructor(target) {
|
|
188
194
|
super();
|
|
189
195
|
this._target = target ?? this;
|
|
@@ -320,10 +326,18 @@ class WebSocketCore extends EventTarget {
|
|
|
320
326
|
// fire-and-forget 経路で例外が伝播するのを防ぐ。
|
|
321
327
|
if (!this._ws || this._ws.readyState !== WS_OPEN) {
|
|
322
328
|
this._setError({ message: "WebSocket is not connected." }, WCS_WEBSOCKET_ERROR_CODE.InvalidState);
|
|
329
|
+
this._warnNotReady();
|
|
323
330
|
return;
|
|
324
331
|
}
|
|
325
332
|
this._ws.send(data);
|
|
326
333
|
}
|
|
334
|
+
_warnNotReady() {
|
|
335
|
+
if (this._toldNotReady)
|
|
336
|
+
return;
|
|
337
|
+
this._toldNotReady = true;
|
|
338
|
+
console.warn("[@wcstack/websocket] [wcs/command-not-ready] send() was refused: the WebSocket is not connected, so the message is lost. " +
|
|
339
|
+
"It goes to `error` too. Send once `connected` is true. (Said once per element.)", this._target);
|
|
340
|
+
}
|
|
327
341
|
close(code, reason) {
|
|
328
342
|
this._intentionalClose = true;
|
|
329
343
|
this._clearReconnectTimer();
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/websocketCapabilities.ts","../src/core/WebSocketCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/WebSocket.ts","../src/registerComponents.ts","../src/bootstrapWebSocket.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n ws: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-wstarget\",\n tagNames: {\n ws: \"wcs-ws\",\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: `bootstrapWebSocket` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/websocket] bootstrapWebSocket: \"${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 [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * websocketCapabilities.ts\n *\n * WebSocket node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。WebSocket は持続的な session / monitor node(1 本の接続を張り続ける)で、\n * 競合する operation を持たないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * この node の `_setError` は 4 形態の非 null 入力を受ける(いずれも公開 `error` shape は不変):\n * 1. synthetic な `{ message: \"url is required.\" }`(`.name` 無し)— connect() の引数不備。\n * 2. synthetic な `{ message: \"WebSocket is not connected.\" }`(`.name` 無し)— open 前の send()。\n * 3. caught された生の構築例外 `e`(`new WebSocket()` の同期 throw)。\n * 4. platform の WebSocket `error` Event(`Event`。`.name`/`.message` を持たない)。\n *\n * これらは shape がバラバラで、message からの分類は脆い。そこで呼び出し側が明示的な\n * taxonomy code を discriminator として渡す(storage の `deriveStorageErrorInfo(error, name)`\n * と同じ技法)。derive 側は synthetic / Event / Error を reverse-engineer せず、渡された\n * code で phase / recoverable を決め、message だけを防御的に抽出する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した websocket error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WEBSOCKET_ERROR_CODE = {\n /** connect() の `url` 未指定 — 開始前の入力不備。retry では回復しない。 */\n InvalidArgument: \"invalid-argument\",\n /** open 前の send() — 接続が OPEN でない状態での送信。retry では回復しない(先に connect が要る)。 */\n InvalidState: \"invalid-state\",\n /**\n * 接続の確立 / 維持に失敗(`new WebSocket()` の同期例外、または platform の error Event)。\n * WebSocket のエラーは通常一過性で、再接続で回復しうる(recoverable=true)。\n */\n ConnectionError: \"connection-error\",\n} as const;\n\n/**\n * websocket の失敗を serializable な error taxonomy に写す。`code` は呼び出し側が渡す\n * discriminator(公開 `error` shape からは復元しない)。`message` は入力から防御的に抽出し、\n * message を持たない error Event 等では安定した fallback を使う。\n *\n * - `invalid-argument`(url 未指定)は開始前の入力不備 → phase=\"start\" / recoverable=false。\n * - `invalid-state`(open 前 send)は接続状態が満たされない実行時失敗 → phase=\"execute\" /\n * recoverable=false(先に connect() が必要)。\n * - `connection-error`(構築例外 / error Event)は接続の確立 / 維持失敗 → phase=\"execute\" /\n * recoverable=true(再接続で回復しうる)。\n */\nexport function deriveWebSocketErrorInfo(error: unknown, code: string): WcsIoErrorInfo {\n // error は非 null(_setError は error===null を derive 前に分岐する)だが、synthetic /\n // Event / caught 例外 / 生 throw と shape がバラバラなので message は防御的に抽出する。\n // error Event は message を持たないため安定した fallback に落とす。\n const raw = (error as { message?: unknown }).message;\n const message = typeof raw === \"string\" ? raw : \"WebSocket connection error\";\n\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidArgument) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidState) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidState, phase: \"execute\", recoverable: false, message };\n }\n // connection-error(構築例外 / error Event): 接続の確立/維持失敗、再接続で回復しうる。\n return { code: WCS_WEBSOCKET_ERROR_CODE.ConnectionError, phase: \"execute\", recoverable: true, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWebSocketErrorInfo, WCS_WEBSOCKET_ERROR_CODE } from \"./websocketCapabilities.js\";\n\n// WebSocket readyState values. Hardcoded rather than read from the global\n// WebSocket so the Core does not require WebSocket to exist at module load\n// (referencing `WebSocket.CLOSED` in a field initializer evaluates at class\n// definition time; tests inject a mock). Mirrors SseCore's SSE_CLOSED.\nconst WS_CONNECTING = 0;\nconst WS_OPEN = 1;\nconst WS_CLOSED = 3;\n\nexport interface WebSocketConnectOptions {\n protocols?: string | string[];\n autoReconnect?: boolean;\n reconnectInterval?: number;\n maxReconnects?: number;\n // How incoming binary frames are surfaced on `message`. \"blob\" (the platform\n // default) or \"arraybuffer\" for direct byte processing. Applied to every\n // socket this connection spawns, including auto-reconnects.\n binaryType?: BinaryType;\n}\n\nexport class WebSocketCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"message\", event: \"wcs-ws:message\", semantics: \"event\" },\n { name: \"connected\", event: \"wcs-ws:connected-changed\", semantics: \"state\" },\n { name: \"loading\", event: \"wcs-ws:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-ws:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (invalid-argument / invalid-state\n // / connection-error); the existing `error` property/event are unchanged. Fires\n // wcs-ws:error-info-changed. No lane — WebSocket is a persistent session/monitor\n // node, not a competing operation.\n { name: \"errorInfo\", event: \"wcs-ws:error-info-changed\", semantics: \"state\" },\n { name: \"readyState\", event: \"wcs-ws:readystate-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"send\" },\n { name: \"close\" },\n ],\n };\n\n private _target: EventTarget;\n private _ws: WebSocket | null = null;\n private _message: any = null;\n private _connected: boolean = false;\n private _loading: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readyState: number = WS_CLOSED;\n\n // 自動再接続\n private _autoReconnect: boolean = false;\n private _reconnectInterval: number = 3000;\n private _maxReconnects: number = Infinity;\n private _reconnectCount: number = 0;\n private _reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n private _url: string = \"\";\n private _protocols: string | string[] | undefined = undefined;\n private _binaryType: BinaryType = \"blob\";\n private _intentionalClose: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and at every connect(). A socket\n // event (open/message/error/close) or a scheduled reconnect that fires after\n // dispose / a superseding connect() carries a stale `gen` and MUST NOT write\n // state onto a torn-down element. A boolean flag is insufficient (dispose→observe\n // would let stale work slip through).\n private _gen = 0;\n // Generation captured when the current socket was opened. The shared socket\n // event handlers compare it against _gen to drop events from a superseded /\n // disposed connection.\n private _socketGen = 0;\n // SSR (§3.8): WebSocket is command-driven with no asynchronous probe to await,\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). WebSocket connections are command-driven (connect()), so\n // observe() is an idempotent no-op that resolves once ready; the Shell's\n // connectedCallback does not auto-establish a subscription here. dispose()\n // invalidates any in-flight socket / pending reconnect and closes the socket.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.close();\n }\n\n get message(): any {\n return this._message;\n }\n\n get connected(): boolean {\n return this._connected;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-ws:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readyState(): number {\n return this._readyState;\n }\n\n // --- State setters with event dispatch ---\n\n private _setMessage(message: any): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:message\", {\n detail: message,\n bubbles: true,\n }));\n }\n\n private _setConnected(connected: boolean): void {\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:connected-changed\", {\n detail: connected,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n // `code` is an explicit taxonomy discriminator (WCS_WEBSOCKET_ERROR_CODE), passed\n // only from the non-null failure call sites. It stays out of the public `error`\n // shape and is used solely to classify errorInfo without reverse-engineering the\n // heterogeneous `error` values (synthetic {message} / caught Error / raw Event).\n // The clear path passes null and no code.\n private _setError(error: any, code?: string): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every connect/send start\n // clears a usually-already-null error) avoids a spurious wcs-ws:error per\n // successful operation. Reference identity is sufficient: each failure builds\n // a fresh object (or the platform's own error Event), and the clear path\n // always passes null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // explicit `code` (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. Every non-null error carries a code (the clear path is the only\n // caller without one, and it is short-circuited here), so `code!` holds.\n this._commitErrorInfo(error === null ? null : deriveWebSocketErrorInfo(error, code!));\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadyState(readyState: number): void {\n this._readyState = readyState;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:readystate-changed\", {\n detail: readyState,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n connect(url: string, options: WebSocketConnectOptions = {}): void {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(なにもしない)を返す。command-token 経路(set trigger →\n // connect())からの呼び出しが state 更新サイクルを壊さないようにする。\n if (!url) {\n this._setError({ message: \"url is required.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidArgument);\n return;\n }\n\n // 新しい接続を開始するため世代を更新し、進行中のソケット/再接続を無効化する。\n this._gen++;\n\n // 既存の接続をクローズ\n this._intentionalClose = true;\n this._closeInternal();\n\n this._url = url;\n this._protocols = options.protocols;\n this._autoReconnect = options.autoReconnect ?? false;\n this._reconnectInterval = options.reconnectInterval ?? 3000;\n this._maxReconnects = options.maxReconnects ?? Infinity;\n this._binaryType = options.binaryType ?? \"blob\";\n this._reconnectCount = 0;\n this._intentionalClose = false;\n\n this._doConnect();\n }\n\n send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n // never-throw (§3.6): 未接続での送信は例外ではなく error に流す。set send の\n // fire-and-forget 経路で例外が伝播するのを防ぐ。\n if (!this._ws || this._ws.readyState !== WS_OPEN) {\n this._setError({ message: \"WebSocket is not connected.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidState);\n return;\n }\n this._ws.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._intentionalClose = true;\n this._clearReconnectTimer();\n if (this._ws) {\n this._ws.close(code, reason);\n }\n }\n\n // --- Internal ---\n\n private _doConnect(): void {\n this._setLoading(true);\n this._setError(null);\n\n // 接続開始時点の世代を捕捉。dispose()/再 connect() 後に発火した古いソケット\n // イベントはこの gen が stale になり、状態を書き換えない(_onOpen ほかが\n // _socketGen と this._gen を突き合わせて判定する)。\n this._socketGen = this._gen;\n\n try {\n this._ws = this._protocols\n ? new WebSocket(this._url, this._protocols)\n : new WebSocket(this._url);\n } catch (e) {\n this._setLoading(false);\n this._setError(e, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n return;\n }\n\n // Binary frames default to Blob; opt into ArrayBuffer for direct byte access.\n this._ws.binaryType = this._binaryType;\n\n this._setReadyState(WS_CONNECTING);\n\n this._ws.addEventListener(\"open\", this._onOpen);\n this._ws.addEventListener(\"message\", this._onMessage);\n this._ws.addEventListener(\"error\", this._onError);\n this._ws.addEventListener(\"close\", this._onClose);\n }\n\n private _onOpen = (): void => {\n if (this._socketGen !== this._gen) return;\n this._reconnectCount = 0;\n this._setLoading(false);\n this._setConnected(true);\n this._setReadyState(WS_OPEN);\n };\n\n private _onMessage = (event: MessageEvent): void => {\n if (this._socketGen !== this._gen) return;\n let data = event.data;\n // JSONの自動パース\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch {\n // テキストのまま\n }\n }\n this._setMessage(data);\n };\n\n private _onError = (event: Event): void => {\n if (this._socketGen !== this._gen) return;\n this._setError(event, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n };\n\n private _onClose = (event: CloseEvent): void => {\n this._removeListeners();\n this._ws = null;\n if (this._socketGen !== this._gen) return;\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\n\n // 異常クローズ時の自動再接続(正常終了 1000 は除外)\n if (!this._intentionalClose && this._autoReconnect && event.code !== 1000 && this._reconnectCount < this._maxReconnects) {\n this._scheduleReconnect();\n }\n };\n\n private _scheduleReconnect(): void {\n const gen = this._gen;\n this._clearReconnectTimer();\n this._reconnectTimer = setTimeout(() => {\n this._reconnectTimer = null;\n // dispose()/再 connect() でこの再接続が無効化されていたら何もしない。\n if (gen !== this._gen) return;\n this._reconnectCount++;\n this._doConnect();\n }, this._reconnectInterval);\n }\n\n private _clearReconnectTimer(): void {\n if (this._reconnectTimer !== null) {\n clearTimeout(this._reconnectTimer);\n this._reconnectTimer = null;\n }\n }\n\n private _removeListeners(): void {\n if (!this._ws) {\n return;\n }\n\n this._ws.removeEventListener(\"open\", this._onOpen);\n this._ws.removeEventListener(\"message\", this._onMessage);\n this._ws.removeEventListener(\"error\", this._onError);\n this._ws.removeEventListener(\"close\", this._onClose);\n }\n\n private _closeInternal(): void {\n this._clearReconnectTimer();\n if (this._ws) {\n this._removeListeners();\n if (this._ws.readyState === WS_OPEN || this._ws.readyState === WS_CONNECTING) {\n this._ws.close();\n }\n this._ws = null;\n }\n // 旧接続の状態をリセット(コンストラクタ例外時に stale 状態が残るのを防止)\n if (this._connected) {\n this._setConnected(false);\n }\n if (this._readyState !== WS_CLOSED) {\n this._setReadyState(WS_CLOSED);\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsWebSocket } from \"./components/WebSocket.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const wsId = triggerElement.getAttribute(config.triggerAttribute);\n if (!wsId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsWebSocket as a value. The value import created a components/WebSocket.ts ⇄\n // autoTrigger.ts cycle (WcsWebSocket.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-ws> class\n // matches — without the import cycle.\n const WsCtor = customElements.get(config.tagNames.ws);\n const wsElement = document.getElementById(wsId);\n if (!WsCtor || !(wsElement instanceof WsCtor)) return;\n\n event.preventDefault();\n (wsElement as WcsWebSocket).connect();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { WebSocketCore } from \"../core/WebSocketCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nexport class WcsWebSocket extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...WebSocketCore.wcBindable,\n properties: [\n ...WebSocketCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-ws:trigger-changed\", semantics: \"state\" },\n { name: \"send\", event: \"wcs-ws:send-changed\", semantics: \"state\" },\n ],\n inputs: [\n { name: \"url\", attribute: \"url\" },\n { name: \"protocols\", attribute: \"protocols\" },\n { name: \"autoReconnect\", attribute: \"auto-reconnect\" },\n { name: \"reconnectInterval\", attribute: \"reconnect-interval\" },\n { name: \"maxReconnects\", attribute: \"max-reconnects\" },\n { name: \"binaryType\", attribute: \"binary-type\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n { name: \"send\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"sendMessage\" },\n { name: \"close\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: WebSocketCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // connectedCallback が接続の判断を終えてから disconnectedCallback までの間だけ true。\n // url 属性の変化による再接続はこの間に限る — upgrade 時は attributeChangedCallback が\n // connectedCallback より先に(isConnected のまま)呼ばれるので、そこで接続すると\n // connectedCallback の接続と合わせて 2 本になる。初回の接続は connectedCallback が持つ。\n private _attached = false;\n\n constructor() {\n super();\n this._core = new WebSocketCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-ws:connected-changed\": (d) => ({ connected: d === true }),\n \"wcs-ws:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-ws:error\": (d) => ({ error: d != null }),\n });\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\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\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\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 //\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" url would reconnect to \"undefined\"): `null` removes the\n // attribute (the documented default; an empty url does not connect),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null | undefined) {\n reflectAttribute(this, \"url\", value);\n }\n\n get protocols(): string {\n return this.getAttribute(\"protocols\") || \"\";\n }\n\n set protocols(value: string | null | undefined) {\n reflectAttribute(this, \"protocols\", value);\n }\n\n get autoReconnect(): boolean {\n return this.hasAttribute(\"auto-reconnect\");\n }\n\n set autoReconnect(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"auto-reconnect\", value);\n }\n\n get reconnectInterval(): number {\n const attr = this.getAttribute(\"reconnect-interval\");\n const parsed = attr ? parseInt(attr, 10) : 3000;\n return Number.isNaN(parsed) ? 3000 : parsed;\n }\n\n set reconnectInterval(value: number | null | undefined) {\n reflectAttribute(this, \"reconnect-interval\", value);\n }\n\n get maxReconnects(): number {\n const attr = this.getAttribute(\"max-reconnects\");\n const parsed = attr ? parseInt(attr, 10) : Infinity;\n return Number.isNaN(parsed) ? Infinity : parsed;\n }\n\n set maxReconnects(value: number | null | undefined) {\n reflectAttribute(this, \"max-reconnects\", value);\n }\n\n // Incoming binary frame representation. Backed by the `binary-type` attribute;\n // any value other than \"arraybuffer\" normalizes to the platform default \"blob\".\n get binaryType(): BinaryType {\n return this.getAttribute(\"binary-type\") === \"arraybuffer\" ? \"arraybuffer\" : \"blob\";\n }\n\n set binaryType(value: string | null | undefined) {\n reflectAttribute(this, \"binary-type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get message(): any {\n return this._core.message;\n }\n\n get connected(): boolean {\n return this._core.connected;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readyState(): number {\n return this._core.readyState;\n }\n\n // --- Command properties ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n this._trigger = true;\n this.connect();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-ws:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // `send` is a write-only command surface: assigning transmits immediately.\n // Reading always returns null (no payload is retained) — consistent with the\n // null carried by wcs-ws:send-changed and the documented \"resets to null\".\n get send(): any {\n return null;\n }\n\n set send(data: any) {\n if (data === null || data === undefined) return;\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n this._core.send(payload);\n this.dispatchEvent(new CustomEvent(\"wcs-ws:send-changed\", {\n detail: null,\n bubbles: true,\n }));\n }\n\n // --- Public methods ---\n\n connect(): void {\n const protocols = this.protocols\n ? this.protocols.split(\",\").map(p => p.trim()).filter(Boolean)\n : undefined;\n\n this._core.connect(this.url, {\n protocols: protocols && protocols.length === 1 ? protocols[0] : protocols,\n autoReconnect: this.autoReconnect,\n reconnectInterval: this.reconnectInterval,\n maxReconnects: this.maxReconnects,\n binaryType: this.binaryType,\n });\n }\n\n sendMessage(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n this._core.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._core.close(code, reason);\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n // 再接続するのは url が「変わった」ときだけ。同じ値の書き込み(url の setter 自身の\n // setAttribute の後に、属性も書く binder — @wcstack/state 3.x の inputs[].attribute ミラー —\n // が同じ値を書く、など)\n // は何もしない。connectedCallback より前(upgrade 中・DOM の外)の変化は、\n // connectedCallback がそのときの url で 1 回だけ接続する。\n if (name === \"url\" && oldValue !== newValue && this._attached && !this.manual && newValue) {\n this.connect();\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)。\n // ここで url の setter が走っても _attached はまだ false なので接続しない —\n // 接続は下で、取り込み後の url / manual を見て 1 回だけ行う。\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() は command-driven node では ready を返す no-op(§3.5)。SSR は\n // connectedCallbackPromise を await して初期スナップショットを取れる。\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.url) {\n this.connect();\n }\n this._attached = true;\n }\n\n disconnectedCallback(): void {\n this._attached = false;\n // dispose() が _gen を bump して進行中のソケット/再接続を無効化し、close() する。\n this._core.dispose();\n }\n}\n","import { WcsWebSocket } from \"./components/WebSocket.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.ws)) {\n registry.define(config.tagNames.ws, WcsWebSocket);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWebSocket(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,eAAe;AACjC,IAAA,QAAQ,EAAE;AACR,QAAA,EAAE,EAAE,QAAQ;AACb,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,G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,GAAG,EAAE;YAC5B,IAAI,CAAC,OAAO,EAAE;QAChB;AACA,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI;IACvB;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;;AAEtB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;ACnSF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IACnD;AACF;;ACRM,SAAU,kBAAkB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC/F,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/websocketCapabilities.ts","../src/core/WebSocketCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/WebSocket.ts","../src/registerComponents.ts","../src/bootstrapWebSocket.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n ws: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-wstarget\",\n tagNames: {\n ws: \"wcs-ws\",\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: `bootstrapWebSocket` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/websocket] bootstrapWebSocket: \"${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 [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","/**\n * websocketCapabilities.ts\n *\n * WebSocket node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。WebSocket は持続的な session / monitor node(1 本の接続を張り続ける)で、\n * 競合する operation を持たないため lane は持たず、error taxonomy(errorInfo)のみを採用する。\n *\n * この node の `_setError` は 4 形態の非 null 入力を受ける(いずれも公開 `error` shape は不変):\n * 1. synthetic な `{ message: \"url is required.\" }`(`.name` 無し)— connect() の引数不備。\n * 2. synthetic な `{ message: \"WebSocket is not connected.\" }`(`.name` 無し)— open 前の send()。\n * 3. caught された生の構築例外 `e`(`new WebSocket()` の同期 throw)。\n * 4. platform の WebSocket `error` Event(`Event`。`.name`/`.message` を持たない)。\n *\n * これらは shape がバラバラで、message からの分類は脆い。そこで呼び出し側が明示的な\n * taxonomy code を discriminator として渡す(storage の `deriveStorageErrorInfo(error, name)`\n * と同じ技法)。derive 側は synthetic / Event / Error を reverse-engineer せず、渡された\n * code で phase / recoverable を決め、message だけを防御的に抽出する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した websocket error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_WEBSOCKET_ERROR_CODE = {\n /** connect() の `url` 未指定 — 開始前の入力不備。retry では回復しない。 */\n InvalidArgument: \"invalid-argument\",\n /** open 前の send() — 接続が OPEN でない状態での送信。retry では回復しない(先に connect が要る)。 */\n InvalidState: \"invalid-state\",\n /**\n * 接続の確立 / 維持に失敗(`new WebSocket()` の同期例外、または platform の error Event)。\n * WebSocket のエラーは通常一過性で、再接続で回復しうる(recoverable=true)。\n */\n ConnectionError: \"connection-error\",\n} as const;\n\n/**\n * websocket の失敗を serializable な error taxonomy に写す。`code` は呼び出し側が渡す\n * discriminator(公開 `error` shape からは復元しない)。`message` は入力から防御的に抽出し、\n * message を持たない error Event 等では安定した fallback を使う。\n *\n * - `invalid-argument`(url 未指定)は開始前の入力不備 → phase=\"start\" / recoverable=false。\n * - `invalid-state`(open 前 send)は接続状態が満たされない実行時失敗 → phase=\"execute\" /\n * recoverable=false(先に connect() が必要)。\n * - `connection-error`(構築例外 / error Event)は接続の確立 / 維持失敗 → phase=\"execute\" /\n * recoverable=true(再接続で回復しうる)。\n */\nexport function deriveWebSocketErrorInfo(error: unknown, code: string): WcsIoErrorInfo {\n // error は非 null(_setError は error===null を derive 前に分岐する)だが、synthetic /\n // Event / caught 例外 / 生 throw と shape がバラバラなので message は防御的に抽出する。\n // error Event は message を持たないため安定した fallback に落とす。\n const raw = (error as { message?: unknown }).message;\n const message = typeof raw === \"string\" ? raw : \"WebSocket connection error\";\n\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidArgument) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n }\n if (code === WCS_WEBSOCKET_ERROR_CODE.InvalidState) {\n return { code: WCS_WEBSOCKET_ERROR_CODE.InvalidState, phase: \"execute\", recoverable: false, message };\n }\n // connection-error(構築例外 / error Event): 接続の確立/維持失敗、再接続で回復しうる。\n return { code: WCS_WEBSOCKET_ERROR_CODE.ConnectionError, phase: \"execute\", recoverable: true, message };\n}\n","import { IWcBindable } from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveWebSocketErrorInfo, WCS_WEBSOCKET_ERROR_CODE } from \"./websocketCapabilities.js\";\n\n// WebSocket readyState values. Hardcoded rather than read from the global\n// WebSocket so the Core does not require WebSocket to exist at module load\n// (referencing `WebSocket.CLOSED` in a field initializer evaluates at class\n// definition time; tests inject a mock). Mirrors SseCore's SSE_CLOSED.\nconst WS_CONNECTING = 0;\nconst WS_OPEN = 1;\nconst WS_CLOSED = 3;\n\nexport interface WebSocketConnectOptions {\n protocols?: string | string[];\n autoReconnect?: boolean;\n reconnectInterval?: number;\n maxReconnects?: number;\n // How incoming binary frames are surfaced on `message`. \"blob\" (the platform\n // default) or \"arraybuffer\" for direct byte processing. Applied to every\n // socket this connection spawns, including auto-reconnects.\n binaryType?: BinaryType;\n}\n\nexport class WebSocketCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"message\", event: \"wcs-ws:message\", semantics: \"event\" },\n { name: \"connected\", event: \"wcs-ws:connected-changed\", semantics: \"state\" },\n { name: \"loading\", event: \"wcs-ws:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-ws:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error` (invalid-argument / invalid-state\n // / connection-error); the existing `error` property/event are unchanged. Fires\n // wcs-ws:error-info-changed. No lane — WebSocket is a persistent session/monitor\n // node, not a competing operation.\n { name: \"errorInfo\", event: \"wcs-ws:error-info-changed\", semantics: \"state\" },\n { name: \"readyState\", event: \"wcs-ws:readystate-changed\", semantics: \"state\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"send\" },\n { name: \"close\" },\n ],\n };\n\n private _target: EventTarget;\n private _ws: WebSocket | null = null;\n private _message: any = null;\n private _connected: boolean = false;\n private _loading: boolean = false;\n private _error: any = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readyState: number = WS_CLOSED;\n\n // 自動再接続\n private _autoReconnect: boolean = false;\n private _reconnectInterval: number = 3000;\n private _maxReconnects: number = Infinity;\n private _reconnectCount: number = 0;\n private _reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n private _url: string = \"\";\n private _protocols: string | string[] | undefined = undefined;\n private _binaryType: BinaryType = \"blob\";\n private _intentionalClose: boolean = false;\n\n // Generation guard (§3.4): bumped on dispose() and at every connect(). A socket\n // event (open/message/error/close) or a scheduled reconnect that fires after\n // dispose / a superseding connect() carries a stale `gen` and MUST NOT write\n // state onto a torn-down element. A boolean flag is insufficient (dispose→observe\n // would let stale work slip through).\n private _gen = 0;\n // Generation captured when the current socket was opened. The shared socket\n // event handlers compare it against _gen to drop events from a superseded /\n // disposed connection.\n private _socketGen = 0;\n // SSR (§3.8): WebSocket is command-driven with no asynchronous probe to await,\n // so readiness is immediate.\n private _ready: Promise<void> = Promise.resolve();\n\n /**\n * Whether `[wcs/command-not-ready]` was said for this element: a `send()` refused because the\n * element is not ready loses what it carried, and `error` alone told only a page that binds it.\n * Said once per element (docs/v4-direction-2026-10.md, the I/O command policy).\n */\n private _toldNotReady = false;\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). WebSocket connections are command-driven (connect()), so\n // observe() is an idempotent no-op that resolves once ready; the Shell's\n // connectedCallback does not auto-establish a subscription here. dispose()\n // invalidates any in-flight socket / pending reconnect and closes the socket.\n observe(): Promise<void> {\n return this._ready;\n }\n\n dispose(): void {\n this._gen++;\n this.close();\n }\n\n get message(): any {\n return this._message;\n }\n\n get connected(): boolean {\n return this._connected;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): any {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-ws:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readyState(): number {\n return this._readyState;\n }\n\n // --- State setters with event dispatch ---\n\n private _setMessage(message: any): void {\n this._message = message;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:message\", {\n detail: message,\n bubbles: true,\n }));\n }\n\n private _setConnected(connected: boolean): void {\n this._connected = connected;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:connected-changed\", {\n detail: connected,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n // `code` is an explicit taxonomy discriminator (WCS_WEBSOCKET_ERROR_CODE), passed\n // only from the non-null failure call sites. It stays out of the public `error`\n // shape and is used solely to classify errorInfo without reverse-engineering the\n // heterogeneous `error` values (synthetic {message} / caught Error / raw Event).\n // The clear path passes null and no code.\n private _setError(error: any, code?: string): void {\n // Same-value guard (async-io-node-guidelines.md §3.3). `error` is state-ish,\n // so suppressing redundant null→null dispatches (every connect/send start\n // clears a usually-already-null error) avoids a spurious wcs-ws:error per\n // successful operation. Reference identity is sufficient: each failure builds\n // a fresh object (or the platform's own error Event), and the clear path\n // always passes null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // explicit `code` (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family. Every non-null error carries a code (the clear path is the only\n // caller without one, and it is short-circuited here), so `code!` holds.\n this._commitErrorInfo(error === null ? null : deriveWebSocketErrorInfo(error, code!));\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already same-value-guards on the error\n // reference), so errorInfo transitions exactly when error does — no separate\n // guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadyState(readyState: number): void {\n this._readyState = readyState;\n this._target.dispatchEvent(new CustomEvent(\"wcs-ws:readystate-changed\", {\n detail: readyState,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n connect(url: string, options: WebSocketConnectOptions = {}): void {\n // never-throw (§3.6): 引数バリデーション失敗は例外ではなく error プロパティに\n // 流し、サニタイズ値(なにもしない)を返す。command-token 経路(set trigger →\n // connect())からの呼び出しが state 更新サイクルを壊さないようにする。\n if (!url) {\n this._setError({ message: \"url is required.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidArgument);\n return;\n }\n\n // 新しい接続を開始するため世代を更新し、進行中のソケット/再接続を無効化する。\n this._gen++;\n\n // 既存の接続をクローズ\n this._intentionalClose = true;\n this._closeInternal();\n\n this._url = url;\n this._protocols = options.protocols;\n this._autoReconnect = options.autoReconnect ?? false;\n this._reconnectInterval = options.reconnectInterval ?? 3000;\n this._maxReconnects = options.maxReconnects ?? Infinity;\n this._binaryType = options.binaryType ?? \"blob\";\n this._reconnectCount = 0;\n this._intentionalClose = false;\n\n this._doConnect();\n }\n\n send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n // never-throw (§3.6): 未接続での送信は例外ではなく error に流す。set send の\n // fire-and-forget 経路で例外が伝播するのを防ぐ。\n if (!this._ws || this._ws.readyState !== WS_OPEN) {\n this._setError({ message: \"WebSocket is not connected.\" }, WCS_WEBSOCKET_ERROR_CODE.InvalidState);\n this._warnNotReady();\n return;\n }\n this._ws.send(data);\n }\n\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n \"[@wcstack/websocket] [wcs/command-not-ready] send() was refused: the WebSocket is not connected, so the message is lost. \" +\n \"It goes to `error` too. Send once `connected` is true. (Said once per element.)\",\n this._target,\n );\n }\n\n close(code?: number, reason?: string): void {\n this._intentionalClose = true;\n this._clearReconnectTimer();\n if (this._ws) {\n this._ws.close(code, reason);\n }\n }\n\n // --- Internal ---\n\n private _doConnect(): void {\n this._setLoading(true);\n this._setError(null);\n\n // 接続開始時点の世代を捕捉。dispose()/再 connect() 後に発火した古いソケット\n // イベントはこの gen が stale になり、状態を書き換えない(_onOpen ほかが\n // _socketGen と this._gen を突き合わせて判定する)。\n this._socketGen = this._gen;\n\n try {\n this._ws = this._protocols\n ? new WebSocket(this._url, this._protocols)\n : new WebSocket(this._url);\n } catch (e) {\n this._setLoading(false);\n this._setError(e, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n return;\n }\n\n // Binary frames default to Blob; opt into ArrayBuffer for direct byte access.\n this._ws.binaryType = this._binaryType;\n\n this._setReadyState(WS_CONNECTING);\n\n this._ws.addEventListener(\"open\", this._onOpen);\n this._ws.addEventListener(\"message\", this._onMessage);\n this._ws.addEventListener(\"error\", this._onError);\n this._ws.addEventListener(\"close\", this._onClose);\n }\n\n private _onOpen = (): void => {\n if (this._socketGen !== this._gen) return;\n this._reconnectCount = 0;\n this._setLoading(false);\n this._setConnected(true);\n this._setReadyState(WS_OPEN);\n };\n\n private _onMessage = (event: MessageEvent): void => {\n if (this._socketGen !== this._gen) return;\n let data = event.data;\n // JSONの自動パース\n if (typeof data === \"string\") {\n try {\n data = JSON.parse(data);\n } catch {\n // テキストのまま\n }\n }\n this._setMessage(data);\n };\n\n private _onError = (event: Event): void => {\n if (this._socketGen !== this._gen) return;\n this._setError(event, WCS_WEBSOCKET_ERROR_CODE.ConnectionError);\n };\n\n private _onClose = (event: CloseEvent): void => {\n this._removeListeners();\n this._ws = null;\n if (this._socketGen !== this._gen) return;\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\n\n // 異常クローズ時の自動再接続(正常終了 1000 は除外)\n if (!this._intentionalClose && this._autoReconnect && event.code !== 1000 && this._reconnectCount < this._maxReconnects) {\n this._scheduleReconnect();\n }\n };\n\n private _scheduleReconnect(): void {\n const gen = this._gen;\n this._clearReconnectTimer();\n this._reconnectTimer = setTimeout(() => {\n this._reconnectTimer = null;\n // dispose()/再 connect() でこの再接続が無効化されていたら何もしない。\n if (gen !== this._gen) return;\n this._reconnectCount++;\n this._doConnect();\n }, this._reconnectInterval);\n }\n\n private _clearReconnectTimer(): void {\n if (this._reconnectTimer !== null) {\n clearTimeout(this._reconnectTimer);\n this._reconnectTimer = null;\n }\n }\n\n private _removeListeners(): void {\n if (!this._ws) {\n return;\n }\n\n this._ws.removeEventListener(\"open\", this._onOpen);\n this._ws.removeEventListener(\"message\", this._onMessage);\n this._ws.removeEventListener(\"error\", this._onError);\n this._ws.removeEventListener(\"close\", this._onClose);\n }\n\n private _closeInternal(): void {\n this._clearReconnectTimer();\n if (this._ws) {\n this._removeListeners();\n if (this._ws.readyState === WS_OPEN || this._ws.readyState === WS_CONNECTING) {\n this._ws.close();\n }\n this._ws = null;\n }\n // 旧接続の状態をリセット(コンストラクタ例外時に stale 状態が残るのを防止)\n if (this._connected) {\n this._setConnected(false);\n }\n if (this._readyState !== WS_CLOSED) {\n this._setReadyState(WS_CLOSED);\n }\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsWebSocket } from \"./components/WebSocket.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n if (!triggerElement) return;\n\n const wsId = triggerElement.getAttribute(config.triggerAttribute);\n if (!wsId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsWebSocket as a value. The value import created a components/WebSocket.ts ⇄\n // autoTrigger.ts cycle (WcsWebSocket.connectedCallback() calls\n // registerAutoTrigger()). instanceof against the customElements registry keeps\n // the exact same identity guarantee — only the registered <wcs-ws> class\n // matches — without the import cycle.\n const WsCtor = customElements.get(config.tagNames.ws);\n const wsElement = document.getElementById(wsId);\n if (!WsCtor || !(wsElement instanceof WsCtor)) return;\n\n event.preventDefault();\n (wsElement as WcsWebSocket).connect();\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\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/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\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 for (const input of inputs) {\n const name = input.name;\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 { config } from \"../config.js\";\nimport { IWcBindable } from \"../types.js\";\nimport { WebSocketCore } from \"../core/WebSocketCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\nexport class WcsWebSocket extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...WebSocketCore.wcBindable,\n properties: [\n ...WebSocketCore.wcBindable.properties,\n { name: \"trigger\", event: \"wcs-ws:trigger-changed\", semantics: \"state\" },\n { name: \"send\", event: \"wcs-ws:send-changed\", semantics: \"state\" },\n ],\n inputs: [\n { name: \"url\", attribute: \"url\" },\n { name: \"protocols\", attribute: \"protocols\" },\n { name: \"autoReconnect\", attribute: \"auto-reconnect\" },\n { name: \"reconnectInterval\", attribute: \"reconnect-interval\" },\n { name: \"maxReconnects\", attribute: \"max-reconnects\" },\n { name: \"binaryType\", attribute: \"binary-type\" },\n { name: \"manual\", attribute: \"manual\" },\n { name: \"trigger\" },\n { name: \"send\" },\n ],\n commands: [\n { name: \"connect\" },\n { name: \"sendMessage\" },\n { name: \"close\" },\n ],\n };\n static get observedAttributes(): string[] { return [\"url\"]; }\n\n private _core: WebSocketCore;\n private _trigger: boolean = false;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n // connectedCallback が接続の判断を終えてから disconnectedCallback までの間だけ true。\n // url 属性の変化による再接続はこの間に限る — upgrade 時は attributeChangedCallback が\n // connectedCallback より先に(isConnected のまま)呼ばれるので、そこで接続すると\n // connectedCallback の接続と合わせて 2 本になる。初回の接続は connectedCallback が持つ。\n private _attached = false;\n\n constructor() {\n super();\n this._core = new WebSocketCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-ws:connected-changed\": (d) => ({ connected: d === true }),\n \"wcs-ws:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-ws:error\": (d) => ({ error: d != null }),\n });\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\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 // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\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\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\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 //\n // Input setters never let setAttribute stringify null / undefined (an\n // \"undefined\" url would reconnect to \"undefined\"): `null` removes the\n // attribute (the documented default; an empty url does not connect),\n // `undefined` restores the attribute the element started with (wc-bindable\n // producer guidance P1; React 19 and a direct assignment deliver it,\n // @wcstack/state does not).\n\n get url(): string {\n return this.getAttribute(\"url\") || \"\";\n }\n\n set url(value: string | null | undefined) {\n reflectAttribute(this, \"url\", value);\n }\n\n get protocols(): string {\n return this.getAttribute(\"protocols\") || \"\";\n }\n\n set protocols(value: string | null | undefined) {\n reflectAttribute(this, \"protocols\", value);\n }\n\n get autoReconnect(): boolean {\n return this.hasAttribute(\"auto-reconnect\");\n }\n\n set autoReconnect(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"auto-reconnect\", value);\n }\n\n get reconnectInterval(): number {\n const attr = this.getAttribute(\"reconnect-interval\");\n const parsed = attr ? parseInt(attr, 10) : 3000;\n return Number.isNaN(parsed) ? 3000 : parsed;\n }\n\n set reconnectInterval(value: number | null | undefined) {\n reflectAttribute(this, \"reconnect-interval\", value);\n }\n\n get maxReconnects(): number {\n const attr = this.getAttribute(\"max-reconnects\");\n const parsed = attr ? parseInt(attr, 10) : Infinity;\n return Number.isNaN(parsed) ? Infinity : parsed;\n }\n\n set maxReconnects(value: number | null | undefined) {\n reflectAttribute(this, \"max-reconnects\", value);\n }\n\n // Incoming binary frame representation. Backed by the `binary-type` attribute;\n // any value other than \"arraybuffer\" normalizes to the platform default \"blob\".\n get binaryType(): BinaryType {\n return this.getAttribute(\"binary-type\") === \"arraybuffer\" ? \"arraybuffer\" : \"blob\";\n }\n\n set binaryType(value: string | null | undefined) {\n reflectAttribute(this, \"binary-type\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Core delegated getters ---\n\n get message(): any {\n return this._core.message;\n }\n\n get connected(): boolean {\n return this._core.connected;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): any {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readyState(): number {\n return this._core.readyState;\n }\n\n // --- Command properties ---\n\n get trigger(): boolean {\n return this._trigger;\n }\n\n set trigger(value: boolean) {\n const v = !!value;\n if (v) {\n this._trigger = true;\n this.connect();\n this._trigger = false;\n this.dispatchEvent(new CustomEvent(\"wcs-ws:trigger-changed\", {\n detail: false,\n bubbles: true,\n }));\n }\n }\n\n // `send` is a write-only command surface: assigning transmits immediately.\n // Reading always returns null (no payload is retained) — consistent with the\n // null carried by wcs-ws:send-changed and the documented \"resets to null\".\n get send(): any {\n return null;\n }\n\n set send(data: any) {\n if (data === null || data === undefined) return;\n const payload = typeof data === \"string\" ? data : JSON.stringify(data);\n this._core.send(payload);\n this.dispatchEvent(new CustomEvent(\"wcs-ws:send-changed\", {\n detail: null,\n bubbles: true,\n }));\n }\n\n // --- Public methods ---\n\n connect(): void {\n const protocols = this.protocols\n ? this.protocols.split(\",\").map(p => p.trim()).filter(Boolean)\n : undefined;\n\n this._core.connect(this.url, {\n protocols: protocols && protocols.length === 1 ? protocols[0] : protocols,\n autoReconnect: this.autoReconnect,\n reconnectInterval: this.reconnectInterval,\n maxReconnects: this.maxReconnects,\n binaryType: this.binaryType,\n });\n }\n\n sendMessage(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {\n this._core.send(data);\n }\n\n close(code?: number, reason?: string): void {\n this._core.close(code, reason);\n }\n\n // --- Lifecycle ---\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n // 再接続するのは url が「変わった」ときだけ。同じ値の書き込み(url の setter 自身の\n // setAttribute の後に、属性も書く binder — @wcstack/state 3.x の inputs[].attribute ミラー —\n // が同じ値を書く、など)\n // は何もしない。connectedCallback より前(upgrade 中・DOM の外)の変化は、\n // connectedCallback がそのときの url で 1 回だけ接続する。\n if (name === \"url\" && oldValue !== newValue && this._attached && !this.manual && newValue) {\n this.connect();\n }\n }\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)。\n // ここで url の setter が走っても _attached はまだ false なので接続しない —\n // 接続は下で、取り込み後の url / manual を見て 1 回だけ行う。\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() は command-driven node では ready を返す no-op(§3.5)。SSR は\n // connectedCallbackPromise を await して初期スナップショットを取れる。\n this._connectedCallbackPromise = this._core.observe();\n if (!this.manual && this.url) {\n this.connect();\n }\n this._attached = true;\n }\n\n disconnectedCallback(): void {\n this._attached = false;\n // dispose() が _gen を bump して進行中のソケット/再接続を無効化し、close() する。\n this._core.dispose();\n }\n}\n","import { WcsWebSocket } from \"./components/WebSocket.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.ws)) {\n registry.define(config.tagNames.ws, WcsWebSocket);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapWebSocket(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,eAAe;AACjC,IAAA,QAAQ,EAAE;AACR,QAAA,EAAE,EAAE,QAAQ;AACb,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,OA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ACvB;;;QAGA,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;QACrD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE;YAC5B,IAAI,CAAC,OAAO,EAAE;QAChB;AACA,QAAA,IAAI,CAAC,SAAS,GAAG,IAAI;IACvB;IAEA,oBAAoB,GAAA;AAClB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;;AAEtB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;ACnSF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;QACrC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IACnD;AACF;;ACRM,SAAU,kBAAkB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAC/F,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/websocket",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "Declarative WebSocket component for Web Components. Framework-agnostic real-time communication via wc-bindable-protocol.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|