From 2051f08b4c658e39e8a5df1c5c3dff8390dd28ad Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 6 Nov 2023 01:26:47 -0500 Subject: [PATCH] fx115: Move `Zotero` object initialization to zotero.mjs --- app/scripts/fetch_xulrunner | 2 +- chrome.manifest | 2 - chrome/content/scaffold/scaffold.js | 7 +- chrome/content/zotero/BlockingObserver.jsm | 5 +- chrome/content/zotero/EPUB.jsm | 6 +- chrome/content/zotero/HiddenBrowser.jsm | 4 +- chrome/content/zotero/RemoteTranslate.jsm | 4 +- .../zotero/actors/TranslationParent.jsm | 4 +- chrome/content/zotero/advancedSearch.xhtml | 3 +- chrome/content/zotero/customElements.js | 2 + .../content/zotero/import/importWizard.xhtml | 8 +- chrome/content/zotero/include.js | 11 +- chrome/content/zotero/include.jsm | 5 - chrome/content/zotero/update/updates.js | 2 +- .../zotero/xpcom/utilities_internal.js | 2 - chrome/content/zotero/xpcom/zotero.js | 1 + chrome/content/zotero/zotero.mjs | 425 +++++++++++++++++ chrome/content/zotero/zoteroPane.xhtml | 2 +- components/zotero-service.js | 445 ------------------ 19 files changed, 450 insertions(+), 490 deletions(-) delete mode 100644 chrome/content/zotero/include.jsm create mode 100644 chrome/content/zotero/zotero.mjs diff --git a/app/scripts/fetch_xulrunner b/app/scripts/fetch_xulrunner index f814bf4660..64f5455b8d 100755 --- a/app/scripts/fetch_xulrunner +++ b/app/scripts/fetch_xulrunner @@ -253,7 +253,7 @@ function modify_omni { cp "$APP_ROOT_DIR/assets/multilocale.txt" res/multilocale.txt # Use Zotero URL opening in Mozilla dialogs (e.g., app update dialog) - replace_line 'function openURL\(aURL\) \{' 'function openURL(aURL) {let {Zotero} = ChromeUtils.import("chrome:\/\/zotero\/content\/include.jsm"); Zotero.launchURL(aURL); if (true) { return; }' chrome/toolkit/content/global/contentAreaUtils.js + replace_line 'function openURL\(aURL\) \{' 'function openURL(aURL) {let {Zotero} = ChromeUtils.importESModule("chrome:\/\/zotero\/content\/zotero.mjs"); Zotero.launchURL(aURL); if (true) { return; }' chrome/toolkit/content/global/contentAreaUtils.js # # Modify Add-ons window diff --git a/chrome.manifest b/chrome.manifest index 7612eaa42c..987caef622 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -63,9 +63,7 @@ locale zotero zh-TW chrome/locale/zh-TW/zotero/ skin zotero default chrome/skin/default/zotero/ -component {e4c61080-ec2d-11da-8ad9-0800200c9a66} components/zotero-service.js component {531828f8-a16c-46be-b9aa-14845c3b010f} components/zotero-service.js -contract @zotero.org/Zotero;1 {e4c61080-ec2d-11da-8ad9-0800200c9a66} contract @mozilla.org/browser/clh;1 {531828f8-a16c-46be-b9aa-14845c3b010f} category command-line-handler m-zotero @mozilla.org/browser/clh;1 diff --git a/chrome/content/scaffold/scaffold.js b/chrome/content/scaffold/scaffold.js index b1df123669..e1000e92c9 100644 --- a/chrome/content/scaffold/scaffold.js +++ b/chrome/content/scaffold/scaffold.js @@ -29,14 +29,9 @@ var { Subprocess } = ChromeUtils.import("resource://gre/modules/Subprocess.jsm") var { RemoteTranslate } = ChromeUtils.import("chrome://zotero/content/RemoteTranslate.jsm"); var { ContentDOMReference } = ChromeUtils.import("resource://gre/modules/ContentDOMReference.jsm"); +var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs"); import FilePicker from 'zotero/modules/filePicker'; -var Zotero = Components.classes["@zotero.org/Zotero;1"] - // Currently uses only nsISupports - //.getService(Components.interfaces.chnmIZoteroService). - .getService(Components.interfaces.nsISupports) - .wrappedJSObject; - // Fix JSON stringify 2028/2029 "bug" // Borrowed from http://stackoverflow.com/questions/16686687/json-stringify-and-u2028-u2029-check if (JSON.stringify(["\u2028\u2029"]) !== '["\\u2028\\u2029"]') { diff --git a/chrome/content/zotero/BlockingObserver.jsm b/chrome/content/zotero/BlockingObserver.jsm index 3616a7cb26..99d8b49813 100644 --- a/chrome/content/zotero/BlockingObserver.jsm +++ b/chrome/content/zotero/BlockingObserver.jsm @@ -25,9 +25,8 @@ const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -XPCOMUtils.defineLazyModuleGetters(this, { - Services: "resource://gre/modules/Services.jsm", - Zotero: "chrome://zotero/content/include.jsm" +ChromeUtils.defineESModuleGetters(this, { + Zotero: "chrome://zotero/content/zotero.mjs", }); var EXPORTED_SYMBOLS = ["BlockingObserver"]; diff --git a/chrome/content/zotero/EPUB.jsm b/chrome/content/zotero/EPUB.jsm index 22f154e23a..71f12f19c1 100644 --- a/chrome/content/zotero/EPUB.jsm +++ b/chrome/content/zotero/EPUB.jsm @@ -25,10 +25,8 @@ var EXPORTED_SYMBOLS = ["EPUB"]; -const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetters(this, { - Zotero: "chrome://zotero/content/include.jsm" +ChromeUtils.defineESModuleGetters(this, { + Zotero: "chrome://zotero/content/zotero.mjs", }); const ZipReader = Components.Constructor( diff --git a/chrome/content/zotero/HiddenBrowser.jsm b/chrome/content/zotero/HiddenBrowser.jsm index 9f0395ba43..1c03ed499a 100644 --- a/chrome/content/zotero/HiddenBrowser.jsm +++ b/chrome/content/zotero/HiddenBrowser.jsm @@ -35,7 +35,9 @@ XPCOMUtils.defineLazyModuleGetters(this, { HiddenFrame: "resource://gre/modules/HiddenFrame.jsm", Services: "resource://gre/modules/Services.jsm", setTimeout: "resource://gre/modules/Timer.jsm", - Zotero: "chrome://zotero/content/include.jsm" +}); +ChromeUtils.defineESModuleGetters(this, { + Zotero: "chrome://zotero/content/zotero.mjs" }); ChromeUtils.registerWindowActor("PageData", { diff --git a/chrome/content/zotero/RemoteTranslate.jsm b/chrome/content/zotero/RemoteTranslate.jsm index 9e66e29440..35a42dc606 100644 --- a/chrome/content/zotero/RemoteTranslate.jsm +++ b/chrome/content/zotero/RemoteTranslate.jsm @@ -36,8 +36,10 @@ ChromeUtils.registerWindowActor("Translation", { } }); +ChromeUtils.defineESModuleGetters(this, { + Zotero: "chrome://zotero/content/zotero.mjs", +}); XPCOMUtils.defineLazyModuleGetters(this, { - Zotero: "chrome://zotero/content/include.jsm", TranslationManager: "chrome://zotero/content/actors/TranslationParent.jsm", }); diff --git a/chrome/content/zotero/actors/TranslationParent.jsm b/chrome/content/zotero/actors/TranslationParent.jsm index af0f6527e4..38e77c6354 100644 --- a/chrome/content/zotero/actors/TranslationParent.jsm +++ b/chrome/content/zotero/actors/TranslationParent.jsm @@ -1,8 +1,6 @@ var EXPORTED_SYMBOLS = ["TranslationParent", "TranslationManager"]; -const Zotero = Components.classes['@zotero.org/Zotero;1'] - .getService(Components.interfaces.nsISupports) - .wrappedJSObject; +var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs"); const TranslationManager = new class { _registeredRemoteTranslates = new Map(); diff --git a/chrome/content/zotero/advancedSearch.xhtml b/chrome/content/zotero/advancedSearch.xhtml index ec61dd7ba4..ab78840cfb 100644 --- a/chrome/content/zotero/advancedSearch.xhtml +++ b/chrome/content/zotero/advancedSearch.xhtml @@ -24,11 +24,10 @@ windowtype="zotero:search" style="display: flex;"> + - - @@ -114,7 +115,4 @@ - -