@vknext/shared 1.3.6 → 1.3.7

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 +1 @@
1
- import{getGlobalThis as r}from"../../../helpers/getGlobalThis.js";import{createPromise as o}from"../../../utils/createPromise.js";import"../../../utils/parseSvg.js";import s from"./watchGlobalProperty.js";const e=async(e,t)=>{const i=r()[e];if(i)return Promise.resolve(i);const{promise:l,resolve:m}=o(),p=s(e,(r=>{m(r),p()}));return l};export{e as default};
1
+ import{getGlobalThis as r}from"../../../helpers/getGlobalThis.js";import{createPromise as o}from"../../../utils/createPromise.js";import"../../../utils/parseSvg.js";import e from"./watchGlobalProperty.js";const s=async(s,t)=>{const i=r()[s];if(i)return Promise.resolve(i);const{promise:l,resolve:m}=o(),p=e(s,(r=>{m(r),p()}),{once:!0});return l};export{s as default};
@@ -6,6 +6,7 @@ interface WatchOptions {
6
6
  timeout?: number;
7
7
  /** Проверять только после полной загрузки страницы */
8
8
  waitForPageLoad?: boolean;
9
+ once?: boolean;
9
10
  }
10
11
  declare const watchGlobalProperty: <T extends WindowVariables>(variable: T, callback: (value: (typeof window)[T]) => void, options?: WatchOptions) => () => void;
11
12
  export default watchGlobalProperty;
@@ -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}=i;let l=!0,a=null,c=null,u=null;const m=()=>{l=!1,a&&a.disconnect(),c&&clearInterval(c),u&&clearTimeout(u)},w=()=>{if(!l)return;const e=window[o];void 0!==e&&(n(e),m())},f=()=>{w(),l&&(a=new MutationObserver((e=>{if(l)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(w,0);t.querySelectorAll("script").length>0&&setTimeout(w,0)}})),t().then((()=>{l&&a&&a.observe(document.head,{childList:!0,subtree:!0})})),e().then((()=>{l&&a&&a.observe(document.body,{childList:!0})})),c=window.setInterval(w,d),null!==r&&(u=window.setTimeout((()=>{m(),console.warn(`[watchGlobalProperty] Timeout waiting for variable: ${String(o)}`)}),r)))};if(s)if("complete"===document.readyState)f();else{const e=()=>{f(),window.removeEventListener("load",e)};window.addEventListener("load",e)}else if("loading"===document.readyState){const e=()=>{f(),document.removeEventListener("DOMContentLoaded",e)};document.addEventListener("DOMContentLoaded",e)}else f();return m};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=(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)},f=()=>{if(!a)return;const e=window[o];void 0!==e&&(n(e),l&&w())},v=()=>{f(),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(f,0);t.querySelectorAll("script").length>0&&setTimeout(f,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(f,d),null!==r&&(m=window.setTimeout((()=>{w(),console.warn(`[watchGlobalProperty] Timeout waiting for variable: ${String(o)}`)}),r)))};if(s)if("complete"===document.readyState)v();else{const e=()=>{v(),window.removeEventListener("load",e)};window.addEventListener("load",e)}else if("loading"===document.readyState){const e=()=>{v(),document.removeEventListener("DOMContentLoaded",e)};document.addEventListener("DOMContentLoaded",e)}else v();return w};export{o as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vknext/shared",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "vk next shared",
5
5
  "type": "module",
6
6
  "files": [