@visactor/vtable
Version:
canvas table width high performance
43 lines (40 loc) • 1.3 kB
JavaScript
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;
//# sourceMappingURL=env.js.map