1 line
57 KiB
Plaintext
1 line
57 KiB
Plaintext
|
{"version":3,"file":"page-NWzulROZ.js","sources":["../src/hooks/useHeavyAnimationCheck.ts","../src/helpers/dom/whichChild.ts","../src/components/transition.ts","../src/helpers/animation.ts","../src/helpers/dom/isInDOM.ts","../src/helpers/fastSmoothScroll.ts","../src/helpers/dom/findUpAsChild.ts","../src/helpers/dom/dispatchEvent.ts","../src/helpers/dom/clickEvent.ts","../src/components/horizontalMenu.ts","../src/pages/pagesManager.ts","../src/pages/page.ts"],"sourcesContent":["/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\n// * Jolly Cobra's useHeavyAnimationCheck.ts, patched\n\nimport {AnyToVoidFunction} from '../types';\nimport ListenerSetter from '../helpers/listenerSetter';\nimport deferredPromise, {CancellablePromise} from '../helpers/cancellablePromise';\nimport DEBUG from '../config/debug';\nimport pause from '../helpers/schedulers/pause';\nimport EventListenerBase from '../helpers/eventListenerBase';\n\nconst eventListener = new EventListenerBase<{\n start: () => void,\n end: () => void\n}>();\nconst ANIMATION_START_EVENT = 'start';\nconst ANIMATION_END_EVENT = 'end';\n\nlet isAnimating = false;\nlet heavyAnimationPromise: CancellablePromise<void> = deferredPromise<void>();\nlet promisesInQueue = 0;\n\nheavyAnimationPromise.resolve();\n\nconst log = console.log.bind(console.log, '[HEAVY-ANIMATION]:');\n\nexport function dispatchHeavyAnimationEvent(promise: Promise<any>, timeout?: number) {\n if(!isAnimating) {\n heavyAnimationPromise = deferredPromise<void>();\n eventListener.dispatchEvent(ANIMATION_START_EVENT);\n isAnimating = true;\n DEBUG && log('start');\n }\n\n ++promisesInQueue;\n DEBUG && log('attach promise, length:', promisesInQueue, timeout);\n\n const promises = [\n timeout !== undefined ? pause(timeout) : undefined,\n promise.finally(() => {})\n ].filter(Boolean);\n\n const perf = performance.now();\n const _heavyAnimationPromise = heavyAnimationPromise;\n Promise.race(promises).then(() => {\n if(heavyAnimationPromise !== _heavyAnimationPromise || heavyAnimationPromise.isFulfilled) { // interrupted\n return;\n }\n\n --promisesInQueue;\n DEBUG && log('promise end, length:', promisesInQueue, performance.now() - perf);\n if(promisesInQueue <= 0) {\n onHeavyAnimationEnd();\n }\n });\n\n return heavyAnimationPromise;\n}\n\n(window as any).dispatchHeavyAnimationEvent = dispatchHeavyAnimationEvent;\n\nfunction onHeavyAnimationEnd() {\n if(heavyAnimationPromise.isFulfilled) {\n return;\n }\n\n isAnimating = false;\n promisesInQueue = 0;\n eventListener.dispatchEvent(ANIMATION_END_EVENT);\n heavyAnimationPromise.resolve();\n\n DEBUG && log('end');\n}\n\nexport function interruptHeavyAnimation() {\n onHeavyAnimationEnd();\n}\n\nexport function getHeavyAnimationPromise() {\n return heavyAnimationPromise;\n}\n\nexport default function(\n handleAnimationStart: AnyToVoidFunction,\n handleAnimationEnd: AnyToVoidFunction,\n listenerSetter?: ListenerSetter\n) {\n // useEffect(() => {\n if(isAnimating) {\n handleAnimationStart();\n }\n\n const add = listenerSetter ? listenerSetter.add(eventListener) : eventListener.addEventListener.bind(eventListener);\n const remove = listenerSetter ? listenerSetter.removeManual.bind(listenerSetter, eventListener) : eventListener.removeEventListener.bind(eventListener);\n add(ANIMATION_START_EVENT, handleAnimationStart);\n add(ANIMATION_END_EVENT, handleAnimationEnd);\n\n return () => {\n remove(ANIMATION_END_EVENT, handleAnimationEnd);\n remove(ANIMATION_START_EVENT, handleAnimationStart);\n };\n // }, [handleAnimationEnd, handleAnimationStart]);\n}\n","/*\n * https://github.com/morethanwords/tweb\n * Copyright (C) 2019-2021 Eduard Kuzmenko\n * https://github.com/morethanwords/tweb/blob/master/LICENSE\n */\n\nexport default function whichChild(elem: Node, countNonElements?: boolean) {\n if(!elem?.parentNode) {\n return -1;\n }\n\n if(countNonElements) {\n return Array.fro
|