@ arcships/ rutis (英语)
写入 卢比 在TypeScript或JavaScript中的插件.
import { definePlugin } from '@arcships/rutis'
export default definePlugin({
inject: ['llm'], // services it uses
optional: ['search'], // used when there: ctx.get('search')
config: { type: 'object', properties: { city: { type: 'string' } } },
apply(ctx, config) {
ctx.provide('weather', new Weather(ctx.use('llm'), config.city))
return () => {} // cleanup
},
})
optional 名称服务,它可以没有: rutis 不等待它们,以及 ctx.get 给每个,或 undefined 当插件启动( rutis- host 0.
什麽 ctx.provide 提供本身达到的rutis, 它的方法对象的功能,称为 async。 。 。 . provides 可选 : provides: { weather: { unit: 'sync' } } 标记方法 sync 告诉 rutis-host check 插件运行前提供的内容 .
在真正的主机上测试( T)rutis-host test· ; @arcships/rutis-runtime 财务报告和审定财务报表 @arcships/rutis-host 作为非依赖性 rutis-host new 添加); 插件是其模块的默认导出 :
import { load } from '@arcships/rutis/testing'
const t = await load(plugin, { config: { city: 'Oslo' }, services: { llm: { ask: async () => 'sunny' } } })
assert.equal(await t.service('weather').today(), 'sunny in Oslo')
await t.unload()
此软件包没有依赖性 。 活动ctx.on,以及 ctx.emit 编号 : parallel 编号 : serial 编号 : waterfall 编号 : bail 编号 : filter)是跨越每个插件,运行时间和链接节点的一款总线,由主机发送;在测试中也是(host() 在一个总线上设置多个插件). 主机安装运行插件的运行时间( R)@arcships/rutis-runtime 为节点, @arcships/rutis-bun 为邦. 以 npx @arcships/rutis-host new <name> --lang node (或 --lang bun) (中文(简体) ).
向导 (中文) 文件/指南/类型说明-插图.md。 。 。 .