@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
29 lines (28 loc) • 859 B
JavaScript
import { getContext, setContext } from "svelte";
//#region src/lib/svelte/motiongpu-context.ts
/**
* Svelte context key used to expose `FragCanvas` runtime state.
*/
var MOTIONGPU_CONTEXT_KEY = Symbol("motiongpu.context");
/**
* Registers the motiongpu context in the current Svelte component tree.
*
* @param context - Context payload to provide.
*/
function provideMotionGPUContext(context) {
setContext(MOTIONGPU_CONTEXT_KEY, context);
}
/**
* Returns the active motiongpu context.
*
* @returns Active context.
* @throws {Error} When called outside `<FragCanvas>`.
*/
function useMotionGPU() {
const context = getContext(MOTIONGPU_CONTEXT_KEY);
if (!context) throw new Error("useMotionGPU must be used inside <FragCanvas>");
return context;
}
//#endregion
export { provideMotionGPUContext, useMotionGPU };
//# sourceMappingURL=motiongpu-context.js.map