windingwind / zotero-pdf-translate

Translate PDF, EPub, webpage, metadata, annotations, notes to the target language. Support 20+ translate services.
GNU Affero General Public License v3.0
6.15k stars 304 forks source link

[Bug] Cannot Use Self Build Version of This Plugin #597

Closed tylzh97 closed 7 months ago

tylzh97 commented 7 months ago

Before Issue/提问之前

  1. See #6 and search the Issues Page to make sure this is not a duplicated issue;
  2. If this is a bug with Translate, i.e. no result or error, make sure you can access the translate service and the secret is currect;

Issues not in the template format will be ignored/不按模板格式或不完整填写模板内容的提问将不会被回复。如果你看不懂英文可以用中文提问,但请有礼貌地详细描述你的问题。如果不详细说明通过什么步骤可以复现问题,具体表现是什么,你正在使用哪个版本的插件,我没办法帮到你。不要浪费大家的时间!!!

Edit the template below and delete the section above/必须准确详细地填写编辑以下提问模版,并删除上面的内容,否则不会被回复

Describe the bug I want to modify some translation APIs, But I cannot correctly build zotero-pf-translate.xpi with commands npm run build. There are 2 problems:

  1. I can build successfuly in main branch. But it Cannot Install in Zotero.
  2. tsc build error when I trying build old version plugin.

To Reproduce

In avoid of enviroment problem. All these trying work in Github Codespace. I'm trying to install plugins to the latest version I download in https://www.zotero.org/download/, which version tag is v6.0.27


For Problem 1, I tryed following:

$ rm -rf builds/ node_modules/
$ git checkout main
$ npm install
$ npm run build

It seems build correctly, But Zotero show it's an incompatible version(Like following screenshot). I guess maybe the default build version is for Zotero 7?


For Problem 2; During my own usage, I have been using version v1.0.22, so I choose to make modifications on this version. I tryed following:

$ rm -rf builds/ node_modules/
$ git checkout v1.0.22
$ npm install
$ npm run build

there are some tsc build error like following:

@tylzh97 ➜ /workspaces/zotero-pdf-translate (075b1a4) $ npm run build

> zotero-pdf-translate@1.0.22 build
> concurrently -c auto npm:build-prod npm:tsc

[build-prod] 
[build-prod] > zotero-pdf-translate@1.0.22 build-prod
[build-prod] > cross-env NODE_ENV=production node scripts/build.js
[build-prod] 
[tsc] 
[tsc] > zotero-pdf-translate@1.0.22 tsc
[tsc] > tsc --noEmit
[tsc] 
[build-prod] [Build] BUILD_DIR=builds, VERSION=1.0.22, BUILD_TIME=2023-09-22 08:20:56, ENV=production
[build-prod] [Build] Run esbuild OK
[build-prod] [Build] Run replace in  [
[build-prod]   'builds/addon/install.rdf : 9 / 9',
[build-prod]   'builds/addon/chrome/locale/en-US/overlay.dtd : 48 / 48',
[build-prod]   'builds/addon/chrome/locale/zh-CN/overlay.dtd : 48 / 48',
[build-prod]   'builds/addon/chrome/content/preferences.xhtml : 90 / 90',
[build-prod]   'builds/addon/chrome/content/standalone.xhtml : 2 / 2',
[build-prod]   'builds/addon/manifest.json : 6 / 6',
[build-prod]   'builds/addon/prefs.js : 42 / 42',
[build-prod]   'builds/addon/chrome.manifest : 3 / 3',
[build-prod]   'builds/addon/bootstrap.js : 4 / 4',
[build-prod]   'update.json : 5 / 5',
[build-prod]   'update.rdf : 4 / 4'
[build-prod] ]
[build-prod] [Build] Replace OK
[build-prod] [Build] Addon prepare OK
[build-prod] [Build] Addon pack OK
[build-prod] [Build] Finished in 0.185 s.
[build-prod] npm run build-prod exited with code 0
[tsc] src/modules/popup.ts(209,19): error TS18048: 'readerInstance._iframe' is possibly 'undefined'.
[tsc] src/modules/popup.ts(233,19): error TS18048: 'readerInstance._iframe' is possibly 'undefined'.
[tsc] src/modules/reader.ts(50,16): error TS2339: Property '_pdftranslateInitialized' does not exist on type 'ReaderInstance'.
[tsc] src/modules/reader.ts(53,12): error TS2339: Property '_pdftranslateInitialized' does not exist on type 'ReaderInstance'.
[tsc] src/modules/reader.ts(68,12): error TS2339: Property '_pdftranslateSelectionCallback' does not exist on type 'ReaderInstance'.
[tsc] src/modules/reader.ts(76,17): error TS2339: Property '_pdftranslateInitialized' does not exist on type 'ReaderInstance'.
[tsc] src/modules/reader.ts(81,14): error TS2339: Property '_pdftranslateSelectionCallback' does not exist on type 'ReaderInstance'.
[tsc] src/modules/reader.ts(83,12): error TS2339: Property '_pdftranslateInitialized' does not exist on type 'ReaderInstance'.
[tsc] npm run tsc exited with code 2

