@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) • 856 B
JavaScript
import { inject, provide } from "vue";
//#region src/lib/vue/motiongpu-context.ts
/**
* Vue injection key used to expose `FragCanvas` runtime state.
*/
var motionGPUContextKey = Symbol("motiongpu.context");
/**
* Registers the motiongpu context in the current Vue component tree.
*
* @param context - Context payload to provide.
*/
function provideMotionGPUContext(context) {
provide(motionGPUContextKey, context);
}
/**
* Returns the active motiongpu context.
*
* @returns Active context.
* @throws {Error} When called outside `<FragCanvas>`.
*/
function useMotionGPU() {
const context = inject(motionGPUContextKey, null);
if (!context) throw new Error("useMotionGPU must be used inside <FragCanvas>");
return context;
}
//#endregion
export { motionGPUContextKey, provideMotionGPUContext, useMotionGPU };
//# sourceMappingURL=motiongpu-context.js.map