@hi-ashleyj/llama 0.13.2 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/Game.svelte +154 -129
  2. package/dist/Game.svelte.d.ts +10 -21
  3. package/dist/Layer.svelte +61 -46
  4. package/dist/Layer.svelte.d.ts +9 -20
  5. package/dist/audio/AudioCompressor.svelte +70 -44
  6. package/dist/audio/AudioCompressor.svelte.d.ts +14 -23
  7. package/dist/audio/AudioGain.svelte +33 -20
  8. package/dist/audio/AudioGain.svelte.d.ts +6 -17
  9. package/dist/audio/AudioListenerPosition.svelte +79 -93
  10. package/dist/audio/AudioListenerPosition.svelte.d.ts +6 -16
  11. package/dist/audio/AudioPanner.svelte +33 -20
  12. package/dist/audio/AudioPanner.svelte.d.ts +6 -17
  13. package/dist/audio/BufferedAudioSource.svelte +59 -44
  14. package/dist/audio/BufferedAudioSource.svelte.d.ts +8 -18
  15. package/dist/audio/MediaAudioSource.svelte +56 -35
  16. package/dist/audio/MediaAudioSource.svelte.d.ts +13 -25
  17. package/dist/audio/context.d.ts +1 -1
  18. package/dist/controllers/MouseClickable.svelte +61 -49
  19. package/dist/controllers/MouseClickable.svelte.d.ts +11 -20
  20. package/dist/controllers/MouseEventArea.svelte +71 -55
  21. package/dist/controllers/MouseEventArea.svelte.d.ts +13 -26
  22. package/dist/controllers/motions.d.ts +4 -5
  23. package/dist/drawables/Arc.svelte +48 -30
  24. package/dist/drawables/Arc.svelte.d.ts +9 -19
  25. package/dist/drawables/Circle.svelte +38 -24
  26. package/dist/drawables/Circle.svelte.d.ts +7 -17
  27. package/dist/drawables/DisplayImage.svelte +26 -16
  28. package/dist/drawables/DisplayImage.svelte.d.ts +11 -21
  29. package/dist/drawables/MultiLineText.svelte +75 -45
  30. package/dist/drawables/MultiLineText.svelte.d.ts +14 -24
  31. package/dist/drawables/Rectangle.svelte +35 -22
  32. package/dist/drawables/Rectangle.svelte.d.ts +7 -17
  33. package/dist/drawables/RoundedRectangle.svelte +41 -23
  34. package/dist/drawables/RoundedRectangle.svelte.d.ts +8 -18
  35. package/dist/drawables/Text.svelte +63 -40
  36. package/dist/drawables/Text.svelte.d.ts +13 -23
  37. package/dist/drawables/Tiled.svelte +79 -61
  38. package/dist/drawables/Tiled.svelte.d.ts +10 -20
  39. package/dist/extras/DefaultFontFace.svelte +35 -17
  40. package/dist/extras/DefaultFontFace.svelte.d.ts +15 -24
  41. package/dist/extras/FullScreenEventHandler.svelte +37 -23
  42. package/dist/extras/FullScreenEventHandler.svelte.d.ts +9 -19
  43. package/dist/extras/LayerPortal.svelte +36 -22
  44. package/dist/extras/LayerPortal.svelte.d.ts +6 -17
  45. package/dist/extras/SensibleDefaultStyles.svelte +8 -2
  46. package/dist/extras/SensibleDefaultStyles.svelte.d.ts +5 -17
  47. package/dist/extras/Tweened.svelte +28 -9
  48. package/dist/extras/Tweened.svelte.d.ts +12 -22
  49. package/dist/primitives/Area.svelte +46 -22
  50. package/dist/primitives/Area.svelte.d.ts +14 -24
  51. package/dist/primitives/Empty.svelte +7 -2
  52. package/dist/primitives/Empty.svelte.d.ts +5 -15
  53. package/dist/primitives/Inset.svelte +45 -26
  54. package/dist/primitives/Inset.svelte.d.ts +9 -20
  55. package/dist/primitives/Node.svelte +32 -19
  56. package/dist/primitives/Node.svelte.d.ts +7 -18
  57. package/dist/primitives/Opacity.svelte +34 -22
  58. package/dist/primitives/Opacity.svelte.d.ts +6 -17
  59. package/dist/primitives/Rotate.svelte +33 -22
  60. package/dist/primitives/Rotate.svelte.d.ts +11 -21
  61. package/dist/primitives/Translate.svelte +32 -19
  62. package/dist/primitives/Translate.svelte.d.ts +7 -18
  63. package/dist/resources/AssetPool.svelte +7 -2
  64. package/dist/resources/AssetPool.svelte.d.ts +5 -15
  65. package/dist/resources/AudioBufferedAsset.svelte +14 -6
  66. package/dist/resources/AudioBufferedAsset.svelte.d.ts +5 -15
  67. package/dist/resources/AudioMediaAsset.svelte +10 -2
  68. package/dist/resources/AudioMediaAsset.svelte.d.ts +5 -15
  69. package/dist/resources/ImageAsset.svelte +16 -9
  70. package/dist/resources/ImageAsset.svelte.d.ts +5 -15
  71. package/dist/resources/audio.d.ts +1 -1
  72. package/dist/resources/images.d.ts +1 -1
  73. package/dist/scenes/SceneSwitcher.svelte +27 -16
  74. package/dist/scenes/SceneSwitcher.svelte.d.ts +5 -16
  75. package/dist/scenes/SceneTransition.svelte +47 -36
  76. package/dist/scenes/SceneTransition.svelte.d.ts +6 -20
  77. package/package.json +10 -9
