@wcstack/permission 4.32.0 → 4.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auto.min.js CHANGED
@@ -1,2 +1,2 @@
1
- const e={tagNames:{permission:"wcs-permission"}};var t="@wcstack/permission",s="4.32.0";const n=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture","fullscreen","picture-in-picture","web-share"]);class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"state",event:"wcs-permission:change",semantics:"state"},{name:"granted",event:"wcs-permission:change",semantics:"state",getter:e=>"granted"===e.detail},{name:"denied",event:"wcs-permission:change",semantics:"state",getter:e=>"denied"===e.detail},{name:"prompt",event:"wcs-permission:change",semantics:"state",getter:e=>"prompt"===e.detail},{name:"unsupported",event:"wcs-permission:change",semantics:"state",getter:e=>"unsupported"===e.detail},{name:"unsupportedReason",event:"wcs-permission:unsupported-reason-changed",semantics:"state"}],commands:[]};_target;_descriptor=null;_state="prompt";_unsupportedReason=null;_permissionStatus=null;_permissionSubscribed=!1;_permGen=0;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._descriptor=e,this._ready=this._initPermission())}get state(){return this._state}get granted(){return"granted"===this._state}get denied(){return"denied"===this._state}get prompt(){return"prompt"===this._state}get unsupported(){return"unsupported"===this._state}get unsupportedReason(){return this._unsupportedReason}get ready(){return this._ready}_setState(e,t=null){const s="unsupported"===e?t:null,n=this._state!==e,i=this._unsupportedReason!==s;this._state=e,this._unsupportedReason=s,i&&this._target.dispatchEvent(new CustomEvent("wcs-permission:unsupported-reason-changed",{detail:s,bubbles:!0})),n&&this._target.dispatchEvent(new CustomEvent("wcs-permission:change",{detail:e,bubbles:!0}))}observe(e){return this._descriptor=e,this._permissionSubscribed||(this._ready=this._initPermission()),this._ready}dispose(){this._permissionSubscribed=!1,this._permGen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_initPermission(){if(!this._descriptor||!this._descriptor.name)return this._setState("unsupported","unknown-name"),Promise.resolve();const e=function(e){const t=globalThis;if(!1===t.isSecureContext)return"insecure-context";if(!n.has(e))return null;const s=t.document?.permissionsPolicy??t.document?.featurePolicy;if(void 0===s||"function"!=typeof s.allowsFeature)return null;try{return"function"!=typeof s.features||s.features().includes(e)?s.allowsFeature(e)?null:"policy-blocked":null}catch{return null}}(this._descriptor.name);if(null!==e)return this._setState("unsupported",e),Promise.resolve();if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setState("unsupported","no-permissions-api"),Promise.resolve();this._permissionSubscribed=!0;const t=++this._permGen;return navigator.permissions.query(this._descriptor).then(e=>{t===this._permGen&&(this._permissionStatus=e,this._setState(e.state),e.addEventListener("change",this._onPermissionChange))},()=>{t===this._permGen&&this._setState("unsupported","unknown-name")})}_onPermissionChange=e=>{const t=e.target;this._setState(t.state)}}function r(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const o=new WeakSet;function a(e,t,s){if(o.has(e))return;o.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const c=new WeakMap;function u(e,t){let s=c.get(e);return void 0===s&&(s=new Map,c.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function l(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function d(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:s?"":null)}const p=()=>{};class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,inputs:[{name:"name",attribute:"name"},{name:"userVisibleOnly",attribute:"user-visible-only"},{name:"sysex",attribute:"sysex"}],commands:[]};_core;_connectedCallbackPromise=Promise.resolve();_observePending=!1;_connectResolve=p;_internals=null;constructor(){super(),this._core=new i(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-permission:change":e=>({granted:"granted"===e,denied:"denied"===e,prompt:"prompt"===e,unsupported:"unsupported"===e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get name(){return this.getAttribute("name")??""}set name(e){!function(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:null===s?null:String(s))}(this,"name",e)}get userVisibleOnly(){return this.hasAttribute("user-visible-only")}set userVisibleOnly(e){d(this,"user-visible-only",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){d(this,"sysex",e)}get state(){return this._core.state}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 unsupportedReason(){return this._core.unsupportedReason}get connectedCallbackPromise(){return this._connectedCallbackPromise}_descriptor(){const e={name:this.name};return this.userVisibleOnly&&(e.userVisibleOnly=!0),this.sysex&&(e.sysex=!0),e}_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending=!1;const e=this._connectResolve;this._connectResolve=p,this.isConnected?this._core.observe(this._descriptor()).then(e):e()}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&a(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!r(e,s))continue;const o=e,c=o[s];delete o[s],o[s]=c}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleObserve()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose(),this._connectResolve(),this._connectResolve=p}}const m=Symbol.for("wcstack.package"),_=new WeakSet;function g(e,t){Object.defineProperty(e,m,{value:t,configurable:!0})}function b(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[m];if(r===i||_.has(e))return;_.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function f(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(g(i,t),e.define(n,i)):b(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.permission,h]])}var v;f(v);
1
+ const e={tagNames:{permission:"wcs-permission"}};var t="@wcstack/permission",s="4.34.0";const n=new Set(["camera","microphone","geolocation","midi","clipboard-read","clipboard-write","screen-wake-lock","idle-detection","accelerometer","gyroscope","magnetometer","ambient-light-sensor","display-capture","fullscreen","picture-in-picture","web-share"]);class i extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"state",event:"wcs-permission:change",semantics:"state"},{name:"granted",event:"wcs-permission:change",semantics:"state",getter:e=>"granted"===e.detail},{name:"denied",event:"wcs-permission:change",semantics:"state",getter:e=>"denied"===e.detail},{name:"prompt",event:"wcs-permission:change",semantics:"state",getter:e=>"prompt"===e.detail},{name:"unsupported",event:"wcs-permission:change",semantics:"state",getter:e=>"unsupported"===e.detail},{name:"unsupportedReason",event:"wcs-permission:unsupported-reason-changed",semantics:"state"}],commands:[]};_target;_descriptor=null;_state="prompt";_unsupportedReason=null;_permissionStatus=null;_permissionSubscribed=!1;_permGen=0;_ready=Promise.resolve();constructor(e,t){super(),this._target=t??this,e&&(this._descriptor=e,this._ready=this._initPermission())}get state(){return this._state}get granted(){return"granted"===this._state}get denied(){return"denied"===this._state}get prompt(){return"prompt"===this._state}get unsupported(){return"unsupported"===this._state}get unsupportedReason(){return this._unsupportedReason}get ready(){return this._ready}_setState(e,t=null){const s="unsupported"===e?t:null,n=this._state!==e,i=this._unsupportedReason!==s;this._state=e,this._unsupportedReason=s,i&&this._target.dispatchEvent(new CustomEvent("wcs-permission:unsupported-reason-changed",{detail:s,bubbles:!0})),n&&this._target.dispatchEvent(new CustomEvent("wcs-permission:change",{detail:e,bubbles:!0}))}observe(e){return this._descriptor=e,this._permissionSubscribed||(this._ready=this._initPermission()),this._ready}dispose(){this._permissionSubscribed=!1,this._permGen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null)}_initPermission(){if(!this._descriptor||!this._descriptor.name)return this._setState("unsupported","unknown-name"),Promise.resolve();const e=function(e){const t=globalThis;if(!1===t.isSecureContext)return"insecure-context";if(!n.has(e))return null;const s=t.document?.permissionsPolicy??t.document?.featurePolicy;if(void 0===s||"function"!=typeof s.allowsFeature)return null;try{return"function"!=typeof s.features||s.features().includes(e)?s.allowsFeature(e)?null:"policy-blocked":null}catch{return null}}(this._descriptor.name);if(null!==e)return this._setState("unsupported",e),Promise.resolve();if("undefined"==typeof navigator||!navigator.permissions||"function"!=typeof navigator.permissions.query)return this._setState("unsupported","no-permissions-api"),Promise.resolve();this._permissionSubscribed=!0;const t=++this._permGen;return navigator.permissions.query(this._descriptor).then(e=>{t===this._permGen&&(this._permissionStatus=e,this._setState(e.state),e.addEventListener("change",this._onPermissionChange))},()=>{t===this._permGen&&this._setState("unsupported","unknown-name")})}_onPermissionChange=e=>{const t=e.target;this._setState(t.state)}}function r(e,t){let s=Object.getPrototypeOf(e);for(;null!==s;){const e=Object.getOwnPropertyDescriptor(s,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;s=Object.getPrototypeOf(s)}return!1}const o=new WeakSet;function a(e,t,s){if(o.has(e))return;o.add(e);const n=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${n}> has the attribute ${t}="${s}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}const c=new WeakMap;function u(e,t){let s=c.get(e);return void 0===s&&(s=new Map,c.set(e,s)),s.has(t)||s.set(t,e.getAttribute(t)),s.get(t)}function l(e,t,s){null===s?e.removeAttribute(t):e.setAttribute(t,s)}function d(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:s?"":null)}const p=()=>{};class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...i.wcBindable,inputs:[{name:"name",attribute:"name"},{name:"userVisibleOnly",attribute:"user-visible-only"},{name:"sysex",attribute:"sysex"}],commands:[]};_core;_connectedCallbackPromise=Promise.resolve();_observePending=!1;_connectResolve=p;_internals=null;constructor(){super(),this._core=new i(null,this),this._internals=this._initInternals(),this._wireStates({"wcs-permission:change":e=>({granted:"granted"===e,denied:"denied"===e,prompt:"prompt"===e,unsupported:"unsupported"===e})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[s,n]of Object.entries(e))this.addEventListener(s,e=>{const s=this.hasAttribute("debug-states");for(const[i,r]of Object.entries(n(e.detail))){try{r?t.add(i):t.delete(i)}catch{}s&&this.toggleAttribute(`data-wcs-state-${i}`,r)}})}get name(){return this.getAttribute("name")??""}set name(e){!function(e,t,s){const n=u(e,t);l(e,t,void 0===s?n:null===s?null:String(s))}(this,"name",e)}get userVisibleOnly(){return this.hasAttribute("user-visible-only")}set userVisibleOnly(e){d(this,"user-visible-only",e)}get sysex(){return this.hasAttribute("sysex")}set sysex(e){d(this,"sysex",e)}get state(){return this._core.state}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 unsupportedReason(){return this._core.unsupportedReason}get connectedCallbackPromise(){return this._connectedCallbackPromise}_descriptor(){const e={name:this.name};return this.userVisibleOnly&&(e.userVisibleOnly=!0),this.sysex&&(e.sysex=!0),e}_scheduleObserve(){this._observePending||(this._observePending=!0,queueMicrotask(()=>{this._observePending=!1;const e=this._connectResolve;this._connectResolve=p,this.isConnected?this._core.observe(this._descriptor()).then(e):e()}))}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,s=t?.inputs;if(void 0===s)return;const n=e.getAttribute;for(const t of s){const s=t.name,i="function"==typeof n?n.call(e,s.toLowerCase()):null;if(null!==i&&i.startsWith("[object ")&&a(e,s,i),!Object.prototype.hasOwnProperty.call(e,s))continue;if(!r(e,s))continue;const o=e,c=o[s];delete o[s],o[s]=c}}(this),this.style.display="none",this._connectedCallbackPromise=new Promise(e=>{this._connectResolve=e}),this._scheduleObserve()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose(),this._connectResolve(),this._connectResolve=p}}const m=Symbol.for("wcstack.package"),_=new WeakSet;function g(e,t){Object.defineProperty(e,m,{value:t,configurable:!0})}function b(e,t,s,n,i){if(void 0!==n&&(s===n||s.prototype instanceof n))return;const r=s[m];if(r===i||_.has(e))return;_.add(e);const o=i.slice(0,i.lastIndexOf("@"));console.warn(`[${o}] [wcs/package-twice] <${t}> is already defined by ${r??`another copy of ${o} that does not name its version`}; this copy, ${i}, does nothing. Load each package once.`)}function f(n=customElements){!function(e,t,s){for(const[n,i]of s){const s=e.get(n);void 0===s?(g(i,t),e.define(n,i)):b(e,n,s,i,t)}}(n,`${t}@${s}`,[[e.tagNames.permission,h]])}var v;f(v);
2
2
  //# sourceMappingURL=auto.min.js.map
package/dist/index.d.ts CHANGED
@@ -27,6 +27,15 @@ interface IWcBindableInput {
27
27
  interface IWcBindableCommand {
28
28
  readonly name: string;
29
29
  readonly async?: boolean;
30
+ /**
31
+ * The declared members — entries of `properties` or of `inputs` — whose current value must be
32
+ * truthy for the command to be carried out (wc-bindable 0.11, SPEC-extensions § The `requires`
33
+ * hint). A declaration for tooling, documentation and diagnostics: the element still settles a
34
+ * call made anyway as it documents, and an applier must not skip or drop a call because of it.
35
+ * Do not list a member whose legitimate values include a falsy one (`0`, `""`, `false`), and
36
+ * keep an input listed here readable.
37
+ */
38
+ readonly requires?: readonly string[];
30
39
  }
31
40
  interface IWcBindable {
32
41
  readonly protocol: "wc-bindable";
package/dist/index.esm.js CHANGED
@@ -58,7 +58,7 @@ function setConfig(partialConfig) {
58
58
  frozenConfig = null;
59
59
  }
60
60
 
61
- var pkg = {"name":"@wcstack/permission","version":"4.32.0"};
61
+ var pkg = {"name":"@wcstack/permission","version":"4.34.0"};
62
62
 
63
63
  // ===========================================================================
64
64
  // AUTO-GENERATED FILE - DO NOT EDIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/permission",
3
- "version": "4.32.0",
3
+ "version": "4.34.0",
4
4
  "description": "Declarative permission-state component for Web Components. Framework-agnostic Permissions API monitor via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",