'use strict'; function protoGlobalPlugin(extensions) { const extensionScript = generateExtensionScript(extensions); return { name: "vite-plugin-proto-global", enforce: "pre", transform(code, id) { if (id.endsWith(".js")) { return { code: `${extensionScript} ${code}`, map: null }; } } }; } function generateExtensionScript(extensions) { return extensions.map((extension) => ` (function() { const classPrototype = ${extension.className}.prototype; ${Object.entries(extension.methods).map(([methodName, method]) => { const methodStr = method.toString().replace(/^function\s*/, "function "); return `classPrototype.${methodName} = ${methodStr};`; }).join("\n")} })(); `).join("\n"); } exports.protoGlobalPlugin = protoGlobalPlugin;