pancake-embed 0.1.0__tar.gz

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,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,56 @@
1
+ # Pancake Embed
2
+
3
+ > 零 import 插件 — 配合 DoughMeta 实现框架 API 自动注入
4
+
5
+ ## 工作原理
6
+
7
+ 1. **Embed 插件**加载时(`init_order=-10`,最先执行),将装饰器注册到 `muffin_flour`
8
+ 2. 用户定义 `Dough` 子类时,**DoughMeta** 自动从 `muffin_flour`/`muffin_water` 注入已注册的名称到模块命名空间
9
+ 3. 用户代码无需 `import` 即可使用所有装饰器和基类
10
+
11
+ ```python
12
+ from pancake.dough import Dough
13
+
14
+ # 定义子类后,Singleton、Service、DoughFactory 等自动可用
15
+ @Singleton
16
+ class UserService(Service):
17
+ async def on_init(self):
18
+ self.db = DoughFactory.get().resolve("DatabaseService")
19
+ ```
20
+
21
+ ## 注册的名称
22
+
23
+ ### 装饰器 (muffin_flour)
24
+ - `@Singleton` / `@Prototype` / `@Lazy` — 作用域
25
+ - `@DoughDecorator` — 标记类为 Bean
26
+ - `@DependsOn("A", "B")` — 声明依赖
27
+ - `@Import(Cls)` — 自动注册外部类
28
+ - `@Maker` / `@noMaker` — 控制方法 Bean 注册
29
+ - `@inject` — 自动注入依赖
30
+ - `@Config` — 从配置注入字段
31
+
32
+ ### 基类 (muffin_water)
33
+ - `Configuration` — 配置类
34
+ - `Service` — 服务类
35
+ - `Function` — 方法类
36
+ - `Struct` — 数据结构类
37
+ - `DoughFactory` — Bean 工厂
38
+
39
+ ## 安装
40
+
41
+ ```bash
42
+ pip install pancake-embed
43
+ ```
44
+
45
+ 或在 `pancake.xml` 中添加:
46
+
47
+ ```xml
48
+ <dependency>
49
+ <groupId>io.pancake</groupId>
50
+ <artifactId>embed</artifactId>
51
+ </dependency>
52
+ ```
53
+
54
+ ## 开源协议
55
+
56
+ MIT
@@ -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,19 @@
1
+ [tool.poetry]
2
+ name = "pancake-embed"
3
+ version = "0.1.0"
4
+ description = "Pancake Embed Plugin - 零 import 机制,将所有装饰器注入 builtins"
5
+ authors = ["drayee <1473443474@qq.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ packages = [{include = "pancake_embed"}]
9
+
10
+ [tool.poetry.dependencies]
11
+ python = "^3.10"
12
+ pancake_framework = ">=0.2.0"
13
+
14
+ [tool.poetry.plugins."pancake.plugins"]
15
+ embed = "pancake_embed:Main"
16
+
17
+ [build-system]
18
+ requires = ["poetry-core"]
19
+ build-backend = "poetry.core.masonry.api"