-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove imports based on isomorphic logic - 3 (#29071)
- Loading branch information
Showing
26 changed files
with
221 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import '../lib/rocketchat'; | ||
import './lib'; | ||
import './emojione-sprites.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { emoji } from '../../emoji/client'; | ||
import { getEmojiConfig, isSetNotNull } from '../lib/rocketchat'; | ||
import { getUserPreference } from '../../utils/client'; | ||
|
||
const config = getEmojiConfig(); | ||
|
||
emoji.packages.emojione = config.emojione as any; | ||
if (emoji.packages.emojione) { | ||
emoji.packages.emojione.sprites = config.sprites; | ||
emoji.packages.emojione.emojisByCategory = config.emojisByCategory; | ||
emoji.packages.emojione.emojiCategories = config.emojiCategories; | ||
emoji.packages.emojione.toneList = config.toneList; | ||
|
||
emoji.packages.emojione.render = config.render; | ||
emoji.packages.emojione.renderPicker = config.renderPicker; | ||
|
||
// RocketChat.emoji.list is the collection of emojis from all emoji packages | ||
for (const key in config.emojione.emojioneList) { | ||
if (config.emojione.emojioneList.hasOwnProperty(key)) { | ||
const currentEmoji = config.emojione.emojioneList[key]; | ||
// @ts-expect-error - emojione types | ||
currentEmoji.emojiPackage = 'emojione'; | ||
emoji.list[key] = currentEmoji; | ||
|
||
// @ts-expect-error - emojione types | ||
if (currentEmoji.shortnames) { | ||
// @ts-expect-error - emojione types | ||
currentEmoji.shortnames.forEach((shortname: string) => { | ||
emoji.list[shortname] = currentEmoji; | ||
}); | ||
} | ||
} | ||
} | ||
|
||
// Additional settings -- ascii emojis | ||
Meteor.startup(function () { | ||
Tracker.autorun(async function () { | ||
if ((await isSetNotNull(() => emoji.packages.emojione)) && emoji.packages.emojione) { | ||
if (await isSetNotNull(() => getUserPreference(Meteor.userId() as string, 'convertAsciiEmoji'))) { | ||
emoji.packages.emojione.ascii = await getUserPreference(Meteor.userId() as string, 'convertAsciiEmoji'); | ||
} else { | ||
emoji.packages.emojione.ascii = true; | ||
} | ||
} | ||
}); | ||
}); | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import emojione from 'emojione'; | ||
|
||
export function emojioneRender(message: string): string { | ||
return emojione.toImage(message); | ||
} | ||
|
||
export function emojioneRenderFromShort(message: string): string { | ||
return emojione.shortnameToImage(message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import '../lib/rocketchat'; | ||
import './lib'; | ||
import './callbacks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { emoji } from '../../emoji/server'; | ||
import { getEmojiConfig, isSetNotNull } from '../lib/rocketchat'; | ||
import { getUserPreference } from '../../utils/server'; | ||
|
||
const config = getEmojiConfig(); | ||
|
||
emoji.packages.emojione = config.emojione as any; | ||
if (emoji.packages.emojione) { | ||
emoji.packages.emojione.sprites = config.sprites; | ||
emoji.packages.emojione.emojisByCategory = config.emojisByCategory; | ||
emoji.packages.emojione.emojiCategories = config.emojiCategories; | ||
emoji.packages.emojione.toneList = config.toneList; | ||
|
||
emoji.packages.emojione.render = config.render; | ||
emoji.packages.emojione.renderPicker = config.renderPicker; | ||
|
||
// RocketChat.emoji.list is the collection of emojis from all emoji packages | ||
for (const key in config.emojione.emojioneList) { | ||
if (config.emojione.emojioneList.hasOwnProperty(key)) { | ||
const currentEmoji = config.emojione.emojioneList[key]; | ||
// @ts-expect-error - emojione types | ||
currentEmoji.emojiPackage = 'emojione'; | ||
emoji.list[key] = currentEmoji; | ||
|
||
// @ts-expect-error - emojione types | ||
if (currentEmoji.shortnames) { | ||
// @ts-expect-error - emojione types | ||
currentEmoji.shortnames.forEach((shortname: string) => { | ||
emoji.list[shortname] = currentEmoji; | ||
}); | ||
} | ||
} | ||
} | ||
|
||
// Additional settings -- ascii emojis | ||
Meteor.startup(async function () { | ||
if ((await isSetNotNull(() => emoji.packages.emojione)) && emoji.packages.emojione) { | ||
if (await isSetNotNull(() => getUserPreference(Meteor.userId() as string, 'convertAsciiEmoji'))) { | ||
emoji.packages.emojione.ascii = await getUserPreference(Meteor.userId() as string, 'convertAsciiEmoji'); | ||
} else { | ||
emoji.packages.emojione.ascii = true; | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { EmojiPicker } from './lib/EmojiPicker'; | ||
export { emoji } from '../lib/rocketchat'; | ||
export { emoji } from './lib'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export type EmojiPackage = { | ||
packages: { | ||
base: { | ||
emojiCategories: Array<{ key: string; i18n: string }>; | ||
categoryIndex: number; | ||
emojisByCategory: Record<string, unknown>; | ||
toneList: Record<string, unknown>; | ||
render: (message: string) => string; | ||
renderPicker: (emojiToRender: string) => void; | ||
ascii?: boolean; | ||
}; | ||
emojione?: { | ||
sprites: boolean; | ||
emojisByCategory: Record<string, unknown>; | ||
emojiCategories: Array<{ key: string; i18n: string }>; | ||
toneList: Record<string, unknown>; | ||
render: (message: string) => string; | ||
renderPicker: (emojiToRender: string) => void; | ||
ascii?: boolean; | ||
}; | ||
}; | ||
list: Record< | ||
string, | ||
{ emojiPackage?: keyof NonNullable<EmojiPackage['packages']> } & { | ||
unicode: string[]; | ||
fname: string; | ||
uc: string; | ||
isCanonical: boolean; | ||
} | ||
>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { emoji } from '../lib/rocketchat'; | ||
export { emoji } from './lib'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { EmojiPackage } from '../lib/rocketchat'; | ||
|
||
export const emoji: EmojiPackage = { | ||
packages: { | ||
base: { | ||
emojiCategories: [{ key: 'recent', i18n: 'Frequently_Used' }], | ||
categoryIndex: 0, | ||
emojisByCategory: { | ||
recent: [], | ||
}, | ||
toneList: {}, | ||
render: (message: string) => message, | ||
renderPicker(emojiToRender) { | ||
if (!emoji.list[emojiToRender]) { | ||
return; | ||
} | ||
const correctPackage = emoji.list[emojiToRender].emojiPackage; | ||
if (!correctPackage) { | ||
return; | ||
} | ||
|
||
return emoji.packages[correctPackage]?.renderPicker(emojiToRender); | ||
}, | ||
}, | ||
}, | ||
/** @type {Record<string, unknown>} */ | ||
list: {}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { OAuth } from 'meteor/oauth'; | ||
|
||
const { _redirectUri } = OAuth; | ||
|
||
OAuth._redirectUri = (serviceName: string, config: any, params: unknown, absoluteUrlOptions: unknown): string => { | ||
const ret = _redirectUri(serviceName, config, params, absoluteUrlOptions); | ||
|
||
// DEPRECATED: Remove in v5.0.0 | ||
// Meteor 2.3 removed ?close from redirect uri so we need to add it back to not break old oauth clients | ||
// https://github.com/meteor/meteor/commit/b5b7306bedc3e8eb241e64efb1e281925aa75dd3#diff-59244f4e0176cb1beed2e287924e97dc7ae2c0cc51494ce121a85d8937d116a5L11 | ||
if (!config?.loginStyle && !ret.includes('close')) { | ||
console.warn( | ||
`Automatically added ?close to 'redirect_uri' for ${serviceName}, this behavior will be removed in v5.0.0.\n` + | ||
"Please update your OAuth config to accept both with and without ?close as the 'redirect_uri'.", | ||
); | ||
return `${ret + (ret.includes('?') ? '&' : '?')}close`; | ||
} | ||
|
||
return ret; | ||
}; |
Oops, something went wrong.