@vknext/shared 1.3.4 → 1.3.6

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{createPromise as e}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{getHlsInstance as r}from"./utils/getHlsInstance.js";import{sendMessage as o}from"./utils/sendMessage.js";const t=async({url:t,filename:s,onProgress:n,forceHls:a})=>{if(!a)try{return await o({url:t,filename:s,type:"convertHlsToMp3",onProgress:n})}catch(e){console.error(e)}const{promise:i,resolve:l,reject:c}=e(),d=await r(),u=new d,E=new Audio;let p=null;const f=[];let m,g,v=0;const R=e=>{c(e),u.stopLoad(),u.destroy()};return u.on(d.Events.MANIFEST_PARSED,((e,r)=>{const o=r.levels[0]?.details;o&&(g=o.fragments.length)})),u.on(d.Events.BUFFER_CODECS,((e,r)=>{r.audio&&"audio/mp4"!==r.audio.container||(m=r.audio)})),u.on(d.Events.BUFFER_APPENDING,((e,r)=>{p=r.data})),u.on(d.Events.ERROR,((e,r)=>{if(!["bufferFullError","fragLoadError"].includes(r.details))return r.type==d.ErrorTypes.MEDIA_ERROR&&v<2?(++v>1&&u.swapAudioCodec(),void u.recoverMediaError()):void R(e);R(e)})),u.on(d.Events.FRAG_BUFFERED,(async(e,r)=>{p&&f.push(m?p.slice(8,p.length):p),E.currentTime=r.frag.start+r.frag.duration;try{n&&n(f.length/g)}catch(e){console.error(e)}if(f.length>=g){u.stopLoad(),u.destroy();const e=new Blob(f,{type:"audio/mp3"});l(e)}})),u.loadSource(t),u.attachMedia(E),await i};export{t as convertTrackToBlob};
1
+ import{createPromise as e}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{getHlsInstance as r}from"./utils/getHlsInstance.js";import{sendMessage as o}from"./utils/sendMessage.js";const t=async({url:t,filename:s,onProgress:n,forceHls:a})=>{if(!a)try{return await o({url:t,filename:s,type:"convertHlsToMp3",onProgress:n})}catch(e){console.error(e)}const{promise:i,resolve:l,reject:c}=e(),d=await r(),u=new d,E=new Audio;let p=null;const m=[];let f,g,v=0;const y=e=>{c(e),u.stopLoad(),u.destroy()};return u.on(d.Events.MANIFEST_PARSED,((e,r)=>{const o=r.levels[0]?.details;o&&(g=o.fragments.length)})),u.on(d.Events.BUFFER_CODECS,((e,r)=>{r.audio&&"audio/mp4"!==r.audio.container||(f=r.audio)})),u.on(d.Events.BUFFER_APPENDING,((e,r)=>{p=r.data})),u.on(d.Events.ERROR,((e,r)=>{if(!["bufferFullError","fragLoadError"].includes(r.details))return r.type==d.ErrorTypes.MEDIA_ERROR&&v<2?(++v>1&&u.swapAudioCodec(),void u.recoverMediaError()):void y(e);y(e)})),u.on(d.Events.FRAG_BUFFERED,(async(e,r)=>{p&&m.push(f?p.slice(8,p.length):p),E.currentTime=r.frag.start+r.frag.duration;try{n&&n(m.length/g)}catch(e){console.error(e)}if(m.length>=g){u.stopLoad(),u.destroy();const e=m.map((e=>new Uint8Array(e))),r=new Blob(e,{type:"audio/mp3"});l(r)}})),u.loadSource(t),u.attachMedia(E),await i};export{t as convertTrackToBlob};
@@ -1 +1 @@
1
- import{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{getHlsInstance as r}from"./utils/getHlsInstance.js";const e=async({url:e})=>{const{promise:o,resolve:a,reject:s}=t(),i=await r(),n=new i,d=new Audio;let l,u=0,E=null;const c=t=>{s(t),n.stopLoad(),n.destroy()};return n.on(i.Events.MANIFEST_PARSED,((t,r)=>{const e=r.levels[0]?.details;e&&(l=e.totalduration)})),n.on(i.Events.BUFFER_APPENDING,((t,r)=>{E=r.data})),n.on(i.Events.FRAG_BUFFERED,((t,r)=>{if(E)return n.detachMedia(),void((t,r)=>{const e=Math.min(32*Math.round(t/4096/r),320);a({bitrate:e,size:t,duration:r})})(E.length/r.frag.duration*l,l)})),n.on(i.Events.ERROR,((t,r)=>{if(!["bufferFullError","fragLoadError"].includes(r.details))return r.type==i.ErrorTypes.MEDIA_ERROR&&u<2?(++u>1&&n.swapAudioCodec(),void n.recoverMediaError()):void c(t);c(t)})),n.loadSource(e),n.attachMedia(d),await o};export{e as getTrackDetails};
1
+ import{createPromise as t}from"../../utils/createPromise.js";import"../../utils/parseSvg.js";import{getHlsInstance as e}from"./utils/getHlsInstance.js";const r=async({url:r})=>{const{promise:o,resolve:s,reject:a}=t(),i=await e(),n=new i,d=new Audio;let l,u=0,E=null;const c=t=>{a(t),n.stopLoad(),n.destroy()};return n.on(i.Events.MANIFEST_PARSED,((t,e)=>{const r=e.levels[0]?.details;r&&(l=r.totalduration)})),n.on(i.Events.BUFFER_APPENDING,((t,e)=>{E=e.data})),n.on(i.Events.FRAG_LOADED,((t,e)=>{if(E)return n.detachMedia(),void((t,e)=>{const r=Math.round(8*t/e/1e3);s({bitrate:r,size:t,duration:e})})(E.length/e.frag.duration*l,l)})),n.on(i.Events.ERROR,((t,e)=>{if(!["bufferFullError","fragLoadError"].includes(e.details))return e.type==i.ErrorTypes.MEDIA_ERROR&&u<2?(++u>1&&n.swapAudioCodec(),void n.recoverMediaError()):void c(t);c(t)})),n.loadSource(r),n.attachMedia(d),await o};export{r as getTrackDetails};
@@ -6,4 +6,4 @@ export interface sendMessageParams {
6
6
  onProgress?: (current: number, total: number) => void;
7
7
  iframeURL?: string;
8
8
  }
9
- export declare const sendMessage: ({ onProgress, type, iframeURL, ...params }: sendMessageParams) => Promise<Blob>;
9
+ export declare const sendMessage: <T = Blob>({ onProgress, type, iframeURL, ...params }: sendMessageParams) => Promise<T>;
@@ -1,3 +1,11 @@
1
1
  export type WindowVariables = keyof (Window & typeof globalThis);
2
- declare const watchGlobalProperty: <T extends WindowVariables>(variable: T, callback: (value: (typeof window)[T]) => void) => () => void;
2
+ interface WatchOptions {
3
+ /** Интервал проверки в миллисекундах (по умолчанию 100мс) */
4
+ checkInterval?: number;
5
+ /** Максимальное время ожидания в миллисекундах */
6
+ timeout?: number;
7
+ /** Проверять только после полной загрузки страницы */
8
+ waitForPageLoad?: boolean;
9
+ }
10
+ declare const watchGlobalProperty: <T extends WindowVariables>(variable: T, callback: (value: (typeof window)[T]) => void, options?: WatchOptions) => () => void;
3
11
  export default watchGlobalProperty;
@@ -1 +1 @@
1
- import{getGlobalThis as e}from"../../../helpers/getGlobalThis.js";const t=()=>{const t=e();return t.__callbacksGlobals||(t.__callbacksGlobals=new Map),t.__callbacksGlobals},l=(e,l)=>{const a=t().get(e);a&&a.delete(l)},a=(a,s)=>{const o=t();if(o.has(a)){return o.get(a).add(s),()=>l(a,s)}const r=new Set;r.add(s),o.set(a,r);let c=window[a];return c&&s(c),(t=>{const l=e(),{variable:a,getValue:s,setValue:o}=t,r=Object.getOwnPropertyDescriptor(l,a);Object.defineProperty(l,a,{get:s,set:e=>(o(e),r?.set?.call(l,e),!0),configurable:!1,enumerable:!0})})({variable:a,getValue:()=>c,setValue:e=>{c=e;for(const t of r)t(e)}}),()=>l(a,s)};export{a 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}=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};
@@ -761,6 +761,10 @@ interface INav {
761
761
  change: (loc: NavGoLoc, ev?: string | React.MouseEvent<HTMLElement, MouseEvent>["nativeEvent"] | null, opts?: Record<string, any>) => void;
762
762
  onLocationChange: (handler: (locStr: string) => unknown) => () => void;
763
763
  addNavigationStartListener: (handler: (locStr: string) => unknown) => () => void;
764
+ /**
765
+ * Доступно только в mvk
766
+ */
767
+ fv_link?: string;
764
768
  }
