{"id":22400961,"url":"https://github.com/samdenty/comlink-extension","last_synced_at":"2025-05-12T14:52:56.586Z","repository":{"id":40438706,"uuid":"277666364","full_name":"samdenty/comlink-extension","owner":"samdenty","description":"Use comlink with chrome extensions","archived":false,"fork":false,"pushed_at":"2024-12-20T17:04:28.000Z","size":16,"stargazers_count":29,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-11T03:02:47.999Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/comlink-extension","language":"TypeScript","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/samdenty.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}},"created_at":"2020-07-06T23:02:47.000Z","updated_at":"2024-12-20T17:04:32.000Z","dependencies_parsed_at":"2025-01-16T19:14:07.583Z","dependency_job_id":"3341d57b-5598-475d-96f7-1b3b3c35a281","html_url":"https://github.com/samdenty/comlink-extension","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"3facc50dbd0171db7d51a07e715c5447e1d36608"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdenty%2Fcomlink-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdenty%2Fcomlink-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdenty%2Fcomlink-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdenty%2Fcomlink-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samdenty","download_url":"https://codeload.github.com/samdenty/comlink-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253759136,"owners_count":21959704,"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","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":"2024-12-05T08:17:39.408Z","updated_at":"2025-05-12T14:52:56.528Z","avatar_url":"https://github.com/samdenty.png","language":"TypeScript","funding_links":["https://github.com/sponsors/samdenty"],"categories":[],"sub_categories":[],"readme":"# Comlink for Web Extensions [![Sponsors](https://img.shields.io/github/sponsors/samdenty?label=Sponsors)](https://github.com/sponsors/samdenty)\n\n[Sponsor this project](https://github.com/sponsors/samdenty)\n\nThis module allows you to use [Comlink](https://github.com/GoogleChromeLabs/comlink) for `Background \u003c-\u003e Content/Popup` communication, in Chrome/Firefox/Safari extensions.\n\n## Usage\n\nBackground-script:\n\n```ts\nimport { createBackgroundEndpoint, isMessagePort } from \"comlink-extension\";\nimport * as Comlink from \"comlink\";\n\nchrome.runtime.onConnect.addListener((port) =\u003e {\n  if (isMessagePort(port)) return;\n\n  Comlink.expose(\n    {\n      test() {\n        console.log(\"called\");\n      },\n    },\n    createBackgroundEndpoint(port)\n  );\n});\n```\n\nContent / popup / devtool script:\n\n```ts\nimport { createEndpoint, forward } from \"comlink-extension\";\nimport * as Comlink from \"comlink\";\n\n// Wrap a chrome.runtime.Port\nconst obj = Comlink.wrap(createEndpoint(chrome.runtime.connect()));\nobj.test();\n\n// Or, wrap an existing Message Channel:\nconst { port1, port2 } = new MessageChannel();\nforward(port1, chrome.runtime.connect());\n\nconst obj = Comlink.wrap(port2);\nobj.test();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamdenty%2Fcomlink-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamdenty%2Fcomlink-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamdenty%2Fcomlink-extension/lists"}