Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wasm-feature-detect

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wasm-feature-detect - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

324

dist/cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: !0 });
var A =
Object.defineProperty(exports, "__esModule", { value: true });
var inlineModule =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQMBAAEMAQAKDgEMAEEAQQBBAPwKAAAL";
async function a(A) {
return WebAssembly.compile(await fetch(A).then(A => A.arrayBuffer()));
}
async function t() {
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This function only exists because `WebAssembly.compile` will
// be called quite often and by having our own function terser can give it
// a one-letter name.
async function testCompile(path) {
try {
return await a(A), !0;
} catch (A) {
return !1;
await WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
return true;
} catch (e) {
return false;
}
}
var r = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgAGQAcLCw==";
async function e() {
try {
return await a(r), !0;
} catch (A) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index() {
return testCompile(inlineModule);
}
var n = "data:application/wasm;base64,AGFzbQEAAAABBgFgAAJ/fwMCAQAKCAEGAEEAQQAL";
async function s() {
try {
return await a(n), !0;
} catch (A) {
return !1;
}
var inlineModule$1 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgAGQAcLCw==";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$1() {
return testCompile(inlineModule$1);
}
var c =
var inlineModule$2 =
"data:application/wasm;base64,AGFzbQEAAAABBgFgAAJ/fwMCAQAKCAEGAEEAQQAL";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$2() {
return testCompile(inlineModule$2);
}
var inlineModule$3 =
"data:application/wasm;base64,AGFzbQEAAAACCAEBYQFiA38BBgYBfwFBAAsHBQEBYQMB";
async function i() {
try {
return await a(c), !0;
} catch (A) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$3() {
return testCompile(inlineModule$3);
}
var B = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
async function o() {
try {
return await a(B), !0;
} catch (A) {
return !1;
}
var inlineModule$4 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$4() {
return testCompile(inlineModule$4);
}
var u =
var inlineModule$5 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgwBCgBDAAAAAPwAGgs=";
async function g() {
try {
return await a(u), !0;
} catch (A) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$5() {
return testCompile(inlineModule$5);
}
var p = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgBBAMAaCw==";
async function w() {
try {
return await a(p), !0;
} catch (A) {
return !1;
}
var inlineModule$6 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgBBAMAaCw==";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$6() {
return testCompile(inlineModule$6);
}
var E = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgkBBwBBAP0EGgs=";
async function y() {
try {
return await a(E), !0;
} catch (A) {
return !1;
}
var inlineModule$7 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgkBBwBBAP0EGgs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$7() {
return testCompile(inlineModule$7);
}
var b = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
async function l() {
try {
return await a(b), !0;
} catch (A) {
return !1;
}
var inlineModule$8 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$8() {
return testCompile(inlineModule$8);
}
var Q =
var inlineModule$9 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQQBAwEBCgsBCQBBAP4QAgAaCw==";
async function m() {
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$9() {
try {
return (
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: !0 }),
await new Promise(A => {
const a = new SharedArrayBuffer(1),
{ port1: t, port2: r } = new MessageChannel();
(r.onmessage = A), t.postMessage(a);
}),
await a(Q),
!0
);
} catch (A) {
return !1;
// Test for availability of shared Wasm memory
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: true });
// Test for transferability of SABs (needed for Firefox)
// https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
await new Promise(resolve => {
const sab = new SharedArrayBuffer(1);
const { port1, port2 } = new MessageChannel();
port2.onmessage = resolve;
port1.postMessage(sab);
});
// Test for atomics
return testCompile(inlineModule$9);
} catch (e) {
return false;
}
}
(exports.bulkMemory = t),
(exports.exceptions = e),
(exports.multiValue = s),
(exports.mutableGlobals = i),
(exports.referenceTypes = o),
(exports.saturatedFloatToInt = g),
(exports.signExtensions = w),
(exports.simd = y),
(exports.tailCall = l),
(exports.threads = m);
exports.bulkMemory = index;
exports.exceptions = index$1;
exports.multiValue = index$2;
exports.mutableGlobals = index$3;
exports.referenceTypes = index$4;
exports.saturatedFloatToInt = index$5;
exports.signExtensions = index$6;
exports.simd = index$7;
exports.tailCall = index$8;
exports.threads = index$9;

@@ -1,108 +0,252 @@

var a =
var inlineModule =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQMBAAEMAQAKDgEMAEEAQQBBAPwKAAAL";
async function A(a) {
return WebAssembly.compile(await fetch(a).then(a => a.arrayBuffer()));
}
async function t() {
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This function only exists because `WebAssembly.compile` will
// be called quite often and by having our own function terser can give it
// a one-letter name.
async function testCompile(path) {
try {
return await A(a), !0;
} catch (a) {
return !1;
await WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
return true;
} catch (e) {
return false;
}
}
var n = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgAGQAcLCw==";
async function r() {
try {
return await A(n), !0;
} catch (a) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index() {
return testCompile(inlineModule);
}
var s = "data:application/wasm;base64,AGFzbQEAAAABBgFgAAJ/fwMCAQAKCAEGAEEAQQAL";
async function e() {
try {
return await A(s), !0;
} catch (a) {
return !1;
}
var inlineModule$1 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgAGQAcLCw==";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$1() {
return testCompile(inlineModule$1);
}
var c =
var inlineModule$2 =
"data:application/wasm;base64,AGFzbQEAAAABBgFgAAJ/fwMCAQAKCAEGAEEAQQAL";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$2() {
return testCompile(inlineModule$2);
}
var inlineModule$3 =
"data:application/wasm;base64,AGFzbQEAAAACCAEBYQFiA38BBgYBfwFBAAsHBQEBYQMB";
async function i() {
try {
return await A(c), !0;
} catch (a) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$3() {
return testCompile(inlineModule$3);
}
var B = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
async function g() {
try {
return await A(B), !0;
} catch (a) {
return !1;
}
var inlineModule$4 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$4() {
return testCompile(inlineModule$4);
}
var u =
var inlineModule$5 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgwBCgBDAAAAAPwAGgs=";
async function o() {
try {
return await A(u), !0;
} catch (a) {
return !1;
}
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$5() {
return testCompile(inlineModule$5);
}
var w = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgBBAMAaCw==";
async function E() {
try {
return await A(w), !0;
} catch (a) {
return !1;
}
var inlineModule$6 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgBBAMAaCw==";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$6() {
return testCompile(inlineModule$6);
}
var y = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgkBBwBBAP0EGgs=";
async function b() {
try {
return await A(y), !0;
} catch (a) {
return !1;
}
var inlineModule$7 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgkBBwBBAP0EGgs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$7() {
return testCompile(inlineModule$7);
}
var p = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
async function Q() {
try {
return await A(p), !0;
} catch (a) {
return !1;
}
var inlineModule$8 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$8() {
return testCompile(inlineModule$8);
}
var l =
var inlineModule$9 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQQBAwEBCgsBCQBBAP4QAgAaCw==";
async function m() {
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$9() {
try {
return (
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: !0 }),
await new Promise(a => {
const A = new SharedArrayBuffer(1),
{ port1: t, port2: n } = new MessageChannel();
(n.onmessage = a), t.postMessage(A);
}),
await A(l),
!0
);
} catch (a) {
return !1;
// Test for availability of shared Wasm memory
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: true });
// Test for transferability of SABs (needed for Firefox)
// https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
await new Promise(resolve => {
const sab = new SharedArrayBuffer(1);
const { port1, port2 } = new MessageChannel();
port2.onmessage = resolve;
port1.postMessage(sab);
});
// Test for atomics
return testCompile(inlineModule$9);
} catch (e) {
return false;
}
}
export {
t as bulkMemory,
r as exceptions,
e as multiValue,
i as mutableGlobals,
g as referenceTypes,
o as saturatedFloatToInt,
E as signExtensions,
b as simd,
Q as tailCall,
m as threads
index as bulkMemory,
index$1 as exceptions,
index$2 as multiValue,
index$3 as mutableGlobals,
index$4 as referenceTypes,
index$5 as saturatedFloatToInt,
index$6 as signExtensions,
index$7 as simd,
index$8 as tailCall,
index$9 as threads
};

@@ -1,110 +0,262 @@

!(function(A, a) {
"object" == typeof exports && "undefined" != typeof module
? a(exports)
: "function" == typeof define && define.amd
? define(["exports"], a)
: a(((A = A || self).wasmFeatureDetect = {}));
})(this, function(A) {
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined"
? factory(exports)
: typeof define === "function" && define.amd
? define(["exports"], factory)
: ((global = global || self), factory((global.wasmFeatureDetect = {})));
})(this, function(exports) {
"use strict";
var a =
var inlineModule =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQMBAAEMAQAKDgEMAEEAQQBBAPwKAAAL";
async function t(A) {
return WebAssembly.compile(await fetch(A).then(A => A.arrayBuffer()));
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This function only exists because `WebAssembly.compile` will
// be called quite often and by having our own function terser can give it
// a one-letter name.
async function testCompile(path) {
try {
await WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
return true;
} catch (e) {
return false;
}
}
var e =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index() {
return testCompile(inlineModule);
}
var inlineModule$1 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgAGQAcLCw==";
var n =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$1() {
return testCompile(inlineModule$1);
}
var inlineModule$2 =
"data:application/wasm;base64,AGFzbQEAAAABBgFgAAJ/fwMCAQAKCAEGAEEAQQAL";
var r =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$2() {
return testCompile(inlineModule$2);
}
var inlineModule$3 =
"data:application/wasm;base64,AGFzbQEAAAACCAEBYQFiA38BBgYBfwFBAAsHBQEBYQMB";
var s = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
var i =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$3() {
return testCompile(inlineModule$3);
}
var inlineModule$4 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBADQGgs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$4() {
return testCompile(inlineModule$4);
}
var inlineModule$5 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgwBCgBDAAAAAPwAGgs=";
var c =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$5() {
return testCompile(inlineModule$5);
}
var inlineModule$6 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACggBBgBBAMAaCw==";
var B =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$6() {
return testCompile(inlineModule$6);
}
var inlineModule$7 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgkBBwBBAP0EGgs=";
var u = "data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
var o =
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$7() {
return testCompile(inlineModule$7);
}
var inlineModule$8 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEACgYBBAASAAs=";
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$8() {
return testCompile(inlineModule$8);
}
var inlineModule$9 =
"data:application/wasm;base64,AGFzbQEAAAABBAFgAAADAgEABQQBAwEBCgsBCQBBAP4QAgAaCw==";
(A.bulkMemory = async function() {
/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function index$9() {
try {
return await t(a), !0;
} catch (A) {
return !1;
// Test for availability of shared Wasm memory
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: true });
// Test for transferability of SABs (needed for Firefox)
// https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
await new Promise(resolve => {
const sab = new SharedArrayBuffer(1);
const { port1, port2 } = new MessageChannel();
port2.onmessage = resolve;
port1.postMessage(sab);
});
// Test for atomics
return testCompile(inlineModule$9);
} catch (e) {
return false;
}
}),
(A.exceptions = async function() {
try {
return await t(e), !0;
} catch (A) {
return !1;
}
}),
(A.multiValue = async function() {
try {
return await t(n), !0;
} catch (A) {
return !1;
}
}),
(A.mutableGlobals = async function() {
try {
return await t(r), !0;
} catch (A) {
return !1;
}
}),
(A.referenceTypes = async function() {
try {
return await t(s), !0;
} catch (A) {
return !1;
}
}),
(A.saturatedFloatToInt = async function() {
try {
return await t(i), !0;
} catch (A) {
return !1;
}
}),
(A.signExtensions = async function() {
try {
return await t(c), !0;
} catch (A) {
return !1;
}
}),
(A.simd = async function() {
try {
return await t(B), !0;
} catch (A) {
return !1;
}
}),
(A.tailCall = async function() {
try {
return await t(u), !0;
} catch (A) {
return !1;
}
}),
(A.threads = async function() {
try {
return (
new WebAssembly.Memory({ initial: 1, maximum: 1, shared: !0 }),
await new Promise(A => {
const a = new SharedArrayBuffer(1),
{ port1: t, port2: e } = new MessageChannel();
(e.onmessage = A), t.postMessage(a);
}),
await t(o),
!0
);
} catch (A) {
return !1;
}
}),
Object.defineProperty(A, "__esModule", { value: !0 });
}
exports.bulkMemory = index;
exports.exceptions = index$1;
exports.multiValue = index$2;
exports.mutableGlobals = index$3;
exports.referenceTypes = index$4;
exports.saturatedFloatToInt = index$5;
exports.signExtensions = index$6;
exports.simd = index$7;
exports.tailCall = index$8;
exports.threads = index$9;
Object.defineProperty(exports, "__esModule", { value: true });
});
{
"name": "wasm-feature-detect",
"version": "0.0.1",
"version": "1.0.0",
"description": "A small library (700B gzip’d) to detect which features of WebAssembly are supported in your current browser.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

@@ -53,4 +53,12 @@ # WebAssembly Feature Detection

## Why are all the tests async?
The _technical_ reason is that some tests might have to be augmented to be asynchronous in the future. For example, Firefox is planning to [make a change][ff coop] that would require a `postMessage` call to detect SABs, which are required for threads.
The _other_ reason is that you _should_ be using `WebAssembly.compile`, `WebAssembly.instantiate`, or their streaming versions `WebAssembly.compileStreaming` and `WebAssembly.instantiateStreaming`, which are all asynchronous. You should already be prepared for asynchronous code when using WebAssembly!
[ff coop]: https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
---
License Apache-2.0

@@ -0,1 +1,14 @@

/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { compileWat } from "./helpers.mjs";

@@ -2,0 +15,0 @@

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -21,9 +21,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,8 +22,3 @@ /**

export default async function() {
try {
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -22,9 +22,3 @@ /**

export default async function() {
try {
// Test for atomics
await testCompile(inlineModule);
return true;
} catch (e) {
return false;
}
return testCompile(inlineModule);
}

@@ -26,2 +26,3 @@ /**

// Test for transferability of SABs (needed for Firefox)
// https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ
await new Promise(resolve => {

@@ -34,4 +35,3 @@ const sab = new SharedArrayBuffer(1);

// Test for atomics
await testCompile(inlineModule);
return true;
return testCompile(inlineModule);
} catch (e) {

@@ -38,0 +38,0 @@ return false;

@@ -0,1 +1,14 @@

/**
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This function only exists because `WebAssembly.compile` will

@@ -5,3 +18,8 @@ // be called quite often and by having our own function terser can give it

export async function testCompile(path) {
return WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
try {
await WebAssembly.compile(await fetch(path).then(r => r.arrayBuffer()));
return true;
} catch (e) {
return false;
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc