zotero-plugin-scaffold 0.2.0-beta.17 → 0.2.0-beta.19
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/chunks/github.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import process from 'node:process';
|
|
|
4
4
|
import { Octokit } from 'octokit';
|
|
5
5
|
import { globSync, glob } from 'tinyglobby';
|
|
6
6
|
import { isCI } from 'std-env';
|
|
7
|
-
import { B as Base } from '../shared/zotero-plugin-scaffold.
|
|
7
|
+
import { B as Base } from '../shared/zotero-plugin-scaffold.Bp11r5bw.mjs';
|
|
8
8
|
import 'c12';
|
|
9
9
|
import 'es-toolkit';
|
|
10
10
|
import 'fs-extra/esm';
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import { Command } from '@commander-js/extra-typings';
|
|
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.
|
|
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.Bp11r5bw.mjs';
|
|
4
4
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { pathExists, ensureFile } from 'fs-extra';
|
|
6
6
|
import tinyUpdateNotifier from 'tiny-update-notifier';
|
|
@@ -30,7 +30,7 @@ import 'xvfb-ts';
|
|
|
30
30
|
|
|
31
31
|
const name = "zotero-plugin-scaffold";
|
|
32
32
|
const type = "module";
|
|
33
|
-
const version = "0.2.0-beta.
|
|
33
|
+
const version = "0.2.0-beta.19";
|
|
34
34
|
const packageManager = "pnpm@9.15.2";
|
|
35
35
|
const description = "A scaffold for Zotero plugin development.";
|
|
36
36
|
const author = "northword";
|
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.
|
|
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.Bp11r5bw.mjs';
|
|
2
2
|
import 'c12';
|
|
3
3
|
import 'es-toolkit';
|
|
4
4
|
import 'fs-extra/esm';
|
package/dist/shared/{zotero-plugin-scaffold.0wXNVWwS.mjs → zotero-plugin-scaffold.Bp11r5bw.mjs}
RENAMED
|
@@ -303,22 +303,38 @@ class PrefsManager {
|
|
|
303
303
|
this.namespace = namespace;
|
|
304
304
|
}
|
|
305
305
|
parse(content) {
|
|
306
|
+
const _map = {};
|
|
306
307
|
const prefPattern = /^(pref|user_pref)\s*\(\s*["']([^"']+)["']\s*,\s*(.+)\s*\)\s*;$/gm;
|
|
307
308
|
const matches = content.matchAll(prefPattern);
|
|
308
309
|
for (const match of matches) {
|
|
309
310
|
const key = match[2].trim();
|
|
310
311
|
const value = match[3].trim();
|
|
311
|
-
this.
|
|
312
|
+
_map[key] = this.cleanValue(value);
|
|
312
313
|
}
|
|
314
|
+
return _map;
|
|
315
|
+
}
|
|
316
|
+
cleanValue(value) {
|
|
317
|
+
if (value === "true")
|
|
318
|
+
return true;
|
|
319
|
+
else if (value === "false")
|
|
320
|
+
return false;
|
|
321
|
+
else if (!Number.isNaN(Number(value)))
|
|
322
|
+
return Number(value);
|
|
323
|
+
else if (value.match(/^["'](.*)["']$/))
|
|
324
|
+
return value.replace(/^["'](.*)["']$/, "$1");
|
|
325
|
+
else
|
|
326
|
+
return value;
|
|
313
327
|
}
|
|
314
328
|
render() {
|
|
315
329
|
return Object.entries(this.prefs).map(([key, value]) => {
|
|
316
|
-
|
|
317
|
-
|
|
330
|
+
const _v = typeof value === "string" ? `"${value}"` : value;
|
|
331
|
+
return `${this.namespace}("${key}", ${_v});`;
|
|
332
|
+
}).join("\n");
|
|
318
333
|
}
|
|
319
334
|
async read(path) {
|
|
320
335
|
const content = await readFile(path, "utf-8");
|
|
321
|
-
this.parse(content);
|
|
336
|
+
const map = this.parse(content);
|
|
337
|
+
this.setPrefs(map);
|
|
322
338
|
}
|
|
323
339
|
async write(path) {
|
|
324
340
|
const content = this.render();
|
|
@@ -326,26 +342,13 @@ class PrefsManager {
|
|
|
326
342
|
logger.debug("The <profile>/prefs.js has been modified.");
|
|
327
343
|
}
|
|
328
344
|
setPref(key, value) {
|
|
329
|
-
let cleanValue;
|
|
330
345
|
if (value === null || value === void 0) {
|
|
331
346
|
if (key in this.prefs)
|
|
332
347
|
delete this.prefs[key];
|
|
333
348
|
else
|
|
334
349
|
return;
|
|
335
|
-
} else if (value === "true") {
|
|
336
|
-
cleanValue = true;
|
|
337
|
-
} else if (value === "false") {
|
|
338
|
-
cleanValue = false;
|
|
339
|
-
} else if (typeof value === "boolean") {
|
|
340
|
-
cleanValue = value;
|
|
341
|
-
} else if (typeof value === "string") {
|
|
342
|
-
cleanValue = value;
|
|
343
|
-
} else if (typeof value === "number") {
|
|
344
|
-
cleanValue = value;
|
|
345
|
-
} else {
|
|
346
|
-
cleanValue = value;
|
|
347
350
|
}
|
|
348
|
-
this.prefs[key] =
|
|
351
|
+
this.prefs[key] = value;
|
|
349
352
|
}
|
|
350
353
|
setPrefs(prefs) {
|
|
351
354
|
Object.entries(prefs).forEach(([key, value]) => {
|
|
@@ -379,28 +382,23 @@ class PrefsManager {
|
|
|
379
382
|
return _prefs;
|
|
380
383
|
}
|
|
381
384
|
}
|
|
382
|
-
function renderPluginPrefsDts(prefs
|
|
383
|
-
|
|
385
|
+
function renderPluginPrefsDts(prefs) {
|
|
386
|
+
return `// Generated by zotero-plugin-scaffold
|
|
384
387
|
/* prettier-ignore */
|
|
385
388
|
/* eslint-disable */
|
|
386
389
|
// @ts-nocheck
|
|
387
390
|
|
|
388
391
|
// prettier-ignore
|
|
389
|
-
|
|
390
|
-
|
|
392
|
+
declare namespace _ZoteroTypes {
|
|
393
|
+
interface Prefs {
|
|
394
|
+
PluginPrefsMap: {
|
|
395
|
+
${Object.entries(prefs).map(([key, value]) => {
|
|
391
396
|
return `"${key}": ${typeof value};`;
|
|
392
|
-
}).join("\n
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
type PluginPrefKey<K extends keyof _PluginPrefsMap> = \`${prefix}.\${K}\`;
|
|
397
|
-
|
|
398
|
-
// prettier-ignore
|
|
399
|
-
type PluginPrefsMap = {
|
|
400
|
-
[K in keyof _PluginPrefsMap as PluginPrefKey<K>]: _PluginPrefsMap[K]
|
|
401
|
-
};
|
|
397
|
+
}).join("\n ")}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
}
|
|
402
401
|
`;
|
|
403
|
-
return dtsContent;
|
|
404
402
|
}
|
|
405
403
|
|
|
406
404
|
class Base {
|
|
@@ -586,7 +584,7 @@ class Build extends Base {
|
|
|
586
584
|
const prefsWithPrefix = prefsManager.getPrefsWithPrefix(prefix);
|
|
587
585
|
const prefsWithoutPrefix = prefsManager.getPrefsWithoutPrefix(prefix);
|
|
588
586
|
if (dts) {
|
|
589
|
-
const dtsContent = renderPluginPrefsDts(prefsWithoutPrefix
|
|
587
|
+
const dtsContent = renderPluginPrefsDts(prefsWithoutPrefix);
|
|
590
588
|
await outputFile(dts, dtsContent, "utf-8");
|
|
591
589
|
}
|
|
592
590
|
if (prefixPrefKeys) {
|
package/package.json
CHANGED