diff --git a/package-lock.json b/package-lock.json index e618e0a..b9f989c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "unist-util-visit": "^5.0.0", "unist-util-visit-parents": "^6.0.1", "yamljs": "^0.3.0", - "zotero-plugin-toolkit": "^4.0.7" + "zotero-plugin-toolkit": "^4.0.8" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", @@ -13588,9 +13588,9 @@ } }, "node_modules/zotero-plugin-toolkit": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/zotero-plugin-toolkit/-/zotero-plugin-toolkit-4.0.7.tgz", - "integrity": "sha512-9bAXXJTgH5SkyauGft50EerudZYGYzN/T3kPgi7udB8lScVyO+HkYERxJqnFuvk2gHzV+stqeaKaX9a0ODTxEQ==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/zotero-plugin-toolkit/-/zotero-plugin-toolkit-4.0.8.tgz", + "integrity": "sha512-uro188jzhAY+6EB2N9Kx0Vn5ITazwljJOragMi7PjrcRQrEi/R350eT+MAFrDR+pMzEOltrKtz6W7aSvMd9iqA==", "dependencies": { "zotero-types": "^2.2.0" }, diff --git a/package.json b/package.json index e2c0cd7..d1286c9 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "unist-util-visit": "^5.0.0", "unist-util-visit-parents": "^6.0.1", "yamljs": "^0.3.0", - "zotero-plugin-toolkit": "^4.0.7" + "zotero-plugin-toolkit": "^4.0.8" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", diff --git a/src/extras/parsingWorker.ts b/src/extras/parsingWorker.ts index 3b5cd5e..d3857cf 100644 --- a/src/extras/parsingWorker.ts +++ b/src/extras/parsingWorker.ts @@ -97,12 +97,10 @@ function parseHTMLLines(html: string): string[] { return parsedLines; } -const funcs = { +const handlers = { parseHTMLLines, }; -const handlers = MessageHelper.wrapHandlers(funcs); - const messageServer = new MessageHelper({ canBeDestroyed: true, dev: true, diff --git a/src/extras/relationWorker.ts b/src/extras/relationWorker.ts index 1325ec5..e87adf5 100644 --- a/src/extras/relationWorker.ts +++ b/src/extras/relationWorker.ts @@ -15,7 +15,7 @@ db.version(2).stores({ log("Using Dexie v" + Dexie.semVer, db); -const funcs = { +const handlers = { addLink, bulkAddLink, rebuildLinkForNote, @@ -26,8 +26,6 @@ const funcs = { getAnnotationByLinkTarget, }; -const handlers = MessageHelper.wrapHandlers(funcs); - const messageServer = new MessageHelper({ canBeDestroyed: true, dev: true, diff --git a/src/utils/note.ts b/src/utils/note.ts index 4e3b54b..bf64596 100644 --- a/src/utils/note.ts +++ b/src/utils/note.ts @@ -20,7 +20,7 @@ export { async function parseHTMLLines(html: string) { const server = await getParsingServer(); - return await server.exec("parseHTMLLines", [html]); + return await server.proxy.parseHTMLLines(html); } async function getLinesInNote( @@ -58,8 +58,7 @@ async function setLinesToNote(note: Zotero.Item, lines: string[]) { } else { const noteHead = noteText.substring(0, containerIndex); note.setNote( - `${noteHead}data-schema-version="${ - config.dataSchemaVersion + `${noteHead}data-schema-version="${config.dataSchemaVersion }">${lines.join("\n")}`, ); } diff --git a/src/utils/parsing.ts b/src/utils/parsing.ts index 1e77289..fd194e7 100644 --- a/src/utils/parsing.ts +++ b/src/utils/parsing.ts @@ -25,7 +25,7 @@ async function getParsingServer() { handlers: {}, }); server.start(); - await server.exec("_ping"); + await server.proxy._ping(); addon.data.parsing.server = server; return server; } diff --git a/src/utils/relation.ts b/src/utils/relation.ts index 0c4505b..98369d5 100644 --- a/src/utils/relation.ts +++ b/src/utils/relation.ts @@ -73,9 +73,7 @@ async function updateNoteLinkRelation(noteID: number) { } } } - const result = await ( - await getRelationServer() - ).exec("rebuildLinkForNote", [fromLibID, fromKey, linkToData]); + const result = await (await getRelationServer()).proxy.rebuildLinkForNote(fromLibID, fromKey, linkToData); for (const link of result.oldOutboundLinks as LinkModel[]) { const item = Zotero.Items.getByLibraryAndKey(link.toLibID, link.toKey); @@ -98,17 +96,14 @@ async function getNoteLinkOutboundRelation(noteID: number) { const note = Zotero.Items.get(noteID); const fromLibID = note.libraryID; const fromKey = note.key; - return (await getRelationServer()).exec("getOutboundLinks", [ - fromLibID, - fromKey, - ]); + return await (await getRelationServer()).proxy.getOutboundLinks(fromLibID, fromKey); } async function getNoteLinkInboundRelation(noteID: number) { const note = Zotero.Items.get(noteID); const toLibID = note.libraryID; const toKey = note.key; - return (await getRelationServer()).exec("getInboundLinks", [toLibID, toKey]); + return await (await getRelationServer()).proxy.getInboundLinks(toLibID, toKey); } function decodeHTMLEntities(text: string) { @@ -130,21 +125,15 @@ interface LinkModel { } async function linkAnnotationToTarget(model: AnnotationModel) { - return (await getRelationServer()).exec("linkAnnotationToTarget", [model]); + return await (await getRelationServer()).proxy.linkAnnotationToTarget(model); } async function getLinkTargetByAnnotation(fromLibID: number, fromKey: string) { - return (await getRelationServer()).exec("getLinkTargetByAnnotation", [ - fromLibID, - fromKey, - ]); + return await (await getRelationServer()).proxy.getLinkTargetByAnnotation(fromLibID, fromKey); } async function getAnnotationByLinkTarget(toLibID: number, toKey: string) { - return (await getRelationServer()).exec("getAnnotationByLinkTarget", [ - toLibID, - toKey, - ]); + return await (await getRelationServer()).proxy.getAnnotationByLinkTarget(toLibID, toKey); } interface AnnotationModel {