@@ -1,50 +1,62 @@
1
- <script>import { getGame } from "../core-contexts.js";
2
- import { setupDrawable } from "../drawable.js";
3
- import { onMount, createEventDispatcher } from "svelte";
4
- import { MOUSE_ACTION } from "./mouse.js";
5
- let tx = 0;
6
- let ty = 0;
7
- let tw = 0;
8
- let th = 0;
9
- let dispatch = createEventDispatcher();
10
- let context = getGame();
11
- const draw = function(_info, { x, y, w, h }) {
12
- tx = x;
13
- ty = y;
14
- tw = w;
15
- th = h;
16
- };
17
- let register = setupDrawable({});
18
- onMount(() => {
19
- let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
20
- let x = context.getMousePosition("mouse_x");
21
- if (x < tx || x > tx + tw)
22
- return;
23
- let y = context.getMousePosition("mouse_y");
24
- if (y < ty || y > ty + th)
25
- return;
26
- dispatch("click");
27
- switch (key) {
28
- case "mouse_left": {
29
- dispatch("left");
30
- dispatch("leftorright");
31
- return;
32
- }
33
- case "mouse_right": {
34
- dispatch("right");
35
- dispatch("leftorright");
36
- return;
37
- }
38
- case "mouse_middle": {
39
- dispatch("middle");
40
- }
41
- }
42
- dispatch("other");
43
- });
44
- let deregister = register({ draw });
45
- return () => {
46
- event();
47
- deregister();
48
- };
49
- });
1
+ <script lang="ts">
2
+
3
+ import { getGame } from "../core-contexts.js";
4
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
5
+ import { onMount } from "svelte";
6
+ import { MOUSE_ACTION } from "./mouse.js";
7
+
8
+ let tx = 0;
9
+ let ty = 0;
10
+ let tw = 0;
11
+ let th = 0;
12
+
13
+ let context = getGame();
14
+
15
+ type Click = () => void;
16
+ let {
17
+ onleft,
18
+ onright,
19
+ onleftorright,
20
+ onclick,
21
+ onmiddle,
22
+ onother
23
+ }: {
24
+ onleft: Click,
25
+ onright: Click,
26
+ onleftorright: Click,
27
+ onclick: Click,
28
+ onmiddle: Click,
29
+ onother: Click,
30
+ } = $props();
31
+
32
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function(_info, { x, y, w, h }) {
33
+ tx = x;
34
+ ty = y;
35
+ tw = w;
36
+ th = h;
37
+ };
38
+
39
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
40
+
41
+ onMount(() => {
42
+ let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
43
+ let x = context.getMousePosition("mouse_x");
44
+ if (x < tx || x > tx + tw) return;
45
+ let y = context.getMousePosition("mouse_y");
46
+ if (y < ty || y > ty + th) return;
47
+ onclick();
48
+ switch (key) {
49
+ case ("mouse_left"): { onleft(); onleftorright(); return; }
50
+ case ("mouse_right"): { onright(); onleftorright(); return; }
51
+ case ("mouse_middle"): { onmiddle; }
52
+ }
53
+ onother();
54
+ });
55
+ let deregister = register({ draw });
56
+ return () => {
57
+ event();
58
+ deregister();
59
+ }
60
+ })
61
+
50
62
  </script>
