chore: initial commit

This commit is contained in:
2026-10-22 17:07:08 +08:00
commit 0acef64f48
200 changed files with 35546 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import assert from 'node:assert/strict';
import {readFile} from 'node:fs/promises';
import vm from 'node:vm';
import test from 'node:test';
import {transformSync} from 'esbuild';
const source = await readFile(new URL('../service/server/update/plugins.ts', import.meta.url), 'utf8');
const code = transformSync(source.replace(/^import .*;\n/gm, '')
.replace('export async function', 'async function'), {loader: 'ts'}).code;
test('late plugin scan never reports through a replacement authenticated session', async () => {
let finish_scan;
let current = true;
const reports = [];
const socket = {connected: true, timeout() { return this; }, async emitWithAck(...args) {
reports.push(args); return {status: 'success', data: 0};
}};
const context = {socket, is_current: () => current,
get_plugin_list: () => new Promise(resolve => { finish_scan = resolve; }),
console_print: {log() {}, success() {}}};
const task = vm.runInNewContext(`${code}\nupdate_plugins(socket, 1, is_current);`, context);
current = false;
finish_scan([]);
await task;
assert.equal(reports.length, 0);
});