@wcstack/websocket 4.4.0 → 4.6.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 CHANGED
@@ -584,17 +584,19 @@ import type { WcsWsValues } from "@wcstack/websocket";
584
584
 
585
585
  interface ChatMessage { type: string; content: string; }
586
586
 
587
- const { ref, values } = useWcBindable<HTMLElement, WcsWsValues<ChatMessage>>();
587
+ const { ref: socket, values } = useWcBindable<HTMLElement, WcsWsValues<ChatMessage>>();
588
588
  </script>
589
589
 
590
590
  <template>
591
- <wcs-ws :ref="ref" url="wss://example.com/ws" auto-reconnect />
591
+ <wcs-ws ref="socket" url="wss://example.com/ws" auto-reconnect />
592
592
  <p v-if="values.loading">接続中...</p>
593
593
  <p v-else-if="values.connected">接続済み</p>
594
594
  <pre v-if="values.message">{{ values.message }}</pre>
595
595
  </template>
596
596
  ```
597
597
 
598
+ テンプレート ref は静的に名前で書きます(`ref="socket"`)。`<script setup>` の `:ref="…"` には ref が剥がされた値(`null`)が渡り、アダプターは束縛しません。
599
+
598
600
  ### Svelte
599
601
 
600
602
  ```svelte
package/README.md CHANGED
@@ -587,17 +587,19 @@ import type { WcsWsValues } from "@wcstack/websocket";
587
587
 
588
588
  interface ChatMessage { type: string; content: string; }
589
589
 
590
- const { ref, values } = useWcBindable<HTMLElement, WcsWsValues<ChatMessage>>();
590
+ const { ref: socket, values } = useWcBindable<HTMLElement, WcsWsValues<ChatMessage>>();
591
591
  </script>
592
592
 
593
593
  <template>
594
- <wcs-ws :ref="ref" url="wss://example.com/ws" auto-reconnect />
594
+ <wcs-ws ref="socket" url="wss://example.com/ws" auto-reconnect />
595
595
  <p v-if="values.loading">Connecting...</p>
596
596
  <p v-else-if="values.connected">Connected</p>
597
597
  <pre v-if="values.message">{{ values.message }}</pre>
598
598
  </template>
599
599
  ```
600
600
 
601
+ Name the template ref statically (`ref="socket"`): in `<script setup>` a `:ref="…"` binding gets the ref unwrapped, `null`, and the adapter never binds.
602
+
601
603
  ### Svelte
602
604
 
603
605
  ```svelte
