{"id":27243170,"url":"https://github.com/react-gjs/gjs-multiprocess","last_synced_at":"2026-02-05T23:32:14.187Z","repository":{"id":172801358,"uuid":"649007348","full_name":"react-gjs/gjs-multiprocess","owner":"react-gjs","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-10T17:26:29.000Z","size":35333,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T01:27:38.771Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/react-gjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-06-03T13:37:14.000Z","updated_at":"2024-12-10T17:26:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"766ef818-4423-449f-a62f-a45210b0feaa","html_url":"https://github.com/react-gjs/gjs-multiprocess","commit_stats":{"total_commits":18,"total_committers":2,"mean_commits":9.0,"dds":"0.38888888888888884","last_synced_commit":"0c02490ca0505a956c4f08a3579de2b6d23f5b1b"},"previous_names":["react-gjs/gjs-multiprocess"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/react-gjs/gjs-multiprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-gjs%2Fgjs-multiprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-gjs%2Fgjs-multiprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-gjs%2Fgjs-multiprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-gjs%2Fgjs-multiprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-gjs","download_url":"https://codeload.github.com/react-gjs/gjs-multiprocess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-gjs%2Fgjs-multiprocess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29138375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-10T20:27:19.556Z","updated_at":"2026-02-05T23:32:14.165Z","avatar_url":"https://github.com/react-gjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gjs-multiprocess\n\nA simple API for running child-processes and comunicating with them via DBus.\n\n## Usage\n\n```ts\n// worker.js\n\nexport function calculatePi(digits) {\n  // some calculations\n  return result;\n}\n```\n\n```ts\n// main.js\n\nconst server = await startServer(\"org.my.app\");\n\nconst client = await server.createClient(\"./worker.js\");\n// note: path to the worker must be relative to the current working directory or absolute\n\nconst pi = await client.invoke.calculatePi(1000);\n\nconsole.log(pi);\n\nclient.terminate();\nserver.close();\n```\n\n## Exposing methods to the client\n\nMain process can expose methods to the client by passing an object to the `createClient` function.\n\n```ts\n// main.js\n\nconst mainProcessApi = {\n  // Pass a log message to the Logger class in the main process\n  log: (message) =\u003e Logger.info(message),\n};\n\nconst client = await server.createClient(\"./worker.js\", mainProcessApi);\n```\n\n```ts\n// worker.js\n\nexport function doWork(message) {\n  try {\n    // ...\n  } catch (error) {\n    Subprocess.invoke.log(error.message);\n  }\n}\n```\n\n## TypeScript\n\nIf you are using TypeScript you will want to have the client and Subprocess fully typed. That cannot be done automatically, since it's impossible atm to infer type definitions from a filepath. But you can fairly easily provide those typings manually:\n\n### Worker Typings\n\n```ts\n// worker.ts\n\nexport function calculatePi(digits: number): string {\n  // some calculations\n  return result;\n}\n\nexport function reverse(str: string): string {\n  return str.split(\"\").reverse().join(\"\");\n}\n```\n\n```ts\nimport type * as Worker from \"./worker\";\n\nconst server = await startServer(\"org.my.app\");\n\nconst client = await server.createClient\u003ctypeof Worker\u003e(\"./worker.ts\");\n```\n\n### Main Process Typings\n\nIn case of the main process exported methods, those must be declared on a interface in the global scope called `MainProcessApi`.\n\n```ts\n// main.ts\n\nconst mainProcessApi = {\n  // Pass a log message to the Logger class in the main process\n  log: (message: string) =\u003e Logger.info(message),\n};\n\nconst client = await server.createClient(\"./worker.ts\", mainProcessApi);\n```\n\n```ts\n// worker.ts\n\ndeclare global {\n  // Methods in this interface should match the methods provided by the main process\n  interface MainProcessApi {\n    log(message: string): void;\n  }\n}\n\nSubprocess.invoke.log(\"Hello from the worker!\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-gjs%2Fgjs-multiprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-gjs%2Fgjs-multiprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-gjs%2Fgjs-multiprocess/lists"}