small plugin changes + make minesweeper and snake plugin

This commit is contained in:
KingKDot
2026-07-30 21:35:17 -05:00
parent 9700647279
commit 6c208da75f
13 changed files with 1299 additions and 2 deletions
@@ -1,5 +1,6 @@
export type PluginRpcCaller = {
id: number;
username: string;
role: string;
};
@@ -11,7 +11,7 @@ declare const self: {
type PluginExports = {
setup?: (ctx: PluginContext) => unknown | Promise<unknown>;
onEvent?: (ctx: PluginContext, clientId: string, event: string, payload: unknown) => unknown | Promise<unknown>;
rpc?: Record<string, (ctx: PluginContext, params: unknown, meta: { caller: { id: number; role: string } }) => unknown | Promise<unknown>>;
rpc?: Record<string, (ctx: PluginContext, params: unknown, meta: { caller: { id: number; username: string; role: string } }) => unknown | Promise<unknown>>;
buildHooks?: Record<string, (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>>;
onBuildPrepare?: (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>;
onBuildTarget?: (ctx: PluginContext, payload: unknown) => unknown | Promise<unknown>;
@@ -278,7 +278,7 @@ export async function handlePluginRoutes(
plugin.id,
"dashboardContributions",
{ clientIds: authorizedClientIds },
{ id: user.userId, role: user.role },
{ id: user.userId, username: user.username, role: user.role },
);
const rows = Array.isArray(result?.contributions) ? result.contributions : Array.isArray(result) ? result : [];
for (const row of rows) {
@@ -1293,6 +1293,7 @@ export async function handlePluginRoutes(
try {
const result = await deps.pluginRuntime.rpc(pluginId, method, body.params, {
id: user.userId,
username: user.username,
role: user.role,
});
metrics.recordCommand("plugin_rpc");