{"name":"@eggjs/eventbus-plugin","version":"4.0.0-beta.32","keywords":["egg","typescript","decorator","eventbus","tegg"],"_id":"@eggjs/eventbus-plugin@4.0.0-beta.32","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":"akitasummer@outlook.com"}],"homepage":"https://github.com/eggjs/egg/tree/next/tegg/plugin/eventbus","bugs":{"url":"https://github.com/eggjs/egg/issues"},"dist":{"shasum":"b8cef34ffa253b23309d123f45b866adffa585c2","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-plugin/download/@eggjs/eventbus-plugin-4.0.0-beta.32.tgz","fileCount":23,"integrity":"sha512-95A0sw4Nv+sADvZW+E4iRsgj+bmWpTGkDZk0sNmhNNh4DnI75ONkDJsbSFSltM0+A2SQvUUK807jGWhnuypK7w==","signatures":[{"sig":"MEYCIQDRh0jy0FoMB0XFmR+Rz6TShC183Hqmv/lcebo5K0RmOQIhAKlWXQrqZfF2z6jKaOwjHS6aqb8Tq3J5rDzJP6UdW0tk","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-plugin@4.0.0-beta.32","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26860,"size":8143,"noattachment":false,"key":"/@eggjs/eventbus-plugin/-/@eggjs/eventbus-plugin-4.0.0-beta.32.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-eventbus-plugin-4.0.0-beta.32.tgz","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"},"scripts":{"build":"tsdown && npm run clean && tsc -p tsconfig.build.json","clean":"rimraf dist *.tsbuildinfo","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:257680a6-5446-4aa0-b801-e36e55db6a94"}},"_resolved":"/tmp/6658b17a91703ce1fd1f03b15b946a57/eggjs-eventbus-plugin-4.0.0-beta.32.tgz","eggPlugin":{"name":"teggEventbus","dependencies":["tegg"]},"_integrity":"sha512-95A0sw4Nv+sADvZW+E4iRsgj+bmWpTGkDZk0sNmhNNh4DnI75ONkDJsbSFSltM0+A2SQvUUK807jGWhnuypK7w==","repository":{"url":"git+ssh://git@github.com/eggjs/egg.git","type":"git","directory":"tegg/plugin/eventbus"},"_npmVersion":"11.6.2","description":"tegg event plugin","directories":{},"_nodeVersion":"22.20.0","dependencies":{"@eggjs/metadata":"4.0.0-beta.32","@eggjs/lifecycle":"4.0.0-beta.32","@eggjs/tegg-runtime":"4.0.0-beta.32","@eggjs/module-common":"4.0.0-beta.32","@eggjs/core-decorator":"4.0.0-beta.32","@eggjs/eventbus-runtime":"4.0.0-beta.32","@eggjs/eventbus-decorator":"4.0.0-beta.32"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"egg":"4.1.0-beta.32","tsdown":"0.15.10","typescript":"^5.9.3","@eggjs/mock":"7.0.0-beta.32","@eggjs/tegg":"4.0.0-beta.32","@types/node":"^24.9.1","@eggjs/tracer":"4.0.0-beta.32","unplugin-unused":"^0.5.4","@eggjs/tegg-config":"4.0.0-beta.32","@eggjs/tegg-plugin":"4.0.0-beta.32","@eggjs/tegg-common-util":"4.0.0-beta.32"},"peerDependencies":{"egg":"4.1.0-beta.32","@eggjs/tegg-plugin":"4.0.0-beta.32"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-plugin_4.0.0-beta.32_1761585248610_0.9081376682388924","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":1761585248819,"_cnpm_publish_time":1761585248819,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}