@wcstack/clipboard 1.29.0 → 1.31.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/dist/auto.min.js CHANGED
@@ -1,2 +1,2 @@
1
- const t={triggerAttribute:"data-clipboardtarget",tagNames:{clipboard:"wcs-clipboard"}},e="capability-missing",r="not-allowed",i="clipboard-error";class s extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"text",event:"wcs-clipboard:read",semantics:"event",getter:t=>t.detail.text},{name:"items",event:"wcs-clipboard:read",semantics:"event",getter:t=>t.detail.items},{name:"loading",event:"wcs-clipboard:loading-changed",semantics:"state"},{name:"error",event:"wcs-clipboard:error",semantics:"state"},{name:"readPermission",event:"wcs-clipboard:read-permission-changed",semantics:"state"},{name:"writePermission",event:"wcs-clipboard:write-permission-changed",semantics:"state"},{name:"monitoring",event:"wcs-clipboard:monitoring-changed",semantics:"state"},{name:"errorInfo",event:"wcs-clipboard:error-info-changed",semantics:"state"},{name:"copied",event:"wcs-clipboard:copied",semantics:"event",getter:t=>t.detail},{name:"cut",event:"wcs-clipboard:cut",semantics:"event",getter:t=>t.detail},{name:"pasted",event:"wcs-clipboard:pasted",semantics:"event",getter:t=>t.detail}],commands:[{name:"writeText",async:!0},{name:"write",async:!0},{name:"readText",async:!0},{name:"read",async:!0},{name:"startMonitor"},{name:"stopMonitor"}]};_target;_text=null;_items=null;_loading=!1;_error=null;_errorInfo=null;_readPermission="prompt";_writePermission="prompt";_monitoring=!1;_copied=null;_cut=null;_pasted=null;_readStatus=null;_writeStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._initPermissions()}get ready(){return this._ready}observe(){return this.reinitPermission(),this._ready}get text(){return this._text}get items(){return this._items}get loading(){return this._loading}get error(){return this._error}get errorInfo(){return this._errorInfo}get readPermission(){return this._readPermission}get writePermission(){return this._writePermission}get monitoring(){return this._monitoring}get copied(){return this._copied}get cut(){return this._cut}get pasted(){return this._pasted}_setRead(t){this._text=t.text,this._items=t.items,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read",{detail:t,bubbles:!0}))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:loading-changed",{detail:t,bubbles:!0})))}_setError(t){var s,n;this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:(s=t.name,n=t.message,"NotSupportedError"===s?{code:e,phase:"start",recoverable:!1,message:n}:"NotAllowedError"===s?{code:r,phase:"execute",recoverable:!1,message:n}:{code:i,phase:"execute",recoverable:!0,message:n})),this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error-info-changed",{detail:t,bubbles:!0}))}_setReadPermission(t){this._readPermission!==t&&(this._readPermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read-permission-changed",{detail:t,bubbles:!0})))}_setWritePermission(t){this._writePermission!==t&&(this._writePermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:write-permission-changed",{detail:t,bubbles:!0})))}_setMonitoring(t){this._monitoring!==t&&(this._monitoring=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:monitoring-changed",{detail:t,bubbles:!0})))}_setCopied(t){this._copied=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:copied",{detail:t,bubbles:!0}))}_setCut(t){this._cut=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:cut",{detail:t,bubbles:!0}))}_setPasted(t){this._pasted=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:pasted",{detail:t,bubbles:!0}))}writeText(t){return this._runWrite(()=>navigator.clipboard.writeText(t))}write(t){return this._runWrite(()=>navigator.clipboard.write(t))}readText(){return this._runRead(async()=>({text:await navigator.clipboard.readText(),items:null}))}read(){return this._runRead(async()=>{const t=await navigator.clipboard.read();return this._normalizeItems(t)})}startMonitor(){this._monitoring||(this._setMonitoring(!0),document.addEventListener("copy",this._onCopy),document.addEventListener("cut",this._onCut),document.addEventListener("paste",this._onPaste))}stopMonitor(){this._removeMonitorListeners(),this._setMonitoring(!1)}reinitPermission(){this._permissionSubscribed||this._initPermissions()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._loading=!1,this._readStatus&&(this._readStatus.removeEventListener("change",this._onReadChange),this._readStatus=null),this._writeStatus&&(this._writeStatus.removeEventListener("change",this._onWriteChange),this._writeStatus=null),this._removeMonitorListeners(),this._monitoring=!1}_runWrite(t){return this._runOp(async()=>(await t(),null))}_runRead(t){return this._runOp(t)}async _runOp(t){if(!this._hasClipboard())return void this._setError(this._unsupportedError());const e=this._acqGen;this._setLoading(!0),this._setError(null);try{const r=await t();if(e!==this._acqGen)return;this._setLoading(!1),r&&this._setRead(r)}catch(t){if(e!==this._acqGen)return;this._setLoading(!1),this._setError(this._normalizeError(t))}}_onCopy=()=>{this._setCopied(this._selectionText())};_onCut=()=>{this._setCut(this._selectionText())};_onPaste=t=>{const e=t.clipboardData,r=e?e.getData("text/plain"):"";this._setPasted(r)};_removeMonitorListeners(){document.removeEventListener("copy",this._onCopy),document.removeEventListener("cut",this._onCut),document.removeEventListener("paste",this._onPaste)}_selectionText(){const t=document.getSelection();return t?t.toString():""}_initPermissions(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setReadPermission("unsupported"),this._setWritePermission("unsupported"),void(this._ready=Promise.resolve());this._permissionSubscribed=!0;const t=++this._permGen,e=this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),r=this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange);this._ready=Promise.all([e,r]).then(()=>{})}_queryPermission(t,e,r,i,s){return navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(r(t),i(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&i("unsupported")})}_onReadChange=t=>{const e=t.target;this._setReadPermission(e.state)};_onWriteChange=t=>{const e=t.target;this._setWritePermission(e.state)};_hasClipboard(){return"undefined"!=typeof navigator&&!!navigator.clipboard}async _normalizeItems(t){const e=await Promise.all(t.map(t=>Promise.all(t.types.map(e=>t.getType(e))).then(e=>({item:t,blobs:e})))),r=[];let i=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,r)=>{e[t]=s[r]}),null===i){const e=t.types.indexOf("text/plain");-1!==e&&(i=await s[e].text())}r.push({types:[...t.types],data:e})}return{text:i,items:r}}_normalizeError(t){return t instanceof Error?{name:t.name,message:t.message}:{name:"Error",message:String(t)}}_unsupportedError(){return{name:"NotSupportedError",message:"Clipboard API is not available in this environment."}}}let n=!1;const o="data-clipboard-text";function a(e){const r=e.target;if(!(r instanceof Element))return;const i=r.closest(`[${t.triggerAttribute}]`);if(!i)return;const s=i.getAttribute(t.triggerAttribute);if(!s)return;const n=customElements.get(t.tagNames.clipboard),a=document.getElementById(s);if(!(n&&a instanceof n))return;const c=function(t){if(t.hasAttribute(o))return t.getAttribute(o)??"";const e=t.getAttribute("data-clipboard-from");if(!e)return null;const r=document.querySelector(e);return r?r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement?r.value:r.textContent??"":null}(i);null!==c&&(e.preventDefault(),a.writeText(c))}function c(t,e){let r=Object.getPrototypeOf(t);for(;null!==r;){const t=Object.getOwnPropertyDescriptor(r,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;r=Object.getPrototypeOf(r)}return!1}class d extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...s.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:s.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new s(this),this._internals=this._initInternals(),this._wireStates({"wcs-clipboard:loading-changed":t=>({loading:!0===t}),"wcs-clipboard:monitoring-changed":t=>({monitoring:!0===t}),"wcs-clipboard:error":t=>({error:null!=t})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[r,i]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[s,n]of Object.entries(i(t.detail))){try{n?e.add(s):e.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,n)}})}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get readPermission(){return this._core.readPermission}get writePermission(){return this._core.writePermission}get monitoring(){return this._core.monitoring}get copied(){return this._core.copied}get cut(){return this._core.cut}get pasted(){return this._core.pasted}writeText(t){return this._core.writeText(t)}write(t){return this._core.write(t)}readText(){return this._core.readText()}read(){return this._core.read()}startMonitor(){this._core.startMonitor()}stopMonitor(){this._core.stopMonitor()}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,r=e?.inputs;if(void 0!==r)for(const e of r){const r=e.name;if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(!c(t,r))continue;const i=t,s=i[r];delete i[r],i[r]=s}}(this),this.style.display="none",n||(n=!0,document.addEventListener("click",a)),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}customElements.get(t.tagNames.clipboard)||customElements.define(t.tagNames.clipboard,d);
1
+ const t={triggerAttribute:"data-clipboardtarget",tagNames:{clipboard:"wcs-clipboard"}},e="capability-missing",r="not-allowed",i="clipboard-error";class s extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"text",event:"wcs-clipboard:read",semantics:"event",getter:t=>t.detail.text},{name:"items",event:"wcs-clipboard:read",semantics:"event",getter:t=>t.detail.items},{name:"loading",event:"wcs-clipboard:loading-changed",semantics:"state"},{name:"error",event:"wcs-clipboard:error",semantics:"state"},{name:"readPermission",event:"wcs-clipboard:read-permission-changed",semantics:"state"},{name:"writePermission",event:"wcs-clipboard:write-permission-changed",semantics:"state"},{name:"monitoring",event:"wcs-clipboard:monitoring-changed",semantics:"state"},{name:"errorInfo",event:"wcs-clipboard:error-info-changed",semantics:"state"},{name:"copied",event:"wcs-clipboard:copied",semantics:"event",getter:t=>t.detail},{name:"cut",event:"wcs-clipboard:cut",semantics:"event",getter:t=>t.detail},{name:"pasted",event:"wcs-clipboard:pasted",semantics:"event",getter:t=>t.detail}],commands:[{name:"writeText",async:!0},{name:"write",async:!0},{name:"readText",async:!0},{name:"read",async:!0},{name:"startMonitor"},{name:"stopMonitor"}]};_target;_text=null;_items=null;_loading=!1;_error=null;_errorInfo=null;_readPermission="prompt";_writePermission="prompt";_monitoring=!1;_copied=null;_cut=null;_pasted=null;_readStatus=null;_writeStatus=null;_permissionSubscribed=!1;_permGen=0;_acqGen=0;_ready=Promise.resolve();constructor(t){super(),this._target=t??this,this._initPermissions()}get ready(){return this._ready}observe(){return this.reinitPermission(),this._ready}get text(){return this._text}get items(){return this._items}get loading(){return this._loading}get error(){return this._error}get errorInfo(){return this._errorInfo}get readPermission(){return this._readPermission}get writePermission(){return this._writePermission}get monitoring(){return this._monitoring}get copied(){return this._copied}get cut(){return this._cut}get pasted(){return this._pasted}_setRead(t){this._text=t.text,this._items=t.items,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read",{detail:t,bubbles:!0}))}_setLoading(t){this._loading!==t&&(this._loading=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:loading-changed",{detail:t,bubbles:!0})))}_setError(t){var s,n;this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:(s=t.name,n=t.message,"NotSupportedError"===s?{code:e,phase:"start",recoverable:!1,message:n}:"NotAllowedError"===s?{code:r,phase:"execute",recoverable:!1,message:n}:{code:i,phase:"execute",recoverable:!0,message:n})),this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:error-info-changed",{detail:t,bubbles:!0}))}_setReadPermission(t){this._readPermission!==t&&(this._readPermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:read-permission-changed",{detail:t,bubbles:!0})))}_setWritePermission(t){this._writePermission!==t&&(this._writePermission=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:write-permission-changed",{detail:t,bubbles:!0})))}_setMonitoring(t){this._monitoring!==t&&(this._monitoring=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:monitoring-changed",{detail:t,bubbles:!0})))}_setCopied(t){this._copied=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:copied",{detail:t,bubbles:!0}))}_setCut(t){this._cut=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:cut",{detail:t,bubbles:!0}))}_setPasted(t){this._pasted=t,this._target.dispatchEvent(new CustomEvent("wcs-clipboard:pasted",{detail:t,bubbles:!0}))}writeText(t){return this._runWrite(()=>navigator.clipboard.writeText(t))}write(t){return this._runWrite(()=>navigator.clipboard.write(t))}readText(){return this._runRead(async()=>({text:await navigator.clipboard.readText(),items:null}))}read(){return this._runRead(async()=>{const t=await navigator.clipboard.read();return this._normalizeItems(t)})}startMonitor(){this._monitoring||(this._setMonitoring(!0),document.addEventListener("copy",this._onCopy),document.addEventListener("cut",this._onCut),document.addEventListener("paste",this._onPaste))}stopMonitor(){this._removeMonitorListeners(),this._setMonitoring(!1)}reinitPermission(){this._permissionSubscribed||this._initPermissions()}dispose(){this._permissionSubscribed=!1,this._permGen++,this._acqGen++,this._loading=!1,this._readStatus&&(this._readStatus.removeEventListener("change",this._onReadChange),this._readStatus=null),this._writeStatus&&(this._writeStatus.removeEventListener("change",this._onWriteChange),this._writeStatus=null),this._removeMonitorListeners(),this._monitoring=!1}_runWrite(t){return this._runOp(async()=>(await t(),null))}_runRead(t){return this._runOp(t)}async _runOp(t){if(!this._hasClipboard())return void this._setError(this._unsupportedError());const e=this._acqGen;this._setLoading(!0),this._setError(null);try{const r=await t();if(e!==this._acqGen)return;this._setLoading(!1),r&&this._setRead(r)}catch(t){if(e!==this._acqGen)return;this._setLoading(!1),this._setError(this._normalizeError(t))}}_onCopy=()=>{this._setCopied(this._selectionText())};_onCut=()=>{this._setCut(this._selectionText())};_onPaste=t=>{const e=t.clipboardData,r=e?e.getData("text/plain"):"";this._setPasted(r)};_removeMonitorListeners(){document.removeEventListener("copy",this._onCopy),document.removeEventListener("cut",this._onCut),document.removeEventListener("paste",this._onPaste)}_selectionText(){const t=document.getSelection();return t?t.toString():""}_initPermissions(){if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setReadPermission("unsupported"),this._setWritePermission("unsupported"),void(this._ready=Promise.resolve());this._permissionSubscribed=!0;const t=++this._permGen,e=this._queryPermission("clipboard-read",t,t=>{this._readStatus=t},t=>this._setReadPermission(t),this._onReadChange),r=this._queryPermission("clipboard-write",t,t=>{this._writeStatus=t},t=>this._setWritePermission(t),this._onWriteChange);this._ready=Promise.all([e,r]).then(()=>{})}_queryPermission(t,e,r,i,s){return navigator.permissions.query({name:t}).then(t=>{e===this._permGen&&(r(t),i(t.state),t.addEventListener("change",s))},()=>{e===this._permGen&&i("unsupported")})}_onReadChange=t=>{const e=t.target;this._setReadPermission(e.state)};_onWriteChange=t=>{const e=t.target;this._setWritePermission(e.state)};_hasClipboard(){return"undefined"!=typeof navigator&&!!navigator.clipboard}async _normalizeItems(t){const e=await Promise.all(t.map(t=>Promise.all(t.types.map(e=>t.getType(e))).then(e=>({item:t,blobs:e})))),r=[];let i=null;for(const{item:t,blobs:s}of e){const e={};if(t.types.forEach((t,r)=>{e[t]=s[r]}),null===i){const e=t.types.indexOf("text/plain");-1!==e&&(i=await s[e].text())}r.push({types:[...t.types],data:e})}return{text:i,items:r}}_normalizeError(t){return t instanceof Error?{name:t.name,message:t.message}:{name:"Error",message:String(t)}}_unsupportedError(){return{name:"NotSupportedError",message:"Clipboard API is not available in this environment."}}}let n=!1;const o="data-clipboard-text";function a(e){const r=e.target;if(!(r instanceof Element))return;const i=r.closest(`[${t.triggerAttribute}]`);if(!i)return;const s=i.getAttribute(t.triggerAttribute);if(!s)return;const n=customElements.get(t.tagNames.clipboard),a=document.getElementById(s);if(!(n&&a instanceof n))return;const c=function(t){if(t.hasAttribute(o))return t.getAttribute(o)??"";const e=t.getAttribute("data-clipboard-from");if(!e)return null;const r=document.querySelector(e);return r?r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement?r.value:r.textContent??"":null}(i);null!==c&&(e.preventDefault(),a.writeText(c))}function c(t,e){let r=Object.getPrototypeOf(t);for(;null!==r;){const t=Object.getOwnPropertyDescriptor(r,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;r=Object.getPrototypeOf(r)}return!1}class d extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...s.wcBindable,inputs:[{name:"monitor",attribute:"monitor"}],commands:s.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new s(this),this._internals=this._initInternals(),this._wireStates({"wcs-clipboard:loading-changed":t=>({loading:!0===t}),"wcs-clipboard:monitoring-changed":t=>({monitoring:!0===t}),"wcs-clipboard:error":t=>({error:null!=t})})}get connectedCallbackPromise(){return this._connectedCallbackPromise}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[r,i]of Object.entries(t))this.addEventListener(r,t=>{const r=this.hasAttribute("debug-states");for(const[s,n]of Object.entries(i(t.detail))){try{n?e.add(s):e.delete(s)}catch{}r&&this.toggleAttribute(`data-wcs-state-${s}`,n)}})}get monitor(){return this.hasAttribute("monitor")}set monitor(t){t?this.setAttribute("monitor",""):this.removeAttribute("monitor")}get text(){return this._core.text}get items(){return this._core.items}get loading(){return this._core.loading}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get readPermission(){return this._core.readPermission}get writePermission(){return this._core.writePermission}get monitoring(){return this._core.monitoring}get copied(){return this._core.copied}get cut(){return this._core.cut}get pasted(){return this._core.pasted}writeText(t){return this._core.writeText(t)}write(t){return this._core.write(t)}readText(){return this._core.readText()}read(){return this._core.read()}startMonitor(){this._core.startMonitor()}stopMonitor(){this._core.stopMonitor()}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,r=e?.inputs;if(void 0!==r)for(const e of r){const r=e.name;if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(!c(t,r))continue;const i=t,s=i[r];delete i[r],i[r]=s}}(this),this.style.display="none",n||(n=!0,document.addEventListener("click",a)),this._connectedCallbackPromise=this._core.observe(),this.monitor&&this._core.startMonitor()}disconnectedCallback(){this._core.stopMonitor(),this._core.dispose()}}var l;!function(e=customElements){e.get(t.tagNames.clipboard)||e.define(t.tagNames.clipboard,d)}(l);
2
2
  //# sourceMappingURL=auto.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/clipboardCapabilities.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/components/Clipboard.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 clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-clipboard:error\", semantics: \"state\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\", semantics: \"state\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\", semantics: \"state\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-changed\", semantics: \"state\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (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. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard: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-clipboard:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\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","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\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 get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n"],"names":["config","triggerAttribute","tagNames","clipboard","WCS_CLIPBOARD_ERROR_CODE","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_errorInfo","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","errorInfo","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","message","_commitErrorInfo","code","phase","recoverable","info","_setReadPermission","permission","_setWritePermission","_setMonitoring","_setCopied","_setCut","_setPasted","writeText","_runWrite","navigator","write","readText","_runRead","read","_normalizeItems","startMonitor","document","addEventListener","_onCopy","_onCut","_onPaste","stopMonitor","_removeMonitorListeners","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","readProbe","_queryPermission","s","state","writeProbe","all","then","assignStatus","setState","onChange","status","resolved","map","item","types","type","getType","blobs","normalized","forEach","i","indexOf","push","Error","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","set","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","toStates","entries","debug","on","toggleAttribute","monitor","setAttribute","removeAttribute","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","define"],"mappings":"AAUA,MA4BaA,EA5BoB,CAE/BC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBCFFC,EACQ,qBADRA,EAEC,cAFDA,EAGK,kBCeZ,MAAOC,UAAsBC,YACjCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOC,MACjH,CAAEN,KAAM,QAASC,MAAO,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IjChG,KAAKoI,0BAA4BpI,KAAKmI,MAAMhI,UAGxCH,KAAKqJ,SACPrJ,KAAKmI,MAAM1F,cAEf,CAEA,oBAAA0H,GACEnK,KAAKmI,MAAMpF,cACX/C,KAAKmI,MAAMlF,SACb,EC/MKsD,eAAeC,IAAIpJ,EAAOE,SAASC,YACtCgJ,eAAe6D,OAAOhN,EAAOE,SAASC,UAAWuK"}
