Three Blocks

Skinned fox / source

Open preview
runtime/mount.jsPlain text ↗
import { createGalleryAdapter } from './gallery-adapters.js';

/** Mount a gallery scene with its asset URLs, controls and optional test hooks. */
export async function mountGalleryExample( slug, example, container ) {

	const adapter = createGalleryAdapter( slug );
	try {

		await adapter.didMount( await example.mount( container, adapter.options ) );

	} catch ( error ) {

		await adapter.dispose();
		await example.unmount?.();
		throw error;

	}
	return async () => {

		if ( ! await adapter.dispose() ) await example.unmount?.();

	};

}