mirror of
https://github.com/zotero/zotero.git
synced 2026-09-29 01:41:24 +00:00
ESMify actors
This commit is contained in:
parent
19f2c88523
commit
f88cd2a7d7
17 changed files with 47 additions and 86 deletions
|
|
@ -25,15 +25,11 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["RemoteTranslate"];
|
||||
|
||||
ChromeUtils.import("chrome://zotero/content/actors/ActorManager.jsm");
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
Zotero: "chrome://zotero/content/zotero.mjs",
|
||||
});
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule("resource://gre/modules/XPCOMUtils.sys.mjs");
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
TranslationManager: "chrome://zotero/content/actors/TranslationParent.jsm",
|
||||
ZOTERO_CONFIG: "resource://zotero/config.js",
|
||||
ZOTERO_CONFIG: "resource://zotero/config.mjs",
|
||||
ActorManager: "chrome://zotero/content/actors/ActorManager.mjs",
|
||||
TranslationManager: "chrome://zotero/content/actors/TranslationParent.mjs",
|
||||
});
|
||||
|
||||
class RemoteTranslate {
|
||||
|
|
|
|||
|
|
@ -1,35 +1,33 @@
|
|||
// Register Mozilla actors
|
||||
import "resource://gre/modules/ActorManagerParent.sys.mjs";
|
||||
|
||||
// TODO: Fx140: Migrate actors and re-enable
|
||||
if(false) {
|
||||
ChromeUtils.registerWindowActor("PageData", {
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/PageDataChild.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/PageDataChild.mjs"
|
||||
}
|
||||
});
|
||||
|
||||
ChromeUtils.registerWindowActor("SingleFile", {
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/SingleFileChild.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/SingleFileChild.mjs"
|
||||
}
|
||||
});
|
||||
|
||||
ChromeUtils.registerWindowActor("Translation", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/TranslationParent.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/TranslationParent.mjs"
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/TranslationChild.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/TranslationChild.mjs"
|
||||
}
|
||||
});
|
||||
|
||||
ChromeUtils.registerWindowActor("FeedAbstract", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/FeedAbstractParent.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/FeedAbstractParent.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/FeedAbstractChild.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/FeedAbstractChild.mjs",
|
||||
events: {
|
||||
DOMDocElementInserted: {},
|
||||
}
|
||||
|
|
@ -39,10 +37,10 @@ ChromeUtils.registerWindowActor("FeedAbstract", {
|
|||
|
||||
ChromeUtils.registerWindowActor("ZoteroPrint", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/ZoteroPrintParent.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/ZoteroPrintParent.mjs"
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/ZoteroPrintChild.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/ZoteroPrintChild.mjs",
|
||||
events: {
|
||||
pageshow: {}
|
||||
}
|
||||
|
|
@ -52,10 +50,10 @@ ChromeUtils.registerWindowActor("ZoteroPrint", {
|
|||
|
||||
ChromeUtils.registerWindowActor("ExternalLinkHandler", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/ExternalLinkHandlerParent.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/ExternalLinkHandlerParent.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/ExternalLinkHandlerChild.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/ExternalLinkHandlerChild.mjs",
|
||||
events: {
|
||||
click: {},
|
||||
}
|
||||
|
|
@ -68,10 +66,10 @@ ChromeUtils.registerWindowActor("ExternalLinkHandler", {
|
|||
if (AppConstants.platform === "macosx") {
|
||||
ChromeUtils.registerWindowActor("SequoiaContextMenu", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/SequoiaContextMenuParent.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/SequoiaContextMenuParent.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/SequoiaContextMenuChild.jsm",
|
||||
esModuleURI: "chrome://zotero/content/actors/SequoiaContextMenuChild.mjs",
|
||||
},
|
||||
allFrames: true,
|
||||
includeChrome: true
|
||||
|
|
@ -80,16 +78,15 @@ if (AppConstants.platform === "macosx") {
|
|||
|
||||
ChromeUtils.registerWindowActor("MendeleyAuth", {
|
||||
parent: {
|
||||
moduleURI: "chrome://zotero/content/actors/MendeleyAuthParent.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/MendeleyAuthParent.mjs"
|
||||
},
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/MendeleyAuthChild.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/MendeleyAuthChild.mjs"
|
||||
}
|
||||
});
|
||||
|
||||
ChromeUtils.registerWindowActor("DocumentIsReady", {
|
||||
child: {
|
||||
moduleURI: "chrome://zotero/content/actors/DocumentIsReadyChild.jsm"
|
||||
esModuleURI: "chrome://zotero/content/actors/DocumentIsReadyChild.mjs"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
var EXPORTED_SYMBOLS = ["DocumentIsReadyChild"];
|
||||
import { documentIsReady } from "chrome://zotero/content/actors/actorUtils.mjs";
|
||||
|
||||
let { documentIsReady } = ChromeUtils.importESModule("chrome://zotero/content/actors/actorUtils.mjs");
|
||||
|
||||
class DocumentIsReadyChild extends JSWindowActorChild {
|
||||
export class DocumentIsReadyChild extends JSWindowActorChild {
|
||||
async receiveMessage({ name, data }) {
|
||||
if (name !== "waitForDocument") {
|
||||
return null;
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["ExternalLinkHandlerChild"];
|
||||
|
||||
|
||||
class ExternalLinkHandlerChild extends JSWindowActorChild {
|
||||
export class ExternalLinkHandlerChild extends JSWindowActorChild {
|
||||
async handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case "click": {
|
||||
|
|
@ -41,7 +38,7 @@ class ExternalLinkHandlerChild extends JSWindowActorChild {
|
|||
}
|
||||
let currentURL = this.contentWindow.location;
|
||||
|
||||
// eslint-disable-next-line no-script-url
|
||||
|
||||
if (hrefURL.protocol === 'javascript:') {
|
||||
// Link executes a script: open internally
|
||||
return true;
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
var EXPORTED_SYMBOLS = ["ExternalLinkHandlerParent"];
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
Zotero: "chrome://zotero/content/zotero.mjs"
|
||||
});
|
||||
|
||||
class ExternalLinkHandlerParent extends JSWindowActorParent {
|
||||
export class ExternalLinkHandlerParent extends JSWindowActorParent {
|
||||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "launchURL": {
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["FeedAbstractChild"];
|
||||
|
||||
class FeedAbstractChild extends JSWindowActorChild {
|
||||
export class FeedAbstractChild extends JSWindowActorChild {
|
||||
_stylesheet;
|
||||
|
||||
_stylesheetPromise;
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
var EXPORTED_SYMBOLS = ["FeedAbstractParent"];
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
Zotero: "chrome://zotero/content/zotero.mjs"
|
||||
});
|
||||
|
||||
class FeedAbstractParent extends JSWindowActorParent {
|
||||
export class FeedAbstractParent extends JSWindowActorParent {
|
||||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "getStylesheet": {
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
/* global JSWindowActorChild:false */
|
||||
|
||||
var EXPORTED_SYMBOLS = ["MendeleyAuthChild"]; // eslint-disable-line no-unused-vars
|
||||
import { documentIsReady } from "chrome://zotero/content/actors/actorUtils.mjs";
|
||||
|
||||
let { documentIsReady } = ChromeUtils.importESModule("chrome://zotero/content/actors/actorUtils.mjs");
|
||||
|
||||
class MendeleyAuthChild extends JSWindowActorChild { // eslint-disable-line no-unused-vars
|
||||
export class MendeleyAuthChild extends JSWindowActorChild {
|
||||
async receiveMessage(message) {
|
||||
let document = this.document;
|
||||
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
/* global JSWindowActorParent:false */
|
||||
|
||||
var EXPORTED_SYMBOLS = ["MendeleyAuthParent"]; // eslint-disable-line no-unused-vars
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
Zotero: "chrome://zotero/content/zotero.mjs"
|
||||
});
|
||||
});
|
||||
|
||||
class MendeleyAuthParent extends JSWindowActorParent { // eslint-disable-line no-unused-vars
|
||||
export class MendeleyAuthParent extends JSWindowActorParent {
|
||||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "debug": {
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
var EXPORTED_SYMBOLS = ["PageDataChild"];
|
||||
import { documentIsReady } from "chrome://zotero/content/actors/actorUtils.mjs";
|
||||
|
||||
let { documentIsReady } = ChromeUtils.importESModule("chrome://zotero/content/actors/actorUtils.mjs");
|
||||
|
||||
class PageDataChild extends JSWindowActorChild {
|
||||
export class PageDataChild extends JSWindowActorChild {
|
||||
async receiveMessage(message) {
|
||||
// Special case for loadURI: don't wait for document to be ready,
|
||||
// since we haven't loaded anything yet
|
||||
|
|
@ -1,12 +1,10 @@
|
|||
var { getTargetElement, createContextMenuEvent } = ChromeUtils.importESModule("chrome://zotero/content/contextMenuUtils.sys.mjs");
|
||||
|
||||
var EXPORTED_SYMBOLS = ["SequoiaContextMenuChild"];
|
||||
import { getTargetElement, createContextMenuEvent } from "chrome://zotero/content/contextMenuUtils.sys.mjs";
|
||||
|
||||
/**
|
||||
* Child-frame implementation of macOS Sequoia Ctrl-Enter context menu behavior.
|
||||
* See platformKeys.js for the chrome implementation.
|
||||
*/
|
||||
class SequoiaContextMenuChild extends JSWindowActorChild {
|
||||
export class SequoiaContextMenuChild extends JSWindowActorChild {
|
||||
async receiveMessage({ name }) {
|
||||
switch (name) {
|
||||
case "handleContextMenuEvent": {
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["SequoiaContextMenuParent"];
|
||||
|
||||
class SequoiaContextMenuParent extends JSWindowActorParent {
|
||||
export class SequoiaContextMenuParent extends JSWindowActorParent {
|
||||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "openContextMenuAtScreen": {
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
var EXPORTED_SYMBOLS = ["SingleFileChild"];
|
||||
import { documentIsReady } from "chrome://zotero/content/actors/actorUtils.mjs";
|
||||
|
||||
let { documentIsReady } = ChromeUtils.importESModule("chrome://zotero/content/actors/actorUtils.mjs");
|
||||
|
||||
class SingleFileChild extends JSWindowActorChild {
|
||||
export class SingleFileChild extends JSWindowActorChild {
|
||||
async receiveMessage(message) {
|
||||
let window = this.contentWindow;
|
||||
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["TranslationChild"];
|
||||
|
||||
let { documentIsReady } = ChromeUtils.importESModule("chrome://zotero/content/actors/actorUtils.mjs");
|
||||
import { documentIsReady } from "chrome://zotero/content/actors/actorUtils.mjs";
|
||||
|
||||
const TRANSLATE_SCRIPT_PATHS = [
|
||||
'src/zotero.js',
|
||||
|
|
@ -40,7 +38,7 @@ const OTHER_SCRIPT_URIS = [
|
|||
'chrome://zotero/content/actors/translation/translate_item.js',
|
||||
];
|
||||
|
||||
class TranslationChild extends JSWindowActorChild {
|
||||
export class TranslationChild extends JSWindowActorChild {
|
||||
_sandbox = null;
|
||||
|
||||
async receiveMessage(message) {
|
||||
|
|
@ -161,11 +159,11 @@ class TranslationChild extends JSWindowActorChild {
|
|||
|
||||
_makeTranslatorProvider(id) {
|
||||
let { Zotero } = this._sandbox;
|
||||
let makeProxy = method => (
|
||||
let makeProxy = method =>
|
||||
(...args) => this._sandbox.Promise.resolve(
|
||||
this.sendQuery('Translators:call', { id, method, args })
|
||||
).then(result => Cu.cloneInto(result, this._sandbox))
|
||||
);
|
||||
;
|
||||
return Cu.cloneInto({
|
||||
...Zotero.Translators,
|
||||
get: makeProxy('get'),
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
var EXPORTED_SYMBOLS = ["TranslationParent", "TranslationManager"];
|
||||
import { Zotero } from "chrome://zotero/content/zotero.mjs";
|
||||
|
||||
var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs");
|
||||
|
||||
const TranslationManager = new class {
|
||||
export const TranslationManager = new (class {
|
||||
_registeredRemoteTranslates = new Map();
|
||||
|
||||
add(id, remoteTranslate) {
|
||||
|
|
@ -62,9 +60,9 @@ const TranslationManager = new class {
|
|||
}
|
||||
return returnValue;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
class TranslationParent extends JSWindowActorParent {
|
||||
export class TranslationParent extends JSWindowActorParent {
|
||||
async receiveMessage(message) {
|
||||
let { name, data } = message;
|
||||
switch (name) {
|
||||
|
|
@ -1,7 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["ZoteroPrintChild"];
|
||||
|
||||
|
||||
class ZoteroPrintChild extends JSWindowActorChild {
|
||||
export class ZoteroPrintChild extends JSWindowActorChild {
|
||||
actorCreated() {
|
||||
Cu.exportFunction(
|
||||
options => new this.contentWindow.Promise(
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
var EXPORTED_SYMBOLS = ["ZoteroPrintParent"];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule("resource://gre/modules/XPCOMUtils.sys.mjs");
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
});
|
||||
|
|
@ -9,7 +7,7 @@ ChromeUtils.defineESModuleGetters(this, {
|
|||
Zotero: "chrome://zotero/content/zotero.mjs",
|
||||
});
|
||||
|
||||
class ZoteroPrintParent extends JSWindowActorParent {
|
||||
export class ZoteroPrintParent extends JSWindowActorParent {
|
||||
async receiveMessage({ name, data }) {
|
||||
switch (name) {
|
||||
case "zoteroPrint": {
|
||||
Loading…
Add table
Reference in a new issue