Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './lib/log-suppression';
import GUI from './containers/gui.jsx';
import AppStateHOC from './lib/app-state-hoc.jsx';
import GuiReducer, {guiInitialState, guiMiddleware, initEmbedded, initFullScreen, initPlayer} from './reducers/gui';
Expand Down
53 changes: 53 additions & 0 deletions src/lib/log-suppression.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Suppress certain console warnings that are known upstream issues or intentional.
*/

const ignoredWarnings = [
'Object freezing is not supported by Opal',
'Canvas2D: Multiple readback operations using getImageData are faster ' +
'with the willReadFrequently attribute set to true',
'Support for defaultProps will be removed from function components',
'React does not recognize the colorMode prop on a DOM element',
'React does not recognize the showNewFeatureCallouts prop on a DOM element',
'React does not recognize the localesOnly prop on a DOM element',
'React does not recognize the setTheme prop on a DOM element',
'React does not recognize the',
'The prop `projectId` is marked as required in `StageHeaderComponent`, but its value is `null`',
'Invalid prop `projectId` of type `string` supplied to `StageHeaderComponent`, expected `number`',
'The prop projectId is marked as required in StageHeaderComponent, but its value is null',
'Invalid prop projectId of type string supplied to StageHeaderComponent, expected number',
'componentWillMount has been renamed',
'componentWillReceiveProps has been renamed',
'findDOMNode is deprecated',
'The AudioContext was not allowed to start',
'apple-mobile-web-app-capable',
'GenerateSW has been called multiple times'
];

/**
* Check if a message should be ignored.
* @param {string} message The message to check.
* @param {Array} args Additional arguments.
* @returns {boolean} True if the message should be ignored.
*/
const shouldIgnore = (message, ...args) => {
const allStrings = [message, ...args].filter(arg => typeof arg === 'string');
return allStrings.some(str =>
ignoredWarnings.some(ignored => str.includes(ignored))
);
};

/* eslint-disable no-console */
const originalWarn = console.warn;
const originalError = console.error;

console.warn = function (message, ...args) {
if (shouldIgnore(message, ...args)) return;
originalWarn.apply(console, [message, ...args]);
};

console.error = function (message, ...args) {
if (shouldIgnore(message, ...args)) return;
originalError.apply(console, [message, ...args]);
};
/* eslint-enable no-console */
2 changes: 2 additions & 0 deletions src/playground/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<% } %>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="google" value="notranslate">
<%
const originTrials = htmlWebpackPlugin.options.originTrials;
Expand Down
2 changes: 2 additions & 0 deletions src/playground/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'core-js/fn/array/includes';
import 'core-js/fn/promise/finally';
import 'intl'; // For Safari 9

import '../lib/log-suppression';

import React from 'react';
import ReactDOM from 'react-dom';

Expand Down
1 change: 1 addition & 0 deletions src/playground/player.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '../lib/log-suppression';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down
Loading