Skip to content

Commit 47f146c

Browse files
committed
fix #487
1 parent 7bd954c commit 47f146c

File tree

16 files changed

+46
-37
lines changed

16 files changed

+46
-37
lines changed

bun.lockb

9.26 KB
Binary file not shown.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,34 @@
3434
"@tsconfig/svelte": "^5.0.4",
3535
"@types/bun": "^1.1.14",
3636
"builtin-modules": "^4.0.0",
37-
"elysia": "^1.1.25",
38-
"esbuild": "^0.24.0",
37+
"elysia": "^1.1.26",
38+
"esbuild": "^0.24.2",
3939
"esbuild-plugin-copy-watch": "^2.3.1",
4040
"esbuild-svelte": "^0.8.2",
41-
"eslint": "^9.15.0",
41+
"eslint": "^9.17.0",
4242
"eslint-plugin-import": "^2.31.0",
4343
"eslint-plugin-isaacscript": "^4.0.0",
4444
"eslint-plugin-no-relative-import-paths": "^1.5.5",
4545
"eslint-plugin-only-warn": "^1.1.0",
46-
"eslint-plugin-svelte": "^2.46.0",
47-
"prettier": "^3.4.0",
46+
"eslint-plugin-svelte": "^2.46.1",
47+
"prettier": "^3.4.2",
4848
"prettier-plugin-svelte": "^3.3.2",
4949
"string-argv": "^0.3.2",
50-
"svelte-check": "^4.1.0",
50+
"svelte-check": "^4.1.1",
5151
"svelte-preprocess": "^6.0.3",
5252
"tslib": "^2.8.1",
5353
"typescript": "^5.7.2",
54-
"typescript-eslint": "^8.16.0",
54+
"typescript-eslint": "^8.18.1",
5555
"yaml": "^2.6.1"
5656
},
5757
"dependencies": {
5858
"@codemirror/legacy-modes": "^6.4.2",
5959
"@lemons_dev/parsinom": "^0.0.12",
60-
"itertools-ts": "^1.27.1",
61-
"mathjs": "^14.0.0",
60+
"itertools-ts": "^1.28.0",
61+
"mathjs": "^14.0.1",
6262
"moment": "^2.30.1",
63-
"svelte": "^5.2.8",
64-
"zod": "^3.23.8",
63+
"svelte": "^5.15.0",
64+
"zod": "^3.24.1",
6565
"zod-validation-error": "^3.4.0"
6666
},
6767
"private": true,

