{"name":"@eggjs/eventbus-plugin","version":"4.0.2-beta.13","keywords":["decorator","egg","eventbus","tegg","typescript"],"_id":"@eggjs/eventbus-plugin@4.0.2-beta.13","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":"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":"2095c8717fab8b3fc027070a17abaebe7025fc2e","tarball":"http://registry-npm.ywwl.com/@eggjs/eventbus-plugin/download/@eggjs/eventbus-plugin-4.0.2-beta.13.tgz","fileCount":23,"integrity":"sha512-SpWH4CV75JnsGPtRO3ea8j4palF4p3zVFo7C1f3ixSP2StHteu9lnRk9ZSKZycDjCwb8JSinj+1jPLOt9dvggw==","signatures":[{"sig":"MEQCIDQ7xcNvgMV4/rf9HYasAj905wOuNfgbVc+B9ygMuYqeAiBmEjNjaXSEH+PQB2trwEPeD40CSKucSjvecftJsTuglQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@eggjs%2feventbus-plugin@4.0.2-beta.13","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":16212,"size":5099,"noattachment":false,"key":"/@eggjs/eventbus-plugin/-/@eggjs/eventbus-plugin-4.0.2-beta.13.tgz"},"main":"./dist/index.js","type":"module","_from":"file:eggjs-eventbus-plugin-4.0.2-beta.13.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":{"typecheck":"tsgo --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:257680a6-5446-4aa0-b801-e36e55db6a94"}},"_resolved":"/tmp/adb5c6e55c4388efd11a4fccba76a033/eggjs-eventbus-plugin-4.0.2-beta.13.tgz","eggPlugin":{"name":"teggEventbus","dependencies":["tegg"]},"_integrity":"sha512-SpWH4CV75JnsGPtRO3ea8j4palF4p3zVFo7C1f3ixSP2StHteu9lnRk9ZSKZycDjCwb8JSinj+1jPLOt9dvggw==","repository":{"url":"git+https://github.com/eggjs/egg.git","type":"git","directory":"tegg/plugin/eventbus"},"_npmVersion":"11.13.0","description":"tegg event plugin","directories":{},"_nodeVersion":"24.16.0","dependencies":{"@eggjs/metadata":"4.0.2-beta.13","@eggjs/lifecycle":"4.0.2-beta.13","@eggjs/tegg-runtime":"4.0.2-beta.13","@eggjs/module-common":"4.0.2-beta.13","@eggjs/core-decorator":"4.0.2-beta.13","@eggjs/eventbus-runtime":"4.0.2-beta.13","@eggjs/eventbus-decorator":"4.0.2-beta.13"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"egg":"4.1.2-beta.13","typescript":"^5.9.3","@eggjs/mock":"7.0.2-beta.13","@eggjs/tegg":"4.0.2-beta.13","@types/node":"^24.10.2","@eggjs/tracer":"4.0.2-beta.13","@eggjs/tegg-config":"4.0.2-beta.13","@eggjs/tegg-plugin":"4.0.2-beta.13","@eggjs/tegg-common-util":"4.0.2-beta.13"},"peerDependencies":{"egg":"4.1.2-beta.13","@eggjs/tegg-plugin":"4.0.2-beta.13"},"_npmOperationalInternal":{"tmp":"tmp/eventbus-plugin_4.0.2-beta.13_1782289672903_0.811859297775374","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":1782289673050,"_cnpm_publish_time":1782289673050,"dist-tags":{"beta":"4.0.2-beta.27","latest":"4.1.0","rc":"4.0.2-rc.1"}}