An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
import {readFileSync} from "node:fs";
import {join} from "node:path";
import {runInNewContext} from "node:vm";
import {it} from "node:test";
import * as assert from "node:assert/strict";
import * as ts from "typescript";
import {DATABASE_ROW_COMMANDS} from "../../command/databaseRowNavigation";
it("does not consume the desktop tab menu binding on mobile", () => {
const calls: string[] = [];
const exports: any = {};
const source = ts.transpileModule(readFileSync(join(__dirname, "keydown.ts"), "utf8"), {
compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020},
}).outputText;
const dependencies: Record<string, object> = {
"../../boot/globalEvent/commonHotkey": {filterHotkey: () => false},
"../../protyle/util/hotKey": {matchHotKey: () => true},
"../../command/executor": {execByCommand: () => calls.push("native")},
"../../command/databaseRowShortcut": {handleDatabaseRowShortcut: () => false},
"../../command/databaseRowNavigation": {DATABASE_ROW_COMMANDS},
"../editor": {getCurrentEditor: () => ({protyle: {toolbar: {}, element: {contains: () => false}}})},
"../../command/shortcutRuntime": {dispatchPluginShortcut: () => calls.push("plugin")},
};
runInNewContext(source, {
exports,
window: {siyuan: {config: {keymap: {general: {switchTab: {custom: "F8"}}}}}},
require: (name: string) => dependencies[name] || {},
});
exports.mobileKeydown({}, {key: "F8", preventDefault: () => calls.push("prevent")});
assert.deepEqual(calls, ["plugin"]);
});