@@ -1,21 +1,12 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- click: CustomEvent<any>;
6
- left: CustomEvent<any>;
7
- leftorright: CustomEvent<any>;
8
- right: CustomEvent<any>;
9
- middle: CustomEvent<any>;
10
- other: CustomEvent<any>;
11
- } & {
12
- [evt: string]: CustomEvent<any>;
13
- };
14
- slots: {};
1
+ type Click = () => void;
2
+ type $$ComponentProps = {
3
+ onleft: Click;
4
+ onright: Click;
5
+ onleftorright: Click;
6
+ onclick: Click;
7
+ onmiddle: Click;
8
+ onother: Click;
15
9
  };
16
- export type MouseClickableProps = typeof __propDef.props;
17
- export type MouseClickableEvents = typeof __propDef.events;
18
- export type MouseClickableSlots = typeof __propDef.slots;
19
- export default class MouseClickable extends SvelteComponent<MouseClickableProps, MouseClickableEvents, MouseClickableSlots> {
20
- }
21
- export {};
10
+ declare const MouseClickable: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ type MouseClickable = ReturnType<typeof MouseClickable>;
12
+ export default MouseClickable;
@@ -1,58 +1,74 @@
1
- <script>import { getGame } from "../core-contexts.js";
2
- import { setupDrawable } from "../drawable.js";
3
- import { onMount, createEventDispatcher } from "svelte";
4
- import { MOUSE_ACTION } from "./mouse.js";
5
- let tx = 0;
6
- let ty = 0;
7
- let tw = 0;
8
- let th = 0;
9
- let dispatch = createEventDispatcher();
10
- let context = getGame();
11
- let mouseX = context.getMouseStore("mouse_x");
12
- let mouseY = context.getMouseStore("mouse_y");
13
- export let hover = false;
14
- const draw = function(_info, { x, y, w, h }) {
15
- tx = x;
16
- ty = y;
17
- tw = w;
18
- th = h;
19
- if ($mouseX < tx || $mouseX > tx + tw)
20
- return hover = false;
21
- if ($mouseY < ty || $mouseY > ty + th)
22
- return hover = false;
23
- hover = true;
24
- };
25
- let register = setupDrawable({});
26
- onMount(() => {
27
- let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
28
- if ($mouseX < tx || $mouseX > tx + tw)
29
- return;
30
- if ($mouseY < ty || $mouseY > ty + th)
31
- return;
32
- dispatch("click");
33
- switch (key) {
34
- case "mouse_left": {
35
- dispatch("left");
36
- dispatch("leftorright");
37
- return;
38
- }
39
- case "mouse_right": {
40
- dispatch("right");
41
- dispatch("leftorright");
42
- return;
43
- }
44
- case "mouse_middle": {
45
- dispatch("middle");
46
- }
1
+ <script lang="ts">
2
+
3
+ import { getGame } from "../core-contexts.js";
4
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
5
+ import { onMount, createEventDispatcher } from "svelte";
6
+ import { MOUSE_ACTION } from "./mouse.js";
7
+
8
+ let tx = 0;
9
+ let ty = 0;
10
+ let tw = 0;
11
+ let th = 0;
12
+
13
+ let dispatch = createEventDispatcher();
14
+ let context = getGame();
15
+
16
+ let mouseX = context.getMouseStore("mouse_x");
17
+ let mouseY = context.getMouseStore("mouse_y");
18
+
19
+ type Click = () => void;
20
+ interface Props {
21
+ hover?: boolean;
22
+ children?: import('svelte').Snippet<[any]>;
23
+ onleft: Click;
24
+ onright: Click;
25
+ onleftorright: Click;
26
+ onclick: Click;
27
+ onmiddle: Click;
28
+ onother: Click;
47
29
  }
48
- dispatch("other");
49
- });
50
- let deregister = register({ draw });
51
- return () => {
52
- event();
53
- deregister();
54
- };
55
- });
30
+
31
+ let { hover = $bindable(false), children,
32
+ onleft,
33
+ onright,
34
+ onleftorright,
35
+ onclick,
36
+ onmiddle,
37
+ onother
38
+ }: Props = $props();
39
+
40
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function(_info, { x, y, w, h }) {
41
+ tx = x;
42
+ ty = y;
43
+ tw = w;
44
+ th = h;
45
+
46
+ if ($mouseX < tx || $mouseX > tx + tw) return hover = false;
47
+ if ($mouseY < ty || $mouseY > ty + th) return hover = false;
48
+ hover = true;
49
+ };
50
+
51
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
52
+
53
+ onMount(() => {
54
+ let event = context.onMouseEvent(null, MOUSE_ACTION.DOWN, ({ key }) => {
55
+ if ($mouseX < tx || $mouseX > tx + tw) return;
56
+ if ($mouseY < ty || $mouseY > ty + th) return;
57
+ onclick();
58
+ switch (key) {
59
+ case ("mouse_left"): { onleft(); onleftorright(); return; }
60
+ case ("mouse_right"): { onright(); onleftorright(); return; }
61
+ case ("mouse_middle"): { onmiddle; }
62
+ }
63
+ onother();
64
+ });
65
+ let deregister = register({ draw });
66
+ return () => {
67
+ event();
68
+ deregister();
69
+ }
70
+ })
71
+
56
72
  </script>
