Coder Social home page Coder Social logo

koala-interactive / is-emoji-supported Goto Github PK

View Code? Open in Web Editor NEW
20.0 12.0 6.0 1.39 MB

Detect if the current attached device support the specified emoji

License: MIT License

TypeScript 60.89% JavaScript 39.11%
emoji support detect emojione joypixels unicode

is-emoji-supported's People

Contributors

dependabot[bot] avatar guillaumepn avatar massinissanm avatar muzishell avatar vthibault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

is-emoji-supported's Issues

Failed to parse source map warning

Getting warning from source-map-loader:

WARNING in ./node_modules/emoji-mart/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'xxx/node_modules/emoji-mart/dist/node_modules/is-emoji-supported/src/is-emoji-supported.ts' file: Error: ENOENT: no such file or directory, open 'xxx/node_modules/emoji-mart/dist/node_modules/is-emoji-supported/src/is-emoji-supported.ts'

webpack compiled with 1 warning

Brave breaks emoji support detection

Hi there,

First, thanks for making this, it's been a godsend.

Brave apparently has "anti fingerprinting" code in their getImageData() method, which makes is-emoji-supported return incorrect results.

To repro, compare this codesandbox in Chrome vs Brave: https://codesandbox.io/s/serene-joliot-hjbef

It's obviously an issue with Brave and not your code, but it still means that code that uses this library is effectively broken for Brave users. I'd be happy to provide a PR that addresses it, but I figured it might be worth discussing approaches first.

1. Simply don't support Brave

A valid choice, given that it's Brave who's not respecting the spec. That said, browsers not respecting specs is common, and a library that exists to test browser support for something might be expected to be able to deal with that.

2. Allow slight color differences

Brave returns colors from getImageData that are very close to the actual colors. Eg when testing, I found that it returned an (0,0,0,16) rgba pixel value as eg (1,0,1,16). We could edit the code to allow small color variations, eg let each channel (r, g, b, a) vary by 1 or 2 points.

3. Allow slight color differences on Brave only

Wrap the loose approach from point 2 in a if(navigator.brave.isBrave)

4. Compare more than one pixel

Brave does not obfuscate every byte, which is why the codesandbox link shows some emojis as supported and some as not. Given that we're checking that the font color is fully ignored when emojis are rendered, it might be good enough when some pixels are equal. Eg compare up to 10 pixels and only fail when none of them match.

I think that personally I lean towards option 3 which is very explicitly Brave-only. This makes maintenance easy because it's a clear hack for a specific browser's specific bug. I'll be happy to provide a PR.

Curious about your thoughts!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.