Use import() for emoji.json

This commit is contained in:
Tusooa Zhu 2022-09-20 22:03:31 -04:00
parent cc58b9b93d
commit 6fab7b9e3f
No known key found for this signature in database
GPG Key ID: 7B467EDE43A08224
4 changed files with 13 additions and 22 deletions

View File

@ -1,7 +1,7 @@
module.exports = { module.exports = {
updateEmoji () { updateEmoji () {
const emojis = require('unicode-emoji-json/data-by-group') const emojis = require('@kazvmoe-infra/unicode-emoji-json/data-by-group')
const fs = require('fs') const fs = require('fs')
Object.keys(emojis) Object.keys(emojis)

View File

@ -117,7 +117,6 @@
"stylelint": "13.13.1", "stylelint": "13.13.1",
"stylelint-config-standard": "20.0.0", "stylelint-config-standard": "20.0.0",
"stylelint-rscss": "0.4.0", "stylelint-rscss": "0.4.0",
"unicode-emoji-json": "^0.3.0",
"vue-loader": "17.0.0", "vue-loader": "17.0.0",
"vue-style-loader": "4.1.3", "vue-style-loader": "4.1.3",
"webpack": "5.74.0", "webpack": "5.74.0",

View File

@ -135,6 +135,7 @@ const loadAnnotations = (lang) => {
return import( return import(
`@kazvmoe-infra/unicode-emoji-json/annotations/${langCodeToCldrName(lang)}.json` `@kazvmoe-infra/unicode-emoji-json/annotations/${langCodeToCldrName(lang)}.json`
) )
.then(k => k.default)
} }
const injectAnnotations = (emoji, annotations) => { const injectAnnotations = (emoji, annotations) => {
@ -233,21 +234,17 @@ const instance = {
}, },
async getStaticEmoji ({ commit }) { async getStaticEmoji ({ commit }) {
try { try {
const res = await window.fetch('/static/emoji.json') const values = (await import('../../static/emoji.json')).default
if (res.ok) {
const values = await res.json() const emoji = Object.keys(values).reduce((res, groupId) => {
const emoji = Object.keys(values).reduce((res, groupId) => { res[groupId] = values[groupId].map(e => ({
res[groupId] = values[groupId].map(e => ({ displayText: e.slug,
displayText: e.slug, imageUrl: false,
imageUrl: false, replacement: e.emoji
replacement: e.emoji }))
})) return res
return res }, {})
}, {}) commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) })
commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) })
} else {
throw (res)
}
} catch (e) { } catch (e) {
console.warn("Can't load static emoji") console.warn("Can't load static emoji")
console.warn(e) console.warn(e)

View File

@ -8138,11 +8138,6 @@ unicode-canonical-property-names-ecmascript@^2.0.0:
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
integrity sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ== integrity sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==
unicode-emoji-json@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/unicode-emoji-json/-/unicode-emoji-json-0.3.0.tgz#965e097ef8a367081c5036f81873015a95a5c1ad"
integrity sha512-yImheILedqhZtVEEenRELu9AnX347ZTA3bVMWAU5WMUv7pdU2hcfpwo2mKN8Rns9uHLmOZP90/4B4SPS5aF/iw==
unicode-match-property-ecmascript@^2.0.0: unicode-match-property-ecmascript@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3" resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3"