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
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,7 +1,13 @@
|
|||||||
build
|
# dot files
|
||||||
logs
|
.DS_Store
|
||||||
|
|
||||||
|
# Node.js
|
||||||
node_modules
|
node_modules
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
yarn.lock
|
yarn.lock
|
||||||
.DS_Store
|
|
||||||
|
# Scaffold
|
||||||
.env
|
.env
|
||||||
|
.scaffold
|
||||||
|
build
|
||||||
|
logs
|
@ -7,7 +7,7 @@
|
|||||||
<label><html:h2 data-l10n-id="pref-title"></html:h2></label>
|
<label><html:h2 data-l10n-id="pref-title"></html:h2></label>
|
||||||
<checkbox
|
<checkbox
|
||||||
id="zotero-prefpane-__addonRef__-enable"
|
id="zotero-prefpane-__addonRef__-enable"
|
||||||
preference="extensions.zotero.__addonRef__.enable"
|
preference="enable"
|
||||||
data-l10n-id="pref-enable"
|
data-l10n-id="pref-enable"
|
||||||
/>
|
/>
|
||||||
<hbox>
|
<hbox>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<html:input
|
<html:input
|
||||||
type="text"
|
type="text"
|
||||||
id="zotero-prefpane-__addonRef__-input"
|
id="zotero-prefpane-__addonRef__-input"
|
||||||
preference="extensions.zotero.__addonRef__.input"
|
preference="input"
|
||||||
></html:input>
|
></html:input>
|
||||||
</hbox>
|
</hbox>
|
||||||
<hbox class="virtualized-table-container" flex="1" height="300px">
|
<hbox class="virtualized-table-container" flex="1" height="300px">
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
pref("__prefsPrefix__.enable", true);
|
pref("enable", true);
|
||||||
pref("__prefsPrefix__.input", "This is input");
|
pref("input", "This is input");
|
||||||
|
@ -5,7 +5,7 @@ import tseslint from "typescript-eslint";
|
|||||||
|
|
||||||
export default tseslint.config(
|
export default tseslint.config(
|
||||||
{
|
{
|
||||||
ignores: ["build/**", "dist/**", "node_modules/**", "scripts/"],
|
ignores: ["build/**", ".scaffold/**", "node_modules/**", "scripts/"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
|
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",
|
"license": "AGPL-3.0-or-later",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "zotero-plugin serve",
|
"start": "zotero-plugin serve",
|
||||||
"build": "tsc --noEmit && zotero-plugin build",
|
"build": "zotero-plugin build && tsc --noEmit",
|
||||||
"lint:check": "prettier --check . && eslint .",
|
"lint:check": "prettier --check . && eslint .",
|
||||||
"lint:fix": "prettier --write . && eslint . --fix",
|
"lint:fix": "prettier --write . && eslint . --fix",
|
||||||
"release": "zotero-plugin release",
|
"release": "zotero-plugin release",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"typescript-eslint": "^8.21.0",
|
"typescript-eslint": "^8.21.0",
|
||||||
"zotero-plugin-scaffold": "^0.1.7",
|
"zotero-plugin-scaffold": "^0.2.0",
|
||||||
"zotero-types": "^3.1.6"
|
"zotero-types": "^3.1.6"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import { config } from "../../package.json";
|
import { config } from "../../package.json";
|
||||||
|
|
||||||
|
type PluginPrefsMap = _ZoteroTypes.Prefs["PluginPrefsMap"];
|
||||||
|
|
||||||
|
const PREFS_PREFIX = config.prefsPrefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get preference value.
|
* Get preference value.
|
||||||
* Wrapper of `Zotero.Prefs.get`.
|
* Wrapper of `Zotero.Prefs.get`.
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
export function getPref(key: string) {
|
export function getPref<K extends keyof PluginPrefsMap>(key: K) {
|
||||||
return Zotero.Prefs.get(`${config.prefsPrefix}.${key}`, true);
|
return Zotero.Prefs.get(`${PREFS_PREFIX}.${key}`, true) as PluginPrefsMap[K];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,8 +19,11 @@ export function getPref(key: string) {
|
|||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
export function setPref(key: string, value: string | number | boolean) {
|
export function setPref<K extends keyof PluginPrefsMap>(
|
||||||
return Zotero.Prefs.set(`${config.prefsPrefix}.${key}`, value, true);
|
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
|
* @param key
|
||||||
*/
|
*/
|
||||||
export function clearPref(key: string) {
|
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({
|
export default defineConfig({
|
||||||
source: ["src", "addon"],
|
source: ["src", "addon"],
|
||||||
dist: "build",
|
dist: ".scaffold/build",
|
||||||
name: pkg.config.addonName,
|
name: pkg.config.addonName,
|
||||||
id: pkg.config.addonID,
|
id: pkg.config.addonID,
|
||||||
namespace: pkg.config.addonRef,
|
namespace: pkg.config.addonRef,
|
||||||
@ -23,6 +23,9 @@ export default defineConfig({
|
|||||||
buildVersion: pkg.version,
|
buildVersion: pkg.version,
|
||||||
buildTime: "{{buildTime}}",
|
buildTime: "{{buildTime}}",
|
||||||
},
|
},
|
||||||
|
prefs: {
|
||||||
|
prefix: pkg.config.prefsPrefix,
|
||||||
|
},
|
||||||
esbuildOptions: [
|
esbuildOptions: [
|
||||||
{
|
{
|
||||||
entryPoints: ["src/index.ts"],
|
entryPoints: ["src/index.ts"],
|
||||||
@ -31,7 +34,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
bundle: true,
|
bundle: true,
|
||||||
target: "firefox115",
|
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