UNPKG

@visactor/vtable

Version:

canvas table width high performance

54 lines (50 loc) 1.76 kB
export class Env { static get mode() { return Env._mode || (Env._mode = defaultMode()), Env._mode; } static set mode(mode) { Env._mode = mode; } static RegisterCreateCanvas(func) { Env.CreateCanvas = func; } static RegisterLoadImage(func) { Env.LoadImage = func; } static GetCreateCanvasFunc() { return Env.CreateCanvas ? Env.CreateCanvas : "worker" === Env.mode ? (width = 200, height = 200) => new OffscreenCanvas(width, height) : void 0; } static RegisterRequestAnimationFrame(func) { Env.RequestAnimationFrame = func(); } static GetRequestAnimationFrame() { if (Env.RequestAnimationFrame) return Env.RequestAnimationFrame; } static RegisterCancelAnimationFrame(func) { Env.CancelAnimationFrame = func(); } static GetCancelAnimationFrame() { if (Env.CancelAnimationFrame) return Env.CancelAnimationFrame; } } function defaultMode() { let mode = "browser"; try { "node" === window.type ? mode = "node" : "undefined" == typeof window || window.performance ? "undefined" == typeof window && (mode = "node") : mode = "miniApp"; } catch (err) { mode = "node"; } return mode; } Env.dpr = 0; export function clearPageSelection() { try { const selection = window.getSelection(); if (selection) { if ("function" == typeof selection.removeAllRanges) return void selection.removeAllRanges(); if ("function" == typeof selection.empty) return void selection.empty(); if ("function" == typeof selection.collapse) return void selection.collapse(document.body, 0); } } catch (error) {} } //# sourceMappingURL=env.js.map