Skip to content

Commit 2a18b63

Browse files
committed
removed deprecated svelte event dispatcher, moved to Svelte 5 event hook functions instead.
1 parent d1d28f5 commit 2a18b63

30 files changed

+270
-279
lines changed

src/lib/Arc.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Arc.html), [
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.ArcConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.ArcConfig> = $props();
3335
3436
export const handle = new Konva.Arc(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Arc.html), [
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

src/lib/Arrow.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Arrow.html),
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.ArrowConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.ArrowConfig> = $props();
3335
3436
export const handle = new Konva.Arrow(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Arrow.html),
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

src/lib/Circle.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Circle.html)
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.CircleConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.CircleConfig> = $props();
3335
3436
export const handle = new Konva.Circle(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Circle.html)
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

src/lib/Ellipse.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Ellipse.html
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.EllipseConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.EllipseConfig> = $props();
3335
3436
export const handle = new Konva.Ellipse(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Ellipse.html
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

src/lib/Group.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,29 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Group.html),
2020
-->
2121
<script lang="ts">
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
23+
import { onMount, onDestroy } from 'svelte';
2424
import { type Writable, writable } from 'svelte/store';
2525
import {
2626
Container,
2727
getParentContainer,
2828
setContainerContext,
2929
type KonvaParent
3030
} from '$lib/util/manageContext';
31-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
31+
import { registerEvents } from '$lib/util/events';
3232
import { copyExistingKeys } from '$lib/util/object';
3333
import { type PropsContainer } from '$lib/util/props';
3434
35-
interface $$Events extends KonvaEvents {}
36-
3735
let {
3836
children,
3937
config = $bindable({}),
40-
staticConfig = false
38+
staticConfig = false,
39+
...eventHooks
4140
}: PropsContainer<Konva.GroupConfig | undefined> = $props();
4241
4342
export const handle = new Konva.Group(config);
4443
4544
const inner = writable<null | Konva.Group>(null);
4645
47-
const dispatcher = createEventDispatcher();
48-
4946
let isReady = $state(false);
5047
5148
$effect(() => {
@@ -67,7 +64,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Group.html),
6764
});
6865
}
6966
70-
registerEvents(dispatcher, handle);
67+
registerEvents(eventHooks, handle);
7168
7269
inner.set(handle);
7370
isReady = true;

src/lib/Image.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Image.html),
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.ImageConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.ImageConfig> = $props();
3335
3436
export const handle = new Konva.Image(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Image.html),
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

src/lib/Label.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Label.html),
2121
-->
2222
<script lang="ts">
2323
import Konva from 'konva';
24-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24+
import { onMount, onDestroy } from 'svelte';
2525
import { writable, type Writable } from 'svelte/store';
2626
import { copyExistingKeys } from '$lib/util/object';
2727
import {
@@ -30,23 +30,20 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Label.html),
3030
setContainerContext,
3131
type KonvaParent
3232
} from '$lib/util/manageContext';
33-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
33+
import { registerEvents } from '$lib/util/events';
3434
import { type PropsContainer } from '$lib/util/props';
3535
36-
interface $$Events extends KonvaEvents {}
37-
3836
let {
3937
children,
4038
config = $bindable(),
41-
staticConfig = false
39+
staticConfig = false,
40+
...eventHooks
4241
}: PropsContainer<Konva.LabelConfig> = $props();
4342
4443
export const handle = new Konva.Label(config);
4544
4645
const inner = writable<null | Konva.Label>(null);
4746
48-
const dispatcher = createEventDispatcher();
49-
5047
let isReady = $state(false);
5148
5249
$effect(() => {
@@ -68,7 +65,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Label.html),
6865
});
6966
}
7067
71-
registerEvents(dispatcher, handle);
68+
registerEvents(eventHooks, handle);
7269
7370
inner.set(handle);
7471
isReady = true;

src/lib/Layer.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,24 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Layer.html),
2222
-->
2323
<script lang="ts">
2424
import Konva from 'konva';
25-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
25+
import { onMount, onDestroy } from 'svelte';
2626
import { type Writable, writable } from 'svelte/store';
2727
import { Container, getParentStage, setContainerContext } from '$lib/util/manageContext';
28-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
28+
import { registerEvents } from '$lib/util/events';
2929
import { copyExistingKeys } from '$lib/util/object';
3030
import { type PropsContainer } from '$lib/util/props';
3131
32-
interface $$Events extends KonvaEvents {}
33-
3432
let {
3533
children,
3634
config = $bindable({}),
37-
staticConfig = false
35+
staticConfig = false,
36+
...eventHooks
3837
}: PropsContainer<Konva.LayerConfig | undefined> = $props();
3938
4039
export const handle = new Konva.Layer(config);
4140
4241
const inner = writable<null | Konva.Layer>(null);
4342
44-
const dispatcher = createEventDispatcher();
45-
4643
let isReady = $state(false);
4744
4845
$effect(() => {
@@ -64,7 +61,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Layer.html),
6461
});
6562
}
6663
67-
registerEvents(dispatcher, handle);
64+
registerEvents(eventHooks, handle);
6865
6966
inner.set(handle);
7067
isReady = true;

src/lib/Line.svelte

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Line.html),
2020
*/
2121
2222
import Konva from 'konva';
23-
import { onMount, onDestroy, createEventDispatcher } from 'svelte';
24-
import type { Writable } from 'svelte/store';
25-
import { registerEvents, type KonvaEvents } from '$lib/util/events';
23+
import { onMount, onDestroy } from 'svelte';
24+
import { type Writable } from 'svelte/store';
25+
import { registerEvents } from '$lib/util/events';
2626
import { getParentContainer, type KonvaParent } from '$lib/util/manageContext';
2727
import { copyExistingKeys } from '$lib/util/object';
2828
import { type Props } from '$lib/util/props';
2929
30-
interface $$Events extends KonvaEvents {}
31-
32-
let { config = $bindable(), staticConfig = false }: Props<Konva.LineConfig> = $props();
30+
let {
31+
config = $bindable(),
32+
staticConfig = false,
33+
...eventHooks
34+
}: Props<Konva.LineConfig> = $props();
3335
3436
export const handle = new Konva.Line(config);
3537
3638
const parent: Writable<null | KonvaParent> = getParentContainer();
37-
const dispatcher = createEventDispatcher();
3839
3940
$effect(() => {
4041
handle.setAttrs(config);
@@ -53,7 +54,7 @@ Further information: [Konva API docs](https://konvajs.org/api/Konva.Line.html),
5354
});
5455
}
5556
56-
registerEvents(dispatcher, handle);
57+
registerEvents(eventHooks, handle);
5758
});
5859
5960
onDestroy(() => {

0 commit comments

Comments
 (0)