57
73
 
58
- <slot {hover} />
74
+ {@render children?.({ hover, })}
@@ -1,27 +1,14 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- hover?: boolean | undefined;
5
- };
6
- events: {
7
- click: CustomEvent<any>;
8
- left: CustomEvent<any>;
9
- leftorright: CustomEvent<any>;
10
- right: CustomEvent<any>;
11
- middle: CustomEvent<any>;
12
- other: CustomEvent<any>;
13
- } & {
14
- [evt: string]: CustomEvent<any>;
15
- };
16
- slots: {
17
- default: {
18
- hover: boolean;
19
- };
20
- };
21
- };
22
- export type MouseEventAreaProps = typeof __propDef.props;
23
- export type MouseEventAreaEvents = typeof __propDef.events;
24
- export type MouseEventAreaSlots = typeof __propDef.slots;
25
- export default class MouseEventArea extends SvelteComponent<MouseEventAreaProps, MouseEventAreaEvents, MouseEventAreaSlots> {
1
+ type Click = () => void;
2
+ interface Props {
3
+ hover?: boolean;
4
+ children?: import('svelte').Snippet<[any]>;
5
+ onleft: Click;
6
+ onright: Click;
7
+ onleftorright: Click;
8
+ onclick: Click;
9
+ onmiddle: Click;
10
+ onother: Click;
26
11
  }
27
- export {};
12
+ declare const MouseEventArea: import("svelte").Component<Props, {}, "hover">;
13
+ type MouseEventArea = ReturnType<typeof MouseEventArea>;
14
+ export default MouseEventArea;
@@ -1,4 +1,3 @@
1
- /// <reference types="svelte" />
2
1
  import type { Writable } from "svelte/store";
3
2
  export declare class Timing {
4
3
  constructor();
@@ -18,10 +17,10 @@ export declare class Timing {
18
17
  duration: number;
19
18
  repeats: number;
20
19
  }): {
21
- stop: () => boolean;
20
+ stop: () => any;
22
21
  set(this: void, value: number): void;
23
22
  update(this: void, updater: import("svelte/store").Updater<number>): void;
24
- subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
23
+ subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: () => void): import("svelte/store").Unsubscriber;
25
24
  };
