mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 13:28:07 +01:00
[Glitch] Dont use CommonJS (require
, module.exports
) anywhere
Port 955179fc55
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
c81d1b0d38
commit
108720d7b0
15 changed files with 49 additions and 37 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
import 'packs/public-path';
|
||||
|
||||
const { delegate } = require('@rails/ujs');
|
||||
import { delegate } from '@rails/ujs';
|
||||
|
||||
const getProfileAvatarAnimationHandler = (swapTo) => {
|
||||
//animate avatar gifs on the profile page when moused over
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import 'packs/public-path';
|
||||
import escapeTextContentForBrowser from 'escape-html';
|
||||
|
||||
const { delegate } = require('@rails/ujs');
|
||||
import { delegate } from '@rails/ujs';
|
||||
|
||||
import emojify from '../mastodon/features/emoji/emoji';
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable import/no-commonjs --
|
||||
We need to use CommonJS here due to preval */
|
||||
// @preval
|
||||
// http://www.unicode.org/Public/emoji/5.0/emoji-test.txt
|
||||
// This file contains the compressed version of the emoji data from
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// The output of this module is designed to mimic emoji-mart's
|
||||
// "data" object, such that we can use it for a light version of emoji-mart's
|
||||
// emojiIndex.search functionality.
|
||||
const { unicodeToUnifiedName } = require('./unicode_to_unified_name');
|
||||
const [ shortCodesToEmojiData, skins, categories, short_names ] = require('./emoji_compressed');
|
||||
import { unicodeToUnifiedName } from './unicode_to_unified_name';
|
||||
import emojiCompressed from './emoji_compressed';
|
||||
|
||||
const [ shortCodesToEmojiData, skins, categories, short_names ] = emojiCompressed;
|
||||
|
||||
const emojis = {};
|
||||
|
||||
|
@ -33,7 +35,7 @@ Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
|||
};
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
export {
|
||||
emojis,
|
||||
skins,
|
||||
categories,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// This code is largely borrowed from:
|
||||
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/emoji-index.js
|
||||
|
||||
import data from './emoji_mart_data_light';
|
||||
import * as data from './emoji_mart_data_light';
|
||||
import { getData, getSanitizedData, uniq, intersect } from './emoji_utils';
|
||||
|
||||
let originalPool = {};
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
// (i.e. the svg filename) and a shortCode intended to be shown
|
||||
// as a "title" attribute in an HTML element (aka tooltip).
|
||||
|
||||
import emojiCompressed from './emoji_compressed';
|
||||
|
||||
import { unicodeToFilename } from './unicode_to_filename';
|
||||
|
||||
const [
|
||||
shortCodesToEmojiData,
|
||||
skins, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
categories, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
short_names, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
_skins,
|
||||
_categories,
|
||||
_short_names,
|
||||
emojisWithoutShortCodes,
|
||||
] = require('./emoji_compressed');
|
||||
const { unicodeToFilename } = require('./unicode_to_filename');
|
||||
] = emojiCompressed;
|
||||
|
||||
// decompress
|
||||
const unicodeMapping = {};
|
||||
|
@ -32,4 +35,4 @@ Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
|
|||
});
|
||||
emojisWithoutShortCodes.forEach(emojiMapData => processEmojiMapData(emojiMapData));
|
||||
|
||||
module.exports = unicodeMapping;
|
||||
export default unicodeMapping;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// This code is largely borrowed from:
|
||||
// https://github.com/missive/emoji-mart/blob/5f2ffcc/src/utils/index.js
|
||||
|
||||
import data from './emoji_mart_data_light';
|
||||
import * as data from './emoji_mart_data_light';
|
||||
|
||||
const buildSearch = (data) => {
|
||||
const search = [];
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/* eslint-disable import/no-commonjs --
|
||||
We need to use CommonJS here as its imported into a preval file (`emoji_compressed.js`) */
|
||||
|
||||
// taken from:
|
||||
// https://github.com/twitter/twemoji/blob/47732c7/twemoji-generator.js#L848-L866
|
||||
exports.unicodeToFilename = (str) => {
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/* eslint-disable import/no-commonjs --
|
||||
We need to use CommonJS here as its imported into a preval file (`emoji_compressed.js`) */
|
||||
|
||||
function padLeft(str, num) {
|
||||
while (str.length < num) {
|
||||
str = '0' + str;
|
||||
|
|
|
@ -6,7 +6,7 @@ import { store } from 'flavours/glitch/store/configureStore';
|
|||
import { me } from 'flavours/glitch/initial_state';
|
||||
import ready from 'flavours/glitch/ready';
|
||||
|
||||
const perf = require('flavours/glitch/performance');
|
||||
import * as perf from 'flavours/glitch/performance';
|
||||
|
||||
/**
|
||||
* @returns {Promise<void>}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import 'packs/public-path';
|
||||
import ready from 'flavours/glitch/ready';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
ready(() => {
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
|
||||
[].forEach.call(document.querySelectorAll('[data-admin-component]'), element => {
|
||||
const componentName = element.getAttribute('data-admin-component');
|
||||
const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props'));
|
||||
|
|
|
@ -5,6 +5,14 @@ import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
|||
import axios from 'axios';
|
||||
import { throttle } from 'lodash';
|
||||
import { defineMessages } from 'react-intl';
|
||||
import * as IntlMessageFormat from 'intl-messageformat';
|
||||
import { timeAgoString } from 'flavours/glitch/components/relative_timestamp';
|
||||
import { delegate } from '@rails/ujs';
|
||||
import emojify from 'flavours/glitch/features/emoji/emoji';
|
||||
import { getLocale } from 'locales';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
const messages = defineMessages({
|
||||
usernameTaken: { id: 'username.taken', defaultMessage: 'That username is taken. Try another' },
|
||||
|
@ -13,15 +21,7 @@ const messages = defineMessages({
|
|||
});
|
||||
|
||||
function main() {
|
||||
const IntlMessageFormat = require('intl-messageformat').default;
|
||||
const { timeAgoString } = require('flavours/glitch/components/relative_timestamp');
|
||||
const { delegate } = require('@rails/ujs');
|
||||
const emojify = require('flavours/glitch/features/emoji/emoji').default;
|
||||
const { getLocale } = require('locales');
|
||||
const { localeData } = getLocale();
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const { createBrowserHistory } = require('history');
|
||||
|
||||
const scrollToDetailedStatus = () => {
|
||||
const history = createBrowserHistory();
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import 'packs/public-path';
|
||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
||||
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
||||
import { delegate } from '@rails/ujs';
|
||||
import 'cocoon-js-vanilla';
|
||||
|
||||
function main() {
|
||||
const { delegate } = require('@rails/ujs');
|
||||
|
||||
const toggleSidebar = () => {
|
||||
const sidebar = document.querySelector('.sidebar ul');
|
||||
const toggleButton = document.querySelector('.sidebar__toggle__icon');
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
import 'packs/public-path';
|
||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
||||
import ComposeContainer from 'flavours/glitch/containers/compose_container';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ready from 'flavours/glitch/ready';
|
||||
|
||||
function loaded() {
|
||||
const ComposeContainer = require('flavours/glitch/containers/compose_container').default;
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const mountNode = document.getElementById('mastodon-compose');
|
||||
|
||||
if (mountNode !== null) {
|
||||
const props = JSON.parse(mountNode.getAttribute('data-props'));
|
||||
if (mountNode) {
|
||||
const attr = mountNode.getAttribute('data-props');
|
||||
if(!attr) return;
|
||||
|
||||
const props = JSON.parse(attr);
|
||||
ReactDOM.render(<ComposeContainer {...props} />, mountNode);
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const ready = require('flavours/glitch/ready').default;
|
||||
ready(loaded);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
// Tools for performance debugging, only enabled in development mode.
|
||||
// Open up Chrome Dev Tools, then Timeline, then User Timing to see output.
|
||||
// Also see config/webpack/loaders/mark.js for the webpack loader marks.
|
||||
//
|
||||
|
||||
let marky;
|
||||
import * as marky from 'marky';
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
|
||||
|
@ -12,8 +11,7 @@ if (process.env.NODE_ENV === 'development') {
|
|||
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1331135
|
||||
performance.setResourceTimingBufferSize(Infinity);
|
||||
}
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
marky = require('marky');
|
||||
|
||||
// allows us to easily do e.g. ReactPerf.printWasted() while debugging
|
||||
//window.ReactPerf = require('react-addons-perf');
|
||||
//window.ReactPerf.start();
|
||||
|
|
Loading…
Reference in a new issue