{"name":"@eggjs/eventbus-plugin","version":"4.0.2-beta.24","keywords":["decorator","egg","eventbus","tegg","typescript"],"_id":"@eggjs/eventbus-plugin@4.0.2-beta.24","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":"a03d9989173cc5af9444c0a485e142ed18f11a9e","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-plugin/download/@eggjs/eventbus-plugin-4.0.2-beta.24.tgz","fileCount":22,"integrity":"sha512-8382jD+qE5YNIZFutxlppQ+5LTkXDuukniBJctxJ61DEzMmbX5gqxOdb1QF0TwDspT9iVTr6AjJMMsx5ZVuDBQ==","signatures":[{"sig":"MEUCIF9xggUg8ksWWh6y7lcarHB9AkAU4hONgWDdpC7GA/meAiEArs3P5TkfoyTLpVk8tsCiV2EsUrXL160SNPutMYmpc24=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-plugin@4.0.2-beta.24","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":15739,"size":4381,"noattachment":false,"key":"/@eggjs/eventbus-plugin/-/@eggjs/eventbus-plugin-4.0.2-beta.24.tgz"},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","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":"1e9757ea83e6846b8458bde0f2b1b9fde5f5e0ef","scripts":{"typecheck":"tsgo --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:257680a6-5446-4aa0-b801-e36e55db6a94"}},"eggPlugin":{"name":"teggEventbus","dependencies":["tegg"]},"repository":{"url":"git+https://github.com/eggjs/egg.git","type":"git","directory":"tegg/plugin/eventbus"},"_npmVersion":"11.16.0","description":"tegg event plugin","directories":{},"_nodeVersion":"24.18.0","dependencies":{"@eggjs/metadata":"4.0.2-beta.24","@eggjs/lifecycle":"4.0.2-beta.24","@eggjs/tegg-runtime":"4.0.2-beta.24","@eggjs/module-common":"4.0.2-beta.24","@eggjs/core-decorator":"4.0.2-beta.24","@eggjs/eventbus-runtime":"4.0.2-beta.24","@eggjs/eventbus-decorator":"4.0.2-beta.24"},"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,"readmeFilename":"README.md","devDependencies":{"egg":"4.1.2-beta.24","typescript":"^5.9.3","@eggjs/mock":"7.0.2-beta.24","@eggjs/tegg":"4.0.2-beta.24","@types/node":"^24.10.2","@eggjs/tracer":"4.0.2-beta.24","@eggjs/tegg-config":"4.0.2-beta.24","@eggjs/tegg-plugin":"4.0.2-beta.24","@eggjs/tegg-common-util":"4.0.2-beta.24"},"peerDependencies":{"egg":"4.1.2-beta.24","@eggjs/tegg-plugin":"4.0.2-beta.24"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-plugin_4.0.2-beta.24_1783867842491_0.7464396063298513","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":1783867842628,"_cnpm_publish_time":1783867842628,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}