zotero-plugin-scaffold 0.0.20 → 0.0.21

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 CHANGED
@@ -24,7 +24,7 @@ import 'chokidar';
24
24
  import 'process';
25
25
 
26
26
  const name = "zotero-plugin-scaffold";
27
- const version = "0.0.20";
27
+ const version = "0.0.21";
28
28
  const description = "A scaffold for Zotero plugin development.";
29
29
  const scripts = {
30
30
  dev: "unbuild --stub",
package/dist/index.d.mts CHANGED
@@ -679,7 +679,6 @@ declare class Serve extends Base {
679
679
  */
680
680
  prepareDevEnv(): void;
681
681
  reload(): void;
682
- openDevTool(): void;
683
682
  exit(): void;
684
683
  private get zoteroBinPath();
685
684
  private get profilePath();
package/dist/index.d.ts CHANGED
@@ -679,7 +679,6 @@ declare class Serve extends Base {
679
679
  */
680
680
  prepareDevEnv(): void;
681
681
  reload(): void;
682
- openDevTool(): void;
683
682
  exit(): void;
684
683
  private get zoteroBinPath();
685
684
  private get profilePath();
package/dist/index.mjs CHANGED
@@ -173,7 +173,13 @@ const defaultConfig = {
173
173
  hooks: {}
174
174
  },
175
175
  server: {
176
- startArgs: ["--debugger", "--purgecaches"],
176
+ startArgs: [
177
+ "--no-remote",
178
+ "--start-debugger-server",
179
+ "--jsdebugger",
180
+ "--debugger",
181
+ "--purgecaches"
182
+ ],
177
183
  asProxy: false,
178
184
  hooks: {}
179
185
  },
@@ -765,7 +771,6 @@ ${path2} changed`);
765
771
  * Starts zotero with plugins pre-installed as proxy file
766
772
  */
767
773
  async startZotero() {
768
- let isZoteroReady = false;
769
774
  if (!fs.existsSync(this.zoteroBinPath)) {
770
775
  throw new Error("Zotero binary does not exist.");
771
776
  }
@@ -774,19 +779,15 @@ ${path2} changed`);
774
779
  }
775
780
  this.prepareDevEnv();
776
781
  const zoteroProcess = spawn(this.zoteroBinPath, [
782
+ "--no-remote",
783
+ "--start-debugger-server",
784
+ "--jsdebugger",
777
785
  "--debugger",
778
786
  "--purgecaches",
779
787
  "-profile",
780
788
  this.profilePath
781
789
  ]);
782
790
  zoteroProcess.stdout?.on("data", (data) => {
783
- if (!isZoteroReady && data.toString().includes(`Plugin ${this.id} startup`)) {
784
- this.logger.log(data.toString());
785
- isZoteroReady = true;
786
- setTimeout(() => {
787
- this.openDevTool();
788
- }, 1e3);
789
- }
790
791
  });
791
792
  zoteroProcess.on("close", (code) => {
792
793
  this.logger.info(`Zotero terminated with code ${code}.`);
@@ -810,8 +811,9 @@ ${path2} changed`);
810
811
  keepProfileChanges: true,
811
812
  args: this.ctx.server.startArgs,
812
813
  pref: { "extensions.experiments.enabled": true },
813
- browserConsole: true,
814
- // devtools: true, // need Zotero upgrade to firefox 115,
814
+ // Use Zotero's devtools instead
815
+ browserConsole: false,
816
+ devtools: false,
815
817
  noInput: true
816
818
  },
817
819
  {
@@ -890,68 +892,6 @@ ${path2} changed`);
890
892
  const command = `${startZoteroCmd} -url "${url}"`;
891
893
  execSync(command);
892
894
  }
893
- openDevTool() {
894
- this.logger.debug("Open dev tools...");
895
- const openDevToolScript = `
896
- (async () => {
897
-
898
- // const { BrowserToolboxLauncher } = ChromeUtils.import(
899
- // "resource://devtools/client/framework/browser-toolbox/Launcher.jsm",
900
- // );
901
- // BrowserToolboxLauncher.init();
902
- // TODO: Use the above code to open the devtool after https://github.com/zotero/zotero/pull/3387
903
-
904
- Zotero.Prefs.set("devtools.debugger.remote-enabled", true, true);
905
- Zotero.Prefs.set("devtools.debugger.remote-port", 6100, true);
906
- Zotero.Prefs.set("devtools.debugger.prompt-connection", false, true);
907
- Zotero.Prefs.set("devtools.debugger.chrome-debugging-websocket", false, true);
908
-
909
- env =
910
- Services.env ||
911
- Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
912
-
913
- env.set("MOZ_BROWSER_TOOLBOX_PORT", 6100);
914
- Zotero.openInViewer(
915
- "chrome://devtools/content/framework/browser-toolbox/window.html",
916
- {
917
- onLoad: (doc) => {
918
- doc.querySelector("#status-message-container").style.visibility =
919
- "collapse";
920
- let toolboxBody;
921
- waitUntil(
922
- () => {
923
- toolboxBody = doc
924
- .querySelector(".devtools-toolbox-browsertoolbox-iframe")
925
- ?.contentDocument?.querySelector(".theme-body");
926
- return toolboxBody;
927
- },
928
- () => {
929
- toolboxBody.style = "pointer-events: all !important";
930
- }
931
- );
932
- },
933
- }
934
- );
935
-
936
- function waitUntil(condition, callback, interval = 100, timeout = 10000) {
937
- const start = Date.now();
938
- const intervalId = setInterval(() => {
939
- if (condition()) {
940
- clearInterval(intervalId);
941
- callback();
942
- } else if (Date.now() - start > timeout) {
943
- clearInterval(intervalId);
944
- }
945
- }, interval);
946
- }
947
- })()`;
948
- const url = `zotero://ztoolkit-debug/?run=${encodeURIComponent(
949
- openDevToolScript
950
- )}`;
951
- const startZoteroCmd = `"${this.zoteroBinPath}" --debugger --purgecaches -profile "${this.profilePath}"`;
952
- const command = `${startZoteroCmd} -url "${url}"`;
953
- execSync(command);
954
- }
955
895
  exit() {
956
896
  console.log("");
957
897
  this.logger.info("Server shutdown by user request.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "A scaffold for Zotero plugin development.",
5
5
  "type": "module",
6
6
  "exports": {