Files
metabuilder/workflow/plugins/ts/math/src/factory.ts
johndoe6345789 7ce8b4ae8a refactor(workflow): convert all plugins to class/struct + factory pattern
- Python: class extending NodeExecutor + factory.py (80+ plugins)
- TypeScript: class implements NodeExecutor + factory.ts (7 groups, 116 classes)
- Go: struct with methods + factory.go (36 plugins)
- Rust: struct impl NodeExecutor trait + factory.rs (54 plugins)
- Mojo: struct + factory.mojo (11 plugins)

All package.json files now include:
- files array listing source files
- metadata.class/struct field
- metadata.entrypoint field

This enables a unified plugin loading system across all languages
with no import side effects (Spring-style DI pattern).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-22 14:53:04 +00:00

115 lines
2.2 KiB
TypeScript

/**
* Factory for math plugin classes.
*/
import {
MathAdd,
MathSubtract,
MathMultiply,
MathDivide,
MathModulo,
MathPower,
MathSqrt,
MathAbs,
MathRound,
MathFloor,
MathCeil,
MathMin,
MathMax,
MathSum,
MathAverage,
MathRandom,
MathClamp,
} from './index';
export function createMathAdd(): MathAdd {
return new MathAdd();
}
export function createMathSubtract(): MathSubtract {
return new MathSubtract();
}
export function createMathMultiply(): MathMultiply {
return new MathMultiply();
}
export function createMathDivide(): MathDivide {
return new MathDivide();
}
export function createMathModulo(): MathModulo {
return new MathModulo();
}
export function createMathPower(): MathPower {
return new MathPower();
}
export function createMathSqrt(): MathSqrt {
return new MathSqrt();
}
export function createMathAbs(): MathAbs {
return new MathAbs();
}
export function createMathRound(): MathRound {
return new MathRound();
}
export function createMathFloor(): MathFloor {
return new MathFloor();
}
export function createMathCeil(): MathCeil {
return new MathCeil();
}
export function createMathMin(): MathMin {
return new MathMin();
}
export function createMathMax(): MathMax {
return new MathMax();
}
export function createMathSum(): MathSum {
return new MathSum();
}
export function createMathAverage(): MathAverage {
return new MathAverage();
}
export function createMathRandom(): MathRandom {
return new MathRandom();
}
export function createMathClamp(): MathClamp {
return new MathClamp();
}
// Factory map for all math plugins
export const factories = {
'math.add': createMathAdd,
'math.subtract': createMathSubtract,
'math.multiply': createMathMultiply,
'math.divide': createMathDivide,
'math.modulo': createMathModulo,
'math.power': createMathPower,
'math.sqrt': createMathSqrt,
'math.abs': createMathAbs,
'math.round': createMathRound,
'math.floor': createMathFloor,
'math.ceil': createMathCeil,
'math.min': createMathMin,
'math.max': createMathMax,
'math.sum': createMathSum,
'math.average': createMathAverage,
'math.random': createMathRandom,
'math.clamp': createMathClamp,
};
export default factories;