{"id":27641421,"url":"https://github.com/samuelmaddock/electron-native-utils","last_synced_at":"2025-10-13T22:16:34.623Z","repository":{"id":267685301,"uuid":"902038746","full_name":"samuelmaddock/electron-native-utils","owner":"samuelmaddock","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-19T19:36:24.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-15T11:13:14.445Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelmaddock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-11T19:35:57.000Z","updated_at":"2024-12-12T18:51:06.000Z","dependencies_parsed_at":"2024-12-11T20:40:14.064Z","dependency_job_id":"d5e62312-cdb4-4d66-a800-ffc78acab1af","html_url":"https://github.com/samuelmaddock/electron-native-utils","commit_stats":null,"previous_names":["samuelmaddock/electron-native-utils"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/samuelmaddock/electron-native-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Felectron-native-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Felectron-native-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Felectron-native-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Felectron-native-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelmaddock","download_url":"https://codeload.github.com/samuelmaddock/electron-native-utils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Felectron-native-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017157,"owners_count":26085983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-23T23:47:30.660Z","updated_at":"2025-10-13T22:16:34.579Z","avatar_url":"https://github.com/samuelmaddock.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-native-utils\n\nAdditional native utilities for Electron.\n\n## Building\n\n### Requirements\n\n- Windows: Visual Studio 2022\n\n### Commands\n\n- `yarn build` - Incremental builds.\n- `yarn build:ci` - Clean and fully rebuild.\n- `yarn build:debug` - Debug builds for easier debugging.\n\n## Architecture\n\nelectron-native-utils uses [node-gyp](https://github.com/nodejs/node-gyp) to configure and build .node binaries.\n\nIt uses [Node-API](https://github.com/nodejs/node-addon-api) to provide JavaScript bindings to native code.\n- [Node addon docs](https://nodejs.org/docs/latest/api/addons.html)\n- [Node-API examples](https://github.com/nodejs/node-addon-examples)\n\n### Files\n- `src/` - contains C++ source and header files\n- `lib/index.js` - main entry point of the node module\n- `lib/index.d.ts` - TypeScript type definitions\n- `binding.gyp` - build config for node-gyp\n- `test.js` - simple test script to require and invoke the module's API to ensure no crashes occur\n\n### API Design\n\n- Group functionality by namespaces\n- Prefer promises over callbacks for async\n- Reject promises with an `Error` instead of a string\n- Exported bindings should be available on each platform (Windows, Mac, Linux)\n  - When a function returns a promise, it should reject on unsupported platforms. \\\n    Otherwise, it should throw an exception.\n\n### Writing cross-platform code\n\n- Source files can be compiled for specific patterns using a filename postfix.\n  - `_win` - Windows\n  - `_mac` - macOS\n  - `_linux` - Linux\n- Platform-specific macros can be used to export methods which throw on\n  unsupported platforms.\n  ```cpp\n  Napi::Object InitApi(Napi::Env env) {\n    Napi::Object exports = Napi::Object::New(env);\n    // Method throws on non-Windows platforms.\n    METHOD_WIN(winMethodName, WinMethod);\n\n    // Method throws on non-MacOS platforms.\n    METHOD_MAC(macMethodName, MacMethod);\n\n    // Async variants which reject returned promise on unsupported platforms.\n    METHOD_ASYNC_WIN(asyncMethod, AsyncMethod);\n    METHOD_ASYNC_MAC(asyncMethod, AsyncMethod);\n    return exports;\n  }\n  ```\n- Platform defines can be used to conditionally include code.\n  ```cpp\n  #ifdef _WIN32\n    // Windows code\n  #endif // _WIN32\n\n  // OR\n\n  #if defined(_WIN32)\n    // Windows code\n  #elif defined(__APPLE__)\n    // Mac code\n  #elif defined(__linux__)\n    // Linux code\n  #endif\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmaddock%2Felectron-native-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelmaddock%2Felectron-native-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmaddock%2Felectron-native-utils/lists"}