Expected behavior Install and use Correctly.

Screenshots image

Environment

Additional context Add any other context about the problem here.

windingwind commented 7 months ago

NPM will install the maximal version that matches package.json. The package zotero-types hasn't had major updates since the 1.0.22 build, so you are probably using the latest version of zotero-types. So manually run npm install zotero-types@xxx (use the actual version in your package.json) would help.

tsc error does not break the building process. Your plugin is still successfully built to a xpi file.

tylzh97 commented 7 months ago

NPM will install the maximal version that matches package.json. The package zotero-types hasn't had major updates since the 1.0.22 build, so you are probably using the latest version of zotero-types. So manually run npm install zotero-types@xxx (use the actual version in your package.json) would help.

tsc error does not break the building process. Your plugin is still successfully built to a xpi file.

Thanks! I will try to install specify version of zotero-types. But which branch I should develop in, main or z6?

tylzh97 commented 7 months ago

After install specific version of zotero-types, Still, Plugin install failed: The add-on "%S" could not be installed. It may be incompatible with this version of Zotero.

windingwind commented 7 months ago
  1. the main branch only supports zotero 7
  2. we recommend using main, as there probably won't be new updates for Zotero 6
  3. you can debug your PR on the 1.0.22 and merge it to main
sevenantonio commented 7 months ago

我好像也是相同問題,在官網載了z6並安裝此附件最新版本時 image

sevenantonio commented 7 months ago

沒事了,安裝了z7@@

tylzh97 commented 7 months ago

I still got some problem. I'm trying build this plugin v1.0.22. As you said, tsc error do not break the building process, I got xpi file in ./build directory. I install this plugin successfully, but it seems works not correctly. There is no translation config in Zotero Perferences page. Errors in following:

[JavaScript Error: "WeakRef is not defined" {file: "resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js" line: 7110}]
createElement@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:7110:15
addStyle@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:9727:25
initializeUI@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:9267:11
node_modules/zotero-plugin-toolkit/dist/managers/prompt.js/Prompt<@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:9261:11
node_modules/zotero-plugin-toolkit/dist/managers/prompt.js/PromptManager2<@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:9906:36
ZToolkit<@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:14013:21
Addon<@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:13981:19
@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:14040:25
@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/chrome/content/scripts/index.js:2:1
startup@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///C:/Users/Admin/AppData/Roaming/Zotero/Zotero/Profiles/tympuzwq.default/extensions/zoteropdftranslate@euclpts.com.xpi!/bootstrap.js:94:3

version => 6.0.27, platform => Win32, oscpu => Windows NT 10.0; WOW64, locale => en-US, appName => Zotero, appVersion => 6.0.27, extensions => Zotero LibreOffice Integration (6.0.4.SA.6.0.27, extension), Zotero Word for Windows Integration (6.0.3.SA.6.0.27, extension), Zotero PDF Translate (1.0.22, extension)

image

windingwind commented 7 months ago

Again, you don’t have the correct version of dependency zotero-plugin-toolkit installed. Please install the specific version manually.

tylzh97 commented 7 months ago

I got it, Thanks!