pancake-embed 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pancake Embed — 零 import 插件
|
|
3
|
+
将框架装饰器注册到 muffin_flour,配合 DoughMeta 实现自动注入。
|
|
4
|
+
DoughMeta 在用户定义 Dough 子类时,自动从 muffin_flour/muffin_water
|
|
5
|
+
注入已注册的名称到模块命名空间。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
|
|
10
|
+
from pancake.ovenware import InitAction
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Main(InitAction):
|
|
16
|
+
"""Embed 插件入口
|
|
17
|
+
|
|
18
|
+
init_order=-10 确保最先加载,
|
|
19
|
+
在用户代码加载前完成装饰器注册。
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
init_order = -10
|
|
23
|
+
build_order = 0
|
|
24
|
+
|
|
25
|
+
def check(self) -> bool:
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
def build(self):
|
|
29
|
+
"""确保所有装饰器已注册到 muffin_flour"""
|
|
30
|
+
# 触发 decorators 模块加载(会自动注册到 muffin_flour)
|
|
31
|
+
import pancake.decorators # noqa: F401
|
|
32
|
+
# 触发 base 模块加载(会自动注册到 muffin_water)
|
|
33
|
+
import pancake.base # noqa: F401
|
|
34
|
+
# 触发 factory 模块加载(会自动注册到 muffin_water)
|
|
35
|
+
import pancake.factory # noqa: F401
|
|
36
|
+
|
|
37
|
+
from pancake.oven.muffin import muffin_flour, muffin_water
|
|
38
|
+
logger.info(
|
|
39
|
+
f"Embed: 已注册 {len(muffin_flour)} 个装饰器, "
|
|
40
|
+
f"{len(muffin_water)} 个类"
|
|
41
|
+
)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pancake-embed
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pancake Embed Plugin - 零 import 机制,将所有装饰器注入 builtins
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: drayee
|
|
7
|
+
Author-email: 1473443474@qq.com
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Requires-Dist: pancake_framework (>=0.2.0)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# Pancake Embed
|
|
20
|
+
|
|
21
|
+
> 零 import 插件 — 配合 DoughMeta 实现框架 API 自动注入
|
|
22
|
+
|
|
23
|
+
## 工作原理
|
|
24
|
+
|
|
25
|
+
1. **Embed 插件**加载时(`init_order=-10`,最先执行),将装饰器注册到 `muffin_flour`
|
|
26
|
+
2. 用户定义 `Dough` 子类时,**DoughMeta** 自动从 `muffin_flour`/`muffin_water` 注入已注册的名称到模块命名空间
|
|
27
|
+
3. 用户代码无需 `import` 即可使用所有装饰器和基类
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from pancake.dough import Dough
|
|
31
|
+
|
|
32
|
+
# 定义子类后,Singleton、Service、DoughFactory 等自动可用
|
|
33
|
+
@Singleton
|
|
34
|
+
class UserService(Service):
|
|
35
|
+
async def on_init(self):
|
|
36
|
+
self.db = DoughFactory.get().resolve("DatabaseService")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 注册的名称
|
|
40
|
+
|
|
41
|
+
### 装饰器 (muffin_flour)
|
|
42
|
+
- `@Singleton` / `@Prototype` / `@Lazy` — 作用域
|
|
43
|
+
- `@DoughDecorator` — 标记类为 Bean
|
|
44
|
+
- `@DependsOn("A", "B")` — 声明依赖
|
|
45
|
+
- `@Import(Cls)` — 自动注册外部类
|
|
46
|
+
- `@Maker` / `@noMaker` — 控制方法 Bean 注册
|
|
47
|
+
- `@inject` — 自动注入依赖
|
|
48
|
+
- `@Config` — 从配置注入字段
|
|
49
|
+
|
|
50
|
+
### 基类 (muffin_water)
|
|
51
|
+
- `Configuration` — 配置类
|
|
52
|
+
- `Service` — 服务类
|
|
53
|
+
- `Function` — 方法类
|
|
54
|
+
- `Struct` — 数据结构类
|
|
55
|
+
- `DoughFactory` — Bean 工厂
|
|
56
|
+
|
|
57
|
+
## 安装
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install pancake-embed
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
或在 `pancake.xml` 中添加:
|
|
64
|
+
|
|
65
|
+
```xml
|
|
66
|
+
<dependency>
|
|
67
|
+
<groupId>io.pancake</groupId>
|
|
68
|
+
<artifactId>embed</artifactId>
|
|
69
|
+
</dependency>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 开源协议
|
|
73
|
+
|
|
74
|
+
MIT
|
|
75
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
pancake_embed/__init__.py,sha256=oXQ2wzK9Wborq-4Oxc0XCjKR9yCBjOa8CuBBXg8t0QY,1248
|
|
2
|
+
pancake_embed-0.1.0.dist-info/entry_points.txt,sha256=R4ovCfWRC9quKClnU5eB5RRlk99cMEGplCd_9R1uJmY,44
|
|
3
|
+
pancake_embed-0.1.0.dist-info/METADATA,sha256=i6lXAhFNwjZP0F1q5JAcOaPLFzz7TlQw1BEROg4_Q5M,2085
|
|
4
|
+
pancake_embed-0.1.0.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
|
|
5
|
+
pancake_embed-0.1.0.dist-info/RECORD,,
|