From 1eb8a3e9ad5df7f890d6145e661bcade60ddf131 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Mon, 24 Feb 2025 18:02:20 +0100 Subject: [PATCH 1/2] fix zotero-types configuration (#3157) remove skipLibCheck remove zotero-types from include --- content/ExportOptions.ts | 11 ++- content/Preferences.ts | 18 +++-- content/better-bibtex.ts | 1 - .../templates/items/serialized-item.d.ts.mako | 2 +- tsconfig.json | 4 +- typings/async-indexed-db.d.ts | 4 +- typings/markup.d.ts | 2 + typings/puqeue.d.ts | 8 +-- typings/translators.d.ts | 1 - typings/xul.d.ts | 70 ------------------- 10 files changed, 24 insertions(+), 97 deletions(-) delete mode 100644 typings/xul.d.ts diff --git a/content/ExportOptions.ts b/content/ExportOptions.ts index 8cc55f0ad3..3c84ebd9be 100644 --- a/content/ExportOptions.ts +++ b/content/ExportOptions.ts @@ -1,7 +1,6 @@ import { Monkey } from './monkey-patch' import * as l10n from './l10n' import { Events } from './events' -import type { XUL } from '../typings/xul' let enabled = true @@ -27,11 +26,11 @@ Events.on('window-loaded', ({ win, href }: { win: Window; href: string }) => { }) function mutex(e?: Event): void { - const exportFileData = document.getElementById('export-option-exportFileData') as XUL.Checkbox - const keepUpdated = document.getElementById('export-option-keepUpdated') as XUL.Checkbox - const worker = document.getElementById('export-option-worker') as XUL.Checkbox - const biblatexAPA = document.getElementById('export-option-biblatexAPA') as XUL.Checkbox - const biblatexChicago = document.getElementById('export-option-biblatexChicago') as XUL.Checkbox + const exportFileData = document.getElementById('export-option-exportFileData') as unknown as XUL.Checkbox + const keepUpdated = document.getElementById('export-option-keepUpdated') as unknown as XUL.Checkbox + const worker = document.getElementById('export-option-worker') as unknown as XUL.Checkbox + const biblatexAPA = document.getElementById('export-option-biblatexAPA') as unknown as XUL.Checkbox + const biblatexChicago = document.getElementById('export-option-biblatexChicago') as unknown as XUL.Checkbox if (!exportFileData || !keepUpdated) return null diff --git a/content/Preferences.ts b/content/Preferences.ts index 977d8db6e8..46b93fadc3 100644 --- a/content/Preferences.ts +++ b/content/Preferences.ts @@ -1,8 +1,6 @@ import * as client from './client' import { Path } from './file' -import type { XUL } from '../typings/xul' - import { log } from './logger' import { Preference } from './prefs' @@ -42,7 +40,7 @@ Events.on('preference-changed', (pref: string) => { } }) -function setQuickCopy(node: XUL.Menuitem): void { +function setQuickCopy(node: XUL.MenuItem): void { if (!node) return let mode = '' @@ -89,7 +87,7 @@ class ZoteroPreferences { this.observed = [...node.getElementsByTagNameNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menulist')].find(added => added.id === 'zotero-quickCopy-menu') this.observer.observe(this.observed, { childList: true, subtree: true }) } - else if (this.observed?.tagName === 'menulist' && (node = [...mutation.addedNodes].find((added: XUL.Menuitem) => added.tagName === 'menuitem' && added.label?.match(/Better BibTeX.*Quick Copy/)))) { + else if (this.observed?.tagName === 'menulist' && (node = [...mutation.addedNodes].find((added: XUL.MenuItem) => added.tagName === 'menuitem' && added.label?.match(/Better BibTeX.*Quick Copy/)))) { node.id = 'translator-bbt-quick-copy' setQuickCopy(node) } @@ -136,7 +134,7 @@ class AutoExportPane { if (details) details.style.display = auto_exports.length ? 'grid' : 'none' if (!auto_exports.length) return null - const menulist: XUL.Menulist = doc.querySelector('#bbt-prefs-auto-export-select') as XUL.Menulist + const menulist = doc.querySelector('#bbt-prefs-auto-export-select') const menupopup = doc.querySelector('#bbt-prefs-auto-export-select menupopup') let selected if (menulist.selectedItem) { @@ -145,7 +143,7 @@ class AutoExportPane { } // list changed - if (Array.from(menupopup.children).map(ae => (ae as unknown as XUL.Menuitem).value).join('\t') !== auto_exports.map(ae => ae.path).join('\t')) { + if (Array.from(menupopup.children).map(ae => (ae as unknown as XUL.MenuItem).value).join('\t') !== auto_exports.map(ae => ae.path).join('\t')) { menulist.querySelectorAll('menuitem').forEach(e => e.remove()) for (const ae of auto_exports) { const menuitem = menulist.appendItem(this.label(ae), ae.path) @@ -206,7 +204,7 @@ class AutoExportPane { case 'DOIandURL': case 'bibtexURL': - (node as unknown as XUL.Menulist).value = selected[field] + (node as unknown as XUL.MenuList).value = selected[field] break case 'cacherate': @@ -243,7 +241,7 @@ class AutoExportPane { } public async remove() { - const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist + const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList if (!menulist.selectedItem) return if (!Services.prompt.confirm(null, l10n.localize('better-bibtex_auto-export_delete'), l10n.localize('better-bibtex_auto-export_delete_confirm'))) return @@ -256,7 +254,7 @@ class AutoExportPane { } public async run() { - const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist + const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList if (!menulist.selectedItem) return AutoExport.run(menulist.selectedItem.getAttribute('value')) @@ -266,7 +264,7 @@ class AutoExportPane { public async edit(node) { let path: string if (!(path = node.getAttribute('data-ae-path'))) { - const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist + const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList path = menulist.selectedItem.getAttribute('value') } const ae = AutoExport.get(path) diff --git a/content/better-bibtex.ts b/content/better-bibtex.ts index 4aa928bd1c..67d85fb26c 100644 --- a/content/better-bibtex.ts +++ b/content/better-bibtex.ts @@ -18,7 +18,6 @@ declare const FileUtils: any import { MenuManager } from 'zotero-plugin-toolkit' const Menu = new MenuManager -import type { XUL } from '../typings/xul' import { DebugLog } from 'zotero-plugin/debug-log' DebugLog.register('Better BibTeX', ['extensions.zotero.translators.better-bibtex.']) diff --git a/setup/templates/items/serialized-item.d.ts.mako b/setup/templates/items/serialized-item.d.ts.mako index 3673334b1b..94a01ab406 100644 --- a/setup/templates/items/serialized-item.d.ts.mako +++ b/setup/templates/items/serialized-item.d.ts.mako @@ -44,7 +44,7 @@ export interface Attachment extends ItemBase { export interface RegularItem extends ItemBase { itemType: ${' | '.join(["'" + itemType + "'" for itemType in itemTypes if itemType not in ['note', 'annotation', 'attachment']])} - citationKey: string + // citationKey: string // fields common to all items creators: Array diff --git a/tsconfig.json b/tsconfig.json index 6fed8dc1b7..d934b450c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,13 +16,14 @@ "downlevelIteration": true, "resolveJsonModule": true, "moduleResolution": "node", - "skipLibCheck": true, "typeRoots": [ + "./node_modules", "./node_modules/@types", "./gen/typings", "./typings" ], "skipDefaultLibCheck": true, + "types": ["zotero-types"], "lib": [ "es2017", "dom", "dom.iterable", "webworker", "ES2021.WeakRef" ] }, "include": [ @@ -31,7 +32,6 @@ "setup/**/*", "gen/**/*", "typings/*", - "node_modules/zotero-types" ], "exclude": [ "headless", diff --git a/typings/async-indexed-db.d.ts b/typings/async-indexed-db.d.ts index 7f54dfe874..7124cca4fe 100644 --- a/typings/async-indexed-db.d.ts +++ b/typings/async-indexed-db.d.ts @@ -14,7 +14,7 @@ declare module 'async-indexed-db' { indexNames: DOMStringList // transaction: IDBTransaction autoIncrement: boolean - async add(value: any, key?: IDBValidKey | IDBKeyRange | null): Promise + add(value: any, key?: IDBValidKey | IDBKeyRange | null): Promise clear(): Promise // count(key?: IDBValidKey | IDBKeyRange | null): IDBRequest // createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex @@ -30,5 +30,5 @@ declare module 'async-indexed-db' { // put(value: any, key?: IDBValidKey | IDBKeyRange | null): IDBRequest } - export = AsyncIndexedDB + export default AsyncIndexedDB } diff --git a/typings/markup.d.ts b/typings/markup.d.ts index 23a0e0ec35..64d31fc829 100644 --- a/typings/markup.d.ts +++ b/typings/markup.d.ts @@ -1,3 +1,5 @@ +declare type IZoteroMarkupNode = any; + export interface MarkupNode { nodeName: string childNodes?: IZoteroMarkupNode[] diff --git a/typings/puqeue.d.ts b/typings/puqeue.d.ts index 8161d587d6..b6ed05f5f9 100644 --- a/typings/puqeue.d.ts +++ b/typings/puqeue.d.ts @@ -4,13 +4,13 @@ declare module 'puqeue' { class Queue { protected _queue: Handler[] - constructor(options: { name?: string, maxOperationCount?: number } = {}) + constructor(options?: { name?: string, maxOperationCount?: number }) get name(): string get maxOperationCount(): number - set maxOperationCount(maxOperationCount: number): void + set maxOperationCount(maxOperationCount: number) get operationCount(): number - async add(todo: Handler, options: { priority?: number } = {}): Promise - async waitAll(todo: Handler): Promise + add(todo: Handler, options?: { priority?: number }): Promise + waitAll(todo: Handler): Promise } export = Queue diff --git a/typings/translators.d.ts b/typings/translators.d.ts index f042c425a3..9b066201d8 100644 --- a/typings/translators.d.ts +++ b/typings/translators.d.ts @@ -88,7 +88,6 @@ export namespace Translators { minVersion: string maxVersion: string translatorType: number - browserSupport: string inRepository: false priority: number target: string diff --git a/typings/xul.d.ts b/typings/xul.d.ts deleted file mode 100644 index 2fdbff3f6b..0000000000 --- a/typings/xul.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -export namespace XUL { - class Element extends HTMLElement { - // public tagName: string - public hidden: boolean - public disabled: boolean - // public getAttribute(name: string): string - // public setAttribute(name: string, value: string): void - // public classList: ClassList - public height?: number - public width?: number - } - - class Tabbox extends Element { - boxObject: { - public height: number - public width: number - } - } - - class Image extends Element { - public src: string - } - - class Label extends Element { - public value: string - } - - class Textbox extends XUL.Element { - public value: string - public readonly: boolean - } - - class Checkbox extends XUL.Element { - public checked: boolean - } - - class Menuitem extends XUL.Element { - public value: string - public label: string - } - - class ProgressMeter extends XUL.Element { - public value: string | number - } - - class Menupopup extends XUL.Element { - public children: Menuitem[] - } - - class Menulist extends XUL.Element { - public selectedItem?: Menuitem - public selectedIndex?: number - public value?: string - public getItemAtIndex?(index: number): XUL.Menuitem - public ensureIndexIsVisible?(index: number): void - public appendItem?(label: string, value: string, description?: string): XUL.Menuitem - public removeAllItems?(): void - } - - class Deck extends XUL.Element { - public selectedIndex: number - } -} - -class ClassList { - public add(classname: string): void - public remove(classname: string): void - public contains(classname: string): boolean -} - From bfca1946bfcc1e05891a57deca7bc3627832f3eb Mon Sep 17 00:00:00 2001 From: Emiliano Heyns Date: Mon, 24 Feb 2025 18:27:48 +0100 Subject: [PATCH 2/2] main --- .github/workflows/label-gun.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/label-gun.yml b/.github/workflows/label-gun.yml index 2e6cc724ff..5282ae3b1f 100644 --- a/.github/workflows/label-gun.yml +++ b/.github/workflows/label-gun.yml @@ -11,7 +11,7 @@ jobs: nag: runs-on: ubuntu-latest steps: - - uses: retorquere/label-gun@project + - uses: retorquere/label-gun@main with: token: ${{ github.token }} label.exempt: question