MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / loadNativeModifiersHelper

Function loadNativeModifiersHelper

packages/pi-tui/src/native-modifiers.ts:21–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21function loadNativeModifiersHelper(): NativeModifiersHelper | undefined {
22 if (nativeModifiersHelper !== undefined) return nativeModifiersHelper ?? undefined;
23 nativeModifiersHelper = null;
24 if (process.platform !== "darwin") return undefined;
25 const arch = process.arch;
26 if (arch !== "x64" && arch !== "arm64") return undefined;
27
28 const moduleDir = path.dirname(fileURLToPath(import.meta.url));
29 const nativePath = path.join("native", "darwin", "prebuilds", `darwin-${arch}`, "darwin-modifiers.node");
30 const candidates = [
31 path.join(moduleDir, "..", nativePath),
32 path.join(moduleDir, nativePath),
33 path.join(path.dirname(process.execPath), nativePath),
34 ];
35
36 for (const modulePath of candidates) {
37 try {
38 const helper = cjsRequire(modulePath) as unknown;
39 if (isNativeModifiersHelper(helper)) {
40 nativeModifiersHelper = helper;
41 return helper;
42 }
43 } catch {
44 // Try the next possible packaging location.
45 }
46 }
47
48 return undefined;
49}
50
51export function isNativeModifierPressed(key: ModifierKey): boolean {
52 const helper = loadNativeModifiersHelper();

Callers 1

isNativeModifierPressedFunction · 0.85

Calls 1

isNativeModifiersHelperFunction · 0.85

Tested by

no test coverage detected