Compare commits
1 Commits
v0.0.3
..
b3a1419ed3
| Author | SHA1 | Date | |
|---|---|---|---|
| b3a1419ed3 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@svelte-toolkit/jitsi",
|
"name": "@svelte-toolkit/jitsi",
|
||||||
"version": "0.0.3",
|
"version": "0.0.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea.auvem.com/svelte-toolkit/jitsi.git"
|
"url": "https://gitea.auvem.com/svelte-toolkit/jitsi.git"
|
||||||
|
|||||||
+7
-55
@@ -1,19 +1,6 @@
|
|||||||
<!-- @component
|
|
||||||
The Jitsi component is a lightweight wrapper that manages loading the Jitsi Meet External API
|
|
||||||
and joining a Jitsi meeting room. It accepts configuration options and provides a callback
|
|
||||||
when the API is ready for use.
|
|
||||||
|
|
||||||
WARNING: Assume that ALL properties are NOT reactive. Due to the nature of the Jitsi Meet
|
|
||||||
External API, changing properties after initialization will NOT update the Jitsi instance.
|
|
||||||
Instead, use the getAPI() method to interact with the Jitsi instance directly.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, type Snippet } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import type {
|
import { type JitsiMeetExternalAPIOptions, JitsiMeetExternalAPI } from './jitsi-iframe-api.js';
|
||||||
JitsiMeetExternalAPIOptions,
|
|
||||||
JitsiMeetExternalAPI
|
|
||||||
} from '$lib/jitsi-iframe-api.d.ts';
|
|
||||||
import type { ClassValue } from 'svelte/elements';
|
import type { ClassValue } from 'svelte/elements';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -31,30 +18,13 @@ Instead, use the getAPI() method to interact with the Jitsi instance directly.
|
|||||||
* Additional CSS classes to apply to the Jitsi container.
|
* Additional CSS classes to apply to the Jitsi container.
|
||||||
*/
|
*/
|
||||||
class?: ClassValue;
|
class?: ClassValue;
|
||||||
/**
|
|
||||||
* Children are rendered inside the Jitsi container until the API is initialized.
|
|
||||||
*/
|
|
||||||
children?: Snippet;
|
|
||||||
/**
|
|
||||||
* Callback function that is called when the Jitsi API is loaded. Can
|
|
||||||
* be used to provide a loading indicator until the API is ready.
|
|
||||||
* @param api The Jitsi Meet External API instance.
|
|
||||||
*/
|
|
||||||
onready?: (api: JitsiMeetExternalAPI) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let { domain = 'https://meet.jit.si', options, class: classValue }: Props = $props();
|
||||||
domain = 'https://meet.jit.si',
|
|
||||||
options,
|
|
||||||
class: classValue,
|
|
||||||
children,
|
|
||||||
onready
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
const src = $derived(`${new URL('external_api.js', domain).toString()}`);
|
const src = $derived(`${new URL('external_api.js', domain).toString()}`);
|
||||||
|
|
||||||
let container: HTMLDivElement;
|
let container: HTMLDivElement;
|
||||||
let ready = $state(false);
|
|
||||||
let api = $state<JitsiMeetExternalAPI | null>(null);
|
let api = $state<JitsiMeetExternalAPI | null>(null);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -62,27 +32,13 @@ Instead, use the getAPI() method to interact with the Jitsi instance directly.
|
|||||||
if (document.querySelectorAll('#jitsi-container').length > 1) {
|
if (document.querySelectorAll('#jitsi-container').length > 1) {
|
||||||
console.warn('Duplicate Jitsi container detected. This may lead to unexpected behavior.');
|
console.warn('Duplicate Jitsi container detected. This may lead to unexpected behavior.');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
const onload = () => {
|
|
||||||
if (typeof window.JitsiMeetExternalAPI === 'undefined') {
|
|
||||||
console.error('Jitsi Meet External API is not available on the window object.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ready = true;
|
|
||||||
// Initialize the Jitsi Meet External API
|
// Initialize the Jitsi Meet External API
|
||||||
api = new window.JitsiMeetExternalAPI(new URL(domain).host, {
|
api = new JitsiMeetExternalAPI(new URL(domain).host, {
|
||||||
...options,
|
...options,
|
||||||
parentNode: container
|
parentNode: container
|
||||||
});
|
});
|
||||||
if (api === null) {
|
});
|
||||||
console.error('Failed to initialize Jitsi Meet External API.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Call the onready callback if provided
|
|
||||||
onready?.(api);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Jitsi Meet External API instance.
|
* Get the Jitsi Meet External API instance.
|
||||||
@@ -94,11 +50,7 @@ Instead, use the getAPI() method to interact with the Jitsi instance directly.
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<script {src} {onload}></script>
|
<script {src}></script>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div id="jitsi-container" bind:this={container} class={[classValue]}>
|
<div id="jitsi-container" bind:this={container} class={[classValue]}></div>
|
||||||
{#if !ready}
|
|
||||||
{@render children?.()}
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user