@kya-os/cli
Version:
CLI for MCP-I setup and management
114 lines • 4.03 kB
JavaScript
/**
* Effect Registry and Exports
* Uses lazy loading to reduce initial bundle size
*/
/**
* Registry of all available effects (lazy loaded)
*/
const lazyEffectRegistry = new Map();
/**
* Cache for loaded effect classes
*/
const effectClassCache = new Map();
/**
* Register a lazy-loaded effect
*/
function registerLazyEffect(entry) {
lazyEffectRegistry.set(entry.name.toLowerCase(), entry);
}
/**
* Get an effect by name (async with lazy loading)
*/
export async function getEffect(name) {
const entry = lazyEffectRegistry.get(name.toLowerCase());
if (!entry)
return null;
try {
// Check cache first
let EffectClass = effectClassCache.get(name.toLowerCase());
if (!EffectClass) {
// Load the effect class
EffectClass = await entry.loader();
effectClassCache.set(name.toLowerCase(), EffectClass);
}
return new EffectClass();
}
catch (error) {
console.error(`Failed to load effect '${name}':`, error);
return null;
}
}
/**
* Get an effect synchronously if already cached
* For backward compatibility with sync code
*/
export function getEffectSync(name) {
const EffectClass = effectClassCache.get(name.toLowerCase());
return EffectClass ? new EffectClass() : null;
}
/**
* Preload specific effects for performance
*/
export async function preloadEffects(...names) {
await Promise.all(names.map(name => getEffect(name)));
}
/**
* Get all available effects (returns basic info without loading)
*/
export function getAllEffects() {
return Array.from(lazyEffectRegistry.values()).map(entry => ({
name: entry.name,
description: entry.description,
factory: () => {
// This is a sync factory that throws if effect not loaded
const EffectClass = effectClassCache.get(entry.name.toLowerCase());
if (!EffectClass) {
throw new Error(`Effect '${entry.name}' not loaded. Use getEffect() instead.`);
}
return new EffectClass();
}
}));
}
// Register built-in effects with lazy loading
registerLazyEffect({
name: "burn",
description: "Characters are ignited and burn up the screen",
loader: async () => (await import("./implementations/burn.js")).BurnEffect,
});
registerLazyEffect({
name: "beams",
description: "Creates beams which travel over the canvas illuminating the characters",
loader: async () => (await import("./implementations/beams.js")).BeamsEffect,
});
// Binary Path effect removed - was causing issues and blocking demo
registerLazyEffect({
name: "decrypt",
description: "Movie-style text decryption effect with typing animation",
loader: async () => (await import("./implementations/decrypt.js")).DecryptEffect,
});
registerLazyEffect({
name: "blackhole",
description: "Characters are consumed by a black hole and explode outwards",
loader: async () => (await import("./implementations/blackhole.js")).BlackholeEffect,
});
registerLazyEffect({
name: "waves",
description: "Creates wave patterns that travel across the text",
loader: async () => (await import("./implementations/waves.js")).WavesEffect,
});
// Individual effect classes are now lazy-loaded
// Use getEffect() to access them
// Export types
export * from "./types.js";
export * from "./utils.js";
export * from "./config.js";
export * from "./safe-executor.js";
export * from "./effect-runner.js";
export * from "./cli-integration.js";
// Export gradient system (has createGradient which conflicts with utils)
export { Gradient, GradientDirection, GRADIENTS, EASING } from "./gradient.js";
// Export animation engine (has Scene which conflicts with types)
export { SyncMetric, AnimationEvent, CharacterAnimation, AnimatedCharacter, } from "./animation-engine.js";
// Export motion engine (has Path which conflicts with types)
export { MotionEvent, CharacterMotion } from "./motion-engine.js";
//# sourceMappingURL=index.js.map