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