feat!: bump scaffold, parse prefs.js
(#236)
* feat!: bump scaffold, parse `prefs.js` * fix: addon not define for getPref * chore: bump deps
This commit is contained in:
parent
0d2b182f64
commit
82b19cab00
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,7 +1,13 @@
|
||||
build
|
||||
logs
|
||||
# dot files
|
||||
.DS_Store
|
||||
|
||||
# Node.js
|
||||
node_modules
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
.DS_Store
|
||||
.env
|
||||
|
||||
# Scaffold
|
||||
.env
|
||||
.scaffold
|
||||
build
|
||||
logs
|
@ -7,7 +7,7 @@
|
||||
<label><html:h2 data-l10n-id="pref-title"></html:h2></label>
|
||||
<checkbox
|
||||
id="zotero-prefpane-__addonRef__-enable"
|
||||
preference="extensions.zotero.__addonRef__.enable"
|
||||
preference="enable"
|
||||
data-l10n-id="pref-enable"
|
||||
/>
|
||||
<hbox>
|
||||
@ -18,7 +18,7 @@
|
||||
<html:input
|
||||
type="text"
|
||||
id="zotero-prefpane-__addonRef__-input"
|
||||
preference="extensions.zotero.__addonRef__.input"
|
||||
preference="input"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<hbox class="virtualized-table-container" flex="1" height="300px">
|
||||
|
@ -1,3 +1,3 @@
|
||||
/* eslint-disable no-undef */
|
||||
pref("__prefsPrefix__.enable", true);
|
||||
pref("__prefsPrefix__.input", "This is input");
|
||||
pref("enable", true);
|
||||
pref("input", "This is input");
|
||||
|
@ -5,7 +5,7 @@ import tseslint from "typescript-eslint";
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ["build/**", "dist/**", "node_modules/**", "scripts/"],
|
||||
ignores: ["build/**", ".scaffold/**", "node_modules/**", "scripts/"],
|
||||
},
|
||||
{
|
||||
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
|
||||
|
5153
package-lock.json
generated
5153
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"start": "zotero-plugin serve",
|
||||
"build": "tsc --noEmit && zotero-plugin build",
|
||||
"build": "zotero-plugin build && tsc --noEmit",
|
||||
"lint:check": "prettier --check . && eslint .",
|
||||
"lint:fix": "prettier --write . && eslint . --fix",
|
||||
"release": "zotero-plugin release",
|
||||
@ -38,7 +38,7 @@
|
||||
"prettier": "^3.4.2",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.21.0",
|
||||
"zotero-plugin-scaffold": "^0.1.7",
|
||||
"zotero-plugin-scaffold": "^0.2.0",
|
||||
"zotero-types": "^3.1.6"
|
||||
},
|
||||
"prettier": {
|
||||
|
@ -1,12 +1,16 @@
|
||||
import { config } from "../../package.json";
|
||||
|
||||
type PluginPrefsMap = _ZoteroTypes.Prefs["PluginPrefsMap"];
|
||||
|
||||
const PREFS_PREFIX = config.prefsPrefix;
|
||||
|
||||
/**
|
||||
* Get preference value.
|
||||
* Wrapper of `Zotero.Prefs.get`.
|
||||
* @param key
|
||||
*/
|
||||
export function getPref(key: string) {
|
||||
return Zotero.Prefs.get(`${config.prefsPrefix}.${key}`, true);
|
||||
export function getPref<K extends keyof PluginPrefsMap>(key: K) {
|
||||
return Zotero.Prefs.get(`${PREFS_PREFIX}.${key}`, true) as PluginPrefsMap[K];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -15,8 +19,11 @@ export function getPref(key: string) {
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
export function setPref(key: string, value: string | number | boolean) {
|
||||
return Zotero.Prefs.set(`${config.prefsPrefix}.${key}`, value, true);
|
||||
export function setPref<K extends keyof PluginPrefsMap>(
|
||||
key: K,
|
||||
value: PluginPrefsMap[K],
|
||||
) {
|
||||
return Zotero.Prefs.set(`${PREFS_PREFIX}.${key}`, value, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,5 +32,5 @@ export function setPref(key: string, value: string | number | boolean) {
|
||||
* @param key
|
||||
*/
|
||||
export function clearPref(key: string) {
|
||||
return Zotero.Prefs.clear(`${config.prefsPrefix}.${key}`, true);
|
||||
return Zotero.Prefs.clear(`${PREFS_PREFIX}.${key}`, true);
|
||||
}
|
||||
|
14
typings/prefs.d.ts
vendored
Normal file
14
typings/prefs.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Generated by zotero-plugin-scaffold
|
||||
/* prettier-ignore */
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
// prettier-ignore
|
||||
declare namespace _ZoteroTypes {
|
||||
interface Prefs {
|
||||
PluginPrefsMap: {
|
||||
"enable": boolean;
|
||||
"input": string;
|
||||
};
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import pkg from "./package.json";
|
||||
|
||||
export default defineConfig({
|
||||
source: ["src", "addon"],
|
||||
dist: "build",
|
||||
dist: ".scaffold/build",
|
||||
name: pkg.config.addonName,
|
||||
id: pkg.config.addonID,
|
||||
namespace: pkg.config.addonRef,
|
||||
@ -23,6 +23,9 @@ export default defineConfig({
|
||||
buildVersion: pkg.version,
|
||||
buildTime: "{{buildTime}}",
|
||||
},
|
||||
prefs: {
|
||||
prefix: pkg.config.prefsPrefix,
|
||||
},
|
||||
esbuildOptions: [
|
||||
{
|
||||
entryPoints: ["src/index.ts"],
|
||||
@ -31,7 +34,7 @@ export default defineConfig({
|
||||
},
|
||||
bundle: true,
|
||||
target: "firefox115",
|
||||
outfile: `build/addon/content/scripts/${pkg.config.addonRef}.js`,
|
||||
outfile: `.scaffold/build/addon/content/scripts/${pkg.config.addonRef}.js`,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user