zotero-plugin-scaffold 0.2.0-beta.12 → 0.2.0-beta.13

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/README.md CHANGED
@@ -1,56 +1,10 @@
1
1
  # Zotero Plugin Development Scaffold
2
2
 
3
- [![NPM Version](https://img.shields.io/npm/v/zotero-plugin-scaffold)](https://www.npmjs.com/package/zotero-plugin-scaffold)
4
- [![NPM Downloads](https://img.shields.io/npm/dm/zotero-plugin-scaffold)](https://www.npmjs.com/package/zotero-plugin-scaffold)
5
- ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/zotero-plugin-scaffold)
6
- ![GitHub License](https://img.shields.io/github/license/northword/zotero-plugin-scaffold)
7
- [![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
8
-
9
- This is an npm package designed to assist in the development of Zotero plugins. It provides features such as compiling plugins, starting Zotero and installing plugins from source code, reloading plugins when the source code changes, and releasing plugins, and so on.
10
-
11
- Initially, the code of this package was part of the [zotero-plugin-template](https://github.com/windingwind/zotero-plugin-template) repository. To allow downstream developers to easily stay up-to-date, we have abstracted these scripts into a standalone npm package.
12
-
13
- This project is under active development, and some APIs may change. However, it is ready for production and has been [used in several projects](https://github.com/northword/zotero-plugin-scaffold/network/dependents).
14
-
15
- For best practices regarding this package, please refer to [zotero-plugin-template](https://github.com/windingwind/zotero-plugin-template).
3
+ Delivering a modern and elegant development experience for Zotero plugins.
16
4
 
17
5
  ## Documentation
18
6
 
19
- [Read the Docs to Learn More.](https://northword.github.io/zotero-plugin-scaffold)
20
-
21
- ## Contributing
22
-
23
- ```bash
24
- # Git Clone
25
- git clone https://github.com/northword/zotero-plugin-scaffold.git zotero-plugin-scaffold
26
- cd zotero-plugin-scaffold/
27
-
28
- # Install deps
29
- pnpm install
30
-
31
- # Development Mode
32
- # This command creates a typescript runtime using jiti,
33
- # and the modified code does not need to be built again.
34
- pnpm run dev
35
-
36
- # link local scaffold to your plugin
37
- cd your-plugin-work-dir/
38
- pnpm link ../zotero-plugin-scaffold
39
- cd zotero-plugin-scaffold/
40
-
41
- ```
42
-
43
- Now you can make changes to Scaffold and test them in your plugin.
44
-
45
- When you're done modifying, make sure that you can pass the build and that the code style meets the requirements of this repository.
46
-
47
- ```bash
48
- # Build
49
- pnpm run build
50
-
51
- # ES Lint
52
- pnpm run lint:fix
53
- ```
7
+ [Read the Docs to Learn More](https://northword.github.io/zotero-plugin-scaffold).
54
8
 
55
9
  ## License
56
10
 
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import cli from "../dist/cli.mjs";
4
+
5
+ cli();
@@ -1,18 +1,17 @@
1
1
  import { readFile, stat } from 'node:fs/promises';
2
- import { join, basename } from 'node:path';
2
+ import { extname, join, basename } from 'node:path';
3
3
  import process from 'node:process';
4
- import mime from 'mime';
5
4
  import { Octokit } from 'octokit';
6
5
  import { globSync, glob } from 'tinyglobby';
7
6
  import { isCI } from 'std-env';
8
- import { B as Base } from '../shared/zotero-plugin-scaffold.af8d03c3.mjs';
7
+ import { B as Base } from '../shared/zotero-plugin-scaffold.CnLqPvW1.mjs';
9
8
  import 'c12';
10
9
  import 'es-toolkit';
11
10
  import 'fs-extra/esm';
12
11
  import 'hookable';
13
12
  import 'node:readline';
14
13
  import 'chalk';
15
- import '../shared/zotero-plugin-scaffold.77c9802c.mjs';
14
+ import '../shared/zotero-plugin-scaffold.v8dJZZ-v.mjs';
16
15
  import 'adm-zip';
17
16
  import 'esbuild';
18
17
  import 'node:crypto';
@@ -27,16 +26,23 @@ import 'node:events';
27
26
  import 'node:http';
28
27
  import 'xvfb-ts';
29
28
 
30
- var __defProp$1 = Object.defineProperty;
31
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
32
- var __publicField$1 = (obj, key, value) => {
33
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
34
- return value;
29
+ const mimeTypes = {
30
+ "application/json": ["json"],
31
+ "application/x-xpinstall": ["xpi"]
35
32
  };
33
+ function getMimeTypeByFileName(filename) {
34
+ const ext = extname(filename);
35
+ for (const type in mimeTypes) {
36
+ if (mimeTypes[type].includes(ext))
37
+ return type;
38
+ }
39
+ return void 0;
40
+ }
41
+
36
42
  class ReleaseBase extends Base {
43
+ isCI;
37
44
  constructor(ctx) {
38
45
  super(ctx);
39
- __publicField$1(this, "isCI");
40
46
  this.isCI = isCI;
41
47
  }
42
48
  checkFiles() {
@@ -47,16 +53,10 @@ class ReleaseBase extends Base {
47
53
  }
48
54
  }
49
55
 
50
- var __defProp = Object.defineProperty;
51
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
- var __publicField = (obj, key, value) => {
53
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
54
- return value;
55
- };
56
56
  class GitHub extends ReleaseBase {
57
+ client;
57
58
  constructor(ctx) {
58
59
  super(ctx);
59
- __publicField(this, "client");
60
60
  this.client = this.getClient();
61
61
  }
62
62
  async run() {
@@ -118,7 +118,7 @@ class GitHub extends ReleaseBase {
118
118
  release_id: releaseID,
119
119
  data: await readFile(asset),
120
120
  headers: {
121
- "content-type": mime.getType(asset) || "application/octet-stream",
121
+ "content-type": getMimeTypeByFileName(asset) || "application/octet-stream",
122
122
  "content-length": (await stat(asset)).size
123
123
  },
124
124
  name: basename(asset)
@@ -168,7 +168,7 @@ class GitHub extends ReleaseBase {
168
168
  release_id: release.id,
169
169
  name: "Release Manifest",
170
170
  body: `This release is used to host \`update.json\`, please do not delete or modify it!
171
- Updated in UTC ${( new Date()).toISOString()} for version ${version}`,
171
+ Updated in UTC ${(/* @__PURE__ */ new Date()).toISOString()} for version ${version}`,
172
172
  prerelease: true,
173
173
  make_latest: "false"
174
174
  });
package/dist/cli.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- declare function main(): Promise<void>;
1
+ declare function run(): Promise<void>;
2
2
 
3
- export { main as default };
3
+ export { run as default };
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare function main(): Promise<void>;
1
+ declare function run(): Promise<void>;
2
2
 
3
- export { main as default };
3
+ export { run as default };
package/dist/cli.mjs CHANGED
@@ -1,7 +1,6 @@
1
- #!/usr/bin/env node
2
1
  import process from 'node:process';
3
2
  import { Command } from '@commander-js/extra-typings';
4
- import { E as ExitSignals, l as logger, C as Config, a as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.af8d03c3.mjs';
3
+ import { E as ExitSignals, l as logger, C as Config, a as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.CnLqPvW1.mjs';
5
4
  import { readFile, writeFile } from 'node:fs/promises';
6
5
  import { pathExists, ensureFile } from 'fs-extra';
7
6
  import tinyUpdateNotifier from 'tiny-update-notifier';
@@ -12,7 +11,7 @@ import 'hookable';
12
11
  import 'node:readline';
13
12
  import 'chalk';
14
13
  import 'std-env';
15
- import './shared/zotero-plugin-scaffold.77c9802c.mjs';
14
+ import './shared/zotero-plugin-scaffold.v8dJZZ-v.mjs';
16
15
  import 'tinyglobby';
17
16
  import 'node:path';
18
17
  import 'adm-zip';
@@ -31,15 +30,16 @@ import 'xvfb-ts';
31
30
 
32
31
  const name = "zotero-plugin-scaffold";
33
32
  const type = "module";
34
- const version = "0.2.0-beta.12";
35
- const packageManager = "pnpm@9.15.0";
33
+ const version = "0.2.0-beta.13";
34
+ const packageManager = "pnpm@9.15.1";
36
35
  const description = "A scaffold for Zotero plugin development.";
37
36
  const author = "northword";
38
37
  const license = "AGPL-3.0-or-later";
39
38
  const homepage = "https://github.com/northword/zotero-plugin-scaffold#readme";
40
39
  const repository = {
41
40
  type: "git",
42
- url: "https://github.com/northword/zotero-plugin-scaffold.git"
41
+ url: "https://github.com/northword/zotero-plugin-scaffold.git",
42
+ directory: "packages/scaffold"
43
43
  };
44
44
  const bugs = {
45
45
  url: "https://github.com/northword/zotero-plugin-scaffold/issues"
@@ -56,6 +56,9 @@ const exports = {
56
56
  types: "./dist/index.d.ts",
57
57
  "import": "./dist/index.mjs"
58
58
  },
59
+ "./cli": {
60
+ "import": "./dist/cli.mjs"
61
+ },
59
62
  "./vendor": {
60
63
  types: "./dist/vendor/index.d.ts",
61
64
  "import": "./dist/vendor/index.mjs"
@@ -65,9 +68,10 @@ const main$1 = "./dist/index.mjs";
65
68
  const module = "./dist/index.mjs";
66
69
  const types = "./dist/index.d.ts";
67
70
  const bin = {
68
- "zotero-plugin": "./dist/cli.mjs"
71
+ "zotero-plugin": "./bin/zotero-plugin.mjs"
69
72
  };
70
73
  const files = [
74
+ "bin",
71
75
  "dist"
72
76
  ];
73
77
  const engines = {
@@ -76,22 +80,14 @@ const engines = {
76
80
  const scripts = {
77
81
  dev: "unbuild --stub",
78
82
  build: "tsc --noEmit && unbuild",
79
- "lint:check": "eslint .",
80
- "lint:fix": "eslint . --fix",
81
- release: "bumpp --commit \"chore(release): publish v%s\"",
82
- "update:deps": "pnpx taze minor -w -f -l",
83
- test: "echo \"Error: no test specified\" && exit 1",
84
- "docs:dev": "vitepress dev docs",
85
- "docs:build": "vitepress build docs",
86
- "docs:preview": "vitepress preview docs"
83
+ test: "echo \"Error: no test specified\" && exit 1"
87
84
  };
88
85
  const publishConfig = {
89
86
  access: "public",
90
87
  registry: "https://registry.npmjs.org"
91
88
  };
92
89
  const directories = {
93
- lib: "dist",
94
- doc: "docs"
90
+ lib: "dist"
95
91
  };
96
92
  const peerDependencies = {
97
93
  "conventional-changelog": "^6.0.0"
@@ -104,16 +100,15 @@ const peerDependenciesMeta = {
104
100
  const dependencies = {
105
101
  "@commander-js/extra-typings": "^12.1.0",
106
102
  "adm-zip": "^0.5.16",
107
- bumpp: "^9.9.1",
103
+ bumpp: "^9.9.2",
108
104
  c12: "^2.0.1",
109
- chalk: "^5.3.0",
110
- chokidar: "^4.0.1",
105
+ chalk: "^5.4.1",
106
+ chokidar: "^4.0.3",
111
107
  commander: "^12.1.0",
112
- "es-toolkit": "^1.29.0",
113
- esbuild: "^0.24.0",
108
+ "es-toolkit": "^1.31.0",
109
+ esbuild: "^0.24.2",
114
110
  "fs-extra": "^11.2.0",
115
111
  hookable: "^5.5.3",
116
- mime: "^4.0.4",
117
112
  octokit: "^4.0.2",
118
113
  "std-env": "^3.8.0",
119
114
  "tiny-update-notifier": "^2.0.0",
@@ -121,15 +116,8 @@ const dependencies = {
121
116
  "xvfb-ts": "^1.1.0"
122
117
  };
123
118
  const devDependencies = {
124
- "@antfu/eslint-config": "^3.11.2",
125
119
  "@types/adm-zip": "^0.5.7",
126
- "@types/fs-extra": "^11.0.4",
127
- "@types/node": "^22.10.2",
128
- eslint: "^9.16.0",
129
- "eslint-plugin-format": "^0.1.3",
130
- typescript: "^5.7.2",
131
- unbuild: "^2.0.0",
132
- vitepress: "^1.5.0"
120
+ "@types/fs-extra": "^11.0.4"
133
121
  };
134
122
  const pkg = {
135
123
  name: name,
@@ -187,10 +175,9 @@ function updateNotifier(name, version) {
187
175
  }
188
176
 
189
177
  async function main() {
190
- var _a;
191
178
  const { name, version } = pkg;
192
179
  updateNotifier(name, version);
193
- (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "development");
180
+ process.env.NODE_ENV ??= "development";
194
181
  const cli = new Command();
195
182
  cli.version(version).usage("<command> [options]");
196
183
  cli.command("build").description("Build the plugin").option("--dev", "Builds the plugin in dev mode").option("--dist <dir>", "The relative path for the new output directory (default: build)").action((options) => {
@@ -235,13 +222,15 @@ async function main() {
235
222
  });
236
223
  cli.parse();
237
224
  }
238
- main().then(() => {
239
- checkGitIgnore();
240
- }).catch(onError);
241
- process.on("uncaughtException", onError);
225
+ async function run() {
226
+ main().then(() => {
227
+ checkGitIgnore();
228
+ }).catch(onError);
229
+ process.on("uncaughtException", onError);
230
+ }
242
231
  function onError(err) {
243
232
  logger.error(err);
244
233
  process.exit(1);
245
234
  }
246
235
 
247
- export { main as default };
236
+ export { run as default };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { a as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.af8d03c3.mjs';
1
+ export { a as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.CnLqPvW1.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -7,7 +7,7 @@ import 'node:process';
7
7
  import 'node:readline';
8
8
  import 'chalk';
9
9
  import 'std-env';
10
- import './shared/zotero-plugin-scaffold.77c9802c.mjs';
10
+ import './shared/zotero-plugin-scaffold.v8dJZZ-v.mjs';
11
11
  import 'node:fs/promises';
12
12
  import 'tinyglobby';
13
13
  import 'node:path';
@@ -6,7 +6,7 @@ import process from 'node:process';
6
6
  import readline from 'node:readline';
7
7
  import chalk from 'chalk';
8
8
  import { isDebug, isCI, isWindows, isMacOS, isLinux } from 'std-env';
9
- import { p as parseRepoUrl, d as dateFormat, t as template, a as toArray, r as replaceInFile } from './zotero-plugin-scaffold.77c9802c.mjs';
9
+ import { p as parseRepoUrl, d as dateFormat, t as template, b as toArray, a as replaceInFile } from './zotero-plugin-scaffold.v8dJZZ-v.mjs';
10
10
  import { readFile, writeFile } from 'node:fs/promises';
11
11
  import { basename, dirname, join, resolve } from 'node:path';
12
12
  import AdmZip from 'adm-zip';
@@ -24,12 +24,6 @@ import EventEmitter from 'node:events';
24
24
  import http from 'node:http';
25
25
  import { Xvfb } from 'xvfb-ts';
26
26
 
27
- var __defProp$7 = Object.defineProperty;
28
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
29
- var __publicField$7 = (obj, key, value) => {
30
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
31
- return value;
32
- };
33
27
  var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
34
28
  LOG_LEVEL2[LOG_LEVEL2["trace"] = 0] = "trace";
35
29
  LOG_LEVEL2[LOG_LEVEL2["debug"] = 1] = "debug";
@@ -38,9 +32,10 @@ var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
38
32
  LOG_LEVEL2[LOG_LEVEL2["error"] = 4] = "error";
39
33
  return LOG_LEVEL2;
40
34
  })(LOG_LEVEL || {});
41
- const _Log = class _Log {
35
+ class Log {
36
+ static instance;
37
+ logLevel;
42
38
  constructor(level) {
43
- __publicField$7(this, "logLevel");
44
39
  if (isDebug)
45
40
  this.logLevel = 0 /* trace */;
46
41
  else if (process.env.ZOTERO_PLUGIN_LOG_LEVEL)
@@ -51,10 +46,10 @@ const _Log = class _Log {
51
46
  this.logLevel = 2 /* info */;
52
47
  }
53
48
  static getInstance() {
54
- if (!_Log.instance) {
55
- _Log.instance = new _Log();
49
+ if (!Log.instance) {
50
+ Log.instance = new Log();
56
51
  }
57
- return _Log.instance;
52
+ return Log.instance;
58
53
  }
59
54
  setLogLevel(level) {
60
55
  this.logLevel = LOG_LEVEL[level];
@@ -123,9 +118,7 @@ ${arg.stack}`;
123
118
  newLine() {
124
119
  console.log("");
125
120
  }
126
- };
127
- __publicField$7(_Log, "instance");
128
- let Log = _Log;
121
+ }
129
122
  const logger = Log.getInstance();
130
123
 
131
124
  function defineConfig(userConfig) {
@@ -149,10 +142,10 @@ function resolveConfig(config) {
149
142
  });
150
143
  const { name, version } = pkgUser;
151
144
  const { owner, repo } = parseRepoUrl(pkgUser.repository?.url);
152
- config.name || (config.name = name);
153
- config.id || (config.id = config.name);
154
- config.namespace || (config.namespace = config.name);
155
- config.xpiName || (config.xpiName = kebabCase(config.name));
145
+ config.name ||= name;
146
+ config.id ||= config.name;
147
+ config.namespace ||= config.name;
148
+ config.xpiName ||= kebabCase(config.name);
156
149
  const isPreRelease = version.includes("-");
157
150
  const templateData = {
158
151
  owner,
@@ -308,15 +301,9 @@ function generateHash(filePath, algorithm) {
308
301
  });
309
302
  }
310
303
 
311
- var __defProp$6 = Object.defineProperty;
312
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
313
- var __publicField$6 = (obj, key, value) => {
314
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
315
- return value;
316
- };
317
304
  class Base {
305
+ ctx;
318
306
  constructor(ctx) {
319
- __publicField$6(this, "ctx");
320
307
  this.ctx = ctx;
321
308
  }
322
309
  get logger() {
@@ -324,19 +311,12 @@ class Base {
324
311
  }
325
312
  }
326
313
 
327
- var __defProp$5 = Object.defineProperty;
328
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
329
- var __publicField$5 = (obj, key, value) => {
330
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
331
- return value;
332
- };
333
314
  class Build extends Base {
315
+ buildTime;
316
+ isPreRelease;
334
317
  constructor(ctx) {
335
- var _a;
336
318
  super(ctx);
337
- __publicField$5(this, "buildTime");
338
- __publicField$5(this, "isPreRelease");
339
- (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "production");
319
+ process.env.NODE_ENV ??= "production";
340
320
  this.buildTime = "";
341
321
  this.isPreRelease = this.ctx.version.includes("-");
342
322
  }
@@ -374,7 +354,7 @@ class Build extends Base {
374
354
  }
375
355
  await this.ctx.hooks.callHook("build:done", this.ctx);
376
356
  this.logger.success(
377
- `Build finished in ${(( new Date()).getTime() - t.getTime()) / 1e3} s.`
357
+ `Build finished in ${((/* @__PURE__ */ new Date()).getTime() - t.getTime()) / 1e3} s.`
378
358
  );
379
359
  }
380
360
  /**
@@ -619,7 +599,6 @@ class Release extends Base {
619
599
  * then, create or update release (tag is "release"), update `update.json`.
620
600
  */
621
601
  async run() {
622
- var _a;
623
602
  const t = /* @__PURE__ */ new Date();
624
603
  const { release, version } = this.ctx;
625
604
  if (release.bumpp.release === "prompt" && isCI) {
@@ -636,7 +615,7 @@ class Release extends Base {
636
615
  const isPublishNeeded = isGitHubEnabled || isGiteeEnabled;
637
616
  if (isPublishNeeded && !release.bumpp.execute) {
638
617
  this.logger.warn(`The current release needs to run the build after bumping the version number, please configure the build script in 'config.release.bumpp.execute'${isBumpNeeded ? "" : " or run build before run release"}.`);
639
- (_a = this.ctx.release.bumpp).execute || (_a.execute = "npm run build");
618
+ this.ctx.release.bumpp.execute ||= "npm run build";
640
619
  }
641
620
  this.logger.debug("Release config: ", this.ctx.release);
642
621
  await this.ctx.hooks.callHook("release:init", this.ctx);
@@ -649,7 +628,7 @@ class Release extends Base {
649
628
  }
650
629
  await this.ctx.hooks.callHook("release:done", this.ctx);
651
630
  this.logger.success(
652
- `Done in ${(( new Date()).getTime() - t.getTime()) / 1e3} s.`
631
+ `Done in ${((/* @__PURE__ */ new Date()).getTime() - t.getTime()) / 1e3} s.`
653
632
  );
654
633
  }
655
634
  async getConventionalChangelog() {
@@ -823,12 +802,6 @@ const prefs = {
823
802
  ...prefsFirefox
824
803
  };
825
804
 
826
- var __defProp$4 = Object.defineProperty;
827
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
828
- var __publicField$4 = (obj, key, value) => {
829
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
830
- return value;
831
- };
832
805
  const UNSOLICITED_EVENTS = /* @__PURE__ */ new Set([
833
806
  "tabNavigated",
834
807
  "styleApplied",
@@ -870,12 +843,12 @@ function parseMessage(data) {
870
843
  }
871
844
  }
872
845
  class MessagingClient extends EventEmitter {
846
+ incomingData = Buffer.alloc(0);
847
+ pendingRequests = [];
848
+ activeRequests = /* @__PURE__ */ new Map();
849
+ connection;
873
850
  constructor() {
874
851
  super();
875
- __publicField$4(this, "incomingData", Buffer.alloc(0));
876
- __publicField$4(this, "pendingRequests", []);
877
- __publicField$4(this, "activeRequests", /* @__PURE__ */ new Map());
878
- __publicField$4(this, "connection");
879
852
  }
880
853
  async connect(port) {
881
854
  await new Promise((resolve, reject) => {
@@ -952,8 +925,7 @@ class MessagingClient extends EventEmitter {
952
925
  }
953
926
  onData(data) {
954
927
  this.incomingData = Buffer.concat([this.incomingData, data]);
955
- while (this.readMessage())
956
- ;
928
+ while (this.readMessage()) ;
957
929
  }
958
930
  readMessage() {
959
931
  const { remainingData, parsedMessage, error, fatal } = parseMessage(
@@ -1020,12 +992,6 @@ class MessagingClient extends EventEmitter {
1020
992
  }
1021
993
  }
1022
994
 
1023
- var __defProp$3 = Object.defineProperty;
1024
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1025
- var __publicField$3 = (obj, key, value) => {
1026
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1027
- return value;
1028
- };
1029
995
  const MAX_RETRIES = 150;
1030
996
  const RETRY_INTERVAL = 1e3;
1031
997
  function requestErrorToMessage(err) {
@@ -1043,9 +1009,9 @@ function isErrorWithCode(codeWanted, error) {
1043
1009
  return false;
1044
1010
  }
1045
1011
  class RemoteFirefox {
1012
+ client;
1013
+ checkedForAddonReloading;
1046
1014
  constructor() {
1047
- __publicField$3(this, "client");
1048
- __publicField$3(this, "checkedForAddonReloading");
1049
1015
  this.client = new MessagingClient();
1050
1016
  this.checkedForAddonReloading = false;
1051
1017
  this.client.on("disconnect", () => {
@@ -1072,7 +1038,7 @@ class RemoteFirefox {
1072
1038
  await this.client.connect(port);
1073
1039
  return this.client;
1074
1040
  } catch (error) {
1075
- logger.fail("Failed to connecte to RDP client, retry...");
1041
+ logger.debug("Failed to connecte to RDP client, retry...");
1076
1042
  if (isErrorWithCode("ECONNREFUSED", error)) {
1077
1043
  await new Promise((resolve) => setTimeout(resolve, RETRY_INTERVAL));
1078
1044
  lastError = error;
@@ -1193,7 +1159,7 @@ class RemoteFirefox {
1193
1159
  await this.checkForAddonReloading(addon);
1194
1160
  await this.addonRequest(addon, "reload");
1195
1161
  logger.success(
1196
- `\rLast extension reload: ${( new Date()).toTimeString()}`
1162
+ `\rLast extension reload: ${(/* @__PURE__ */ new Date()).toTimeString()}`
1197
1163
  );
1198
1164
  }
1199
1165
  }
@@ -1210,17 +1176,11 @@ function findFreeTcpPort() {
1210
1176
  });
1211
1177
  }
1212
1178
 
1213
- var __defProp$2 = Object.defineProperty;
1214
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1215
- var __publicField$2 = (obj, key, value) => {
1216
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1217
- return value;
1218
- };
1219
1179
  class ZoteroRunner {
1180
+ options;
1181
+ remoteFirefox;
1182
+ zotero;
1220
1183
  constructor(options) {
1221
- __publicField$2(this, "options");
1222
- __publicField$2(this, "remoteFirefox");
1223
- __publicField$2(this, "zotero");
1224
1184
  this.options = options;
1225
1185
  this.remoteFirefox = new RemoteFirefox();
1226
1186
  }
@@ -1380,7 +1340,7 @@ class ZoteroRunner {
1380
1340
  progressWindow.changeHeadline("${name} Hot Reload");
1381
1341
  progressWindow.progress = new progressWindow.ItemProgress(
1382
1342
  "chrome://zotero/skin/tick.png",
1383
- "VERSION=${version}, BUILD=${( new Date()).toLocaleString()}. By zotero-plugin-toolkit"
1343
+ "VERSION=${version}, BUILD=${(/* @__PURE__ */ new Date()).toLocaleString()}. By zotero-plugin-toolkit"
1384
1344
  );
1385
1345
  progressWindow.progress.setProgress(100);
1386
1346
  progressWindow.show();
@@ -1437,32 +1397,14 @@ function killZotero() {
1437
1397
  }
1438
1398
  }
1439
1399
 
1440
- var __defProp$1 = Object.defineProperty;
1441
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1442
- var __publicField$1 = (obj, key, value) => {
1443
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
1444
- return value;
1445
- };
1446
1400
  class Serve extends Base {
1401
+ builder;
1402
+ runner;
1403
+ _zoteroBinPath;
1404
+ _profilePath;
1447
1405
  constructor(ctx) {
1448
- var _a;
1449
1406
  super(ctx);
1450
- __publicField$1(this, "builder");
1451
- __publicField$1(this, "runner");
1452
- __publicField$1(this, "_zoteroBinPath");
1453
- __publicField$1(this, "_profilePath");
1454
- // Use arrow functions to keep `this`
1455
- __publicField$1(this, "exit", () => {
1456
- this.logger.info("Server shutdown by user request.");
1457
- this.runner?.exit();
1458
- this.ctx.hooks.callHook("serve:exit", this.ctx);
1459
- process.exit();
1460
- });
1461
- __publicField$1(this, "onZoteroExit", (_code, _signal) => {
1462
- this.logger.info(`Zotero terminated.`);
1463
- process.exit();
1464
- });
1465
- (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "development");
1407
+ process.env.NODE_ENV ??= "development";
1466
1408
  this.builder = new Build(ctx);
1467
1409
  }
1468
1410
  async run() {
@@ -1528,6 +1470,17 @@ class Serve extends Base {
1528
1470
  await this.runner?.reloadAllPlugins();
1529
1471
  await this.ctx.hooks.callHook("serve:onReloaded", this.ctx);
1530
1472
  }
1473
+ // Use arrow functions to keep `this`
1474
+ exit = () => {
1475
+ this.logger.info("Server shutdown by user request.");
1476
+ this.runner?.exit();
1477
+ this.ctx.hooks.callHook("serve:exit", this.ctx);
1478
+ process.exit();
1479
+ };
1480
+ onZoteroExit = (_code, _signal) => {
1481
+ this.logger.info(`Zotero terminated.`);
1482
+ process.exit();
1483
+ };
1531
1484
  get zoteroBinPath() {
1532
1485
  if (this._zoteroBinPath)
1533
1486
  return this._zoteroBinPath;
@@ -1613,35 +1566,13 @@ async function installZoteroLinux() {
1613
1566
  process.env.ZOTERO_PLUGIN_ZOTERO_BIN_PATH = `${process.cwd()}/Zotero_linux-x86_64/zotero`;
1614
1567
  }
1615
1568
 
1616
- var __defProp = Object.defineProperty;
1617
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1618
- var __publicField = (obj, key, value) => {
1619
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1620
- return value;
1621
- };
1622
1569
  class Test extends Base {
1570
+ builder;
1571
+ runner;
1572
+ communicator = {};
1623
1573
  constructor(ctx) {
1624
- var _a;
1625
1574
  super(ctx);
1626
- __publicField(this, "builder");
1627
- __publicField(this, "runner");
1628
- __publicField(this, "communicator", {});
1629
- __publicField(this, "exit", (code) => {
1630
- this.communicator.server?.close();
1631
- this.runner?.exit();
1632
- this.ctx.hooks.callHook("test:exit", this.ctx);
1633
- if (code === 1) {
1634
- this.logger.error("Test run failed");
1635
- process.exit(1);
1636
- } else if (code === "SIGINT") {
1637
- this.logger.info("Tester shutdown by user request");
1638
- process.exit();
1639
- } else {
1640
- this.logger.success("Test run completed successfully");
1641
- process.exit();
1642
- }
1643
- });
1644
- (_a = process.env).NODE_ENV ?? (_a.NODE_ENV = "test");
1575
+ process.env.NODE_ENV ??= "test";
1645
1576
  this.builder = new Build(ctx);
1646
1577
  if (isCI) {
1647
1578
  this.ctx.test.exitOnFinish = true;
@@ -2121,6 +2052,21 @@ class Test extends Base {
2121
2052
  });
2122
2053
  await this.runner.run();
2123
2054
  }
2055
+ exit = (code) => {
2056
+ this.communicator.server?.close();
2057
+ this.runner?.exit();
2058
+ this.ctx.hooks.callHook("test:exit", this.ctx);
2059
+ if (code === 1) {
2060
+ this.logger.error("Test run failed");
2061
+ process.exit(1);
2062
+ } else if (code === "SIGINT") {
2063
+ this.logger.info("Tester shutdown by user request");
2064
+ process.exit();
2065
+ } else {
2066
+ this.logger.success("Test run completed successfully");
2067
+ process.exit();
2068
+ }
2069
+ };
2124
2070
  get zoteroBinPath() {
2125
2071
  if (!process.env.ZOTERO_PLUGIN_ZOTERO_BIN_PATH)
2126
2072
  throw new Error("No Zotero Found.");
@@ -1,7 +1,5 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { glob } from 'tinyglobby';
3
- import 'es-toolkit';
4
- import 'fs-extra/esm';
5
3
 
6
4
  function dateFormat(fmt, date) {
7
5
  let ret;
@@ -60,4 +58,4 @@ async function replaceInFile({ files, from, to, isGlob = true }) {
60
58
  }));
61
59
  }
62
60
 
63
- export { toArray as a, replace as b, dateFormat as d, parseRepoUrl as p, replaceInFile as r, template as t };
61
+ export { replaceInFile as a, toArray as b, dateFormat as d, parseRepoUrl as p, replace as r, template as t };
@@ -1,4 +1,4 @@
1
- export { b as replace, r as replaceInFile } from '../shared/zotero-plugin-scaffold.77c9802c.mjs';
1
+ export { r as replace, a as replaceInFile } from '../shared/zotero-plugin-scaffold.v8dJZZ-v.mjs';
2
2
  import * as esToolkit from 'es-toolkit';
3
3
  export { esToolkit };
4
4
  import * as esm from 'fs-extra/esm';
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.12",
4
+ "version": "0.2.0-beta.13",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",
8
8
  "homepage": "https://github.com/northword/zotero-plugin-scaffold#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/northword/zotero-plugin-scaffold.git"
11
+ "url": "https://github.com/northword/zotero-plugin-scaffold.git",
12
+ "directory": "packages/scaffold"
12
13
  },
13
14
  "bugs": {
14
15
  "url": "https://github.com/northword/zotero-plugin-scaffold/issues"
@@ -25,6 +26,9 @@
25
26
  "types": "./dist/index.d.ts",
26
27
  "import": "./dist/index.mjs"
27
28
  },
29
+ "./cli": {
30
+ "import": "./dist/cli.mjs"
31
+ },
28
32
  "./vendor": {
29
33
  "types": "./dist/vendor/index.d.ts",
30
34
  "import": "./dist/vendor/index.mjs"
@@ -34,9 +38,10 @@
34
38
  "module": "./dist/index.mjs",
35
39
  "types": "./dist/index.d.ts",
36
40
  "bin": {
37
- "zotero-plugin": "./dist/cli.mjs"
41
+ "zotero-plugin": "./bin/zotero-plugin.mjs"
38
42
  },
39
43
  "files": [
44
+ "bin",
40
45
  "dist"
41
46
  ],
42
47
  "engines": {
@@ -47,8 +52,7 @@
47
52
  "registry": "https://registry.npmjs.org"
48
53
  },
49
54
  "directories": {
50
- "lib": "dist",
51
- "doc": "docs"
55
+ "lib": "dist"
52
56
  },
53
57
  "peerDependencies": {
54
58
  "conventional-changelog": "^6.0.0"
@@ -61,16 +65,15 @@
61
65
  "dependencies": {
62
66
  "@commander-js/extra-typings": "^12.1.0",
63
67
  "adm-zip": "^0.5.16",
64
- "bumpp": "^9.9.1",
68
+ "bumpp": "^9.9.2",
65
69
  "c12": "^2.0.1",
66
- "chalk": "^5.3.0",
67
- "chokidar": "^4.0.1",
70
+ "chalk": "^5.4.1",
71
+ "chokidar": "^4.0.3",
68
72
  "commander": "^12.1.0",
69
- "es-toolkit": "^1.29.0",
70
- "esbuild": "^0.24.0",
73
+ "es-toolkit": "^1.31.0",
74
+ "esbuild": "^0.24.2",
71
75
  "fs-extra": "^11.2.0",
72
76
  "hookable": "^5.5.3",
73
- "mime": "^4.0.4",
74
77
  "octokit": "^4.0.2",
75
78
  "std-env": "^3.8.0",
76
79
  "tiny-update-notifier": "^2.0.0",
@@ -78,26 +81,12 @@
78
81
  "xvfb-ts": "^1.1.0"
79
82
  },
80
83
  "devDependencies": {
81
- "@antfu/eslint-config": "^3.11.2",
82
84
  "@types/adm-zip": "^0.5.7",
83
- "@types/fs-extra": "^11.0.4",
84
- "@types/node": "^22.10.2",
85
- "eslint": "^9.16.0",
86
- "eslint-plugin-format": "^0.1.3",
87
- "typescript": "^5.7.2",
88
- "unbuild": "^2.0.0",
89
- "vitepress": "^1.5.0"
85
+ "@types/fs-extra": "^11.0.4"
90
86
  },
91
87
  "scripts": {
92
88
  "dev": "unbuild --stub",
93
89
  "build": "tsc --noEmit && unbuild",
94
- "lint:check": "eslint .",
95
- "lint:fix": "eslint . --fix",
96
- "release": "bumpp --commit \"chore(release): publish v%s\"",
97
- "update:deps": "pnpx taze minor -w -f -l",
98
- "test": "echo \"Error: no test specified\" && exit 1",
99
- "docs:dev": "vitepress dev docs",
100
- "docs:build": "vitepress build docs",
101
- "docs:preview": "vitepress preview docs"
90
+ "test": "echo \"Error: no test specified\" && exit 1"
102
91
  }
103
92
  }