Skip to content

Commit

Permalink
build: upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
darlal committed Oct 26, 2024
1 parent 1930b8c commit 4219cfc
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 831 deletions.
1,201 changes: 407 additions & 794 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
"author": "darlal",
"license": "GPL-3.0-only",
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-typescript": "^12.1.1",
"@types/chance": "^1.1.6",
"@types/jest": "^29.5.12",
"@types/jest": "^29.5.14",
"@types/node": "^18.19.34",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"chance": "^1.1.11",
"chance": "^1.1.12",
"electron": "^30.1.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -47,17 +47,17 @@
"jest": "^29.7.0",
"jest-mock-extended": "^3.0.7",
"npm-run-all": "^4.1.5",
"obsidian": "^1.5.7-1",
"obsidian": "^1.7.2",
"onchange": "^7.1.0",
"prettier": "^3.3.1",
"rollup": "^4.18.0",
"serve": "^14.2.3",
"ts-essentials": "^10.0.0",
"ts-jest": "^29.1.4",
"prettier": "^3.3.3",
"rollup": "^4.24.0",
"serve": "^14.2.4",
"ts-essentials": "^10.0.2",
"ts-jest": "^29.2.5",
"tslib": "^2.6.3",
"typescript": "^5.4.5"
},
"dependencies": {
"ts-deepmerge": "^7.0.0"
"ts-deepmerge": "^7.0.1"
}
}
3 changes: 2 additions & 1 deletion src/Handlers/__tests__/editorHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
makeFuzzyMatch,
} from '@fixtures';
import { EditorHandler, Handler } from 'src/Handlers';
import { mock, MockProxy } from 'jest-mock-extended';
import { mock, mockFn, MockProxy } from 'jest-mock-extended';
import { Searcher } from 'src/search';

function makeLeafWithRoot(text: string, root: WorkspaceItem): MockProxy<WorkspaceLeaf> {
Expand All @@ -45,6 +45,7 @@ describe('editorHandler', () => {
rootSplit: mock<WorkspaceSplit>(),
leftSplit: mock<WorkspaceSplit>(),
rightSplit: mock<WorkspaceSplit>(),
revealLeaf: mockFn().mockResolvedValue(null),
});

settings = new SwitcherPlusSettings(null);
Expand Down
23 changes: 11 additions & 12 deletions src/Handlers/__tests__/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,25 +621,24 @@ describe('Handler', () => {
const mockLeaf = makeLeaf();
const mockView = mockLeaf.view as MockProxy<View>;

it('should activate main panel leaf', () => {
mockLeaf.getRoot.mockReturnValueOnce(mockWorkspace.rootSplit);

sut.activateLeaf(mockLeaf);
it('should activate a WorkspaceLeaf', async () => {
await sut.activateLeaf(mockLeaf);

expect(mockLeaf.getRoot).toHaveBeenCalled();
expect(mockWorkspace.revealLeaf).toHaveBeenCalledWith(mockLeaf);
expect(mockWorkspace.setActiveLeaf).toHaveBeenCalledWith(mockLeaf, { focus: true });
expect(mockView.setEphemeralState).toHaveBeenCalled();
});

it('should activate side panel leaf', () => {
mockLeaf.getRoot.mockReturnValueOnce(mockWorkspace.rightSplit);
it('should log errors to the console when it fails to reveal a WorkspaceLeaf', async () => {
const consoleLogSpy = jest.spyOn(console, 'log').mockReturnValueOnce();
const errorMsg = 'RevealLeaf unit test error';
mockWorkspace.revealLeaf.mockRejectedValueOnce(errorMsg);

sut.activateLeaf(mockLeaf);
await sut.activateLeaf(mockLeaf);

expect(mockLeaf.getRoot).toHaveBeenCalled();
expect(mockWorkspace.setActiveLeaf).toHaveBeenCalledWith(mockLeaf, { focus: true });
expect(mockView.setEphemeralState).toHaveBeenCalled();
expect(mockWorkspace.revealLeaf).toHaveBeenCalledWith(mockLeaf);
expect(consoleLogSpy).toHaveBeenCalledWith(expect.any(String), errorMsg);

consoleLogSpy.mockRestore();
});
});

Expand Down
5 changes: 4 additions & 1 deletion src/Handlers/__tests__/symbolHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ describe('symbolHandler', () => {
mockMetadataCache = mock<MetadataCache>();
mockMetadataCache.getFileCache.mockImplementation((_f) => rootFixture.cachedMetadata);

mockWorkspace = mock<Workspace>();
mockWorkspace = mock<Workspace>({
revealLeaf: mockFn().mockResolvedValue(null),
});

mockVault = mock<Vault>();
mockApp = mock<App>({
workspace: mockWorkspace,
Expand Down
23 changes: 13 additions & 10 deletions src/Handlers/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,20 @@ export abstract class Handler<T> {
* @param {Record<string, unknown>} eState?
* @returns void
*/
activateLeaf(leaf: WorkspaceLeaf, eState?: Record<string, unknown>): void {
async activateLeaf(
leaf: WorkspaceLeaf,
eState?: Record<string, unknown>,
): Promise<void> {
const { workspace } = this.app;
const isInSidePanel = !this.isMainPanelLeaf(leaf);
const state = { focus: true, ...eState };

if (isInSidePanel) {
workspace.revealLeaf(leaf);
try {
await workspace.revealLeaf(leaf);
workspace.setActiveLeaf(leaf, { focus: true });
leaf.view.setEphemeralState({ focus: true, ...eState });
} catch (err) {
const title = leaf?.getDisplayText();
console.log(`Switcher++: error activating WorkspaceLeaf with title: ${title}`, err);
}

workspace.setActiveLeaf(leaf, { focus: true });
leaf.view.setEphemeralState(state);
}

/**
Expand Down Expand Up @@ -563,8 +566,8 @@ export abstract class Handler<T> {
openState = openState ?? { active: true, eState: { active: true, focus: true } };

if (leaf && navType === false) {
const eState = openState?.eState as Record<string, unknown>;
this.activateLeaf(leaf, eState);
const eState = openState?.eState;
await this.activateLeaf(leaf, eState);
} else {
await this.openFileInLeaf(file, navType, openState, splitDirection);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/symbolHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class SymbolHandler extends Handler<SymbolSuggestion> {
if (item.symbolType !== SymbolType.CanvasNode) {
openState.eState = this.constructMDFileNavigationState(
item as SymbolInfoExcludingCanvasNodes,
).eState as Record<string, unknown>;
).eState;
}

this.navigateToLeafOrOpenFileAsync(
Expand Down
3 changes: 3 additions & 0 deletions src/__mocks__/obsidian/mockSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ export class MockSliderComponent implements SliderComponent {
return this;
}

setInstant(instant: boolean): this {
throw new Error('Method not implemented.');
}
setDisabled(disabled: boolean): this {
throw new Error('Method not implemented.');
}
Expand Down

0 comments on commit 4219cfc

Please sign in to comment.