UNPKG

@tensorify.io/sdk

Version:

TypeScript SDK for developing Tensorify plugins with V2-Alpha definition/execution pattern and legacy compatibility

38 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BasePlugin = void 0; /** * Base class for V2-Alpha plugins * * All plugins must extend this class and implement the required methods. * This follows the definition/execution pattern for clean code generation. */ class BasePlugin { /** * Generate class definitions, functions, and other declarations * that need to be defined before execution. * * @param ctx - The code generation context * @param registry - The node registry for accessing other nodes * @returns Code, imports, and requirements for definitions */ async generateDefinition(ctx, registry) { // Default implementation returns empty return { code: "" }; } /** * Helper to get input variable names from connected nodes */ getInputVar(ctx, inputId) { return ctx.getGlobalInputVarName(inputId) || inputId; } /** * Helper to generate a unique variable name for this node */ getNodeVar(ctx, suffix = "") { const base = this.manifest.id.split("/").pop()?.replace(/-/g, "_") || "node"; return suffix ? `${base}_${ctx.nodeId}_${suffix}` : `${base}_${ctx.nodeId}`; } } exports.BasePlugin = BasePlugin; //# sourceMappingURL=base-plugin.js.map