package/dist/auto.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Importing this module defines the package's custom elements. It exports nothing.
2
+ export {};
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();_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);
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(),this._setConnected(!1),this._setLoading(!1),this._setReadyState(3)}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 WeakSet;function h(e,t,n){if(a.has(e))return;a.add(e);const s=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${s}> has the attribute ${t}="${n}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const l=new WeakMap;function d(e,t){let n=l.get(e);return void 0===n&&(n=new Map,l.set(e,n)),n.has(t)||n.set(t,e.getAttribute(t)),n.get(t)}function u(e,t,n){null===n?e.removeAttribute(t):e.setAttribute(t,n)}function _(e,t,n){const s=d(e,t);u(e,t,void 0===n?s:null===n?null:String(n))}function g(e,t,n){const s=d(e,t);u(e,t,void 0===n?s:n?"":null)}class m 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){g(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){g(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)return;const s=e.getAttribute;for(const t of n){const n=t.name,r="function"==typeof s?s.call(e,n.toLowerCase()):null;if(null!==r&&r.startsWith("[object ")&&h(e,n,r),!Object.prototype.hasOwnProperty.call(e,n))continue;if(!c(e,n))continue;const o=e,i=o[n];delete o[n],o[n]=i}}(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 b;!function(t=customElements){t.get(e.tagNames.ws)||t.define(e.tagNames.ws,m)}(b);
2
2
  //# sourceMappingURL=auto.min.js.map
@@ -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 /**\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,GAAI,WCSKC,EAEM,mBAFNA,EAIG,gBAJHA,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,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"}
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 // The socket's close event is dropped as stale (the generation moved), so the\n // connection's end is published here (timing-and-firing-contract §22): a route the\n // element leaves keeps its nodes — bindings included — for the next entry, and\n // state would keep showing a connection that is gone.\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\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// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { 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","_setConnected","_setLoading","_setReadyState","message","connected","loading","error","errorInfo","readyState","_setMessage","dispatchEvent","CustomEvent","detail","bubbles","_setError","code","_commitErrorInfo","raw","phase","recoverable","deriveWebSocketErrorInfo","info","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","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","has","add","tag","localName","initialAttributes","WeakMap","initialAttribute","el","byName","Map","writeAttribute","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","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","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","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,aAAcC,MAAO,4BAA6BC,UAAW,UAEvEC,SAAU,CACR,CAAEH,KAAM,WACR,CAAEA,KAAM,QACR,CAAEA,KAAM,WAIJI,QACAC,IAAwB,KACxBC,SAAgB,KAChBC,YAAsB,EACtBC,UAAoB,EACpBC,OAAc,KACdC,WAAoC,KACpCC,YA5CQ,EA+CRC,gBAA0B,EAC1BC,mBAA6B,IAC7BC,eAAyBC,IACzBC,gBAA0B,EAC1BC,gBAAwD,KACxDC,KAAe,GACfC,gBAA4CC,EAC5CC,YAA0B,OAC1BC,mBAA6B,EAO7BC,KAAO,EAIPC,WAAa,EAGbC,OAAwBC,QAAQC,UAOhCC,eAAgB,EAExB,WAAAC,CAAYC,GACVC,QACAC,KAAK5B,QAAU0B,GAAUE,IAC3B,CAEA,SAAIC,GACF,OAAOD,KAAKP,MACd,CAMA,OAAAS,GACE,OAAOF,KAAKP,MACd,CAEA,OAAAU,GACEH,KAAKT,OACLS,KAAKI,QAKLJ,KAAKK,eAAc,GACnBL,KAAK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mBF"}
package/dist/index.esm.js CHANGED
@@ -207,6 +207,13 @@ class WebSocketCore extends EventTarget {
207
207
  dispose() {
208
208
  this._gen++;
209
209
  this.close();
210
+ // The socket's close event is dropped as stale (the generation moved), so the
211
+ // connection's end is published here (timing-and-firing-contract §22): a route the
212
+ // element leaves keeps its nodes — bindings included — for the next entry, and
213
+ // state would keep showing a connection that is gone.
214
+ this._setConnected(false);
215
+ this._setLoading(false);
216
+ this._setReadyState(WS_CLOSED);
210
217
  }
211
218
  get message() {
212
219
  return this._message;
@@ -505,6 +512,21 @@ function hasAccessorOnPrototype(target, name) {
505
512
  }
506
513
  return false;
507
514
  }
515
+ // 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
516
+ // React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
517
+ // 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
518
+ // (docs/seam-apps.md、fw-inventory)。
519
+ const toldObjectAttribute = new WeakSet();
520
+ function warnObjectAttribute(element, name, value) {
521
+ if (toldObjectAttribute.has(element))
522
+ return;
523
+ toldObjectAttribute.add(element);
524
+ const tag = element.localName ?? "element";
525
+ console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
526
+ `attribute, so the element did not receive it. A framework does that when the property is set before the ` +
527
+ `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
528
+ `or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
529
+ }
508
530
  /**
509
531
  * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
510
532
  * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
@@ -512,14 +534,19 @@ function hasAccessorOnPrototype(target, name) {
512
534
  * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
513
535
  * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
514
536
  * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
537
+ * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
515
538
  */
516
539
  function upgradeProperties(element) {
517
540
  const declaration = element.constructor?.wcBindable;
518
541
  const inputs = declaration?.inputs;
519
542
  if (inputs === undefined)
520
543
  return;
544
+ const getAttribute = element.getAttribute;
521
545
  for (const input of inputs) {
522
546
  const name = input.name;
547
+ const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
548
+ if (attribute !== null && attribute.startsWith("[object "))
549
+ warnObjectAttribute(element, name, attribute);
523
550
  if (!Object.prototype.hasOwnProperty.call(element, name))
524
551
  continue;
525
552
  if (!hasAccessorOnPrototype(element, name))
@@ -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 /**\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,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAA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C,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 // The socket's close event is dropped as stale (the generation moved), so the\n // connection's end is published here (timing-and-firing-contract §22): a route the\n // element leaves keeps its nodes — bindings included — for the next entry, and\n // state would keep showing a connection that is gone.\n this._setConnected(false);\n this._setLoading(false);\n this._setReadyState(WS_CLOSED);\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// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { 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,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;AAEhC,MAAM,MAAM,GAAY,OAAkB;SAEjC,SAAS,GAAA;IACvB,IAAI,CAAC,YAAY,EAAE;QAC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AE,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.4.0",
3
+ "version": "4.6.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",
@@ -11,7 +11,10 @@
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.esm.js"
13
13
  },
14
- "./auto": "./dist/auto.min.js"
14
+ "./auto": {
15
+ "types": "./dist/auto.d.ts",
16
+ "import": "./dist/auto.min.js"
17
+ }
15
18
  },
16
19
  "files": [
17
20
  "dist"