@wcstack/notification 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto.d.ts +2 -0
- package/dist/auto.min.js +1 -1
- package/dist/auto.min.js.map +1 -1
- package/dist/index.esm.js +20 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -2
package/dist/auto.d.ts
ADDED
package/dist/auto.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={autoTrigger:!0,triggerAttribute:"data-notifytarget",tagNames:{notify:"wcs-notify"}},e=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture"]);function s(t){const s=globalThis;if(!1===s.isSecureContext)return"insecure-context";if(!e.has(t))return null;const i=s.document?.permissionsPolicy??s.document?.featurePolicy;if(void 0===i||"function"!=typeof i.allowsFeature)return null;try{return i.allowsFeature(t)?null:"policy-blocked"}catch{return null}}const i="capability-missing",n="not-allowed",r="invalid-argument",o="show-failed",a="no-service-worker",c="notify-error";class h extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"permission",event:"wcs-notify:permission-change",semantics:"state"},{name:"granted",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"granted"===t.detail},{name:"denied",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"denied"===t.detail},{name:"prompt",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"prompt"===t.detail},{name:"unsupported",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"unsupported"===t.detail},{name:"error",event:"wcs-notify:error",semantics:"state"},{name:"errorInfo",event:"wcs-notify:error-info-changed",semantics:"state"},{name:"clicked",event:"wcs-notify:click",semantics:"event",getter:t=>t.detail},{name:"closed",event:"wcs-notify:close",semantics:"event",getter:t=>t.detail},{name:"shown",event:"wcs-notify:show",semantics:"event",getter:t=>t.detail}],commands:[{name:"request",async:!0},{name:"notify"},{name:"close"},{name:"closeAll"}]};_target;_mode="auto";_permission="prompt";_error=null;_errorInfo=null;_lastClick=null;_lastClose=null;_lastShow=null;_permissionStatus=null;_permissionSubscribed=!1;_gen=0;_ready=Promise.resolve();_idSeq=0;_toldNotReady=!1;_constructed=new Map;_swTags=new Set;_channel=null;_serviceWorker=null;_clicksSubscribed=!1;_seenIds=[];constructor(t){super(),this._target=t??this}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get prompt(){return"prompt"===this._permission}get unsupported(){return"unsupported"===this._permission}get error(){return this._error}get errorInfo(){return this._errorInfo}get clicked(){return this._lastClick}get closed(){return this._lastClose}get shown(){return this._lastShow}get ready(){return this._ready}_setPermission(t){this._permission!==t&&(this._permission=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:permission-change",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:function(t){const{error:e,message:s}=t;switch(e){case"unsupported":return{code:i,phase:"probe",recoverable:!1,message:s};case"not-granted":return{code:n,phase:"start",recoverable:!1,message:s};case"invalid-title":return{code:r,phase:"start",recoverable:!1,message:s};case"show-failed":return{code:o,phase:"execute",recoverable:!1,message:s};case"no-service-worker":return{code:a,phase:"execute",recoverable:!1,message:s};default:return{code:c,phase:"execute",recoverable:!1,message:s}}}(t)),this._target.dispatchEvent(new CustomEvent("wcs-notify:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:error-info-changed",{detail:t,bubbles:!0}))}_emit(t,e){"click"===t?this._lastClick=e:"close"===t?this._lastClose=e:this._lastShow=e,this._target.dispatchEvent(new CustomEvent(`wcs-notify:${t}`,{detail:e,bubbles:!0}))}observe(t="auto"){return this._mode=t,this._permissionSubscribed||(this._ready=this._initPermission(),this._subscribeClicks()),this._ready}async request(){const t=this._api();if(!t||"function"!=typeof t.requestPermission)return this._setPermission("unsupported"),this._permission;try{const e=await t.requestPermission();this._setPermission(this._normalize(e))}catch{}return this._permission}notify(t,e={}){if(!this._api()){const t=s("notifications");return this._setError(this._err("unsupported",null===t?"Notifications API is not available in this environment.":function(t,e,s){return"insecure-context"===s?`${t} needs a secure context (https:, or http://localhost), and this page is not one.`:`${t} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, or an <iframe> without allow="${e}". The browser's site settings cannot change that.`}("Notifications","notifications",t))),""}if("granted"!==this._permission)return this._setError(this._err("not-granted","Notification permission is not granted; call request() first.")),this._warnNotReady(),"";if("string"!=typeof t)return this._setError(this._err("invalid-title","notify() requires a string title.")),"";const i="string"==typeof e.tag&&""!==e.tag?e.tag:this._nextId(),n=e.data,r={__wcsId:i,payload:n},o={...e,tag:i,data:r};return this._setError(null),this._show(t,o,i,n),i}close(t){if("string"!=typeof t||""===t)return;const e=this._constructed.get(t);e&&(e.close(),this._constructed.delete(t)),this._swTags.has(t)&&(this._closeSw(t),this._swTags.delete(t))}closeAll(){for(const t of this._constructed.values())t.close();this._constructed.clear();for(const t of this._swTags)this._closeSw(t);this._swTags.clear()}dispose(){this._permissionSubscribed=!1,this._clicksSubscribed=!1,this._gen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null),this._channel&&(this._channel.removeEventListener("message",this._onInbound),this._channel.close(),this._channel=null),this._serviceWorker&&(this._serviceWorker.removeEventListener("message",this._onInbound),this._serviceWorker=null)}_initPermission(){const t=this._api();if(!t)return this._setPermission("unsupported"),Promise.resolve();if(this._permissionSubscribed=!0,"undefined"!=typeof navigator&&navigator.permissions&&"function"==typeof navigator.permissions.query){const e=++this._gen;return navigator.permissions.query({name:"notifications"}).then(t=>{e===this._gen&&(this._permissionStatus=t,this._setPermission(this._normalize(t.state)),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._gen&&this._setPermission(this._normalize(t.permission))})}return this._setPermission(this._normalize(t.permission)),Promise.resolve()}_onPermissionChange=t=>{const e=t.target;this._setPermission(this._normalize(e.state))};_normalize(t){return"default"===t?"prompt":"granted"===t||"denied"===t||"prompt"===t?t:"prompt"}_show(t,e,s,i){if("sw"===this._mode)return void this._showViaSw(t,e,s,i);this._showViaConstructor(t,e,s,i)||("auto"===this._mode?this._showViaSw(t,e,s,i):this._setError(this._err("show-failed",'new Notification() is not usable here and mode="constructor" disallows the Service Worker fallback.')))}_showViaConstructor(t,e,s,i){const n=this._api(),r=this._gen;let o;try{o=new n(t,e)}catch(t){return!(t instanceof TypeError)&&(this._setError(this._err("show-failed","Failed to create the notification.")),!0)}return this._constructed.set(s,o),o.onshow=()=>{r===this._gen&&this._emit("show",{tag:s,data:i,action:""})},o.onclick=()=>{r===this._gen&&this._emit("click",{tag:s,data:i,action:""})},o.onclose=()=>{this._constructed.delete(s),r===this._gen&&this._emit("close",{tag:s,data:i,action:""})},o.onerror=()=>{r===this._gen&&this._setError(this._err("show-failed","The notification failed to display."))},!0}_showViaSw(t,e,s,i){const n=navigator.serviceWorker;if(!n)return void this._setError(this._err("no-service-worker","Service Worker is required to show this notification but is unavailable."));const r=this._gen;this._swTags.add(s),n.ready.then(s=>s.showNotification(t,e)).then(()=>{r===this._gen&&this._emit("show",{tag:s,data:i,action:""})}).catch(()=>{r===this._gen&&this._setError(this._err("show-failed","ServiceWorkerRegistration.showNotification() failed."))})}_closeSw(t){const e=navigator.serviceWorker;e&&e.ready.then(e=>e.getNotifications({tag:t}).then(t=>{for(const e of t)e.close()})).catch(()=>{})}_subscribeClicks(){if(this._clicksSubscribed)return;this._clicksSubscribed=!0,"function"==typeof BroadcastChannel&&(this._channel=new BroadcastChannel("wcs-notify"),this._channel.addEventListener("message",this._onInbound));const t=navigator.serviceWorker;t&&(this._serviceWorker=t,t.addEventListener("message",this._onInbound))}_onInbound=t=>{const e=t.data;e&&!0===e.__wcsNotify&&(this._isDuplicate(e.id)||this._emit("click",{tag:e.tag,data:this._unwrap(e.data),action:e.action}))};_isDuplicate(t){return!!this._seenIds.includes(t)||(this._seenIds.push(t),this._seenIds.length>50&&this._seenIds.shift(),!1)}_unwrap(t){return null!==t&&"object"==typeof t&&"__wcsId"in t?t.payload:t}_api(){const t=globalThis;return"function"==typeof t.Notification&&null===s("notifications")?t.Notification:void 0}_warnNotReady(){this._toldNotReady||(this._toldNotReady=!0,console.warn(`[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is "${this._permission}", so nothing is shown. It goes to \`error\` too. Ask with request() first (from a user gesture), and notify once \`permission\` is "granted". (Said once per element.)`,this._target))}_nextId(){return"wcs-"+ ++this._idSeq}_err(t,e){return{error:t,message:e}}}let l=!1;function u(e){const s=e.target;if(!(s instanceof Element))return;let i;try{i=s.closest(`[${t.triggerAttribute}]`)}catch{return}if(!i)return;const n=i.getAttribute(t.triggerAttribute);if(!n)return;const r=customElements.get(t.tagNames.notify),o=document.getElementById(n);if(!(r&&o instanceof r))return;const a=i.getAttribute("data-notifytitle"),c=null!==a?a:i.textContent.trim(),h=i.getAttribute("data-notifybody");o.notify(c,null!==h?{body:h}:void 0)}function d(t,e){let s=Object.getPrototypeOf(t);for(;null!==s;){const t=Object.getOwnPropertyDescriptor(s,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;s=Object.getPrototypeOf(s)}return!1}const _=new WeakMap;function g(t,e){let s=_.get(t);return void 0===s&&(s=new Map,_.set(t,s)),s.has(e)||s.set(e,t.getAttribute(e)),s.get(e)}function m(t,e,s){null===s?t.removeAttribute(e):t.setAttribute(e,s)}function f(t,e,s){const i=g(t,e);m(t,e,void 0===s?i:null===s?null:String(s))}function p(t,e,s){const i=g(t,e);m(t,e,void 0===s?i:s?"":null)}class b extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...h.wcBindable,inputs:[{name:"notice"},{name:"mode",attribute:"mode"},{name:"body",attribute:"body"},{name:"icon",attribute:"icon"},{name:"badge",attribute:"badge"},{name:"tag",attribute:"tag"},{name:"lang",attribute:"lang"},{name:"dir",attribute:"dir"},{name:"requireInteraction",attribute:"require-interaction"},{name:"silent",attribute:"silent"},{name:"renotify",attribute:"renotify"},{name:"manual",attribute:"manual"}],commands:h.wcBindable.commands};_core;_notice="";_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new h(this),this._internals=this._initInternals(),this._wireStates({"wcs-notify:permission-change":t=>({granted:"granted"===t,denied:"denied"===t,prompt:"prompt"===t,unsupported:"unsupported"===t}),"wcs-notify:error":t=>({error:null!=t})})}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[s,i]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[n,r]of Object.entries(i(t.detail))){try{r?e.add(n):e.delete(n)}catch{}s&&this.toggleAttribute(`data-wcs-state-${n}`,r)}})}get mode(){const t=this.getAttribute("mode");return"sw"===t||"constructor"===t?t:"auto"}set mode(t){f(this,"mode",t)}get body(){return this.getAttribute("body")??""}set body(t){f(this,"body",t)}get icon(){return this.getAttribute("icon")??""}set icon(t){f(this,"icon",t)}get badge(){return this.getAttribute("badge")??""}set badge(t){f(this,"badge",t)}get tag(){return this.getAttribute("tag")??""}set tag(t){f(this,"tag",t)}get lang(){return this.getAttribute("lang")??""}set lang(t){f(this,"lang",t)}get dir(){return this.getAttribute("dir")??""}set dir(t){f(this,"dir",t)}get requireInteraction(){return this.hasAttribute("require-interaction")}set requireInteraction(t){p(this,"require-interaction",t)}get silent(){return this.hasAttribute("silent")}set silent(t){p(this,"silent",t)}get renotify(){return this.hasAttribute("renotify")}set renotify(t){p(this,"renotify",t)}get manual(){return this.hasAttribute("manual")}set manual(t){p(this,"manual",t)}get notice(){return this._notice}set notice(t){if(null==t)return;if(this.manual)return;const e=String(t);e!==this._notice&&(this._notice=e,this.notify(e))}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get clicked(){return this._core.clicked}get closed(){return this._core.closed}get shown(){return this._core.shown}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.request()}notify(t,e){return this._core.notify(t,{...this._options(),...e??{}})}close(t){this._core.close(t)}closeAll(){this._core.closeAll()}_options(){const t={};return""!==this.body&&(t.body=this.body),""!==this.icon&&(t.icon=this.icon),""!==this.badge&&(t.badge=this.badge),""!==this.tag&&(t.tag=this.tag),""!==this.lang&&(t.lang=this.lang),"auto"!==this.dir&&"ltr"!==this.dir&&"rtl"!==this.dir||(t.dir=this.dir),this.requireInteraction&&(t.requireInteraction=!0),this.silent&&(t.silent=!0),this.renotify&&(t.renotify=!0),t}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,s=e?.inputs;if(void 0!==s)for(const e of s){const s=e.name;if(!Object.prototype.hasOwnProperty.call(t,s))continue;if(!d(t,s))continue;const i=t,n=i[s];delete i[s],i[s]=n}}(this),this.style.display="none",l||(l=!0,document.addEventListener("click",u)),this._connectedCallbackPromise=this._core.observe(this.mode)}disconnectedCallback(){this._core.dispose()}}var w;!function(e=customElements){e.get(t.tagNames.notify)||e.define(t.tagNames.notify,b)}(w);
|
|
1
|
+
const t={autoTrigger:!0,triggerAttribute:"data-notifytarget",tagNames:{notify:"wcs-notify"}},e=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture"]);function s(t){const s=globalThis;if(!1===s.isSecureContext)return"insecure-context";if(!e.has(t))return null;const i=s.document?.permissionsPolicy??s.document?.featurePolicy;if(void 0===i||"function"!=typeof i.allowsFeature)return null;try{return i.allowsFeature(t)?null:"policy-blocked"}catch{return null}}const i="capability-missing",n="not-allowed",r="invalid-argument",o="show-failed",a="no-service-worker",c="notify-error";class h extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"permission",event:"wcs-notify:permission-change",semantics:"state"},{name:"granted",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"granted"===t.detail},{name:"denied",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"denied"===t.detail},{name:"prompt",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"prompt"===t.detail},{name:"unsupported",event:"wcs-notify:permission-change",semantics:"state",getter:t=>"unsupported"===t.detail},{name:"error",event:"wcs-notify:error",semantics:"state"},{name:"errorInfo",event:"wcs-notify:error-info-changed",semantics:"state"},{name:"clicked",event:"wcs-notify:click",semantics:"event",getter:t=>t.detail},{name:"closed",event:"wcs-notify:close",semantics:"event",getter:t=>t.detail},{name:"shown",event:"wcs-notify:show",semantics:"event",getter:t=>t.detail}],commands:[{name:"request",async:!0},{name:"notify"},{name:"close"},{name:"closeAll"}]};_target;_mode="auto";_permission="prompt";_error=null;_errorInfo=null;_lastClick=null;_lastClose=null;_lastShow=null;_permissionStatus=null;_permissionSubscribed=!1;_gen=0;_ready=Promise.resolve();_idSeq=0;_toldNotReady=!1;_constructed=new Map;_swTags=new Set;_channel=null;_serviceWorker=null;_clicksSubscribed=!1;_seenIds=[];constructor(t){super(),this._target=t??this}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get prompt(){return"prompt"===this._permission}get unsupported(){return"unsupported"===this._permission}get error(){return this._error}get errorInfo(){return this._errorInfo}get clicked(){return this._lastClick}get closed(){return this._lastClose}get shown(){return this._lastShow}get ready(){return this._ready}_setPermission(t){this._permission!==t&&(this._permission=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:permission-change",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._commitErrorInfo(null===t?null:function(t){const{error:e,message:s}=t;switch(e){case"unsupported":return{code:i,phase:"probe",recoverable:!1,message:s};case"not-granted":return{code:n,phase:"start",recoverable:!1,message:s};case"invalid-title":return{code:r,phase:"start",recoverable:!1,message:s};case"show-failed":return{code:o,phase:"execute",recoverable:!1,message:s};case"no-service-worker":return{code:a,phase:"execute",recoverable:!1,message:s};default:return{code:c,phase:"execute",recoverable:!1,message:s}}}(t)),this._target.dispatchEvent(new CustomEvent("wcs-notify:error",{detail:t,bubbles:!0})))}_commitErrorInfo(t){this._errorInfo=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:error-info-changed",{detail:t,bubbles:!0}))}_emit(t,e){"click"===t?this._lastClick=e:"close"===t?this._lastClose=e:this._lastShow=e,this._target.dispatchEvent(new CustomEvent(`wcs-notify:${t}`,{detail:e,bubbles:!0}))}observe(t="auto"){return this._mode=t,this._permissionSubscribed||(this._ready=this._initPermission(),this._subscribeClicks()),this._ready}async request(){const t=this._api();if(!t||"function"!=typeof t.requestPermission)return this._setPermission("unsupported"),this._permission;try{const e=await t.requestPermission();this._setPermission(this._normalize(e))}catch{}return this._permission}notify(t,e={}){if(!this._api()){const t=s("notifications");return this._setError(this._err("unsupported",null===t?"Notifications API is not available in this environment.":function(t,e,s){return"insecure-context"===s?`${t} needs a secure context (https:, or http://localhost), and this page is not one.`:`${t} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, or an <iframe> without allow="${e}". The browser's site settings cannot change that.`}("Notifications","notifications",t))),""}if("granted"!==this._permission)return this._setError(this._err("not-granted","Notification permission is not granted; call request() first.")),this._warnNotReady(),"";if("string"!=typeof t)return this._setError(this._err("invalid-title","notify() requires a string title.")),"";const i="string"==typeof e.tag&&""!==e.tag?e.tag:this._nextId(),n=e.data,r={__wcsId:i,payload:n},o={...e,tag:i,data:r};return this._setError(null),this._show(t,o,i,n),i}close(t){if("string"!=typeof t||""===t)return;const e=this._constructed.get(t);e&&(e.close(),this._constructed.delete(t)),this._swTags.has(t)&&(this._closeSw(t),this._swTags.delete(t))}closeAll(){for(const t of this._constructed.values())t.close();this._constructed.clear();for(const t of this._swTags)this._closeSw(t);this._swTags.clear()}dispose(){this._permissionSubscribed=!1,this._clicksSubscribed=!1,this._gen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null),this._channel&&(this._channel.removeEventListener("message",this._onInbound),this._channel.close(),this._channel=null),this._serviceWorker&&(this._serviceWorker.removeEventListener("message",this._onInbound),this._serviceWorker=null)}_initPermission(){const t=this._api();if(!t)return this._setPermission("unsupported"),Promise.resolve();if(this._permissionSubscribed=!0,"undefined"!=typeof navigator&&navigator.permissions&&"function"==typeof navigator.permissions.query){const e=++this._gen;return navigator.permissions.query({name:"notifications"}).then(t=>{e===this._gen&&(this._permissionStatus=t,this._setPermission(this._normalize(t.state)),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._gen&&this._setPermission(this._normalize(t.permission))})}return this._setPermission(this._normalize(t.permission)),Promise.resolve()}_onPermissionChange=t=>{const e=t.target;this._setPermission(this._normalize(e.state))};_normalize(t){return"default"===t?"prompt":"granted"===t||"denied"===t||"prompt"===t?t:"prompt"}_show(t,e,s,i){if("sw"===this._mode)return void this._showViaSw(t,e,s,i);this._showViaConstructor(t,e,s,i)||("auto"===this._mode?this._showViaSw(t,e,s,i):this._setError(this._err("show-failed",'new Notification() is not usable here and mode="constructor" disallows the Service Worker fallback.')))}_showViaConstructor(t,e,s,i){const n=this._api(),r=this._gen;let o;try{o=new n(t,e)}catch(t){return!(t instanceof TypeError)&&(this._setError(this._err("show-failed","Failed to create the notification.")),!0)}return this._constructed.set(s,o),o.onshow=()=>{r===this._gen&&this._emit("show",{tag:s,data:i,action:""})},o.onclick=()=>{r===this._gen&&this._emit("click",{tag:s,data:i,action:""})},o.onclose=()=>{this._constructed.delete(s),r===this._gen&&this._emit("close",{tag:s,data:i,action:""})},o.onerror=()=>{r===this._gen&&this._setError(this._err("show-failed","The notification failed to display."))},!0}_showViaSw(t,e,s,i){const n=navigator.serviceWorker;if(!n)return void this._setError(this._err("no-service-worker","Service Worker is required to show this notification but is unavailable."));const r=this._gen;this._swTags.add(s),n.ready.then(s=>s.showNotification(t,e)).then(()=>{r===this._gen&&this._emit("show",{tag:s,data:i,action:""})}).catch(()=>{r===this._gen&&this._setError(this._err("show-failed","ServiceWorkerRegistration.showNotification() failed."))})}_closeSw(t){const e=navigator.serviceWorker;e&&e.ready.then(e=>e.getNotifications({tag:t}).then(t=>{for(const e of t)e.close()})).catch(()=>{})}_subscribeClicks(){if(this._clicksSubscribed)return;this._clicksSubscribed=!0,"function"==typeof BroadcastChannel&&(this._channel=new BroadcastChannel("wcs-notify"),this._channel.addEventListener("message",this._onInbound));const t=navigator.serviceWorker;t&&(this._serviceWorker=t,t.addEventListener("message",this._onInbound))}_onInbound=t=>{const e=t.data;e&&!0===e.__wcsNotify&&(this._isDuplicate(e.id)||this._emit("click",{tag:e.tag,data:this._unwrap(e.data),action:e.action}))};_isDuplicate(t){return!!this._seenIds.includes(t)||(this._seenIds.push(t),this._seenIds.length>50&&this._seenIds.shift(),!1)}_unwrap(t){return null!==t&&"object"==typeof t&&"__wcsId"in t?t.payload:t}_api(){const t=globalThis;return"function"==typeof t.Notification&&null===s("notifications")?t.Notification:void 0}_warnNotReady(){this._toldNotReady||(this._toldNotReady=!0,console.warn(`[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is "${this._permission}", so nothing is shown. It goes to \`error\` too. Ask with request() first (from a user gesture), and notify once \`permission\` is "granted". (Said once per element.)`,this._target))}_nextId(){return"wcs-"+ ++this._idSeq}_err(t,e){return{error:t,message:e}}}let l=!1;function u(e){const s=e.target;if(!(s instanceof Element))return;let i;try{i=s.closest(`[${t.triggerAttribute}]`)}catch{return}if(!i)return;const n=i.getAttribute(t.triggerAttribute);if(!n)return;const r=customElements.get(t.tagNames.notify),o=document.getElementById(n);if(!(r&&o instanceof r))return;const a=i.getAttribute("data-notifytitle"),c=null!==a?a:i.textContent.trim(),h=i.getAttribute("data-notifybody");o.notify(c,null!==h?{body:h}:void 0)}function d(t,e){let s=Object.getPrototypeOf(t);for(;null!==s;){const t=Object.getOwnPropertyDescriptor(s,e);if(void 0!==t)return"function"==typeof t.get||"function"==typeof t.set;s=Object.getPrototypeOf(s)}return!1}const _=new WeakSet;function g(t,e,s){if(_.has(t))return;_.add(t);const i=t.localName??"element";console.warn(`[wcs/input-as-attribute] <${i}> has the attribute ${e}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,t)}const m=new WeakMap;function f(t,e){let s=m.get(t);return void 0===s&&(s=new Map,m.set(t,s)),s.has(e)||s.set(e,t.getAttribute(e)),s.get(e)}function p(t,e,s){null===s?t.removeAttribute(e):t.setAttribute(e,s)}function b(t,e,s){const i=f(t,e);p(t,e,void 0===s?i:null===s?null:String(s))}function w(t,e,s){const i=f(t,e);p(t,e,void 0===s?i:s?"":null)}class y extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...h.wcBindable,inputs:[{name:"notice"},{name:"mode",attribute:"mode"},{name:"body",attribute:"body"},{name:"icon",attribute:"icon"},{name:"badge",attribute:"badge"},{name:"tag",attribute:"tag"},{name:"lang",attribute:"lang"},{name:"dir",attribute:"dir"},{name:"requireInteraction",attribute:"require-interaction"},{name:"silent",attribute:"silent"},{name:"renotify",attribute:"renotify"},{name:"manual",attribute:"manual"}],commands:h.wcBindable.commands};_core;_notice="";_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new h(this),this._internals=this._initInternals(),this._wireStates({"wcs-notify:permission-change":t=>({granted:"granted"===t,denied:"denied"===t,prompt:"prompt"===t,unsupported:"unsupported"===t}),"wcs-notify:error":t=>({error:null!=t})})}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[s,i]of Object.entries(t))this.addEventListener(s,t=>{const s=this.hasAttribute("debug-states");for(const[n,r]of Object.entries(i(t.detail))){try{r?e.add(n):e.delete(n)}catch{}s&&this.toggleAttribute(`data-wcs-state-${n}`,r)}})}get mode(){const t=this.getAttribute("mode");return"sw"===t||"constructor"===t?t:"auto"}set mode(t){b(this,"mode",t)}get body(){return this.getAttribute("body")??""}set body(t){b(this,"body",t)}get icon(){return this.getAttribute("icon")??""}set icon(t){b(this,"icon",t)}get badge(){return this.getAttribute("badge")??""}set badge(t){b(this,"badge",t)}get tag(){return this.getAttribute("tag")??""}set tag(t){b(this,"tag",t)}get lang(){return this.getAttribute("lang")??""}set lang(t){b(this,"lang",t)}get dir(){return this.getAttribute("dir")??""}set dir(t){b(this,"dir",t)}get requireInteraction(){return this.hasAttribute("require-interaction")}set requireInteraction(t){w(this,"require-interaction",t)}get silent(){return this.hasAttribute("silent")}set silent(t){w(this,"silent",t)}get renotify(){return this.hasAttribute("renotify")}set renotify(t){w(this,"renotify",t)}get manual(){return this.hasAttribute("manual")}set manual(t){w(this,"manual",t)}get notice(){return this._notice}set notice(t){if(null==t)return;if(this.manual)return;const e=String(t);e!==this._notice&&(this._notice=e,this.notify(e))}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get errorInfo(){return this._core.errorInfo}get clicked(){return this._core.clicked}get closed(){return this._core.closed}get shown(){return this._core.shown}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.request()}notify(t,e){return this._core.notify(t,{...this._options(),...e??{}})}close(t){this._core.close(t)}closeAll(){this._core.closeAll()}_options(){const t={};return""!==this.body&&(t.body=this.body),""!==this.icon&&(t.icon=this.icon),""!==this.badge&&(t.badge=this.badge),""!==this.tag&&(t.tag=this.tag),""!==this.lang&&(t.lang=this.lang),"auto"!==this.dir&&"ltr"!==this.dir&&"rtl"!==this.dir||(t.dir=this.dir),this.requireInteraction&&(t.requireInteraction=!0),this.silent&&(t.silent=!0),this.renotify&&(t.renotify=!0),t}connectedCallback(){!function(t){const e=t.constructor?.wcBindable,s=e?.inputs;if(void 0===s)return;const i=t.getAttribute;for(const e of s){const s=e.name,n="function"==typeof i?i.call(t,s.toLowerCase()):null;if(null!==n&&n.startsWith("[object ")&&g(t,s,n),!Object.prototype.hasOwnProperty.call(t,s))continue;if(!d(t,s))continue;const r=t,o=r[s];delete r[s],r[s]=o}}(this),this.style.display="none",l||(l=!0,document.addEventListener("click",u)),this._connectedCallbackPromise=this._core.observe(this.mode)}disconnectedCallback(){this._core.dispose()}}var v;!function(e=customElements){e.get(t.tagNames.notify)||e.define(t.tagNames.notify,y)}(v);
|
|
2
2
|
//# sourceMappingURL=auto.min.js.map
|
package/dist/auto.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/platformCapability.ts","../src/core/notificationCapabilities.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/Notify.ts","../src/bootstrapNotification.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 notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\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\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNotification` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/notification] bootstrapNotification: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * notificationCapabilities.ts\n *\n * Notification node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。notification は監視(permission)と操作(notify/close)を 1 タグに併せ持つが、\n * 競合する非同期 operation の lane は持たない(show は最新値で上書きされる momentary な\n * 送出)ため、lane は採用せず error taxonomy(errorInfo)のみを追加する。\n *\n * sensor family と異なり、NotificationCore の error detail の `.error` は既に安定コード\n * (`this._err(code, message)` が産出する `\"unsupported\"` / `\"not-granted\"` /\n * `\"invalid-title\"` / `\"show-failed\"` / `\"no-service-worker\"`)であり、Error.name ではない。\n * したがって derivation は `.error` コードを taxonomy に写すだけの純粋な map である。\n * 想定外のコードは防御的に `notify-error` へ畳む。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport type { WcsNotifyErrorDetail } from \"../types.js\";\n\n/** 安定した notification error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_NOTIFY_ERROR_CODE = {\n /** Notifications API 非対応(`globalThis.Notification` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** 権限が granted でない状態での notify()。 */\n NotAllowed: \"not-allowed\",\n /** notify() に非文字列 title が渡された。 */\n InvalidArgument: \"invalid-argument\",\n /** notification の生成 / 表示に失敗した(constructor 例外 / onerror / SW show reject)。 */\n ShowFailed: \"show-failed\",\n /** SW backend が必要だが `navigator.serviceWorker` が不在。 */\n NoServiceWorker: \"no-service-worker\",\n /** その他 / 想定外の error code に対する防御的 fallback。 */\n NotifyError: \"notify-error\",\n} as const;\n\n/**\n * notification の失敗を serializable な error taxonomy に写す。引数は\n * `wcs-notify:error` の detail(`{ error, message }`)そのもの。`.error` は\n * `NotificationCore._err()` が付与した安定コードで、Error.name ではない。\n *\n * - `\"unsupported\"` は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `\"not-granted\"` / `\"invalid-title\"` は show 手前の前提条件違反(権限・引数)→\n * phase=\"start\" / not-allowed・invalid-argument。\n * - `\"show-failed\"` は show 実行中の失敗 → phase=\"execute\" / show-failed。\n * - `\"no-service-worker\"` は SW backend 要求時の transport 欠如 → phase=\"execute\" /\n * no-service-worker。\n * - それ以外(未知コード)は防御的に phase=\"execute\" / notify-error。\n *\n * いずれも retry で自動回復しない(recoverable=false)。\n */\nexport function deriveNotifyErrorInfo(error: WcsNotifyErrorDetail): WcsIoErrorInfo {\n const { error: code, message } = error;\n switch (code) {\n case \"unsupported\":\n return { code: WCS_NOTIFY_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n case \"not-granted\":\n return { code: WCS_NOTIFY_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n case \"invalid-title\":\n return { code: WCS_NOTIFY_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n case \"show-failed\":\n return { code: WCS_NOTIFY_ERROR_CODE.ShowFailed, phase: \"execute\", recoverable: false, message };\n case \"no-service-worker\":\n return { code: WCS_NOTIFY_ERROR_CODE.NoServiceWorker, phase: \"execute\", recoverable: false, message };\n default:\n return { code: WCS_NOTIFY_ERROR_CODE.NotifyError, phase: \"execute\", recoverable: false, message };\n }\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable, featureUnavailableMessage } from \"./platformCapability.js\";\nimport { deriveNotifyErrorInfo } from \"./notificationCapabilities.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the stable code the\n // Core's `_err()` already produces); the existing `error` property/event are\n // unchanged. Fires wcs-notify:error-info-changed. No lane — show is a\n // momentary, last-value-wins send, not a competing async operation.\n { name: \"errorInfo\", event: \"wcs-notify:error-info-changed\", semantics: \"state\" },\n { name: \"clicked\", event: \"wcs-notify:click\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n /** Whether `[wcs/command-not-ready]` was said for this element. */\n private _toldNotReady = false;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-notify:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // stable error code (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveNotifyErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already guards on error identity), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n const reason = featureUnavailable(\"notifications\");\n this._setError(this._err(\"unsupported\", reason === null\n ? \"Notifications API is not available in this environment.\"\n : featureUnavailableMessage(\"Notifications\", \"notifications\", reason)));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n this._warnNotReady();\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n // A page that cannot use notifications (not a secure context) has none: Chromium\n // keeps the constructor there and answers \"denied\", which reads as the user's refusal.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" && featureUnavailable(\"notifications\") === null ? g.Notification : undefined;\n }\n\n // A notification refused because the permission is not granted was lost, and only a\n // page that binds `error` heard of it. Said once per element (docs/v4-direction-2026-10.md\n // §5.1, the I/O command policy).\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n `[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is \"${this._permission}\", ` +\n \"so nothing is shown. It goes to `error` too. Ask with request() first (from a user gesture), and \" +\n \"notify once `permission` is \\\"granted\\\". (Said once per element.)\",\n this._target,\n );\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // 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 // Input setters never let setAttribute stringify null / undefined: `null`\n // removes the attribute (the default — no option, `mode` \"auto\"), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not).\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend | null | undefined) {\n reflectAttribute(this, \"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null | undefined) {\n reflectAttribute(this, \"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null | undefined) {\n reflectAttribute(this, \"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null | undefined) {\n reflectAttribute(this, \"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null | undefined) {\n reflectAttribute(this, \"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null | undefined) {\n reflectAttribute(this, \"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null | undefined) {\n reflectAttribute(this, \"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). @wcstack/state never writes\n // `undefined`, but a wc-bindable applier writes it after a value (applier\n // profile A2; React 19 does too), and a direct assignment can: \"no value\" is\n // not a notice, so null/undefined are a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\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 // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\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 bootstrapNotification(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsNotify } from \"./components/Notify.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.notify)) {\n registry.define(config.tagNames.notify, WcsNotify);\n }\n}\n"],"names":["config","autoTrigger","triggerAttribute","tagNames","notify","POLICY_CONTROLLED","Set","featureUnavailable","feature","g","globalThis","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","WCS_NOTIFY_ERROR_CODE","NotificationCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","async","_target","_mode","_permission","_error","_errorInfo","_lastClick","_lastClose","_lastShow","_permissionStatus","_permissionSubscribed","_gen","_ready","Promise","resolve","_idSeq","_toldNotReady","_constructed","Map","_swTags","_channel","_serviceWorker","_clicksSubscribed","_seenIds","constructor","target","super","this","permission","granted","denied","prompt","unsupported","error","errorInfo","clicked","closed","shown","ready","_setPermission","state","dispatchEvent","CustomEvent","bubbles","_setError","_commitErrorInfo","code","message","phase","recoverable","deriveNotifyErrorInfo","info","_emit","kind","observe","mode","_initPermission","_subscribeClicks","request","api","_api","requestPermission","result","_normalize","title","options","reason","_err","what","featureUnavailableMessage","_warnNotReady","tag","_nextId","payload","data","__wcsId","backendOptions","_show","close","n","get","delete","_closeSw","closeAll","values","clear","dispose","removeEventListener","_onPermissionChange","_onInbound","navigator","permissions","query","gen","then","status","addEventListener","raw","_showViaSw","_showViaConstructor","TypeError","set","onshow","action","onclick","onclose","onerror","sw","serviceWorker","add","registration","showNotification","catch","getNotifications","list","BroadcastChannel","msg","__wcsNotify","_isDuplicate","id","_unwrap","includes","push","length","shift","Notification","console","warn","registered","handleClick","Element","triggerElement","closest","notifyId","getAttribute","NotifyCtor","customElements","notifyElement","getElementById","explicit","textContent","trim","body","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","initialAttributes","WeakMap","initialAttribute","el","byName","writeAttribute","value","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsNotify","HTMLElement","wcBindable","inputs","attribute","_core","_notice","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","m","icon","badge","lang","dir","requireInteraction","silent","renotify","manual","notice","v","connectedCallbackPromise","_options","o","connectedCallback","element","declaration","input","prototype","hasOwnProperty","call","record","upgradeProperties","style","display","disconnectedCallback","registry","define","registerComponents"],"mappings":"AAUA,MAkCaA,EAlCoB,CAC/BC,aAAa,EACbC,iBAAkB,oBAClBC,SAAU,CACRC,OAAQ,eC6INC,EAAoB,IAAIC,IAAI,CAChC,SAAU,aAAc,cAAe,OAAQ,iBAAkB,kBACjE,mBAAoB,iBAAkB,gBAAiB,YAAa,eACpE,uBAAwB,oBAKpB,SAAUC,EAAmBC,GACjC,MAAMC,EAAIC,WACV,IAA0B,IAAtBD,EAAEE,gBAA2B,MAAO,mBACxC,IAAKN,EAAkBO,IAAIJ,GAAU,OAAO,KAC5C,MAAMK,EAASJ,EAAEK,UAAUC,mBAAqBN,EAAEK,UAAUE,cAC5D,QAAeC,IAAXJ,GAAwD,mBAAzBA,EAAOK,cAA8B,OAAO,KAC/E,IACE,OAAOL,EAAOK,cAAcV,GAAW,KAAO,gBAChD,CAAE,MACA,OAAO,IACT,CACF,CC1JO,MAAMW,EAEQ,qBAFRA,E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AAAC,IFjRI,SAA4BC,GAChC,MAAMC,EAAeD,EAA2DhL,aAAa4I,WACvFC,EAASoC,GAAapC,OAC5B,QAAerL,IAAXqL,EACJ,IAAK,MAAMqC,KAASrC,EAAQ,CAC1B,MAAM5K,EAAOiN,EAAMjN,KACnB,IAAKwJ,OAAO0D,UAAUC,eAAeC,KAAKL,EAAS/M,GAAO,SAC1D,IAAKsJ,EAAuByD,EAAS/M,GAAO,SAC5C,MAAMqN,EAASN,EACT7C,EAAQmD,EAAOrN,UACdqN,EAAOrN,GACdqN,EAAOrN,GAAQkK,CACjB,CACF,CEsQIoD,CAAkBpL,MAClBA,KAAKqL,MAAMC,QAAU,OHpRnBjF,IACJA,GAAa,EACbnJ,SAASmH,iBAAiB,QAASiC,IGyRjCtG,KAAK8I,0BAA4B9I,KAAK4I,MAAMjH,QAAQ3B,KAAK4B,KAC3D,CAEA,oBAAA2J,GAGEvL,KAAK4I,MAAMjF,SACb,EC5UI,IAA8D6H,GCI9D,SAA6BA,EAAkC3E,gBAC9D2E,EAASnI,IAAIjH,EAAOG,SAASC,SAChCgP,EAASC,OAAOrP,EAAOG,SAASC,OAAQ+L,EAE5C,CDJEmD,CAAmBF"}
|
|
1
|
+
{"version":3,"file":"auto.min.js","sources":["../src/config.ts","../src/core/platformCapability.ts","../src/core/notificationCapabilities.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/Notify.ts","../src/bootstrapNotification.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 notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\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\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNotification` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/notification] bootstrapNotification: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * notificationCapabilities.ts\n *\n * Notification node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。notification は監視(permission)と操作(notify/close)を 1 タグに併せ持つが、\n * 競合する非同期 operation の lane は持たない(show は最新値で上書きされる momentary な\n * 送出)ため、lane は採用せず error taxonomy(errorInfo)のみを追加する。\n *\n * sensor family と異なり、NotificationCore の error detail の `.error` は既に安定コード\n * (`this._err(code, message)` が産出する `\"unsupported\"` / `\"not-granted\"` /\n * `\"invalid-title\"` / `\"show-failed\"` / `\"no-service-worker\"`)であり、Error.name ではない。\n * したがって derivation は `.error` コードを taxonomy に写すだけの純粋な map である。\n * 想定外のコードは防御的に `notify-error` へ畳む。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport type { WcsNotifyErrorDetail } from \"../types.js\";\n\n/** 安定した notification error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_NOTIFY_ERROR_CODE = {\n /** Notifications API 非対応(`globalThis.Notification` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** 権限が granted でない状態での notify()。 */\n NotAllowed: \"not-allowed\",\n /** notify() に非文字列 title が渡された。 */\n InvalidArgument: \"invalid-argument\",\n /** notification の生成 / 表示に失敗した(constructor 例外 / onerror / SW show reject)。 */\n ShowFailed: \"show-failed\",\n /** SW backend が必要だが `navigator.serviceWorker` が不在。 */\n NoServiceWorker: \"no-service-worker\",\n /** その他 / 想定外の error code に対する防御的 fallback。 */\n NotifyError: \"notify-error\",\n} as const;\n\n/**\n * notification の失敗を serializable な error taxonomy に写す。引数は\n * `wcs-notify:error` の detail(`{ error, message }`)そのもの。`.error` は\n * `NotificationCore._err()` が付与した安定コードで、Error.name ではない。\n *\n * - `\"unsupported\"` は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `\"not-granted\"` / `\"invalid-title\"` は show 手前の前提条件違反(権限・引数)→\n * phase=\"start\" / not-allowed・invalid-argument。\n * - `\"show-failed\"` は show 実行中の失敗 → phase=\"execute\" / show-failed。\n * - `\"no-service-worker\"` は SW backend 要求時の transport 欠如 → phase=\"execute\" /\n * no-service-worker。\n * - それ以外(未知コード)は防御的に phase=\"execute\" / notify-error。\n *\n * いずれも retry で自動回復しない(recoverable=false)。\n */\nexport function deriveNotifyErrorInfo(error: WcsNotifyErrorDetail): WcsIoErrorInfo {\n const { error: code, message } = error;\n switch (code) {\n case \"unsupported\":\n return { code: WCS_NOTIFY_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n case \"not-granted\":\n return { code: WCS_NOTIFY_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n case \"invalid-title\":\n return { code: WCS_NOTIFY_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n case \"show-failed\":\n return { code: WCS_NOTIFY_ERROR_CODE.ShowFailed, phase: \"execute\", recoverable: false, message };\n case \"no-service-worker\":\n return { code: WCS_NOTIFY_ERROR_CODE.NoServiceWorker, phase: \"execute\", recoverable: false, message };\n default:\n return { code: WCS_NOTIFY_ERROR_CODE.NotifyError, phase: \"execute\", recoverable: false, message };\n }\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable, featureUnavailableMessage } from \"./platformCapability.js\";\nimport { deriveNotifyErrorInfo } from \"./notificationCapabilities.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the stable code the\n // Core's `_err()` already produces); the existing `error` property/event are\n // unchanged. Fires wcs-notify:error-info-changed. No lane — show is a\n // momentary, last-value-wins send, not a competing async operation.\n { name: \"errorInfo\", event: \"wcs-notify:error-info-changed\", semantics: \"state\" },\n { name: \"clicked\", event: \"wcs-notify:click\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n /** Whether `[wcs/command-not-ready]` was said for this element. */\n private _toldNotReady = false;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-notify:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // stable error code (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveNotifyErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already guards on error identity), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n const reason = featureUnavailable(\"notifications\");\n this._setError(this._err(\"unsupported\", reason === null\n ? \"Notifications API is not available in this environment.\"\n : featureUnavailableMessage(\"Notifications\", \"notifications\", reason)));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n this._warnNotReady();\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n // A page that cannot use notifications (not a secure context) has none: Chromium\n // keeps the constructor there and answers \"denied\", which reads as the user's refusal.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" && featureUnavailable(\"notifications\") === null ? g.Notification : undefined;\n }\n\n // A notification refused because the permission is not granted was lost, and only a\n // page that binds `error` heard of it. Said once per element (docs/v4-direction-2026-10.md\n // §5.1, the I/O command policy).\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n `[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is \"${this._permission}\", ` +\n \"so nothing is shown. It goes to `error` too. Ask with request() first (from a user gesture), and \" +\n \"notify once `permission` is \\\"granted\\\". (Said once per element.)\",\n this._target,\n );\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // 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 // Input setters never let setAttribute stringify null / undefined: `null`\n // removes the attribute (the default — no option, `mode` \"auto\"), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not).\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend | null | undefined) {\n reflectAttribute(this, \"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null | undefined) {\n reflectAttribute(this, \"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null | undefined) {\n reflectAttribute(this, \"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null | undefined) {\n reflectAttribute(this, \"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null | undefined) {\n reflectAttribute(this, \"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null | undefined) {\n reflectAttribute(this, \"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null | undefined) {\n reflectAttribute(this, \"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). @wcstack/state never writes\n // `undefined`, but a wc-bindable applier writes it after a value (applier\n // profile A2; React 19 does too), and a direct assignment can: \"no value\" is\n // not a notice, so null/undefined are a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\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 // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\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 bootstrapNotification(userConfig?: IWritableConfig, registry?: CustomElementRegistry): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents(registry);\n}\n","import { WcsNotify } from \"./components/Notify.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.notify)) {\n registry.define(config.tagNames.notify, WcsNotify);\n }\n}\n"],"names":["config","autoTrigger","triggerAttribute","tagNames","notify","POLICY_CONTROLLED","Set","featureUnavailable","feature","g","globalThis","isSecureContext","has","policy","document","permissionsPolicy","featurePolicy","undefined","allowsFeature","WCS_NOTIFY_ERROR_CODE","NotificationCore","EventTarget","static","protocol","version","properties","name","event","semantics","getter","e","detail","commands","async","_target","_mode","_permission","_error","_errorInfo","_lastClick","_lastClose","_lastShow","_permissionStatus","_permissionSubscribed","_gen","_ready","Promise","resolve","_idSeq","_toldNotReady","_constructed","Map","_swTags","_channel","_serviceWorker","_clicksSubscribed","_seenIds","constructor","target","super","this","permission","granted","denied","prompt","unsupported","error","errorInfo","clicked","closed","shown","ready","_setPermission","state","dispatchEvent","CustomEvent","bubbles","_setError","_commitErrorInfo","code","message","phase","recoverable","deriveNotifyErrorInfo","info","_emit","kind","observe","mode","_initPermission","_subscribeClicks","request","api","_api","requestPermission","result","_normalize","title","options","reason","_err","what","featureUnavailableMessage","_warnNotReady","tag","_nextId","payload","data","__wcsId","backendOptions","_show","close","n","get","delete","_closeSw","closeAll","values","clear","dispose","removeEventListener","_onPermissionChange","_onInbound","navigator","permissions","query","gen","then","status","addEventListener","raw","_showViaSw","_showViaConstructor","TypeError","set","onshow","action","onclick","onclose","onerror","sw","serviceWorker","add","registration","showNotification","catch","getNotifications","list","BroadcastChannel","msg","__wcsNotify","_isDuplicate","id","_unwrap","includes","push","length","shift","Notification","console","warn","registered","handleClick","Element","triggerElement","closest","notifyId","getAttribute","NotifyCtor","customElements","notifyElement","getElementById","explicit","textContent","trim","body","hasAccessorOnPrototype","proto","Object","getPrototypeOf","descriptor","getOwnPropertyDescriptor","toldObjectAttribute","WeakSet","warnObjectAttribute","element","value","localName","initialAttributes","WeakMap","initialAttribute","el","byName","writeAttribute","removeAttribute","setAttribute","reflectAttribute","initial","String","reflectBooleanAttribute","WcsNotify","HTMLElement","wcBindable","inputs","attribute","_core","_notice","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","m","icon","badge","lang","dir","requireInteraction","silent","renotify","manual","notice","v","connectedCallbackPromise","_options","o","connectedCallback","declaration","input","call","toLowerCase","startsWith","prototype","hasOwnProperty","record","upgradeProperties","style","display","disconnectedCallback","registry","define","registerComponents"],"mappings":"AAUA,MAkCaA,EAlCoB,CAC/BC,aAAa,EACbC,iBAAkB,oBAClBC,SAAU,CACRC,OAAQ,eC6INC,EAAoB,IAAIC,IAAI,CAChC,SAAU,aAAc,cAAe,OAAQ,iBAAkB,kBACjE,mBAAoB,iBAAkB,gBAAiB,YAAa,eACpE,uBAAwB,oBAKpB,SAAUC,EAAmBC,GACjC,MAAMC,EAAIC,WACV,IAA0B,IAAtBD,EAAEE,gBAA2B,MAAO,mBACxC,IAAKN,EAAkBO,IAAIJ,GAAU,OAAO,KAC5C,MAAMK,EAASJ,EAAEK,UAAUC,mBAAqBN,EAAEK,UAAUE,cAC5D,QAAeC,IAAXJ,GAAwD,mBAAzBA,EAAOK,cAA8B,OAAO,KAC/E,IACE,OAAOL,EAAOK,cAAcV,GAAW,KAAO,gBAChD,CAAE,MACA,OAAO,IACT,CACF,CC1JO,MAAMW,EAEQ,qBAFRA,EAIC,cAJDA,EAMM,mBANNA,EAQC,cARDA,EAUM,oBAVNA,EAYE,eCqBT,MAAOC,UAAyBC,YACpCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,aAAcC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AqB,GAChDxK,KAAKyK,SAAQO,EAAEP,QAAS,GACxBzK,KAAK0K,WAAUM,EAAEN,UAAW,GACzBM,CACT,CAIA,iBAAAC,IF7PI,SAA4BpD,GAChC,MAAMqD,EAAerD,EAA2DhI,aAAaiJ,WACvFC,EAASmC,GAAanC,OAC5B,QAAe1L,IAAX0L,EAAsB,OAC1B,MAAMpC,EAAgBkB,EAA+DlB,aACrF,IAAK,MAAMwE,KAASpC,EAAQ,CAC1B,MAAMjL,EAAOqN,EAAMrN,KACbkL,EAAoC,mBAAjBrC,EAA8BA,EAAayE,KAAKvD,EAAS/J,EAAKuN,eAAiB,KAExG,GADkB,OAAdrC,GAAsBA,EAAUsC,WAAW,aAAa1D,EAAoBC,EAAS/J,EAAMkL,IAC1F1B,OAAOiE,UAAUC,eAAeJ,KAAKvD,EAAS/J,GAAO,SAC1D,IAAKsJ,EAAuBS,EAAS/J,GAAO,SAC5C,MAAM2N,EAAS5D,EACTC,EAAQ2D,EAAO3N,UACd2N,EAAO3N,GACd2N,EAAO3N,GAAQgK,CACjB,CACF,CE+OI4D,CAAkB1L,MAClBA,KAAK2L,MAAMC,QAAU,OHpRnBvF,IACJA,GAAa,EACbnJ,SAASmH,iBAAiB,QAASiC,IGyRjCtG,KAAKmJ,0BAA4BnJ,KAAKiJ,MAAMtH,QAAQ3B,KAAK4B,KAC3D,CAEA,oBAAAiK,GAGE7L,KAAKiJ,MAAMtF,SACb,EC5UI,IAA8DmI,GCI9D,SAA6BA,EAAkCjF,gBAC9DiF,EAASzI,IAAIjH,EAAOG,SAASC,SAChCsP,EAASC,OAAO3P,EAAOG,SAASC,OAAQoM,EAE5C,CDJEoD,CAAmBF"}
|
package/dist/index.esm.js
CHANGED
|
@@ -752,6 +752,21 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
752
752
|
}
|
|
753
753
|
return false;
|
|
754
754
|
}
|
|
755
|
+
// 属性になってしまったオブジェクトの入力(`files="[object File]"`)を、要素ごとに 1 回だけ言う。
|
|
756
|
+
// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も
|
|
757
|
+
// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった
|
|
758
|
+
// (docs/seam-apps.md、fw-inventory)。
|
|
759
|
+
const toldObjectAttribute = new WeakSet();
|
|
760
|
+
function warnObjectAttribute(element, name, value) {
|
|
761
|
+
if (toldObjectAttribute.has(element))
|
|
762
|
+
return;
|
|
763
|
+
toldObjectAttribute.add(element);
|
|
764
|
+
const tag = element.localName ?? "element";
|
|
765
|
+
console.warn(`[wcs/input-as-attribute] <${tag}> has the attribute ${name}="${value}": an object was written as an ` +
|
|
766
|
+
`attribute, so the element did not receive it. A framework does that when the property is set before the ` +
|
|
767
|
+
`element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +
|
|
768
|
+
`or assign the property through a ref (Vue: .prop). (Said once per element.)`, element);
|
|
769
|
+
}
|
|
755
770
|
/**
|
|
756
771
|
* `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で
|
|
757
772
|
* accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。
|
|
@@ -759,14 +774,19 @@ function hasAccessorOnPrototype(target, name) {
|
|
|
759
774
|
* - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。
|
|
760
775
|
* - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。
|
|
761
776
|
* - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。
|
|
777
|
+
* - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。
|
|
762
778
|
*/
|
|
763
779
|
function upgradeProperties(element) {
|
|
764
780
|
const declaration = element.constructor?.wcBindable;
|
|
765
781
|
const inputs = declaration?.inputs;
|
|
766
782
|
if (inputs === undefined)
|
|
767
783
|
return;
|
|
784
|
+
const getAttribute = element.getAttribute;
|
|
768
785
|
for (const input of inputs) {
|
|
769
786
|
const name = input.name;
|
|
787
|
+
const attribute = typeof getAttribute === "function" ? getAttribute.call(element, name.toLowerCase()) : null;
|
|
788
|
+
if (attribute !== null && attribute.startsWith("[object "))
|
|
789
|
+
warnObjectAttribute(element, name, attribute);
|
|
770
790
|
if (!Object.prototype.hasOwnProperty.call(element, name))
|
|
771
791
|
continue;
|
|
772
792
|
if (!hasAccessorOnPrototype(element, name))
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/platformCapability.ts","../src/core/notificationCapabilities.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/Notify.ts","../src/registerComponents.ts","../src/bootstrapNotification.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\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\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNotification` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/notification] bootstrapNotification: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * notificationCapabilities.ts\n *\n * Notification node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。notification は監視(permission)と操作(notify/close)を 1 タグに併せ持つが、\n * 競合する非同期 operation の lane は持たない(show は最新値で上書きされる momentary な\n * 送出)ため、lane は採用せず error taxonomy(errorInfo)のみを追加する。\n *\n * sensor family と異なり、NotificationCore の error detail の `.error` は既に安定コード\n * (`this._err(code, message)` が産出する `\"unsupported\"` / `\"not-granted\"` /\n * `\"invalid-title\"` / `\"show-failed\"` / `\"no-service-worker\"`)であり、Error.name ではない。\n * したがって derivation は `.error` コードを taxonomy に写すだけの純粋な map である。\n * 想定外のコードは防御的に `notify-error` へ畳む。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport type { WcsNotifyErrorDetail } from \"../types.js\";\n\n/** 安定した notification error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_NOTIFY_ERROR_CODE = {\n /** Notifications API 非対応(`globalThis.Notification` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** 権限が granted でない状態での notify()。 */\n NotAllowed: \"not-allowed\",\n /** notify() に非文字列 title が渡された。 */\n InvalidArgument: \"invalid-argument\",\n /** notification の生成 / 表示に失敗した(constructor 例外 / onerror / SW show reject)。 */\n ShowFailed: \"show-failed\",\n /** SW backend が必要だが `navigator.serviceWorker` が不在。 */\n NoServiceWorker: \"no-service-worker\",\n /** その他 / 想定外の error code に対する防御的 fallback。 */\n NotifyError: \"notify-error\",\n} as const;\n\n/**\n * notification の失敗を serializable な error taxonomy に写す。引数は\n * `wcs-notify:error` の detail(`{ error, message }`)そのもの。`.error` は\n * `NotificationCore._err()` が付与した安定コードで、Error.name ではない。\n *\n * - `\"unsupported\"` は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `\"not-granted\"` / `\"invalid-title\"` は show 手前の前提条件違反(権限・引数)→\n * phase=\"start\" / not-allowed・invalid-argument。\n * - `\"show-failed\"` は show 実行中の失敗 → phase=\"execute\" / show-failed。\n * - `\"no-service-worker\"` は SW backend 要求時の transport 欠如 → phase=\"execute\" /\n * no-service-worker。\n * - それ以外(未知コード)は防御的に phase=\"execute\" / notify-error。\n *\n * いずれも retry で自動回復しない(recoverable=false)。\n */\nexport function deriveNotifyErrorInfo(error: WcsNotifyErrorDetail): WcsIoErrorInfo {\n const { error: code, message } = error;\n switch (code) {\n case \"unsupported\":\n return { code: WCS_NOTIFY_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n case \"not-granted\":\n return { code: WCS_NOTIFY_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n case \"invalid-title\":\n return { code: WCS_NOTIFY_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n case \"show-failed\":\n return { code: WCS_NOTIFY_ERROR_CODE.ShowFailed, phase: \"execute\", recoverable: false, message };\n case \"no-service-worker\":\n return { code: WCS_NOTIFY_ERROR_CODE.NoServiceWorker, phase: \"execute\", recoverable: false, message };\n default:\n return { code: WCS_NOTIFY_ERROR_CODE.NotifyError, phase: \"execute\", recoverable: false, message };\n }\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable, featureUnavailableMessage } from \"./platformCapability.js\";\nimport { deriveNotifyErrorInfo } from \"./notificationCapabilities.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the stable code the\n // Core's `_err()` already produces); the existing `error` property/event are\n // unchanged. Fires wcs-notify:error-info-changed. No lane — show is a\n // momentary, last-value-wins send, not a competing async operation.\n { name: \"errorInfo\", event: \"wcs-notify:error-info-changed\", semantics: \"state\" },\n { name: \"clicked\", event: \"wcs-notify:click\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n /** Whether `[wcs/command-not-ready]` was said for this element. */\n private _toldNotReady = false;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-notify:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // stable error code (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveNotifyErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already guards on error identity), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n const reason = featureUnavailable(\"notifications\");\n this._setError(this._err(\"unsupported\", reason === null\n ? \"Notifications API is not available in this environment.\"\n : featureUnavailableMessage(\"Notifications\", \"notifications\", reason)));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n this._warnNotReady();\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n // A page that cannot use notifications (not a secure context) has none: Chromium\n // keeps the constructor there and answers \"denied\", which reads as the user's refusal.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" && featureUnavailable(\"notifications\") === null ? g.Notification : undefined;\n }\n\n // A notification refused because the permission is not granted was lost, and only a\n // page that binds `error` heard of it. Said once per element (docs/v4-direction-2026-10.md\n // §5.1, the I/O command policy).\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n `[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is \"${this._permission}\", ` +\n \"so nothing is shown. It goes to `error` too. Ask with request() first (from a user gesture), and \" +\n \"notify once `permission` is \\\"granted\\\". (Said once per element.)\",\n this._target,\n );\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n for (const input of inputs) {\n const name = input.name;\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // 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 // Input setters never let setAttribute stringify null / undefined: `null`\n // removes the attribute (the default — no option, `mode` \"auto\"), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not).\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend | null | undefined) {\n reflectAttribute(this, \"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null | undefined) {\n reflectAttribute(this, \"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null | undefined) {\n reflectAttribute(this, \"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null | undefined) {\n reflectAttribute(this, \"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null | undefined) {\n reflectAttribute(this, \"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null | undefined) {\n reflectAttribute(this, \"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null | undefined) {\n reflectAttribute(this, \"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). @wcstack/state never writes\n // `undefined`, but a wc-bindable applier writes it after a value (applier\n // profile A2; React 19 does too), and a direct assignment can: \"no value\" is\n // not a notice, so null/undefined are a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\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 // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { WcsNotify } from \"./components/Notify.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.notify)) {\n registry.define(config.tagNames.notify, WcsNotify);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(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,mBAAmB;AACrC,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACrB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;IACvD,MAAM,KAAK,GAA4B,EAAE;IACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAClC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/D;AACA,IAAA,OAAO,KAAU;AACnB;AAEA,IAAI,YAAY,GAAmB,IAAI;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AM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACzC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IACpD;AACF;;ACRM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;IACA,kBAAkB,CAAC,QAAQ,CAAC;AAC9B;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/platformCapability.ts","../src/core/notificationCapabilities.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/protocol/upgradeProperties.ts","../src/protocol/inputAttribute.ts","../src/components/Notify.ts","../src/registerComponents.ts","../src/bootstrapNotification.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\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\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\n/** A misspelt option would otherwise do nothing: `bootstrapNotification` refuses it. */\nfunction invalid(key: string): never {\n throw new Error(`[@wcstack/notification] bootstrapNotification: \"${key}\" is not one of its options, or not of the option's type.`);\n}\n\n/**\n * Applies the options given; an undefined value is left out. An option this package does not\n * have, a value of another type than its default (null, or an array for an object, included) or\n * a tag name it does not define throws, and then nothing is applied.\n */\nexport function setConfig(partialConfig: IWritableConfig): void {\n const options = _config as unknown as Record<string, unknown>;\n const tags = _config.tagNames as Record<string, string>;\n const given = Object.entries(partialConfig).filter(([, value]) => value !== undefined);\n const givenTags = Object.entries(partialConfig.tagNames ?? {}).filter(([, tag]) => tag !== undefined);\n for (const [key, value] of given) {\n const current = options[key];\n if (!Object.hasOwn(options, key) || value === null || typeof value !== typeof current || Array.isArray(value) !== Array.isArray(current)) {\n invalid(key);\n }\n }\n for (const [name, tag] of givenTags) {\n if (!Object.hasOwn(tags, name) || typeof tag !== \"string\") invalid(`tagNames.${name}`);\n }\n for (const [key, value] of given) {\n if (key !== \"tagNames\") {\n options[key] = value;\n }\n }\n for (const [name, tag] of givenTags) tags[name] = tag as string;\n frozenConfig = null;\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /io-core/platform-capability.ts by scripts/sync-io-core.mjs.\n// Run `node scripts/sync-io-core.mjs` after editing the source.\n// ===========================================================================\n\n/**\n * platform-capability.ts\n *\n * Phase 6(docs/architecture-hardening/09-remediation-design.md §7.2 /\n * 07-browser-capability-variance.md)の browser capability 判定と error taxonomy の\n * 汎用プリミティブ。node 固有の capability registry / error code は各パッケージが\n * 別ファイルで宣言し、この汎用層(型 + assess 機構)を import する。\n *\n * 原則:\n * - feature detection は境界(利用直前)で行う。module 評価時に browser global を\n * 参照しない(SSR / worker で import が失敗しない)。\n * - capability ID(`web.fetch` 等)は文字列を global property path として eval せず、\n * registry が ID ごとに副作用のない presence probe を対応付ける。\n * - availability / permission / readiness / activity / operation error を 1 つの\n * `ready / unsupported / error` enum に畳まない。required 欠如は開始しない、\n * optional 欠如は宣言済み fallback で readiness を `degraded` にする。\n *\n * 配置: 本ファイルは /io-core/ の単一正典であり、scripts/sync-io-core.mjs が\n * 各 IO ノードの src/core/ へ生成コピー (AUTO-GENERATED, 編集禁止) を配布する。\n * `protocol/wcBindable.ts` と同じ copy-distribution 方式で、ランタイム依存を導入せず\n * 各パッケージのバンドルへ inline される (zero-runtime-dep / 自己完結 CDN を維持)。\n * 編集はこの正典に対して行い、`node scripts/sync-io-core.mjs` で再配布する。\n *\n * pure(module 評価時に browser global 非参照)。\n */\n\nexport type Availability = \"available\" | \"missing\" | \"unknown\";\nexport type PermissionState = \"granted\" | \"denied\" | \"prompt\" | \"not-applicable\" | \"unknown\";\nexport type Readiness = \"idle\" | \"ready\" | \"degraded\";\nexport type Activity = \"inactive\" | \"active\";\nexport type PreconditionState = \"satisfied\" | \"required\" | \"not-applicable\";\n\n/** operation error の phase(taxonomy)。 */\nexport type WcsIoErrorPhase = \"probe\" | \"start\" | \"execute\" | \"decode\" | \"commit\" | \"dispose\";\n\n/** serializable な error info(non-cloneable な cause とは分離。DevTools / remote へは info のみ)。 */\nexport interface WcsIoErrorInfo {\n readonly code: string;\n readonly phase: WcsIoErrorPhase;\n readonly recoverable: boolean;\n readonly capabilityId?: string;\n readonly message: string;\n}\n\nexport interface PlatformAssessment {\n readonly availability: ReadonlyMap<string, Availability>;\n readonly permission: PermissionState;\n readonly readiness: Readiness;\n readonly activity: Activity;\n readonly preconditions: {\n readonly secureContext: PreconditionState;\n readonly userActivation: PreconditionState;\n };\n readonly epoch: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\n/** capability 1 件の仕様。probe は副作用なく presence を返す(利用直前に呼ぶ)。 */\nexport interface CapabilitySpec {\n readonly probe: () => boolean;\n readonly requiresSecureContext?: boolean;\n readonly requiresUserActivation?: boolean;\n /** browser compatibility dataset のキー(任意・診断用)。 */\n readonly compatKey?: string;\n}\n\nexport type CapabilityRegistry = ReadonlyMap<string, CapabilitySpec>;\n\nexport interface AssessOptions {\n readonly required: readonly string[];\n readonly optional?: readonly string[];\n readonly permission?: PermissionState;\n readonly activity?: Activity;\n readonly epoch?: number;\n readonly lastError?: WcsIoErrorInfo;\n}\n\nfunction isSecureContext(): boolean {\n return (globalThis as { isSecureContext?: unknown }).isSecureContext === true;\n}\n\n/**\n * capability を利用直前に評価して PlatformAssessment を作る。\n * required が 1 つでも欠ければ readiness は \"idle\"(開始不可)、\n * required 揃い + optional 欠けは \"degraded\"、全揃いは \"ready\"。\n */\nexport function assessCapabilities(registry: CapabilityRegistry, options: AssessOptions): PlatformAssessment {\n const availability = new Map<string, Availability>();\n const evaluate = (id: string): Availability => {\n const spec = registry.get(id);\n if (spec === undefined) return \"unknown\";\n return spec.probe() ? \"available\" : \"missing\";\n };\n\n let requiredAllAvailable = true;\n for (const id of options.required) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") requiredAllAvailable = false;\n }\n let optionalAllAvailable = true;\n for (const id of options.optional ?? []) {\n const a = evaluate(id);\n availability.set(id, a);\n if (a !== \"available\") optionalAllAvailable = false;\n }\n\n const readiness: Readiness = !requiredAllAvailable ? \"idle\" : (optionalAllAvailable ? \"ready\" : \"degraded\");\n\n // preconditions: 対象 capability のいずれかが要求する場合だけ評価する。\n const allIds = [...options.required, ...(options.optional ?? [])];\n const needsSecure = allIds.some((id) => registry.get(id)?.requiresSecureContext === true);\n const needsActivation = allIds.some((id) => registry.get(id)?.requiresUserActivation === true);\n const secureContext: PreconditionState = needsSecure ? (isSecureContext() ? \"satisfied\" : \"required\") : \"not-applicable\";\n const userActivation: PreconditionState = needsActivation ? \"required\" : \"not-applicable\";\n\n return {\n availability,\n permission: options.permission ?? \"not-applicable\",\n readiness,\n activity: options.activity ?? \"inactive\",\n preconditions: { secureContext, userActivation },\n epoch: options.epoch ?? 0,\n lastError: options.lastError,\n };\n}\n\n/** availability から「required がすべて available か」を判定するヘルパ(supported の最低条件)。 */\nexport function requiredCapabilitiesAvailable(assessment: PlatformAssessment, required: readonly string[]): boolean {\n return required.every((id) => assessment.availability.get(id) === \"available\");\n}\n\n/**\n * このページで機能が使えない理由(使える、または分からないなら null)。利用直前に読む。\n *\n * - `\"insecure-context\"`: 安全なコンテキストではない(`isSecureContext === false`)。\n * Permissions API が扱う機能はどれも安全なコンテキストを要る。\n * - `\"policy-blocked\"`: Permissions-Policy(サーバーのヘッダ、または `allow` の無い\n * `<iframe>`)がその機能を切っている。\n *\n * どちらも Permissions API は教えない: Chromium はポリシーで切られた文書でも\n * `granted` を、安全でない origin では `denied` を返す。利用者の拒否と区別するため、\n * 見張り役(`<wcs-permission>`)も取りに行く側も `unsupported` を報告する\n * (docs/v4-direction-2026-10.md の決定、state-field-report)。\n * `isSecureContext` が無い環境(SSR・テスト)は判断しない。\n */\nexport type FeatureUnavailableReason = \"insecure-context\" | \"policy-blocked\";\n\n/** Permissions-Policy が制御する機能(permission 名と同じ文字列)。 */\nconst POLICY_CONTROLLED = new Set([\n \"camera\", \"microphone\", \"geolocation\", \"midi\", \"clipboard-read\", \"clipboard-write\",\n \"screen-wake-lock\", \"idle-detection\", \"accelerometer\", \"gyroscope\", \"magnetometer\",\n \"ambient-light-sensor\", \"display-capture\",\n]);\n\ninterface PolicyLike { allowsFeature(feature: string): boolean }\n\nexport function featureUnavailable(feature: string): FeatureUnavailableReason | null {\n const g = globalThis as { isSecureContext?: unknown; document?: { permissionsPolicy?: PolicyLike; featurePolicy?: PolicyLike } };\n if (g.isSecureContext === false) return \"insecure-context\";\n if (!POLICY_CONTROLLED.has(feature)) return null;\n const policy = g.document?.permissionsPolicy ?? g.document?.featurePolicy;\n if (policy === undefined || typeof policy.allowsFeature !== \"function\") return null;\n try {\n return policy.allowsFeature(feature) ? null : \"policy-blocked\";\n } catch {\n return null;\n }\n}\n\n/** `featureUnavailable` の理由を、作者が直し方を読める文にする。`what` は文頭(「The camera」など)。 */\nexport function featureUnavailableMessage(what: string, feature: string, reason: FeatureUnavailableReason): string {\n return reason === \"insecure-context\"\n ? `${what} needs a secure context (https:, or http://localhost), and this page is not one.`\n : `${what} is turned off for this page by a Permissions-Policy: the server's Permissions-Policy header, ` +\n `or an <iframe> without allow=\"${feature}\". The browser's site settings cannot change that.`;\n}\n","/**\n * notificationCapabilities.ts\n *\n * Notification node 固有の error code(taxonomy)と derivation。汎用の error info 型は\n * `./platformCapability.js`(/io-core/ から copy-distribution される生成ファイル)から\n * import する。notification は監視(permission)と操作(notify/close)を 1 タグに併せ持つが、\n * 競合する非同期 operation の lane は持たない(show は最新値で上書きされる momentary な\n * 送出)ため、lane は採用せず error taxonomy(errorInfo)のみを追加する。\n *\n * sensor family と異なり、NotificationCore の error detail の `.error` は既に安定コード\n * (`this._err(code, message)` が産出する `\"unsupported\"` / `\"not-granted\"` /\n * `\"invalid-title\"` / `\"show-failed\"` / `\"no-service-worker\"`)であり、Error.name ではない。\n * したがって derivation は `.error` コードを taxonomy に写すだけの純粋な map である。\n * 想定外のコードは防御的に `notify-error` へ畳む。\n */\n\nimport type { WcsIoErrorInfo } from \"./platformCapability.js\";\nimport type { WcsNotifyErrorDetail } from \"../types.js\";\n\n/** 安定した notification error code(taxonomy)。値は公開キーとして固定。 */\nexport const WCS_NOTIFY_ERROR_CODE = {\n /** Notifications API 非対応(`globalThis.Notification` 不在)。 */\n CapabilityMissing: \"capability-missing\",\n /** 権限が granted でない状態での notify()。 */\n NotAllowed: \"not-allowed\",\n /** notify() に非文字列 title が渡された。 */\n InvalidArgument: \"invalid-argument\",\n /** notification の生成 / 表示に失敗した(constructor 例外 / onerror / SW show reject)。 */\n ShowFailed: \"show-failed\",\n /** SW backend が必要だが `navigator.serviceWorker` が不在。 */\n NoServiceWorker: \"no-service-worker\",\n /** その他 / 想定外の error code に対する防御的 fallback。 */\n NotifyError: \"notify-error\",\n} as const;\n\n/**\n * notification の失敗を serializable な error taxonomy に写す。引数は\n * `wcs-notify:error` の detail(`{ error, message }`)そのもの。`.error` は\n * `NotificationCore._err()` が付与した安定コードで、Error.name ではない。\n *\n * - `\"unsupported\"` は開始前の能力欠如 → phase=\"probe\" / capability-missing。\n * - `\"not-granted\"` / `\"invalid-title\"` は show 手前の前提条件違反(権限・引数)→\n * phase=\"start\" / not-allowed・invalid-argument。\n * - `\"show-failed\"` は show 実行中の失敗 → phase=\"execute\" / show-failed。\n * - `\"no-service-worker\"` は SW backend 要求時の transport 欠如 → phase=\"execute\" /\n * no-service-worker。\n * - それ以外(未知コード)は防御的に phase=\"execute\" / notify-error。\n *\n * いずれも retry で自動回復しない(recoverable=false)。\n */\nexport function deriveNotifyErrorInfo(error: WcsNotifyErrorDetail): WcsIoErrorInfo {\n const { error: code, message } = error;\n switch (code) {\n case \"unsupported\":\n return { code: WCS_NOTIFY_ERROR_CODE.CapabilityMissing, phase: \"probe\", recoverable: false, message };\n case \"not-granted\":\n return { code: WCS_NOTIFY_ERROR_CODE.NotAllowed, phase: \"start\", recoverable: false, message };\n case \"invalid-title\":\n return { code: WCS_NOTIFY_ERROR_CODE.InvalidArgument, phase: \"start\", recoverable: false, message };\n case \"show-failed\":\n return { code: WCS_NOTIFY_ERROR_CODE.ShowFailed, phase: \"execute\", recoverable: false, message };\n case \"no-service-worker\":\n return { code: WCS_NOTIFY_ERROR_CODE.NoServiceWorker, phase: \"execute\", recoverable: false, message };\n default:\n return { code: WCS_NOTIFY_ERROR_CODE.NotifyError, phase: \"execute\", recoverable: false, message };\n }\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { WcsIoErrorInfo, featureUnavailable, featureUnavailableMessage } from \"./platformCapability.js\";\nimport { deriveNotifyErrorInfo } from \"./notificationCapabilities.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\", semantics: \"state\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", semantics: \"state\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\", semantics: \"state\" },\n // Serializable failure taxonomy (stable code / phase / recoverable), or null.\n // Additive bindable output derived from `error.error` (the stable code the\n // Core's `_err()` already produces); the existing `error` property/event are\n // unchanged. Fires wcs-notify:error-info-changed. No lane — show is a\n // momentary, last-value-wins send, not a competing async operation.\n { name: \"errorInfo\", event: \"wcs-notify:error-info-changed\", semantics: \"state\" },\n { name: \"clicked\", event: \"wcs-notify:click\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", semantics: \"event\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _errorInfo: WcsIoErrorInfo | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n /** Whether `[wcs/command-not-ready]` was said for this element. */\n private _toldNotReady = false;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n /**\n * The last failure's serializable `WcsIoErrorInfo` (stable `code` / `phase` /\n * `recoverable`), or null. Additive wc-bindable property (event\n * `wcs-notify:error-info-changed`), derived from `error`; the existing `error`\n * property/event are unchanged.\n */\n get errorInfo(): WcsIoErrorInfo | null {\n return this._errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n // Keep the additive `errorInfo` taxonomy in sync with `error`: derive from the\n // stable error code (or null on clear). Fires before the `error` event so an\n // observer binding both sees the classification first, mirroring the io-node\n // family.\n this._commitErrorInfo(error === null ? null : deriveNotifyErrorInfo(error));\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n // Called only from _setError (which already guards on error identity), so\n // errorInfo transitions exactly when error does — no separate guard needed here.\n private _commitErrorInfo(info: WcsIoErrorInfo | null): void {\n this._errorInfo = info;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error-info-changed\", {\n detail: info,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n const reason = featureUnavailable(\"notifications\");\n this._setError(this._err(\"unsupported\", reason === null\n ? \"Notifications API is not available in this environment.\"\n : featureUnavailableMessage(\"Notifications\", \"notifications\", reason)));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n this._warnNotReady();\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n // A page that cannot use notifications (not a secure context) has none: Chromium\n // keeps the constructor there and answers \"denied\", which reads as the user's refusal.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" && featureUnavailable(\"notifications\") === null ? g.Notification : undefined;\n }\n\n // A notification refused because the permission is not granted was lost, and only a\n // page that binds `error` heard of it. Said once per element (docs/v4-direction-2026-10.md\n // §5.1, the I/O command policy).\n private _warnNotReady(): void {\n if (this._toldNotReady) return;\n this._toldNotReady = true;\n console.warn(\n `[@wcstack/notification] [wcs/command-not-ready] notify() was refused: the permission is \"${this._permission}\", ` +\n \"so nothing is shown. It goes to `error` too. Ask with request() first (from a user gesture), and \" +\n \"notify once `permission` is \\\"granted\\\". (Said once per element.)\",\n this._target,\n );\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/upgrade-properties.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// custom element の property upgrade — `static wcBindable.inputs` に宣言した入力のうち、\n// 要素が upgrade される前に代入された own データプロパティを取り込み直す。\n//\n// なぜ必要か:\n// 未定義タグの要素は素の HTMLElement なので、`el.url = \"...\"` は own データプロパティを作る。\n// upgrade 後にクラスの accessor が prototype へ入っても own プロパティが優先されるため、\n// setter は二度と呼ばれず、値は要素へ届かないまま消える(エラーも警告も出ない)。\n// 常にプロパティ代入を行う framework(Angular の `[prop]`、Lit の `.prop=`、\n// Solid の `prop:`、Vue の `.prop` 修飾子)× 遅延定義(autoloader / CDN / code-split)で\n// 常態的に起きる。docs/architecture-hardening/13-framework-adapter-binding-constraints.md §1.2。\n//\n// 安全側の判定:\n// own プロパティがあっても、prototype チェーンに accessor が無ければ「シャドウ」ではなく\n// その own プロパティ自体が正規の格納先なので触らない(public class field を壊さない)。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/upgrade-properties.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/upgradeProperties.ts). Those copies are generated — do not edit them.\nimport { IWcBindable } from \"./wcBindable.js\";\n\nfunction hasAccessorOnPrototype(target: object, name: string): boolean {\n let proto = Object.getPrototypeOf(target);\n while (proto !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor !== undefined) {\n return typeof descriptor.get === \"function\" || typeof descriptor.set === \"function\";\n }\n proto = Object.getPrototypeOf(proto);\n }\n return false;\n}\n\n// 属性になってしまったオブジェクトの入力(`files=\"[object File]\"`)を、要素ごとに 1 回だけ言う。\n// React 19 は定義前の要素にプロパティが無いのでオブジェクトを属性に書き、Vue の `.attr` も\n// 書く。要素はその入力をプロパティでしか読まないので、何も受け取らず、何も言わなかった\n// (docs/seam-apps.md、fw-inventory)。\nconst toldObjectAttribute = new WeakSet<object>();\n\nfunction warnObjectAttribute(element: object, name: string, value: string): void {\n if (toldObjectAttribute.has(element)) return;\n toldObjectAttribute.add(element);\n const tag = (element as { localName?: string }).localName ?? \"element\";\n console.warn(\n `[wcs/input-as-attribute] <${tag}> has the attribute ${name}=\"${value}\": an object was written as an ` +\n `attribute, so the element did not receive it. A framework does that when the property is set before the ` +\n `element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, ` +\n `or assign the property through a ref (Vue: .prop). (Said once per element.)`,\n element,\n );\n}\n\n/**\n * `connectedCallback` の先頭で呼ぶ。宣言済み input のうち upgrade 前の代入で\n * accessor をシャドウしている own プロパティを、delete → 再代入で setter に通し直す。\n *\n * - 冪等: 再代入は accessor を通るので own プロパティは残らず、2 回目以降は no-op。\n * - 宣言に `inputs` が無い要素、`wcBindable` を持たない要素では何もしない。\n * - 値の意味は変えない。今まで捨てられていた代入が届くようになる一方向の変化。\n * - 値が `[object …]` の属性(属性に書かれてしまったオブジェクトの入力)は、要素ごとに 1 回警告する。\n */\nexport function upgradeProperties(element: object): void {\n const declaration = (element as { constructor?: { wcBindable?: IWcBindable } }).constructor?.wcBindable;\n const inputs = declaration?.inputs;\n if (inputs === undefined) return;\n const getAttribute = (element as { getAttribute?: (name: string) => string | null }).getAttribute;\n for (const input of inputs) {\n const name = input.name;\n const attribute = typeof getAttribute === \"function\" ? getAttribute.call(element, name.toLowerCase()) : null;\n if (attribute !== null && attribute.startsWith(\"[object \")) warnObjectAttribute(element, name, attribute);\n if (!Object.prototype.hasOwnProperty.call(element, name)) continue;\n if (!hasAccessorOnPrototype(element, name)) continue;\n const record = element as Record<string, unknown>;\n const value = record[name];\n delete record[name];\n record[name] = value;\n }\n}\n","// ===========================================================================\n// AUTO-GENERATED FILE - DO NOT EDIT.\n// Generated from /protocol/input-attribute.ts by scripts/sync-protocol-types.mjs.\n// Run `node scripts/sync-protocol-types.mjs` after editing the source.\n// ===========================================================================\n\n// 属性へ反映する wc-bindable 入力の producer 側(SPEC-extensions § Producer guidance for inputs の P1〜P3)。\n// 入力の setter は属性をこの 2 関数で書く。それで次が揃う:\n// - `undefined` は「値が無い」(P1): 属性を、この関数で最初に書く前の状態 — マークアップに書かれた値、\n// 無ければ属性なし(= その入力の文書化した既定値)— へ戻す。applier プロファイルを宣言する binder は\n// 値の後の `undefined` を書き(A2)、React 19 も書き、直接の代入でも届く。\n// - `null` はクリア(P2): 属性なし、つまり文書化した既定値。\n// - どちらも文字列 \"undefined\" / \"null\" として属性に入らない。\n//\n// 「最初に書く前」は、その最初の書き込みのときに読む(遅延)。upgrade 前に代入されたプロパティは\n// connectedCallback の upgradeProperties() が通し直すので、そのときにはパーサが書いた属性が揃っている。\n// 要素自身が setter を通さずに書いた属性は、最初の書き込みより前なら「最初の状態」に含まれる。\n//\n// SINGLE SOURCE OF TRUTH: edit only this file (/protocol/input-attribute.ts), then run\n// `node scripts/sync-protocol-types.mjs` to regenerate the per-package copies\n// (packages/<pkg>/src/protocol/inputAttribute.ts). Those copies are generated — do not edit them.\n\nconst initialAttributes = new WeakMap<Element, Map<string, string | null>>();\n\n/** The attribute as it stood before the first write through these helpers. */\nfunction initialAttribute(el: Element, name: string): string | null {\n let byName = initialAttributes.get(el);\n if (byName === undefined) {\n byName = new Map();\n initialAttributes.set(el, byName);\n }\n if (!byName.has(name)) byName.set(name, el.getAttribute(name));\n return byName.get(name) as string | null;\n}\n\nfunction writeAttribute(el: Element, name: string, value: string | null): void {\n if (value === null) el.removeAttribute(name);\n else el.setAttribute(name, value);\n}\n\n/**\n * A value attribute. `value` is written as `String(value)`; `null` removes the attribute;\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value === null ? null : String(value));\n}\n\n/**\n * A boolean attribute, present while `value` is truthy (`null` and `false` remove it);\n * `undefined` restores the attribute the element started with.\n */\nexport function reflectBooleanAttribute(el: Element, name: string, value: unknown): void {\n const initial = initialAttribute(el, name);\n writeAttribute(el, name, value === undefined ? initial : value ? \"\" : null);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { WcsIoErrorInfo } from \"../core/platformCapability.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\nimport { upgradeProperties } from \"../protocol/upgradeProperties.js\";\nimport { reflectAttribute, reflectBooleanAttribute } from \"../protocol/inputAttribute.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // 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 // Input setters never let setAttribute stringify null / undefined: `null`\n // removes the attribute (the default — no option, `mode` \"auto\"), `undefined`\n // restores the attribute the element started with (wc-bindable producer\n // guidance P1; React 19 and a direct assignment deliver it, @wcstack/state\n // does not).\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend | null | undefined) {\n reflectAttribute(this, \"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null | undefined) {\n reflectAttribute(this, \"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null | undefined) {\n reflectAttribute(this, \"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null | undefined) {\n reflectAttribute(this, \"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null | undefined) {\n reflectAttribute(this, \"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null | undefined) {\n reflectAttribute(this, \"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null | undefined) {\n reflectAttribute(this, \"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean | null | undefined) {\n reflectBooleanAttribute(this, \"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). @wcstack/state never writes\n // `undefined`, but a wc-bindable applier writes it after a value (applier\n // profile A2; React 19 does too), and a direct assignment can: \"no value\" is\n // not a notice, so null/undefined are a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get errorInfo(): WcsIoErrorInfo | null {\n return this._core.errorInfo;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\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 // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { WcsNotify } from \"./components/Notify.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.notify)) {\n registry.define(config.tagNames.notify, WcsNotify);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(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,mBAAmB;AACrC,IAAA,QAAQ,EAAE;AACR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,QAAA,IAAI,MAAM,CAAC,WAAW,EAAE;AACtB,YAAA,mBAAmB,EAAE;QACvB;;;;AAIA,QAAA,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IAChE;IAEA,oBAAoB,GAAA;;;AAGlB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;AC7UF;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,QAAA,GAAkC,cAAc,EAAA;AACjF,IAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACzC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IACpD;AACF;;ACRM,SAAU,qBAAqB,CAAC,UAA4B,EAAE,QAAgC,EAAA;IAClG,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/notification",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Declarative desktop-notification component for Web Components. Framework-agnostic Notifications API wrapper via wc-bindable-protocol, with Service Worker support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
"types": "./dist/sw.d.ts",
|
|
16
16
|
"import": "./dist/sw.js"
|
|
17
17
|
},
|
|
18
|
-
"./auto":
|
|
18
|
+
"./auto": {
|
|
19
|
+
"types": "./dist/auto.d.ts",
|
|
20
|
+
"import": "./dist/auto.min.js"
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
"files": [
|
|
21
24
|
"dist"
|