dougong 0.0.2 → 0.1.0

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.
Files changed (2) hide show
  1. package/README.md +101 -6
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,16 +1,111 @@
1
1
  # dougong
2
2
 
3
- Dougong 的门面包,聚合 `@dougongjs/core`、`@dougongjs/reactive` 与 `@dougongjs/platform`。
3
+ [简体中文](#简体中文) · [English](#english)
4
4
 
5
- 只做 re-export,不包含任何逻辑——架构门禁会强制这一点。
5
+ ---
6
+
7
+ ## 简体中文
8
+
9
+ **能力组合与结构化生命周期内核**,纯 JavaScript/TypeScript。
10
+
11
+ 这是门面包,聚合 [`@dougongjs/core`](https://www.npmjs.com/package/@dougongjs/core)、[`@dougongjs/reactive`](https://www.npmjs.com/package/@dougongjs/reactive) 与 [`@dougongjs/platform`](https://www.npmjs.com/package/@dougongjs/platform)。它只做 re-export,不包含任何逻辑——架构门禁会强制这一点。
12
+
13
+ ```sh
14
+ npm install dougong
15
+ ```
6
16
 
7
17
  ```ts
8
- import { createApp, definePlugin, service } from "dougong"
18
+ import { createHost, definePlugin, service } from "dougong"
19
+
20
+ const CLOCK = service<Clock>("app/clock")
21
+
22
+ const clock = definePlugin({
23
+ name: "app.clock",
24
+ provides: { clock: CLOCK },
25
+ setup: () => ({ clock: { now: () => new Date() } }),
26
+ })
27
+
28
+ const greeter = definePlugin({
29
+ name: "app.greeter",
30
+ requires: { clock: CLOCK }, // 依赖写在这里
31
+ setup(ctx) {
32
+ console.log(ctx.clock.now()) // 只能读声明过的依赖,否则编译错误
33
+ },
34
+ })
35
+
36
+ const host = createHost({ name: "hello" })
37
+ host.install(greeter) // 安装顺序不决定启动顺序
38
+ host.install(clock)
39
+ await host.start() // 从声明推导拓扑,同层并发启动
9
40
  ```
10
41
 
11
- - 文档站:https://tangerg.github.io/dougong/
12
- - 仓库:https://github.com/Tangerg/dougong
42
+ 六个原子:**Service**(稳定的一对一能力)、**ExtensionPoint**(开放贡献集合)、**Event**(瞬时事实)、**Lifetime**(结构化所有权)、**Plugin**、**Host**。
43
+
44
+ 三条核心保证:依赖与所有权**显式**写在声明里;每个语义只有**一条**正式路径;事务只暴露**已提交**状态。
45
+
46
+ ### 环境要求
47
+
48
+ Node.js ≥ 22 或等价的 ES2024 运行时。TypeScript 消费者需要:
49
+
50
+ ```json
51
+ "lib": ["ES2024", "DOM", "DOM.Iterable", "ESNext.Disposable"]
52
+ ```
53
+
54
+ ---
55
+
56
+ ## English
57
+
58
+ A **capability composition and structured lifetime kernel** in pure JavaScript/TypeScript.
59
+
60
+ This is the facade package aggregating [`@dougongjs/core`](https://www.npmjs.com/package/@dougongjs/core), [`@dougongjs/reactive`](https://www.npmjs.com/package/@dougongjs/reactive) and [`@dougongjs/platform`](https://www.npmjs.com/package/@dougongjs/platform). It only re-exports and contains no logic — an architecture gate enforces that.
61
+
62
+ ```sh
63
+ npm install dougong
64
+ ```
65
+
66
+ ```ts
67
+ import { createHost, definePlugin, service } from "dougong"
68
+
69
+ const CLOCK = service<Clock>("app/clock")
70
+
71
+ const clock = definePlugin({
72
+ name: "app.clock",
73
+ provides: { clock: CLOCK },
74
+ setup: () => ({ clock: { now: () => new Date() } }),
75
+ })
76
+
77
+ const greeter = definePlugin({
78
+ name: "app.greeter",
79
+ requires: { clock: CLOCK }, // the dependency lives here
80
+ setup(ctx) {
81
+ console.log(ctx.clock.now()) // only declared dependencies exist, or it fails to compile
82
+ },
83
+ })
84
+
85
+ const host = createHost({ name: "hello" })
86
+ host.install(greeter) // install order does not decide start order
87
+ host.install(clock)
88
+ await host.start() // topology derived from declarations, layers start concurrently
89
+ ```
90
+
91
+ Six atoms: **Service** (a stable one-to-one capability), **ExtensionPoint** (an open contribution set), **Event** (a transient fact), **Lifetime** (structured ownership), **Plugin**, **Host**.
92
+
93
+ Three core guarantees: dependencies and ownership are written **explicitly** in declarations; every semantic has exactly **one** canonical path; transactions expose only **committed** state.
94
+
95
+ ### Requirements
96
+
97
+ Node.js ≥ 22 or an equivalent ES2024 runtime. TypeScript consumers need:
98
+
99
+ ```json
100
+ "lib": ["ES2024", "DOM", "DOM.Iterable", "ESNext.Disposable"]
101
+ ```
102
+
103
+ ---
104
+
105
+ - 文档站 / Documentation: https://tangerg.github.io/dougong/
106
+ - 仓库 / Repository: https://github.com/Tangerg/dougong
13
107
 
14
- > 早期开发阶段(0.0.x),当前不承诺向后兼容。需要 Node.js >= 22 或等价的 ES2024 宿主。
108
+ > 早期开发阶段(0.0.x),当前不承诺向后兼容。
109
+ > Early development (0.0.x); no backward-compatibility promises yet.
15
110
 
16
111
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dougong",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -18,9 +18,9 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@dougongjs/core": "0.0.2",
22
- "@dougongjs/platform": "0.0.2",
23
- "@dougongjs/reactive": "0.0.2"
21
+ "@dougongjs/platform": "0.1.0",
22
+ "@dougongjs/core": "0.1.0",
23
+ "@dougongjs/reactive": "0.1.0"
24
24
  },
25
25
  "description": "Capability composition and structured lifetime kernel, plus its plugin distribution layer.",
26
26
  "license": "MIT",