{"id":16550859,"url":"https://github.com/tmaize/i-message","last_synced_at":"2025-06-18T03:07:08.708Z","repository":{"id":62076549,"uuid":"557314096","full_name":"TMaize/i-message","owner":"TMaize","description":"优雅的 iframe 通信封装","archived":false,"fork":false,"pushed_at":"2022-10-26T12:20:21.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-11T09:47:40.132Z","etag":null,"topics":["iframe","postmessage"],"latest_commit_sha":null,"homepage":"https://tmaize.github.io/i-message/","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/TMaize.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}},"created_at":"2022-10-25T13:16:26.000Z","updated_at":"2022-10-26T01:57:44.000Z","dependencies_parsed_at":"2023-01-20T12:31:38.742Z","dependency_job_id":null,"html_url":"https://github.com/TMaize/i-message","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TMaize/i-message","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TMaize%2Fi-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TMaize%2Fi-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TMaize%2Fi-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TMaize%2Fi-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TMaize","download_url":"https://codeload.github.com/TMaize/i-message/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TMaize%2Fi-message/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260477920,"owners_count":23015064,"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":["iframe","postmessage"],"created_at":"2024-10-11T19:35:37.706Z","updated_at":"2025-06-18T03:07:03.695Z","avatar_url":"https://github.com/TMaize.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i-message\n\n优雅的 iframe 通信封装\n\n## 注册消息处理器\n\n```ts\nimport * as msg from '@tmaize/i-message'\n\n// 回调风格\n// callback(new Error('xxx')) 返回错误\nmsg.on('test1', function (payload: msg.IRequest, callback: (data: any) =\u003e void) {\n  setTimeout(() =\u003e {\n    callback('resp:' + payload.messageId)\n  }, 3000)\n})\n\n// promise 风格\n// return new Error('xxx') | Promise\u003cError\u003e 返回错误\nmsg.on('test2', async function (payload: msg.IRequest) {\n  await sleep(3000)\n  return 'resp: ' + payload.messageId\n})\n```\n\n## 发送消息\n\n```ts\nimport * as msg from '@tmaize/i-message'\n\nconst resp = await msg.emit({ request: 'test1', target: window.parent, data: {} })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmaize%2Fi-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmaize%2Fi-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmaize%2Fi-message/lists"}