mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
Update dependencies and replace deprecated API calls
Replace activeDocument/activeWindow globals with Obsidian API equivalents (createFragment, createDiv, createSpan, window), update officeparser to use async API, switch diff2html import path and disable highlight option, prefix unused parameters with underscore, and update dependencies including @anthropic-ai/sdk, @google/genai, officeparser, and various dev dependencies
This commit is contained in:
parent
3e1b52fe1c
commit
89dceda21c
15 changed files with 380 additions and 346 deletions
|
|
@ -41,7 +41,7 @@ export async function readDocument(arrayBuffer: ArrayBuffer): Promise<IPageText[
|
|||
});
|
||||
|
||||
// OfficeParser doesn't currently expose page data (page number etc)
|
||||
return [{ text: ast.toText(), pageNumber: 1 }] as IPageText[];
|
||||
return [{ text: (await ast.to('text')).value, pageNumber: 1 }] as IPageText[];
|
||||
} catch (error) {
|
||||
return [{ text: `Failed to read document: ${Exception.messageFrom(error)}`, pageNumber: 1 }] as IPageText[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export function hideDrawerElements() {
|
|||
});
|
||||
element.addClass("vaultKeeper-drawer-hiding");
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
element.removeClass("vaultKeeper-drawer-hiding");
|
||||
element.addClass("vaultKeeper-drawer-collapsed");
|
||||
});
|
||||
|
|
@ -66,7 +66,7 @@ export function restoreDrawerElements() {
|
|||
element.removeClass("vaultKeeper-drawer-hidden");
|
||||
element.addClass("vaultKeeper-drawer-restoring");
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
element.removeClass("vaultKeeper-drawer-restoring");
|
||||
element.addClass("vaultKeeper-drawer-expanding");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -56,5 +56,5 @@ export function pathExtname(filePath: string) {
|
|||
}
|
||||
|
||||
export async function sleep(ms: number): Promise<void> {
|
||||
return new Promise(resolve => activeWindow.setTimeout(resolve, ms));
|
||||
return new Promise(resolve => window.setTimeout(resolve, ms));
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ export abstract class StringTools {
|
|||
}
|
||||
}
|
||||
|
||||
const canvas = activeDocument.createElement("canvas");
|
||||
const canvas = activeDocument.createEl("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const context = canvas.getContext("2d");
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export class ChatService {
|
|||
await this.mainAgent.runMainAgent(conversation, chatMode, callbacks);
|
||||
|
||||
if (namingPromise) {
|
||||
const timeout = new Promise<void>(resolve => activeWindow.setTimeout(resolve, 5000));
|
||||
const timeout = new Promise<void>(resolve => window.setTimeout(resolve, 5000));
|
||||
await Promise.race([namingPromise, timeout]);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Resolve } from './DependencyService';
|
|||
import { Services } from './Services';
|
||||
import type { EventService } from './EventService';
|
||||
import { Event } from 'Enums/Event';
|
||||
import type { Diff2HtmlUIConfig } from 'diff2html/lib/ui/js/diff2html-ui';
|
||||
import type { Diff2HtmlUIConfig } from 'diff2html/lib/ui/js/diff2html-ui-base';
|
||||
import { ColorSchemeType, OutputFormatType } from 'diff2html/lib/types';
|
||||
import { Component } from 'obsidian';
|
||||
import { AbortService } from './AbortService';
|
||||
|
|
@ -44,7 +44,7 @@ export class DiffService extends Component {
|
|||
drawFileList: false,
|
||||
matching: "words",
|
||||
outputFormat: outputFormat,
|
||||
highlight: true,
|
||||
highlight: false,
|
||||
fileListToggle: false,
|
||||
fileContentToggle: false,
|
||||
synchronisedScroll: true,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export class QuickActionsService {
|
|||
|
||||
/* Action Definitions */
|
||||
|
||||
private async beautify(menu: Menu, editor: Editor, view: MarkdownView | MarkdownFileInfo) {
|
||||
private async beautify(_menu: Menu, editor: Editor, view: MarkdownView | MarkdownFileInfo) {
|
||||
const file = view.file;
|
||||
if (!file) {
|
||||
return;
|
||||
|
|
@ -76,7 +76,7 @@ export class QuickActionsService {
|
|||
}
|
||||
}
|
||||
|
||||
private async applyTemplate(menu: Menu, editor: Editor, view: MarkdownView | MarkdownFileInfo) {
|
||||
private async applyTemplate(_menu: Menu, _editor: Editor, view: MarkdownView | MarkdownFileInfo) {
|
||||
const file = view.file;
|
||||
if (!file) {
|
||||
return;
|
||||
|
|
@ -217,8 +217,8 @@ export class QuickActionsService {
|
|||
}
|
||||
|
||||
private showNotice(message: string): Notice {
|
||||
const fragment = activeDocument.createDocumentFragment();
|
||||
const container = activeDocument.createElement("div");
|
||||
const fragment = createFragment();
|
||||
const container = activeDocument.createDiv();
|
||||
|
||||
container.addClass("quick-action-notice");
|
||||
mount(Spinner, { target: container, props: {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export class StreamingMarkdownService {
|
|||
private debouncedRender(messageId: string, immediate: boolean = false) {
|
||||
const existingTimeout = this.renderTimeouts.get(messageId);
|
||||
if (existingTimeout) {
|
||||
activeWindow.clearTimeout(existingTimeout);
|
||||
window.clearTimeout(existingTimeout);
|
||||
}
|
||||
|
||||
const render = () => {
|
||||
|
|
@ -127,7 +127,7 @@ export class StreamingMarkdownService {
|
|||
if (immediate) {
|
||||
render();
|
||||
} else {
|
||||
const timeout = activeWindow.setTimeout(render, 50); // 50ms debounce
|
||||
const timeout = window.setTimeout(render, 50); // 50ms debounce
|
||||
this.renderTimeouts.set(messageId, timeout);
|
||||
}
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ export class StreamingMarkdownService {
|
|||
this.streamingStates.delete(messageId);
|
||||
const timeout = this.renderTimeouts.get(messageId);
|
||||
if (timeout) {
|
||||
activeWindow.clearTimeout(timeout);
|
||||
window.clearTimeout(timeout);
|
||||
this.renderTimeouts.delete(messageId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export class WebViewerService {
|
|||
if (Date.now() - start > timeoutMs) {
|
||||
return false;
|
||||
}
|
||||
await new Promise(r => activeWindow.setTimeout(r, 200));
|
||||
await new Promise(r => window.setTimeout(r, 200));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Diff2HtmlUI, type Diff2HtmlUIConfig } from "diff2html/lib/ui/js/diff2html-ui";
|
||||
import { Diff2HtmlUI, type Diff2HtmlUIConfig } from "diff2html/lib/ui/js/diff2html-ui-base";
|
||||
import { Event } from "Enums/Event";
|
||||
import { ItemView, WorkspaceLeaf, Platform, type ViewStateResult } from "obsidian";
|
||||
import { Resolve } from "Services/DependencyService";
|
||||
|
|
@ -78,13 +78,12 @@ export class DiffView extends ItemView {
|
|||
const diff2htmlUi = new Diff2HtmlUI(this.diffContainer, this.diffString, this.config);
|
||||
|
||||
diff2htmlUi.draw();
|
||||
diff2htmlUi.highlightCode();
|
||||
|
||||
if (Platform.isMobile) {
|
||||
this.mobileButtonsContainer = this.createMobileButtons();
|
||||
}
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => {
|
||||
const firstChange = this.diffContainer?.querySelector('.d2h-change, .d2h-ins, .d2h-del');
|
||||
firstChange?.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ export class VaultkeeperAISettingTab extends PluginSettingTab {
|
|||
|
||||
/* Planning Model Selection Setting */
|
||||
const currentProvider = fromModel(this.settingsService.settings.model);
|
||||
const planningModelDescFragment = activeDocument.createDocumentFragment();
|
||||
const planningModelDescFragment = createFragment();
|
||||
planningModelDescFragment.appendText(Copy.SettingPlanningModelDesc);
|
||||
planningModelDescFragment.createEl("br");
|
||||
planningModelDescFragment.createEl("br");
|
||||
planningModelDescFragment.createEl("span", { text: Copy.SettingPlanningModelTip, cls: "planning-model-description-tip" });
|
||||
planningModelDescFragment.createSpan({ text: Copy.SettingPlanningModelTip, cls: "planning-model-description-tip" });
|
||||
new Setting(containerEl)
|
||||
.setName(Copy.SettingPlanningModel)
|
||||
.setDesc(planningModelDescFragment)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ describe('DiffService', () => {
|
|||
expect.stringContaining('old.md'),
|
||||
expect.objectContaining({
|
||||
outputFormat: 'line-by-line',
|
||||
highlight: true
|
||||
highlight: false
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -603,13 +603,13 @@ describe('DiffService', () => {
|
|||
await diffPromise;
|
||||
});
|
||||
|
||||
it('should enable highlighting in config', async () => {
|
||||
it('should disable highlighting in config', async () => {
|
||||
const diffPromise = service.requestDiff('a.md', 'b.md', 'old', 'new');
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 10));
|
||||
|
||||
const configArg = mockPlugin.activateDiffView.mock.calls[0][1];
|
||||
expect(configArg.highlight).toBe(true);
|
||||
expect(configArg.highlight).toBe(false);
|
||||
|
||||
service.onAccept();
|
||||
await diffPromise;
|
||||
|
|
|
|||
|
|
@ -1,11 +1 @@
|
|||
{
|
||||
"id": "vaultkeeper-ai",
|
||||
"name": "Vaultkeeper AI",
|
||||
"version": "1.3.4",
|
||||
"minAppVersion": "1.9.14",
|
||||
"description": "Multi-AI assistant. Read, search, create, and edit notes with multiple AI providers.",
|
||||
"author": "Andy-Stack",
|
||||
"authorUrl": "https://github.com/Andy-Stack",
|
||||
"fundingUrl": "https://buymeacoffee.com/andy.stack",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
{"id":"vaultkeeper-ai","name":"Vaultkeeper AI","version":"1.3.4","minAppVersion":"1.9.14","description":"Multi-AI assistant. Read, search, create, and edit notes with multiple AI providers.","author":"Andy-Stack","authorUrl":"https://github.com/Andy-Stack","fundingUrl":"https://buymeacoffee.com/andy.stack","isDesktopOnly":false}
|
||||
637
package-lock.json
generated
637
package-lock.json
generated
File diff suppressed because it is too large
Load diff
30
package.json
30
package.json
|
|
@ -23,29 +23,29 @@
|
|||
"@eslint/js": "^10.0.1",
|
||||
"@testing-library/svelte": "^5.3.1",
|
||||
"@types/express": "^5.0.6",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/node": "^25.8.0",
|
||||
"@types/path-browserify": "^1.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "8.59.2",
|
||||
"@typescript-eslint/parser": "8.59.2",
|
||||
"@vitest/ui": "^4.1.5",
|
||||
"builtin-modules": "5.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "8.59.3",
|
||||
"@typescript-eslint/parser": "8.59.3",
|
||||
"@vitest/ui": "^4.1.6",
|
||||
"builtin-modules": "5.2.0",
|
||||
"esbuild": "^0.28.0",
|
||||
"esbuild-svelte": "^0.9.4",
|
||||
"eslint": "^10.3.0",
|
||||
"esbuild-svelte": "^0.9.5",
|
||||
"eslint": "^10.4.0",
|
||||
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
||||
"eslint-plugin-obsidianmd": "^0.2.9",
|
||||
"eslint-plugin-obsidianmd": "^0.3.0",
|
||||
"happy-dom": "^20.9.0",
|
||||
"obsidian": "latest",
|
||||
"svelte": "^5.55.5",
|
||||
"svelte": "^5.55.7",
|
||||
"svelte-check": "^4.4.8",
|
||||
"svelte-preprocess": "^6.0.3",
|
||||
"tslib": "2.8.1",
|
||||
"typescript": "^6.0.3",
|
||||
"vitest": "^4.1.5"
|
||||
"vitest": "^4.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.94.0",
|
||||
"@google/genai": "^1.52.0",
|
||||
"@anthropic-ai/sdk": "^0.96.0",
|
||||
"@google/genai": "^2.3.0",
|
||||
"@shikijs/rehype": "^4.0.2",
|
||||
"core-js": "^3.49.0",
|
||||
"diff": "^9.0.0",
|
||||
|
|
@ -53,10 +53,10 @@
|
|||
"express": "^5.2.1",
|
||||
"fuzzysort": "^3.1.0",
|
||||
"highlight.js": "^11.11.1",
|
||||
"katex": "^0.16.45",
|
||||
"katex": "^0.16.47",
|
||||
"lowlight": "^3.3.0",
|
||||
"officeparser": "^6.1.1",
|
||||
"openai": "^6.36.0",
|
||||
"officeparser": "^7.0.3",
|
||||
"openai": "^6.38.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"regex-parser": "^2.3.1",
|
||||
"rehype-highlight": "^7.0.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue