update: hot reload without waiting
This commit is contained in:
parent
27c68b1167
commit
b2b490b191
@ -225,11 +225,10 @@ When file changes are detected in `src` or `addon`, the plugin will be automatic
|
|||||||
<details style="text-indent: 2em">
|
<details style="text-indent: 2em">
|
||||||
<summary>💡 Steps to add this feature to an existing plugin</summary>
|
<summary>💡 Steps to add this feature to an existing plugin</summary>
|
||||||
|
|
||||||
1. Add `if (reason == ADDON_DISABLE) {Services.obs.notifyObservers(null, "startupcache-invalidate", null);}` to `shutdown()` in the `addon/bootstrap.js`
|
1. Copy `scripts/reload.mjs`
|
||||||
2. Copy `scripts/reload.mjs`
|
2. Copy `reload`, `watch`, and `start-watch` commands in `package.json`
|
||||||
3. Copy `reload`, `watch`, and `start-watch` commands in `package.json`
|
3. Run `npm install --save-dev chokidar-cli`
|
||||||
4. Run `npm install --save-dev chokidar-cli`
|
4. Done.
|
||||||
5. Done.
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
3
addon/bootstrap.js
vendored
3
addon/bootstrap.js
vendored
@ -106,9 +106,6 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
|
|||||||
if (reason === APP_SHUTDOWN) {
|
if (reason === APP_SHUTDOWN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (reason == ADDON_DISABLE) {
|
|
||||||
Services.obs.notifyObservers(null, "startupcache-invalidate", null);
|
|
||||||
}
|
|
||||||
if (typeof Zotero === "undefined") {
|
if (typeof Zotero === "undefined") {
|
||||||
Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
|
Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
|
||||||
Components.interfaces.nsISupports
|
Components.interfaces.nsISupports
|
||||||
|
@ -20,9 +20,7 @@ const script = `
|
|||||||
(async () => {
|
(async () => {
|
||||||
const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
|
const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
const addon = await AddonManager.getAddonByID("${addonID}");
|
const addon = await AddonManager.getAddonByID("${addonID}");
|
||||||
addon.disable();
|
await addon.reload();
|
||||||
await Zotero.Promise.delay(1000);
|
|
||||||
addon.enable();
|
|
||||||
const progressWindow = new Zotero.ProgressWindow({ closeOnClick: true });
|
const progressWindow = new Zotero.ProgressWindow({ closeOnClick: true });
|
||||||
progressWindow.changeHeadline("${addonName} Hot Reload");
|
progressWindow.changeHeadline("${addonName} Hot Reload");
|
||||||
progressWindow.progress = new progressWindow.ItemProgress(
|
progressWindow.progress = new progressWindow.ItemProgress(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user