@wcstack/network 4.26.0 → 4.28.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:{network:"wcs-network"}};var t="@wcstack/network",n="4.26.0";const s=Object.freeze({effectiveType:null,downlink:null,rtt:null,saveData:null,supported:!1,offline:null});class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"effectiveType",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.effectiveType},{name:"downlink",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.downlink},{name:"rtt",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.rtt},{name:"saveData",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.saveData},{name:"supported",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.supported},{name:"offline",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.offline}],commands:[]};_target;_snapshot=s;_connection=null;_subscribed=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get effectiveType(){return this._snapshot.effectiveType}get downlink(){return this._snapshot.downlink}get rtt(){return this._snapshot.rtt}get saveData(){return this._snapshot.saveData}get supported(){return this._snapshot.supported}get offline(){return this._snapshot.offline}observe(){if(!this._subscribed){this._subscribed=!0;const e=this._api();e&&(this._connection=e,e.addEventListener("change",this._onChange)),this._window()?.addEventListener("online",this._onChange),this._window()?.addEventListener("offline",this._onChange),this._apply(this._read())}return this._ready}dispose(){this._subscribed=!1,this._connection&&(this._connection.removeEventListener("change",this._onChange),this._connection=null),this._window()?.removeEventListener("online",this._onChange),this._window()?.removeEventListener("offline",this._onChange)}_window(){const e=globalThis.window;return void 0!==e&&"function"==typeof e.addEventListener?e:void 0}_api(){const e=globalThis.navigator;return void 0!==e&&e.connection?e.connection:void 0}_read(){const e=this._api(),t=globalThis.navigator,n=void 0!==t&&"boolean"==typeof t.onLine?!t.onLine:null;return e?{offline:n,effectiveType:"string"==typeof e.effectiveType?e.effectiveType:null,downlink:"number"==typeof e.downlink?e.downlink:null,rtt:"number"==typeof e.rtt?e.rtt:null,saveData:"boolean"==typeof e.saveData?e.saveData:null,supported:!0}:null===n?s:{...s,offline:n}}_onChange=()=>{this._apply(this._read())};_apply(e){const t=this._snapshot;t.effectiveType===e.effectiveType&&t.downlink===e.downlink&&t.rtt===e.rtt&&t.saveData===e.saveData&&t.supported===e.supported&&t.offline===e.offline||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-network:change",{detail:e,bubbles:!0})))}}function i(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const a=new WeakSet;function r(e,t,n){if(a.has(e))return;a.add(e);const s=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${s}> has the attribute ${t}="${n}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-network:change":e=>({"save-data":!0===e.saveData,supported:!0===e.supported,offline:!0===e.offline})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[o,i]of Object.entries(s(e.detail))){try{i?t.add(o):t.delete(o)}catch{}n&&this.toggleAttribute(`data-wcs-state-${o}`,i)}})}get effectiveType(){return this._core.effectiveType}get downlink(){return this._core.downlink}get rtt(){return this._core.rtt}get saveData(){return this._core.saveData}get supported(){return this._core.supported}get offline(){return this._core.offline}get connectedCallbackPromise(){return this._connectedCallbackPromise}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0===n)return;const s=e.getAttribute;for(const t of n){const n=t.name,o="function"==typeof s?s.call(e,n.toLowerCase()):null;if(null!==o&&o.startsWith("[object ")&&r(e,n,o),!Object.prototype.hasOwnProperty.call(e,n))continue;if(!i(e,n))continue;const a=e,c=a[n];delete a[n],a[n]=c}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose()}}const l=Symbol.for("wcstack.package"),d=new WeakSet;function h(e,t){Object.defineProperty(e,l,{value:t,configurable:!0})}function f(e,t,n,s,o){if(void 0!==s&&(n===s||n.prototype instanceof s))return;const i=n[l];if(i===o||d.has(e))return;d.add(e);const a=o.slice(0,o.lastIndexOf("@"));console.warn(`[${a}] [wcs/package-twice] <${t}> is already defined by ${i??`another copy of ${a} that does not name its version`}; this copy, ${o}, does nothing. Load each package once.`)}function u(s=customElements){!function(e,t,n){for(const[s,o]of n){const n=e.get(s);void 0===n?(h(o,t),e.define(s,o)):f(e,s,n,o,t)}}(s,`${t}@${n}`,[[e.tagNames.network,c]])}var p;u(p);
1
+ const e={tagNames:{network:"wcs-network"}};var t="@wcstack/network",n="4.28.0";const s=Object.freeze({effectiveType:null,downlink:null,rtt:null,saveData:null,supported:!1,offline:null});class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"effectiveType",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.effectiveType},{name:"downlink",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.downlink},{name:"rtt",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.rtt},{name:"saveData",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.saveData},{name:"supported",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.supported},{name:"offline",event:"wcs-network:change",semantics:"state",getter:e=>e.detail.offline}],commands:[]};_target;_snapshot=s;_connection=null;_subscribed=!1;_ready=Promise.resolve();constructor(e){super(),this._target=e??this}get ready(){return this._ready}get effectiveType(){return this._snapshot.effectiveType}get downlink(){return this._snapshot.downlink}get rtt(){return this._snapshot.rtt}get saveData(){return this._snapshot.saveData}get supported(){return this._snapshot.supported}get offline(){return this._snapshot.offline}observe(){if(!this._subscribed){this._subscribed=!0;const e=this._api();e&&(this._connection=e,e.addEventListener("change",this._onChange)),this._window()?.addEventListener("online",this._onChange),this._window()?.addEventListener("offline",this._onChange),this._apply(this._read())}return this._ready}dispose(){this._subscribed=!1,this._connection&&(this._connection.removeEventListener("change",this._onChange),this._connection=null),this._window()?.removeEventListener("online",this._onChange),this._window()?.removeEventListener("offline",this._onChange)}_window(){const e=globalThis.window;return void 0!==e&&"function"==typeof e.addEventListener?e:void 0}_api(){const e=globalThis.navigator;return void 0!==e&&e.connection?e.connection:void 0}_read(){const e=this._api(),t=globalThis.navigator,n=void 0!==t&&"boolean"==typeof t.onLine?!t.onLine:null;return e?{offline:n,effectiveType:"string"==typeof e.effectiveType?e.effectiveType:null,downlink:"number"==typeof e.downlink?e.downlink:null,rtt:"number"==typeof e.rtt?e.rtt:null,saveData:"boolean"==typeof e.saveData?e.saveData:null,supported:!0}:null===n?s:{...s,offline:n}}_onChange=()=>{this._apply(this._read())};_apply(e){const t=this._snapshot;t.effectiveType===e.effectiveType&&t.downlink===e.downlink&&t.rtt===e.rtt&&t.saveData===e.saveData&&t.supported===e.supported&&t.offline===e.offline||(this._snapshot=e,this._target.dispatchEvent(new CustomEvent("wcs-network:change",{detail:e,bubbles:!0})))}}function i(e,t){let n=Object.getPrototypeOf(e);for(;null!==n;){const e=Object.getOwnPropertyDescriptor(n,t);if(void 0!==e)return"function"==typeof e.get||"function"==typeof e.set;n=Object.getPrototypeOf(n)}return!1}const a=new WeakSet;function r(e,t,n){if(a.has(e))return;a.add(e);const s=e.localName??"element";console.warn(`[wcs/input-as-attribute] <${s}> has the attribute ${t}="${n}": an object was written as an attribute, so the element did not receive it. A framework does that when the property is set before the element's definition loads (React 19), or when told to (Vue's .attr). Load the definition before rendering, or assign the property through a ref (Vue: .prop). (Said once per element.)`,e)}class c extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[],commands:o.wcBindable.commands};_core;_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-network:change":e=>({"save-data":!0===e.saveData,supported:!0===e.supported,offline:!0===e.offline})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const e=this.attachInternals();return e.states.add("wcs-probe"),e.states.delete("wcs-probe"),e}catch{return null}}_wireStates(e){if(null===this._internals)return;const t=this._internals.states;for(const[n,s]of Object.entries(e))this.addEventListener(n,e=>{const n=this.hasAttribute("debug-states");for(const[o,i]of Object.entries(s(e.detail))){try{i?t.add(o):t.delete(o)}catch{}n&&this.toggleAttribute(`data-wcs-state-${o}`,i)}})}get effectiveType(){return this._core.effectiveType}get downlink(){return this._core.downlink}get rtt(){return this._core.rtt}get saveData(){return this._core.saveData}get supported(){return this._core.supported}get offline(){return this._core.offline}get connectedCallbackPromise(){return this._connectedCallbackPromise}connectedCallback(){!function(e){const t=e.constructor?.wcBindable,n=t?.inputs;if(void 0===n)return;const s=e.getAttribute;for(const t of n){const n=t.name,o="function"==typeof s?s.call(e,n.toLowerCase()):null;if(null!==o&&o.startsWith("[object ")&&r(e,n,o),!Object.prototype.hasOwnProperty.call(e,n))continue;if(!i(e,n))continue;const a=e,c=a[n];delete a[n],a[n]=c}}(this),this.style.display="none",this._connectedCallbackPromise=this._core.observe()}connectedMoveCallback(){}disconnectedCallback(){this._core.dispose()}}const l=Symbol.for("wcstack.package"),d=new WeakSet;function h(e,t){Object.defineProperty(e,l,{value:t,configurable:!0})}function f(e,t,n,s,o){if(void 0!==s&&(n===s||n.prototype instanceof s))return;const i=n[l];if(i===o||d.has(e))return;d.add(e);const a=o.slice(0,o.lastIndexOf("@"));console.warn(`[${a}] [wcs/package-twice] <${t}> is already defined by ${i??`another copy of ${a} that does not name its version`}; this copy, ${o}, does nothing. Load each package once.`)}function u(s=customElements){!function(e,t,n){for(const[s,o]of n){const n=e.get(s);void 0===n?(h(o,t),e.define(s,o)):f(e,s,n,o,t)}}(s,`${t}@${n}`,[[e.tagNames.network,c]])}var p;u(p);
2
2
  //# sourceMappingURL=auto.min.js.map
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/network","version":"4.26.0"};
61
+ var pkg = {"name":"@wcstack/network","version":"4.28.0"};
62
62
 
63
63
  const UNSUPPORTED_SNAPSHOT = Object.freeze({
64
64
  effectiveType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wcstack/network",
3
- "version": "4.26.0",
3
+ "version": "4.28.0",
4
4
  "description": "Declarative Network Information component for Web Components. Framework-agnostic navigator.connection monitor via wc-bindable-protocol.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.esm.js",