zotero-plugin-scaffold 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +24 -14
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -667,15 +667,17 @@ declare class Serve extends Base {
|
|
|
667
667
|
/**
|
|
668
668
|
* Starts zotero with plugins pre-installed as proxy file
|
|
669
669
|
*/
|
|
670
|
-
|
|
670
|
+
startZoteroByProxyFile(): Promise<child_process.ChildProcessWithoutNullStreams>;
|
|
671
671
|
/**
|
|
672
672
|
* start zotero with plugin installed and reload when dist changed
|
|
673
673
|
*/
|
|
674
|
-
|
|
674
|
+
startZoteroByWebExt(): Promise<any>;
|
|
675
675
|
/**
|
|
676
676
|
* Preparing the development environment
|
|
677
677
|
*
|
|
678
|
-
* When asProxy=true, generate a proxy file
|
|
678
|
+
* When asProxy=true, generate a proxy file and replace prefs.
|
|
679
|
+
*
|
|
680
|
+
* @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
|
|
679
681
|
*/
|
|
680
682
|
prepareDevEnv(): void;
|
|
681
683
|
reload(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -667,15 +667,17 @@ declare class Serve extends Base {
|
|
|
667
667
|
/**
|
|
668
668
|
* Starts zotero with plugins pre-installed as proxy file
|
|
669
669
|
*/
|
|
670
|
-
|
|
670
|
+
startZoteroByProxyFile(): Promise<child_process.ChildProcessWithoutNullStreams>;
|
|
671
671
|
/**
|
|
672
672
|
* start zotero with plugin installed and reload when dist changed
|
|
673
673
|
*/
|
|
674
|
-
|
|
674
|
+
startZoteroByWebExt(): Promise<any>;
|
|
675
675
|
/**
|
|
676
676
|
* Preparing the development environment
|
|
677
677
|
*
|
|
678
|
-
* When asProxy=true, generate a proxy file
|
|
678
|
+
* When asProxy=true, generate a proxy file and replace prefs.
|
|
679
|
+
*
|
|
680
|
+
* @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
|
|
679
681
|
*/
|
|
680
682
|
prepareDevEnv(): void;
|
|
681
683
|
reload(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -174,7 +174,6 @@ const defaultConfig = {
|
|
|
174
174
|
},
|
|
175
175
|
server: {
|
|
176
176
|
startArgs: [
|
|
177
|
-
"--no-remote",
|
|
178
177
|
"--start-debugger-server",
|
|
179
178
|
"--jsdebugger",
|
|
180
179
|
"--debugger",
|
|
@@ -734,10 +733,10 @@ class Serve extends Base {
|
|
|
734
733
|
await this.builder.run();
|
|
735
734
|
await this.ctx.hooks.callHook("serve:prebuild", this.ctx);
|
|
736
735
|
if (this.ctx.server.asProxy) {
|
|
737
|
-
this.
|
|
736
|
+
this.startZoteroByProxyFile();
|
|
738
737
|
} else {
|
|
739
738
|
console.log("");
|
|
740
|
-
await this.
|
|
739
|
+
await this.startZoteroByWebExt();
|
|
741
740
|
}
|
|
742
741
|
await this.watch();
|
|
743
742
|
}
|
|
@@ -787,16 +786,11 @@ ${path2} changed`);
|
|
|
787
786
|
/**
|
|
788
787
|
* Starts zotero with plugins pre-installed as proxy file
|
|
789
788
|
*/
|
|
790
|
-
async
|
|
791
|
-
if (!fs.existsSync(this.zoteroBinPath)) {
|
|
792
|
-
throw new Error("Zotero binary does not exist.");
|
|
793
|
-
}
|
|
794
|
-
if (!fs.existsSync(this.profilePath)) {
|
|
795
|
-
throw new Error("The given Zotero profile does not exist.");
|
|
796
|
-
}
|
|
789
|
+
async startZoteroByProxyFile() {
|
|
797
790
|
this.prepareDevEnv();
|
|
798
791
|
const zoteroProcess = spawn(this.zoteroBinPath, [
|
|
799
|
-
|
|
792
|
+
// Do not disable remote, or the debug bridge command will not run.
|
|
793
|
+
// "--no-remote",
|
|
800
794
|
"--start-debugger-server",
|
|
801
795
|
"--jsdebugger",
|
|
802
796
|
"--debugger",
|
|
@@ -819,7 +813,7 @@ ${path2} changed`);
|
|
|
819
813
|
/**
|
|
820
814
|
* start zotero with plugin installed and reload when dist changed
|
|
821
815
|
*/
|
|
822
|
-
async
|
|
816
|
+
async startZoteroByWebExt() {
|
|
823
817
|
return await webext.cmd.run(
|
|
824
818
|
{
|
|
825
819
|
firefox: this.zoteroBinPath,
|
|
@@ -844,7 +838,9 @@ ${path2} changed`);
|
|
|
844
838
|
/**
|
|
845
839
|
* Preparing the development environment
|
|
846
840
|
*
|
|
847
|
-
* When asProxy=true, generate a proxy file
|
|
841
|
+
* When asProxy=true, generate a proxy file and replace prefs.
|
|
842
|
+
*
|
|
843
|
+
* @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
|
|
848
844
|
*/
|
|
849
845
|
prepareDevEnv() {
|
|
850
846
|
const addonProxyFilePath = path.join(
|
|
@@ -865,7 +861,8 @@ ${path2} changed`);
|
|
|
865
861
|
`extensions/${this.id}.xpi`
|
|
866
862
|
);
|
|
867
863
|
if (fs.existsSync(addonXpiFilePath)) {
|
|
868
|
-
fs.
|
|
864
|
+
fs.removeSync(addonXpiFilePath);
|
|
865
|
+
this.logger.debug(`XPI file found, removed.`);
|
|
869
866
|
}
|
|
870
867
|
const prefsPath = path.join(this.profilePath, "prefs.js");
|
|
871
868
|
if (fs.existsSync(prefsPath)) {
|
|
@@ -883,6 +880,19 @@ ${path2} changed`);
|
|
|
883
880
|
fs.writeFileSync(prefsPath, updatedPrefs, "utf-8");
|
|
884
881
|
this.logger.debug("The <profile>/prefs.js has been modified.");
|
|
885
882
|
}
|
|
883
|
+
const addonInfoFilePath = path.join(this.profilePath, "extensions.json");
|
|
884
|
+
if (fs.existsSync(addonInfoFilePath)) {
|
|
885
|
+
const content = fs.readJSONSync(addonInfoFilePath);
|
|
886
|
+
content.addons = content.addons.map((addon) => {
|
|
887
|
+
if (addon.id === this.id && addon.active === false) {
|
|
888
|
+
addon.active = true;
|
|
889
|
+
addon.userDisabled = false;
|
|
890
|
+
this.logger.debug(`Active plugin ${this.id} in extensions.json.`);
|
|
891
|
+
}
|
|
892
|
+
return addon;
|
|
893
|
+
});
|
|
894
|
+
fs.outputJSONSync(addonInfoFilePath, content);
|
|
895
|
+
}
|
|
886
896
|
}
|
|
887
897
|
reload() {
|
|
888
898
|
this.logger.debug("Reloading...");
|