Remove require.js

But not yet calls to require().
This commit is contained in:
Abe Jellinek 2025-06-27 10:58:33 -04:00
parent 48604a7d7e
commit 3170110944
10 changed files with 0 additions and 1409 deletions

View file

@ -59,7 +59,6 @@
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);

View file

@ -1,21 +1 @@
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;
}

View file

@ -31,7 +31,6 @@
<script>
Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
Services.scriptloader.loadSubScript("resource://zotero/require.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this);
// Mozilla scripts

View file

@ -32,7 +32,6 @@
<script type="application/javascript">
Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
Services.scriptloader.loadSubScript("resource://zotero/require.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/browserWindowShim.js", this);

View file

@ -167,13 +167,6 @@ var isFirstLoadThisSession = true;
var zContext = null;
var initCallbacks = [];
// 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.
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript('resource://zotero/require.js');
var ZoteroContext = function() {}
ZoteroContext.prototype = {
require,

View file

@ -59,7 +59,6 @@
<script>
var { Zotero } = ChromeUtils.importESModule("chrome://zotero/content/zotero.mjs");
Services.scriptloader.loadSubScript("resource://zotero/require.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/standalone/standalone.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/titlebar.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this);

View file

@ -101,12 +101,10 @@ export default [
"resource/citeproc_rs*",
"resource/csl-validator.js",
"resource/jspath.js",
"resource/loader.jsm",
"resource/pako.js",
"resource/PluralForm.jsm",
"resource/prop-types.js",
"resource/react*",
"resource/require.js",
"resource/SingleFile/*",
"resource/tinymce/*",
"test/resource/*",

View file

@ -25,18 +25,6 @@
var EXPORTED_SYMBOLS = ["ConcurrentCaller"];
if (!(typeof process === 'object' && process + '' === '[object process]')) {
// 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.
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript('resource://zotero/require.js');
var Promise = require('resource://zotero/bluebird.js');
} else {
Promise = require('bluebird');
}
/**
* Call a fixed number of functions at once, queueing the rest until slots
* open and returning a promise for the final completion. The functions do

File diff suppressed because it is too large Load diff

View file

@ -1,114 +0,0 @@
'use strict';
var require = (function() {
var win, cons, Zotero;
Components.utils.import('resource://zotero/loader.jsm');
var requirer = Module('/', '/');
var _runningTimers = {};
if (typeof window != 'undefined') {
win = window;
} else {
win = {};
win.setTimeout = function (func, ms) {
var id = Math.floor(Math.random() * (1000000000000 - 1)) + 1
var useMethodjit = Components.utils.methodjit;
var timer = Components.classes["@mozilla.org/timer;1"]
.createInstance(Components.interfaces.nsITimer);
timer.initWithCallback({"notify":function() {
// Remove timer from object so it can be garbage collected
delete _runningTimers[id];
// Execute callback function
try {
func();
} catch(err) {
// Rethrow errors that occur so that they appear in the error
// console with the appropriate name and line numbers. While the
// the errors appear without this, the line numbers get eaten.
var scriptError = Components.classes["@mozilla.org/scripterror;1"]
.createInstance(Components.interfaces.nsIScriptError);
scriptError.init(
err.message || err.toString(),
err.fileName || err.filename || null,
null,
err.lineNumber || null,
null,
scriptError.errorFlag,
'component javascript'
);
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.logMessage(scriptError);
typeof Zotero !== 'undefined' && Zotero.debug(err.stack, 1);
}
}}, ms, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
_runningTimers[id] = timer;
return id;
};
win.clearTimeout = function (id) {
var timer = _runningTimers[id];
if (timer) {
timer.cancel();
}
delete _runningTimers[id];
};
win.debug = function (msg) {
dump(msg + "\n\n");
};
}
function getZotero() {
if (win.Zotero) Zotero = win.Zotero;
if (typeof Zotero === 'undefined') {
try {
Zotero = Components.classes["@zotero.org/Zotero;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
} catch (e) {}
}
return Zotero || {};
}
if (typeof win.console !== 'undefined') {
cons = console;
}
if (!cons) {
cons = {};
for (let key of ['log', 'warn', 'error']) {
cons[key] = text => {getZotero(); typeof Zotero !== 'undefined' && false && Zotero.debug(`console.${key}: ${text}`)};
}
}
if (!win.console) {
win.console = cons;
}
let globals = {
window: win,
document: typeof win.document !== 'undefined' && win.document || {},
console: cons,
navigator: typeof win.navigator !== 'undefined' && win.navigator || {},
setTimeout: win.setTimeout,
clearTimeout: win.clearTimeout,
requestAnimationFrame: win.setTimeout,
cancelAnimationFrame: win.clearTimeout,
IOUtils: IOUtils,
PathUtils: PathUtils,
TextEncoder: TextEncoder,
TextDecoder: TextDecoder,
};
Object.defineProperty(globals, 'Zotero', { get: getZotero });
var loader = Loader({
id: 'zotero/require',
paths: {
'': 'resource://zotero/',
'containers/': 'chrome://zotero/content/containers/',
'components/': 'chrome://zotero/content/components/',
'zotero/': 'chrome://zotero/content/',
},
globals
});
let require = Require(loader, requirer);
return require;
})();