@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.
- package/dist/Game.svelte +154 -129
- package/dist/Game.svelte.d.ts +10 -21
- package/dist/Layer.svelte +61 -46
- package/dist/Layer.svelte.d.ts +9 -20
- package/dist/audio/AudioCompressor.svelte +70 -44
- package/dist/audio/AudioCompressor.svelte.d.ts +14 -23
- package/dist/audio/AudioGain.svelte +33 -20
- package/dist/audio/AudioGain.svelte.d.ts +6 -17
- package/dist/audio/AudioListenerPosition.svelte +79 -93
- package/dist/audio/AudioListenerPosition.svelte.d.ts +6 -16
- package/dist/audio/AudioPanner.svelte +33 -20
- package/dist/audio/AudioPanner.svelte.d.ts +6 -17
- package/dist/audio/BufferedAudioSource.svelte +59 -44
- package/dist/audio/BufferedAudioSource.svelte.d.ts +8 -18
- package/dist/audio/MediaAudioSource.svelte +56 -35
- package/dist/audio/MediaAudioSource.svelte.d.ts +13 -25
- package/dist/audio/context.d.ts +1 -1
- package/dist/controllers/MouseClickable.svelte +61 -49
- package/dist/controllers/MouseClickable.svelte.d.ts +11 -20
- package/dist/controllers/MouseEventArea.svelte +71 -55
- package/dist/controllers/MouseEventArea.svelte.d.ts +13 -26
- package/dist/controllers/motions.d.ts +4 -5
- package/dist/drawables/Arc.svelte +48 -30
- package/dist/drawables/Arc.svelte.d.ts +9 -19
- package/dist/drawables/Circle.svelte +38 -24
- package/dist/drawables/Circle.svelte.d.ts +7 -17
- package/dist/drawables/DisplayImage.svelte +26 -16
- package/dist/drawables/DisplayImage.svelte.d.ts +11 -21
- package/dist/drawables/MultiLineText.svelte +75 -45
- package/dist/drawables/MultiLineText.svelte.d.ts +14 -24
- package/dist/drawables/Rectangle.svelte +35 -22
- package/dist/drawables/Rectangle.svelte.d.ts +7 -17
- package/dist/drawables/RoundedRectangle.svelte +41 -23
- package/dist/drawables/RoundedRectangle.svelte.d.ts +8 -18
- package/dist/drawables/Text.svelte +63 -40
- package/dist/drawables/Text.svelte.d.ts +13 -23
- package/dist/drawables/Tiled.svelte +79 -61
- package/dist/drawables/Tiled.svelte.d.ts +10 -20
- package/dist/extras/DefaultFontFace.svelte +35 -17
- package/dist/extras/DefaultFontFace.svelte.d.ts +15 -24
- package/dist/extras/FullScreenEventHandler.svelte +37 -23
- package/dist/extras/FullScreenEventHandler.svelte.d.ts +9 -19
- package/dist/extras/LayerPortal.svelte +36 -22
- package/dist/extras/LayerPortal.svelte.d.ts +6 -17
- package/dist/extras/SensibleDefaultStyles.svelte +8 -2
- package/dist/extras/SensibleDefaultStyles.svelte.d.ts +5 -17
- package/dist/extras/Tweened.svelte +28 -9
- package/dist/extras/Tweened.svelte.d.ts +12 -22
- package/dist/primitives/Area.svelte +46 -22
- package/dist/primitives/Area.svelte.d.ts +14 -24
- package/dist/primitives/Empty.svelte +7 -2
- package/dist/primitives/Empty.svelte.d.ts +5 -15
- package/dist/primitives/Inset.svelte +45 -26
- package/dist/primitives/Inset.svelte.d.ts +9 -20
- package/dist/primitives/Node.svelte +32 -19
- package/dist/primitives/Node.svelte.d.ts +7 -18
- package/dist/primitives/Opacity.svelte +34 -22
- package/dist/primitives/Opacity.svelte.d.ts +6 -17
- package/dist/primitives/Rotate.svelte +33 -22
- package/dist/primitives/Rotate.svelte.d.ts +11 -21
- package/dist/primitives/Translate.svelte +32 -19
- package/dist/primitives/Translate.svelte.d.ts +7 -18
- package/dist/resources/AssetPool.svelte +7 -2
- package/dist/resources/AssetPool.svelte.d.ts +5 -15
- package/dist/resources/AudioBufferedAsset.svelte +14 -6
- package/dist/resources/AudioBufferedAsset.svelte.d.ts +5 -15
- package/dist/resources/AudioMediaAsset.svelte +10 -2
- package/dist/resources/AudioMediaAsset.svelte.d.ts +5 -15
- package/dist/resources/ImageAsset.svelte +16 -9
- package/dist/resources/ImageAsset.svelte.d.ts +5 -15
- package/dist/resources/audio.d.ts +1 -1
- package/dist/resources/images.d.ts +1 -1
- package/dist/scenes/SceneSwitcher.svelte +27 -16
- package/dist/scenes/SceneSwitcher.svelte.d.ts +5 -16
- package/dist/scenes/SceneTransition.svelte +47 -36
- package/dist/scenes/SceneTransition.svelte.d.ts +6 -20
- package/package.json +10 -9
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { TileSet } from "../resources/tileset.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
10
|
+
declare const Tiled: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type Tiled = ReturnType<typeof Tiled>;
|
|
12
|
+
export default Tiled;
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
+
declare const DefaultFontFace: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type DefaultFontFace = ReturnType<typeof DefaultFontFace>;
|
|
16
|
+
export default DefaultFontFace;
|
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
8
|
+
declare const FullScreenEventHandler: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type FullScreenEventHandler = ReturnType<typeof FullScreenEventHandler>;
|
|
10
|
+
export default FullScreenEventHandler;
|
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
38
|
+
{@render children?.()}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
declare const LayerPortal: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type LayerPortal = ReturnType<typeof LayerPortal>;
|
|
7
|
+
export default LayerPortal;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
<script>
|
|
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
|
-
|
|
11
|
+
{@render children?.({ wrapper: x, })}
|
|
6
12
|
</div>
|
|
7
13
|
|
|
8
14
|
<style>
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
4
|
+
declare const SensibleDefaultStyles: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type SensibleDefaultStyles = ReturnType<typeof SensibleDefaultStyles>;
|
|
6
|
+
export default SensibleDefaultStyles;
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
30
|
+
{@render children?.({ smooth: tween.current })}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
11
|
+
declare const Tweened: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type Tweened = ReturnType<typeof Tweened>;
|
|
13
|
+
export default Tweened;
|
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
49
|
+
{@render children?.()}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
13
|
+
declare const Area: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type Area = ReturnType<typeof Area>;
|
|
15
|
+
export default Area;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
4
|
+
declare const Empty: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type Empty = ReturnType<typeof Empty>;
|
|
6
|
+
export default Empty;
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
48
|
+
{@render children?.()}
|