2020-06-02 06:24:46 +02:00
|
|
|
|
import { determineEmojiSupportLevel } from './determineEmojiSupportLevel'
|
2022-12-29 19:16:39 +01:00
|
|
|
|
import { requestIdleCallback } from './requestIdleCallback.js'
|
|
|
|
|
|
2020-05-18 04:08:00 +02:00
|
|
|
|
// Check which emojis we know for sure aren't supported, based on Unicode version level
|
2022-12-29 19:16:39 +01:00
|
|
|
|
let promise
|
|
|
|
|
export const detectEmojiSupportLevel = () => {
|
|
|
|
|
if (!promise) {
|
|
|
|
|
// Delay so it can run while the IDB database is being created by the browser (on another thread).
|
|
|
|
|
// This helps especially with first load – we want to start pre-populating the database on the main thread,
|
|
|
|
|
// and then wait for IDB to commit everything, and while waiting we run this check.
|
|
|
|
|
promise = new Promise(resolve => (
|
|
|
|
|
requestIdleCallback(() => (
|
|
|
|
|
resolve(determineEmojiSupportLevel()) // delay so ideally this can run while IDB is first populating
|
|
|
|
|
))
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
2024-03-09 22:21:00 +01:00
|
|
|
|
if (import.meta.env.MODE !== 'production') {
|
2022-12-29 19:16:39 +01:00
|
|
|
|
promise.then(emojiSupportLevel => {
|
|
|
|
|
console.log('emoji support level', emojiSupportLevel)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return promise
|
|
|
|
|
}
|
2020-05-18 04:08:00 +02:00
|
|
|
|
// determine which emojis containing ZWJ (zero width joiner) characters
|
|
|
|
|
// are supported (rendered as one glyph) rather than unsupported (rendered as two or more glyphs)
|
|
|
|
|
export const supportedZwjEmojis = new Map()
|