From 3d5f5f2d239e5acee4463052cdab5215143c721b Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 30 Jun 2025 16:00:43 -0400 Subject: [PATCH] Revert "Remove require.js" This reverts commit 31701109 --- chrome/content/scaffold/scaffold.xhtml | 1 + chrome/content/zotero/include.js | 20 + chrome/content/zotero/note.xhtml | 1 + chrome/content/zotero/reader.xhtml | 1 + chrome/content/zotero/zotero.mjs | 7 + chrome/content/zotero/zoteroPane.xhtml | 1 + eslint.config.mjs | 2 + resource/concurrentCaller.js | 12 + resource/loader.jsm | 1250 ++++++++++++++++++++++++ resource/require.js | 114 +++ 10 files changed, 1409 insertions(+) create mode 100644 resource/loader.jsm create mode 100644 resource/require.js diff --git a/chrome/content/scaffold/scaffold.xhtml b/chrome/content/scaffold/scaffold.xhtml index bae5f7ed70..a9881b7e4f 100644 --- a/chrome/content/scaffold/scaffold.xhtml +++ b/chrome/content/scaffold/scaffold.xhtml @@ -59,6 +59,7 @@ Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this); + Services.scriptloader.loadSubScript("resource://zotero/require.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/titlebar.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this); Services.scriptloader.loadSubScript("chrome://zotero/content/editMenuOverlay.js", this); diff --git a/chrome/content/zotero/include.js b/chrome/content/zotero/include.js index cfba2e5b8b..8fb85a11ae 100644 --- a/chrome/content/zotero/include.js +++ b/chrome/content/zotero/include.js @@ -1 +1,21 @@ var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs"); + +// Components.utils.import('resource://zotero/require.js'); +// Not using Cu.import here since we don't want the require module to be cached +// for includes within ZoteroPane or other code, where we want the window +// instance available to modules. +// However, doing this unsets `window.name` (and possibly other window props) +// so we're manually handling it here +var winName; +if (typeof window != 'undefined') { + winName = window.name; +} +if (typeof require == "undefined") { + Components.classes["@mozilla.org/moz/jssubscript-loader;1"] + .getService(Components.interfaces.mozIJSSubScriptLoader) + .loadSubScript('resource://zotero/require.js'); +} + +if (winName) { + window.name = winName; +} diff --git a/chrome/content/zotero/note.xhtml b/chrome/content/zotero/note.xhtml index 3321a1309f..dad3c9c34a 100644 --- a/chrome/content/zotero/note.xhtml +++ b/chrome/content/zotero/note.xhtml @@ -31,6 +31,7 @@