26
25
  /**
27
26
  * Used to create a store whose value adjusts based on bursts.
@@ -31,11 +30,11 @@ export declare class Timing {
31
30
  duration: number;
32
31
  initialTrigger?: boolean;
33
32
  }): {
34
- stop: () => boolean;
33
+ stop: () => any;
35
34
  trigger: () => void;
36
35
  set(this: void, value: number): void;
37
36
  update(this: void, updater: import("svelte/store").Updater<number>): void;
38
- subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
37
+ subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: () => void): import("svelte/store").Unsubscriber;
39
38
  };
40
39
  update(delta: number): void;
41
40
  }
@@ -1,31 +1,49 @@
1
- <script>import { setupDrawable } from "../drawable.js";
2
- import { onMount } from "svelte";
3
- export let fill = null;
4
- export let stroke = null;
5
- export let strokeWidth = null;
6
- export let startAngle;
7
- export let endAngle;
8
- $:
9
- sd = (startAngle - 90) * Math.PI / 180;
10
- $:
11
- ed = (endAngle - 90) * Math.PI / 180;
12
- const draw = function({ ctx }, { x, y, w, h }) {
13
- let r = (w + h) / 4;
14
- ctx.beginPath();
15
- ctx.arc(x + r, y + r, r, sd, ed);
16
- ctx.lineTo(x + r, y + r);
17
- if (fill) {
18
- ctx.fillStyle = fill;
19
- ctx.fill();
20
- }
21
- if (stroke && strokeWidth) {
22
- ctx.strokeStyle = stroke;
23
- ctx.lineWidth = strokeWidth;
24
- ctx.stroke();
25
- }
26
- };
27
- let register = setupDrawable({});
28
- onMount(() => {
29
- return register({ draw });
30
- });
1
+ <script lang="ts">
2
+
3
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
4
+ import { onMount } from "svelte";
5
+
6
+ interface Props {
7
+ fill?: string | null;
8
+ stroke?: string | null;
9
+ strokeWidth?: number | null;
10
+ startAngle: number;
11
+ endAngle: number;
12
+ }
13
+
14
+ let {
15
+ fill = null,
16
+ stroke = null,
17
+ strokeWidth = null,
18
+ startAngle,
19
+ endAngle
20
+ }: Props = $props();
21
+
22
+ let sd = $derived((startAngle - 90) * Math.PI / 180);
23
+ let ed = $derived((endAngle - 90) * Math.PI / 180);
24
+
25
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
26
+ let r = (w + h) / 4
27
+
28
+ ctx.beginPath();
29
+ ctx.arc(x + r, y + r, r, sd, ed);
30
+ ctx.lineTo(x + r, y + r);
31
+
32
+ if (fill) {
33
+ ctx.fillStyle = fill;
34
+ ctx.fill();
35
+ }
36
+
37
+ if (stroke && strokeWidth) {
38
+ ctx.strokeStyle = stroke;
39
+ ctx.lineWidth = strokeWidth;
40
+ ctx.stroke();
41
+ }
42
+ };
43
+
44
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
45
+
46
+ onMount(() => {
47
+ return register({ draw });
48
+ })
31
49
  </script>
@@ -1,20 +1,10 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- fill?: string | null | undefined;
5
- stroke?: string | null | undefined;
6
- strokeWidth?: number | null | undefined;
7
- startAngle: number;
8
- endAngle: number;
9
- };
10
- events: {
11
- [evt: string]: CustomEvent<any>;
12
- };
13
- slots: {};
14
- };
15
- export type ArcProps = typeof __propDef.props;
16
- export type ArcEvents = typeof __propDef.events;
17
- export type ArcSlots = typeof __propDef.slots;
18
- export default class Arc extends SvelteComponent<ArcProps, ArcEvents, ArcSlots> {
1
+ interface Props {
2
+ fill?: string | null;
3
+ stroke?: string | null;
4
+ strokeWidth?: number | null;
5
+ startAngle: number;
6
+ endAngle: number;
19
7
  }
20
- export {};
8
+ declare const Arc: import("svelte").Component<Props, {}, "">;
9
+ type Arc = ReturnType<typeof Arc>;
10
+ export default Arc;
@@ -1,25 +1,39 @@
1
- <script>import { setupDrawable } from "../drawable.js";
2
- import { onMount } from "svelte";
3
- export let fill = null;
4
- export let stroke = null;
5
- export let strokeWidth = null;
6
- const TWO_PI = Math.PI * 2;
7
- const draw = function({ ctx }, { x, y, w, h }) {
8
- let r = (w + h) / 4;
9
- ctx.beginPath();
10
- ctx.arc(x + r, y + r, r, 0, TWO_PI);
11
- if (fill) {
12
- ctx.fillStyle = fill;
13
- ctx.fill();
14
- }
15
- if (stroke && strokeWidth) {
16
- ctx.strokeStyle = stroke;
17
- ctx.lineWidth = strokeWidth;
18
- ctx.stroke();
19
- }
20
- };
21
- let register = setupDrawable({});
22
- onMount(() => {
23
- return register({ draw });
24
- });
1
+ <script lang="ts">
2
+
3
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
4
+ import { onMount } from "svelte";
5
+
6
+ interface Props {
7
+ fill?: string | null;
8
+ stroke?: string | null;
9
+ strokeWidth?: number | null;
10
+ }
11
+
12
+ let { fill = null, stroke = null, strokeWidth = null }: Props = $props();
13
+
14
+ const TWO_PI = Math.PI * 2;
15
+
16
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
17
+ let r = (w + h) / 4
18
+
19
+ ctx.beginPath();
20
+ ctx.arc(x + r, y + r, r, 0, TWO_PI);
21
+
22
+ if (fill) {
23
+ ctx.fillStyle = fill;
24
+ ctx.fill();
25
+ }
26
+
27
+ if (stroke && strokeWidth) {
28
+ ctx.strokeStyle = stroke;
29
+ ctx.lineWidth = strokeWidth;
30
+ ctx.stroke();
31
+ }
32
+ };
33
+
34
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
35
+
36
+ onMount(() => {
37
+ return register({ draw });
38
+ })
25
39
  </script>
@@ -1,18 +1,8 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- fill?: string | null | undefined;
5
- stroke?: string | null | undefined;
6
- strokeWidth?: number | null | undefined;
7
- };
8
- events: {
9
- [evt: string]: CustomEvent<any>;
10
- };
11
- slots: {};
12
- };
13
- export type CircleProps = typeof __propDef.props;
14
- export type CircleEvents = typeof __propDef.events;
15
- export type CircleSlots = typeof __propDef.slots;
16
- export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
1
+ interface Props {
2
+ fill?: string | null;
3
+ stroke?: string | null;
4
+ strokeWidth?: number | null;
17
5
  }
18
- export {};
6
+ declare const Circle: import("svelte").Component<Props, {}, "">;
7
+ type Circle = ReturnType<typeof Circle>;
8
+ export default Circle;
@@ -1,17 +1,27 @@
1
- <script>import { setupDrawable } from "../drawable.js";
2
- import { onMount } from "svelte";
3
- export let image = null;
4
- export let crop = null;
5
- const draw = function({ ctx }, { x, y, w, h }) {
6
- if (!image)
7
- return;
8
- if (crop) {
9
- return ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, x, y, w, h);
10
- }
11
- ctx.drawImage(image, x, y, w, h);
12
- };
13
- let register = setupDrawable({});
14
- onMount(() => {
15
- return register({ draw });
16
- });
1
+ <script lang="ts">
2
+
3
+ import { setupDrawable, type DrawFunction} from "../drawable.js";
4
+ import { onMount } from "svelte";
5
+
6
+ interface Props {
7
+ image?: HTMLImageElement | null;
8
+ crop?: { x: number, y: number, w: number, h: number } | null;
9
+ }
10
+
11
+ let { image = null, crop = null }: Props = $props();
12
+
13
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function({ ctx }, { x, y, w, h }: { x: number, y: number, w: number, h: number }) {
14
+ if (!image) return;
15
+ if (crop) {
16
+ return ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, x, y, w, h);
17
+ }
18
+ ctx.drawImage(image, x, y, w, h);
19
+ };
20
+
21
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, null>({});
22
+
23
+ onMount(() => {
24
+ return register({ draw });
25
+ })
26
+
17
27
  </script>
@@ -1,22 +1,12 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- image?: HTMLImageElement | null | undefined;
5
- crop?: {
6
- x: number;
7
- y: number;
8
- w: number;
9
- h: number;
10
- } | null | undefined;
11
- };
12
- events: {
13
- [evt: string]: CustomEvent<any>;
14
- };
15
- slots: {};
16
- };
17
- export type DisplayImageProps = typeof __propDef.props;
18
- export type DisplayImageEvents = typeof __propDef.events;
19
- export type DisplayImageSlots = typeof __propDef.slots;
20
- export default class DisplayImage extends SvelteComponent<DisplayImageProps, DisplayImageEvents, DisplayImageSlots> {
1
+ interface Props {
2
+ image?: HTMLImageElement | null;
3
+ crop?: {
4
+ x: number;
5
+ y: number;
6
+ w: number;
7
+ h: number;
8
+ } | null;
21
9
  }
22
- export {};
10
+ declare const DisplayImage: import("svelte").Component<Props, {}, "">;
11
+ type DisplayImage = ReturnType<typeof DisplayImage>;
12
+ export default DisplayImage;