@vknext/shared 1.4.2 → 1.4.3

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.
@@ -1,6 +1,6 @@
1
1
  export type WindowVariables = keyof (Window & typeof globalThis);
2
2
  interface WatchOptions {
3
- /** Интервал проверки в миллисекундах (по умолчанию 100мс) */
3
+ /** Интервал проверки в миллисекундах (по умолчанию зависит от количества ядер) */
4
4
  checkInterval?: number;
5
5
  /** Максимальное время ожидания в миллисекундах */
6
6
  timeout?: number;
@@ -1 +1 @@
1
- import"../../../utils/parseSvg.js";import{waitHTMLBody as e}from"../../../utils/waitHTMLBody.js";import{waitHTMLHead as t}from"../../../utils/waitHTMLHead.js";const o=(o,n,i={})=>{const{checkInterval:d=100,timeout:r=null,waitForPageLoad:s=!1,once:l=!1}=i;let a=!0,c=null,u=null,m=null;const w=()=>{a=!1,c&&c.disconnect(),u&&clearInterval(u),m&&clearTimeout(m)};let f;const v=()=>{if(!a)return;const e=window[o];void 0!==e&&e!==f&&(f=e,n(e),l&&w())},L=()=>{v(),a&&(c=new MutationObserver((e=>{if(a)for(const t of e)if("childList"===t.type)for(const e of t.addedNodes)if(e.nodeType===Node.ELEMENT_NODE){const t=e;"SCRIPT"===t.tagName&&setTimeout(v,0);t.querySelectorAll("script").length>0&&setTimeout(v,0)}})),t().then((()=>{a&&c&&c.observe(document.head,{childList:!0,subtree:!0})})),e().then((()=>{a&&c&&c.observe(document.body,{childList:!0})})),u=window.setInterval(v,d),null!==r&&(m=window.setTimeout((()=>{w(),console.warn(`[watchGlobalProperty] Timeout waiting for variable: ${String(o)}`)}),r)))};if(s)if("complete"===document.readyState)L();else{const e=()=>{L(),window.removeEventListener("load",e)};window.addEventListener("load",e)}else if("loading"===document.readyState){const e=()=>{L(),document.removeEventListener("DOMContentLoaded",e)};document.addEventListener("DOMContentLoaded",e)}else L();return w};export{o as default};
1
+ import"../../../utils/parseSvg.js";import{waitHTMLBody as e}from"../../../utils/waitHTMLBody.js";import{waitHTMLHead as t}from"../../../utils/waitHTMLHead.js";const o=globalThis.navigator?.hardwareConcurrency??1,n=(n,i,r={})=>{const{checkInterval:a=Math.max(25,Math.round(233.33-8.33*o)),timeout:d=null,waitForPageLoad:l=!1,once:s=!1}=r;let c=!0,u=null,m=null,w=null;const v=()=>{c=!1,u&&u.disconnect(),m&&clearInterval(m),w&&clearTimeout(w)};let f;const h=()=>{if(!c)return;const e=window[n];void 0!==e&&e!==f&&(f=e,i(e),s&&v())},L=()=>{h(),c&&(u=new MutationObserver((e=>{if(c)for(const t of e)if("childList"===t.type)for(const e of t.addedNodes)if(e.nodeType===Node.ELEMENT_NODE){const t=e;"SCRIPT"===t.tagName&&setTimeout(h,0);t.querySelectorAll("script").length>0&&setTimeout(h,0)}})),t().then((()=>{c&&u&&u.observe(document.head,{childList:!0,subtree:!0})})),e().then((()=>{c&&u&&u.observe(document.body,{childList:!0})})),m=window.setInterval(h,a),null!==d&&(w=window.setTimeout((()=>{v(),console.warn(`[watchGlobalProperty] Timeout waiting for variable: ${String(n)}`)}),d)))};if(l)if("complete"===document.readyState)L();else{const e=()=>{L(),window.removeEventListener("load",e)};window.addEventListener("load",e)}else if("loading"===document.readyState){const e=()=>{L(),document.removeEventListener("DOMContentLoaded",e)};document.addEventListener("DOMContentLoaded",e)}else L();return v};export{n as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vknext/shared",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "vk next shared",
5
5
  "type": "module",
6
6
  "files": [