UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

74 lines (73 loc) 2.48 kB
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */ var u = Object.defineProperty; var h = (t, e, s) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s; var g = (t, e, s) => h(t, typeof e != "symbol" ? e + "" : e, s); class d { constructor() { g(this, "plugins", /* @__PURE__ */ new Map()); } /** * Регистрирует новый плагин * @param plugin Плагин для регистрации * @throws Ошибка, если плагин с таким именем уже зарегистрирован */ register(e) { if (this.plugins.has(e.name)) throw new Error(`Plugin ${e.name} is already registered`); this.plugins.set(e.name, e); } /** * Удаляет плагин по его имени * @param pluginName Имя плагина для удаления */ unregister(e) { const s = this.plugins.get(e); s != null && s.destroy && s.destroy(), this.plugins.delete(e); } /** * Возвращает плагины */ getPlugins() { return this.plugins; } getHotkeys() { const e = {}, s = {}; return this.plugins.forEach((a, r) => { const o = r.charAt(0).toUpperCase() + r.slice(1) + " Plugin", c = a.hotkeys ?? []; for (const l in c) { const i = c[l], n = i.keys; s[n] ? console.warn( `Hotkey conflict: The key combination "${n}" is already used for the command "${s[n]}".` ) : s[n] = i.command, e[o] || (e[o] = []), e[o].push({ command: i.command, description: i.description, icon: i.icon, keys: i.keys }); } }), e; } /** * Возвращает плагин по его имени * @param pluginName Имя плагина * @returns Плагин или undefined, если плагин не найден */ getPlugin(e) { return this.plugins.get(e); } getVersion(e) { var s; return ((s = this.getPlugin(e)) == null ? void 0 : s.version) || "1.0.0"; } /** * Уничтожает все зарегистрированные плагины */ destroy() { for (const [e, s] of this.plugins) s.destroy && s.destroy(); this.plugins.clear(); } } export { d as DefaultPluginManager };