Run ESLint on preload.js
This commit is contained in:
parent
12cdeee7ec
commit
6e6b93d917
2 changed files with 143 additions and 133 deletions
|
@ -28,4 +28,5 @@ test/views/*.js
|
|||
!js/views/message_view.js
|
||||
!js/views/settings_view.js
|
||||
!main.js
|
||||
!preload.js
|
||||
!prepare_build.js
|
||||
|
|
275
preload.js
275
preload.js
|
@ -1,159 +1,168 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
/* global Whisper: false */
|
||||
/* global window: false */
|
||||
|
||||
console.log('preload');
|
||||
const electron = require('electron');
|
||||
console.log('preload');
|
||||
|
||||
const Attachment = require('./js/modules/types/attachment');
|
||||
const Attachments = require('./app/attachments');
|
||||
const Message = require('./js/modules/types/message');
|
||||
const { deferredToPromise } = require('./js/modules/deferred_to_promise');
|
||||
const electron = require('electron');
|
||||
|
||||
const { app } = electron.remote;
|
||||
const Attachment = require('./js/modules/types/attachment');
|
||||
const Attachments = require('./app/attachments');
|
||||
const Message = require('./js/modules/types/message');
|
||||
const { deferredToPromise } = require('./js/modules/deferred_to_promise');
|
||||
|
||||
const { app } = electron.remote;
|
||||
|
||||
|
||||
window.PROTO_ROOT = 'protos';
|
||||
window.config = require('url').parse(window.location.toString(), true).query;
|
||||
window.wrapDeferred = deferredToPromise;
|
||||
window.PROTO_ROOT = 'protos';
|
||||
window.config = require('url').parse(window.location.toString(), true).query;
|
||||
|
||||
const ipc = electron.ipcRenderer;
|
||||
window.config.localeMessages = ipc.sendSync('locale-data');
|
||||
window.wrapDeferred = deferredToPromise;
|
||||
|
||||
window.setBadgeCount = function(count) {
|
||||
ipc.send('set-badge-count', count);
|
||||
};
|
||||
window.drawAttention = function() {
|
||||
console.log('draw attention');
|
||||
ipc.send('draw-attention');
|
||||
};
|
||||
window.showWindow = function() {
|
||||
console.log('show window');
|
||||
ipc.send('show-window');
|
||||
};
|
||||
window.setAutoHideMenuBar = function(autoHide) {
|
||||
ipc.send('set-auto-hide-menu-bar', autoHide);
|
||||
};
|
||||
window.setMenuBarVisibility = function(visibility) {
|
||||
ipc.send('set-menu-bar-visibility', visibility);
|
||||
};
|
||||
window.restart = function() {
|
||||
console.log('restart');
|
||||
ipc.send('restart');
|
||||
};
|
||||
window.closeAbout = function() {
|
||||
ipc.send('close-about');
|
||||
};
|
||||
window.updateTrayIcon = function(unreadCount) {
|
||||
ipc.send('update-tray-icon', unreadCount);
|
||||
};
|
||||
const ipc = electron.ipcRenderer;
|
||||
window.config.localeMessages = ipc.sendSync('locale-data');
|
||||
|
||||
ipc.on('debug-log', function() {
|
||||
Whisper.events.trigger('showDebugLog');
|
||||
});
|
||||
window.setBadgeCount = count =>
|
||||
ipc.send('set-badge-count', count);
|
||||
|
||||
ipc.on('set-up-with-import', function() {
|
||||
Whisper.events.trigger('setupWithImport');
|
||||
});
|
||||
window.drawAttention = () => {
|
||||
console.log('draw attention');
|
||||
ipc.send('draw-attention');
|
||||
};
|
||||
window.showWindow = () => {
|
||||
console.log('show window');
|
||||
ipc.send('show-window');
|
||||
};
|
||||
|
||||
ipc.on('set-up-as-new-device', function() {
|
||||
Whisper.events.trigger('setupAsNewDevice');
|
||||
});
|
||||
window.setAutoHideMenuBar = autoHide =>
|
||||
ipc.send('set-auto-hide-menu-bar', autoHide);
|
||||
|
||||
ipc.on('set-up-as-standalone', function() {
|
||||
Whisper.events.trigger('setupAsStandalone');
|
||||
});
|
||||
window.setMenuBarVisibility = visibility =>
|
||||
ipc.send('set-menu-bar-visibility', visibility);
|
||||
|
||||
ipc.on('show-settings', function() {
|
||||
Whisper.events.trigger('showSettings');
|
||||
});
|
||||
window.restart = () => {
|
||||
console.log('restart');
|
||||
ipc.send('restart');
|
||||
};
|
||||
|
||||
window.addSetupMenuItems = function() {
|
||||
ipc.send('add-setup-menu-items');
|
||||
}
|
||||
window.closeAbout = () =>
|
||||
ipc.send('close-about');
|
||||
|
||||
window.removeSetupMenuItems = function() {
|
||||
ipc.send('remove-setup-menu-items');
|
||||
}
|
||||
window.updateTrayIcon = unreadCount =>
|
||||
ipc.send('update-tray-icon', unreadCount);
|
||||
|
||||
// We pull these dependencies in now, from here, because they have Node.js dependencies
|
||||
ipc.on('debug-log', () => {
|
||||
Whisper.events.trigger('showDebugLog');
|
||||
});
|
||||
|
||||
require('./js/logging');
|
||||
ipc.on('set-up-with-import', () => {
|
||||
Whisper.events.trigger('setupWithImport');
|
||||
});
|
||||
|
||||
if (window.config.proxyUrl) {
|
||||
console.log('using proxy url', window.config.proxyUrl);
|
||||
}
|
||||
ipc.on('set-up-as-new-device', () => {
|
||||
Whisper.events.trigger('setupAsNewDevice');
|
||||
});
|
||||
|
||||
window.nodeSetImmediate = setImmediate;
|
||||
window.nodeWebSocket = require("websocket").w3cwebsocket;
|
||||
ipc.on('set-up-as-standalone', () => {
|
||||
Whisper.events.trigger('setupAsStandalone');
|
||||
});
|
||||
|
||||
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
||||
setInterval(function() {
|
||||
window.nodeSetImmediate(function() {});
|
||||
}, 1000);
|
||||
ipc.on('show-settings', () => {
|
||||
Whisper.events.trigger('showSettings');
|
||||
});
|
||||
|
||||
window.dataURLToBlobSync = require('blueimp-canvas-to-blob');
|
||||
window.loadImage = require('blueimp-load-image');
|
||||
window.ProxyAgent = require('proxy-agent');
|
||||
window.EmojiConvertor = require('emoji-js');
|
||||
window.emojiData = require('emoji-datasource');
|
||||
window.nodeFetch = require('node-fetch');
|
||||
window.nodeBuffer = Buffer;
|
||||
window.EmojiPanel = require('emoji-panel');
|
||||
window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||
window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').PhoneNumberFormat;
|
||||
window.nodeNotifier = require('node-notifier');
|
||||
window.addSetupMenuItems = () =>
|
||||
ipc.send('add-setup-menu-items');
|
||||
|
||||
const { autoOrientImage } = require('./js/modules/auto_orient_image');
|
||||
window.autoOrientImage = autoOrientImage;
|
||||
window.removeSetupMenuItems = () =>
|
||||
ipc.send('remove-setup-menu-items');
|
||||
|
||||
// ES2015+ modules
|
||||
const attachmentsPath = Attachments.getPath(app.getPath('userData'));
|
||||
const deleteAttachmentData = Attachments.deleteData(attachmentsPath);
|
||||
const readAttachmentData = Attachments.readData(attachmentsPath);
|
||||
const writeAttachmentData = Attachments.writeData(attachmentsPath);
|
||||
// We pull these dependencies in now, from here, because they have Node.js dependencies
|
||||
|
||||
// Injected context functions to keep `Message` agnostic from Electron:
|
||||
const upgradeSchemaContext = {
|
||||
writeAttachmentData,
|
||||
};
|
||||
const upgradeMessageSchema = message =>
|
||||
Message.upgradeSchema(message, upgradeSchemaContext);
|
||||
require('./js/logging');
|
||||
|
||||
const { getPlaceholderMigrations } =
|
||||
require('./js/modules/migrations/get_placeholder_migrations');
|
||||
const { IdleDetector} = require('./js/modules/idle_detector');
|
||||
if (window.config.proxyUrl) {
|
||||
console.log('using proxy url', window.config.proxyUrl);
|
||||
}
|
||||
|
||||
window.Signal = {};
|
||||
window.Signal.Backup = require('./js/modules/backup');
|
||||
window.Signal.Crypto = require('./js/modules/crypto');
|
||||
window.Signal.Database = require('./js/modules/database');
|
||||
window.Signal.Debug = require('./js/modules/debug');
|
||||
window.Signal.Logs = require('./js/modules/logs');
|
||||
window.Signal.Migrations = {};
|
||||
window.Signal.Migrations.deleteAttachmentData = Attachment.deleteData(deleteAttachmentData);
|
||||
window.Signal.Migrations.getPlaceholderMigrations =getPlaceholderMigrations;
|
||||
window.Signal.Migrations.loadAttachmentData = Attachment.loadData(readAttachmentData);
|
||||
window.Signal.Migrations.Migrations0DatabaseWithAttachmentData =
|
||||
require('./js/modules/migrations/migrations_0_database_with_attachment_data');
|
||||
window.Signal.Migrations.Migrations1DatabaseWithoutAttachmentData =
|
||||
require('./js/modules/migrations/migrations_1_database_without_attachment_data');
|
||||
window.Signal.Migrations.upgradeMessageSchema = upgradeMessageSchema;
|
||||
window.Signal.OS = require('./js/modules/os');
|
||||
window.Signal.Settings = require('./js/modules/settings');
|
||||
window.Signal.Types = {};
|
||||
window.Signal.Types.Attachment = Attachment;
|
||||
window.Signal.Types.Errors = require('./js/modules/types/errors');
|
||||
window.Signal.Types.Message = Message;
|
||||
window.Signal.Types.MIME = require('./js/modules/types/mime');
|
||||
window.Signal.Types.Settings = require('./js/modules/types/settings');
|
||||
window.Signal.Views = {};
|
||||
window.Signal.Views.Initialization = require('./js/modules/views/initialization');
|
||||
window.Signal.Workflow = {};
|
||||
window.Signal.Workflow.IdleDetector = IdleDetector;
|
||||
window.Signal.Workflow.MessageDataMigrator =
|
||||
require('./js/modules/messages_data_migrator');
|
||||
window.nodeSetImmediate = setImmediate;
|
||||
window.nodeWebSocket = require('websocket').w3cwebsocket;
|
||||
|
||||
// We pull this in last, because the native module involved appears to be sensitive to
|
||||
// /tmp mounted as noexec on Linux.
|
||||
require('./js/spell_check');
|
||||
})();
|
||||
// Linux seems to periodically let the event loop stop, so this is a global workaround
|
||||
setInterval(() => {
|
||||
window.nodeSetImmediate(() => {});
|
||||
}, 1000);
|
||||
|
||||
const { autoOrientImage } = require('./js/modules/auto_orient_image');
|
||||
|
||||
window.autoOrientImage = autoOrientImage;
|
||||
window.dataURLToBlobSync = require('blueimp-canvas-to-blob');
|
||||
window.EmojiConvertor = require('emoji-js');
|
||||
window.emojiData = require('emoji-datasource');
|
||||
window.EmojiPanel = require('emoji-panel');
|
||||
window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInstance();
|
||||
window.libphonenumber.PhoneNumberFormat =
|
||||
require('google-libphonenumber').PhoneNumberFormat;
|
||||
window.loadImage = require('blueimp-load-image');
|
||||
|
||||
window.nodeBuffer = Buffer;
|
||||
window.nodeFetch = require('node-fetch');
|
||||
window.nodeNotifier = require('node-notifier');
|
||||
window.ProxyAgent = require('proxy-agent');
|
||||
|
||||
// ES2015+ modules
|
||||
const attachmentsPath = Attachments.getPath(app.getPath('userData'));
|
||||
const deleteAttachmentData = Attachments.deleteData(attachmentsPath);
|
||||
const readAttachmentData = Attachments.readData(attachmentsPath);
|
||||
const writeAttachmentData = Attachments.writeData(attachmentsPath);
|
||||
|
||||
// Injected context functions to keep `Message` agnostic from Electron:
|
||||
const upgradeSchemaContext = {
|
||||
writeAttachmentData,
|
||||
};
|
||||
const upgradeMessageSchema = message =>
|
||||
Message.upgradeSchema(message, upgradeSchemaContext);
|
||||
|
||||
const { getPlaceholderMigrations } =
|
||||
require('./js/modules/migrations/get_placeholder_migrations');
|
||||
const { IdleDetector } = require('./js/modules/idle_detector');
|
||||
|
||||
window.Signal = {};
|
||||
window.Signal.Backup = require('./js/modules/backup');
|
||||
window.Signal.Crypto = require('./js/modules/crypto');
|
||||
window.Signal.Database = require('./js/modules/database');
|
||||
window.Signal.Debug = require('./js/modules/debug');
|
||||
window.Signal.Logs = require('./js/modules/logs');
|
||||
|
||||
window.Signal.Migrations = {};
|
||||
window.Signal.Migrations.deleteAttachmentData =
|
||||
Attachment.deleteData(deleteAttachmentData);
|
||||
window.Signal.Migrations.getPlaceholderMigrations = getPlaceholderMigrations;
|
||||
window.Signal.Migrations.loadAttachmentData = Attachment.loadData(readAttachmentData);
|
||||
window.Signal.Migrations.Migrations0DatabaseWithAttachmentData =
|
||||
require('./js/modules/migrations/migrations_0_database_with_attachment_data');
|
||||
window.Signal.Migrations.Migrations1DatabaseWithoutAttachmentData =
|
||||
require('./js/modules/migrations/migrations_1_database_without_attachment_data');
|
||||
|
||||
window.Signal.Migrations.upgradeMessageSchema = upgradeMessageSchema;
|
||||
window.Signal.OS = require('./js/modules/os');
|
||||
window.Signal.Settings = require('./js/modules/settings');
|
||||
|
||||
window.Signal.Types = {};
|
||||
window.Signal.Types.Attachment = Attachment;
|
||||
window.Signal.Types.Errors = require('./js/modules/types/errors');
|
||||
|
||||
window.Signal.Types.Message = Message;
|
||||
window.Signal.Types.MIME = require('./js/modules/types/mime');
|
||||
window.Signal.Types.Settings = require('./js/modules/types/settings');
|
||||
|
||||
window.Signal.Views = {};
|
||||
window.Signal.Views.Initialization = require('./js/modules/views/initialization');
|
||||
|
||||
window.Signal.Workflow = {};
|
||||
window.Signal.Workflow.IdleDetector = IdleDetector;
|
||||
window.Signal.Workflow.MessageDataMigrator =
|
||||
require('./js/modules/messages_data_migrator');
|
||||
|
||||
// We pull this in last, because the native module involved appears to be sensitive to
|
||||
// /tmp mounted as noexec on Linux.
|
||||
require('./js/spell_check');
|
||||
|
|
Loading…
Reference in a new issue