1
+ {"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/clipboardCapabilities.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/components/Clipboard.ts","../src/bootstrapClipboard.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 clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-clipboard:error\", semantics: \"state\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\", semantics: \"state\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\", semantics: \"state\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-changed\", semantics: \"state\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (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. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard: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-clipboard:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\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","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\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 get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\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 bootstrapClipboard(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsClipboard } from \"./components/Clipboard.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.clipboard)) {\n registry.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n"],"names":["config","triggerAttribute","tagNames","clipboard","WCS_CLIPBOARD_ERROR_CODE","ClipboardCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","text","items","commands","async","_target","_text","_items","_loading","_error","_errorInfo","_readPermission","_writePermission","_monitoring","_copied","_cut","_pasted","_readStatus","_writeStatus","_permissionSubscribed","_permGen","_acqGen","_ready","Promise","resolve","constructor","target","super","this","_initPermissions","ready","observe","reinitPermission","loading","error","errorInfo","readPermission","writePermission","monitoring","copied","cut","pasted","_setRead","dispatchEvent","CustomEvent","bubbles","_setLoading","_setError","message","_commitErrorInfo","code","phase","recoverable","info","_setReadPermission","permission","_setWritePermission","_setMonitoring","_setCopied","_setCut","_setPasted","writeText","_runWrite","navigator","write","readText","_runRead","read","_normalizeItems","startMonitor","document","addEventListener","_onCopy","_onCut","_onPaste","stopMonitor","_removeMonitorListeners","dispose","removeEventListener","_onReadChange","_onWriteChange","op","_runOp","_hasClipboard","_unsupportedError","gen","err","_normalizeError","_selectionText","data","clipboardData","getData","selection","getSelection","toString","permissions","query","readProbe","_queryPermission","s","state","writeProbe","all","then","assignStatus","setState","onChange","status","resolved","map","item","types","type","getType","blobs","normalized","forEach","i","indexOf","push","Error","String","registered","TEXT_ATTRIBUTE","handleClick","Element","triggerElement","closest","clipboardId","getAttribute","ClipboardCtor","customElements","get","clipboardElement","getElementById","hasAttribute","selector","source","querySelector","HTMLInputElement","HTMLTextAreaElement","HTMLSelectElement","value","textContent","resolveText","preventDefault","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","undefined","set","WcsClipboard","HTMLElement","wcBindable","inputs","attribute","_core","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","connectedCallbackPromise","debugStates","states","attachInternals","internals","add","delete","toStates","entries","debug","on","toggleAttribute","monitor","setAttribute","removeAttribute","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","define","registerComponents"],"mappings":"AAUA,MA4BaA,EA5BoB,CAE/BC,iBAAkB,uBAClBC,SAAU,CACRC,UAAW,kBCFFC,EACQ,qBADRA,EAEC,cAFDA,EAGK,kBCeZ,MAAOC,UAAsBC,YACjCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,OAAQC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOC,MACjH,CAAEN,KAAM,QAASC,MAAO,qBAAsBC,UAAW,QAASC,OAASC,GAAcA,EAAkBC,OAAOE,OAClH,CAAEP,KAAM,UAAWC,MAAO,gCAAiCC,UAAW,SACtE,CAAEF,KAAM,QAASC,MAAO,sBAAuBC,UAAW,SAC1D,CAAEF,KAAM,iBAAkBC,MAAO,wCAAyCC,UAAW,SACrF,CAAEF,KAAM,kBAAmBC,MAAO,yCAA0CC,UAAW,SACvF,CAAEF,KAAM,aAAcC,MAAO,mC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AWuK,EAE/C,CDJEwC,CAAmBF"}
package/dist/index.d.ts CHANGED
@@ -155,7 +155,7 @@ interface WcsClipboardCoreCommands {
155
155
  /** Commands exposed on the Shell — identical surface to the Core. */
156
156
  type WcsClipboardCommands = WcsClipboardCoreCommands;
157
157
 
158
- declare function bootstrapClipboard(userConfig?: IWritableConfig): void;
158
+ declare function bootstrapClipboard(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void;
159
159
 
160
160
  declare function getConfig(): IConfig;
161
161
 
package/dist/index.esm.js CHANGED
@@ -888,17 +888,22 @@ class WcsClipboard extends HTMLElement {
888
888
  }
889
889
  }
890
890
 
891
- function registerComponents() {
892
- if (!customElements.get(config.tagNames.clipboard)) {
893
- customElements.define(config.tagNames.clipboard, WcsClipboard);
891
+ /**
892
+ * Register this package's tags. Pass a scoped `CustomElementRegistry` to define
893
+ * them for a single shadow tree -- scoped registries do not inherit the global
894
+ * one, so a tree using one needs its own definitions.
895
+ */
896
+ function registerComponents(registry = customElements) {
897
+ if (!registry.get(config.tagNames.clipboard)) {
898
+ registry.define(config.tagNames.clipboard, WcsClipboard);
894
899
  }
895
900
  }
896
901
 
897
- function bootstrapClipboard(userConfig) {
902
+ function bootstrapClipboard(userConfig, registry) {
898
903
  if (userConfig) {
899
904
  setConfig(userConfig);
900
905
  }
901
- registerComponents();
906
+ registerComponents(registry);
902
907
  }
903
908
 
904
909
  export { ClipboardCore, WCS_CLIPBOARD_ERROR_CODE, WcsClipboard, bootstrapClipboard, getConfig };
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/clipboardCapabilities.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/components/Clipboard.ts","../src/registerComponents.ts","../src/bootstrapClipboard.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-clipboard:error\", semantics: \"state\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\", semantics: \"state\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\", semantics: \"state\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-changed\", semantics: \"state\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (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. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard: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-clipboard:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\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","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\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 get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.clipboard)) {\n customElements.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA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,CAAC,KAAK,CAAC,WAAW,EAAE;AACxB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;SChNc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAClD,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IAChE;AACF;;ACHM,SAAU,kBAAkB,CAAC,UAA4B,EAAA;IAC7D,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/clipboardCapabilities.ts","../src/core/ClipboardCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/components/Clipboard.ts","../src/registerComponents.ts","../src/bootstrapClipboard.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n clipboard: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-clipboardtarget\",\n tagNames: {\n clipboard: \"wcs-clipboard\",\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\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","/**\n * clipboardCapabilities.ts\n *\n * Clipboard node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。clipboard の read/write は concurrent-independent(競合しない)ため lane\n * は持たず、error taxonomy(errorInfo)のみを採用する。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\n\n/** 安定した clipboard error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_CLIPBOARD_ERROR_CODE = {\n CapabilityMissing: \"capability-missing\",\n NotAllowed: \"not-allowed\",\n ClipboardError: \"clipboard-error\",\n} as const;\n\n/**\n * 正規化済み error(`{ name, message }`)を serializable な error taxonomy に写す。\n * `NotSupportedError`(Clipboard API 不在)→ capability-missing、`NotAllowedError`\n * (permission 拒否、retry では回復しない)→ not-allowed、その他 → clipboard-error。\n */\nexport function deriveClipboardErrorInfo(name: string, message: string): WcsIoErrorInfo {\n if (name === \"NotSupportedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.CapabilityMissing, phase: \"start\", recoverable: false, message };\n }\n if (name === \"NotAllowedError\") {\n return { code: WCS_CLIPBOARD_ERROR_CODE.NotAllowed, phase: \"execute\", recoverable: false, message };\n }\n return { code: WCS_CLIPBOARD_ERROR_CODE.ClipboardError, phase: \"execute\", recoverable: true, message };\n}\n","import {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardReadDetail, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport { deriveClipboardErrorInfo } from \"./clipboardCapabilities.js\";\n\n/**\n * Headless clipboard primitive. A thin, framework-agnostic wrapper around the\n * Clipboard API exposed through the wc-bindable protocol.\n *\n * It has two surfaces, mirroring the two distinct shapes of clipboard access:\n * - **commands** — `writeText()` / `write()` push to the clipboard;\n * `readText()` / `read()` pull from it. These are the `state → element`\n * (command-token) and `element → state` (read result) paths. All four are\n * async and never reject: failures surface through the `error` property so\n * they flow into the declarative state, symmetrical with FetchCore /\n * GeolocationCore.\n * - **monitor** — `startMonitor()` / `stopMonitor()` subscribe to the document's\n * `copy` / `cut` / `paste` events and republish them as the `copied` / `cut` /\n * `pasted` properties (like TimerCore's continuous `start()` / `stop()`),\n * toggling the `monitoring` flag. This is the event-token showcase: a user\n * paste flows element → state declaratively.\n *\n * Clipboard also has permission gates, like GeolocationCore but doubled: read\n * and write are separate permissions (`clipboard-read` / `clipboard-write`).\n * `readPermission` / `writePermission` reflect `navigator.permissions.query`\n * (`prompt` / `granted` / `denied`, or `unsupported`) and track their live\n * `change` events.\n */\nexport class ClipboardCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"text\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.text },\n { name: \"items\", event: \"wcs-clipboard:read\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail.items },\n { name: \"loading\", event: \"wcs-clipboard:loading-changed\", semantics: \"state\" },\n { name: \"error\", event: \"wcs-clipboard:error\", semantics: \"state\" },\n { name: \"readPermission\", event: \"wcs-clipboard:read-permission-changed\", semantics: \"state\" },\n { name: \"writePermission\", event: \"wcs-clipboard:write-permission-changed\", semantics: \"state\" },\n { name: \"monitoring\", event: \"wcs-clipboard:monitoring-changed\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from the normalized `error` (`name` →\n // capability-missing / not-allowed / clipboard-error); the existing `error`\n // property/event are unchanged. Fires `wcs-clipboard:error-info-changed`.\n { name: \"errorInfo\", event: \"wcs-clipboard:error-info-changed\", semantics: \"state\" },\n { name: \"copied\", event: \"wcs-clipboard:copied\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"cut\", event: \"wcs-clipboard:cut\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"pasted\", event: \"wcs-clipboard:pasted\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"writeText\", async: true },\n { name: \"write\", async: true },\n { name: \"readText\", async: true },\n { name: \"read\", async: true },\n { name: \"startMonitor\" },\n { name: \"stopMonitor\" },\n ],\n };\n\n private _target: EventTarget;\n\n private _text: string | null = null;\n private _items: WcsClipboardReadItem[] | null = null;\n private _loading: boolean = false;\n private _error: WcsClipboardErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _readPermission: ClipboardPermissionState = \"prompt\";\n private _writePermission: ClipboardPermissionState = \"prompt\";\n\n private _monitoring: boolean = false;\n private _copied: string | null = null;\n private _cut: string | null = null;\n private _pasted: string | null = null;\n\n // Live PermissionStatus handles (when the Permissions API is available), kept\n // so the `change` listeners can be removed on dispose(). Read and write are\n // separate permissions, hence two handles.\n private _readStatus: PermissionStatus | null = null;\n private _writeStatus: PermissionStatus | null = null;\n\n // True once a permission subscription has been (or is being) established, and\n // reset by dispose(). Guards reinitPermission() so the first connect after\n // construction does not double-subscribe, while a reconnect after dispose()\n // does re-subscribe. (Mirrors GeolocationCore.)\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current permission query round. Bumped by every\n // _initPermissions() and by dispose(). Each in-flight query captures it and,\n // on resolve, bails unless it is still current — so a query superseded by a\n // rapid (synchronous) disconnect→reconnect, or one that resolves after\n // dispose(), never attaches a listener.\n private _permGen: number = 0;\n\n // Monotonic id of the current async acquisition lifecycle (read/write),\n // bumped only by dispose(). Each command captures it at start; the resolution\n // bails (no setters) if it is stale, so an op that settles after the element\n // was disconnected does not dispatch wcs-clipboard:* on a torn-down element.\n // The Clipboard API has no AbortController, so a generation guard is the only\n // way to neutralize an in-flight op.\n private _acqGen: number = 0;\n\n // SSR (§3.8): resolves once the first permission probe settles, so the state\n // binder can await a real snapshot before reading. Set by _initPermissions();\n // Promise.resolve() when the Permissions API is unsupported (no async probe).\n private _ready: Promise<void> = Promise.resolve();\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n // Probe the permission states up front so observers see the real values\n // before the first read, then keep them live.\n this._initPermissions();\n }\n\n // SSR (§3.8): the first permission probe's settle promise.\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // Lifecycle (§3.5). Clipboard reads/writes are command-driven (they need a\n // user gesture), so observe() establishes no acquisition; it only (re)subscribes\n // to permission `change` events — idempotent while a subscription is live, and\n // reviving it after a dispose() (reconnect/reparent). Returns ready so the Shell\n // can expose it as connectedCallbackPromise.\n observe(): Promise<void> {\n this.reinitPermission();\n return this._ready;\n }\n\n get text(): string | null {\n return this._text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._items;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Exposed as an additive wc-bindable property (event\n * `wcs-clipboard:error-info-changed`), derived from the normalized `error`; the\n * existing `error` property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._writePermission;\n }\n\n get monitoring(): boolean {\n return this._monitoring;\n }\n\n get copied(): string | null {\n return this._copied;\n }\n\n get cut(): string | null {\n return this._cut;\n }\n\n get pasted(): string | null {\n return this._pasted;\n }\n\n // --- State setters with event dispatch ---\n\n // Deliberately NO same-value guard (unlike error/loading/permission/monitoring).\n // A read is a result event, not idempotent state: reading the same text twice is\n // two distinct user/command actions and must re-fire wcs-clipboard:read each time\n // so a `text:`/`items:` binding and command-result consumers see every read.\n private _setRead(detail: WcsClipboardReadDetail): void {\n this._text = detail.text;\n this._items = detail.items;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read\", {\n detail,\n bubbles: true,\n }));\n }\n\n private _setLoading(loading: boolean): void {\n if (this._loading === loading) return;\n this._loading = loading;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:loading-changed\", {\n detail: loading,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsClipboardErrorDetail | null): void {\n // Same-value guard. `error` has no derived state, so suppressing redundant\n // null→null dispatches (e.g. a successful op clearing an already-null error)\n // avoids spurious events. Reference identity is sufficient: each failure\n // builds a fresh object, and the clear path always passes the literal null.\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive it from\n // the normalized error (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. No lane here — clipboard's read/write ops don't compete.\n this._commitErrorInfo(error === null ? null : deriveClipboardErrorInfo(error.name, error.message));\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard: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-clipboard:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _setReadPermission(permission: ClipboardPermissionState): void {\n if (this._readPermission === permission) return;\n this._readPermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:read-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setWritePermission(permission: ClipboardPermissionState): void {\n if (this._writePermission === permission) return;\n this._writePermission = permission;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:write-permission-changed\", {\n detail: permission,\n bubbles: true,\n }));\n }\n\n private _setMonitoring(monitoring: boolean): void {\n if (this._monitoring === monitoring) return;\n this._monitoring = monitoring;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:monitoring-changed\", {\n detail: monitoring,\n bubbles: true,\n }));\n }\n\n // Deliberately NO same-value guard on the copied/cut/pasted setters (unlike\n // error/loading/permission/monitoring above). These are events, not state:\n // copying the same text twice is two distinct user actions and must re-fire\n // both times so an event-token subscriber (`eventToken.pasted: ...`) sees each\n // occurrence. Do not add a `===` guard here.\n private _setCopied(text: string): void {\n this._copied = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:copied\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setCut(text: string): void {\n this._cut = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:cut\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n private _setPasted(text: string): void {\n this._pasted = text;\n this._target.dispatchEvent(new CustomEvent(\"wcs-clipboard:pasted\", {\n detail: text,\n bubbles: true,\n }));\n }\n\n // --- Public API: write ---\n\n /**\n * Write plain text to the clipboard. Resolves once the write settles or fails\n * — never rejects: failures surface through `error`. Requires transient\n * activation (a user gesture), so call from a click handler / command-token.\n */\n writeText(text: string): Promise<void> {\n return this._runWrite(() => navigator.clipboard.writeText(text));\n }\n\n /**\n * Write rich `ClipboardItem`s (images, HTML, multiple MIME types) to the\n * clipboard. Resolves once the write settles or fails — never rejects.\n */\n write(items: ClipboardItem[]): Promise<void> {\n return this._runWrite(() => navigator.clipboard.write(items));\n }\n\n // --- Public API: read ---\n\n /**\n * Read plain text from the clipboard, publishing it via `text` and the\n * `wcs-clipboard:read` event. Resolves once the read settles or fails — never\n * rejects. Requires focus + read permission.\n */\n readText(): Promise<void> {\n return this._runRead(async () => {\n const text = await navigator.clipboard.readText();\n return { text, items: null };\n });\n }\n\n /**\n * Read rich `ClipboardItem`s from the clipboard, eagerly resolving every\n * representation to a `Blob`. A `text/plain` representation is also surfaced\n * via `text`. Resolves once the read settles or fails — never rejects.\n */\n read(): Promise<void> {\n return this._runRead(async () => {\n const items = await navigator.clipboard.read();\n return this._normalizeItems(items);\n });\n }\n\n // --- Public API: monitor ---\n\n /**\n * Begin monitoring document `copy` / `cut` / `paste` events, republishing\n * them as the `copied` / `cut` / `pasted` properties. Idempotent while already\n * monitoring (mirrors GeolocationCore.watch()).\n */\n startMonitor(): void {\n if (this._monitoring) return;\n this._setMonitoring(true);\n // §4 deviation: document-scoped Web API; no element-free alternative.\n // copy/cut/paste fire on `document`, so monitoring necessarily listens there\n // rather than on a Core-owned element. Registered as an allowed deviation.\n document.addEventListener(\"copy\", this._onCopy);\n document.addEventListener(\"cut\", this._onCut);\n document.addEventListener(\"paste\", this._onPaste);\n }\n\n stopMonitor(): void {\n this._removeMonitorListeners();\n this._setMonitoring(false);\n }\n\n // --- Permission lifecycle ---\n\n /**\n * Re-establish the permission `change` subscriptions after a dispose() — e.g.\n * the Shell element was disconnected and then reconnected (reparented). No-op\n * while a subscription is already live, so the first connect after\n * construction does not double-subscribe.\n */\n reinitPermission(): void {\n if (!this._permissionSubscribed) {\n this._initPermissions();\n }\n }\n\n /**\n * Detach the live permission `change` listeners and any monitor listeners, and\n * neutralize in-flight async ops. Call from the Shell's `disconnectedCallback`\n * so a removed element does not leak subscriptions or dispatch on a torn-down\n * element. A later reconnect can re-subscribe via reinitPermission().\n */\n dispose(): void {\n this._permissionSubscribed = false;\n // Invalidate any in-flight permission query so its .then() bails instead of\n // attaching a listener after teardown.\n this._permGen++;\n // Invalidate any in-flight read/write so its resolution bails instead of\n // dispatching on a disconnected element.\n this._acqGen++;\n // Reset the loading shadow silently (no dispatch on a disposed element). The\n // bailed resolution will not clear it, and leaving it true would let the\n // same-value guard swallow the loading=true edge of the next op after a\n // reconnect.\n this._loading = false;\n if (this._readStatus) {\n this._readStatus.removeEventListener(\"change\", this._onReadChange);\n this._readStatus = null;\n }\n if (this._writeStatus) {\n this._writeStatus.removeEventListener(\"change\", this._onWriteChange);\n this._writeStatus = null;\n }\n // Remove monitor listeners silently. The Shell calls stopMonitor() before\n // dispose(), but a direct headless dispose() still tears them down.\n this._removeMonitorListeners();\n this._monitoring = false;\n }\n\n // --- Internal: write/read runners ---\n\n private _runWrite(op: () => Promise<void>): Promise<void> {\n return this._runOp(async () => {\n await op();\n return null;\n });\n }\n\n private _runRead(op: () => Promise<WcsClipboardReadDetail>): Promise<void> {\n return this._runOp(op);\n }\n\n /**\n * Shared async-op lifecycle for read/write: capability check, loading toggle,\n * generation guard, never-reject error handling. When `op` returns a read\n * detail it is published; when it returns null (a write) nothing is published.\n */\n private async _runOp(op: () => Promise<WcsClipboardReadDetail | null>): Promise<void> {\n if (!this._hasClipboard()) {\n this._setError(this._unsupportedError());\n return;\n }\n const gen = this._acqGen;\n this._setLoading(true);\n this._setError(null);\n try {\n const detail = await op();\n // Stale: the element was disposed (disconnected) while this op was in\n // flight. Drop it so a torn-down element never dispatches wcs-clipboard:*.\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n if (detail) this._setRead(detail);\n } catch (err) {\n if (gen !== this._acqGen) return;\n this._setLoading(false);\n this._setError(this._normalizeError(err));\n }\n }\n\n // --- Internal: monitor handlers ---\n\n // During a `copy` / `cut` event the clipboard payload is not yet readable —\n // the browser returns an empty string for security reasons — so we report the\n // user's selected text (`document.getSelection().toString()`) instead. A page\n // that overrides the payload with a custom handler via clipboardData.setData()\n // is therefore NOT reflected here. (See README \"copy / cut text comes from the\n // selection\".) `paste` differs: clipboardData is readable, so _onPaste reads it.\n private _onCopy = (): void => {\n this._setCopied(this._selectionText());\n };\n\n private _onCut = (): void => {\n this._setCut(this._selectionText());\n };\n\n private _onPaste = (event: Event): void => {\n const data = (event as ClipboardEvent).clipboardData;\n const text = data ? data.getData(\"text/plain\") : \"\";\n this._setPasted(text);\n };\n\n private _removeMonitorListeners(): void {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n document.removeEventListener(\"copy\", this._onCopy);\n document.removeEventListener(\"cut\", this._onCut);\n document.removeEventListener(\"paste\", this._onPaste);\n }\n\n private _selectionText(): string {\n // §4 deviation: document-scoped Web API; no element-free alternative.\n const selection = document.getSelection();\n return selection ? selection.toString() : \"\";\n }\n\n // --- Internal: permission ---\n\n private _initPermissions(): void {\n // The Permissions API is optional. When absent (or it rejects, e.g. Firefox\n // does not expose the clipboard permission names), report \"unsupported\" and\n // leave reads/writes to fail loudly via the error property if attempted.\n // Note: we deliberately do NOT set _permissionSubscribed here — there is no\n // live subscription to tear down, so reinitPermission() re-runs this branch\n // on every reconnect. That is harmless: the same-value guard in\n // _setReadPermission/_setWritePermission swallows the redundant\n // unsupported→unsupported dispatch. (Mirrors GeolocationCore.)\n if (typeof navigator === \"undefined\" || !navigator.permissions || typeof navigator.permissions.query !== \"function\") {\n this._setReadPermission(\"unsupported\");\n this._setWritePermission(\"unsupported\");\n // No async probe: readiness is immediate (§3.8).\n this._ready = Promise.resolve();\n return;\n }\n this._permissionSubscribed = true;\n const gen = ++this._permGen;\n const readProbe = this._queryPermission(\n \"clipboard-read\", gen,\n (s) => { this._readStatus = s; },\n (state) => this._setReadPermission(state),\n this._onReadChange,\n );\n const writeProbe = this._queryPermission(\n \"clipboard-write\", gen,\n (s) => { this._writeStatus = s; },\n (state) => this._setWritePermission(state),\n this._onWriteChange,\n );\n // SSR (§3.8): ready resolves once both initial permission probes settle.\n this._ready = Promise.all([readProbe, writeProbe]).then(() => undefined);\n }\n\n private _queryPermission(\n name: string,\n gen: number,\n assignStatus: (status: PermissionStatus) => void,\n setState: (state: ClipboardPermissionState) => void,\n onChange: (event: Event) => void,\n ): Promise<void> {\n return navigator.permissions.query({ name: name as PermissionName }).then(\n (status) => {\n // Stale resolution: this query was superseded (rapid reconnect) or the\n // element was disposed while it was in flight. Drop it so only the\n // current subscription attaches a listener.\n if (gen !== this._permGen) return;\n assignStatus(status);\n setState(status.state as ClipboardPermissionState);\n status.addEventListener(\"change\", onChange);\n },\n () => {\n if (gen !== this._permGen) return;\n setState(\"unsupported\");\n },\n );\n }\n\n private _onReadChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setReadPermission(status.state as ClipboardPermissionState);\n };\n\n private _onWriteChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setWritePermission(status.state as ClipboardPermissionState);\n };\n\n // --- Internal: normalization ---\n\n private _hasClipboard(): boolean {\n return typeof navigator !== \"undefined\" && !!navigator.clipboard;\n }\n\n private async _normalizeItems(items: ClipboardItem[]): Promise<WcsClipboardReadDetail> {\n // Resolve every representation of every item in parallel. getType() calls are\n // independent, so awaiting them serially only adds latency. The trade-off is\n // intentional and unchanged from the serial version: if any getType() rejects\n // the whole read errors (no partial success), consistent with the never-reject\n // design where a failed op surfaces a single `error` rather than a half-filled\n // snapshot. Order is preserved so the `text` pick below stays deterministic.\n const resolved = await Promise.all(\n items.map((item) =>\n Promise.all(item.types.map((type) => item.getType(type))).then((blobs) => ({ item, blobs })),\n ),\n );\n\n const normalized: WcsClipboardReadItem[] = [];\n let text: string | null = null;\n for (const { item, blobs } of resolved) {\n const data: Record<string, Blob> = {};\n item.types.forEach((type, i) => {\n data[type] = blobs[i];\n });\n // Surface the first text/plain representation through `text` for the\n // common \"read whatever text is there\" case (first item, first match).\n if (text === null) {\n const i = item.types.indexOf(\"text/plain\");\n if (i !== -1) {\n text = await blobs[i].text();\n }\n }\n normalized.push({ types: [...item.types], data });\n }\n return { text, items: normalized };\n }\n\n private _normalizeError(err: unknown): WcsClipboardErrorDetail {\n if (err instanceof Error) {\n // DOMException is an Error subclass; its `name` (NotAllowedError, etc.) is\n // the meaningful discriminator for consumers switching on failure kind.\n return { name: err.name, message: err.message };\n }\n return { name: \"Error\", message: String(err) };\n }\n\n private _unsupportedError(): WcsClipboardErrorDetail {\n return {\n name: \"NotSupportedError\",\n message: \"Clipboard API is not available in this environment.\",\n };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsClipboard } from \"./components/Clipboard.js\";\n\nlet registered = false;\n\n// Attribute names for the optional copy-on-click DOM trigger (clipboard.js-style\n// DX). The element carrying `data-clipboardtarget` points at a <wcs-clipboard>\n// by id; the text to copy comes from either a literal `data-clipboard-text` or\n// a `data-clipboard-from` CSS selector resolving to a source element.\nconst TEXT_ATTRIBUTE = \"data-clipboard-text\";\nconst FROM_ATTRIBUTE = \"data-clipboard-from\";\n\nfunction resolveText(triggerElement: Element): string | null {\n // Literal text wins when present (including an empty string — copying \"\" is a\n // legitimate request).\n if (triggerElement.hasAttribute(TEXT_ATTRIBUTE)) {\n return triggerElement.getAttribute(TEXT_ATTRIBUTE) ?? \"\";\n }\n const selector = triggerElement.getAttribute(FROM_ATTRIBUTE);\n if (!selector) return null;\n const source = document.querySelector(selector);\n if (!source) return null;\n // Read a form control's `value`; fall back to text content. A bare\n // `\"value\" in source` check is too broad — it also matches <button>,\n // <li value>, <progress>, etc. (which carry an unrelated `value`), copying\n // the wrong thing. Narrow to the text-bearing controls a user actually points\n // `data-clipboard-from` at; everything else falls through to textContent.\n if (\n source instanceof HTMLInputElement ||\n source instanceof HTMLTextAreaElement ||\n source instanceof HTMLSelectElement\n ) {\n return source.value;\n }\n return source.textContent ?? \"\";\n}\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 clipboardId = triggerElement.getAttribute(config.triggerAttribute);\n if (!clipboardId) return;\n\n // Resolve the registered constructor at call time instead of importing\n // WcsClipboard as a value (avoids a components ⇄ autoTrigger import cycle:\n // Clipboard.connectedCallback() calls registerAutoTrigger()). instanceof\n // against the customElements registry keeps the same identity guarantee.\n const ClipboardCtor = customElements.get(config.tagNames.clipboard);\n const clipboardElement = document.getElementById(clipboardId);\n if (!ClipboardCtor || !(clipboardElement instanceof ClipboardCtor)) return;\n\n const text = resolveText(triggerElement);\n // No resolvable source: leave the click alone (do not preventDefault) so the\n // element's default action is unaffected.\n if (text === null) return;\n\n // Suppress the default action so a copy can run without navigating. Intentional:\n // do not attach data-clipboardtarget to an element whose default action you\n // also want (real <a href> link). See README \"Optional DOM Triggering\".\n event.preventDefault();\n (clipboardElement as WcsClipboard).writeText(text);\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","import { config } from \"../config.js\";\nimport {\n IWcBindable, ClipboardPermissionState,\n WcsClipboardReadItem, WcsClipboardErrorDetail,\n} from \"../types.js\";\nimport { ClipboardCore } from \"../core/ClipboardCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\n\n// Named WcsClipboard (not `Clipboard`) so the class does not shadow the global\n// DOM `Clipboard` interface (the type of `navigator.clipboard`), matching the\n// <wcs-geo> WcsGeolocation / <wcs-ws> WcsWebSocket convention.\nexport class WcsClipboard extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...ClipboardCore.wcBindable,\n // Shell-level settable surface. `monitor` mirrors its boolean attribute\n // (reflects idempotently), following the <wcs-ws> / <wcs-geo> convention.\n // There is no momentary `trigger` property: writes need an argument (the\n // text/items), so element actions are driven via command-token\n // (`command.writeText: $command.copy`) or the DOM autoTrigger, not a\n // false→true boolean pulse.\n inputs: [\n { name: \"monitor\", attribute: \"monitor\" },\n ],\n // Commands are identical to the Core's — no rename is needed because the\n // `monitor` boolean attribute accessor does not collide with the\n // `startMonitor` / `stopMonitor` command names (unlike <wcs-geo>, whose\n // `watch` attribute forced the Core's `watch` command to `watchPosition`).\n commands: ClipboardCore.wcBindable.commands,\n };\n\n private _core: ClipboardCore;\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new ClipboardCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-clipboard:loading-changed\": (d) => ({ loading: d === true }),\n \"wcs-clipboard:monitoring-changed\": (d) => ({ monitoring: d === true }),\n \"wcs-clipboard:error\": (d) => ({ error: d != null }),\n });\n }\n\n // SSR (§4.4): the state binder awaits this before snapshotting, so the first\n // permission probe has settled. Backed by _core.observe() (see connectedCallback).\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 get monitor(): boolean {\n return this.hasAttribute(\"monitor\");\n }\n\n /**\n * Reflects the `monitor` boolean attribute only — it does NOT start or stop\n * monitoring by itself. The attribute is read at connect time (see\n * connectedCallback); toggling `el.monitor` after connect just flips the\n * attribute. To start/stop monitoring imperatively, call `startMonitor()` /\n * `stopMonitor()`.\n */\n set monitor(value: boolean) {\n if (value) {\n this.setAttribute(\"monitor\", \"\");\n } else {\n this.removeAttribute(\"monitor\");\n }\n }\n\n // --- Core delegated getters ---\n\n get text(): string | null {\n return this._core.text;\n }\n\n get items(): WcsClipboardReadItem[] | null {\n return this._core.items;\n }\n\n get loading(): boolean {\n return this._core.loading;\n }\n\n get error(): WcsClipboardErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get readPermission(): ClipboardPermissionState {\n return this._core.readPermission;\n }\n\n get writePermission(): ClipboardPermissionState {\n return this._core.writePermission;\n }\n\n get monitoring(): boolean {\n return this._core.monitoring;\n }\n\n get copied(): string | null {\n return this._core.copied;\n }\n\n get cut(): string | null {\n return this._core.cut;\n }\n\n get pasted(): string | null {\n return this._core.pasted;\n }\n\n // --- Commands ---\n\n writeText(text: string): Promise<void> {\n return this._core.writeText(text);\n }\n\n write(items: ClipboardItem[]): Promise<void> {\n return this._core.write(items);\n }\n\n readText(): Promise<void> {\n return this._core.readText();\n }\n\n read(): Promise<void> {\n return this._core.read();\n }\n\n startMonitor(): void {\n this._core.startMonitor();\n }\n\n stopMonitor(): void {\n this._core.stopMonitor();\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n // upgrade 前に代入された input を取り込み直す(doc 13 §1.2 / Phase A1)\n upgradeProperties(this);\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // observe() revives permission tracking after a reconnect (reparenting) —\n // a no-op on the first connect since the constructor already subscribed — and\n // returns the readiness promise exposed as connectedCallbackPromise (§4.4).\n this._connectedCallbackPromise = this._core.observe();\n // Unlike <wcs-geo>, there is no connect-time acquisition: reads require a\n // user gesture, so the only connect-time action is optional monitoring.\n if (this.monitor) {\n this._core.startMonitor();\n }\n }\n\n disconnectedCallback(): void {\n this._core.stopMonitor();\n this._core.dispose();\n }\n}\n","import { WcsClipboard } from \"./components/Clipboard.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.clipboard)) {\n registry.define(config.tagNames.clipboard, WcsClipboard);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapClipboard(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,sBAAsB;AACxC,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE,eAAe;AAC3B,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,I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AE,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/clipboard",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "Declarative clipboard component for Web Components. Framework-agnostic Clipboard API primitive via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",