zotero-plugin-scaffold 0.0.22 → 0.0.24
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 +32 -23
- 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
|
}
|
|
@@ -756,7 +755,12 @@ class Serve extends Base {
|
|
|
756
755
|
if (path2.endsWith(".ts")) {
|
|
757
756
|
this.builder.esbuild();
|
|
758
757
|
} else {
|
|
759
|
-
this.builder.run();
|
|
758
|
+
await this.builder.run();
|
|
759
|
+
}
|
|
760
|
+
if (this.ctx.server.asProxy) {
|
|
761
|
+
this.reload();
|
|
762
|
+
this.logger.info("Reloaded done.");
|
|
763
|
+
await this.ctx.hooks.callHook("serve:onReloaded", this.ctx);
|
|
760
764
|
}
|
|
761
765
|
} catch (err) {
|
|
762
766
|
this.logger.error(err);
|
|
@@ -768,18 +772,12 @@ class Serve extends Base {
|
|
|
768
772
|
this.logger.ready("Server Ready! \n");
|
|
769
773
|
}).on("change", async (path2) => {
|
|
770
774
|
if (this.ctx.server.asProxy) {
|
|
771
|
-
|
|
772
|
-
|
|
775
|
+
console.clear();
|
|
776
|
+
this.logger.log(`${path2} changed`);
|
|
773
777
|
} else {
|
|
774
778
|
console.log("");
|
|
775
779
|
}
|
|
776
|
-
onChange.cancel();
|
|
777
780
|
onChange(path2);
|
|
778
|
-
if (this.ctx.server.asProxy) {
|
|
779
|
-
this.reload();
|
|
780
|
-
this.logger.info("Reloaded done.");
|
|
781
|
-
await this.ctx.hooks.callHook("serve:onReloaded", this.ctx);
|
|
782
|
-
}
|
|
783
781
|
}).on("error", (err) => {
|
|
784
782
|
this.logger.error("Server start failed!", err);
|
|
785
783
|
});
|
|
@@ -787,16 +785,11 @@ ${path2} changed`);
|
|
|
787
785
|
/**
|
|
788
786
|
* Starts zotero with plugins pre-installed as proxy file
|
|
789
787
|
*/
|
|
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
|
-
}
|
|
788
|
+
async startZoteroByProxyFile() {
|
|
797
789
|
this.prepareDevEnv();
|
|
798
790
|
const zoteroProcess = spawn(this.zoteroBinPath, [
|
|
799
|
-
|
|
791
|
+
// Do not disable remote, or the debug bridge command will not run.
|
|
792
|
+
// "--no-remote",
|
|
800
793
|
"--start-debugger-server",
|
|
801
794
|
"--jsdebugger",
|
|
802
795
|
"--debugger",
|
|
@@ -819,7 +812,7 @@ ${path2} changed`);
|
|
|
819
812
|
/**
|
|
820
813
|
* start zotero with plugin installed and reload when dist changed
|
|
821
814
|
*/
|
|
822
|
-
async
|
|
815
|
+
async startZoteroByWebExt() {
|
|
823
816
|
return await webext.cmd.run(
|
|
824
817
|
{
|
|
825
818
|
firefox: this.zoteroBinPath,
|
|
@@ -844,7 +837,9 @@ ${path2} changed`);
|
|
|
844
837
|
/**
|
|
845
838
|
* Preparing the development environment
|
|
846
839
|
*
|
|
847
|
-
* When asProxy=true, generate a proxy file
|
|
840
|
+
* When asProxy=true, generate a proxy file and replace prefs.
|
|
841
|
+
*
|
|
842
|
+
* @see https://www.zotero.org/support/dev/client_coding/plugin_development#setting_up_a_plugin_development_environment
|
|
848
843
|
*/
|
|
849
844
|
prepareDevEnv() {
|
|
850
845
|
const addonProxyFilePath = path.join(
|
|
@@ -865,7 +860,8 @@ ${path2} changed`);
|
|
|
865
860
|
`extensions/${this.id}.xpi`
|
|
866
861
|
);
|
|
867
862
|
if (fs.existsSync(addonXpiFilePath)) {
|
|
868
|
-
fs.
|
|
863
|
+
fs.removeSync(addonXpiFilePath);
|
|
864
|
+
this.logger.debug(`XPI file found, removed.`);
|
|
869
865
|
}
|
|
870
866
|
const prefsPath = path.join(this.profilePath, "prefs.js");
|
|
871
867
|
if (fs.existsSync(prefsPath)) {
|
|
@@ -883,6 +879,19 @@ ${path2} changed`);
|
|
|
883
879
|
fs.writeFileSync(prefsPath, updatedPrefs, "utf-8");
|
|
884
880
|
this.logger.debug("The <profile>/prefs.js has been modified.");
|
|
885
881
|
}
|
|
882
|
+
const addonInfoFilePath = path.join(this.profilePath, "extensions.json");
|
|
883
|
+
if (fs.existsSync(addonInfoFilePath)) {
|
|
884
|
+
const content = fs.readJSONSync(addonInfoFilePath);
|
|
885
|
+
content.addons = content.addons.map((addon) => {
|
|
886
|
+
if (addon.id === this.id && addon.active === false) {
|
|
887
|
+
addon.active = true;
|
|
888
|
+
addon.userDisabled = false;
|
|
889
|
+
this.logger.debug(`Active plugin ${this.id} in extensions.json.`);
|
|
890
|
+
}
|
|
891
|
+
return addon;
|
|
892
|
+
});
|
|
893
|
+
fs.outputJSONSync(addonInfoFilePath, content);
|
|
894
|
+
}
|
|
886
895
|
}
|
|
887
896
|
reload() {
|
|
888
897
|
this.logger.debug("Reloading...");
|