sounds, better files

This commit is contained in:
2024-08-18 19:11:41 +00:00
parent 9ed2f70701
commit 08489ed67b
86 changed files with 4226 additions and 86 deletions

58
src/summon.ts Normal file
View File

@@ -0,0 +1,58 @@
import { createApp } from 'vue';
import './style.css';
import { JsonChannelSymbol, WebRtcChannelSymbol } from './model/injectionSymbols';
import { PostMessageChannel } from './model/Remote/Channels/PostMessage';
import SummonApp from './modules/summon/SummonApp.vue';
import { immediate } from './helpers/immediate';
import { WebRtcChannelSummon } from './model/Remote/Channels/WebRTCChannel';
import { loadScript } from './helpers/loadScript';
import { ChromecastChannelSummon } from './model/Remote/Channels/ChromcastSummon';
import { WsSignalingSummon } from './model/Remote/Channels/WsSignaling';
const app = createApp(SummonApp)
const query = new URLSearchParams(location.search);
let name = query.get('name') ?? 'Unknown';
app.provide('name', name);
const channel = (() => {
if (query.get('channel') === 'postMessage') {
const channel = new PostMessageChannel(window)
channel.send({type: 'summoned', name});
return channel;
} else if (query.get('channel') === 'chromecast') {
const chromeCastChannel = new ChromecastChannelSummon();
const channel = new WsSignalingSummon();
chromeCastChannel.initialize();
chromeCastChannel.on(async (msg) => {
if (msg.type === 'hello') {
name = msg.name ?? 'Chromecast';
}
if (msg.type === 'RtcSignalingConnect') {
channel.disconnect();
await channel.connect(msg.uuid);
channel.send({type: 'summoned', name});
}
});
return channel;
}
})();
if (channel) {
const webRtcChannel = new WebRtcChannelSummon(channel);
app.provide(WebRtcChannelSymbol, webRtcChannel);
app.provide(JsonChannelSymbol, channel);
webRtcChannel.on((msg) => {
if (msg.type === 'connected') {
webRtcChannel.send({
type: 'resolution',
width: window.innerWidth * window.devicePixelRatio,
height: window.innerHeight * window.devicePixelRatio,
});
}
})
}
app.mount('#app')