@hi-ashleyj/llama 0.13.1 → 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,22 +1,12 @@
1
- import { SvelteComponent } from "svelte";
2
1
  import type { TileSet } from "../resources/tileset.js";
3
- declare const __propDef: {
4
- props: {
5
- shiftX: number;
6
- shiftY: number;
7
- drawSize: number;
8
- tileSet: TileSet;
9
- alias: Record<string, [number, number]>;
10
- map: string[];
11
- };
12
- events: {
13
- [evt: string]: CustomEvent<any>;
14
- };
15
- slots: {};
16
- };
17
- export type TiledProps = typeof __propDef.props;
18
- export type TiledEvents = typeof __propDef.events;
19
- export type TiledSlots = typeof __propDef.slots;
20
- export default class Tiled extends SvelteComponent<TiledProps, TiledEvents, TiledSlots> {
2
+ interface Props {
3
+ shiftX: number;
4
+ shiftY: number;
5
+ drawSize: number;
6
+ tileSet: TileSet;
7
+ alias: Record<string, [number, number]>;
8
+ map: string[];
21
9
  }
22
- export {};
10
+ declare const Tiled: import("svelte").Component<Props, {}, "">;
11
+ type Tiled = ReturnType<typeof Tiled>;
12
+ export default Tiled;
@@ -1,18 +1,36 @@
1
- <script>import { getGame } from "../core-contexts.js";
2
- import { onMount, createEventDispatcher } from "svelte";
3
- const { defaultTextFontFace } = getGame();
4
- const dispatch = createEventDispatcher();
5
- export let font;
6
- export let url = null;
7
- onMount(() => {
8
- defaultTextFontFace.set(font);
9
- if (url) {
10
- const face = new FontFace(font, `url(${url})`);
11
- face.load().then(() => dispatch("loaded"));
12
- document.fonts.add(face);
13
- return () => {
14
- document.fonts.delete(face);
15
- };
16
- }
17
- });
1
+ <script lang="ts">
2
+
3
+ import { getGame } from "../core-contexts.js";
4
+ import { onMount } from "svelte";
5
+ const { defaultTextFontFace } = getGame();
6
+
7
+ interface Props {
8
+ /**
9
+ * THE DEFAULT FONT IS ONLY SET ON MOUNT. WRAP INSIDE A {key} IF THIS WILL CHANGE
10
+ */
11
+ font: string;
12
+ /**
13
+ * FONT FACES ARE ONLY AUTO-LOADED ON MOUNT.
14
+ * WRAPPING INSIDE A {key} MAY FIX THIS (not recommended)
15
+ * IF CHANGING FONTS, PRELOAD THEM ALL IN CSS AND UPDATE font PROP ONLY WITHIN {key} BLOCK
16
+ */
17
+ url?: string | null;
18
+ onload?: () => void;
19
+ }
20
+
21
+ let { font, url = null, onload }: Props = $props();
22
+
23
+ onMount(() => {
24
+ defaultTextFontFace.set(font);
25
+
26
+ if (url) {
27
+ const face = new FontFace(font, `url(${url})`);
28
+ face.load().then(() => onload?.());
29
+ document.fonts.add(face);
30
+ return () => {
31
+ document.fonts.delete(face);
32
+ }
33
+ }
34
+ })
35
+
18
36
  </script>
@@ -1,25 +1,16 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- /**
5
- * THE DEFAULT FONT IS ONLY SET ON MOUNT. WRAP INSIDE A {key} IF THIS WILL CHANGE
6
- */ font: string;
7
- /**
8
- * FONT FACES ARE ONLY AUTO-LOADED ON MOUNT.
9
- * WRAPPING INSIDE A {key} MAY FIX THIS (not recommended)
10
- * IF CHANGING FONTS, PRELOAD THEM ALL IN CSS AND UPDATE font PROP ONLY WITHIN {key} BLOCK
11
- */ url?: string | null | undefined;
12
- };
13
- events: {
14
- loaded: CustomEvent<any>;
15
- } & {
16
- [evt: string]: CustomEvent<any>;
17
- };
18
- slots: {};
19
- };
20
- export type DefaultFontFaceProps = typeof __propDef.props;
21
- export type DefaultFontFaceEvents = typeof __propDef.events;
22
- export type DefaultFontFaceSlots = typeof __propDef.slots;
23
- export default class DefaultFontFace extends SvelteComponent<DefaultFontFaceProps, DefaultFontFaceEvents, DefaultFontFaceSlots> {
1
+ interface Props {
2
+ /**
3
+ * THE DEFAULT FONT IS ONLY SET ON MOUNT. WRAP INSIDE A {key} IF THIS WILL CHANGE
4
+ */
5
+ font: string;
6
+ /**
7
+ * FONT FACES ARE ONLY AUTO-LOADED ON MOUNT.
8
+ * WRAPPING INSIDE A {key} MAY FIX THIS (not recommended)
9
+ * IF CHANGING FONTS, PRELOAD THEM ALL IN CSS AND UPDATE font PROP ONLY WITHIN {key} BLOCK
10
+ */
11
+ url?: string | null;
12
+ onload?: () => void;
24
13
  }
25
- export {};
14
+ declare const DefaultFontFace: import("svelte").Component<Props, {}, "">;
15
+ type DefaultFontFace = ReturnType<typeof DefaultFontFace>;
16
+ export default DefaultFontFace;
@@ -1,25 +1,39 @@
1
- <script>import { getGame } from "../core-contexts.js";
2
- import { onMount } from "svelte";
3
- import { KEYBOARD_ACTION } from "../controllers/keyboard.js";
4
- const context = getGame();
5
- export let key = "f";
6
- export let usesShift = true;
7
- export let usesCtrl = false;
8
- export let usesAlt = false;
9
- export let wrapper;
10
- onMount(() => {
11
- return context.onKeyboardEvent(key, KEYBOARD_ACTION.DOWN, () => {
12
- if (usesShift && !context.isKeyboardPressed("shift"))
13
- return;
14
- if (usesCtrl && !context.isKeyboardPressed("ctrl"))
15
- return;
16
- if (usesAlt && !context.isKeyboardPressed("alt"))
17
- return;
18
- if (document.fullscreenElement) {
19
- document.exitFullscreen();
20
- } else {
21
- wrapper.requestFullscreen().catch();
1
+ <script lang="ts">
2
+
3
+ import { getGame } from "../core-contexts.js";
4
+ import { onMount } from "svelte";
5
+ import { KEYBOARD_ACTION } from "../controllers/keyboard.js";
6
+
7
+ const context = getGame();
8
+ // ONLY OBSERVED ON MOUNT. NOT REACTIVE (good practice anyway)
9
+ interface Props {
10
+ key?: string;
11
+ usesShift?: boolean;
12
+ usesCtrl?: boolean;
13
+ usesAlt?: boolean;
14
+ wrapper: HTMLDivElement;
22
15
  }
23
- });
24
- });
16
+
17
+ let {
18
+ key = "f",
19
+ usesShift = true,
20
+ usesCtrl = false,
21
+ usesAlt = false,
22
+ wrapper
23
+ }: Props = $props();
24
+
25
+ onMount(() => {
26
+ return context.onKeyboardEvent(key, KEYBOARD_ACTION.DOWN, () => {
27
+ if (usesShift && !context.isKeyboardPressed("shift")) return;
28
+ if (usesCtrl && !context.isKeyboardPressed("ctrl")) return;
29
+ if (usesAlt && !context.isKeyboardPressed("alt")) return;
30
+
31
+ if (document.fullscreenElement) {
32
+ document.exitFullscreen();
33
+ } else {
34
+ wrapper.requestFullscreen().catch();
35
+ }
36
+ });
37
+ })
38
+
25
39
  </script>
@@ -1,20 +1,10 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- key?: string | undefined;
5
- usesShift?: boolean | undefined;
6
- usesCtrl?: boolean | undefined;
7
- usesAlt?: boolean | undefined;
8
- wrapper: HTMLDivElement;
9
- };
10
- events: {
11
- [evt: string]: CustomEvent<any>;
12
- };
13
- slots: {};
14
- };
15
- export type FullScreenEventHandlerProps = typeof __propDef.props;
16
- export type FullScreenEventHandlerEvents = typeof __propDef.events;
17
- export type FullScreenEventHandlerSlots = typeof __propDef.slots;
18
- export default class FullScreenEventHandler extends SvelteComponent<FullScreenEventHandlerProps, FullScreenEventHandlerEvents, FullScreenEventHandlerSlots> {
1
+ interface Props {
2
+ key?: string;
3
+ usesShift?: boolean;
4
+ usesCtrl?: boolean;
5
+ usesAlt?: boolean;
6
+ wrapper: HTMLDivElement;
19
7
  }
20
- export {};
8
+ declare const FullScreenEventHandler: import("svelte").Component<Props, {}, "">;
9
+ type FullScreenEventHandler = ReturnType<typeof FullScreenEventHandler>;
10
+ export default FullScreenEventHandler;
@@ -1,24 +1,38 @@
1
- <script>import { getGame } from "../core-contexts";
2
- import { setupDrawable } from "../drawable";
3
- import { onMount } from "svelte";
4
- const game = getGame();
5
- export let name;
6
- const targets = /* @__PURE__ */ new Set();
7
- const draw = (core) => {
8
- targets.forEach((t) => t.draw(core));
9
- };
10
- setupDrawable({
11
- assign: (obj) => {
12
- targets.add(obj);
13
- return () => targets.delete(obj);
14
- }
15
- });
16
- onMount(() => {
17
- const context = game.getLayerByName(name);
18
- if (!context)
19
- return;
20
- return context.assign({ draw });
21
- });
1
+ <script lang="ts">
2
+
3
+ import { getGame } from "../core-contexts.js";
4
+ import { setupDrawable, type DrawableObject, type DrawFunction } from "../drawable.js";
5
+ import { onMount } from "svelte";
6
+
7
+ const game = getGame();
8
+
9
+ interface Props {
10
+ name: string;
11
+ children?: import('svelte').Snippet;
12
+ }
13
+
14
+ let { name, children }: Props = $props();
15
+ const targets = new Set<DrawableObject<null>>();
16
+
17
+
18
+ const draw: DrawFunction<null> = (core) => {
19
+ targets.forEach(t => t.draw(core));
20
+ }
21
+
22
+ setupDrawable<null, null>({
23
+ assign: (obj) => {
24
+ targets.add(obj);
25
+ return () => targets.delete(obj);
26
+ }
27
+ });
28
+
29
+ onMount(() => {
30
+ const context = game.getLayerByName(name);
31
+ if (!context) return;
32
+
33
+ return context.assign({ draw });
34
+ })
35
+
22
36
  </script>
23
37
 
24
- <slot />
38
+ {@render children?.()}
@@ -1,18 +1,7 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- name: string;
5
- };
6
- events: {
7
- [evt: string]: CustomEvent<any>;
8
- };
9
- slots: {
10
- default: {};
11
- };
12
- };
13
- export type LayerPortalProps = typeof __propDef.props;
14
- export type LayerPortalEvents = typeof __propDef.events;
15
- export type LayerPortalSlots = typeof __propDef.slots;
16
- export default class LayerPortal extends SvelteComponent<LayerPortalProps, LayerPortalEvents, LayerPortalSlots> {
1
+ interface Props {
2
+ name: string;
3
+ children?: import('svelte').Snippet;
17
4
  }
18
- export {};
5
+ declare const LayerPortal: import("svelte").Component<Props, {}, "">;
6
+ type LayerPortal = ReturnType<typeof LayerPortal>;
7
+ export default LayerPortal;
@@ -1,8 +1,14 @@
1
- <script>let x;
1
+ <script lang="ts">
2
+ interface Props {
3
+ children?: import('svelte').Snippet<[any]>;
4
+ }
5
+
6
+ let { children }: Props = $props();
7
+ let x: HTMLDivElement | undefined = $state();
2
8
  </script>
3
9
 
4
10
  <div class="game-wrapper" bind:this={x}>
5
- <slot wrapper={x} />
11
+ {@render children?.({ wrapper: x, })}
6
12
  </div>
7
13
 
8
14
  <style>
@@ -1,18 +1,6 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {
8
- default: {
9
- wrapper: HTMLDivElement;
10
- };
11
- };
12
- };
13
- export type SensibleDefaultStylesProps = typeof __propDef.props;
14
- export type SensibleDefaultStylesEvents = typeof __propDef.events;
15
- export type SensibleDefaultStylesSlots = typeof __propDef.slots;
16
- export default class SensibleDefaultStyles extends SvelteComponent<SensibleDefaultStylesProps, SensibleDefaultStylesEvents, SensibleDefaultStylesSlots> {
1
+ interface Props {
2
+ children?: import('svelte').Snippet<[any]>;
17
3
  }
18
- export {};
4
+ declare const SensibleDefaultStyles: import("svelte").Component<Props, {}, "">;
5
+ type SensibleDefaultStyles = ReturnType<typeof SensibleDefaultStyles>;
6
+ export default SensibleDefaultStyles;
@@ -1,11 +1,30 @@
1
- <script>import { linear } from "svelte/easing";
2
- import { tweened } from "svelte/motion";
3
- export let duration = 200;
4
- export let value = 0;
5
- export let easing = linear;
6
- const tweening = tweened(null, { duration, easing });
7
- $:
8
- tweening.set(value, { duration, easing });
1
+ <script lang="ts">
2
+ import { linear } from "svelte/easing";
3
+ import { Tween, type TweenOptions } from "svelte/motion";
4
+
5
+ type Milliseconds = number;
6
+
7
+ interface Props {
8
+ duration?: Milliseconds;
9
+ value?: number;
10
+ easing?: TweenOptions<number>["easing"];
11
+ children?: import('svelte').Snippet<[{ smooth: number }]>;
12
+ }
13
+
14
+ let {
15
+ duration = 200,
16
+ value = 0,
17
+ easing = linear,
18
+ children
19
+ }: Props = $props();
20
+
21
+ //@ts-ignore
22
+ const tween = new Tween<number>(value, { duration, easing });
23
+
24
+ $effect(() => {
25
+ tween.set(value, { duration, easing });
26
+ });
27
+
9
28
  </script>
10
29
 
11
- <slot smooth={$tweening} />
30
+ {@render children?.({ smooth: tween.current })}
@@ -1,23 +1,13 @@
1
- import { SvelteComponent } from "svelte";
2
- import { type TweenedOptions } from "svelte/motion";
3
- declare const __propDef: {
4
- props: {
5
- duration?: number | undefined;
6
- value?: number | undefined;
7
- easing?: TweenedOptions<number>["easing"];
8
- };
9
- events: {
10
- [evt: string]: CustomEvent<any>;
11
- };
12
- slots: {
13
- default: {
14
- smooth: number;
15
- };
16
- };
17
- };
18
- export type TweenedProps = typeof __propDef.props;
19
- export type TweenedEvents = typeof __propDef.events;
20
- export type TweenedSlots = typeof __propDef.slots;
21
- export default class Tweened extends SvelteComponent<TweenedProps, TweenedEvents, TweenedSlots> {
1
+ import { type TweenOptions } from "svelte/motion";
2
+ type Milliseconds = number;
3
+ interface Props {
4
+ duration?: Milliseconds;
5
+ value?: number;
6
+ easing?: TweenOptions<number>["easing"];
7
+ children?: import('svelte').Snippet<[{
8
+ smooth: number;
9
+ }]>;
22
10
  }
23
- export {};
11
+ declare const Tweened: import("svelte").Component<Props, {}, "">;
12
+ type Tweened = ReturnType<typeof Tweened>;
13
+ export default Tweened;
@@ -1,25 +1,49 @@
1
- <script>import { setupDrawable } from "../drawable.js";
2
- import { onMount } from "svelte";
3
- export let x = 0;
4
- export let y = 0;
5
- export let w;
6
- export let h;
7
- export let center = false;
8
- const targets = /* @__PURE__ */ new Set();
9
- const draw = function({ width, height, ctx }, offset) {
10
- targets.forEach((f) => f.draw({ width, height, ctx }, { x: offset.x + x - (center ? w / 2 : 0), y: offset.y + y - (center ? h / 2 : 0), w, h }));
11
- };
12
- let register = setupDrawable({
13
- assign: (ctx) => {
14
- targets.add(ctx);
15
- return () => {
16
- targets.delete(ctx);
1
+ <script lang="ts">
2
+
3
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
4
+ import { onMount } from "svelte";
5
+
6
+ interface Props {
7
+ x?: number;
8
+ y?: number;
9
+ w: number;
10
+ h: number;
11
+ /**
12
+ * TRUE = ALIGN CENTER
13
+ * FALSE (default) = ALIGN TOP LEFT
14
+ */
15
+ center?: boolean;
16
+ children?: import('svelte').Snippet;
17
+ }
18
+
19
+ let {
20
+ x = 0,
21
+ y = 0,
22
+ w,
23
+ h,
24
+ center = false,
25
+ children
26
+ }: Props = $props();
27
+
28
+ const targets = new Set<{ draw: DrawFunction<{x: number, y: number, w: number, h: number}> }>();
29
+
30
+ const draw: DrawFunction<{x: number, y: number}> = function ( { width, height, ctx }, offset ) {
31
+ targets.forEach(f => f.draw({ width, height, ctx }, { x: offset.x + x - (center ? w / 2 : 0), y: offset.y + y - (center ? h / 2 : 0), w, h }));
17
32
  };
18
- }
19
- });
20
- onMount(() => {
21
- return register({ draw });
22
- });
33
+
34
+ let register = setupDrawable<{x: number, y: number}, {x: number, y: number, w: number, h: number}>({
35
+ assign: (ctx) => {
36
+ targets.add(ctx);
37
+ return () => {
38
+ targets.delete(ctx);
39
+ };
40
+ },
41
+ });
42
+
43
+ onMount(() => {
44
+ return register({ draw });
45
+ });
46
+
23
47
  </script>
24
48
 
25
- <slot/>
49
+ {@render children?.()}
@@ -1,25 +1,15 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: {
4
- x?: number | undefined;
5
- y?: number | undefined;
6
- w: number;
7
- h: number;
8
- /**
9
- * TRUE = ALIGN CENTER
10
- * FALSE (default) = ALIGN TOP LEFT
11
- */ center?: boolean | undefined;
12
- };
13
- events: {
14
- [evt: string]: CustomEvent<any>;
15
- };
16
- slots: {
17
- default: {};
18
- };
19
- };
20
- export type AreaProps = typeof __propDef.props;
21
- export type AreaEvents = typeof __propDef.events;
22
- export type AreaSlots = typeof __propDef.slots;
23
- export default class Area extends SvelteComponent<AreaProps, AreaEvents, AreaSlots> {
1
+ interface Props {
2
+ x?: number;
3
+ y?: number;
4
+ w: number;
5
+ h: number;
6
+ /**
7
+ * TRUE = ALIGN CENTER
8
+ * FALSE (default) = ALIGN TOP LEFT
9
+ */
10
+ center?: boolean;
11
+ children?: import('svelte').Snippet;
24
12
  }
25
- export {};
13
+ declare const Area: import("svelte").Component<Props, {}, "">;
14
+ type Area = ReturnType<typeof Area>;
15
+ export default Area;
@@ -1,2 +1,7 @@
1
- <script></script>
2
- <slot />
1
+ <script lang="ts">
2
+ interface Props {
3
+ children?: import('svelte').Snippet;
4
+ }
5
+
6
+ let { children }: Props = $props();</script>
7
+ {@render children?.()}
@@ -1,16 +1,6 @@
1
- import { SvelteComponent } from "svelte";
2
- declare const __propDef: {
3
- props: Record<string, never>;
4
- events: {
5
- [evt: string]: CustomEvent<any>;
6
- };
7
- slots: {
8
- default: {};
9
- };
10
- };
11
- export type EmptyProps = typeof __propDef.props;
12
- export type EmptyEvents = typeof __propDef.events;
13
- export type EmptySlots = typeof __propDef.slots;
14
- export default class Empty extends SvelteComponent<EmptyProps, EmptyEvents, EmptySlots> {
1
+ interface Props {
2
+ children?: import('svelte').Snippet;
15
3
  }
16
- export {};
4
+ declare const Empty: import("svelte").Component<Props, {}, "">;
5
+ type Empty = ReturnType<typeof Empty>;
6
+ export default Empty;
@@ -1,29 +1,48 @@
1
- <script>import { setupDrawable } from "../drawable.js";
2
- import { onMount } from "svelte";
3
- export let left = 0;
4
- export let right = 0;
5
- export let top = 0;
6
- export let bottom = 0;
7
- const targets = /* @__PURE__ */ new Set();
8
- const draw = function({ width, height, ctx }, o) {
9
- targets.forEach((f) => f.draw({ width, height, ctx }, {
10
- x: o.x + left,
11
- y: o.y + top,
12
- w: o.x - left - right,
13
- h: o.y - top - bottom
14
- }));
15
- };
16
- let register = setupDrawable({
17
- assign: (ctx) => {
18
- targets.add(ctx);
19
- return () => {
20
- targets.delete(ctx);
1
+ <script lang="ts">
2
+
3
+ import { setupDrawable, type DrawFunction } from "../drawable.js";
4
+ import { onMount } from "svelte";
5
+
6
+ interface Props {
7
+ left?: number;
8
+ right?: number;
9
+ top?: number;
10
+ bottom?: number;
11
+ children?: import('svelte').Snippet;
12
+ }
13
+
14
+ let {
15
+ left = 0,
16
+ right = 0,
17
+ top = 0,
18
+ bottom = 0,
19
+ children
20
+ }: Props = $props();
21
+
22
+ const targets = new Set<{ draw: DrawFunction<{x: number, y: number, w: number, h: number}> }>();
23
+
24
+ const draw: DrawFunction<{x: number, y: number, w: number, h: number}> = function ( { width, height, ctx }, o ) {
25
+ targets.forEach(f => f.draw({ width, height, ctx }, {
26
+ x: o.x + left,
27
+ y: o.y + top,
28
+ w: o.w - (left + right),
29
+ h: o.h - (top + bottom),
30
+ }));
21
31
  };
22
- }
23
- });
24
- onMount(() => {
25
- return register({ draw });
26
- });
32
+
33
+ let register = setupDrawable<{x: number, y: number, w: number, h: number}, {x: number, y: number, w: number, h: number}>({
34
+ assign: (ctx) => {
35
+ targets.add(ctx);
36
+ return () => {
37
+ targets.delete(ctx);
38
+ };
39
+ },
40
+ });
41
+
42
+ onMount(() => {
43
+ return register({ draw });
44
+ });
45
+
27
46
  </script>
28
47
 
29
- <slot/>
48
+ {@render children?.()}