{"_id":"@bytemend/mfebus","_rev":"6-7361740720a6407c39e6f0e99777e9aa","name":"@bytemend/mfebus","dist-tags":{"latest":"1.4.5"},"versions":{"1.4.0":{"name":"@bytemend/mfebus","version":"1.4.0","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"author":{"url":"https://github.com/bytemend","name":"bytemend","email":"bytemend@pm.me"},"license":"MIT","_id":"@bytemend/mfebus@1.4.0","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"homepage":"https://github.com/bytemend/mfebus#readme","bugs":{"url":"https://github.com/bytemend/mfebus/issues"},"dist":{"shasum":"6db74f8ad3cca0d369281c60d689f984a08c084e","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.0.tgz","fileCount":6,"integrity":"sha512-52vvVVGI4W6S8pjP80tTWUQJGd1kbsUSwo+abg1iCI9NuBc+XykUkMmQqo3YuelJRqG/lln7y3SQjmRR3lKJdA==","signatures":[{"sig":"MEUCICp5gDKeYPM4IZ0ol4uIHd7MBYEneIAttgZfYvP87jBkAiEAwjUxhB5KhbHIwkaFvNRw65/v4q/hP+h51mDLquxKltI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18333},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14"},"gitHead":"3f0a61fde99f31d7920c551fa0af3f5087449f90","scripts":{"postinstall":"node dist/bootstrap.js"},"_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"repository":{"url":"git+https://github.com/bytemend/mfebus.git","type":"git"},"_npmVersion":"11.11.0","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mfebus_1.4.0_1780558374493_0.8120006306998984","host":"s3://npm-registry-packages-npm-production"}},"1.4.1":{"name":"@bytemend/mfebus","version":"1.4.1","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"author":{"url":"https://github.com/bytemend","name":"bytemend","email":"bytemend@pm.me"},"license":"MIT","_id":"@bytemend/mfebus@1.4.1","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"dist":{"shasum":"38bcb3ba371e95d2d8da67d99ef276826cf0e299","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.1.tgz","fileCount":6,"integrity":"sha512-fHIzs6SjXgjSvWKQBYDg8MuBmVk0i2ehzsmU2Q7aEyspD06I3j7W57zIB8Yt+KyxZzJHSRTizgd7M2Yi5Kjiqw==","signatures":[{"sig":"MEUCIQDWs4XOHl9YoT8O39rNJe6F/cgmIY10u1SVHS1jjlKq3QIgVGfrRLRRBXeHsI4AJKMJLuZByoRBfHF+oc87AA1f2TQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18108},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14"},"gitHead":"32f5571ba391acf78f9f2656a96c725d531ddb47","scripts":{"postinstall":"node dist/bootstrap.js"},"_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"_npmVersion":"11.11.0","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mfebus_1.4.1_1781420280153_0.3296572484042515","host":"s3://npm-registry-packages-npm-production"}},"1.4.2":{"name":"@bytemend/mfebus","version":"1.4.2","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"author":{"url":"https://github.com/bytemend","name":"bytemend","email":"bytemend@pm.me"},"license":"MIT","_id":"@bytemend/mfebus@1.4.2","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"dist":{"shasum":"1fd6beea4ba1097ba767bcbcc62ee4de8d92d153","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.2.tgz","fileCount":6,"integrity":"sha512-C9RVCdKE/oSvyLKKv75va4kyED2Zjpv3ksXtTsm/Id/SsBJ8ije/Zy4q+5klQm/E5tySclTJ9rlcBMzZ9MTBdA==","signatures":[{"sig":"MEUCIAkgHdlZaIhTwaf/6v/12h7vTvajMhUIa0EG/1KucuL8AiEAyjoU0LUmyQB/pdd4QIBNTuHrw8cK+5HPtVlfatkT0yU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":295012},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14"},"gitHead":"d5d1ca676e4f10347546bbab60a3fd0faa1f891f","scripts":{"postinstall":"node dist/bootstrap.js"},"_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"_npmVersion":"11.11.0","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mfebus_1.4.2_1781765215952_0.4662706017571612","host":"s3://npm-registry-packages-npm-production"}},"1.4.3":{"name":"@bytemend/mfebus","version":"1.4.3","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"author":{"url":"https://github.com/bytemend","name":"bytemend","email":"bytemend@pm.me"},"license":"MIT","_id":"@bytemend/mfebus@1.4.3","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"dist":{"shasum":"35d1f3ede98964880c4759a2346ab1f1893c130b","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.3.tgz","fileCount":6,"integrity":"sha512-kxFo8/qHEMUTvwCNgrwOB6TyO1Nr3gcggKfk95jqUR5pz8ITygFiCQ3dKYVDs7jJUmgHbtvPCVwfYXvXRlJRkA==","signatures":[{"sig":"MEYCIQDB9WFXkjc6UlKGf4eTJ6S9CKQq7bu1XZRrT5DNaJ0kdQIhAKZ2p9jrR8BMkwfmTtuVhfEvK7KCJHic7Xr4mfAhsdbx","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":294948},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14"},"gitHead":"d5c89325b103f88f15ce46fdd8eac3dd4c98cfb1","_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"_npmVersion":"11.11.0","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mfebus_1.4.3_1781770022906_0.8418336129984216","host":"s3://npm-registry-packages-npm-production"}},"1.4.4":{"name":"@bytemend/mfebus","version":"1.4.4","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"author":{"url":"https://github.com/bytemend","name":"bytemend","email":"bytemend@pm.me"},"license":"MIT","_id":"@bytemend/mfebus@1.4.4","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"dist":{"shasum":"65ca51b6b88170003ac8d90535b38d6084d0820f","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.4.tgz","fileCount":6,"integrity":"sha512-bJ0J99JQWoILpJZk8H5dMJd7Y9PoLlHgDb4ZvZMX68qluGjrditr2yNeQlt3aexT33yMfDkYwjRNZ3puLLRuzw==","signatures":[{"sig":"MEUCIQCM4U9NnmfgsaD6Xk38l9Bn0xOUiPjle1Yyh62G5LK3vQIgHSPWml9sDBMI941NclaZg9NXTMCoG/Y32+RIsab3s5Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":295069},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14"},"gitHead":"d7dcd1a7baec569a43543876c7657b427a1f7f36","_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"_npmVersion":"11.11.0","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/mfebus_1.4.4_1781774604236_0.8408094327006139","host":"s3://npm-registry-packages-npm-production"}},"1.4.5":{"name":"@bytemend/mfebus","version":"1.4.5","description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","main":"dist/index.js","types":"dist/index.d.ts","license":"MIT","author":{"name":"bytemend","email":"bytemend@pm.me","url":"https://github.com/bytemend"},"engines":{"node":">=14"},"sideEffects":false,"keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"gitHead":"3d4b27adc4c0a6304821c3bca2cbcb3cd0c3c0f0","_id":"@bytemend/mfebus@1.4.5","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-taEV4nUYpJMeTs9aTkMYwkNIq/TlOpEcn/YXtccOM+tqhBAWTRJMjcWAYC+2L2dCkSatZGGxgsmhkrkl6K8pKQ==","shasum":"aaa6742634b907f291db9f4b51f7d204ca2bb5e5","tarball":"https://registry.npmjs.org/@bytemend/mfebus/-/mfebus-1.4.5.tgz","fileCount":6,"unpackedSize":294721,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDoHWwDQvWNkYHl7HEpTvRUQBok0UPGRHDK98/U5SrEZgIgCL23jX8KzdoHWTVQMApKJkf5oTBdpARtr8bsPml6PUU="}]},"_npmUser":{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"},"directories":{},"maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mfebus_1.4.5_1781775826524_0.7565629852712963"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T07:32:54.331Z","modified":"2026-06-18T09:43:46.786Z","1.4.0":"2026-06-04T07:32:54.633Z","1.4.1":"2026-06-14T06:58:00.297Z","1.4.2":"2026-06-18T06:46:56.097Z","1.4.3":"2026-06-18T08:07:03.070Z","1.4.4":"2026-06-18T09:23:24.385Z","1.4.5":"2026-06-18T09:43:46.674Z"},"author":{"name":"bytemend","email":"bytemend@pm.me","url":"https://github.com/bytemend"},"license":"MIT","keywords":["event-bus","pubsub","ipc","node","worker-threads","child-process","broadcast","transport"],"description":"In-memory pub-sub for Node with pluggable transports — child_process / worker_threads IPC, EventEmitter, browser cross-frame","maintainers":[{"name":"bytemend","email":"bytemend-dwzfhq@wshu.net"}],"readme":"# @bytemend/mfebus\n\nIn-memory pub-sub for Node. Synchronous same-process dispatch, plus pluggable transports so the bus can extend across `child_process`, `worker_threads`, `MessagePort`, or — when running in the browser — `postMessage` boundaries.\n\nWhen the package is loaded inside a `fork()`-spawned child (`process.send` defined), it auto-binds to the parent channel. No setup needed for the common worker-pool pattern.\n\n## Install\n\n```sh\nnpm i @bytemend/mfebus\n```\n\n## Same-process\n\n```js\nimport { emit, on } from '@bytemend/mfebus';\n\nconst off = on('job:done', (payload, meta) => {\n  console.log('job', payload.id, 'finished', meta.local ? '(local)' : `(from ${meta.senderId})`);\n});\n\nemit('job:done', { id: 42 });\noff();\n```\n\n## Node IPC — `worker_threads`\n\n```js\nimport { Worker } from 'node:worker_threads';\nimport { addIpcTarget, on } from '@bytemend/mfebus';\n\nconst worker = new Worker(new URL('./worker.js', import.meta.url));\nconst remove = addIpcTarget(worker);\n\non('worker:status', (s) => console.log('[main]', s));\n\n// inside worker.js — `addIpcTarget(parentPort)` plus `emit('worker:status', …)`\n// is enough to reach the listener above.\n```\n\n## Node IPC — `child_process.fork`\n\n```js\nimport { fork } from 'node:child_process';\nimport { addIpcTarget } from '@bytemend/mfebus';\n\nconst child = fork('./child.js');\naddIpcTarget(child);\n\n// inside child.js the package auto-binds to `process` because\n// `process.send` is defined under fork(). Just import and use.\n```\n\n## Custom transport (Redis, NATS, etc.)\n\n```js\nimport { addTransport } from '@bytemend/mfebus';\n\naddTransport({\n  send: (envelope) => redis.publish('events', JSON.stringify(envelope)),\n  onMessage: (cb) => {\n    const onMsg = (_, raw) => cb(JSON.parse(raw));\n    redis.on('message', onMsg);\n    redis.subscribe('events');\n    return () => redis.off('message', onMsg);\n  },\n});\n```\n\n## Browser cross-frame (optional)\n\nWhen loaded in a browser context, the bus also listens for `window.postMessage`. Register the peer window once:\n\n```js\nimport { addCrossFrameTarget, setAllowedOrigins } from '@bytemend/mfebus';\n\nconst frame = document.querySelector('#peer');\nif (frame?.contentWindow) addCrossFrameTarget(frame.contentWindow);\n\n// Tighten in production:\nsetAllowedOrigins(['https://peer.example.com']);\n```\n\n## API\n\n```ts\nemit<T>(event: string, payload?: T): void\non<T>(event: string, handler: (p: T, meta) => void): () => void\nonce<T>(event: string, handler: (p: T, meta) => void): () => void\noff(event: string, handler?: Handler): void\nclear(event?: string): void\n\naddTransport(transport: { send(env), onMessage?(cb) → off }): () => void\naddIpcTarget(channel): () => void   // Worker | ChildProcess | MessagePort\n\naddCrossFrameTarget(target): void\nremoveCrossFrameTarget(target): void\nsetAllowedOrigins(origins: string[]): void\n\nsenderId: string\n```\n\n### Handler meta\n\n```ts\ntype DispatchMeta = {\n  senderId: string;        // random per-load id of the emitter\n  local: boolean;          // came from the same process / frame?\n  origin?: string;         // window origin (browser cross-frame only)\n  ts?: number;             // posting timestamp (transport dispatches)\n  transport?: unknown;     // handle of the transport that delivered the envelope\n};\n```\n\n## Notes\n\n- Handlers run in registration order. Exceptions are caught and logged — one bad subscriber can't kill the bus.\n- The bus drops envelopes whose `senderId` matches the local id, so transports that loop back are safe.\n- `setAllowedOrigins(['*'])` is the dev default; tighten in production for browser frames.\n\n## License\n\nMIT.\n","readmeFilename":"README.md"}