-
Notifications
You must be signed in to change notification settings - Fork 80
/
Platform.js
73 lines (64 loc) · 1.6 KB
/
Platform.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
let $URL = null;
let $atob = null;
let $Blob = null;
let $window = null;
let $document = null;
let $DOMParser = null;
let $TextDecoder = null;
let $XMLHttpRequest = null;
let $OffscreenCanvas = null;
let $HTMLCanvasElement = null;
let $createImageBitmap = null;
let $requestAnimationFrame = null;
let $cancelAnimationFrame = null;
class Platform {
set(platform) {
this.platform && this.platform.dispose();
this.platform = platform;
const globals = platform.getGlobals();
$atob = globals.atob;
$Blob = globals.Blob;
$window = globals.window;
$document = globals.document;
$XMLHttpRequest = globals.XMLHttpRequest;
$OffscreenCanvas = globals.OffscreenCanvas;
$HTMLCanvasElement = globals.HTMLCanvasElement;
$createImageBitmap = globals.createImageBitmap;
$URL = $window.URL;
$DOMParser = $window.DOMParser;
$TextDecoder = $window.TextDecoder;
$requestAnimationFrame = $window.requestAnimationFrame;
$cancelAnimationFrame = $window.cancelAnimationFrame;
}
dispose() {
this.platform && this.platform.dispose();
$URL = null;
$Blob = null;
$atob = null;
$window = null;
$document = null;
$DOMParser = null;
$TextDecoder = null;
$XMLHttpRequest = null;
$OffscreenCanvas = null;
$HTMLCanvasElement = null;
$createImageBitmap = null;
$requestAnimationFrame = null;
}
}
const PLATFORM = new Platform();
export {
$URL,
$atob,
$Blob,
$window,
PLATFORM,
$document,
$DOMParser,
$TextDecoder,
$XMLHttpRequest,
$OffscreenCanvas,
$HTMLCanvasElement,
$createImageBitmap,
$requestAnimationFrame,
};