[Glitch] Rework polyfills loading
Port a3a2414f0e
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
main
parent
e22a88b512
commit
526fe33e2f
|
@ -1,5 +1,5 @@
|
||||||
import 'packs/public-path';
|
import 'packs/public-path';
|
||||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
import { loadPolyfills } from 'flavours/glitch/polyfills';
|
||||||
|
|
||||||
loadPolyfills().then(async () => {
|
loadPolyfills().then(async () => {
|
||||||
const { default: main } = await import('flavours/glitch/main');
|
const { default: main } = await import('flavours/glitch/main');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'packs/public-path';
|
import 'packs/public-path';
|
||||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
import { loadPolyfills } from 'flavours/glitch/polyfills';
|
||||||
import ready from 'flavours/glitch/ready';
|
import ready from 'flavours/glitch/ready';
|
||||||
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'packs/public-path';
|
import 'packs/public-path';
|
||||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
import { loadPolyfills } from 'flavours/glitch/polyfills';
|
||||||
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
import loadKeyboardExtensions from 'flavours/glitch/load_keyboard_extensions';
|
||||||
import { delegate } from '@rails/ujs';
|
import { delegate } from '@rails/ujs';
|
||||||
import 'cocoon-js-vanilla';
|
import 'cocoon-js-vanilla';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import 'packs/public-path';
|
import 'packs/public-path';
|
||||||
import loadPolyfills from 'flavours/glitch/load_polyfills';
|
import { loadPolyfills } from 'flavours/glitch/polyfills';
|
||||||
import ComposeContainer from 'flavours/glitch/containers/compose_container';
|
import ComposeContainer from 'flavours/glitch/containers/compose_container';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
|
@ -1,26 +1,16 @@
|
||||||
import 'intl';
|
import 'intl';
|
||||||
import 'intl/locale-data/jsonp/en';
|
import 'intl/locale-data/jsonp/en';
|
||||||
import 'es6-symbol/implement';
|
import 'core-js/features/object/assign';
|
||||||
import assign from 'object-assign';
|
import 'core-js/features/object/values';
|
||||||
import values from 'object.values';
|
import 'core-js/features/symbol';
|
||||||
import { decode as decodeBase64 } from './utils/base64';
|
import 'core-js/features/promise/finally';
|
||||||
import promiseFinally from 'promise.prototype.finally';
|
import { decode as decodeBase64 } from '../utils/base64';
|
||||||
|
|
||||||
if (!Object.assign) {
|
|
||||||
Object.assign = assign;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Object.values) {
|
|
||||||
values.shim();
|
|
||||||
}
|
|
||||||
|
|
||||||
promiseFinally.shim();
|
|
||||||
|
|
||||||
if (!HTMLCanvasElement.prototype.toBlob) {
|
if (!HTMLCanvasElement.prototype.toBlob) {
|
||||||
const BASE64_MARKER = ';base64,';
|
const BASE64_MARKER = ';base64,';
|
||||||
|
|
||||||
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
|
||||||
value(callback, type = 'image/png', quality) {
|
value(callback: BlobCallback, type = 'image/png', quality: any) {
|
||||||
const dataURL = this.toDataURL(type, quality);
|
const dataURL = this.toDataURL(type, quality);
|
||||||
let data;
|
let data;
|
||||||
|
|
|
@ -10,14 +10,14 @@ function importExtraPolyfills() {
|
||||||
return import(/* webpackChunkName: "extra_polyfills" */ './extra_polyfills');
|
return import(/* webpackChunkName: "extra_polyfills" */ './extra_polyfills');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPolyfills() {
|
export function loadPolyfills() {
|
||||||
const needsBasePolyfills = !(
|
const needsBasePolyfills = !(
|
||||||
HTMLCanvasElement.prototype.toBlob &&
|
'toBlob' in HTMLCanvasElement.prototype &&
|
||||||
window.Intl &&
|
'Intl' in window &&
|
||||||
Object.assign &&
|
'assign' in Object &&
|
||||||
Object.values &&
|
'values' in Object &&
|
||||||
window.Symbol &&
|
'Symbol' in window &&
|
||||||
Promise.prototype.finally
|
'finally' in Promise.prototype
|
||||||
);
|
);
|
||||||
|
|
||||||
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
// Latest version of Firefox and Safari do not have IntersectionObserver.
|
||||||
|
@ -36,5 +36,3 @@ function loadPolyfills() {
|
||||||
needsExtraPolyfills && importExtraPolyfills(),
|
needsExtraPolyfills && importExtraPolyfills(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default loadPolyfills;
|
|
Loading…
Reference in New Issue