From bf1ff3a6fb216631dafb91413d42440dd7feecfe Mon Sep 17 00:00:00 2001 From: Northword <44738481+northword@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:47:36 +0800 Subject: [PATCH] fix: chrome/content -> content (#213) --- README.md | 79 ++++++++---------- addon/bootstrap.js | 6 +- addon/{chrome => }/content/icons/favicon.png | Bin .../content/icons/favicon@0.5x.png | Bin addon/{chrome => }/content/preferences.xhtml | 0 addon/{chrome => }/content/zoteroPane.css | 0 addon/manifest.json | 4 +- doc/README-zhCN.md | 77 ++++++++--------- src/modules/examples.ts | 2 +- src/modules/preferenceScript.ts | 2 +- zotero-plugin.config.ts | 2 +- 11 files changed, 79 insertions(+), 93 deletions(-) rename addon/{chrome => }/content/icons/favicon.png (100%) rename addon/{chrome => }/content/icons/favicon@0.5x.png (100%) rename addon/{chrome => }/content/preferences.xhtml (100%) rename addon/{chrome => }/content/zoteroPane.css (100%) diff --git a/README.md b/README.md index 808d0ea..9057e82 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ Steps of build: - Prepare locale files to [avoid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts) - Rename `**/*.flt` to `**/${addonRef}-*.flt` - Prefix each fluent message with `addonRef-` -- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/chrome/content/scripts`. +- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/content/scripts`. - (Production mode only) Zip the `./build/addon` to `./build/*.xpi` - (Production mode only) Prepare `update.json` or `update-beta.json` @@ -271,7 +271,7 @@ npm run release > [!note] > This will use [Bumpp](https://github.com/antfu-collective/bumpp) to prompt for the new version number, locally bump the version, run any (pre/post)version scripts defined in `package.json`, commit, build (optional), tag the commit with the version number and push commits and git.tags. Bumpp can be configured in `zotero-plugin-config.ts`; for example, add `release: { bumpp: { execute: "npm run build" } }` to also build before committing. -> +> > Subsequently GitHub Action will rebuild the plugin and use `zotero-plugin-scaffold`'s `release` script to publish the XPI to GitHub Release. In addition, a separate release (tag: `release`) will be created or updated that includes update manifests `update.json` and `update-beta.json` as assets. These will be available at `https://github.com/{{owner}}/{{repo}}/releases/download/release/update*.json`. #### About Prerelease @@ -340,70 +340,63 @@ This section shows the directory structure of a template. - All `.js/.ts` code files are in `./src`; - Addon config files: `./addon/manifest.json`; -- UI files: `./addon/chrome/content/*.xhtml`. +- UI files: `./addon/content/*.xhtml`. - Locale files: `./addon/locale/**/*.flt`; - Preferences file: `./addon/prefs.js`; - > Don't break the lines in the `prefs.js` ```shell . -|-- .eslintrc.json # eslint conf -|-- .gitattributes # git conf |-- .github/ # github conf -|-- .gitignore # git conf -|-- .prettierrc # prettier conf -|-- .release-it.json # release-it conf -|-- .vscode # vs code conf -| |-- extensions.json -| |-- launch.json -| |-- setting.json -| `-- toolkit.code-snippets -|-- package-lock.json # npm conf -|-- package.json # npm conf -|-- LICENSE -|-- README.md -|-- addon -| |-- bootstrap.js # addon load/unload script, like a main.c -| |-- chrome -| | `-- content -| | |-- icons/ -| | |-- preferences.xhtml # preference panel -| | `-- zoteroPane.css -| |-- locale # locale +|-- .vscode/ # vscode conf +|-- addon # static files +| |-- bootstrap.js +| |-- content +| | |-- icons +| | | |-- favicon.png +| | | `-- favicon@0.5x.png +| | |-- preferences.xhtml +| | `-- zoteroPane.css +| |-- locale | | |-- en-US | | | |-- addon.ftl +| | | |-- mainWindow.ftl | | | `-- preferences.ftl | | `-- zh-CN | | |-- addon.ftl +| | |-- mainWindow.ftl | | `-- preferences.ftl -| |-- manifest.json # addon config +| |-- manifest.json | `-- prefs.js -|-- build/ # build dir -|-- scripts # scripts for dev -| |-- build.mjs # script to build plugin -| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc -| |-- server.mjs # script to start a development server -| |-- start.mjs # script to start Zotero process -| |-- stop.mjs # script to kill Zotero process -| |-- utils.mjs # utils functions for dev scripts -| |-- update-template.json # template of `update.json` -| `-- zotero-cmd-template.json # template of local env -|-- src # source code +|-- build # build dir +|-- node_modules +|-- src # source code of scripts | |-- addon.ts # base class | |-- hooks.ts # lifecycle hooks | |-- index.ts # main entry | |-- modules # sub modules | | |-- examples.ts | | `-- preferenceScript.ts -| `-- utils # utilities +| `-- utils # utilities | |-- locale.ts | |-- prefs.ts | |-- wait.ts -| `-- window.ts -|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig -|-- typings # ts typings +| |-- window.ts +| `-- ztoolkit.ts +|-- typings # ts typings | `-- global.d.ts -`-- update.json + +|-- .env # enviroment config (do not check into repo) +|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold +|-- .gitignore # git conf +|-- .gitattributes # git conf +|-- .prettierrc # prettier conf, https://prettier.io/ +|-- eslint.config.mjs # eslint conf, https://eslint.org/ +|-- LICENSE +|-- package-lock.json +|-- package.json +|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig +|-- README.md +`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold ``` ## Disclaimer diff --git a/addon/bootstrap.js b/addon/bootstrap.js index 03c5493..00125ed 100644 --- a/addon/bootstrap.js +++ b/addon/bootstrap.js @@ -24,7 +24,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) { ].getService(Components.interfaces.amIAddonManagerStartup); var manifestURI = Services.io.newURI(rootURI + "manifest.json"); chromeHandle = aomStartup.registerChrome(manifestURI, [ - ["content", "__addonRef__", rootURI + "chrome/content/"], + ["content", "__addonRef__", rootURI + "content/"], ]); /** @@ -39,7 +39,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) { ctx._globalThis = ctx; Services.scriptloader.loadSubScript( - `${rootURI}/chrome/content/scripts/__addonRef__.js`, + `${rootURI}/content/scripts/__addonRef__.js`, ctx, ); Zotero.__addonInstance__.hooks.onStartup(); @@ -69,7 +69,7 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) { .getService(Components.interfaces.nsIStringBundleService) .flushBundles(); - Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`); + Cu.unload(`${rootURI}/content/scripts/__addonRef__.js`); if (chromeHandle) { chromeHandle.destruct(); diff --git a/addon/chrome/content/icons/favicon.png b/addon/content/icons/favicon.png similarity index 100% rename from addon/chrome/content/icons/favicon.png rename to addon/content/icons/favicon.png diff --git a/addon/chrome/content/icons/favicon@0.5x.png b/addon/content/icons/favicon@0.5x.png similarity index 100% rename from addon/chrome/content/icons/favicon@0.5x.png rename to addon/content/icons/favicon@0.5x.png diff --git a/addon/chrome/content/preferences.xhtml b/addon/content/preferences.xhtml similarity index 100% rename from addon/chrome/content/preferences.xhtml rename to addon/content/preferences.xhtml diff --git a/addon/chrome/content/zoteroPane.css b/addon/content/zoteroPane.css similarity index 100% rename from addon/chrome/content/zoteroPane.css rename to addon/content/zoteroPane.css diff --git a/addon/manifest.json b/addon/manifest.json index 0c356c6..53cab4b 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -6,8 +6,8 @@ "homepage_url": "__homepage__", "author": "__author__", "icons": { - "48": "chrome/content/icons/favicon@0.5x.png", - "96": "chrome/content/icons/favicon.png" + "48": "content/icons/favicon@0.5x.png", + "96": "content/icons/favicon.png" }, "applications": { "zotero": { diff --git a/doc/README-zhCN.md b/doc/README-zhCN.md index ca46f18..a1546aa 100644 --- a/doc/README-zhCN.md +++ b/doc/README-zhCN.md @@ -251,7 +251,7 @@ Obsidian风格的指令输入模块,它通过接受文本来运行插件,并 - 准备本地化文件以避免冲突,查看官方文档了解更多( - 重命名`**/*.flt` 为 `**/${addonRef}-*.flt` - 在每个消息前加上 `addonRef-` -- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/chrome/content/scripts` +- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/content/scripts` - (仅在生产模式下工作) 压缩 `./build/addon` 目录为 `./build/*.xpi` - (仅在生产模式下工作) 准备 `update.json` 或 `update-beta.json` @@ -340,70 +340,63 @@ Zotero 文档已过时且不完整,克隆 - 所有的 `.js/.ts` 代码都在 `./src`; - 插件配置文件:`./addon/manifest.json`; -- UI 文件: `./addon/chrome/content/*.xhtml`. +- UI 文件: `./addon/content/*.xhtml`. - 区域设置文件: `./addon/locale/**/*.flt`; - 首选项文件: `./addon/prefs.js`; - > 不要在 `prefs.js` 中换行 ```shell . -|-- .eslintrc.json # eslint conf -|-- .gitattributes # git conf |-- .github/ # github conf -|-- .gitignore # git conf -|-- .prettierrc # prettier conf -|-- .release-it.json # release-it conf -|-- .vscode # vs code conf -| |-- extensions.json -| |-- launch.json -| |-- setting.json -| `-- toolkit.code-snippets -|-- package-lock.json # npm conf -|-- package.json # npm conf -|-- LICENSE -|-- README.md -|-- addon -| |-- bootstrap.js # addon load/unload script, like a main.c -| |-- chrome -| | `-- content -| | |-- icons/ -| | |-- preferences.xhtml # preference panel -| | `-- zoteroPane.css -| |-- locale # locale +|-- .vscode/ # vscode conf +|-- addon # static files +| |-- bootstrap.js +| |-- content +| | |-- icons +| | | |-- favicon.png +| | | `-- favicon@0.5x.png +| | |-- preferences.xhtml +| | `-- zoteroPane.css +| |-- locale | | |-- en-US | | | |-- addon.ftl +| | | |-- mainWindow.ftl | | | `-- preferences.ftl | | `-- zh-CN | | |-- addon.ftl +| | |-- mainWindow.ftl | | `-- preferences.ftl -| |-- manifest.json # addon config +| |-- manifest.json | `-- prefs.js -|-- build/ # build dir -|-- scripts # scripts for dev -| |-- build.mjs # script to build plugin -| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc -| |-- server.mjs # script to start a development server -| |-- start.mjs # script to start Zotero process -| |-- stop.mjs # script to kill Zotero process -| |-- utils.mjs # utils functions for dev scripts -| |-- update-template.json # template of `update.json` -| `-- zotero-cmd-template.json # template of local env -|-- src # source code +|-- build # build dir +|-- node_modules +|-- src # source code of scripts | |-- addon.ts # base class | |-- hooks.ts # lifecycle hooks | |-- index.ts # main entry | |-- modules # sub modules | | |-- examples.ts | | `-- preferenceScript.ts -| `-- utils # utilities +| `-- utils # utilities | |-- locale.ts | |-- prefs.ts | |-- wait.ts -| `-- window.ts -|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig -|-- typings # ts typings +| |-- window.ts +| `-- ztoolkit.ts +|-- typings # ts typings | `-- global.d.ts -`-- update.json + +|-- .env # enviroment config (do not check into repo) +|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold +|-- .gitignore # git conf +|-- .gitattributes # git conf +|-- .prettierrc # prettier conf, https://prettier.io/ +|-- eslint.config.mjs # eslint conf, https://eslint.org/ +|-- LICENSE +|-- package-lock.json +|-- package.json +|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig +|-- README.md +`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold ``` ## Disclaimer 免责声明 diff --git a/src/modules/examples.ts b/src/modules/examples.ts index 654451a..d44a610 100644 --- a/src/modules/examples.ts +++ b/src/modules/examples.ts @@ -71,7 +71,7 @@ export class BasicExampleFactory { static registerPrefs() { Zotero.PreferencePanes.register({ pluginID: config.addonID, - src: rootURI + "chrome/content/preferences.xhtml", + src: rootURI + "content/preferences.xhtml", label: getString("prefs-title"), image: `chrome://${config.addonRef}/content/icons/favicon.png`, }); diff --git a/src/modules/preferenceScript.ts b/src/modules/preferenceScript.ts index ef6e5b9..a4dcb7c 100644 --- a/src/modules/preferenceScript.ts +++ b/src/modules/preferenceScript.ts @@ -3,7 +3,7 @@ import { getString } from "../utils/locale"; export async function registerPrefsScripts(_window: Window) { // This function is called when the prefs window is opened - // See addon/chrome/content/preferences.xul onpaneload + // See addon/content/preferences.xhtml onpaneload if (!addon.data.prefs) { addon.data.prefs = { window: _window, diff --git a/zotero-plugin.config.ts b/zotero-plugin.config.ts index 1065853..b1eccd1 100644 --- a/zotero-plugin.config.ts +++ b/zotero-plugin.config.ts @@ -31,7 +31,7 @@ export default defineConfig({ }, bundle: true, target: "firefox115", - outfile: `build/addon/chrome/content/scripts/${pkg.config.addonRef}.js`, + outfile: `build/addon/content/scripts/${pkg.config.addonRef}.js`, }, ], },