mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 13:19:34 +08:00
9d995ded67
Summary: Move sync workers and Edgehill token checks to work window Move the task queue and database setup to the work window Move ContactStore background refresh to work window Store the task queue in the database WIP The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually. If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window. This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window ActivitySidebar has a special little store that observes the task queue since it's no longer in the window Move "toggle component regions" / "toggle react remote" to the Developer menu Move sync worker specs, update draft store specs to not rely on TaskQueue at all Test Plan: Run existing tests, all pass Reviewers: dillon, evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1936
93 lines
3 KiB
JavaScript
93 lines
3 KiB
JavaScript
// This is to prevent React from displaying an annoying message about
|
|
// installing their dev tools. The React dev tools put a variable on the
|
|
// global scope. We need to do it here before React loads.
|
|
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {}
|
|
|
|
|
|
function registerRuntimeTranspilers(hotreload) {
|
|
// This sets require.extensions['.coffee'].
|
|
require('coffee-script').register();
|
|
|
|
// This sets require.extensions['.cjsx']
|
|
if (hotreload) {
|
|
// This is custom built to look at window.devMode and enable hot-reloading
|
|
require('../src/cjsx').register();
|
|
} else {
|
|
require('coffee-react/register');
|
|
}
|
|
// This redefines require.extensions['.js'].
|
|
require('../src/6to5').register();
|
|
}
|
|
|
|
window.onload = function() {
|
|
try {
|
|
var startTime = Date.now();
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
// Skip "?loadSettings=".
|
|
var rawLoadSettings = decodeURIComponent(location.search.substr(14));
|
|
var loadSettings;
|
|
try {
|
|
loadSettings = JSON.parse(rawLoadSettings);
|
|
} catch (error) {
|
|
console.error("Failed to parse load settings: " + rawLoadSettings);
|
|
throw error;
|
|
}
|
|
|
|
// Normalize to make sure drive letter case is consistent on Windows
|
|
process.resourcesPath = path.normalize(process.resourcesPath);
|
|
|
|
var registerBeforeModuleCache = loadSettings.devMode || !loadSettings.resourcePath.startsWith(process.resourcesPath + path.sep);
|
|
var hotreload = loadSettings.devMode && !loadSettings.isSpec;
|
|
|
|
// Require before the module cache in dev mode
|
|
if (registerBeforeModuleCache) {
|
|
registerRuntimeTranspilers(hotreload);
|
|
}
|
|
|
|
ModuleCache = require('../src/module-cache');
|
|
ModuleCache.register(loadSettings);
|
|
ModuleCache.add(loadSettings.resourcePath);
|
|
|
|
// Start the crash reporter before anything else.
|
|
require('crash-reporter').start({
|
|
productName: 'Atom',
|
|
companyName: 'GitHub',
|
|
// By explicitly passing the app version here, we could save the call
|
|
// of "require('remote').require('app').getVersion()".
|
|
extra: {_version: loadSettings.appVersion}
|
|
});
|
|
|
|
require('vm-compatibility-layer');
|
|
|
|
if (!registerBeforeModuleCache) {
|
|
registerRuntimeTranspilers(hotreload);
|
|
}
|
|
|
|
require('../src/coffee-cache').register();
|
|
|
|
require(loadSettings.bootstrapScript);
|
|
|
|
// Defer by one tick to make sure the window has rendered. This was in Atom,
|
|
// but special cased in Atom.coffee instead of here.
|
|
setTimeout(function() {
|
|
require('ipc').sendChannel('window-command', 'window:loaded');
|
|
}, 1);
|
|
|
|
if (global.atom) {
|
|
global.atom.loadTime = Date.now() - startTime;
|
|
console.log('Window load time: ' + global.atom.getWindowLoadTime() + 'ms');
|
|
}
|
|
}
|
|
catch (error) {
|
|
var currentWindow = require('remote').getCurrentWindow();
|
|
currentWindow.setSize(800, 600);
|
|
currentWindow.center();
|
|
currentWindow.show();
|
|
currentWindow.openDevTools();
|
|
console.error(error.stack || error);
|
|
console.error(error.message, error);
|
|
}
|
|
}
|