Socket
Socket
Sign inDemoInstall

@mapbox/mapbox-gl-supported

Package Overview
Dependencies
0
Maintainers
14
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 2.0.0

mapbox-gl-supported.js

55

index.js
'use strict';
if (typeof module !== 'undefined' && module.exports) {
module.exports = isSupported;
} else if (window) {
window.mapboxgl = window.mapboxgl || {};
window.mapboxgl.supported = isSupported;
window.mapboxgl.notSupportedReason = notSupportedReason;
}
exports.supported = isSupported;
exports.notSupportedReason = notSupportedReason;

@@ -34,2 +29,3 @@ /**

if (!isWebGLSupportedCached(options && options.failIfMajorPerformanceCaveat)) return 'insufficient WebGL support';
if (!isNotIE()) return 'insufficient ECMAScript 6 support';
}

@@ -122,9 +118,9 @@

function isCanvasGetImageDataSupported() {
const canvas = document.createElement('canvas');
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 1;
const context = canvas.getContext('2d');
var context = canvas.getContext('2d');
if (!context) {
return false;
}
const imageData = context.getImageData(0, 0, 1, 1);
var imageData = context.getImageData(0, 0, 1, 1);
return imageData && imageData.width === canvas.width;

@@ -156,24 +152,10 @@ }

if (canvas.probablySupportsContext) {
return (
canvas.probablySupportsContext('webgl', attributes) ||
canvas.probablySupportsContext('experimental-webgl', attributes)
);
} else if (canvas.supportsContext) {
return (
canvas.supportsContext('webgl', attributes) ||
canvas.supportsContext('experimental-webgl', attributes)
);
} else {
return (
canvas.getContext('webgl', attributes) ||
canvas.getContext('experimental-webgl', attributes)
);
}
return (
canvas.getContext('webgl', attributes) ||
canvas.getContext('experimental-webgl', attributes)
);
}
function isWebGLSupported(failIfMajorPerformanceCaveat) {
const gl = getWebGLContext(failIfMajorPerformanceCaveat);
var gl = getWebGLContext(failIfMajorPerformanceCaveat);
if (!gl) {

@@ -185,3 +167,12 @@ return false;

// to prevent fingerprinting. Unfortunately, this also means that Mapbox GL won't work.
const shader = gl.createShader(gl.VERTEX_SHADER);
var shader;
try {
shader = gl.createShader(gl.VERTEX_SHADER);
} catch (e) {
// some older browsers throw an exception that `createShader` is not defined
// so handle this separately from the case where browsers block `createShader`
// for security reasons
return false;
}
if (!shader || gl.isContextLost()) {

@@ -194,1 +185,5 @@ return false;

}
function isNotIE() {
return !document.documentMode;
}
{
"name": "@mapbox/mapbox-gl-supported",
"version": "1.5.0",
"version": "2.0.0",
"description": "A library to determine if a browser supports Mapbox GL JS",

@@ -8,3 +8,4 @@ "main": "index.js",

"test": "eslint index.js",
"build": "mkdir -p dist && uglifyjs index.js -c -m -o dist/mapbox-gl-supported.js"
"build": "browserify -s mapboxgl index.js | uglifyjs -c -m -o mapbox-gl-supported.js",
"prepublishOnly": "npm run build"
},

@@ -20,11 +21,11 @@ "repository": {

"homepage": "https://github.com/mapbox/mapbox-gl-supported#readme",
"files": [
"mapbox-gl-supported.js"
],
"devDependencies": {
"browserify": "^16.2.3",
"eslint": "^2.8.0",
"browserify": "^17.0.0",
"eslint": "^7.15.0",
"eslint-config-mourner": "^2.0.1",
"uglify-js": "^2.4.24"
},
"peerDependencies": {
"mapbox-gl": ">=0.32.1 <2.0.0"
"uglify-js": "^3.12.1"
}
}

@@ -29,3 +29,7 @@ # Mapbox GL JS Supported

```js
var isSupported = require('@mapbox/mapbox-gl-supported')();
var mapboxglSupported = require('@mapbox/mapbox-gl-supported');
if (mapboxglSupported.supported()) {
...
}
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc