Tweak loading process
This commit is contained in:
parent
7ff11fdebb
commit
94619403ca
|
@ -1674,5 +1674,5 @@ Zotero.Utilities = {
|
|||
* Provides unicode support and other additional features for regular expressions
|
||||
* See https://github.com/slevithan/xregexp for usage
|
||||
*/
|
||||
"XRegExp": Zotero.XRegExp
|
||||
"XRegExp": XRegExp
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
//List of files to be loaded by Zotero
|
||||
var load = [
|
||||
/**Core functions**/
|
||||
'xregexp',
|
||||
|
||||
/**Addons**/
|
||||
'addons/build', //adds ability to "build regular expressions using named subpatterns, for readability and pattern reuse"
|
||||
'addons/matchrecursive', //adds ability to "match recursive constructs using XRegExp pattern strings as left and right delimiters"
|
||||
|
||||
/**Unicode support**/
|
||||
'addons/unicode/unicode-base', //required for all other unicode packages. Adds \p{Letter} category
|
||||
|
||||
//'addons/unicode/unicode-blocks', //adds support for all Unicode blocks (e.g. InArabic, InCyrillic_Extended_A, etc.)
|
||||
'addons/unicode/unicode-categories', //adds support for all Unicode categories (e.g. Punctuation, Lowercase_Letter, etc.)
|
||||
//'addons/unicode/unicode-properties', //adds Level 1 Unicode properties (e.g. Uppercase, White_Space, etc.)
|
||||
//'addons/unicode/unicode-scripts' //adds support for all Unicode scripts (e.g. Gujarati, Cyrillic, etc.)
|
||||
'addons/unicode/unicode-zotero' //adds support for some Unicode categories used in Zotero
|
||||
];
|
|
@ -195,37 +195,41 @@ function makeZoteroContext(isConnector) {
|
|||
zContext.Zotero = function() {};
|
||||
}
|
||||
|
||||
var subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||
|
||||
// Load zotero.js first
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext);
|
||||
|
||||
// Load CiteProc into Zotero.CiteProc namespace
|
||||
zContext.Zotero.CiteProc = {"Zotero":zContext.Zotero};
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
|
||||
|
||||
//Load XRegExp object into Zotero.XRegExp
|
||||
//This needs to be loaded before Zotero.Utilities so it gets included in Zotero.Utilities.Translate
|
||||
//The files that need to be loaded are defined in the init.js file
|
||||
var xregexpContext = {};
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/xregexp/init.js", xregexpContext);
|
||||
for(var i=0; i<xregexpContext.load.length; i++) {
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpContext.load[i] + ".js", xregexpContext);
|
||||
// Load XRegExp object into Zotero.XRegExp
|
||||
const xregexpFiles = [
|
||||
/**Core functions**/
|
||||
'xregexp',
|
||||
|
||||
/**Addons**/
|
||||
'addons/build', //adds ability to "build regular expressions using named subpatterns, for readability and pattern reuse"
|
||||
'addons/matchrecursive', //adds ability to "match recursive constructs using XRegExp pattern strings as left and right delimiters"
|
||||
|
||||
/**Unicode support**/
|
||||
'addons/unicode/unicode-base', //required for all other unicode packages. Adds \p{Letter} category
|
||||
|
||||
//'addons/unicode/unicode-blocks', //adds support for all Unicode blocks (e.g. InArabic, InCyrillic_Extended_A, etc.)
|
||||
'addons/unicode/unicode-categories', //adds support for all Unicode categories (e.g. Punctuation, Lowercase_Letter, etc.)
|
||||
//'addons/unicode/unicode-properties', //adds Level 1 Unicode properties (e.g. Uppercase, White_Space, etc.)
|
||||
//'addons/unicode/unicode-scripts' //adds support for all Unicode scripts (e.g. Gujarati, Cyrillic, etc.)
|
||||
'addons/unicode/unicode-zotero' //adds support for some Unicode categories used in Zotero
|
||||
];
|
||||
for (var i=0; i<xregexpFiles.length; i++) {
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpFiles[i] + ".js", zContext);
|
||||
}
|
||||
zContext.Zotero.XRegExp = xregexpContext.XRegExp;
|
||||
|
||||
// Load remaining xpcomFiles
|
||||
for (var i=1; i<xpcomFilesAll.length; i++) {
|
||||
try {
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[i] + ".js", zContext);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError("Error loading " + xpcomFilesAll[i] + ".js", zContext);
|
||||
|
@ -236,9 +240,7 @@ function makeZoteroContext(isConnector) {
|
|||
// Load xpcomFiles for specific mode
|
||||
for each(var xpcomFile in (isConnector ? xpcomFilesConnector : xpcomFilesLocal)) {
|
||||
try {
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFile + ".js", zContext);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError("Error loading " + xpcomFile + ".js", zContext);
|
||||
|
@ -259,22 +261,16 @@ function makeZoteroContext(isConnector) {
|
|||
];
|
||||
zContext.Zotero.RDF = {Zotero:zContext.Zotero};
|
||||
for (var i=0; i<rdfXpcomFiles.length; i++) {
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", zContext.Zotero.RDF);
|
||||
}
|
||||
|
||||
if(isStandalone()) {
|
||||
// If isStandalone, load standalone.js
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext);
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/standalone.js", zContext);
|
||||
}
|
||||
|
||||
// load nsTransferable (query: do we still use this?)
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://global/content/nsTransferable.js", zContext);
|
||||
subscriptLoader.loadSubScript("chrome://global/content/nsTransferable.js", zContext);
|
||||
|
||||
// add connector-related properties
|
||||
zContext.Zotero.isConnector = isConnector;
|
||||
|
|
Loading…
Reference in New Issue
Block a user