zotero-plugin-scaffold 0.8.0 → 0.8.2

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as Base, C as Context, O as OverrideConfig } from './shared/zotero-plugin-scaffold.fkuivpCE.mjs';
1
+ import { B as Base, C as Context, O as OverrideConfig } from './shared/zotero-plugin-scaffold.D0-KTF5z.mjs';
2
2
  import 'hookable';
3
3
  import 'esbuild';
4
4
 
package/dist/cli.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import process from 'node:process';
2
2
  import { Command } from 'commander';
3
- import { E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.8gLns8GX.mjs';
3
+ import { E as ExitSignals, C as Config, B as Build, S as Serve, T as Test, R as Release } from './shared/zotero-plugin-scaffold.DQYuTa0n.mjs';
4
4
  import { readFile } from 'node:fs/promises';
5
5
  import { pathExists } from 'fs-extra';
6
- import { l as logger } from './shared/zotero-plugin-scaffold.CzBjWbS8.mjs';
6
+ import { l as logger } from './shared/zotero-plugin-scaffold.qsx_2VJx.mjs';
7
7
  import tinyUpdateNotifier from 'tiny-update-notifier';
8
8
  import 'c12';
9
9
  import 'es-toolkit';
@@ -36,7 +36,7 @@ import 'node:http';
36
36
  import 'node:readline';
37
37
 
38
38
  const name = "zotero-plugin-scaffold";
39
- const version = "0.8.0";
39
+ const version = "0.8.2";
40
40
  const pkg = {
41
41
  name: name,
42
42
  version: version};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { U as UserConfig, O as OverrideConfig, C as Context, B as Base } from './shared/zotero-plugin-scaffold.fkuivpCE.mjs';
1
+ import { U as UserConfig, O as OverrideConfig, C as Context, B as Base } from './shared/zotero-plugin-scaffold.D0-KTF5z.mjs';
2
2
  import 'hookable';
3
3
  import 'esbuild';
4
4
 
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
- export { B as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.8gLns8GX.mjs';
1
+ export { B as Build, C as Config, R as Release, S as Serve, T as Test, d as defineConfig } from './shared/zotero-plugin-scaffold.DQYuTa0n.mjs';
2
2
  import 'c12';
3
3
  import 'es-toolkit';
4
4
  import 'fs-extra/esm';
5
5
  import 'hookable';
6
- import './shared/zotero-plugin-scaffold.CzBjWbS8.mjs';
6
+ import './shared/zotero-plugin-scaffold.qsx_2VJx.mjs';
7
7
  import 'node:fs/promises';
8
8
  import 'tinyglobby';
9
9
  import 'node:process';
@@ -525,6 +525,14 @@ interface ServerConfig {
525
525
  * @default []
526
526
  */
527
527
  startArgs: string[];
528
+ /**
529
+ * The default preferences for the dev server.
530
+ * These preferences will be set before Zotero starts.
531
+ *
532
+ * 开发服务器的默认首选项。
533
+ * 这些首选项将在 Zotero 启动前设置。
534
+ */
535
+ prefs: Record<string, string | number | boolean>;
528
536
  /**
529
537
  * Install the plugin as a Proxy File mode.
530
538
  *
@@ -2,7 +2,7 @@ import { loadConfig as loadConfig$1, setupDotenv } from 'c12';
2
2
  import { kebabCase, mapValues, toMerged, escapeRegExp, debounce, delay } from 'es-toolkit';
3
3
  import { readJsonSync, copy, move, outputFile, readJSON, outputJSON, writeJson, emptyDir, pathExists, ensureDir, remove } from 'fs-extra/esm';
4
4
  import { createHooks } from 'hookable';
5
- import { l as logger, p as parseRepoUrl, d as dateFormat, t as template, b as toArray, s as styleText, c as replaceDefine, L as LOG_LEVEL } from './zotero-plugin-scaffold.CzBjWbS8.mjs';
5
+ import { l as logger, p as parseRepoUrl, d as dateFormat, t as template, b as toArray, s as stdout, c as replaceDefine, L as LOG_LEVEL } from './zotero-plugin-scaffold.qsx_2VJx.mjs';
6
6
  import process$1 from 'node:process';
7
7
  import { glob, globSync } from 'tinyglobby';
8
8
  import path, { resolve as resolve$1, dirname, basename, join as join$1, isAbsolute as isAbsolute$1, extname as extname$1 } from 'node:path';
@@ -133,6 +133,7 @@ const defaultConfig = {
133
133
  server: {
134
134
  devtools: true,
135
135
  startArgs: [],
136
+ prefs: {},
136
137
  asProxy: false,
137
138
  prebuild: true,
138
139
  // keepProfileChanges: true,
@@ -374,7 +375,7 @@ class MessageManager {
374
375
  return;
375
376
  const missingLocales = [...this.ftlMessages.entries()].filter(([_, messages]) => !messages.has(msg)).map(([locale]) => locale);
376
377
  if (missingLocales.length > 0)
377
- logger.warn(`I10N id ${styleText.blue(msg)} missing in locale: ${missingLocales.join(", ")}`);
378
+ logger.warn(`I10N id ${stdout.blue(msg)} missing in locale: ${missingLocales.join(", ")}`);
378
379
  });
379
380
  }
380
381
  getFTLMessages() {
@@ -397,11 +398,11 @@ function processHTMLFile(content, namespace, allMessages, ignores, filePath) {
397
398
  const processed = content.replace(L10N_PATTERN, (match, attr, id) => {
398
399
  foundMessages.add(id);
399
400
  if (ignores.includes(id)) {
400
- logger.debug(`Skipped ignored ID: ${styleText.blue(id)} in ${styleText.gray(filePath)}`);
401
+ logger.debug(`Skipped ignored ID: ${stdout.blue(id)} in ${stdout.gray(filePath)}`);
401
402
  return match;
402
403
  }
403
404
  if (!allMessages.has(id)) {
404
- logger.warn(`I10N id ${styleText.blue(id)} in path ${styleText.gray(filePath)} does not exist in any locale, skip renaming it.`);
405
+ logger.warn(`I10N id ${stdout.blue(id)} in path ${stdout.gray(filePath)} does not exist in any locale, skip renaming it.`);
405
406
  return match;
406
407
  }
407
408
  return `${attr}="${namespace}-${id}"`;
@@ -683,7 +684,7 @@ async function buildPrefs(dist, options) {
683
684
  Object.entries(prefs).forEach(([key, value]) => {
684
685
  if (typeof value === "number") {
685
686
  if (!is32BitNumber(value)) {
686
- logger.warn(`Pref key '${styleText.blue(key)}' is a number, but is more than 4 bytes, which can be problematic on some OS.`);
687
+ logger.warn(`Pref key '${stdout.blue(key)}' is a number, but is more than 4 bytes, which can be problematic on some OS.`);
687
688
  }
688
689
  }
689
690
  });
@@ -705,17 +706,17 @@ async function buildPrefs(dist, options) {
705
706
  for (const match of matchs) {
706
707
  const [matched, key] = match;
707
708
  if (key.startsWith(prefix)) {
708
- logger.debug(`Pref key '${styleText.blue(key)}' is already starts with '${prefix}', skip prefixing it.`);
709
+ logger.debug(`Pref key '${stdout.blue(key)}' is already starts with '${prefix}', skip prefixing it.`);
709
710
  continue;
710
711
  } else if (key.startsWith("extensions.")) {
711
- logger.warn(`Pref key '${styleText.blue(key)}' in ${styleText.gray(path)} starts with 'extensions.' but not '${styleText.blue(prefix)}', skip prefixing it.`);
712
+ logger.warn(`Pref key '${stdout.blue(key)}' in ${stdout.gray(path)} starts with 'extensions.' but not '${stdout.blue(prefix)}', skip prefixing it.`);
712
713
  continue;
713
714
  } else if (!(key in prefsWithPrefix) && !(key in prefsWithoutPrefix)) {
714
- logger.warn(`Pref key '${styleText.blue(key)}' in ${styleText.gray(path)} is not found in prefs.js, skip prefixing it.`);
715
+ logger.warn(`Pref key '${stdout.blue(key)}' in ${stdout.gray(path)} is not found in prefs.js, skip prefixing it.`);
715
716
  continue;
716
717
  } else {
717
718
  const prefixed = `${prefix}.${key}`;
718
- logger.debug(`Pref key '${styleText.blue(key)}' in ${styleText.gray(path)} is prefixed to ${styleText.blue(prefixed)}.`);
719
+ logger.debug(`Pref key '${stdout.blue(key)}' in ${stdout.gray(path)} is prefixed to ${stdout.blue(prefixed)}.`);
719
720
  content = content.replace(matched, `preference="${prefixed}"`);
720
721
  }
721
722
  }
@@ -816,7 +817,7 @@ class Build extends Base {
816
817
  const { dist, version } = this.ctx;
817
818
  const t = /* @__PURE__ */ new Date();
818
819
  this.buildTime = dateFormat("YYYY-mm-dd HH:MM:SS", t);
819
- this.logger.info(`Building version ${styleText.blue(version)} to ${styleText.blue(dist)} at ${styleText.blue(this.buildTime)} in ${styleText.blue(process$1.env.NODE_ENV)} mode.`);
820
+ this.logger.info(`Building version ${stdout.blue(version)} to ${stdout.blue(dist)} at ${stdout.blue(this.buildTime)} in ${stdout.blue(process$1.env.NODE_ENV)} mode.`);
820
821
  await this.ctx.hooks.callHook("build:init", this.ctx);
821
822
  this.logger.tip("Preparing static assets", { space: 1 });
822
823
  await this.prepareAssets();
@@ -3919,9 +3920,9 @@ class ZoteroRunner {
3919
3920
  const prefsPath = join$1(this.options.profile.path, "prefs.js");
3920
3921
  const prefsManager = new PrefsManager("user_pref");
3921
3922
  prefsManager.setPrefs(prefs);
3922
- prefsManager.setPrefs(this.options.profile.customPrefs);
3923
3923
  if (await pathExists(prefsPath))
3924
3924
  await prefsManager.read(prefsPath);
3925
+ prefsManager.setPrefs(this.options.profile.customPrefs);
3925
3926
  prefsManager.setPrefs({
3926
3927
  "extensions.lastAppBuildId": null,
3927
3928
  "extensions.lastAppVersion": null
@@ -4136,7 +4137,8 @@ class Serve extends Base {
4136
4137
  path: this.profilePath,
4137
4138
  dataDir: this.dataDir,
4138
4139
  // keepChanges: this.ctx.server.keepProfileChanges,
4139
- createIfMissing: this.ctx.server.createProfileIfMissing
4140
+ createIfMissing: this.ctx.server.createProfileIfMissing,
4141
+ customPrefs: this.ctx.server.prefs
4140
4142
  },
4141
4143
  plugins: {
4142
4144
  list: [{
@@ -4354,7 +4356,7 @@ class TestHttpReporter {
4354
4356
  logger.tip(data.title, logger_option);
4355
4357
  break;
4356
4358
  case "pass":
4357
- logger.success(`${data.title} ${styleText.gray(`${data.duration}ms`)}`, logger_option);
4359
+ logger.success(`${data.title} ${stdout.gray(`${data.duration}ms`)}`, logger_option);
4358
4360
  break;
4359
4361
  case "fail": {
4360
4362
  let formatOutput = function(obj, indent) {
@@ -4365,15 +4367,15 @@ class TestHttpReporter {
4365
4367
  return `${firstLine}
4366
4368
  ${restLines}`;
4367
4369
  };
4368
- logger.fail(styleText.red(`${data.title}, ${data?.error?.message}`), logger_option);
4370
+ logger.fail(stdout.red(`${data.title}, ${data?.error?.message}`), logger_option);
4369
4371
  let expected = data.error.expected;
4370
4372
  let received = data.error.actual;
4371
4373
  if (expected && typeof expected === "object")
4372
4374
  expected = formatOutput(expected, data.indents + 1);
4373
4375
  if (received && typeof received === "object")
4374
4376
  received = formatOutput(received, data.indents + 1);
4375
- logger.log(`Expected: ${styleText.green(String(expected))}`, { space: data.indents + 0.5 });
4376
- logger.log(`Received: ${styleText.red(String(received))}`, { space: data.indents + 0.5 });
4377
+ logger.log(`Expected: ${stdout.green(String(expected))}`, { space: data.indents + 0.5 });
4378
+ logger.log(`Received: ${stdout.red(String(received))}`, { space: data.indents + 0.5 });
4377
4379
  break;
4378
4380
  }
4379
4381
  case "pending":
@@ -3,16 +3,22 @@ import { glob } from 'tinyglobby';
3
3
  import process from 'node:process';
4
4
  import readline from 'node:readline';
5
5
  import { isPlainObject } from 'es-toolkit';
6
- import util from 'node:util';
6
+ import { styleText } from 'node:util';
7
7
  import { isDebug } from 'std-env';
8
8
 
9
- const factory = (...formats) =>
10
- new Proxy(util.styleText.bind(util, formats), {
11
- get: (_, format) =>
12
- util.inspect.colors[format] && factory(...formats, format),
13
- });
9
+ const factory = (styleText, options, ...formats) =>
10
+ new Proxy(
11
+ (raw, ...substitutions) =>
12
+ styleText(
13
+ formats,
14
+ raw.raw ? String.raw({raw}, ...substitutions) : raw,
15
+ options,
16
+ ),
17
+ {get: (_, format) => factory(styleText, options, ...formats, format)},
18
+ );
14
19
 
15
- const styleText = factory();
20
+ const stdout = factory(styleText, {stream: process.stdout});
21
+ factory(styleText, {stream: process.stderr});
16
22
 
17
23
  var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
18
24
  LOG_LEVEL2[LOG_LEVEL2["TRACE"] = 0] = "TRACE";
@@ -23,13 +29,13 @@ var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
23
29
  return LOG_LEVEL2;
24
30
  })(LOG_LEVEL || {});
25
31
  const SYMBOLS = {
26
- SUCCESS: styleText.green("\u2714"),
27
- INFO: styleText.blue("\u2139"),
28
- FAIL: styleText.red("\u2716"),
29
- TIP: styleText.blue("\u2192"),
30
- ERROR: styleText.bgRed(" ERROR "),
31
- WARN: styleText.bgYellow(" WARN "),
32
- DEBUG: styleText.grey("\u2699"),
32
+ SUCCESS: stdout.green("\u2714"),
33
+ INFO: stdout.blue("\u2139"),
34
+ FAIL: stdout.red("\u2716"),
35
+ TIP: stdout.blue("\u2192"),
36
+ ERROR: stdout.bgRed(" ERROR "),
37
+ WARN: stdout.bgYellow(" WARN "),
38
+ DEBUG: stdout.grey("\u2699"),
33
39
  NONE: ""
34
40
  };
35
41
  const DEFAULT_OPTIONS = {
@@ -112,7 +118,7 @@ class Logger {
112
118
  return String(content);
113
119
  }
114
120
  formatError(error) {
115
- return `${styleText.red(error.name)}: ${styleText.red(error.message)}
121
+ return `${stdout.red(error.name)}: ${stdout.red(error.message)}
116
122
  ${error.stack}`;
117
123
  }
118
124
  /**
@@ -157,7 +163,7 @@ ${error.stack}`;
157
163
  this.logInternal(content, LOG_METHODS_CONFIG.fail, options);
158
164
  }
159
165
  ready(content) {
160
- this.logInternal(styleText.green(content), LOG_METHODS_CONFIG.success);
166
+ this.logInternal(stdout.green(content), LOG_METHODS_CONFIG.success);
161
167
  }
162
168
  log(content, options) {
163
169
  this.logInternal(content, LOG_METHODS_CONFIG.log, options);
@@ -254,4 +260,4 @@ async function replaceDefine(dist, define) {
254
260
  });
255
261
  }
256
262
 
257
- export { LOG_LEVEL as L, replaceInFile as a, toArray as b, replaceDefine as c, dateFormat as d, logger as l, parseRepoUrl as p, replace as r, styleText as s, template as t };
263
+ export { LOG_LEVEL as L, replaceInFile as a, toArray as b, replaceDefine as c, dateFormat as d, logger as l, parseRepoUrl as p, replace as r, stdout as s, template as t };
@@ -1,4 +1,4 @@
1
- export { r as replace, a as replaceInFile } from '../shared/zotero-plugin-scaffold.CzBjWbS8.mjs';
1
+ export { r as replace, a as replaceInFile } from '../shared/zotero-plugin-scaffold.qsx_2VJx.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,7 +1,7 @@
1
1
  {
2
2
  "name": "zotero-plugin-scaffold",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.8.2",
5
5
  "description": "A scaffold for Zotero plugin development.",
6
6
  "author": "northword",
7
7
  "license": "AGPL-3.0-or-later",
@@ -55,39 +55,39 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@fluent/syntax": "^0.19.0",
58
- "@swc/core": "^1.13.3",
58
+ "@swc/core": "^1.15.0",
59
59
  "adm-zip": "^0.5.16",
60
- "bumpp": "^10.2.1",
61
- "c12": "^3.2.0",
60
+ "bumpp": "^10.3.1",
61
+ "c12": "^3.3.1",
62
62
  "chokidar": "^4.0.3",
63
- "commander": "^14.0.0",
64
- "es-toolkit": "^1.39.8",
65
- "esbuild": "^0.25.8",
66
- "fs-extra": "^11.3.0",
63
+ "commander": "^14.0.2",
64
+ "es-toolkit": "^1.41.0",
65
+ "esbuild": "^0.25.12",
66
+ "fs-extra": "^11.3.2",
67
67
  "hookable": "^5.5.3",
68
- "octokit": "^5.0.3",
69
- "std-env": "^3.9.0",
68
+ "octokit": "^5.0.5",
69
+ "std-env": "^3.10.0",
70
70
  "tiny-update-notifier": "^2.0.2",
71
- "tinyglobby": "^0.2.14",
72
- "xvfb-ts": "^1.1.0"
71
+ "tinyglobby": "^0.2.15",
72
+ "xvfb-ts": "^1.1.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@antfu/eslint-config": "^5.0.0",
75
+ "@antfu/eslint-config": "^6.2.0",
76
76
  "@commander-js/extra-typings": "^14.0.0",
77
77
  "@types/adm-zip": "^0.5.7",
78
78
  "@types/fs-extra": "^11.0.4",
79
- "@types/node": "^22.17.0",
80
- "bumpp": "^10.2.1",
79
+ "@types/node": "^24.10.0",
80
+ "bumpp": "^10.3.1",
81
81
  "changelogen": "^0.6.2",
82
- "eslint": "^9.32.0",
83
- "eslint-plugin-format": "^1.0.1",
82
+ "eslint": "^9.39.1",
83
+ "eslint-plugin-format": "^1.0.2",
84
84
  "husky": "^9.1.7",
85
- "lint-staged": "^16.1.2",
86
- "node-style-text": "^0.0.8",
87
- "tsx": "^4.20.3",
88
- "typescript": "^5.9.2",
89
- "unbuild": "^3.6.0",
90
- "vitest": "^3.2.4"
85
+ "lint-staged": "^16.2.6",
86
+ "node-style-text": "^2.1.2",
87
+ "tsx": "^4.20.6",
88
+ "typescript": "^5.9.3",
89
+ "unbuild": "^3.6.1",
90
+ "vitest": "^4.0.7"
91
91
  },
92
92
  "workspaces": [
93
93
  "src",