mirror of
https://github.com/zotero/zotero.git
synced 2026-10-06 02:50:03 +00:00
Remove Bluebird
And add a partial shim for the simplest and most useful methods. Not sure if we actually want that, or if we should just replace it entirely with native methods.
This commit is contained in:
parent
3170110944
commit
8f7c760804
10 changed files with 20 additions and 89 deletions
5
chrome/content/zotero/xpcom/bluebirdShim.mjs
Normal file
5
chrome/content/zotero/xpcom/bluebirdShim.mjs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export default class BluebirdShimPromise extends Promise {
|
||||
static delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
|
|
@ -23,18 +23,18 @@
|
|||
***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const BluebirdShimPromise = ChromeUtils.importESModule('chrome://zotero/content/xpcom/bluebirdShim.mjs');
|
||||
const ZOTERO_CONFIG = ChromeUtils.importESModule('resource://zotero/config.mjs');
|
||||
|
||||
// Commonly used imports accessible anywhere
|
||||
Components.utils.importGlobalProperties(["XMLHttpRequest"]);
|
||||
Components.utils.import("resource://zotero/config.js");
|
||||
var { OS } = ChromeUtils.importESModule("chrome://zotero/content/osfile.mjs");
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetters(globalThis, {
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
|
||||
AppConstants: "resource://gre/modules/AppConstants.jsm",
|
||||
ChromeUtils.defineESModuleGetters(globalThis, {
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
|
||||
AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
|
||||
});
|
||||
const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
||||
Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||
|
||||
/*
|
||||
* Core functions
|
||||
|
|
@ -72,7 +72,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
|||
this.isMac;
|
||||
this.isWin;
|
||||
this.initialURL; // used by Schema to show the changelog on upgrades
|
||||
this.Promise = require('resource://zotero/bluebird.js');
|
||||
this.Promise = BluebirdShimPromise;
|
||||
|
||||
this.getMainWindow = function () {
|
||||
return Services.wm.getMostRecentWindow("navigator:browser");
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ const xpcomFilesLocal = [
|
|||
'translation/translators',
|
||||
];
|
||||
|
||||
Components.utils.import("resource://gre/modules/ComponentUtils.jsm");
|
||||
const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/content/modules/commandLineOptions.mjs");
|
||||
|
||||
var instanceID = (new Date()).getTime();
|
||||
|
|
@ -169,8 +168,6 @@ var initCallbacks = [];
|
|||
|
||||
var ZoteroContext = function() {}
|
||||
ZoteroContext.prototype = {
|
||||
require,
|
||||
|
||||
/**
|
||||
* Shuts down Zotero, calls a callback (that may return a promise),
|
||||
* then reinitializes Zotero. Returns a promise that is resolved
|
||||
|
|
@ -193,16 +190,13 @@ ZoteroContext.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import(
|
||||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(ZoteroContext.prototype, {
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
clearTimeout: "resource://gre/modules/Timer.jsm",
|
||||
setInterval: "resource://gre/modules/Timer.jsm",
|
||||
clearInterval: "resource://gre/modules/Timer.jsm",
|
||||
requestIdleCallback: "resource://gre/modules/Timer.jsm",
|
||||
cancelIdleCallback: "resource://gre/modules/Timer.jsm",
|
||||
ChromeUtils.defineESModuleGetters(ZoteroContext.prototype, {
|
||||
setTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
|
||||
setInterval: "resource://gre/modules/Timer.sys.mjs",
|
||||
clearInterval: "resource://gre/modules/Timer.sys.mjs",
|
||||
requestIdleCallback: "resource://gre/modules/Timer.sys.mjs",
|
||||
cancelIdleCallback: "resource://gre/modules/Timer.sys.mjs",
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
|||
11
package-lock.json
generated
11
package-lock.json
generated
|
|
@ -10,7 +10,6 @@
|
|||
"dependencies": {
|
||||
"@citeproc-rs/wasm": "^0.2.0",
|
||||
"ace-builds": "^1.4.12",
|
||||
"bluebird": "^3.7.2",
|
||||
"classnames": "^2.2.6",
|
||||
"monaco-editor": "^0.47.0",
|
||||
"monacopilot": "^1.1.15",
|
||||
|
|
@ -1982,11 +1981,6 @@
|
|||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bluebird": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
|
||||
},
|
||||
"node_modules/bn.js": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz",
|
||||
|
|
@ -10315,11 +10309,6 @@
|
|||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
|
||||
},
|
||||
"bn.js": {
|
||||
"version": "5.1.3",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.1.3.tgz",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
"dependencies": {
|
||||
"@citeproc-rs/wasm": "^0.2.0",
|
||||
"ace-builds": "^1.4.12",
|
||||
"bluebird": "^3.7.2",
|
||||
"classnames": "^2.2.6",
|
||||
"monaco-editor": "^0.47.0",
|
||||
"monacopilot": "^1.1.15",
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
../node_modules/bluebird/js/release
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var EXPORTED_SYMBOLS = ['Promise'];
|
||||
|
||||
var Promise = require('bluebird/promise')();
|
||||
|
||||
Promise.config({
|
||||
warnings: true,
|
||||
longStackTraces: true,
|
||||
cancellation: true
|
||||
});
|
||||
|
||||
// Use our own stub to avoid the Bluebird deprecation warnings
|
||||
Promise.defer = function() {
|
||||
var deferred = {};
|
||||
deferred.promise = new Promise(function(resolve, reject) {
|
||||
deferred.resolve = resolve;
|
||||
deferred.reject = reject;
|
||||
});
|
||||
return deferred;
|
||||
}
|
||||
// TEMP: Only turn on if debug logging enabled?
|
||||
Promise.onPossiblyUnhandledRejection((e, promise) => {
|
||||
if (e.handledRejection) {
|
||||
return;
|
||||
}
|
||||
|
||||
dump('Possibly unhandled rejection:\n\n'
|
||||
+ (e.message
|
||||
? e.message + "\n\n" + e.stack.split(/\n/)
|
||||
// Filter out internal Bluebird calls
|
||||
.filter(line => !line.includes('bluebird'))
|
||||
.join('\n')
|
||||
: e)
|
||||
+ '\n');
|
||||
throw e;
|
||||
});
|
||||
|
||||
module.exports = Promise;
|
||||
|
|
@ -34,9 +34,4 @@ var ZOTERO_CONFIG = {
|
|||
NEW_FEATURES_URL: 'https://www.zotero.org/blog/zotero-7/'
|
||||
};
|
||||
|
||||
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||||
module.exports = ZOTERO_CONFIG;
|
||||
}
|
||||
else {
|
||||
var EXPORTED_SYMBOLS = ["ZOTERO_CONFIG"];
|
||||
}
|
||||
export default ZOTERO_CONFIG;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
if (!Object.values) {
|
||||
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
|
||||
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
|
||||
const concat = Function.bind.call(Function.call, Array.prototype.concat);
|
||||
const keys = Reflect.ownKeys;
|
||||
|
||||
Object.values = function values(O) {
|
||||
return reduce(keys(O), (v, k) => concat(v, typeof k === 'string' && isEnumerable(O, k) ? [O[k]] : []), []);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||
var EventUtils = Components.utils.import("resource://zotero-unit/EventUtils.jsm");
|
||||
var { FileUtils } = ChromeUtils.importESModule("resource://gre/modules/FileUtils.sys.mjs");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue