change: config.addonInstance
This commit is contained in:
parent
c1ad9c5ee7
commit
7b9e139cb8
17
README.md
17
README.md
@ -124,17 +124,20 @@ This is also how your plugin will be released and used by others.
|
|||||||
- Enter the repo folder;
|
- Enter the repo folder;
|
||||||
- Modify the settings in `./package.json`, including:
|
- Modify the settings in `./package.json`, including:
|
||||||
|
|
||||||
```
|
```json
|
||||||
|
{
|
||||||
version,
|
version,
|
||||||
author,
|
author,
|
||||||
description,
|
description,
|
||||||
homepage,
|
homepage,
|
||||||
config {
|
config {
|
||||||
releasepage,
|
releasepage, // URL to releases(`.xpi`)
|
||||||
updaterdf,
|
updaterdf, // URL to update.json
|
||||||
addonName,
|
addonName, // name to be displayed in the plugin manager
|
||||||
addonID,
|
addonID, // ID to avoid confliction. IMPORTANT!
|
||||||
addonRef
|
addonRef, // e.g. Element ID prefix
|
||||||
|
addonInstance // the plugin's root instance: Zotero.${addonInstance}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -145,7 +148,7 @@ This is also how your plugin will be released and used by others.
|
|||||||
|
|
||||||
> What the difference between dev & prod?
|
> What the difference between dev & prod?
|
||||||
>
|
>
|
||||||
> - This environment variable is stored in `Zotero.AddonTemplate.data.env`. The outputs to console is disabled in prod mode.
|
> - This environment variable is stored in `Zotero.${addonInstance}.data.env`. The outputs to console is disabled in prod mode.
|
||||||
> - You can decide what users cannot see/use based on this variable.
|
> - You can decide what users cannot see/use based on this variable.
|
||||||
|
|
||||||
### Release
|
### Release
|
||||||
|
2
addon/bootstrap.js
vendored
2
addon/bootstrap.js
vendored
@ -106,7 +106,7 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
|
|||||||
Components.interfaces.nsISupports
|
Components.interfaces.nsISupports
|
||||||
).wrappedJSObject;
|
).wrappedJSObject;
|
||||||
}
|
}
|
||||||
Zotero.AddonTemplate.hooks.onShutdown();
|
Zotero.__addonInstance__.hooks.onShutdown();
|
||||||
|
|
||||||
Cc["@mozilla.org/intl/stringbundle;1"]
|
Cc["@mozilla.org/intl/stringbundle;1"]
|
||||||
.getService(Components.interfaces.nsIStringBundleService)
|
.getService(Components.interfaces.nsIStringBundleService)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<vbox
|
<vbox
|
||||||
id="zotero-prefpane-__addonRef__"
|
id="zotero-prefpane-__addonRef__"
|
||||||
onload="Zotero.AddonTemplate.hooks.onPrefsEvent('load', {window})"
|
onload="Zotero.__addonInstance__.hooks.onPrefsEvent('load', {window})"
|
||||||
>
|
>
|
||||||
<groupbox>
|
<groupbox>
|
||||||
<label><html:h2>&zotero.__addonRef__.pref.title;</html:h2></label>
|
<label><html:h2>&zotero.__addonRef__.pref.title;</html:h2></label>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
"addonName": "Zotero Addon Template",
|
"addonName": "Zotero Addon Template",
|
||||||
"addonID": "addontemplate@euclpts.com",
|
"addonID": "addontemplate@euclpts.com",
|
||||||
"addonRef": "addontemplate",
|
"addonRef": "addontemplate",
|
||||||
|
"addonInstance": "AddonTemplate",
|
||||||
"releasepage": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi",
|
"releasepage": "https://github.com/windingwind/zotero-addon-template/releases/latest/download/zotero-addon-template.xpi",
|
||||||
"updaterdf": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/bootstrap/update.json"
|
"updaterdf": "https://raw.githubusercontent.com/windingwind/zotero-addon-template/bootstrap/update.json"
|
||||||
},
|
},
|
||||||
|
@ -112,6 +112,21 @@ async function main() {
|
|||||||
|
|
||||||
console.log("[Build] Run esbuild OK");
|
console.log("[Build] Run esbuild OK");
|
||||||
|
|
||||||
|
const replaceFrom = [
|
||||||
|
/__author__/g,
|
||||||
|
/__description__/g,
|
||||||
|
/__homepage__/g,
|
||||||
|
/__buildVersion__/g,
|
||||||
|
/__buildTime__/g,
|
||||||
|
];
|
||||||
|
|
||||||
|
const replaceTo = [author, description, homepage, version, buildTime];
|
||||||
|
|
||||||
|
replaceFrom.push(
|
||||||
|
...Object.keys(config).map((k) => new RegExp(`__${k}__`, "g"))
|
||||||
|
);
|
||||||
|
replaceTo.push(...Object.values(config));
|
||||||
|
|
||||||
const optionsAddon = {
|
const optionsAddon = {
|
||||||
files: [
|
files: [
|
||||||
path.join(buildDir, "**/*.rdf"),
|
path.join(buildDir, "**/*.rdf"),
|
||||||
@ -126,30 +141,8 @@ async function main() {
|
|||||||
"update.json",
|
"update.json",
|
||||||
"update.rdf",
|
"update.rdf",
|
||||||
],
|
],
|
||||||
from: [
|
from: replaceFrom,
|
||||||
/__author__/g,
|
to: replaceTo,
|
||||||
/__description__/g,
|
|
||||||
/__homepage__/g,
|
|
||||||
/__releasepage__/g,
|
|
||||||
/__updaterdf__/g,
|
|
||||||
/__addonName__/g,
|
|
||||||
/__addonID__/g,
|
|
||||||
/__addonRef__/g,
|
|
||||||
/__buildVersion__/g,
|
|
||||||
/__buildTime__/g,
|
|
||||||
],
|
|
||||||
to: [
|
|
||||||
author,
|
|
||||||
description,
|
|
||||||
homepage,
|
|
||||||
config.releasepage,
|
|
||||||
config.updaterdf,
|
|
||||||
config.addonName,
|
|
||||||
config.addonID,
|
|
||||||
config.addonRef,
|
|
||||||
version,
|
|
||||||
buildTime,
|
|
||||||
],
|
|
||||||
countMatches: true,
|
countMatches: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ function onShutdown(): void {
|
|||||||
ztoolkit.unregisterAll();
|
ztoolkit.unregisterAll();
|
||||||
// Remove addon object
|
// Remove addon object
|
||||||
addon.data.alive = false;
|
addon.data.alive = false;
|
||||||
delete Zotero.AddonTemplate;
|
delete Zotero[config.addonInstance];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@ import { config } from "../package.json";
|
|||||||
|
|
||||||
const basicTool = new BasicTool();
|
const basicTool = new BasicTool();
|
||||||
|
|
||||||
if (!basicTool.getGlobal("Zotero").AddonTemplate) {
|
if (!basicTool.getGlobal("Zotero")[config.addonInstance]) {
|
||||||
// Set global variables
|
// Set global variables
|
||||||
_globalThis.Zotero = basicTool.getGlobal("Zotero");
|
_globalThis.Zotero = basicTool.getGlobal("Zotero");
|
||||||
_globalThis.ZoteroPane = basicTool.getGlobal("ZoteroPane");
|
_globalThis.ZoteroPane = basicTool.getGlobal("ZoteroPane");
|
||||||
@ -17,7 +17,7 @@ if (!basicTool.getGlobal("Zotero").AddonTemplate) {
|
|||||||
ztoolkit.basicOptions.log.disableConsole = addon.data.env === "production";
|
ztoolkit.basicOptions.log.disableConsole = addon.data.env === "production";
|
||||||
ztoolkit.UI.basicOptions.ui.enableElementJSONLog =
|
ztoolkit.UI.basicOptions.ui.enableElementJSONLog =
|
||||||
addon.data.env === "development";
|
addon.data.env === "development";
|
||||||
Zotero.AddonTemplate = addon;
|
Zotero[config.addonInstance] = addon;
|
||||||
// Trigger addon hook for initialization
|
// Trigger addon hook for initialization
|
||||||
addon.hooks.onStartup();
|
addon.hooks.onStartup();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ export class KeyExampleFactory {
|
|||||||
id: cmdSmallerId,
|
id: cmdSmallerId,
|
||||||
document,
|
document,
|
||||||
_parentId: cmdsetId,
|
_parentId: cmdsetId,
|
||||||
oncommand: "Zotero.AddonTemplate.hooks.onShortcuts('smaller')",
|
oncommand: `Zotero.${config.addonInstance}.hooks.onShortcuts('smaller')`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user