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

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,22 +1,21 @@
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.rCsToUj_.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';
15
+ import 'node:fs';
16
16
  import 'adm-zip';
17
17
  import 'esbuild';
18
18
  import 'node:crypto';
19
- import 'node:fs';
20
19
  import 'node:child_process';
21
20
  import 'bumpp';
22
21
  import 'chokidar';
@@ -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.rCsToUj_.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,13 +11,13 @@ 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';
16
+ import 'node:fs';
17
17
  import 'node:path';
18
18
  import 'adm-zip';
19
19
  import 'esbuild';
20
20
  import 'node:crypto';
21
- import 'node:fs';
22
21
  import 'node:child_process';
23
22
  import 'bumpp';
24
23
  import 'chokidar';
@@ -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.14";
34
+ const packageManager = "pnpm@9.15.2";
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"
@@ -102,18 +98,17 @@ const peerDependenciesMeta = {
102
98
  }
103
99
  };
104
100
  const dependencies = {
105
- "@commander-js/extra-typings": "^12.1.0",
101
+ "@commander-js/extra-typings": "^13.0.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",
111
- commander: "^12.1.0",
112
- "es-toolkit": "^1.29.0",
113
- esbuild: "^0.24.0",
105
+ chalk: "^5.4.1",
106
+ chokidar: "^4.0.3",
107
+ commander: "^13.0.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.d.mts CHANGED
@@ -301,6 +301,40 @@ interface BuildConfig {
301
301
  */
302
302
  prefixFluentMessages: boolean;
303
303
  };
304
+ prefs: {
305
+ /**
306
+ * Prefixes the keys of preferences in `prefs.js` and
307
+ * the value of the `preference` attribute in XHTML files.
308
+ *
309
+ * 为 `prefs.js` 中的首选项键和 XHTML 文件中的 `preference` 属性的值
310
+ * 添加前缀。
311
+ *
312
+ * @default true
313
+ */
314
+ prefixPrefKeys: boolean;
315
+ /**
316
+ * Prefixes for Preference Keys, no dot at the end.
317
+ *
318
+ * 首选项键的前缀,结尾不需要加点号。
319
+ *
320
+ * @default 'extensions.${namespace}'
321
+ */
322
+ prefix: string;
323
+ /**
324
+ * Generate prefs.d.ts form prefs.js.
325
+ *
326
+ * - false: disable
327
+ * - string: path of dts file
328
+ *
329
+ * 为首选项生成类型声明文件。
330
+ *
331
+ * - false: 禁用
332
+ * - string:dts 文件路径
333
+ *
334
+ * @default 'typings/prefs.d.ts'
335
+ */
336
+ dts: false | string;
337
+ };
304
338
  /**
305
339
  * Configurations of esbuild.
306
340
  *
@@ -426,6 +460,8 @@ interface ServerConfig {
426
460
  * @default false
427
461
  */
428
462
  asProxy: boolean;
463
+ prebuild: boolean;
464
+ createProfileIfMissing: boolean;
429
465
  /**
430
466
  * The lifecycle hook.
431
467
  */
@@ -726,6 +762,7 @@ interface Hooks extends BuildHooks, ServeHooks, ReleaseHooks, TestHooks {
726
762
  type RecursivePartial<T> = {
727
763
  [P in keyof T]?: T[P] extends object ? RecursivePartial<T[P]> : T[P];
728
764
  };
765
+
729
766
  /**
730
767
  * User config
731
768
  */
@@ -789,6 +826,7 @@ declare class Build extends Base {
789
826
  */
790
827
  makeManifest(): Promise<void>;
791
828
  prepareLocaleFiles(): Promise<void>;
829
+ preparePrefs(): Promise<void>;
792
830
  esbuild(): Promise<esbuild.BuildResult<esbuild.BuildOptions>[]> | undefined;
793
831
  makeUpdateJson(): Promise<void>;
794
832
  pack(): Promise<void>;
@@ -816,7 +854,6 @@ declare class Serve extends Base {
816
854
  private builder;
817
855
  private runner?;
818
856
  private _zoteroBinPath?;
819
- private _profilePath?;
820
857
  constructor(ctx: Context);
821
858
  run(): Promise<void>;
822
859
  /**
@@ -828,8 +865,8 @@ declare class Serve extends Base {
828
865
  exit: () => never;
829
866
  private onZoteroExit;
830
867
  get zoteroBinPath(): string;
831
- get profilePath(): string;
832
- get dataDir(): string;
868
+ get profilePath(): string | undefined;
869
+ get dataDir(): string | undefined;
833
870
  }
834
871
 
835
872
  declare class Test extends Base {
package/dist/index.d.ts CHANGED
@@ -301,6 +301,40 @@ interface BuildConfig {
301
301
  */
302
302
  prefixFluentMessages: boolean;
303
303
  };
304
+ prefs: {
305
+ /**
306
+ * Prefixes the keys of preferences in `prefs.js` and
307
+ * the value of the `preference` attribute in XHTML files.
308
+ *
309
+ * 为 `prefs.js` 中的首选项键和 XHTML 文件中的 `preference` 属性的值
310
+ * 添加前缀。
311
+ *
312
+ * @default true
313
+ */
314
+ prefixPrefKeys: boolean;
315
+ /**
316
+ * Prefixes for Preference Keys, no dot at the end.
317
+ *
318
+ * 首选项键的前缀,结尾不需要加点号。
319
+ *
320
+ * @default 'extensions.${namespace}'
321
+ */
322
+ prefix: string;
323
+ /**
324
+ * Generate prefs.d.ts form prefs.js.
325
+ *
326
+ * - false: disable
327
+ * - string: path of dts file
328
+ *
329
+ * 为首选项生成类型声明文件。
330
+ *
331
+ * - false: 禁用
332
+ * - string:dts 文件路径
333
+ *
334
+ * @default 'typings/prefs.d.ts'
335
+ */
336
+ dts: false | string;
337
+ };
304
338
  /**
305
339
  * Configurations of esbuild.
306
340
  *
@@ -426,6 +460,8 @@ interface ServerConfig {
426
460
  * @default false
427
461
  */
428
462
  asProxy: boolean;
463
+ prebuild: boolean;
464
+ createProfileIfMissing: boolean;
429
465
  /**
430
466
  * The lifecycle hook.
431
467
  */
@@ -726,6 +762,7 @@ interface Hooks extends BuildHooks, ServeHooks, ReleaseHooks, TestHooks {
726
762
  type RecursivePartial<T> = {
727
763
  [P in keyof T]?: T[P] extends object ? RecursivePartial<T[P]> : T[P];
728
764
  };
765
+
729
766
  /**
730
767
  * User config
731
768
  */
@@ -789,6 +826,7 @@ declare class Build extends Base {
789
826
  */
790
827
  makeManifest(): Promise<void>;
791
828
  prepareLocaleFiles(): Promise<void>;
829
+ preparePrefs(): Promise<void>;
792
830
  esbuild(): Promise<esbuild.BuildResult<esbuild.BuildOptions>[]> | undefined;
793
831
  makeUpdateJson(): Promise<void>;
794
832
  pack(): Promise<void>;
@@ -816,7 +854,6 @@ declare class Serve extends Base {
816
854
  private builder;
817
855
  private runner?;
818
856
  private _zoteroBinPath?;
819
- private _profilePath?;
820
857
  constructor(ctx: Context);
821
858
  run(): Promise<void>;
822
859
  /**
@@ -828,8 +865,8 @@ declare class Serve extends Base {
828
865
  exit: () => never;
829
866
  private onZoteroExit;
830
867
  get zoteroBinPath(): string;
831
- get profilePath(): string;
832
- get dataDir(): string;
868
+ get profilePath(): string | undefined;
869
+ get dataDir(): string | undefined;
833
870
  }
834
871
 
835
872
  declare class Test extends Base {
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.rCsToUj_.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
@@ -7,14 +7,14 @@ 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
+ import 'node:fs';
13
14
  import 'node:path';
14
15
  import 'adm-zip';
15
16
  import 'esbuild';
16
17
  import 'node:crypto';
17
- import 'node:fs';
18
18
  import 'node:child_process';
19
19
  import 'bumpp';
20
20
  import 'chokidar';