{"version":3,"file":"static/chunks/57457.eb9c00a499b7b697.js","sources":["webpack://_N_E/./src/modules/performance/store/performance.constants.ts","webpack://_N_E/./src/modules/performance/methods/checkLowPerformance.ts","webpack://_N_E/./src/modules/performance/store/performance.action.ts","webpack://_N_E/./src/modules/performance/store/performance.epic.ts","webpack://_N_E/./src/modules/performance/store/performance.thunk.ts"],"sourceRoot":"","sourcesContent":["export const PERFORMANCE_SET_IS_LOW_PERFORMANCE =\n\t'PERFORMANCE_SET_IS_LOW_PERFORMANCE';\n","import { roundNumber } from '@common/methods/roundNumber/roundNumber';\nimport { PERFORMANCE_ELEMENT_ID } from '../components/PERFORMANCE_ELEMENT_ID';\n\nconst MAXIMUM_TIME_FRAME = roundNumber(1000 / 30, 0); // 30 FPS\nconst MAX_SLOW = 10;\nconst LOW_PERFORMANCE_LOAD_THRESHOLD = 250;\n\nlet DRAW_LOAD = 1;\nlet SLOW_COUNT = 0;\n\nconst draw = function (load, ctx) {\n\tconst img = document.querySelector('img');\n\tconst angle = 0.01;\n\tctx.clearRect(0, 0, 400, 400);\n\tctx.save();\n\tctx.translate(200, 200);\n\tfor (let i = 0; i < load; i++) {\n\t\tctx.rotate(angle);\n\t\tif (img) {\n\t\t\tctx.drawImage(img, 0, 0);\n\t\t}\n\t}\n\tctx.restore();\n};\n\nconst tick = function (ctx, callback, previousTime = null) {\n\tconst t_ = performance.now();\n\tconst elapsed_ = previousTime ? t_ - previousTime : 0;\n\tconst previousTime_ = t_;\n\tif (elapsed_ < MAXIMUM_TIME_FRAME || SLOW_COUNT < MAX_SLOW) {\n\t\tif (elapsed_ < MAXIMUM_TIME_FRAME) {\n\t\t\tDRAW_LOAD += 10;\n\t\t} else {\n\t\t\tSLOW_COUNT++;\n\t\t}\n\t\tdraw(DRAW_LOAD, ctx);\n\t\trequestAnimationFrame(() => tick(ctx, callback, previousTime_));\n\t} else {\n\t\t// found maximum sustainable load at 30 FPS\n\t\t// alert(`could draw ${DRAW_LOAD} in ${MAXIMUM_TIME_FRAME} ms`);\n\t\tcallback(DRAW_LOAD < LOW_PERFORMANCE_LOAD_THRESHOLD);\n\t}\n};\n\ntype CheckLowPerformanceCalback = (isLow: boolean) => void;\n\nexport const checkLowPerformance = (callback: CheckLowPerformanceCalback) => {\n\tconst performanceBox = document.getElementById(PERFORMANCE_ELEMENT_ID);\n\tconst canvas = document.createElement('canvas');\n\tperformanceBox.appendChild(canvas);\n\tconst ctx = canvas.getContext('2d');\n\trequestAnimationFrame(() => tick(ctx, callback));\n};\n","import { actionSimple } from '@legacyApp/client/modules/app/actionService';\nimport { PERFORMANCE_SET_IS_LOW_PERFORMANCE } from './performance.constants';\n\nexport const performanceSetIsLowPerformance = actionSimple(\n\tPERFORMANCE_SET_IS_LOW_PERFORMANCE,\n);\n","import { of } from 'rxjs';\nimport { combineEpics } from 'redux-observable';\nimport { epic } from '@legacyApp/client/modules/app/epicService';\nimport { REGISTRY_PERFORMANCE_PACKAGE } from '@legacyApp/client/store/registry/registry.constants';\nimport { adaptAppToLowPerformance, performanceTest } from './performance.thunk';\nimport { PERFORMANCE_SET_IS_LOW_PERFORMANCE } from './performance.constants';\n\nconst packageInjectedEpic = epic('packageInjectedEpic', {\n\tactions: (ofType) => ofType(REGISTRY_PERFORMANCE_PACKAGE),\n\tcallback: () => {\n\t\treturn of(performanceTest());\n\t},\n});\n\nconst performanceCheckedEpic = epic('performanceCheckedEpic', {\n\tactions: (ofType) => ofType(PERFORMANCE_SET_IS_LOW_PERFORMANCE),\n\tcallback: ({ action }) => {\n\t\tif (action.payload === false) {\n\t\t\treturn of();\n\t\t}\n\t\treturn of(adaptAppToLowPerformance());\n\t},\n});\n\nconst performanceEpic = combineEpics(\n\tpackageInjectedEpic,\n\tperformanceCheckedEpic,\n);\n\nexport default performanceEpic;\n","import { AppThunk } from '@legacyApp/types/store/ThunkAction';\nimport { optionsDisable } from '@legacyApp/client/store/options/options.actions';\nimport { OPTIONS } from '@legacyApp/client/store/options/options.constants';\nimport { lsSet } from '@modules/localStorage/methods/lsSet';\nimport { LocalStorageKeys } from '@modules/localStorage/types/localStorageKeys.type';\nimport { checkLowPerformance } from '../methods/checkLowPerformance';\nimport { performanceSetIsLowPerformance } from './performance.action';\n\nexport const performanceTest = (): AppThunk => {\n\treturn (dispatch, getState) => {\n\t\tconsole.log('performanceTest', getState().performance);\n\t\tif (getState().performance.isLowPerformance !== null) {\n\t\t\treturn;\n\t\t}\n\t\tcheckLowPerformance((isLow) => {\n\t\t\tlsSet(LocalStorageKeys.IS_LOW_PERFORMANCE, isLow);\n\t\t\tdispatch(performanceSetIsLowPerformance(isLow));\n\t\t});\n\t};\n};\n\nexport const adaptAppToLowPerformance = (): AppThunk => {\n\treturn (dispatch) => {\n\t\tdispatch(optionsDisable(OPTIONS.SOUND, true));\n\t\tdispatch(optionsDisable(OPTIONS.ANIMATION, true));\n\t\tdispatch(optionsDisable(OPTIONS.AUTOBET_CHART, true));\n\t\tdispatch(optionsDisable(OPTIONS.CHART, true));\n\t};\n};\n"],"names":["PERFORMANCE_SET_IS_LOW_PERFORMANCE","MAXIMUM_TIME_FRAME","roundNumber","DRAW_LOAD","SLOW_COUNT","draw","load","ctx","img","document","querySelector","clearRect","save","translate","i","rotate","drawImage","restore","tick","callback","previousTime","t_","performance","now","elapsed_","previousTime_","requestAnimationFrame","checkLowPerformance","performanceBox","getElementById","PERFORMANCE_ELEMENT_ID","canvas","createElement","appendChild","getContext","performanceSetIsLowPerformance","actionSimple","packageInjectedEpic","epic","actions","ofType","REGISTRY_PERFORMANCE_PACKAGE","of","dispatch","getState","isLowPerformance","isLow","lsSet","LocalStorageKeys","performanceCheckedEpic","action","payload","optionsDisable","OPTIONS","combineEpics"],"mappings":";;uHAAO,IAAMA,EACZ,sC,qLCEKC,GAAqBC,EAAAA,EAAAA,GAAY,IAAO,GAAI,GAI9CC,EAAY,EACZC,EAAa,EAEXC,EAAO,SAAUC,EAAMC,GAC5B,IAAMC,EAAMC,SAASC,cAAc,OAEnCH,EAAII,UAAU,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