UNPKG

@microcursor/node-axkit

Version:

Native macOS Accessibility API integration for Node.js

134 lines (130 loc) 5.44 kB
// Generated by tsup - Node-AXKit Native Module "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { awaitAccessibilityPermission: () => awaitAccessibilityPermission, checkAccessibilityPermission: () => checkAccessibilityPermission, default: () => index_default, focusWindow: () => focusWindow, listWindows: () => listWindows, requestAccessibilityPermission: () => requestAccessibilityPermission }); module.exports = __toCommonJS(index_exports); var fs = __toESM(require("fs")); var os = __toESM(require("os")); var path = __toESM(require("path")); function loadNativeModule() { const baseDir = path.join(__dirname, ".."); const platform2 = os.platform(); const arch2 = os.arch(); const isDebug = process.env.DEBUG === "1"; const modulePathOverride = process.env.NODE_AXKIT_MODULE_PATH; if (modulePathOverride) { const overridePath = path.resolve(baseDir, modulePathOverride); if (fs.existsSync(overridePath)) { console.log(`[node-axkit] Loading native module from override: ${overridePath}`); return require(overridePath); } else { console.warn(`[node-axkit] Override path does not exist: ${overridePath}`); } } const possiblePaths = [ // Primary location: bundled in dist (for published packages) path.join(baseDir, "dist", "Module.node"), // Development fallbacks: .build directory (for local development) ...isDebug ? [path.join(baseDir, ".build", "debug", "Module.node")] : [path.join(baseDir, ".build", "release", "Module.node")], // Standard NodeSwift build locations (development fallbacks) path.join(baseDir, ".build", "release", "Module.node"), path.join(baseDir, ".build", "debug", "Module.node"), // Legacy fallback locations path.join(baseDir, "build", "Release", "Module.node"), path.join(baseDir, "build", "Debug", "Module.node"), path.join(baseDir, "native", "Module.node"), path.join(baseDir, "lib", "Module.node") ]; for (const modulePath of possiblePaths) { try { if (fs.existsSync(modulePath)) { const module2 = require(modulePath); const relativePath = path.relative(process.cwd(), modulePath); console.log(`[node-axkit] Loading native module from: ${relativePath}`); return module2; } } catch (error) { console.warn( `[node-axkit] Failed to load ${modulePath}: ${error instanceof Error ? error.message : String(error)}` ); continue; } } const searchedPaths = possiblePaths.map((p) => ` - ${p}`).join("\n"); const envInfo = [ `Platform: ${platform2}`, `Architecture: ${arch2}`, `Node.js: ${process.version}`, `Environment: ${"production"}`, `Debug mode: ${isDebug ? "enabled" : "disabled"}` ].join("\n "); throw new Error( `[node-axkit] Native module not found. Searched paths: ${searchedPaths} Environment information: ${envInfo} Please ensure the native module is built by running: npm run build:debug (for debug build) npm run build (for release build) You can also set NODE_AXKIT_MODULE_PATH environment variable to specify a custom path.` ); } __name(loadNativeModule, "loadNativeModule"); var nativeModule = loadNativeModule(); var listWindows = nativeModule.listWindows; var focusWindow = nativeModule.focusWindow; var checkAccessibilityPermission = nativeModule.checkAccessibilityPermission; var requestAccessibilityPermission = nativeModule.requestAccessibilityPermission; var awaitAccessibilityPermission = nativeModule.awaitAccessibilityPermission; var index_default = { listWindows, focusWindow, checkAccessibilityPermission, requestAccessibilityPermission, awaitAccessibilityPermission }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { awaitAccessibilityPermission, checkAccessibilityPermission, focusWindow, listWindows, requestAccessibilityPermission }); //# sourceMappingURL=index.js.map