packages/core/src/fields/button/ButtonField.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class ButtonField extends Mountable {
102102

103103
protected onUnmount(): void {
104104
if (this.buttonComponent) {
105-
unmount(this.buttonComponent);
105+
void unmount(this.buttonComponent);
106106
}
107107

108108
if (!this.isInline && !this.isPreview) {

packages/core/src/fields/button/ButtonGroupField.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ButtonGroupField extends Mountable {
7171
buttonId,
7272
(buttonConfig: ButtonConfig) => {
7373
if (initialButton) {
74-
unmount(initialButton);
74+
void unmount(initialButton);
7575
}
7676
initialButton = undefined;
7777
button = new ButtonField(
@@ -89,7 +89,7 @@ export class ButtonGroupField extends Mountable {
8989

9090
this.registerUnmountCb(() => {
9191
if (initialButton) {
92-
unmount(initialButton);
92+
void unmount(initialButton);
9393
}
9494
initialButton = undefined;
9595
button?.unmount();

packages/core/src/fields/inputFields/InputFieldSvelteWrapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class InputFieldSvelteWrapper<Value, SvelteExports = object> {
8282
*/
8383
public unmount(): void {
8484
if (this.svelteComponentInstance) {
85-
unmount(this.svelteComponentInstance);
85+
void unmount(this.svelteComponentInstance);
8686
}
8787

8888
this.mounted = false;

packages/core/src/fields/metaBindTable/TableMountable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class TableMountable extends FieldMountable {
209209

210210
this.unregisterSelfFromMetadataManager();
211211
if (this.tableComponent) {
212-
unmount(this.tableComponent);
212+
void unmount(this.tableComponent);
213213
}
214214

215215
showUnloadedMessage(targetEl, 'table');

packages/core/src/fields/viewFields/fields/ImageVF.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ImageVF extends AbstractViewField<string> {
8383
protected async onRerender(container: HTMLElement, value: string | undefined): Promise<void> {
8484
const linkList = value ? MDLinkParser.parseLinkList(value) : [];
8585
if (this.component) {
86-
unmount(this.component);
86+
void unmount(this.component);
8787
}
8888
this.component = mount(ImageGrid, {
8989
target: container,
@@ -98,7 +98,7 @@ export class ImageVF extends AbstractViewField<string> {
9898
super.onUnmount();
9999

100100
if (this.component) {
101-
unmount(this.component);
101+
void unmount(this.component);
102102
}
103103
}
104104
}

packages/core/src/fields/viewFields/fields/LinkVF.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class LinkVF extends AbstractViewField<string> {
158158
super.onUnmount();
159159

160160
if (this.component) {
161-
unmount(this.component);
161+
void unmount(this.component);
162162
}
163163
}
164164
}

packages/core/src/modals/modalContents/SvelteModalContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class SvelteModalContent<T extends SvelteComponent> extends ModalContent
2626

2727
protected onUnmount(targetEl: HTMLElement): void {
2828
if (this.component) {
29-
unmount(this.component);
29+
void unmount(this.component);
3030
}
3131

3232
DomHelpers.empty(targetEl);

packages/core/src/modals/modalContents/buttonBuilder/ButtonBuilderModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ButtonBuilderModal extends ModalContent {
2828
protected onMount(targetEl: HTMLElement): void {
2929
DomHelpers.empty(targetEl);
3030
if (this.component) {
31-
unmount(this.component);
31+
void unmount(this.component);
3232
}
3333

3434
this.component = mount(ButtonBuilderModalComponent, {
@@ -44,7 +44,7 @@ export class ButtonBuilderModal extends ModalContent {
4444
protected onUnmount(targetEl: HTMLElement): void {
4545
DomHelpers.empty(targetEl);
4646
if (this.component) {
47-
unmount(this.component);
47+
void unmount(this.component);
4848
}
4949
}
5050

packages/core/src/utils/Mountable.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ export abstract class Mountable {
4949
*/
5050
public mount(targetEl: HTMLElement): void {
5151
if (this.mounted || this.targetEl) {
52-
throw new Error('Mountable is already mounted');
52+
console.warn('Mountable is already mounted', this);
53+
return;
54+
}
55+
56+
if (targetEl === undefined) {
57+
console.error('Mountable target element is undefined', this);
58+
return;
5359
}
5460

5561
this.mounted = true;
@@ -60,11 +66,11 @@ export abstract class Mountable {
6066

6167
/**
6268
* Unmount the mountable from the current element.
63-
* Will throw an error if the mountable is not mounted.
6469
*/
6570
public unmount(): void {
6671
if (!this.mounted || !this.targetEl) {
67-
throw new Error('Mountable is not mounted');
72+
console.warn('Mountable is not mounted', this);
73+
return;
6874
}
6975

7076
this.mounted = false;

packages/core/src/utils/components/MountableComponent.svelte

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
<script lang="ts">
22
import type { Mountable } from 'packages/core/src/utils/Mountable';
3-
import { onDestroy, onMount } from 'svelte';
3+
import { onDestroy } from 'svelte';
44
5-
const {
5+
let {
66
mountable,
77
}: {
88
mountable: Mountable;
99
} = $props();
1010
1111
let element: HTMLElement;
12+
let current: Mountable | undefined;
1213
13-
onMount(() => {
14-
mountable.mount(element);
14+
$effect(() => {
15+
current?.unmount();
16+
current = mountable;
17+
current.mount(element);
1518
});
1619
1720
onDestroy(() => {
18-
mountable.unmount();
21+
current?.unmount();
1922
});
2023
</script>
2124

packages/obsidian/src/playground/PlaygroundView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class PlaygroundView extends ItemView {
3737

3838
async onClose(): Promise<void> {
3939
if (this.component) {
40-
unmount(this.component);
40+
void unmount(this.component);
4141
}
4242
}
4343
}

packages/obsidian/src/settings/buttonTemplateSetting/ButtonTemplatesSettingModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class ButtonTemplatesSettingModal extends Modal {
2020
public onOpen(): void {
2121
this.contentEl.empty();
2222
if (this.component) {
23-
unmount(this.component);
23+
void unmount(this.component);
2424
}
2525

2626
this.component = mount(ButtonTemplatesSettingComponent, {
@@ -35,7 +35,7 @@ export class ButtonTemplatesSettingModal extends Modal {
3535
public onClose(): void {
3636
this.contentEl.empty();
3737
if (this.component) {
38-
unmount(this.component);
38+
void unmount(this.component);
3939
}
4040
}
4141

packages/obsidian/src/settings/excludedFoldersSetting/ExcludedFoldersSettingModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class ExcludedFoldersSettingModal extends Modal {
1818
public onOpen(): void {
1919
this.contentEl.empty();
2020
if (this.component) {
21-
unmount(this.component);
21+
void unmount(this.component);
2222
}
2323

2424
this.component = mount(ExcludedFoldersSettingComponent, {
@@ -34,7 +34,7 @@ export class ExcludedFoldersSettingModal extends Modal {
3434
public onClose(): void {
3535
this.contentEl.empty();
3636
if (this.component) {
37-
unmount(this.component);
37+
void unmount(this.component);
3838
}
3939
}
4040

packages/obsidian/src/settings/inputFieldTemplateSetting/InputFieldTemplatesSettingModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class InputFieldTemplatesSettingModal extends Modal {
1919
public onOpen(): void {
2020
this.contentEl.empty();
2121
if (this.component) {
22-
unmount(this.component);
22+
void unmount(this.component);
2323
}
2424

2525
this.component = mount(InputFieldTemplatesSettingComponent, {
@@ -35,7 +35,7 @@ export class InputFieldTemplatesSettingModal extends Modal {
3535
public onClose(): void {
3636
this.contentEl.empty();
3737
if (this.component) {
38-
unmount(this.component);
38+
void unmount(this.component);
3939
}
4040
}
4141

0 commit comments

Comments
 (0)