Update translation-server-v2 dependent files to be commonJS compatible
Also some minor misc changes to translate.js
This commit is contained in:
parent
3c82263082
commit
5425c272b2
8 changed files with 68 additions and 45 deletions
|
@ -17029,3 +17029,9 @@ CSL.parseParticles = function(){
|
|||
}
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = CSL;
|
||||
}
|
||||
|
||||
|
|
|
@ -911,3 +911,7 @@ Zotero.Date = new function(){
|
|||
return _localeDateOrder;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.Date;
|
||||
}
|
||||
|
|
|
@ -505,3 +505,7 @@ Zotero.OpenURL = new function() {
|
|||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.OpenURL;
|
||||
}
|
||||
|
|
|
@ -268,4 +268,7 @@ const TLDS = {
|
|||
"za":true,
|
||||
"zm":true,
|
||||
"zw":true
|
||||
};
|
||||
};
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = TLDS;
|
||||
}
|
|
@ -147,6 +147,25 @@ Zotero.Translate.Sandbox = {
|
|||
if(item.tags) item.tags = translate._cleanTags(item.tags);
|
||||
}
|
||||
|
||||
if(item.attachments) {
|
||||
var attachments = item.attachments;
|
||||
for(var j=0; j<attachments.length; j++) {
|
||||
var attachment = attachments[j];
|
||||
|
||||
// Don't save documents as documents in connector, since we can't pass them around
|
||||
if((Zotero.isConnector || Zotero.isServer) && attachment.document) {
|
||||
attachment.url = attachment.document.documentURI || attachment.document.URL;
|
||||
attachment.mimeType = "text/html";
|
||||
delete attachment.document;
|
||||
}
|
||||
|
||||
// If we're not in a child translator, canonicalize tags
|
||||
if (!translate._parentTranslator) {
|
||||
if(attachment.tags !== undefined) attachment.tags = translate._cleanTags(attachment.tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we're not supposed to save the item or we're in a child translator,
|
||||
// just return the item array
|
||||
if(translate._libraryID === false || translate._parentTranslator) {
|
||||
|
@ -161,25 +180,6 @@ Zotero.Translate.Sandbox = {
|
|||
|
||||
// We use this within the connector to keep track of items as they are saved
|
||||
if(!item.id) item.id = Zotero.Utilities.randomString();
|
||||
|
||||
if(item.attachments) {
|
||||
var attachments = item.attachments;
|
||||
for(var j=0; j<attachments.length; j++) {
|
||||
var attachment = attachments[j];
|
||||
|
||||
// Don't save documents as documents in connector, since we can't pass them around
|
||||
if(Zotero.isConnector && attachment.document) {
|
||||
attachment.url = attachment.document.documentURI || attachment.document.URL;
|
||||
attachment.mimeType = "text/html";
|
||||
delete attachment.document;
|
||||
}
|
||||
|
||||
// If we're not in a child translator, canonicalize tags
|
||||
if (!translate._parentTranslator) {
|
||||
if(attachment.tags !== undefined) attachment.tags = translate._cleanTags(attachment.tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(item.notes) {
|
||||
var notes = item.notes;
|
||||
|
@ -954,9 +954,14 @@ Zotero.Translate.Base.prototype = {
|
|||
/**
|
||||
* Sets the translator to be used for import/export
|
||||
*
|
||||
* @param {Zotero.Translator|string} Translator object or ID
|
||||
* @param {Array{Zotero.Translator}|Zotero.Translator|string} Translator object or ID
|
||||
*/
|
||||
"setTranslator":function(translator) {
|
||||
// Accept an array of translators
|
||||
if (Array.isArray(translator)) {
|
||||
this.translator = translator;
|
||||
return true;
|
||||
}
|
||||
if(!translator) {
|
||||
throw new Error("No translator specified");
|
||||
}
|
||||
|
@ -2655,20 +2660,6 @@ Zotero.Translate.Search.prototype.getTranslators = function() {
|
|||
return Zotero.Translate.Base.prototype.getTranslators.call(this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the translator or translators to be used for search
|
||||
*
|
||||
* @param {Zotero.Translator|string} Translator object or ID
|
||||
*/
|
||||
Zotero.Translate.Search.prototype.setTranslator = function(translator) {
|
||||
// Accept an array of translators
|
||||
if (Array.isArray(translator)) {
|
||||
this.translator = translator;
|
||||
return true;
|
||||
}
|
||||
return Zotero.Translate.Base.prototype.setTranslator.apply(this, [translator]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload Zotero.Translate.Base#complete to move onto the next translator if
|
||||
* translation fails
|
||||
|
@ -3203,4 +3194,8 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
}
|
||||
return returnArray;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.Translate;
|
||||
}
|
||||
|
|
|
@ -1978,5 +1978,9 @@ Zotero.Utilities = {
|
|||
* Provides unicode support and other additional features for regular expressions
|
||||
* See https://github.com/slevithan/xregexp for usage
|
||||
*/
|
||||
"XRegExp": XRegExp
|
||||
"XRegExp": typeof XRegExp !== "undefined" ? XRegExp : null
|
||||
}
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.Utilities;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ Zotero.Utilities.Internal = {
|
|||
* @param {Function} func - A promise-returning function
|
||||
* @return {Array} The return values from the successive runs
|
||||
*/
|
||||
"forEachChunkAsync": Zotero.Promise.coroutine(function* (arr, chunkSize, func) {
|
||||
"forEachChunkAsync": async function (arr, chunkSize, func) {
|
||||
var retValues = [];
|
||||
var tmpArray = arr.concat();
|
||||
var num = arr.length;
|
||||
|
@ -49,12 +49,12 @@ Zotero.Utilities.Internal = {
|
|||
do {
|
||||
var chunk = tmpArray.splice(0, chunkSize);
|
||||
done += chunk.length;
|
||||
retValues.push(yield func(chunk));
|
||||
retValues.push(await func(chunk));
|
||||
}
|
||||
while (done < num);
|
||||
|
||||
return retValues;
|
||||
}),
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
|
@ -202,7 +202,7 @@ Zotero.Utilities.Internal = {
|
|||
},
|
||||
|
||||
|
||||
gzip: Zotero.Promise.coroutine(function* (data) {
|
||||
gzip: async function (data) {
|
||||
var deferred = Zotero.Promise.defer();
|
||||
|
||||
// Get input stream from POST data
|
||||
|
@ -258,10 +258,10 @@ Zotero.Utilities.Internal = {
|
|||
pump.asyncRead(converter, null);
|
||||
|
||||
return deferred.promise;
|
||||
}),
|
||||
},
|
||||
|
||||
|
||||
gunzip: Zotero.Promise.coroutine(function* (data) {
|
||||
gunzip: async function (data) {
|
||||
var deferred = Zotero.Promise.defer();
|
||||
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
@ -318,7 +318,7 @@ Zotero.Utilities.Internal = {
|
|||
pump.asyncRead(converter, null);
|
||||
|
||||
return deferred.promise;
|
||||
}),
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1838,3 +1838,6 @@ Zotero.Utilities.Internal.Base64 = {
|
|||
return string;
|
||||
}
|
||||
}
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.Utilities.Internal;
|
||||
}
|
||||
|
|
|
@ -381,4 +381,8 @@ for(var j in Zotero.Utilities.Translate.prototype) {
|
|||
if(typeof Zotero.Utilities.Translate.prototype[j] === "function" && j[0] !== "_" && j != "Translate") {
|
||||
Zotero.Utilities.Translate.prototype.__exposedProps__[j] = "r";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||
module.exports = Zotero.Utilities.Translate;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue