{"_id":"message-channel","_rev":"30-b6e656feec968b8dbec2fb0f40b2a4c6","name":"message-channel","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"message-channel","version":"1.0.0","author":{"name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.0.0","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"7dad24a83c6ec4d204189a1db19f433dd7de7f17","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.0.0.tgz","integrity":"sha512-/fKp/1pgL0ci2JQdeU9xTxMCHqQSeGTDnSF5JvKrr3F02HGlPZLCgR1up1LKvYiMaaS+6FkoG2JttZRi8ohrmg==","signatures":[{"sig":"MEUCIAUMsVGZ1VQY20fCfZDfnX8fKA2eqgOngaR9xiI3hyAJAiEA4nuH0518e7seBEkJegish2PJvCu8h3OQl5ClMQdt5ts=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"env":{"test":{"presets":[["env",{"targets":{"node":"current"}}]]},"development":{"presets":["env"]}},"plugins":["transform-runtime"],"presets":["stage-3"]},"files":["dist"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"ecb4bca16b7fbe785c0ff0658263619f989c525b","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":"yoshi release","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.4.0","dependencies":{"uuid":"^3.1.0","babel-runtime":"^6.22.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","babel-preset-env":"^1.5.2","eslint-config-wix":"~1.1.16","babel-preset-stage-3":"^6.5.0","babel-plugin-transform-runtime":"^6.22.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.0.0.tgz_1507039892039_0.6707508459221572","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"message-channel","version":"1.0.1","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.0.1","maintainers":[{"name":"wix-ci","email":"ci@wix.com"},{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"cb921a962c24d11ac77804e9b2d6e09c784ffada","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.0.1.tgz","integrity":"sha512-KGvjtO/xlkSQQ2GKh/rGHgKEMKvywB2j+GCWB/iZmp+IqX8f1POcx3/ZeL57GSNc8rGa9+jwWi/8nDqPkodB5Q==","signatures":[{"sig":"MEUCIQCGxo4pn0YD1+/j+fLRx9p4IIey3TFc4yuYRpG9ouKL9AIgHvM/E+++g1a5VrqL1Q5VxwPIIhcWtlvSXkTG37aGD7o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"env":{"test":{"presets":[["env",{"targets":{"node":"current"}}]]},"development":{"presets":["env"]}},"plugins":["transform-runtime"],"presets":["stage-3"]},"files":["dist"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"e60d278d8ca8f52c0cb24810ce1d3d82a62583e9","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":"yoshi release","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.4.0","dependencies":{"uuid":"^3.1.0","babel-runtime":"^6.22.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","babel-preset-env":"^1.5.2","eslint-config-wix":"~1.1.16","babel-preset-stage-3":"^6.5.0","babel-plugin-transform-runtime":"^6.22.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.0.1.tgz_1507046516457_0.29084199108183384","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"message-channel","version":"1.0.2","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.0.2","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"4f11d79c76b083b9077addd6aebbdee2de640c6e","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.0.2.tgz","integrity":"sha512-eW98CMvvOE3Pk7+THcbPd//s0YVoDl0MmxYeyHhrHRvliARqMuA3RXrF5/pVemGM8r0Y1ABvQVy6MblEmmZTcQ==","signatures":[{"sig":"MEUCIEAOxqe9zoid7W+k61weqI0ywpi4p88l9/UjYWayb+bKAiEA9ctTtmG4BP/8C0fNfh6/PfzE3Jk864dpe29pwfqh3TM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"presets":["es2015"]},"files":["dist/","connect.js","listener.js","README.md"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"1f2154eacd3863aad7be35044ca97d113914c85d","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":"yoshi release","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.6.0","dependencies":{"uuid":"^3.1.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","eslint-config-wix":"~1.1.16","babel-preset-es2015":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.0.2.tgz_1507542276587_0.7453179389704019","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"message-channel","version":"1.0.3","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.0.3","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"2dc649cc0a3e7b3c77dcaf5d9720da39ceafcb84","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.0.3.tgz","integrity":"sha512-BEvUrd8ZDA7GwmPlnz/mU+VAAhhYZPGbPqGeO4s3jD9Ctpea6pHFJ9GeuiS5uif/X7vceO+m3o0B/uVDTBcy+g==","signatures":[{"sig":"MEUCICHhx1PUvZcaszNUaOmCTwaORqehBvNjMNbUQEizOeQFAiEAy6Mvcydt60TEbhQHI/ua00m0O+XovIQSdbiND4fJA6E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"presets":["es2015"]},"files":["dist/","connect.js","listener.js","README.md"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"66dc0d09d8625cbc353d9cc69a108bc683ea2722","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":"yoshi release","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.3.0","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.6.0","dependencies":{"uuid":"^3.1.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","eslint-config-wix":"~1.1.16","babel-preset-es2015":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.0.3.tgz_1507625810057_0.40505335107445717","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"message-channel","version":"1.1.0","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.1.0","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"3c8cfaf5232e0e1d07fc9089e5407a01613bd3ae","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.1.0.tgz","integrity":"sha512-VvSnj+iSARSeq9Bt5t04GSEIokng70GcrzFNGGNeRMVaJfdGsDlCwYyceK61HBCZ66zd0x1/ZMhe/sLF3sLutg==","signatures":[{"sig":"MEQCIA5q6b29ljHkSkRfTCEzVcLaRY32v4pk17gqUATTDi4DAiAG9AJ5G/kcdWhwOOqp4PoL9iSA/hPykBvjC2creajcfg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"presets":["es2015"]},"files":["dist/","connect.js","listener.js","README.md"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"85b1506cc5d3f938f4b1abf28d22d9abadaa95e0","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":":","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.7.0","dependencies":{"uuid":"^3.1.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","eslint-config-wix":"~1.1.16","babel-preset-es2015":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.1.0.tgz_1508085422589_0.17002351651899517","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"message-channel","version":"1.2.0","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@1.2.0","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"6b417889f835e49f78d6409ae052f04e5523deab","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-1.2.0.tgz","integrity":"sha512-yKCCrCFNHU+XPvyH+RH8p+gOLS+Xewg4aFOw+XUp8NRtAYosmmPJKuLwro+UnV2nc2Hi6pxHAHVg6+0mp8kstQ==","signatures":[{"sig":"MEQCIHIpAs7ADjv8NOXg0owwqk5bMa6bXVhL8kz/HAWPCuQUAiACt13qY7uhcNvrU4hotWSPbuAevS7NnUU/doQGji/d3g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"presets":["es2015"]},"files":["dist/","connect.js","listener.js","README.md"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"840d529c7469bc17a4676f6f9018cd6eb064169e","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":":","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.7.0","dependencies":{"uuid":"^3.1.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","eslint-config-wix":"~1.1.16","babel-preset-es2015":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-1.2.0.tgz_1508400772231_0.031037597451359034","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"message-channel","version":"2.0.0","author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"_id":"message-channel@2.0.0","maintainers":[{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"}],"dist":{"shasum":"c58a38810ba3b521d3e5b500da7a83b42c52c609","tarball":"https://registry.npmjs.org/message-channel/-/message-channel-2.0.0.tgz","integrity":"sha512-+2tScCzaZegcun+ZA05YkBkrNUkAnEnjw5yuQu0y41PmOsX+H/lHwAiNqTqsFhe/telFnXJOp4YMh11aAyE0ag==","signatures":[{"sig":"MEUCIQDkYPLDEqpyDhcNW7GsfMdkg1cj8NqkCeSWDm/icfr3tAIgFye2WqCyTjj43G5WpIFqRsbPCENF2k2wjbpwo9ZQLTM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./dist/src/index.js","babel":{"presets":["es2015"]},"files":["dist/","connect.js","listener.js","README.md"],"yoshi":{"entry":{"connect":"./connect/connect-global.js","listener":"./listener/listener-global.js"}},"gitHead":"e71252b3268af3b98301d9b93573f8825b706035","private":false,"scripts":{"test":"yoshi test","build":":","start":"yoshi start","pretest":"yoshi build","release":":","posttest":"yoshi lint","precommit":"yoshi lint"},"_npmUser":{"name":"ranyitzhaki","email":"ranyitzhaki@gmail.com"},"_npmVersion":"5.4.2","description":"> request and response abstraction for message channel","directories":{},"_nodeVersion":"8.7.0","dependencies":{"uuid":"^3.1.0"},"eslintConfig":{"extends":"wix/esnext","globals":{"window":true}},"publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"chai":"^3.5.0","husky":"^0.13.4","jsdom":"11.2.0","yoshi":"^1.1.275","eslint":"~4.7.2","puppeteer":"~0.11.0","jsdom-global":"3.0.2","eslint-config-wix":"~1.1.16","babel-preset-es2015":"^6.5.0"},"_npmOperationalInternal":{"tmp":"tmp/message-channel-2.0.0.tgz_1508406247020_0.5745529918931425","host":"s3://npm-registry-packages"}}},"time":{"created":"2017-06-02T00:16:35.021Z","modified":"2026-06-29T09:44:26.085Z","0.0.1":"2017-06-02T00:16:35.021Z","1.0.0":"2017-10-03T14:11:33.395Z","1.0.1":"2017-10-03T16:01:57.699Z","1.0.2":"2017-10-09T09:44:37.639Z","1.0.3":"2017-10-10T08:56:51.108Z","1.1.0":"2017-10-15T16:37:03.620Z","1.2.0":"2017-10-19T08:12:53.168Z","2.0.0":"2017-10-19T09:44:07.944Z"},"author":{"url":"https://github.com/wix/message-channel","name":"Ran Yitzhaki","email":"rany@wix.com"},"description":"> request and response abstraction for message channel","maintainers":[{"email":"ci@wix.com","name":"wix-ci"},{"email":"shahart@wix.com","name":"wix-ambassador"},{"email":"falcon-ci-user@wix.com","name":"wix-ci-publisher"},{"email":"alterman@wix.com","name":"wix-bi-publisher"},{"email":"danielk@wix.com","name":"falconci"},{"email":"roir@wix.com","name":"roir-wix"},{"email":"ranyitz@gmail.com","name":"ranyitzhaki"}],"readme":"# message-channel\n> request and response abstraction for message channel\n\nThe best communication method between an iframe and the main frame is through [Channel messaging API](https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API).\n\n[![Build Status](https://travis-ci.org/wix/message-channel.svg?branch=master)](https://travis-ci.org/wix/message-channel)\n## TLDR\nUse this library for fast and performant communication between frames which uses message channel api underneath the hood.\n__________________________________________________\n\n### why do i need it ?\nlet's say we want to have few iframes which need to communicate with the main frame.\n\n#### usualy we'll need to:\n* Listen to post messages from the main frame.\n* Create a message channel from the iframe side.\n* Send a post message with one of the ports to the main frame.\n* Get the message from the iframe and register a callback to messages from the channel.\n* Be able to fit the main frame replies to the requests from the iframe.\n\n#### with message-channel\n\n```js\n// on the main frame\nimport listenerMessageChannel from 'message-channel/listener';\n\n// the listener will call the onMessage callback everytime a connection is being established.\n\nconst handleMessage = (e, reply) => reply(e.data + ' world');\n\nlistenerMessageChannel('scope-name', handleMessage);\n```\n\n```js\n// on the iframe\nimport connectMessageChannel from 'message-channel/connect';\n\n// Establish a connection with the main frame and send messages.\nconst send = await connectMessageChannel('scope-name');\n\nsend('hello')\n  .then(e => console.log(e.data)); // 'hello world'\n```\n\n## Installation\n\n### use a scipt tag and import the bundle\n```html\n<!-- add this on the main frame -->\n<script src=\"node_modules/message-channel/dist/statics/listener.bundle.min.js\" />\n<script> window.listenerMessageChannel(); // function will be available </script>\n```\n\n```html\n<!-- add this on the iframe -->\n<script src=\"node_modules/message-channel/dist/statics/listener.bundle.min.js\" />\n<script> window.connectMessageChannel(); // function will be available </script>\n```\n\n### you can also use npm\n\n```bash\nnpm i --save message-channel\n```\n\n### or yarn\n\n```bash\nyarn add message-channel\n```\n\n## basic usage\n\n**scope** - A scope is way to differentiate between two or more message-channels in the same application. (**it has to be the same on both listener and connect**)\n\n## methods\n\n### connectMessageChannel(scope: `string`, options: `object`): reply: `string`\n\n* targetOrigin = `string` ([target origin for the connection post message](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage)) = '*',\n* connectionMaxTimeout: `number` (ms) = 200\n* messageMaxTimeout: `number` (ms) = 6000\n\n### listenerMessageChannel(scope: `string`, messageHandler: `function`): `void`\n\n```js\nmessageHandler((e: `object`, reply: `function`) => {\n  reply(e.data); // will return a reply with the argument value (value must be serializable)\n});\n```\n\n__important note!:__ The event you'll get on the `onMessage` callback is a mirror of the [messageEvent](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent) type. The reason for not sending the \"real\" event, is that we add an id to every message and we want to strip the id from the data.\n\n### stop the listener\nIf you want to stop the listener, just call the stop function which returns from the call to the listener.\n\n```js\nconst stop = listenerMessageChannel('scope-name', (e, reply) => reply(e.data + ' world'));\n\nstop(); // The listener won't work.\n```\n","readmeFilename":"README.md"}