Releases: DamonOehlman/detect-browser
4.3.0
4.2.1
4.2.0
Added additional regex for matching the new UA string for ios-webview
for iOS 12.1.4
and greater (#96) - thanks to @e-compton on this one.
4.1.0
4.0.3
FIX: Remove Array#find
usage in the code. Additionally the source tsconfig.json
file (not release related, but pertinent) has been set to only expect es5
constructs in the code which should prevent any future attempts to use all the newer things we like to use.
Big thanks to @limonte for picking up these IE11 related issues.
4.0.2
FIX: Remove Array#fill
usage. While I expected this would be transpiled out by TypeScript, this is not the case. TypeScript expects that you might have injected a polyfill to take care of this, which is completely reasonable.
4.0.1
FIX: Address babel static analysis issue
TL; DR; If you were having "critical dependency" (see issue #84) warning when using [email protected]
it's now fixed (see PR #85). You should upgrade to 4.0.1
to resolve the issue.
Due to the use of the TypeScript umd
transpilation target, the generated index.js
file included code that implied dynamic require behaviour (something that is inherent in the UMD header pattern apparently). The TypeScript compiler has now been switched to generating a standard commonjs
output file.
Given that a UMD compilation target was selected for the 4.x
only very recently to satisfy a potential use case of detect-browser
within a requirejs
context, I feel this is an acceptable (and necessary) change.
I will look to create a transpiled file that can be used in a requirejs
context as part of completing #83 sometime in the future.
4.0.0
Summary
A TypeScript rewrite.
Breaking Changes
The only potential breaking change is that the bot
boolean flag has been removed for all "non-bot" detection results, i.e. when we have detected a browser or the node environment.
In the majority of cases this should not affect usage as detecting for bots will still succeed due to the "falsiness" evaluation of the undefined
value. The only corner case is if you are doing an equality comparison against false
at any point.
For instance, the following would no longer work:
const { detect } = require('detect-browser');
const result = detect();
if (result && result.bot == false) {
console.log('browser or node detected');
}
A simple change to the following, however, would resolve the issue:
const { detect } = require('detect-browser');
const result = detect();
if (result && !result.bot) {
console.log('browser or node detected');
}
Extra Goodness
As this is a full TypeScript rewrite, the type definitions are now included in the package by default. So with an upgrade to detect-browser@4
you should probably also remove the @types/detect-browser
package if you are working in a TypeScript environment.
Thanks
A big thanks goes to @sargant for being the catalyst for a source conversion to TypeScript with a couple of solid PRs, and also to @carusology for an excellent review and challenging some of the early design decisions that I had made with the initial conversion. What we have ended up with I think is a solid result.
3.0.0
(copied from the text of #65)
So this is a reasonably simple change, but one that should have a pretty big impact for people who have been hit with the code path which is returning a false positive on node detection (see #54).
It changes two things:
We do browser detection if at all possible (i.e. navigator is defined). This then falls back to detecting the node environment if that isn't available.
-
Removes the require('os') import for os detection and simply uses process.platform instead. The information won't be as detailed and it's possible that a user of this module may still want to opt to do their own check using the os module. Given that the majority use case is web browser detection though I think that makes sense. Should stop browserify bringing in any shims for the os module also (which is a good thing).
-
Because of point 2 though, I believe we should do a major version bump to 3.0.0 to ensure that no-one that is using detect-browser in an isomorphic way is caught out unexpectedly.