diff --git a/.eslintrc.js b/.eslintrc.js index 3c78bf58ca..d83c9c77da 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,7 +36,7 @@ const config = { singleline: { delimiter: 'semi', requireLast: false } }], '@stylistic/array-bracket-spacing': ['error', 'always', { singleValue: false }], - '@stylistic/object-curly-spacing': ['error', 'always', { arraysInObjects: false, objectsInObjects: false }], + '@stylistic/object-curly-spacing': 'off', '@stylistic/new-parens': ['error', 'never'], '@stylistic/quote-props': [ 'error', 'as-needed' ], '@stylistic/arrow-parens': [ 'error', 'as-needed' ], diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6306103653..36535d4e82 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,6 +31,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' + cache: pip + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install packaging xvfbwrapper + pip install -r requirements.txt - name: install node uses: actions/setup-node@v4 with: @@ -43,15 +49,8 @@ jobs: with: path: | ~/.npm - ~/.nocache/pip - ${{ env.pythonLocation }} - key: ${{ runner.os }}-build-${{ env.pythonLocation }}-${{ env.cache-name }}-${{ - hashFiles('package-lock.json') }}-${{ hashFiles('requirements.txt') }} - - name: install python packages - run: | - python -m pip install --upgrade pip - pip install packaging xvfbwrapper - pip install -r requirements.txt + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') + }}-${{ hashFiles('requirements.txt') }} - name: install node packages run: npm install @@ -130,6 +129,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' + cache: pip + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install packaging xvfbwrapper + pip install -r requirements.txt - name: Cache python/node dependencies id: cache uses: actions/cache@v4 @@ -138,15 +143,8 @@ jobs: with: path: | ~/.npm - ~/.nocache/pip - ${{ env.pythonLocation }} - key: ${{ runner.os }}-build-${{ env.pythonLocation }}-${{ env.cache-name }}-${{ - hashFiles('package-lock.json') }}-${{ hashFiles('requirements.txt') }} - - name: install python packages - run: | - python -m pip install --upgrade pip - pip install packaging xvfbwrapper - pip install -r requirements.txt + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') + }}-${{ hashFiles('requirements.txt') }} - name: install ${{ matrix.client }} run: | @@ -221,6 +219,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' + cache: pip + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install packaging xvfbwrapper + pip install -r requirements.txt - name: install node uses: actions/setup-node@v4 with: @@ -233,15 +237,8 @@ jobs: with: path: | ~/.npm - ~/.nocache/pip - ${{ env.pythonLocation }} - key: ${{ runner.os }}-build-${{ env.pythonLocation }}-${{ env.cache-name }}-${{ - hashFiles('package-lock.json') }}-${{ hashFiles('requirements.txt') }} - - name: install python packages - run: | - python -m pip install --upgrade pip - pip install packaging xvfbwrapper - pip install -r requirements.txt + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') + }}-${{ hashFiles('requirements.txt') }} - name: install node packages run: npm install @@ -274,6 +271,12 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' + cache: pip + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install packaging xvfbwrapper + pip install -r requirements.txt - name: fetch test artifacts uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/src/ci.yaml b/.github/workflows/src/ci.yaml index a3daf976d3..f0bd045ccd 100644 --- a/.github/workflows/src/ci.yaml +++ b/.github/workflows/src/ci.yaml @@ -15,6 +15,7 @@ _anchors: uses: actions/setup-python@v5 with: python-version: '3.10' + cache: 'pip' install_node: &install_node name: install node uses: actions/setup-node@v4 @@ -29,9 +30,7 @@ _anchors: with: path: | ~/.npm - ~/.nocache/pip - ${{ env.pythonLocation }} - key: ${{ runner.os }}-build-${{ env.pythonLocation }}-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('requirements.txt') }} install_python_packages: &install_python_packages name: install python packages run: | @@ -63,9 +62,9 @@ jobs: if: github.event.head_commit.message == env.version && !startsWith(github.ref, 'refs/tags/') - *install_python + - *install_python_packages - *install_node - *cache - - *install_python_packages - *install_node_packages - name: set slow/legacy/beta flags run: ./util/action-flags @@ -133,8 +132,8 @@ jobs: with: name: build-artifacts - *install_python - - *cache - *install_python_packages + - *cache - name: install ${{ matrix.client }} run: | @@ -200,9 +199,9 @@ jobs: with: name: build-artifacts - *install_python + - *install_python_packages - *install_node - *cache - - *install_python_packages - *install_node_packages - run: npm run release @@ -230,6 +229,7 @@ jobs: steps: - uses: actions/checkout@v4 - *install_python + - *install_python_packages - name: fetch test artifacts uses: actions/download-artifact@v4 with: diff --git a/content/ZoteroPane.ts b/content/ZoteroPane.ts index 026fc99590..059063bd35 100644 --- a/content/ZoteroPane.ts +++ b/content/ZoteroPane.ts @@ -127,7 +127,7 @@ class ZoteroPane { const items = zp.getSelectedItems() toClipboard(await Translators.queueJob({ translatorID, - displayOptions: {}, + displayOptions: { worker: true }, scope: { type: 'items', items }, })) } @@ -414,7 +414,7 @@ class ZoteroPane { try { return await Translators.queueJob({ translatorID: Translators.bySlug.BetterBibTeXJSON.translatorID, - displayOptions: { exportNotes: true, dropAttachments: true, Normalize: true }, + displayOptions: { worker: true, exportNotes: true, dropAttachments: true, Normalize: true }, scope, timeout: 40, }) diff --git a/content/auto-export.ts b/content/auto-export.ts index 9de50598c0..25827941c4 100644 --- a/content/auto-export.ts +++ b/content/auto-export.ts @@ -305,6 +305,7 @@ const queue = new class TaskQueue { useJournalAbbreviation: ae.useJournalAbbreviation, biblatexAPA: ae.biblatexAPA || false, biblatexChicago: ae.biblatexChicago || false, + worker: true, } const jobs: ExportJob[] = [{ diff --git a/content/better-bibtex.ts b/content/better-bibtex.ts index f3abc579bb..30bb66a311 100644 --- a/content/better-bibtex.ts +++ b/content/better-bibtex.ts @@ -498,7 +498,7 @@ $Patcher$.schedule(Zotero.Translate.Export.prototype, 'translate', original => f if (useWorker) { return Translators.queueJob({ translatorID, - displayOptions, + displayOptions: {...displayOptions, worker: true}, translate: this, scope: { ...this._export, getter: this._itemGetter }, path: this.location?.path, diff --git a/content/cayw/formatter.ts b/content/cayw/formatter.ts index 94efe3b3b8..a52bfe271a 100644 --- a/content/cayw/formatter.ts +++ b/content/cayw/formatter.ts @@ -285,6 +285,7 @@ export const Formatter = new class { // eslint-disable-line @typescript-eslint/n const displayOptions = { exportNotes: [ 'yes', 'y', 'true' ].includes((options.exportNotes || '').toLowerCase()), useJournalAbbreviation: [ 'yes', 'y', 'true' ].includes((options.useJournalAbbreviation || '').toLowerCase()), + worker: !options.worker || [ 'yes', 'y', 'true' ].includes((options.worker || '').toLowerCase()), } return await Translators.queueJob({ translatorID, displayOptions, scope: { type: 'items', items }}) diff --git a/content/json-rpc.ts b/content/json-rpc.ts index 7193337698..f6375a5e7b 100644 --- a/content/json-rpc.ts +++ b/content/json-rpc.ts @@ -495,7 +495,7 @@ class NSItem { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return await Translators.queueJob({ translatorID: Translators.getTranslatorId(translator), - displayOptions: {}, + displayOptions: { worker: true }, scope: { type: 'items', items: await getItemsAsync(found.map(key => key.itemID)) }, // eslint-disable-line @typescript-eslint/no-unsafe-return }) } @@ -537,7 +537,7 @@ class NSItem { // I need the cleanup BCJ does const csl = JSON.parse(await Translators.queueJob({ translatorID: Translators.getTranslatorId('Better CSL JSON'), - displayOptions: { custom: true }, + displayOptions: { worker: true, custom: true }, scope: { type: 'items', items }, })) diff --git a/content/logger.ts b/content/logger.ts index 76f97bacd6..57a7fd235a 100644 --- a/content/logger.ts +++ b/content/logger.ts @@ -67,8 +67,8 @@ function to_s(obj: any): string { return JSON.stringify(obj, replacer(), 2) } -export function format(...msg): void { - msg.map(to_s).join(' ') +export function format(...msg): string { + return msg.map(to_s).join(' ') } export const log = new class { diff --git a/content/translators.ts b/content/translators.ts index e7bd2c6cc6..cbb44a6acf 100644 --- a/content/translators.ts +++ b/content/translators.ts @@ -4,6 +4,7 @@ import { Shim } from './os' import * as client from './client' const $OS = client.is7 ? Shim : OS import merge from 'lodash.merge' +import { pick } from './object' import { Cache } from './db/cache' import { Serializer } from './item-export-format' @@ -224,25 +225,14 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint } public async queueJob(job: ExportJob): Promise { - return await this.queue.add(async () => { - const translator = this.byId[job.translatorID] - const displayOptions = this.displayOptions(job.translatorID, job.displayOptions) - if (typeof translator?.displayOptions.worker === 'boolean' && displayOptions.worker) { - return await this.exportItemsByWorker(job) - } - else { - return await this.exportItems(job) - } - }) + return await this.queue.add(() => this.exportItems(job)) } private async exportItemsByWorker(job: ExportJob): Promise { - // trace('exportItemsByWorker: requested') if (job.path && job.canceled) return '' await Zotero.BetterBibTeX.ready if (job.path && job.canceled) return '' - // trace('exportItemsByWorker: preparing') const displayOptions = { ...this.displayOptions(job.translatorID, job.displayOptions), exportPath: job.path || undefined, @@ -372,9 +362,7 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint }, }) - // trace('exportItemsByWorker: starting cache completion') await Cache.ZoteroSerialized.fill(items, this.serializer) - // trace('exportItemsByWorker: cache completion completed') config.data.items = items.map(item => item.id) prepare.update() @@ -391,7 +379,6 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint prepare.done() - // trace('exportItemsByWorker: prepare finished') this.worker.postMessage({ kind: 'start', config }) if (typeof job.timeout === 'number') { @@ -413,13 +400,15 @@ export const Translators = new class { // eslint-disable-line @typescript-eslint } public displayOptions(translatorID: string, displayOptions: any): any { - return merge({}, this.byId[translatorID]?.displayOptions || {}, displayOptions) + const defaults = this.byId[translatorID]?.displayOptions || {} + return pick(merge({}, defaults, displayOptions), Object.keys(defaults)) } - private async exportItems(job: ExportJob): Promise { + public async exportItems(job: ExportJob): Promise { await Zotero.BetterBibTeX.ready const displayOptions = this.displayOptions(job.translatorID, job.displayOptions) + if (displayOptions.worker) return await this.exportItemsByWorker(job) const translation = new Zotero.Translate.Export diff --git a/package-lock.json b/package-lock.json index 379b996c4d..e7e3118732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zotero-better-bibtex", - "version": "6.7.257", + "version": "6.7.258", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zotero-better-bibtex", - "version": "6.7.257", + "version": "6.7.258", "license": "ISC", "dependencies": { "@artsy/to-title-case": "^1.1.0", @@ -72,7 +72,7 @@ "@retorquere/zotero-sync": "^1.0.27", "@stylistic/eslint-plugin": "^2.11.0", "@types/bluebird": "^3.5.42", - "@types/node": "^22.10.0", + "@types/node": "^22.10.1", "@xmldom/xmldom": "^0.9.5", "ajv-keywords": "^5.1.0", "archiver": "^7.0.1", @@ -132,7 +132,7 @@ "string-template": "^1.0.0", "ts-node": "^10.9.2", "tslib": "^2.8.1", - "typedoc": "^0.27.0", + "typedoc": "^0.27.1", "typescript": "^5.7.2", "unicode-11.0.0": "^0.7.8", "unicode2latex": "^6.0.6", @@ -5468,9 +5468,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.10.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.0.tgz", - "integrity": "sha512-XC70cRZVElFHfIUB40FgZOBbgJYFKKMa5nb9lxcwYstFG/Mi+/Y0bGS+rs6Dmhmkpq4pnNiLiuZAbc02YCOnmA==", + "version": "22.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", + "integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==", "license": "MIT", "dependencies": { "undici-types": "~6.20.0" @@ -19979,9 +19979,9 @@ } }, "node_modules/typedoc": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.27.0.tgz", - "integrity": "sha512-7AkTJhFdhsihthaBFHNpj5iFdLyR7FpQqXM+IABJmE1/qTjWypirCLrheToUP3fjpWHN1Drn3K7PWH1t37KvNQ==", + "version": "0.27.1", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.27.1.tgz", + "integrity": "sha512-cbFtNFpkCtHAHRvMnCDdtM2+xhO2uiJAcw4ooLmVMuaY9yLJswKvi6wOwPZgTnKKnm/HKpO/Ub6DVk4KRf/vRg==", "dev": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index a21a0c686d..a949d10b1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zotero-better-bibtex", - "version": "6.7.257", + "version": "6.7.258", "description": "Make Zotero useful for us LaTeX holdouts.", "homepage": "https://retorque.re/zotero-better-bibtex", "license": "ISC", @@ -127,7 +127,7 @@ "@retorquere/zotero-sync": "^1.0.27", "@stylistic/eslint-plugin": "^2.11.0", "@types/bluebird": "^3.5.42", - "@types/node": "^22.10.0", + "@types/node": "^22.10.1", "@xmldom/xmldom": "^0.9.5", "ajv-keywords": "^5.1.0", "archiver": "^7.0.1", @@ -187,7 +187,7 @@ "string-template": "^1.0.0", "ts-node": "^10.9.2", "tslib": "^2.8.1", - "typedoc": "^0.27.0", + "typedoc": "^0.27.1", "typescript": "^5.7.2", "unicode-11.0.0": "^0.7.8", "unicode2latex": "^6.0.6", diff --git a/setup/setup.py b/setup/setup.py index 436fa30718..bccf653cf8 100755 --- a/setup/setup.py +++ b/setup/setup.py @@ -14,4 +14,5 @@ import unicode import shutil -shutil.copyfile('submodules/zotero/chrome/content/zotero/osfile.mjs', 'gen/osfile.js') +with open('submodules/zotero/chrome/content/zotero/osfile.mjs') as i, open('gen/osfile.js', 'w') as o: + o.write(''.join([line for line in i.readlines() if 'Cu.reportError' not in line])) diff --git a/submodules/zotero b/submodules/zotero index bacb60a103..c9c373854c 160000 --- a/submodules/zotero +++ b/submodules/zotero @@ -1 +1 @@ -Subproject commit bacb60a10392f7c313b5338f44644cf15ba5bc6d +Subproject commit c9c373854c3122ed1f264314c9223600ae5c777a