Skip to content

Commit 8a90c3b

Browse files
committed
chore(deps): update to types v4 and toolkit v5
1 parent 585cf93 commit 8a90c3b

File tree

7 files changed

+79
-90
lines changed

7 files changed

+79
-90
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ node_modules
66
pnpm-lock.yaml
77
yarn.lock
88

9+
# TSC
10+
tsconfig.tsbuildinfo
11+
912
# Scaffold
1013
.env
1114
.scaffold

package-lock.json

Lines changed: 62 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"update-deps": "npm update --save"
3131
},
3232
"dependencies": {
33-
"zotero-plugin-toolkit": "^4.1.2"
33+
"zotero-plugin-toolkit": "^5.0.0-0"
3434
},
3535
"devDependencies": {
3636
"@eslint/js": "^9.23.0",
@@ -40,7 +40,7 @@
4040
"typescript": "^5.8.2",
4141
"typescript-eslint": "^8.28.0",
4242
"zotero-plugin-scaffold": "^0.4.1",
43-
"zotero-types": "^3.1.9"
43+
"zotero-types": "^4.0.0-beta.3"
4444
},
4545
"prettier": {
4646
"printWidth": 80,

src/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function onStartup() {
3939
);
4040
}
4141

42-
async function onMainWindowLoad(win: Window): Promise<void> {
42+
async function onMainWindowLoad(win: _ZoteroTypes.MainWindow): Promise<void> {
4343
// Create ztoolkit for every window
4444
addon.data.ztoolkit = createZToolkit();
4545

src/modules/examples.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class KeyExampleFactory {
123123

124124
export class UIExampleFactory {
125125
@example
126-
static registerStyleSheet(win: Window) {
126+
static registerStyleSheet(win: _ZoteroTypes.MainWindow) {
127127
const doc = win.document;
128128
const styles = ztoolkit.UI.createElement(doc, "link", {
129129
properties: {
@@ -132,7 +132,7 @@ export class UIExampleFactory {
132132
href: `chrome://${addon.data.config.addonRef}/content/zoteroPane.css`,
133133
},
134134
});
135-
doc.documentElement.appendChild(styles);
135+
doc.documentElement?.appendChild(styles);
136136
doc.getElementById("zotero-item-pane-content")?.classList.add("makeItRed");
137137
}
138138

@@ -165,7 +165,7 @@ export class UIExampleFactory {
165165
],
166166
},
167167
"before",
168-
win.document.querySelector(
168+
win.document?.querySelector(
169169
"#zotero-itemmenu-addontemplate-test",
170170
) as XUL.MenuItem,
171171
);
@@ -208,12 +208,9 @@ export class UIExampleFactory {
208208
dataProvider: (item: Zotero.Item, dataKey: string) => {
209209
return field + String(item.id);
210210
},
211-
renderCell(index, data, column) {
211+
renderCell(index, data, column, isFirstColumn, doc) {
212212
ztoolkit.log("Custom column cell is rendered!");
213-
const span = Zotero.getMainWindow().document.createElementNS(
214-
"http://www.w3.org/1999/xhtml",
215-
"span",
216-
);
213+
const span = doc.createElement("span");
217214
span.className = `cell ${column.className}`;
218215
span.style.background = "#0dd068";
219216
span.innerText = "⭐" + data;
@@ -502,7 +499,7 @@ export class PromptExampleFactory {
502499
ids.forEach((id: number) => {
503500
const item = Zotero.Items.get(id);
504501
const title = item.getField("title");
505-
const ele = ztoolkit.UI.createElement(window.document, "div", {
502+
const ele = ztoolkit.UI.createElement(window.document!, "div", {
506503
namespace: "html",
507504
classList: ["command"],
508505
listeners: [

src/modules/preferenceScript.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ async function updatePrefsUI() {
108108

109109
function bindPrefEvents() {
110110
addon.data
111-
.prefs!.window.document.querySelector(
111+
.prefs!.window.document?.querySelector(
112112
`#zotero-prefpane-${config.addonRef}-enable`,
113113
)
114-
?.addEventListener("command", (e) => {
114+
?.addEventListener("command", (e: Event) => {
115115
ztoolkit.log(e);
116116
addon.data.prefs!.window.alert(
117117
`Successfully changed to ${(e.target as XUL.Checkbox).checked}!`,
118118
);
119119
});
120120

121121
addon.data
122-
.prefs!.window.document.querySelector(
122+
.prefs!.window.document?.querySelector(
123123
`#zotero-prefpane-${config.addonRef}-input`,
124124
)
125-
?.addEventListener("change", (e) => {
125+
?.addEventListener("change", (e: Event) => {
126126
ztoolkit.log(e);
127127
addon.data.prefs!.window.alert(
128128
`Successfully changed to ${(e.target as HTMLInputElement).value}!`,

tsconfig.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2016",
4-
"lib": ["ESNext"],
5-
"experimentalDecorators": true,
6-
"module": "ESNext",
7-
"moduleResolution": "bundler",
8-
"resolveJsonModule": true,
9-
"types": ["zotero-types"],
10-
"strict": true,
11-
"outDir": "build/dist/",
12-
"skipLibCheck": true
13-
},
2+
"extends": "zotero-types/entries/sandbox/",
143
"include": ["src", "typings"],
154
"exclude": ["build", "addon"]
165
}

0 commit comments

Comments
 (0)