@hi-ashleyj/llama 0.11.0 → 0.12.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 +23 -2
- package/dist/audio/AudioCompressor.svelte +46 -0
- package/dist/audio/AudioCompressor.svelte.d.ts +24 -0
- package/dist/audio/AudioGain.svelte +22 -0
- package/dist/audio/AudioGain.svelte.d.ts +18 -0
- package/dist/audio/AudioListenerPosition.svelte +94 -0
- package/dist/audio/AudioListenerPosition.svelte.d.ts +17 -0
- package/dist/audio/AudioPanner.svelte +22 -0
- package/dist/audio/AudioPanner.svelte.d.ts +18 -0
- package/dist/audio/BufferedAudioSource.svelte +47 -0
- package/dist/audio/BufferedAudioSource.svelte.d.ts +19 -0
- package/dist/audio/MediaAudioSource.svelte +37 -0
- package/dist/audio/MediaAudioSource.svelte.d.ts +26 -0
- package/dist/audio/context.d.ts +7 -0
- package/dist/audio/context.js +21 -0
- package/dist/core-contexts.d.ts +2 -0
- package/dist/drawables/MultiLineText.svelte +6 -1
- package/dist/drawables/Text.svelte +5 -1
- package/dist/drawables/Text.svelte.d.ts +1 -1
- package/dist/extras/DefaultFontFace.svelte +18 -0
- package/dist/extras/DefaultFontFace.svelte.d.ts +25 -0
- package/dist/extras/Empty.svelte +1 -0
- package/dist/extras/Empty.svelte.d.ts +7 -11
- package/dist/extras/SensibleDefaultStyles.svelte +2 -0
- package/dist/extras/SensibleDefaultStyles.svelte.d.ts +7 -11
- package/dist/index.d.ts +16 -5
- package/dist/index.js +14 -0
- package/dist/resources/AssetPool.svelte +11 -0
- package/dist/resources/AssetPool.svelte.d.ts +16 -0
- package/dist/resources/AudioBufferedAsset.svelte +7 -0
- package/dist/resources/AudioBufferedAsset.svelte.d.ts +16 -0
- package/dist/resources/AudioMediaAsset.svelte +4 -0
- package/dist/resources/AudioMediaAsset.svelte.d.ts +16 -0
- package/dist/resources/ImageAsset.svelte +12 -0
- package/dist/resources/ImageAsset.svelte.d.ts +16 -0
- package/dist/resources/audio.d.ts +3 -0
- package/dist/resources/audio.js +34 -0
- package/dist/resources/images.d.ts +2 -1
- package/dist/resources/images.js +11 -7
- package/package.json +4 -4
package/dist/Game.svelte
CHANGED
|
@@ -4,6 +4,11 @@ import { setupGame } from "./core-contexts.js";
|
|
|
4
4
|
import { Timing } from "./controllers/motions.js";
|
|
5
5
|
import { Keyboard } from "./controllers/keyboard.js";
|
|
6
6
|
import { Mouse } from "./controllers/mouse.js";
|
|
7
|
+
import { getSetupAudio } from "./audio/context.js";
|
|
8
|
+
import { decodeAllBuffers } from "./resources/audio.js";
|
|
9
|
+
const raise = (err) => {
|
|
10
|
+
throw new Error(err);
|
|
11
|
+
};
|
|
7
12
|
export let width = 1920;
|
|
8
13
|
export let height = 1080;
|
|
9
14
|
export let background = "#000000";
|
|
@@ -68,7 +73,9 @@ export const context = {
|
|
|
68
73
|
onAfterFrame: (callback) => {
|
|
69
74
|
frameAfterEvents.add(callback);
|
|
70
75
|
return () => frameAfterEvents.delete(callback);
|
|
71
|
-
}
|
|
76
|
+
},
|
|
77
|
+
defaultTextFontFace: writable(null),
|
|
78
|
+
getAudioContext: () => audio ? audio : raise("There Is No AudioContext")
|
|
72
79
|
};
|
|
73
80
|
setupGame(context);
|
|
74
81
|
let last = -1;
|
|
@@ -88,7 +95,16 @@ const loop = function(time) {
|
|
|
88
95
|
requestAnimationFrame(loop);
|
|
89
96
|
last = time;
|
|
90
97
|
};
|
|
98
|
+
let audio = null;
|
|
99
|
+
getSetupAudio((node) => {
|
|
100
|
+
if (!audio)
|
|
101
|
+
throw new Error("Audio Is Not Yet Created!");
|
|
102
|
+
node.connect(audio.destination);
|
|
103
|
+
return () => audio && node.disconnect(audio.destination);
|
|
104
|
+
});
|
|
91
105
|
onMount(() => {
|
|
106
|
+
audio = new AudioContext();
|
|
107
|
+
decodeAllBuffers(audio);
|
|
92
108
|
requestAnimationFrame(loop);
|
|
93
109
|
keyboard.start();
|
|
94
110
|
mouse.start();
|
|
@@ -104,13 +120,18 @@ $: {
|
|
|
104
120
|
$: {
|
|
105
121
|
mouse.setWidth(width);
|
|
106
122
|
}
|
|
123
|
+
const resumeAudioContext = () => {
|
|
124
|
+
if (audio?.state === "suspended") {
|
|
125
|
+
audio?.resume();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
107
128
|
</script>
|
|
108
129
|
|
|
109
130
|
<div class="game" style:background-color={background}>
|
|
110
131
|
<slot />
|
|
111
132
|
</div>
|
|
112
133
|
|
|
113
|
-
<svelte:window bind:innerHeight={wih} bind:innerWidth={wiw}></svelte:window>
|
|
134
|
+
<svelte:window bind:innerHeight={wih} bind:innerWidth={wiw} on:click={resumeAudioContext} on:keydown={resumeAudioContext}></svelte:window>
|
|
114
135
|
|
|
115
136
|
<style>
|
|
116
137
|
.game {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>import { getAudioContext, getConnector } from "./context.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
const audioContext = getAudioContext();
|
|
4
|
+
export let preGain = 1;
|
|
5
|
+
export let postGain = 1;
|
|
6
|
+
export let attack = 10;
|
|
7
|
+
export let threshold = -6;
|
|
8
|
+
export let blend = 3;
|
|
9
|
+
export let ratio = 2;
|
|
10
|
+
export let release = 150;
|
|
11
|
+
let output;
|
|
12
|
+
let input;
|
|
13
|
+
let process;
|
|
14
|
+
$: {
|
|
15
|
+
if (output) {
|
|
16
|
+
output.gain.setTargetAtTime(postGain, audioCTX.currentTime, 4e-3);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
$: {
|
|
20
|
+
if (input) {
|
|
21
|
+
input.gain.setTargetAtTime(preGain, audioCTX.currentTime, 4e-3);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
$: {
|
|
25
|
+
if (process) {
|
|
26
|
+
process.attack.setTargetAtTime(attack / 1e3, audioCTX.currentTime, 4e-3);
|
|
27
|
+
process.threshold.setTargetAtTime(threshold, audioCTX.currentTime, 4e-3);
|
|
28
|
+
process.knee.setTargetAtTime(Math.min(threshold + blend, 0), audioCTX.currentTime, 4e-3);
|
|
29
|
+
process.ratio.setTargetAtTime(ratio, audioCTX.currentTime, 4e-3);
|
|
30
|
+
process.release.setTargetAtTime(release / 1e3, audioCTX.currentTime, 4e-3);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const connect = getConnector((node) => {
|
|
34
|
+
node.connect(output);
|
|
35
|
+
return () => node.disconnect(output);
|
|
36
|
+
});
|
|
37
|
+
onMount(() => {
|
|
38
|
+
const audioCTX2 = audioContext();
|
|
39
|
+
output = audioCTX2.createGain();
|
|
40
|
+
input = audioCTX2.createGain();
|
|
41
|
+
process = audioCTX2.createDynamicsCompressor();
|
|
42
|
+
return connect(output);
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<slot />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
preGain?: number | undefined;
|
|
5
|
+
postGain?: number | undefined;
|
|
6
|
+
attack?: number | undefined;
|
|
7
|
+
threshold?: number | undefined;
|
|
8
|
+
blend?: number | undefined;
|
|
9
|
+
ratio?: number | undefined;
|
|
10
|
+
release?: number | undefined;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
default: {};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type AudioCompressorProps = typeof __propDef.props;
|
|
20
|
+
export type AudioCompressorEvents = typeof __propDef.events;
|
|
21
|
+
export type AudioCompressorSlots = typeof __propDef.slots;
|
|
22
|
+
export default class AudioCompressor extends SvelteComponent<AudioCompressorProps, AudioCompressorEvents, AudioCompressorSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import { getAudioContext, getConnector } from "./context.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
const audioContext = getAudioContext();
|
|
4
|
+
export let gain = 1;
|
|
5
|
+
let output;
|
|
6
|
+
$: {
|
|
7
|
+
if (output) {
|
|
8
|
+
output.gain.setTargetAtTime(gain, output.context.currentTime, 4e-3);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const connect = getConnector((node) => {
|
|
12
|
+
node.connect(output);
|
|
13
|
+
return () => node.disconnect(output);
|
|
14
|
+
});
|
|
15
|
+
onMount(() => {
|
|
16
|
+
const audioCTX = audioContext();
|
|
17
|
+
output = audioCTX.createGain();
|
|
18
|
+
return connect(output);
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<slot />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
gain?: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type AudioGainProps = typeof __propDef.props;
|
|
14
|
+
export type AudioGainEvents = typeof __propDef.events;
|
|
15
|
+
export type AudioGainSlots = typeof __propDef.slots;
|
|
16
|
+
export default class AudioGain extends SvelteComponent<AudioGainProps, AudioGainEvents, AudioGainSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script>export let position = [0, 0, 0];
|
|
2
|
+
export let orientation = [0, 0, 0];
|
|
3
|
+
$:
|
|
4
|
+
positionX = position[0];
|
|
5
|
+
$:
|
|
6
|
+
positionY = position[1];
|
|
7
|
+
$:
|
|
8
|
+
positionZ = position[2];
|
|
9
|
+
$:
|
|
10
|
+
roll = orientation[0];
|
|
11
|
+
$:
|
|
12
|
+
pitch = orientation[1];
|
|
13
|
+
$:
|
|
14
|
+
yaw = orientation[2];
|
|
15
|
+
const dot = ([i, j, k], [x, y, z]) => {
|
|
16
|
+
return i * x + j * y + k * z;
|
|
17
|
+
};
|
|
18
|
+
const cross = ([i, j, k], [x, y, z]) => {
|
|
19
|
+
return [
|
|
20
|
+
j * z - k * y,
|
|
21
|
+
(i * z - k * x) * -1,
|
|
22
|
+
i * y - j * x
|
|
23
|
+
];
|
|
24
|
+
};
|
|
25
|
+
const buildQuaternion = (roll2, pitch2, yaw2) => {
|
|
26
|
+
const rdRoll = roll2 / 360 * Math.PI;
|
|
27
|
+
const rdPitch = pitch2 / 360 * Math.PI;
|
|
28
|
+
const rdYaw = yaw2 / 360 * Math.PI;
|
|
29
|
+
const x = Math.sin(rdRoll) * Math.cos(rdPitch) * Math.cos(rdYaw) - Math.cos(rdRoll) * Math.sin(rdPitch) * Math.sin(rdYaw);
|
|
30
|
+
const y = Math.cos(rdRoll) * Math.sin(rdPitch) * Math.cos(rdYaw) + Math.sin(rdRoll) * Math.cos(rdPitch) * Math.sin(rdYaw);
|
|
31
|
+
const z = Math.cos(rdRoll) * Math.cos(rdPitch) * Math.sin(rdYaw) - Math.sin(rdRoll) * Math.sin(rdPitch) * Math.cos(rdYaw);
|
|
32
|
+
const w = Math.cos(rdRoll) * Math.cos(rdPitch) * Math.cos(rdYaw) + Math.sin(rdRoll) * Math.sin(rdPitch) * Math.sin(rdYaw);
|
|
33
|
+
return [x, y, z, w];
|
|
34
|
+
};
|
|
35
|
+
const rotatedVector = ([i, j, k], [x, y, z, w]) => {
|
|
36
|
+
const dotUVTimesTwo = dot([x, y, z], [i, j, k]) * 2;
|
|
37
|
+
const WxWMinusDotUU = w * w - dot([x, y, z], [x, y, z]);
|
|
38
|
+
const crossUV = cross([x, y, z], [i, j, k]);
|
|
39
|
+
return [
|
|
40
|
+
dotUVTimesTwo * x + WxWMinusDotUU * i + 2 * w * crossUV[0],
|
|
41
|
+
dotUVTimesTwo * y + WxWMinusDotUU * j + 2 * w * crossUV[1],
|
|
42
|
+
dotUVTimesTwo * z + WxWMinusDotUU * k + 2 * w * crossUV[2]
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
$:
|
|
46
|
+
quaterion = buildQuaternion(roll, pitch, yaw);
|
|
47
|
+
$:
|
|
48
|
+
forward = rotatedVector([1, 0, 0], quaterion);
|
|
49
|
+
$:
|
|
50
|
+
up = rotatedVector([0, 1, 0], quaterion);
|
|
51
|
+
import { getAudioContext } from "./context.js";
|
|
52
|
+
import { onMount } from "svelte";
|
|
53
|
+
const audioContext = getAudioContext();
|
|
54
|
+
let audioCTX = null;
|
|
55
|
+
$: {
|
|
56
|
+
if (audioCTX)
|
|
57
|
+
audioCTX.listener.positionX.value = positionX;
|
|
58
|
+
}
|
|
59
|
+
$: {
|
|
60
|
+
if (audioCTX)
|
|
61
|
+
audioCTX.listener.positionY.value = positionY;
|
|
62
|
+
}
|
|
63
|
+
$: {
|
|
64
|
+
if (audioCTX)
|
|
65
|
+
audioCTX.listener.positionZ.value = positionZ;
|
|
66
|
+
}
|
|
67
|
+
$: {
|
|
68
|
+
if (audioCTX)
|
|
69
|
+
audioCTX.listener.forwardX.value = forward[0];
|
|
70
|
+
}
|
|
71
|
+
$: {
|
|
72
|
+
if (audioCTX)
|
|
73
|
+
audioCTX.listener.forwardY.value = forward[1];
|
|
74
|
+
}
|
|
75
|
+
$: {
|
|
76
|
+
if (audioCTX)
|
|
77
|
+
audioCTX.listener.forwardZ.value = forward[2];
|
|
78
|
+
}
|
|
79
|
+
$: {
|
|
80
|
+
if (audioCTX)
|
|
81
|
+
audioCTX.listener.upX.value = up[0];
|
|
82
|
+
}
|
|
83
|
+
$: {
|
|
84
|
+
if (audioCTX)
|
|
85
|
+
audioCTX.listener.upY.value = up[1];
|
|
86
|
+
}
|
|
87
|
+
$: {
|
|
88
|
+
if (audioCTX)
|
|
89
|
+
audioCTX.listener.upZ.value = up[2];
|
|
90
|
+
}
|
|
91
|
+
onMount(() => {
|
|
92
|
+
audioCTX = audioContext();
|
|
93
|
+
});
|
|
94
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
position?: [number, number, number] | undefined;
|
|
5
|
+
orientation?: [number, number, number] | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type AudioListenerPositionProps = typeof __propDef.props;
|
|
13
|
+
export type AudioListenerPositionEvents = typeof __propDef.events;
|
|
14
|
+
export type AudioListenerPositionSlots = typeof __propDef.slots;
|
|
15
|
+
export default class AudioListenerPosition extends SvelteComponent<AudioListenerPositionProps, AudioListenerPositionEvents, AudioListenerPositionSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>import { getAudioContext, getConnector } from "./context.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
const audioContext = getAudioContext();
|
|
4
|
+
export let pan = 0;
|
|
5
|
+
let output;
|
|
6
|
+
$: {
|
|
7
|
+
if (output) {
|
|
8
|
+
output.pan.value = pan;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const connect = getConnector((node) => {
|
|
12
|
+
node.connect(output);
|
|
13
|
+
return () => node.disconnect(output);
|
|
14
|
+
});
|
|
15
|
+
onMount(() => {
|
|
16
|
+
const audioCtx = audioContext();
|
|
17
|
+
output = audioCtx.createStereoPanner();
|
|
18
|
+
return connect(output);
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<slot />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
pan?: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type AudioPannerProps = typeof __propDef.props;
|
|
14
|
+
export type AudioPannerEvents = typeof __propDef.events;
|
|
15
|
+
export type AudioPannerSlots = typeof __propDef.slots;
|
|
16
|
+
export default class AudioPanner extends SvelteComponent<AudioPannerProps, AudioPannerEvents, AudioPannerSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>import { getAudioContext, getConnector } from "./context.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
const audioContext = getAudioContext();
|
|
4
|
+
export let volume = 1;
|
|
5
|
+
export let audioBuffer;
|
|
6
|
+
let output;
|
|
7
|
+
let audioCTX;
|
|
8
|
+
$: {
|
|
9
|
+
if (output) {
|
|
10
|
+
output.gain.setTargetAtTime(volume, output.context.currentTime, 4e-3);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const playing = /* @__PURE__ */ new Set();
|
|
14
|
+
export const play = () => {
|
|
15
|
+
if (!audioBuffer)
|
|
16
|
+
return;
|
|
17
|
+
const source = audioCTX.createBufferSource();
|
|
18
|
+
source.buffer = audioBuffer;
|
|
19
|
+
source.addEventListener("ended", () => {
|
|
20
|
+
source.disconnect(output);
|
|
21
|
+
playing.delete(source);
|
|
22
|
+
});
|
|
23
|
+
source.connect(output);
|
|
24
|
+
playing.add(source);
|
|
25
|
+
source.start();
|
|
26
|
+
return () => {
|
|
27
|
+
if (playing.has(source)) {
|
|
28
|
+
source.stop();
|
|
29
|
+
source.disconnect(output);
|
|
30
|
+
playing.delete(source);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const connect = getConnector();
|
|
35
|
+
onMount(() => {
|
|
36
|
+
audioCTX = audioContext();
|
|
37
|
+
output = audioCtx.createGain();
|
|
38
|
+
const disconnect = connect(output);
|
|
39
|
+
return () => {
|
|
40
|
+
for (let node of playing) {
|
|
41
|
+
node.stop();
|
|
42
|
+
node.disconnect(output);
|
|
43
|
+
}
|
|
44
|
+
disconnect();
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
volume?: number | undefined;
|
|
5
|
+
audioBuffer: AudioBuffer;
|
|
6
|
+
play?: (() => (() => void) | undefined) | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type BufferedAudioSourceProps = typeof __propDef.props;
|
|
14
|
+
export type BufferedAudioSourceEvents = typeof __propDef.events;
|
|
15
|
+
export type BufferedAudioSourceSlots = typeof __propDef.slots;
|
|
16
|
+
export default class BufferedAudioSource extends SvelteComponent<BufferedAudioSourceProps, BufferedAudioSourceEvents, BufferedAudioSourceSlots> {
|
|
17
|
+
get play(): any;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script>import { getAudioContext, getConnector } from "./context.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
const audioContext = getAudioContext();
|
|
4
|
+
export let url;
|
|
5
|
+
export let volume = 1;
|
|
6
|
+
export let paused = true;
|
|
7
|
+
export let playbackPosition;
|
|
8
|
+
export let loop = false;
|
|
9
|
+
export const playFromStart = () => {
|
|
10
|
+
playbackPosition = 0;
|
|
11
|
+
paused = false;
|
|
12
|
+
};
|
|
13
|
+
export const play = () => {
|
|
14
|
+
paused = false;
|
|
15
|
+
};
|
|
16
|
+
export const pause = () => {
|
|
17
|
+
paused = true;
|
|
18
|
+
};
|
|
19
|
+
let output;
|
|
20
|
+
let sourceNode;
|
|
21
|
+
let element;
|
|
22
|
+
$: {
|
|
23
|
+
if (output) {
|
|
24
|
+
output.gain.setTargetAtTime(volume, output.context.currentTime, 4e-3);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const connect = getConnector();
|
|
28
|
+
onMount(() => {
|
|
29
|
+
const audioCTX = audioContext();
|
|
30
|
+
sourceNode = audioCTX.createMediaElementSource(element);
|
|
31
|
+
output = audioCTX.createGain();
|
|
32
|
+
sourceNode.connect(output);
|
|
33
|
+
return connect(output);
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<audio src={url} hidden loop={loop} bind:paused={paused} bind:currentTime={playbackPosition} bind:this={element} />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
url: string;
|
|
5
|
+
volume?: number | undefined;
|
|
6
|
+
paused?: boolean | undefined;
|
|
7
|
+
playbackPosition: number;
|
|
8
|
+
loop?: boolean | undefined;
|
|
9
|
+
playFromStart?: (() => void) | undefined;
|
|
10
|
+
play?: (() => void) | undefined;
|
|
11
|
+
pause?: (() => void) | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export type MediaAudioSourceProps = typeof __propDef.props;
|
|
19
|
+
export type MediaAudioSourceEvents = typeof __propDef.events;
|
|
20
|
+
export type MediaAudioSourceSlots = typeof __propDef.slots;
|
|
21
|
+
export default class MediaAudioSource extends SvelteComponent<MediaAudioSourceProps, MediaAudioSourceEvents, MediaAudioSourceSlots> {
|
|
22
|
+
get playFromStart(): any;
|
|
23
|
+
get play(): any;
|
|
24
|
+
get pause(): any;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type DisconnectFunction = () => any;
|
|
2
|
+
export type AudioSvelteContext = {
|
|
3
|
+
connect: (node: AudioNode) => DisconnectFunction;
|
|
4
|
+
};
|
|
5
|
+
export declare const getSetupAudio: (connect: (node: AudioNode) => DisconnectFunction) => void;
|
|
6
|
+
export declare const getAudioContext: () => () => AudioContext;
|
|
7
|
+
export declare const getConnector: (connect?: ((node: AudioNode) => DisconnectFunction) | undefined) => (node: AudioNode) => DisconnectFunction;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { getGame } from "../core-contexts.js";
|
|
3
|
+
const CONNECTOR = Symbol();
|
|
4
|
+
export const getSetupAudio = function (connect) {
|
|
5
|
+
if (getContext(CONNECTOR)) {
|
|
6
|
+
throw new Error("HELP ME I AM ALREADY INSIDE AN AUDIO CONTEXT");
|
|
7
|
+
}
|
|
8
|
+
setContext(CONNECTOR, {
|
|
9
|
+
connect
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export const getAudioContext = () => {
|
|
13
|
+
return getGame().getAudioContext;
|
|
14
|
+
};
|
|
15
|
+
export const getConnector = (connect) => {
|
|
16
|
+
const ctx = getContext(CONNECTOR);
|
|
17
|
+
if (connect) {
|
|
18
|
+
setContext(CONNECTOR, { connect });
|
|
19
|
+
}
|
|
20
|
+
return ctx.connect;
|
|
21
|
+
};
|
package/dist/core-contexts.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type GameContext = {
|
|
|
32
32
|
time: number;
|
|
33
33
|
}) => any | void) => () => any;
|
|
34
34
|
getLayerByName: (name: string) => LayerContext | null;
|
|
35
|
+
defaultTextFontFace: Writable<string | null>;
|
|
36
|
+
getAudioContext: () => AudioContext;
|
|
35
37
|
};
|
|
36
38
|
export declare const setupGame: (context: GameContext) => void;
|
|
37
39
|
export declare const getGame: () => GameContext;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>import { setupDrawable } from "../drawable.js";
|
|
2
2
|
import { onMount } from "svelte";
|
|
3
|
+
import { getGame } from "../core-contexts.js";
|
|
4
|
+
import { effectiveScene } from "../extras/scenes.js";
|
|
3
5
|
export let text;
|
|
4
6
|
export let size;
|
|
5
7
|
export let spacing = 1.4;
|
|
@@ -10,8 +12,11 @@ export let stroke = void 0;
|
|
|
10
12
|
export let strokeWidth = null;
|
|
11
13
|
export let alignH = "left";
|
|
12
14
|
export let alignV = "top";
|
|
15
|
+
const { defaultTextFontFace } = getGame();
|
|
13
16
|
$:
|
|
14
|
-
|
|
17
|
+
effectiveFont = font ? font : typeof $defaultTextFontFace === "string" ? $defaultTextFontFace : "sans-serif";
|
|
18
|
+
$:
|
|
19
|
+
computedFont = (style ? style + " " : "") + size + "px " + effectiveFont;
|
|
15
20
|
$:
|
|
16
21
|
splits = text?.split("\n") || [];
|
|
17
22
|
$:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script>import { setupDrawable } from "../drawable.js";
|
|
2
|
+
import { getGame } from "..";
|
|
2
3
|
import { onMount } from "svelte";
|
|
3
4
|
export let text;
|
|
4
5
|
export let size;
|
|
@@ -9,8 +10,11 @@ export let stroke = void 0;
|
|
|
9
10
|
export let strokeWidth = null;
|
|
10
11
|
export let alignH = "left";
|
|
11
12
|
export let alignV = "top";
|
|
13
|
+
const { defaultTextFontFace } = getGame();
|
|
12
14
|
$:
|
|
13
|
-
|
|
15
|
+
effectiveFont = font ? font : typeof $defaultTextFontFace === "string" ? $defaultTextFontFace : "sans-serif";
|
|
16
|
+
$:
|
|
17
|
+
computedFont = (style ? style + " " : "") + size + "px " + effectiveFont;
|
|
14
18
|
const draw = function({ ctx }, { x, y, w, h }) {
|
|
15
19
|
if (!text)
|
|
16
20
|
return;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>import { getGame } from "..";
|
|
2
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
3
|
+
const { defaultTextFontFace } = getGame();
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
|
+
export let font;
|
|
6
|
+
export let url;
|
|
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
|
+
});
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
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 | 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> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/dist/extras/Empty.svelte
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/** @typedef {typeof __propDef.events} EmptyEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} EmptySlots */
|
|
4
|
-
export default class Empty {
|
|
5
|
-
}
|
|
6
|
-
export type EmptyProps = typeof __propDef.props;
|
|
7
|
-
export type EmptyEvents = typeof __propDef.events;
|
|
8
|
-
export type EmptySlots = typeof __propDef.slots;
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
9
2
|
declare const __propDef: {
|
|
10
|
-
props:
|
|
11
|
-
[x: string]: never;
|
|
12
|
-
};
|
|
3
|
+
props: Record<string, never>;
|
|
13
4
|
events: {
|
|
14
5
|
[evt: string]: CustomEvent<any>;
|
|
15
6
|
};
|
|
@@ -17,4 +8,9 @@ declare const __propDef: {
|
|
|
17
8
|
default: {};
|
|
18
9
|
};
|
|
19
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> {
|
|
15
|
+
}
|
|
20
16
|
export {};
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
/** @typedef {typeof __propDef.events} SensibleDefaultStylesEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} SensibleDefaultStylesSlots */
|
|
4
|
-
export default class SensibleDefaultStyles {
|
|
5
|
-
}
|
|
6
|
-
export type SensibleDefaultStylesProps = typeof __propDef.props;
|
|
7
|
-
export type SensibleDefaultStylesEvents = typeof __propDef.events;
|
|
8
|
-
export type SensibleDefaultStylesSlots = typeof __propDef.slots;
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
9
2
|
declare const __propDef: {
|
|
10
|
-
props:
|
|
11
|
-
[x: string]: never;
|
|
12
|
-
};
|
|
3
|
+
props: Record<string, never>;
|
|
13
4
|
events: {
|
|
14
5
|
[evt: string]: CustomEvent<any>;
|
|
15
6
|
};
|
|
@@ -17,4 +8,9 @@ declare const __propDef: {
|
|
|
17
8
|
default: {};
|
|
18
9
|
};
|
|
19
10
|
};
|
|
11
|
+
export type SensibleDefaultStylesProps = typeof __propDef.props;
|
|
12
|
+
export type SensibleDefaultStylesEvents = typeof __propDef.events;
|
|
13
|
+
export type SensibleDefaultStylesSlots = typeof __propDef.slots;
|
|
14
|
+
export default class SensibleDefaultStyles extends SvelteComponent<SensibleDefaultStylesProps, SensibleDefaultStylesEvents, SensibleDefaultStylesSlots> {
|
|
15
|
+
}
|
|
20
16
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,17 +2,20 @@ export { default as Game } from "./Game.svelte";
|
|
|
2
2
|
export { default as Layer } from "./Layer.svelte";
|
|
3
3
|
export { default as GameObject } from "./GameObject.svelte";
|
|
4
4
|
export { getGame, getLayer, getTriggerLayerRender } from "./core-contexts.js";
|
|
5
|
-
export type { GameContext, LayerContext, LayerDrawable } from "./core-contexts.
|
|
5
|
+
export type { GameContext, LayerContext, LayerDrawable } from "./core-contexts.js";
|
|
6
6
|
export { default as MouseClickable } from "./controllers/MouseClickable.svelte";
|
|
7
7
|
export { default as MouseEventArea } from "./controllers/MouseEventArea.svelte";
|
|
8
8
|
export { MOUSE_ACTION } from "./controllers/mouse.js";
|
|
9
9
|
export { KEYBOARD_ACTION } from "./controllers/keyboard.js";
|
|
10
|
-
export { setupDrawable } from "./drawable.js";
|
|
11
|
-
export type { DrawableContext, DrawableObject, DrawFunction } from "./drawable.d.ts";
|
|
10
|
+
export { setupDrawable, type DrawableContext, type DrawFunction, type DrawableObject } from "./drawable.js";
|
|
12
11
|
export * as Drawables from "./drawables/index.js";
|
|
13
12
|
export { resolve as resolveImage } from "./resources/images.js";
|
|
14
|
-
export { useTileSet, getTile } from "./resources/tileset.js";
|
|
15
|
-
export
|
|
13
|
+
export { useTileSet, getTile, type TileSet } from "./resources/tileset.js";
|
|
14
|
+
export { resolveBuffer as resolveAudioBuffer } from "./resources/audio.js";
|
|
15
|
+
export { default as AssetPool } from "./resources/AssetPool.svelte";
|
|
16
|
+
export { default as AudioBufferedAsset } from "./resources/AudioBufferedAsset.svelte";
|
|
17
|
+
export { default as AudioMediaAsset } from "./resources/AudioMediaAsset.svelte";
|
|
18
|
+
export { default as ImageAsset } from "./resources/ImageAsset.svelte";
|
|
16
19
|
export { default as SensibleDefaultStyles } from "./extras/SensibleDefaultStyles.svelte";
|
|
17
20
|
export { default as Empty } from "./extras/Empty.svelte";
|
|
18
21
|
export { default as LayerPortal } from "./extras/LayerPortal.svelte";
|
|
@@ -21,3 +24,11 @@ export { default as SceneSwitcher } from "./extras/SceneSwitcher.svelte";
|
|
|
21
24
|
export { default as SceneTransition } from "./extras/SceneTransition.svelte";
|
|
22
25
|
export { default as Rotate } from "./extras/Rotate.svelte";
|
|
23
26
|
export { default as Tweened } from "./extras/Tweened.svelte";
|
|
27
|
+
export { default as DefaultFontFace } from "./extras/DefaultFontFace.svelte";
|
|
28
|
+
export { getAudioContext, getConnector as getAudioConnector } from "./audio/context.js";
|
|
29
|
+
export { default as AudioListenerPosition } from "./audio/AudioListenerPosition.svelte";
|
|
30
|
+
export { default as BufferedAudioSource } from "./audio/BufferedAudioSource.svelte";
|
|
31
|
+
export { default as MediaAudioSource } from "./audio/MediaAudioSource.svelte";
|
|
32
|
+
export { default as AudioGain } from "./audio/AudioGain.svelte";
|
|
33
|
+
export { default as AudioPanner } from "./audio/AudioPanner.svelte";
|
|
34
|
+
export { default as AudioCompressor } from "./audio/AudioCompressor.svelte";
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,11 @@ export * as Drawables from "./drawables/index.js";
|
|
|
14
14
|
// RESOURCES
|
|
15
15
|
export { resolve as resolveImage } from "./resources/images.js";
|
|
16
16
|
export { useTileSet, getTile } from "./resources/tileset.js";
|
|
17
|
+
export { resolveBuffer as resolveAudioBuffer } from "./resources/audio.js";
|
|
18
|
+
export { default as AssetPool } from "./resources/AssetPool.svelte";
|
|
19
|
+
export { default as AudioBufferedAsset } from "./resources/AudioBufferedAsset.svelte";
|
|
20
|
+
export { default as AudioMediaAsset } from "./resources/AudioMediaAsset.svelte";
|
|
21
|
+
export { default as ImageAsset } from "./resources/ImageAsset.svelte";
|
|
17
22
|
// EXTRAS
|
|
18
23
|
export { default as SensibleDefaultStyles } from "./extras/SensibleDefaultStyles.svelte";
|
|
19
24
|
export { default as Empty } from "./extras/Empty.svelte";
|
|
@@ -23,3 +28,12 @@ export { default as SceneSwitcher } from "./extras/SceneSwitcher.svelte";
|
|
|
23
28
|
export { default as SceneTransition } from "./extras/SceneTransition.svelte";
|
|
24
29
|
export { default as Rotate } from "./extras/Rotate.svelte";
|
|
25
30
|
export { default as Tweened } from "./extras/Tweened.svelte";
|
|
31
|
+
export { default as DefaultFontFace } from "./extras/DefaultFontFace.svelte";
|
|
32
|
+
// AUDIO
|
|
33
|
+
export { getAudioContext, getConnector as getAudioConnector } from "./audio/context.js";
|
|
34
|
+
export { default as AudioListenerPosition } from "./audio/AudioListenerPosition.svelte";
|
|
35
|
+
export { default as BufferedAudioSource } from "./audio/BufferedAudioSource.svelte";
|
|
36
|
+
export { default as MediaAudioSource } from "./audio/MediaAudioSource.svelte";
|
|
37
|
+
export { default as AudioGain } from "./audio/AudioGain.svelte";
|
|
38
|
+
export { default as AudioPanner } from "./audio/AudioPanner.svelte";
|
|
39
|
+
export { default as AudioCompressor } from "./audio/AudioCompressor.svelte";
|
|
@@ -0,0 +1,16 @@
|
|
|
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 AssetPoolProps = typeof __propDef.props;
|
|
12
|
+
export type AssetPoolEvents = typeof __propDef.events;
|
|
13
|
+
export type AssetPoolSlots = typeof __propDef.slots;
|
|
14
|
+
export default class AssetPool extends SvelteComponent<AssetPoolProps, AssetPoolEvents, AssetPoolSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
url: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type AudioBufferedAssetProps = typeof __propDef.props;
|
|
12
|
+
export type AudioBufferedAssetEvents = typeof __propDef.events;
|
|
13
|
+
export type AudioBufferedAssetSlots = typeof __propDef.slots;
|
|
14
|
+
export default class AudioBufferedAsset extends SvelteComponent<AudioBufferedAssetProps, AudioBufferedAssetEvents, AudioBufferedAssetSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
url: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type AudioMediaAssetProps = typeof __propDef.props;
|
|
12
|
+
export type AudioMediaAssetEvents = typeof __propDef.events;
|
|
13
|
+
export type AudioMediaAssetSlots = typeof __propDef.slots;
|
|
14
|
+
export default class AudioMediaAsset extends SvelteComponent<AudioMediaAssetProps, AudioMediaAssetEvents, AudioMediaAssetSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script>import { pushAsset } from "./images.js";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let url;
|
|
4
|
+
let element;
|
|
5
|
+
onMount(() => {
|
|
6
|
+
if (!element)
|
|
7
|
+
return;
|
|
8
|
+
pushAsset(url, element);
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<img src={url} alt="A Game Asset" bind:this={element} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
url: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type ImageAssetProps = typeof __propDef.props;
|
|
12
|
+
export type ImageAssetEvents = typeof __propDef.events;
|
|
13
|
+
export type ImageAssetSlots = typeof __propDef.slots;
|
|
14
|
+
export default class ImageAsset extends SvelteComponent<ImageAssetProps, ImageAssetEvents, ImageAssetSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const encodedBinaryBuffers = new Map();
|
|
2
|
+
const decodedBuffers = new Map();
|
|
3
|
+
let instantDecode = null;
|
|
4
|
+
export const pushBufferAsset = (url) => {
|
|
5
|
+
fetch(url).then(response => {
|
|
6
|
+
return response.arrayBuffer();
|
|
7
|
+
}).then(buffer => {
|
|
8
|
+
encodedBinaryBuffers.set(url, buffer);
|
|
9
|
+
if (instantDecode) {
|
|
10
|
+
instantDecode.decodeAudioData(buffer).then(audio => {
|
|
11
|
+
decodedBuffers.set(url, audio);
|
|
12
|
+
});
|
|
13
|
+
} // otherwise there's no audioContext
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const decodeAllBuffers = (context) => {
|
|
17
|
+
instantDecode = context;
|
|
18
|
+
for (let [url, binary] of encodedBinaryBuffers.entries()) {
|
|
19
|
+
instantDecode.decodeAudioData(binary).then(audio => {
|
|
20
|
+
decodedBuffers.set(url, audio);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const resolveBuffer = async (url) => {
|
|
25
|
+
if (decodedBuffers.has(url))
|
|
26
|
+
return decodedBuffers.get(url);
|
|
27
|
+
if (encodedBinaryBuffers.has(url)) {
|
|
28
|
+
if (instantDecode) {
|
|
29
|
+
const audio = await instantDecode.decodeAudioData(encodedBinaryBuffers.get(url));
|
|
30
|
+
decodedBuffers.set(url, audio);
|
|
31
|
+
return audio;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const pushAsset: (url: string, element: HTMLImageElement) => void;
|
|
2
|
+
export declare const resolve: (url: string) => HTMLImageElement | undefined;
|
package/dist/resources/images.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const assets = new Map();
|
|
2
|
+
export const pushAsset = (url, element) => {
|
|
3
|
+
assets.set(url, element);
|
|
4
|
+
};
|
|
5
|
+
export const resolve = (url) => {
|
|
6
|
+
if (assets.has(url)) {
|
|
7
|
+
return assets.get(url);
|
|
8
|
+
}
|
|
9
|
+
const img = document.createElement("img");
|
|
10
|
+
img.src = url;
|
|
11
|
+
assets.set(url, img);
|
|
8
12
|
return img;
|
|
9
13
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hi-ashleyj/llama",
|
|
3
3
|
"description": "A (Very Incomplete) 2D Canvas Game Engine powered by Svelte",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite dev",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/hi-ashleyj/llama-game-engine#readme",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@sveltejs/adapter-static": "
|
|
26
|
-
"@sveltejs/kit": "
|
|
27
|
-
"@sveltejs/package": "
|
|
25
|
+
"@sveltejs/adapter-static": "^2.0.3",
|
|
26
|
+
"@sveltejs/kit": "^1.25.0",
|
|
27
|
+
"@sveltejs/package": "^2.2.2",
|
|
28
28
|
"sass": "^1.58.0",
|
|
29
29
|
"svelte": "^3.44.0",
|
|
30
30
|
"svelte-check": "^3.4.6",
|