-
Notifications
You must be signed in to change notification settings - Fork 27
/
wasmFeatureDetect.js
107 lines (107 loc) · 3.18 KB
/
wasmFeatureDetect.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
!(function (e, n) {
"object" == typeof exports && "undefined" != typeof module
? (module.exports = n())
: "function" == typeof define && define.amd
? define(n)
: ((e = e || self).wasmFeatureDetect = n());
})(this, function () {
"use strict";
return {
bigInt: () =>
(async (e) => {
try {
return (
(await WebAssembly.instantiate(e)).instance.exports.b(BigInt(0)) ===
BigInt(0)
);
} catch (e) {
return !1;
}
})(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 126, 1, 126, 3, 2, 1, 0,
7, 5, 1, 1, 98, 0, 0, 10, 6, 1, 4, 0, 32, 0, 11,
])
),
bulkMemory: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 3, 1,
0, 1, 10, 14, 1, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11,
])
),
exceptions: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1,
6, 0, 6, 64, 25, 11, 11,
])
),
multiValue: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 0, 2, 127, 127, 3, 2, 1, 0,
10, 8, 1, 6, 0, 65, 0, 65, 0, 11,
])
),
mutableGlobals: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 2, 8, 1, 1, 97, 1, 98, 3, 127, 1, 6, 6,
1, 127, 1, 65, 0, 11, 7, 5, 1, 1, 97, 3, 1,
])
),
referenceTypes: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 7, 1,
5, 0, 208, 112, 26, 11,
])
),
saturatedFloatToInt: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 12, 1,
10, 0, 67, 0, 0, 0, 0, 252, 0, 26, 11,
])
),
signExtensions: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1,
6, 0, 65, 0, 192, 26, 11,
])
),
simd: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1,
7, 0, 65, 0, 253, 15, 26, 11,
])
),
tailCall: async () =>
WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 6, 1,
4, 0, 18, 0, 11,
])
),
threads: () =>
(async (e) => {
try {
return (
"undefined" != typeof MessageChannel &&
new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),
WebAssembly.validate(e)
);
} catch (e) {
return !1;
}
})(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 4, 1,
3, 1, 1, 10, 11, 1, 9, 0, 65, 0, 254, 16, 2, 0, 26, 11,
])
),
};
});