nyalab / caniuse-api Goto Github PK
View Code? Open in Web Editor NEWrequest the caniuse data to check browsers compatibilities
License: MIT License
request the caniuse data to check browsers compatibilities
License: MIT License
Can anyone tell why query isn't working for some well-known properties like background-color
and width
. The code below produces output as: Uncaught TypeError: Cannot read property 'title' of undefined
.
const caniuse = require('caniuse-api');
console.log(caniuse.getSupport('background-color'));
I've a plugin that uses caniuse-api
and would like to support these css properties too - agauniyal/vscode-caniuse#1 (comment). Are there any plans to support them in future?
I have tried the getSupport(feature)
and get reply like this.
For instance asking for animation-delay
:
Support for animation-delay:
Error: Please provide a proper feature name. Cannot find animation-delay
or background-color
:
Support for background-color:
Error: Please provide a proper feature name. Cannot find background-color
Both examples works fine if you search for them on caniuse.com
caniuse.getSupport()
returns some unexpected keys in numbers like:
{ n: 3.5, a: 34, '#3': 33, d: 34, '#1': 34, y: 35 }
What do these numbers (#3
, #1
) mean?
const caniuse = require('caniuse-api')
caniuse.getLatestStableBrowsers();
TypeError: Cannot read property 'lastVersions' of undefined
at Object.getLatestStableBrowsers (node_modules/caniuse-api/dist/index.js:85:41)
at Context.<anonymous> (test/test.js:14:13)
caniuse-lite: "1.0.30000830"
caniuse-api: "2.0.0"
browserslist: "2.11.3"
find a good es6 one
The current CS are not consistent:
Maybe something like: https://github.com/felixge/node-style-guide
How to install and setup this package? Is there external packages there need to be installed? as far I can see the require issn't a part of javascript.
is there a step by step how to set up a full working basic site using this package?
import * as caniuse from 'caniuse-api'
caniuse.isSupported(feature, browsers)
caniuse.getSupport(feature)
caniuse.find(query)
caniuse.currentBrowsers()
The diff for border-radius get support test now have a difference for safari: { '#1': 6.1, x: 4, y: 3.1 }
.
Note the #1
added. I take a quick look into recent caniuse db update and saw this diff Fyrd/caniuse@44dc9c2
Do you just want me to add this for the test ?
Maybe we should make test simpler (no deep equal) and just test keys to avoid testing data (we don't need to test data right?)
Hi,
Got a Weird Error when running
npm install -g caniuse-api
The install appears to go OK until it runs postinstall where it results in:
npm http 200 https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.2.tgz
> [email protected] postinstall C:\[REMOVED]\src\node_modules\caniuse-api
> node -e "require('shelljs/global');if(test('-d', 'dist'))exec('node dist/generate-features.js')"
[eval]:1
"require('shelljs/global');if(test('-d',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token ILLEGAL
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:456:26)
at evalScript (node.js:532:25)
at startup (node.js:80:7)
at node.js:901:3
unbuild [email protected]
npm ERR! weird error 8
npm ERR! not ok code 0
Hence the weird error :)
The funny thing is this runs fine within node itself. For example running the command straight from the command line works without any issue:
C:\[REMOVED]\src> node -e "require('shelljs/global');if(test('-d', 'dist'))exec('node dist/generate-features.js')"
I've included the relative position in the current working directory so you can see where I am running 'npm install' from.
Any help would be appreciated.
Hey, thanks for making this handy tool.
Seems like the few css values I used it for are not included in caniuse-lite.
Would it be possible to be able to choose either you want to use caniuse-lite or caniuse-db, that would be nice :)
Thanks.
https://travis-ci.org/cssnext/cssnext/builds/64634160
I get the issue locally too with another one name. I checked my features.json and there is a lot missing.
Here are some idea:
Maybe we can also get in touch if the owner of https://github.com/wuchengwei/caniuse
to get the name back.
So I realize that it is very vague but this module is causing me so many problems in trying to install with docker. It always seems to hang when it runs the generator.js and then crashes the process. Unfortunately I can't seem to get the error log out either. I saw there was another issue that mentioned the generator being a problem before, so I don't know if it's related or not.
I'm using the latest version of docker with node 4.2.2 and I'm running it on AWS free-tier.
es6 string: https://github.com/Nyalab/caniuse-api/blob/master/src/index.js#L26, more let, ...
Current lodash.uniq
version is 3.1.0 now, it has fewer deps and one fourth the size.
It would be nice to be able to check in the current runtime if some property is supported by passing the navigator.userAgent.
Should this be here?
It bothers JSPM, and I can't see a good reason.
Should I PR?
Is it possible to get returned information after entering a specific location/region (e.g. USA, North America, United Kingdom, etc.) rather than just using the default Global?
'y', 'n', 'x', 'a' are neither usable, nor readable enough
the lib needs to provide something better like:
[
ie: {
notavailableSince: number, // really needed? (sometimes 0, null, wat)
notavailableUntil: number,
availableSince: number,
availableUntil: number, // really needed? (technically max version of browser)
prefixedSince: number,
prefixedUntil: number,
partiallySince: number,
partiallyUntil: number,
unprefixedSince: number,
unprefixedUntil: number // really needed? (technically max version of browser)
},
....
]
is this a good idea to provide all properties, even il you can process data to recalculate it on the project side ?
which ones do you find useful ?
var browsers = "> 1%, last 2 versions, Firefox ESR, Opera 12.1"
// or
var browsers = ["> 1%", "last 2 versions", "Firefox ESR", "Opera 12.1"]
// then
if(caniuse("some-feature", browsers)) {
// YES YOU CAN
}
browser list like autoprefixer https://github.com/postcss/autoprefixer#browsers
Some properties fall into a subset called well-supported (encountered this while searching for "width" with the api)
How exactly can I target those considering that the well-supported subset might change in time?
Hey,
I saw another issue on this -- I'm encountering the same problem.
I install cssnext
via jspm: jspm install npm:cssnext
. It installs without error, but when I try to leverage cssnext I encounter an error stating that features.js
does not exist.
If I navigate to the caniuse-api
directory and run node generator.js
the file is generated successfully and all is well.
Node v5.3.0
NPM v3.5.3
Windows 10 x64
This module does not build on windows. There is an issue with the use of path.join where windows inserts backslashes. This then makes the require calls in features.js throw.
If you are ok with it I can submit a pull request to fix.
The postInstall scripts seems to never be executed.
it fails leaving stderout with
> [email protected] postinstall d:\E-Ressources\WebApps\www\node_modul
es\gulp-cssnext\node_modules\cssnext\node_modules\caniuse-api
> node -e "require('shelljs/global');if(test('-d', 'dist'))exec('node
dist/generate-features.js')"
based on the caniuse data, ofc
Maybe just "browserslist": "^1.3.6 || ^2.0.0"
😄
npm-install
currently installs the contents of the entire repo.
Here are some ways to prevent it:
TypeError: Cannot read property 'stats' of undefined
at /home/upyun/impress-website/node_modules/caniuse-api/dist/index.js:78:16
it might sound silly, according to the database weight, but it would be nice to replace require.resolve
usage by a json generation to avoid the readDir.
Probably hooked in the postinstall to have a json that match the installed db (so no prepublish since the json might be outdated according to the caniuse-db (hello semver)).
Also hooked in the "pretest" and it should be good.
Well it's almost done. I'll take a look to that tomorrow morning if nobody had done that before me.
Hi @Nyalab!
I've been working on an unofficial way to consume caniuse support data that is intended for modules, whereas the official dataset is intended for people. So I dropped a lot of keys that Autoprefixer & Browserslist don't use and then compacted the rest of the data. The end result weighs around 7 times less than the official database as of this writing, and the only downside is a slight performance hit when the data is restored into a caniuse format. We optimised for size, not speed, but I think we can perhaps improve this further in the future. For now the dataset is as close to caniuse-db as possible, for easy migration.
So I think it's important to use a single source of truth for the support data, and as I am starting to make much more use of caniuse-api I'd like to update the module to use caniuse-lite too.
My only reservation about the migration is that you are using the title
key from each feature. I'd like to know if that can be dropped so that we can keep caniuse-lite as lean as possible. But I would like some input from caniuse-api users, on whether they think this is necessary or not. I'm open to any feedback! 😄
Copying in users of this module/caniuse data: @agauniyal, @una, @schiehll, @sylvainpolletvillard, @MoOx, @bebraw & @ai.
Thanks!
I run npm install in my node Docker container and I get this in the output logs:
> [email protected] postinstall /var/www/node_modules/caniuse-api
> node generator.js
The command '/bin/sh -c npm install' returned a non-zero code: 1
Mind you, I don't explicitly depend on this package. I have no idea which package is responsible for downloading it.
Is there a way of figuring out what's going on? I am no npm
expert by any means so any options that could show me more details are more than welcome.
FYI
npm info using [email protected]
npm info using [email protected]
There is no reason to commit dist/
.
Those files must be included to the NPM release.
I recently changed npm version from 3 to 2 in order to use google app engine.
I could successfully install packages when i was using npm3, but after i changed to npm2, this error happens. I don't use this package directly. It is installed via dependencies of postcss-cssnext.
I think it's related to the way npm installs packages. I heard that npm3 differently installs its packages than npm2.
> [email protected] postinstall C:\Users\ZeroCho\WebstormProjects\zerocho-home\node_modules\caniuse-api
> node generator.js
module.js:338
throw err;
^
Error: Cannot find module './src/common'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\Users\ZeroCho\WebstormProjects\zerocho-home\node_modules\shelljs\shell.js:9:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
and the strange thing is, after failing npm install
, I tried to run that command again, then it succeeded. First install always fails and second install succeeds.
Per npm view it appears that on 4-6 version 1.6.0 was published ... but the next day 1.6.1 was published, and version 1.6.0 was unpublished or something? Even though the version exists in npm view it is no longer in the tree of available tgzs, so I'm making a guess here. (https://registry.npmjs.org/caniuse-api)
Problem is ... this causes yarn to blow up, because someone somewhere listed 1.6.0 as a valid dependency. I imagine you unpublished it for good reason (horrible problems or something), but would you mind publishing 1.6.1 again as 1.6.0 or something? I know the "right" thing would be to find the package and have them update their dependencies to be correct, but this should also be done (unpublishing is bad news).
You don't need to transpile tests.
You can use 6to5-node
to run them.
Hi,
a line similar to the following needs to be added in the README or somewhere:
caniuse-lite from caniuse.com / CC BY 4.0
Thanks,
Chris
getLatestStableBrowsers is returning an array with 180 elements
["firefox 2", "firefox 3" ...]
instead of the documented
'opera 26',
'ios_saf 8.1',
'ie_mob 11',
'ie 11',
'firefox 33',
'chrome 39' ]
$ jake compile --trace
� Compiling common...
� Compiling full...
� Compiling mobile...
[18:52:44] Using gulpfile ~/projects/desktop/gulpfile.js
[18:52:44] Starting 'mobile:clean'...
[18:52:44] Finished 'mobile:clean' after 4.54 ms
[18:52:44] Starting 'mobile:static'...
[18:52:44] Using gulpfile ~/projects/desktop/gulpfile.js
[18:52:44] Starting 'full:clean'...
[18:52:44] Starting 'mobile:styles'...
[18:52:44] Finished 'full:clean' after 3.5 ms
[18:52:44] Starting 'full:static'...
[18:52:44] Using gulpfile ~/projects/desktop/gulpfile.js
[18:52:44] Starting 'common:clean'...
[18:52:44] Starting 'full:styles'...
[18:52:44] Finished 'common:clean' after 18 ms
[18:52:44] Starting 'common:static'...
[18:52:44] Starting 'common:styles'...
[18:52:44] 'mobile:styles' errored after 163 ms
[18:52:44] Error: Cannot find module '../features.json'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/kslimani/projects/desktop/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/caniuse-api/dist/index.js:10:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
[18:52:44] 'full:styles' errored after 160 ms
[18:52:44] Error: Cannot find module '../features.json'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/kslimani/projects/desktop/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/caniuse-api/dist/index.js:10:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
[18:52:44] Finished 'full:static' after 188 ms
jake aborted.
Error: Process exited with error.
at api.fail (/usr/lib/node_modules/jake/lib/api.js:336:18)
at null.<anonymous> (/usr/lib/node_modules/jake/lib/utils/index.js:136:9)
at emit (events.js:98:17)
at ChildProcess.<anonymous> (/usr/lib/node_modules/jake/lib/utils/index.js:219:20)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:810:12)
[18:52:44] 'common:styles' errored after 176 ms
[18:52:44] Error: Cannot find module '../features.json'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/kslimani/projects/desktop/node_modules/gulp-cssnext/node_modules/cssnext/node_modules/caniuse-api/dist/index.js:10:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
kslimani@df3:~/projects/desktop (master)$ [18:52:44] Finished 'mobile:static' after 236 ms
[18:52:44] Finished 'common:static' after 287 ms
Attempting to install [email protected] on CentOS Linux release 7.2.1511 (Core)
. I was successful yesterday (don't know how), but am now failing due to [email protected].
Using react 0.14.3 but believe material-ui attempts to upgrade to 0.14.7
Looking for suggestions
npm ERR! Linux 3.10.0-327.10.1.el7.x86_64
npm ERR! argv "/usr/bin/node" "/bin/npm" "install"
npm ERR! node v4.4.0
npm ERR! npm v2.14.20
npm ERR! code ELIFECYCLEnpm ERR! [email protected] postinstall:
node generator.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node generator.js'.
npm ERR! This is most likely a problem with the caniuse-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node generator.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs caniuse-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls caniuse-api
npm ERR! There is likely additional logging output above.npm ERR! Please include the following file with any support request:
npm ERR! /var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/npm-debug.log[email protected] postinstall /var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api
node generator.jsmodule.js:327
throw err;
^Error: Cannot find module '/var/lib/jenkins/jobs/Arches'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
shell.js: internal error
Error: Command failed: "/usr/bin/node" /var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api/shelljs_61861a524f0a7dc03ee0
at checkExecSyncError (child_process.js:464:13)
at Object.execSync (child_process.js:504:13)
at execSync (/var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api/node_modules/shelljs/src/exec.js:81:11)
at _exec (/var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api/node_modules/shelljs/src/exec.js:214:12)
at /var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api/node_modules/shelljs/src/common.js:182:23
at Object. (/var/lib/jenkins/jobs/Arches - Development - Front/workspace/node_modules/material-ui/node_modules/inline-style-prefixer/node_modules/caniuse-api/generator.js:4:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
I just upgraded my version of browserslist to 3.2.8, and now I have this error in my tests:
Error {
browserslist: true,
message: 'Unknown version 66 of android',
name: 'BrowserslistError',
}
Function.select (node_modules/caniuse-api/node_modules/browserslist/index.js:622:17)
node_modules/caniuse-api/node_modules/browserslist/index.js:151:33
resolve (node_modules/caniuse-api/node_modules/browserslist/index.js:132:18)
browserslist (node_modules/caniuse-api/node_modules/browserslist/index.js:224:16)
Object.isSupported (node_modules/caniuse-api/dist/index.js:62:37)
module.exports (dist/main.js:49:34)
from this code:
const browsers = browserslist(options.browsers);
let isFallbackNeeded = !caniuse.isSupported("css-grid", browsers);
This already happened before. I think it is due to the browserslist version used by caniuse-api being out of date, possibly because of the package-lock.json file: https://github.com/Nyalab/caniuse-api/blob/master/package-lock.json#L862
If I rollback to the same version of browserslist, the problem is gone. But I would like to be up to date if possible. Do you know how to always use the latest version of browserslist by caniuse-api ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.