chore(extension): upgrade gulp (#662)

* Update upath

* Upgrade gulp

* Fix core-js

* stash

* prettier
This commit is contained in:
Nathan Bierema 2020-10-31 07:51:20 -05:00 committed by GitHub
parent e1bd517519
commit 9cf69bcc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1216 additions and 372 deletions

View File

@ -1,4 +1,5 @@
{ {
"root": true,
"extends": "eslint-config-airbnb", "extends": "eslint-config-airbnb",
"globals": { "globals": {
"chrome": true, "chrome": true,

View File

@ -18,7 +18,7 @@ function copy(dest) {
/* /*
* common tasks * common tasks
*/ */
gulp.task('replace-webpack-code', () => { gulp.task('replace-webpack-code', (done) => {
const replaceTasks = [ const replaceTasks = [
{ {
from: './webpack/replace/JsonpMainTemplate.runtime.js', from: './webpack/replace/JsonpMainTemplate.runtime.js',
@ -32,6 +32,7 @@ gulp.task('replace-webpack-code', () => {
replaceTasks.forEach((task) => replaceTasks.forEach((task) =>
fs.writeFileSync(task.to, fs.readFileSync(task.from)) fs.writeFileSync(task.to, fs.readFileSync(task.from))
); );
done();
}); });
/* /*
@ -48,7 +49,7 @@ gulp.task('webpack:dev', (callback) => {
callback(); callback();
}); });
gulp.task('views:dev', () => { gulp.task('views:dev', (done) => {
gulp gulp
.src('./src/browser/views/*.pug') .src('./src/browser/views/*.pug')
.pipe( .pipe(
@ -57,14 +58,16 @@ gulp.task('views:dev', () => {
}) })
) )
.pipe(gulp.dest('./dev')); .pipe(gulp.dest('./dev'));
done();
}); });
gulp.task('copy:dev', () => { gulp.task('copy:dev', (done) => {
gulp gulp
.src('./src/browser/extension/manifest.json') .src('./src/browser/extension/manifest.json')
.pipe(rename('manifest.json')) .pipe(rename('manifest.json'))
.pipe(gulp.dest('./dev')); .pipe(gulp.dest('./dev'));
copy('./dev'); copy('./dev');
done();
}); });
/* /*
@ -95,7 +98,7 @@ gulp.task('webpack:build:extension', (callback) => {
}); });
}); });
gulp.task('views:build:extension', () => { gulp.task('views:build:extension', (done) => {
gulp gulp
.src(['./src/browser/views/*.pug']) .src(['./src/browser/views/*.pug'])
.pipe( .pipe(
@ -104,47 +107,36 @@ gulp.task('views:build:extension', () => {
}) })
) )
.pipe(gulp.dest('./build/extension')); .pipe(gulp.dest('./build/extension'));
done();
}); });
gulp.task('copy:build:extension', () => { gulp.task('copy:build:extension', (done) => {
gulp gulp
.src('./src/browser/extension/manifest.json') .src('./src/browser/extension/manifest.json')
.pipe(rename('manifest.json')) .pipe(rename('manifest.json'))
.pipe(gulp.dest('./build/extension')); .pipe(gulp.dest('./build/extension'));
copy('./build/extension'); copy('./build/extension');
}); done();
gulp.task('copy:build:firefox', ['build:extension'], () => {
gulp
.src([
'./build/extension/**',
'!./build/extension/js/redux-devtools-extension.js',
])
.pipe(gulp.dest('./build/firefox'))
.on('finish', function () {
gulp
.src('./src/browser/firefox/manifest.json')
.pipe(gulp.dest('./build/firefox'));
});
copy('./build/firefox');
}); });
/* /*
* compress task * compress task
*/ */
gulp.task('compress:extension', () => { gulp.task('compress:extension', (done) => {
gulp gulp
.src('build/extension/**') .src('build/extension/**')
.pipe(zip('extension.zip')) .pipe(zip('extension.zip'))
.pipe(gulp.dest('./build')); .pipe(gulp.dest('./build'));
done();
}); });
gulp.task('compress:firefox', () => { gulp.task('compress:firefox', (done) => {
gulp gulp
.src('build/firefox/**') .src('build/firefox/**')
.pipe(zip('firefox.zip')) .pipe(zip('firefox.zip'))
.pipe(gulp.dest('./build')); .pipe(gulp.dest('./build'));
done();
}); });
/* /*
@ -152,13 +144,13 @@ gulp.task('compress:firefox', () => {
*/ */
gulp.task('views:watch', () => { gulp.task('views:watch', () => {
gulp.watch('./src/browser/views/*.pug', ['views:dev']); gulp.watch('./src/browser/views/*.pug', gulp.series('views:dev'));
}); });
gulp.task('copy:watch', () => { gulp.task('copy:watch', () => {
gulp.watch( gulp.watch(
['./src/browser/extension/manifest.json', './src/assets/**/*'], ['./src/browser/extension/manifest.json', './src/assets/**/*'],
['copy:dev'] gulp.series('copy:dev')
); );
}); });
@ -178,18 +170,42 @@ gulp.task('test:electron', () => {
.on('end', () => crdv.stop()); .on('end', () => crdv.stop());
}); });
gulp.task('default', [ gulp.task(
'replace-webpack-code', 'default',
'webpack:dev', gulp.parallel(
'views:dev', 'replace-webpack-code',
'copy:dev', 'webpack:dev',
'views:watch', 'views:dev',
'copy:watch', 'copy:dev',
]); 'views:watch',
gulp.task('build:extension', [ 'copy:watch'
'replace-webpack-code', )
'webpack:build:extension', );
'views:build:extension', gulp.task(
'copy:build:extension', 'build:extension',
]); gulp.parallel(
gulp.task('build:firefox', ['copy:build:firefox']); 'replace-webpack-code',
'webpack:build:extension',
'views:build:extension',
'copy:build:extension'
)
);
gulp.task(
'copy:build:firefox',
gulp.series('build:extension', (done) => {
gulp
.src([
'./build/extension/**',
'!./build/extension/js/redux-devtools-extension.js',
])
.pipe(gulp.dest('./build/firefox'))
.on('finish', function () {
gulp
.src('./src/browser/firefox/manifest.json')
.pipe(gulp.dest('./build/firefox'));
});
copy('./build/firefox');
done();
})
);
gulp.task('build:firefox', gulp.series('copy:build:firefox'));

View File

@ -53,7 +53,7 @@
"eslint-plugin-react": "^3.2.3", "eslint-plugin-react": "^3.2.3",
"expect": "^1.20.1", "expect": "^1.20.1",
"gitbook-cli": "^2.3.0", "gitbook-cli": "^2.3.0",
"gulp": "^3.9.1", "gulp": "^4.0.2",
"gulp-mocha": "^3.0.1", "gulp-mocha": "^3.0.1",
"gulp-pug": "^3.1.0", "gulp-pug": "^3.1.0",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",

View File

@ -31,8 +31,9 @@ export function isFiltered(action, localFilter) {
if ( if (
noFiltersApplied(localFilter) || noFiltersApplied(localFilter) ||
(typeof action !== 'string' && typeof action.type.match !== 'function') (typeof action !== 'string' && typeof action.type.match !== 'function')
) ) {
return false; return false;
}
const { whitelist, blacklist } = localFilter || window.devToolsOptions || {}; const { whitelist, blacklist } = localFilter || window.devToolsOptions || {};
const actionType = action.type || action; const actionType = action.type || action;
@ -67,9 +68,9 @@ export function filterState(
nextActionId, nextActionId,
predicate predicate
) { ) {
if (type === 'ACTION') if (type === 'ACTION') {
return !stateSanitizer ? state : stateSanitizer(state, nextActionId - 1); return !stateSanitizer ? state : stateSanitizer(state, nextActionId - 1);
else if (type !== 'STATE') return state; } else if (type !== 'STATE') return state;
if (predicate || !noFiltersApplied(localFilter)) { if (predicate || !noFiltersApplied(localFilter)) {
const filteredStagedActionIds = []; const filteredStagedActionIds = [];
@ -151,8 +152,9 @@ export function startingFrom(
if ( if (
(predicate && !predicate(currState.state, currAction.action)) || (predicate && !predicate(currState.state, currAction.action)) ||
isFiltered(currAction.action, localFilter) isFiltered(currAction.action, localFilter)
) ) {
continue; continue;
}
filteredStagedActionIds.push(key); filteredStagedActionIds.push(key);
if (i < index) continue; if (i < index) continue;
} }

View File

@ -3,9 +3,10 @@ import jsan from 'jsan';
import seralizeImmutable from 'remotedev-serialize/immutable/serialize'; import seralizeImmutable from 'remotedev-serialize/immutable/serialize';
function deprecate(param) { function deprecate(param) {
// eslint-disable-next-line no-console
console.warn( console.warn(
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1` `\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
); // eslint-disable-line );
} }
export default function importState( export default function importState(
@ -34,8 +35,9 @@ export default function importState(
let preloadedState; let preloadedState;
let nextLiftedState = parse(state); let nextLiftedState = parse(state);
if (nextLiftedState.payload) { if (nextLiftedState.payload) {
if (nextLiftedState.preloadedState) if (nextLiftedState.preloadedState) {
preloadedState = parse(nextLiftedState.preloadedState); preloadedState = parse(nextLiftedState.preloadedState);
}
nextLiftedState = parse(nextLiftedState.payload); nextLiftedState = parse(nextLiftedState.payload);
} }
if (deserializeState) { if (deserializeState) {

View File

@ -21,8 +21,9 @@ function tryCatchStringify(obj) {
return JSON.stringify(obj); return JSON.stringify(obj);
} catch (err) { } catch (err) {
/* eslint-disable no-console */ /* eslint-disable no-console */
if (process.env.NODE_ENV !== 'production') if (process.env.NODE_ENV !== 'production') {
console.log('Failed to stringify', err); console.log('Failed to stringify', err);
}
/* eslint-enable no-console */ /* eslint-enable no-console */
return jsan.stringify(obj, windowReplacer, null, { return jsan.stringify(obj, windowReplacer, null, {
circular: '[CIRCULAR]', circular: '[CIRCULAR]',
@ -71,8 +72,9 @@ export function getSeralizeParameter(config, param) {
: immutableSerializer.options, : immutableSerializer.options,
}; };
} }
if (!serialize.replacer && !serialize.reviver) if (!serialize.replacer && !serialize.reviver) {
return { options: serialize.options }; return { options: serialize.options };
}
return { return {
replacer: serialize.replacer, replacer: serialize.replacer,
reviver: serialize.reviver, reviver: serialize.reviver,
@ -82,9 +84,10 @@ export function getSeralizeParameter(config, param) {
const value = config[param]; const value = config[param];
if (typeof value === 'undefined') return undefined; if (typeof value === 'undefined') return undefined;
// eslint-disable-next-line no-console
console.warn( console.warn(
`\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1` `\`${param}\` parameter for Redux DevTools Extension is deprecated. Use \`serialize\` parameter instead: https://github.com/zalmoxisus/redux-devtools-extension/releases/tag/v2.12.1`
); // eslint-disable-line );
if (typeof serializeState === 'boolean') return { options: value }; if (typeof serializeState === 'boolean') return { options: value };
if (typeof serializeState === 'function') return { replacer: value }; if (typeof serializeState === 'function') return { replacer: value };
@ -133,8 +136,9 @@ function getStackTrace(config, toExcludeFromTrace) {
function amendActionType(action, config, toExcludeFromTrace) { function amendActionType(action, config, toExcludeFromTrace) {
let timestamp = Date.now(); let timestamp = Date.now();
let stack = getStackTrace(config, toExcludeFromTrace); let stack = getStackTrace(config, toExcludeFromTrace);
if (typeof action === 'string') if (typeof action === 'string') {
return { action: { type: action }, timestamp, stack }; return { action: { type: action }, timestamp, stack };
}
if (!action.type) return { action: { type: 'update' }, timestamp, stack }; if (!action.type) return { action: { type: 'update' }, timestamp, stack };
if (action.action) return stack ? { stack, ...action } : action; if (action.action) return stack ? { stack, ...action } : action;
return { action, timestamp, stack }; return { action, timestamp, stack };
@ -187,17 +191,19 @@ export function sendMessage(action, state, config, instanceId, name) {
} }
function handleMessages(event) { function handleMessages(event) {
if (process.env.BABEL_ENV !== 'test' && (!event || event.source !== window)) if (process.env.BABEL_ENV !== 'test' && (!event || event.source !== window)) {
return; return;
}
const message = event.data; const message = event.data;
if (!message || message.source !== '@devtools-extension') return; if (!message || message.source !== '@devtools-extension') return;
Object.keys(listeners).forEach((id) => { Object.keys(listeners).forEach((id) => {
if (message.id && id !== message.id) return; if (message.id && id !== message.id) return;
if (typeof listeners[id] === 'function') listeners[id](message); if (typeof listeners[id] === 'function') listeners[id](message);
else else {
listeners[id].forEach((fn) => { listeners[id].forEach((fn) => {
fn(message); fn(message);
}); });
}
}); });
} }
@ -229,9 +235,10 @@ export function connect(preConfig) {
const config = preConfig || {}; const config = preConfig || {};
const id = generateId(config.instanceId); const id = generateId(config.instanceId);
if (!config.instanceId) config.instanceId = id; if (!config.instanceId) config.instanceId = id;
if (!config.name) if (!config.name) {
config.name = config.name =
document.title && id === 1 ? document.title : `Instance ${id}`; document.title && id === 1 ? document.title : `Instance ${id}`;
}
if (config.serialize) config.serialize = getSeralizeParameter(config); if (config.serialize) config.serialize = getSeralizeParameter(config);
const actionCreators = config.actionCreators || {}; const actionCreators = config.actionCreators || {};
const latency = config.latency; const latency = config.latency;
@ -306,8 +313,9 @@ export function connect(preConfig) {
timestamp: Date.now(), timestamp: Date.now(),
}; };
} }
} else if (config.actionSanitizer) } else if (config.actionSanitizer) {
amendedAction = config.actionSanitizer(action); amendedAction = config.actionSanitizer(action);
}
amendedAction = amendActionType(amendedAction, config, send); amendedAction = amendActionType(amendedAction, config, send);
if (latency) { if (latency) {
delayedActions.push(amendedAction); delayedActions.push(amendedAction);

View File

@ -34,8 +34,9 @@ function catchErrors(e) {
if ( if (
(window.devToolsOptions && !window.devToolsOptions.shouldCatchErrors) || (window.devToolsOptions && !window.devToolsOptions.shouldCatchErrors) ||
e.timeStamp - lastTime < nextErrorTimeout() e.timeStamp - lastTime < nextErrorTimeout()
) ) {
return; return;
}
lastTime = e.timeStamp; lastTime = e.timeStamp;
nextErrorTimeout(true); nextErrorTimeout(true);
postError(e.message); postError(e.message);

View File

@ -31,8 +31,9 @@ export default class Monitor {
isPaused = () => { isPaused = () => {
if (this.paused) { if (this.paused) {
if (this.lastAction !== 'BLOCKED') { if (this.lastAction !== 'BLOCKED') {
if (!window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__) if (!window.__REDUX_DEVTOOLS_EXTENSION_LOCKED__) {
this.lastAction = 'BLOCKED'; this.lastAction = 'BLOCKED';
}
return false; return false;
} }
return true; return true;

View File

@ -9,8 +9,9 @@ export default function openDevToolsWindow(position) {
lastPosition = position; lastPosition = position;
} else { } else {
let params = { focused: true }; let params = { focused: true };
if (lastPosition !== position && position !== 'devtools-panel') if (lastPosition !== position && position !== 'devtools-panel') {
params = { ...params, ...customOptions }; params = { ...params, ...customOptions };
}
chrome.windows.update(windows[position], params, () => { chrome.windows.update(windows[position], params, () => {
lastPosition = null; lastPosition = null;
if (chrome.runtime.lastError) callback(); if (chrome.runtime.lastError) callback();

View File

@ -93,8 +93,9 @@ function tryCatch(fn, args) {
} }
handleDisconnect(); handleDisconnect();
/* eslint-disable no-console */ /* eslint-disable no-console */
if (process.env.NODE_ENV !== 'production') if (process.env.NODE_ENV !== 'production') {
console.error('Failed to send message', err); console.error('Failed to send message', err);
}
/* eslint-enable no-console */ /* eslint-enable no-console */
} }
} }
@ -112,8 +113,9 @@ function send(message) {
// Resend messages from the page to the background script // Resend messages from the page to the background script
function handleMessages(event) { function handleMessages(event) {
if (!isAllowed()) return; if (!isAllowed()) return;
if (!event || event.source !== window || typeof event.data !== 'object') if (!event || event.source !== window || typeof event.data !== 'object') {
return; return;
}
const message = event.data; const message = event.data;
if (message.source !== pageSource) return; if (message.source !== pageSource) return;
if (message.type === 'DISCONNECT') { if (message.type === 'DISCONNECT') {

View File

@ -164,8 +164,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
isFiltered(action, localFilter) || isFiltered(action, localFilter) ||
(predicate && (predicate &&
!predicate(computedStates[computedStates.length - 1].state, action)) !predicate(computedStates[computedStates.length - 1].state, action))
) ) {
return; return;
}
const state = const state =
liftedState.computedStates[liftedState.computedStates.length - 1].state; liftedState.computedStates[liftedState.computedStates.length - 1].state;
relay( relay(
@ -233,8 +234,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
if ( if (
!features.jump && !features.jump &&
(type === 'JUMP_TO_STATE' || type === 'JUMP_TO_ACTION') (type === 'JUMP_TO_STATE' || type === 'JUMP_TO_ACTION')
) ) {
return; return;
}
if (!features.skip && type === 'TOGGLE_ACTION') return; if (!features.skip && type === 'TOGGLE_ACTION') return;
if (!features.reorder && type === 'REORDER_ACTION') return; if (!features.reorder && type === 'REORDER_ACTION') return;
if (!features.import && type === 'IMPORT_STATE') return; if (!features.import && type === 'IMPORT_STATE') return;
@ -297,8 +299,13 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
const filteredActionIds = []; // simple circular buffer of non-excluded actions with fixed maxAge-1 length const filteredActionIds = []; // simple circular buffer of non-excluded actions with fixed maxAge-1 length
const getMaxAge = (liftedAction, liftedState) => { const getMaxAge = (liftedAction, liftedState) => {
let m = (config && config.maxAge) || window.devToolsOptions.maxAge || 50; let m = (config && config.maxAge) || window.devToolsOptions.maxAge || 50;
if (!liftedAction || noFiltersApplied(localFilter) || !liftedAction.action) if (
!liftedAction ||
noFiltersApplied(localFilter) ||
!liftedAction.action
) {
return m; return m;
}
if (!maxAge || maxAge < m) maxAge = m; // it can be modified in process on options page if (!maxAge || maxAge < m) maxAge = m; // it can be modified in process on options page
if (isFiltered(liftedAction.action, localFilter)) { if (isFiltered(liftedAction.action, localFilter)) {
// TODO: check also predicate && !predicate(state, action) with current state // TODO: check also predicate && !predicate(state, action) with current state
@ -347,8 +354,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
relayAction(); relayAction();
return; return;
} }
if (monitor.isPaused() || monitor.isLocked() || monitor.isTimeTraveling()) if (monitor.isPaused() || monitor.isLocked() || monitor.isTimeTraveling()) {
return; return;
}
const liftedState = store.liftedStore.getState(); const liftedState = store.liftedStore.getState();
if ( if (
errorOccurred && errorOccurred &&
@ -361,8 +369,9 @@ const __REDUX_DEVTOOLS_EXTENSION__ = function (
const enhance = () => (next) => { const enhance = () => (next) => {
return (reducer_, initialState_, enhancer_) => { return (reducer_, initialState_, enhancer_) => {
if (!isAllowed(window.devToolsOptions)) if (!isAllowed(window.devToolsOptions)) {
return next(reducer_, initialState_, enhancer_); return next(reducer_, initialState_, enhancer_);
}
store = stores[instanceId] = configureStore(next, monitor.reducer, { store = stores[instanceId] = configureStore(next, monitor.reducer, {
...config, ...config,

View File

@ -16,8 +16,9 @@ getPreloadedState(position, (state) => {
chrome.runtime.getBackgroundPage(({ store }) => { chrome.runtime.getBackgroundPage(({ store }) => {
const localStore = configureStore(store, position, preloadedState); const localStore = configureStore(store, position, preloadedState);
let name = 'monitor'; let name = 'monitor';
if (chrome && chrome.devtools && chrome.devtools.inspectedWindow) if (chrome && chrome.devtools && chrome.devtools.inspectedWindow) {
name += chrome.devtools.inspectedWindow.tabId; name += chrome.devtools.inspectedWindow.tabId;
}
const bg = chrome.runtime.connect({ name }); const bg = chrome.runtime.connect({ name });
const update = (action) => { const update = (action) => {
localStore.dispatch(action || { type: UPDATE_STATE }); localStore.dispatch(action || { type: UPDATE_STATE });

File diff suppressed because it is too large Load Diff