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;
|
return _localeDateOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
|
module.exports = Zotero.Date;
|
||||||
|
}
|
||||||
|
|
|
@ -505,3 +505,7 @@ Zotero.OpenURL = new function() {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
|
module.exports = Zotero.OpenURL;
|
||||||
|
}
|
||||||
|
|
|
@ -269,3 +269,6 @@ const TLDS = {
|
||||||
"zm":true,
|
"zm":true,
|
||||||
"zw":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.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,
|
// if we're not supposed to save the item or we're in a child translator,
|
||||||
// just return the item array
|
// just return the item array
|
||||||
if(translate._libraryID === false || translate._parentTranslator) {
|
if(translate._libraryID === false || translate._parentTranslator) {
|
||||||
|
@ -162,25 +181,6 @@ Zotero.Translate.Sandbox = {
|
||||||
// We use this within the connector to keep track of items as they are saved
|
// 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.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) {
|
if(item.notes) {
|
||||||
var notes = item.notes;
|
var notes = item.notes;
|
||||||
for(var j=0; j<notes.length; j++) {
|
for(var j=0; j<notes.length; j++) {
|
||||||
|
@ -954,9 +954,14 @@ Zotero.Translate.Base.prototype = {
|
||||||
/**
|
/**
|
||||||
* Sets the translator to be used for import/export
|
* 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) {
|
"setTranslator":function(translator) {
|
||||||
|
// Accept an array of translators
|
||||||
|
if (Array.isArray(translator)) {
|
||||||
|
this.translator = translator;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(!translator) {
|
if(!translator) {
|
||||||
throw new Error("No translator specified");
|
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);
|
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
|
* Overload Zotero.Translate.Base#complete to move onto the next translator if
|
||||||
* translation fails
|
* translation fails
|
||||||
|
@ -3204,3 +3195,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
||||||
return returnArray;
|
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
|
* Provides unicode support and other additional features for regular expressions
|
||||||
* See https://github.com/slevithan/xregexp for usage
|
* 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
|
* @param {Function} func - A promise-returning function
|
||||||
* @return {Array} The return values from the successive runs
|
* @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 retValues = [];
|
||||||
var tmpArray = arr.concat();
|
var tmpArray = arr.concat();
|
||||||
var num = arr.length;
|
var num = arr.length;
|
||||||
|
@ -49,12 +49,12 @@ Zotero.Utilities.Internal = {
|
||||||
do {
|
do {
|
||||||
var chunk = tmpArray.splice(0, chunkSize);
|
var chunk = tmpArray.splice(0, chunkSize);
|
||||||
done += chunk.length;
|
done += chunk.length;
|
||||||
retValues.push(yield func(chunk));
|
retValues.push(await func(chunk));
|
||||||
}
|
}
|
||||||
while (done < num);
|
while (done < num);
|
||||||
|
|
||||||
return retValues;
|
return retValues;
|
||||||
}),
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +202,7 @@ Zotero.Utilities.Internal = {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
gzip: Zotero.Promise.coroutine(function* (data) {
|
gzip: async function (data) {
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
|
|
||||||
// Get input stream from POST data
|
// Get input stream from POST data
|
||||||
|
@ -258,10 +258,10 @@ Zotero.Utilities.Internal = {
|
||||||
pump.asyncRead(converter, null);
|
pump.asyncRead(converter, null);
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}),
|
},
|
||||||
|
|
||||||
|
|
||||||
gunzip: Zotero.Promise.coroutine(function* (data) {
|
gunzip: async function (data) {
|
||||||
var deferred = Zotero.Promise.defer();
|
var deferred = Zotero.Promise.defer();
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
@ -318,7 +318,7 @@ Zotero.Utilities.Internal = {
|
||||||
pump.asyncRead(converter, null);
|
pump.asyncRead(converter, null);
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}),
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1838,3 +1838,6 @@ Zotero.Utilities.Internal.Base64 = {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
|
module.exports = Zotero.Utilities.Internal;
|
||||||
|
}
|
||||||
|
|
|
@ -382,3 +382,7 @@ for(var j in Zotero.Utilities.Translate.prototype) {
|
||||||
Zotero.Utilities.Translate.prototype.__exposedProps__[j] = "r";
|
Zotero.Utilities.Translate.prototype.__exposedProps__[j] = "r";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
|
module.exports = Zotero.Utilities.Translate;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue