[Refactoring] Landmark version 1.0.0-alpha.5
#62
Labels
feature request
向维护者提出新的特性建议
score: builtin-tools
与 Avilla Core 中提供的工具链相关
score: core
与 Avilla Protocol (Avilla Core) 相关, 并以此为作用域
score: design
与项目本身的抽象架构设计相关
Milestone
概要
本次重构的 Landmark 版本被设定为
1.0.0-alpha.5
.本次主要对各种用名进行修改, 对
Relationship
模型进行重构, 以及分割 core 部件内的框架抽象到avilla.core.abstract
处, 这将会不可避免的带来 API 的破坏性改动和用户体验的变化.ContextSelector
#65ContextClientSelector
ContextSceneSelector
ContextEndpointSelector
ContextRequestSelector
context.endpoint.expects_request() -> ContextRequestSelector
context.request (property)
Context.wrap
#63Context.wrap(bound: Selector) -> ContextSelector
Context.wrap(bound: MetadataOf) -> ContextWrappedMetadataOf
Context.wrap(bound: Selector, trait: type[T extends Trait]) -> T
Context.wrap(bound: MetadataOf, trait: type[T extends Trait]) -> T
ContextSelector.wrap(trait: type[T extends Trait]) -> T
ContextWrappedMetadata.wrap(trait: type[T extends Trait]) -> T
Context.pull
#64ContextSelector.pull(metadata: type[T extends Metadata] | MetadataRoute[..._L, T]) -> T
ContextWrappedMetadataOf[T].pull() -> T
implement
&bound
#67bound(...)
impl
and others.用名修改
以下更改同时会影响到
Filter
等内置组件上的方法命名, 请尤其是该提案的实现编写者注意.API 变动概览
ContextSelector
该 Selector 同时包装了一个 Context, 使得可以配合其完成更多的操作, 这也导致了一些代码风格上的变化.
Context.{client, endpoint, scene, mediums[number].selector}
的类型都为ContextSelector
.目前正在考虑实现例如
ContextClientSelector
,ContextSceneSelector
等派生类, 用于进一步的提供高效的 API 实现.Selector
相关新加入
Selector.expects
方法, 用于对 Selector 的内容进行断言. 在语法上使用 follows-style, 同时 follows-style 作为优雅的模式表达方式将得到进一步的推广.Metadata.of
&MetadataRoute.of
需要注意的是, 这里的
MetadataOf
与先前版本中的CellOf
完全不同.MetadataOf
的声明:可以这样创建:
Context.wrap
该 API 不仅用于替代
Relationship.cast
, 还用于简单的包装 Selector 为ContextSelector
.该方法会自动运行
Context.complete
, 且自动忽略land
字段.对于 Metadata 上的 bound, 这里有一个简单的草案, 但未经验证:
Context.check
!> 该项仍然处于设计中(In-Design)阶段.
在
1.0.0rc4
中,Relationship.check
尚未被实现,1.0.0rc5
将着手相关工程.由于要确认的包括且不限于 Metadata, Selector, Trait 之类的交互形式, 所以该项仍然处于设计中阶段.
impl
相关鉴于 bound 在
Context.wrap -> Trait
中的强制要求, 协议实现中impl
的方式亦有所改变.事件结构体变动
鉴于现在的自动从
AvillaEvent
生成Context
/Relationship
和注入Metadata
的方式实在是不堪入目,从
1.0.0-alpha.5
开始, 事件的实例化强制要求Context
作为第一个参数的传入.这不会影响事件本身描述的完整性, 也就是说,
MessageReceived.scene
等不会被删除.包组织结构改动
Trait
,Fn
以及各式 recorder,AvillaEvent
事件基类,Resource
基类等部件将被移动至avilla.core.abstract
处.由
avilla-core
所提供的事件, 元信息类, 内建 Trait 等都被移动至avilla.core.standards
下.其他改动
Relationship.send_message
等缩写形式不再受到支持, 其职权将由ContextSelector
及其派生完成, 而不需要实现默认求值 (default_target
).default_target
不再提供.ImplRecorder.pin
, 实现签名类型OrientFn
与DirectFn
将不再提供.bound
辅助型上下文管理器的出现,prefix
被标记为弃用.MessageSend.send_message
等实现签名 Fn 的方法名现已被改为仅包含谓词的形式, 如MessageSend.send
, 这将减少语义杂糅.Message
派生为多个消息类型, 如ChatMessage
,NoticeMessage
,PlatformMessage
等.MetadataModified.modifies
的表述方式现已如下呈现, 因为引入Context.endpoint
, 这一切都变得更简单了:设计中事项
avilla.core.exceptions
, 现阶段其大部分设计都来自于OneBot
的错误类型.BaseProtocol
使用单个ProtocolManifest
实例表述, 并使用一套 Credential 机制或是kayaku
描述账号及其鉴权信息.The text was updated successfully, but these errors were encountered: