{"name":"@eggjs/eventbus-plugin","version":"4.0.2-beta.26","description":"tegg event plugin","keywords":["decorator","egg","eventbus","tegg","typescript"],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/plugin/eventbus","bugs":{"url":"https://github.com/eggjs/egg/issues"},"repository":{"type":"git","url":"git+https://github.com/eggjs/egg.git","directory":"tegg/plugin/eventbus"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./app":"./dist/app.js","./app/extend/application.unittest":"./dist/app/extend/application.unittest.js","./app/extend/context":"./dist/app/extend/context.js","./lib/EggContextEventBus":"./dist/lib/EggContextEventBus.js","./lib/EggEventContext":"./dist/lib/EggEventContext.js","./lib/EventbusLoadUnitHook":"./dist/lib/EventbusLoadUnitHook.js","./lib/EventbusProtoHook":"./dist/lib/EventbusProtoHook.js","./lib/EventHandlerProtoManager":"./dist/lib/EventHandlerProtoManager.js","./types":"./dist/types.js","./package.json":"./package.json"},"publishConfig":{"access":"public","exports":{".":"./dist/index.js","./app":"./dist/app.js","./app/extend/application.unittest":"./dist/app/extend/application.unittest.js","./app/extend/context":"./dist/app/extend/context.js","./lib/EggContextEventBus":"./dist/lib/EggContextEventBus.js","./lib/EggEventContext":"./dist/lib/EggEventContext.js","./lib/EventbusLoadUnitHook":"./dist/lib/EventbusLoadUnitHook.js","./lib/EventbusProtoHook":"./dist/lib/EventbusProtoHook.js","./lib/EventHandlerProtoManager":"./dist/lib/EventHandlerProtoManager.js","./types":"./dist/types.js","./package.json":"./package.json"}},"scripts":{"typecheck":"tsgo --noEmit"},"dependencies":{"@eggjs/core-decorator":"4.0.2-beta.26","@eggjs/eventbus-decorator":"4.0.2-beta.26","@eggjs/eventbus-runtime":"4.0.2-beta.26","@eggjs/lifecycle":"4.0.2-beta.26","@eggjs/metadata":"4.0.2-beta.26","@eggjs/module-common":"4.0.2-beta.26","@eggjs/tegg-runtime":"4.0.2-beta.26"},"devDependencies":{"@eggjs/mock":"7.0.2-beta.26","@eggjs/tegg":"4.0.2-beta.26","@eggjs/tegg-common-util":"4.0.2-beta.26","@eggjs/tegg-config":"4.0.2-beta.26","@eggjs/tegg-plugin":"4.0.2-beta.26","@eggjs/tracer":"4.0.2-beta.26","@types/node":"^24.10.2","egg":"4.1.2-beta.26","typescript":"^5.9.3"},"peerDependencies":{"@eggjs/tegg-plugin":"4.0.2-beta.26","egg":"4.1.2-beta.26"},"engines":{"node":">=22.18.0"},"eggPlugin":{"name":"teggEventbus","dependencies":["tegg"]},"readmeFilename":"README.md","gitHead":"2b18475d501defd6f3b7b2c42e02426c1c3e0f84","_id":"@eggjs/eventbus-plugin@4.0.2-beta.26","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-h32tWt9rQvO98U4egYDX4w6bVaoKS+zyAO8FEhhsqTG5lOtNxn5/NhEokz9Lc6QM9gSI6p3rmNQ5Q2Z+THjqow==","shasum":"4cfdab70386092dc42934ae8d7a8338b592b17d7","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-plugin/download/@eggjs/eventbus-plugin-4.0.2-beta.26.tgz","fileCount":22,"unpackedSize":15739,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-plugin@4.0.2-beta.26","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAZZBOfg3Qjocv40fcZRrXx9F3aO0xDpwKYRIRHVS2TwAiEAvIhJ/6GkShC+9n+0j+/ozttqm0ILfkeyFsDyEyTRoMA="}],"size":4381,"noattachment":false,"key":"/@eggjs/eventbus-plugin/-/@eggjs/eventbus-plugin-4.0.2-beta.26.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:257680a6-5446-4aa0-b801-e36e55db6a94"}},"directories":{},"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"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/eventbus-plugin_4.0.2-beta.26_1786087013114_0.6826379569803773"},"_hasShrinkwrap":false,"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":1786087013273,"_cnpm_publish_time":1786087013273,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}