{"name":"@eggjs/eventbus-plugin","version":"4.0.2","keywords":["decorator","egg","eventbus","tegg","typescript"],"_id":"@eggjs/eventbus-plugin@4.0.2","maintainers":[{"name":"gxkl","email":"gxkl203@gmail.com"},{"name":"eggjs-admin","email":"fengmk2+eggjs@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"atian25","email":"atian25@qq.com"},{"name":"hyj1991","email":"yeekwanvong@gmail.com"},{"name":"killagu","email":"killa07071201@gmail.com"},{"name":"coolme200","email":"2001-wms@163.com"},{"name":"akitasummer","email":"644171127@qq.com"},{"name":"elrrrrrrr","email":"elrrrrrrr@gmail.com"},{"name":"niania","email":"ljracm@gmail.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/plugin/eventbus","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"90bf885b8143da3e36dfdfd51b353a5103aa9637","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-plugin/download/@eggjs/eventbus-plugin-4.0.2.tgz","fileCount":22,"integrity":"sha512-7J6a7Wz8XS3Y/llJ1Vj/68vIWSZBz0XHA4qXUVSYMzFMgafdqn/sCosLCT6aKX6W2MF2mG4HX7ozBhXQHVVoZg==","signatures":[{"sig":"MEYCIQDx1JvSeh+O15TnszN/vYv2YupinK8DSmYWA/aocUwgKQIhAJsLFIXfVZgtYOmZ9IPdzzEF7PS+PRUURWrEpQZh/KdA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQCxPpLTIxYGW36QeSpG1gGB3XTAkg2JkkrfK556QM5GAgIgIjyiniZrPWUHJxyhKX8Yz4YD0gGU1FUUeinlA7DxiwQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-plugin@4.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":15275,"size":4356,"noattachment":false,"key":"/@eggjs/eventbus-plugin/-/@eggjs/eventbus-plugin-4.0.2.tgz"},"type":"module","types":"./dist/index.d.ts","engines":{"node":">=22.18.0"},"exports":{".":"./dist/index.js","./app":"./dist/app.js","./types":"./dist/types.js","./package.json":"./package.json","./app/extend/context":"./dist/app/extend/context.js","./lib/EggEventContext":"./dist/lib/EggEventContext.js","./lib/EventbusProtoHook":"./dist/lib/EventbusProtoHook.js","./lib/EggContextEventBus":"./dist/lib/EggContextEventBus.js","./lib/EventbusLoadUnitHook":"./dist/lib/EventbusLoadUnitHook.js","./lib/EventHandlerProtoManager":"./dist/lib/EventHandlerProtoManager.js","./app/extend/application.unittest":"./dist/app/extend/application.unittest.js"},"gitHead":"cd042a2c1fa06414f4f3290240a92a0e528b24c3","scripts":{"typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"0c0aabc2-68c4-4780-ba93-ea1a5d016fe8"}},"eggPlugin":{"name":"teggEventbus","dependencies":["tegg"]},"repository":{"url":"git+https://github.com/eggjs/egg.git","type":"git","directory":"tegg/plugin/eventbus"},"_npmVersion":"11.19.0","description":"tegg event plugin","directories":{},"_nodeVersion":"24.21.0","dependencies":{"@eggjs/metadata":"4.0.2","@eggjs/lifecycle":"4.0.2","@eggjs/tegg-runtime":"4.0.2","@eggjs/module-common":"4.0.2","@eggjs/core-decorator":"4.0.2","@eggjs/eventbus-runtime":"4.0.2","@eggjs/eventbus-decorator":"4.0.2"},"publishConfig":{"access":"public","exports":{".":"./dist/index.js","./app":"./dist/app.js","./types":"./dist/types.js","./package.json":"./package.json","./app/extend/context":"./dist/app/extend/context.js","./lib/EggEventContext":"./dist/lib/EggEventContext.js","./lib/EventbusProtoHook":"./dist/lib/EventbusProtoHook.js","./lib/EggContextEventBus":"./dist/lib/EggContextEventBus.js","./lib/EventbusLoadUnitHook":"./dist/lib/EventbusLoadUnitHook.js","./lib/EventHandlerProtoManager":"./dist/lib/EventHandlerProtoManager.js","./app/extend/application.unittest":"./dist/app/extend/application.unittest.js"}},"_hasShrinkwrap":false,"devDependencies":{"egg":"4.1.2","typescript":"^7.0.2","@eggjs/mock":"7.0.2","@eggjs/tegg":"4.0.2","@types/node":"^24.10.2","@eggjs/tracer":"4.0.2","@eggjs/tegg-config":"4.0.2","@eggjs/tegg-plugin":"4.0.2","@eggjs/tegg-common-util":"4.0.2"},"peerDependencies":{"egg":"4.1.2","@eggjs/tegg-plugin":"4.0.2"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-plugin_4.0.2_1791297349692_0.42829511548540156","host":"s3://npm-registry-packages-npm-production"},"readme":"# @eggjs/eventbus-plugin\n\n[![NPM version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/@eggjs/eventbus-plugin.svg?style=flat)](https://nodejs.org/en/download/)\n\n[npm-image]: https://img.shields.io/npm/v/@eggjs/eventbus-plugin.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/@eggjs/eventbus-plugin\n[snyk-image]: https://snyk.io/test/npm/@eggjs/eventbus-plugin/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/@eggjs/eventbus-plugin\n[download-image]: https://img.shields.io/npm/dm/@eggjs/eventbus-plugin.svg?style=flat-square\n[download-url]: https://npmjs.org/package/@eggjs/eventbus-plugin\n\n## Usage\n\n```js\n// plugin.js\nexport.teggEventbus = {\n  enable: true,\n  package: '@eggjs/eventbus-plugin',\n};\n```\n\n## Unittest\n\n```ts\n// test/fixtures/apps/event-app/app/event-module/HelloService\n@ContextProto({\n  accessLevel: AccessLevel.PUBLIC,\n})\nexport class HelloService {\n  @Inject()\n  private readonly eventBus: EventBus;\n\n  hello() {\n    this.eventBus.emit('hello', '01');\n  }\n}\n\n// test/fixtures/apps/event-app/app/event-module/HelloLogger\n@Event('helloEgg')\nexport class HelloLogger {\n  handle(msg: string) {\n    console.log('hello, ', msg);\n  }\n}\n\n// test/event.test.ts\nimport assert from 'assert';\nimport path from 'path';\nimport mm from 'egg-mock';\nimport { HelloService } from './fixtures/apps/event-app/app/event-module/HelloService';\nimport { HelloLogger } from './fixtures/apps/event-app/app/event-module/HelloLogger';\n\ndescribe('test/eventbus.test.ts', () => {\n  let app;\n  let ctx;\n\n  afterEach(async () => {\n    await app.destroyModuleContext(ctx);\n    mm.restore();\n  });\n\n  before(async () => {\n    app = mm.app();\n    await app.ready();\n  });\n\n  after(() => {\n    return app.close();\n  });\n\n  it('msg should work', async () => {\n    ctx = await app.mockModuleContext();\n    const helloService = await ctx.getEggObject(HelloService);\n    let msg: string | undefined;\n    // helloLogger is in child context, should mock the prototype\n    mm(HelloLogger.prototype, 'handle', (m) => {\n      msg = m;\n    });\n    const eventWaiter = await app.getEventWaiter();\n    const helloEvent = eventWaiter.await('hello');\n    helloService.hello();\n    await helloEvent;\n    assert(msg === '01');\n  });\n});\n```\n","publish_time":1791297349782,"_cnpm_publish_time":1791297349782,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}