From 6fab7b9e3ffb4a9bce2788174ef0e9e6eef7b2c5 Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Tue, 20 Sep 2022 22:03:31 -0400 Subject: [PATCH] Use import() for emoji.json --- build/update-emoji.js | 2 +- package.json | 1 - src/modules/instance.js | 27 ++++++++++++--------------- yarn.lock | 5 ----- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/build/update-emoji.js b/build/update-emoji.js index fba7706e..9f4b4e67 100644 --- a/build/update-emoji.js +++ b/build/update-emoji.js @@ -1,7 +1,7 @@ module.exports = { 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') Object.keys(emojis) diff --git a/package.json b/package.json index b0c06a61..260df573 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,6 @@ "stylelint": "13.13.1", "stylelint-config-standard": "20.0.0", "stylelint-rscss": "0.4.0", - "unicode-emoji-json": "^0.3.0", "vue-loader": "17.0.0", "vue-style-loader": "4.1.3", "webpack": "5.74.0", diff --git a/src/modules/instance.js b/src/modules/instance.js index 9be35d88..9f326d26 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -135,6 +135,7 @@ const loadAnnotations = (lang) => { return import( `@kazvmoe-infra/unicode-emoji-json/annotations/${langCodeToCldrName(lang)}.json` ) + .then(k => k.default) } const injectAnnotations = (emoji, annotations) => { @@ -233,21 +234,17 @@ const instance = { }, async getStaticEmoji ({ commit }) { try { - const res = await window.fetch('/static/emoji.json') - if (res.ok) { - const values = await res.json() - const emoji = Object.keys(values).reduce((res, groupId) => { - res[groupId] = values[groupId].map(e => ({ - displayText: e.slug, - imageUrl: false, - replacement: e.emoji - })) - return res - }, {}) - commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) }) - } else { - throw (res) - } + const values = (await import('../../static/emoji.json')).default + + const emoji = Object.keys(values).reduce((res, groupId) => { + res[groupId] = values[groupId].map(e => ({ + displayText: e.slug, + imageUrl: false, + replacement: e.emoji + })) + return res + }, {}) + commit('setInstanceOption', { name: 'emoji', value: injectRegionalIndicators(emoji) }) } catch (e) { console.warn("Can't load static emoji") console.warn(e) diff --git a/yarn.lock b/yarn.lock index f1cfc7f3..a22ab65d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" 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: version "2.0.0" resolved "https://registry.yarnpkg.com/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz#54fd16e0ecb167cf04cf1f756bdcc92eba7976c3"