wasm-feature-detect
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,65 +0,1 @@ | ||
"use strict"; | ||
async function e(e) { | ||
return WebAssembly.validate( | ||
new Uint8Array(e.match(/(.{1,2})/g).map(e => parseInt(e, 16))) | ||
); | ||
} | ||
async function n() { | ||
try { | ||
return ( | ||
await new Promise(e => { | ||
const { port1: n, port2: a } = new MessageChannel(); | ||
(a.onmessage = e), n.postMessage(new SharedArrayBuffer(1)); | ||
}), | ||
!0 | ||
); | ||
} catch (e) { | ||
return !1; | ||
} | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
const a = e.bind( | ||
null, | ||
"0061736d010000000104016000000302010005030100010c01000a0e010c00410041004100fc0a00000b" | ||
), | ||
t = e.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107000640071a0b0b" | ||
), | ||
r = e.bind( | ||
null, | ||
"0061736d010000000106016000027f7f030201000a08010600410041000b" | ||
), | ||
s = e.bind( | ||
null, | ||
"0061736d0100000002080101610162037f010606017f0141000b07050101610301" | ||
), | ||
l = e.bind(null, "0061736d01000000010401600000030201000a06010400d01a0b"), | ||
o = e.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a0c010a004300000000fc001a0b" | ||
), | ||
d = e.bind(null, "0061736d01000000010401600000030201000a080106004100c01a0b"), | ||
b = e.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107004100fd041a0b" | ||
), | ||
i = e.bind(null, "0061736d01000000010401600000030201000a0601040012000b"); | ||
async function u() { | ||
return (await Promise.all([ | ||
e( | ||
"0061736d01000000010401600000030201000504010301010a0b0109004100fe1002001a0b" | ||
), | ||
n() | ||
])).every(e => e); | ||
} | ||
(exports.bulkMemory = a), | ||
(exports.exceptions = t), | ||
(exports.multiValue = r), | ||
(exports.mutableGlobals = s), | ||
(exports.referenceTypes = l), | ||
(exports.saturatedFloatToInt = o), | ||
(exports.signExtensions = d), | ||
(exports.simd = b), | ||
(exports.tailCall = i), | ||
(exports.threads = u); | ||
"use strict";async function e(e){return WebAssembly.validate(new Uint8Array(e))}async function n(){try{return await new Promise(e=>{const{port1:n,port2:t}=new MessageChannel;t.onmessage=e,n.postMessage(new SharedArrayBuffer(1))}),!0}catch(e){return!1}}Object.defineProperty(exports,"__esModule",{value:!0});const t=e.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,12,1,0,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11]),r=e.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,6,64,7,26,11,11]),s=e.bind(null,[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]),l=e.bind(null,[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]),o=e.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,208,26,11]),a=e.bind(null,[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]),i=e.bind(null,[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]),u=e.bind(null,[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,4,26,11]),p=e.bind(null,[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]);async function d(){return(await Promise.all([e([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]),n()])).every(e=>e)}exports.bulkMemory=t,exports.exceptions=r,exports.multiValue=s,exports.mutableGlobals=l,exports.referenceTypes=o,exports.saturatedFloatToInt=a,exports.signExtensions=i,exports.simd=u,exports.tailCall=p,exports.threads=d; |
@@ -1,65 +0,1 @@ | ||
async function n(n) { | ||
return WebAssembly.validate( | ||
new Uint8Array(n.match(/(.{1,2})/g).map(n => parseInt(n, 16))) | ||
); | ||
} | ||
async function a() { | ||
try { | ||
return ( | ||
await new Promise(n => { | ||
const { port1: a, port2: e } = new MessageChannel(); | ||
(e.onmessage = n), a.postMessage(new SharedArrayBuffer(1)); | ||
}), | ||
!0 | ||
); | ||
} catch (n) { | ||
return !1; | ||
} | ||
} | ||
const e = n.bind( | ||
null, | ||
"0061736d010000000104016000000302010005030100010c01000a0e010c00410041004100fc0a00000b" | ||
), | ||
b = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107000640071a0b0b" | ||
), | ||
d = n.bind( | ||
null, | ||
"0061736d010000000106016000027f7f030201000a08010600410041000b" | ||
), | ||
l = n.bind( | ||
null, | ||
"0061736d0100000002080101610162037f010606017f0141000b07050101610301" | ||
), | ||
r = n.bind(null, "0061736d01000000010401600000030201000a06010400d01a0b"), | ||
t = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a0c010a004300000000fc001a0b" | ||
), | ||
i = n.bind(null, "0061736d01000000010401600000030201000a080106004100c01a0b"), | ||
c = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107004100fd041a0b" | ||
), | ||
s = n.bind(null, "0061736d01000000010401600000030201000a0601040012000b"); | ||
async function u() { | ||
return (await Promise.all([ | ||
n( | ||
"0061736d01000000010401600000030201000504010301010a0b0109004100fe1002001a0b" | ||
), | ||
a() | ||
])).every(n => n); | ||
} | ||
export { | ||
e as bulkMemory, | ||
b as exceptions, | ||
d as multiValue, | ||
l as mutableGlobals, | ||
r as referenceTypes, | ||
t as saturatedFloatToInt, | ||
i as signExtensions, | ||
c as simd, | ||
s as tailCall, | ||
u as threads | ||
}; | ||
async function n(n){return WebAssembly.validate(new Uint8Array(n))}async function e(){try{return await new Promise(n=>{const{port1:e,port2:l}=new MessageChannel;l.onmessage=n,e.postMessage(new SharedArrayBuffer(1))}),!0}catch(n){return!1}}const l=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,12,1,0,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11]),r=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,6,64,7,26,11,11]),t=n.bind(null,[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]),a=n.bind(null,[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]),i=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,208,26,11]),u=n.bind(null,[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]),s=n.bind(null,[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]),o=n.bind(null,[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,4,26,11]),b=n.bind(null,[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]);async function d(){return(await Promise.all([n([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]),e()])).every(n=>n)}export{l as bulkMemory,r as exceptions,t as multiValue,a as mutableGlobals,i as referenceTypes,u as saturatedFloatToInt,s as signExtensions,o as simd,b as tailCall,d as threads}; |
@@ -1,75 +0,1 @@ | ||
!(function(e, n) { | ||
"object" == typeof exports && "undefined" != typeof module | ||
? n(exports) | ||
: "function" == typeof define && define.amd | ||
? define(["exports"], n) | ||
: n(((e = e || self).wasmFeatureDetect = {})); | ||
})(this, function(e) { | ||
"use strict"; | ||
async function n(e) { | ||
return WebAssembly.validate( | ||
new Uint8Array(e.match(/(.{1,2})/g).map(e => parseInt(e, 16))) | ||
); | ||
} | ||
async function a() { | ||
try { | ||
return ( | ||
await new Promise(e => { | ||
const { port1: n, port2: a } = new MessageChannel(); | ||
(a.onmessage = e), n.postMessage(new SharedArrayBuffer(1)); | ||
}), | ||
!0 | ||
); | ||
} catch (e) { | ||
return !1; | ||
} | ||
} | ||
const t = n.bind( | ||
null, | ||
"0061736d010000000104016000000302010005030100010c01000a0e010c00410041004100fc0a00000b" | ||
), | ||
l = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107000640071a0b0b" | ||
), | ||
d = n.bind( | ||
null, | ||
"0061736d010000000106016000027f7f030201000a08010600410041000b" | ||
), | ||
s = n.bind( | ||
null, | ||
"0061736d0100000002080101610162037f010606017f0141000b07050101610301" | ||
), | ||
i = n.bind(null, "0061736d01000000010401600000030201000a06010400d01a0b"), | ||
r = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a0c010a004300000000fc001a0b" | ||
), | ||
u = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a080106004100c01a0b" | ||
), | ||
o = n.bind( | ||
null, | ||
"0061736d01000000010401600000030201000a090107004100fd041a0b" | ||
), | ||
b = n.bind(null, "0061736d01000000010401600000030201000a0601040012000b"); | ||
(e.bulkMemory = t), | ||
(e.exceptions = l), | ||
(e.multiValue = d), | ||
(e.mutableGlobals = s), | ||
(e.referenceTypes = i), | ||
(e.saturatedFloatToInt = r), | ||
(e.signExtensions = u), | ||
(e.simd = o), | ||
(e.tailCall = b), | ||
(e.threads = async function() { | ||
return (await Promise.all([ | ||
n( | ||
"0061736d01000000010401600000030201000504010301010a0b0109004100fe1002001a0b" | ||
), | ||
a() | ||
])).every(e => e); | ||
}), | ||
Object.defineProperty(e, "__esModule", { value: !0 }); | ||
}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).wasmFeatureDetect={})}(this,function(e){"use strict";async function n(e){return WebAssembly.validate(new Uint8Array(e))}async function t(){try{return await new Promise(e=>{const{port1:n,port2:t}=new MessageChannel;t.onmessage=e,n.postMessage(new SharedArrayBuffer(1))}),!0}catch(e){return!1}}const l=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,12,1,0,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11]),i=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,6,64,7,26,11,11]),s=n.bind(null,[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]),r=n.bind(null,[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]),a=n.bind(null,[0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,208,26,11]),u=n.bind(null,[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]),o=n.bind(null,[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]),d=n.bind(null,[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,4,26,11]),c=n.bind(null,[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]);e.bulkMemory=l,e.exceptions=i,e.multiValue=s,e.mutableGlobals=r,e.referenceTypes=a,e.saturatedFloatToInt=u,e.signExtensions=o,e.simd=d,e.tailCall=c,e.threads=async function(){return(await Promise.all([n([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]),t()])).every(e=>e)},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "wasm-feature-detect", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A small library to detect which features of WebAssembly are supported in your current browser.", | ||
@@ -10,4 +10,4 @@ "main": "dist/cjs/index.js", | ||
"build:readme": "node --experimental-modules ./render-readme.mjs", | ||
"build": "npm run build:library && npm run build:readme", | ||
"fmt": "prettier --write './{,src,rollup-plugins}/**/*.{mjs,js,md}'" | ||
"build": "npm run build:library && npm run build:readme && npm run fmt", | ||
"fmt": "prettier --write './{,{src,rollup-plugins}/**/}*.{mjs,js,md}'" | ||
}, | ||
@@ -14,0 +14,0 @@ "repository": "GoogleChromeLabs/wasm-feature-detect", |
# WebAssembly Feature Detection | ||
A small library (~560B gzip’d) to detect which features of WebAssembly are supported in your current browser. | ||
A small library to detect which features of WebAssembly are supported. | ||
- ✅ Runs in all major browsers | ||
- ✅ Runs in Node | ||
- ✅ Provided as an ES6 module, CommonJS and UMD module. | ||
- ✅ CSP compatible | ||
- ✅ Only ~550B | ||
## Installation | ||
@@ -59,3 +65,20 @@ | ||
## Contributing | ||
If you want to contribute a new feature test, all you need to do is create a new folder in `src/detectors` and it will be automatically picked up. The folder must contain a `module.wat` file, which will be compiled using [`wat2wasm`][wat2wasm]. | ||
```wat | ||
;; Name: <Name of the feature for the README> | ||
;; Proposal: <Link to the proposal’s explainer/repo> | ||
;; Flags: <CLI flags for `wat2wasm`> | ||
(module | ||
;; More WAT code here | ||
) | ||
``` | ||
The folder can also contain an optional `index.js` file, whose default export must be an async function. This function can do additional testing in JavaScript and must return a boolean. See the “threads” detector as an example. | ||
[ff coop]: https://groups.google.com/forum/#!msg/mozilla.dev.platform/IHkBZlHETpA/dwsMNchWEQAJ | ||
[wat2wasm]: https://github.com/webassembly/wabt | ||
@@ -62,0 +85,0 @@ --- |
@@ -33,3 +33,2 @@ /** | ||
const plugins = await fsp.readdir(rootPluginPath); | ||
const base64s = []; | ||
const sources = await Promise.all( | ||
@@ -45,7 +44,8 @@ plugins.map(async plugin => { | ||
])[1].split(" "); | ||
const module = await compileWat( | ||
`./src/${pluginFolder}/${plugin}/module.wat`, | ||
flags | ||
); | ||
const hexModule = module.toString("hex"); | ||
const module = JSON.stringify([ | ||
...(await compileWat( | ||
`./src/${pluginFolder}/${plugin}/module.wat`, | ||
flags | ||
)) | ||
]); | ||
if (await fileExists(`./src/${pluginFolder}/${plugin}/index.js`)) { | ||
@@ -57,5 +57,5 @@ return ` | ||
export async function ${camelCaseify(plugin)}() { | ||
return (await Promise.all([validate(${JSON.stringify( | ||
hexModule | ||
)}), ${camelCaseify(plugin)}_internal()])).every(x => x); | ||
return (await Promise.all([validate(${module}), ${camelCaseify( | ||
plugin | ||
)}_internal()])).every(x => x); | ||
} | ||
@@ -65,5 +65,3 @@ `; | ||
return ` | ||
export const ${camelCaseify( | ||
plugin | ||
)} = validate.bind(null, ${JSON.stringify(hexModule)}); | ||
export const ${camelCaseify(plugin)} = validate.bind(null, ${module}); | ||
`; | ||
@@ -70,0 +68,0 @@ }) |
@@ -28,11 +28,15 @@ /** | ||
indexGenerator({ indexPath: "./src/index.js", pluginFolder: "detectors" }), | ||
terser({ | ||
ecma: 8, | ||
compress: true, | ||
mangle: { | ||
toplevel: true | ||
} | ||
}), | ||
...(process.env.NO_MINIFY | ||
? [] | ||
: [ | ||
terser({ | ||
ecma: 8, | ||
compress: true, | ||
mangle: { | ||
toplevel: true | ||
} | ||
}) | ||
]), | ||
sizePrinter() | ||
] | ||
})); |
@@ -17,6 +17,4 @@ /** | ||
// a one-letter name. | ||
export async function validate(hexModule) { | ||
return WebAssembly.validate( | ||
new Uint8Array(hexModule.match(/(.{1,2})/g).map(v => parseInt(v, 16))) | ||
); | ||
export async function validate(module) { | ||
return WebAssembly.validate(new Uint8Array(module)); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36554
87
1
262
5