765
769
 
766
770
  interface IPhotoview {
package/package.json CHANGED
@@ -1,16 +1,12 @@
1
1
  {
2
2
  "name": "@vknext/shared",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "vk next shared",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
8
8
  ],
9
9
  "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/index.js"
13
- },
14
10
  "./common": {
15
11
  "types": "./dist/common/index.d.ts",
16
12
  "default": "./dist/common/index.js"
@@ -55,9 +51,6 @@
55
51
  },
56
52
  "typesVersions": {
57
53
  "*": {
58
- ".": [
59
- "./dist/index.d.ts"
60
- ],
61
54
  "*": [
62
55
  "./dist/*.d.ts"
63
56
  ]
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./utils";
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- export{DOMContentLoaded}from"./utils/DOMContentLoaded.js";export{arrayUnFlat}from"./utils/arrayUnFlat.js";export{convertBlobToUint8Array}from"./utils/convertBlobToUint8Array.js";export{createPromise}from"./utils/createPromise.js";export{delay}from"./utils/delay.js";export{getReactAttrs}from"./utils/getReactAttrs.js";export{onDocumentComplete}from"./utils/onDocumentComplete.js";export{parseSvg}from"./utils/parseSvg.js";export{waitHTMLBody}from"./utils/waitHTMLBody.js";export{waitHTMLHead}from"./utils/waitHTMLHead.js";export{waitRAF}from"./utils/waitRAF.js";export{waitRIC}from"./utils/waitRIC.js";export{noop}from"./utils/noop.js";export{noopAsync}from"./utils/noopAsync.js";