@celljs/core 4.0.0 → 4.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.
- package/README.md +0 -6
- package/esm/common/application/application-protocol.js +1 -1
- package/esm/common/application/application-protocol.js.map +1 -1
- package/esm/common/config/config-provider.js +2 -1
- package/esm/common/config/config-provider.js.map +1 -1
- package/esm/common/container/auto-bind.js +26 -12
- package/esm/common/container/auto-bind.js.map +1 -1
- package/esm/common/el/expression-compiler.d.ts +4 -15
- package/esm/common/el/expression-compiler.js +6 -163
- package/esm/common/el/expression-compiler.js.map +1 -1
- package/esm/common/el/expression-handler.d.ts +7 -2
- package/esm/common/el/expression-handler.js +14 -53
- package/esm/common/el/expression-handler.js.map +1 -1
- package/esm/common/el/expression-util.d.ts +68 -0
- package/esm/common/el/expression-util.js +347 -0
- package/esm/common/el/expression-util.js.map +1 -0
- package/esm/common/el/index.d.ts +1 -0
- package/esm/common/el/index.js +1 -0
- package/esm/common/el/index.js.map +1 -1
- package/esm/common/logger/abstract-logger.d.ts +4 -2
- package/esm/common/logger/abstract-logger.js +11 -6
- package/esm/common/logger/abstract-logger.js.map +1 -1
- package/esm/common/logger/logger-protocol.d.ts +4 -0
- package/esm/common/logger/logger-protocol.js +2 -0
- package/esm/common/logger/logger-protocol.js.map +1 -1
- package/esm/common/logger/logger.js +7 -7
- package/esm/common/logger/logger.js.map +1 -1
- package/esm/common/test/mock-logger.d.ts +1 -0
- package/esm/common/test/mock-logger.js +3 -0
- package/esm/common/test/mock-logger.js.map +1 -1
- package/esm/common/utils/emitter.d.ts +1 -10
- package/esm/common/utils/emitter.js +0 -56
- package/esm/common/utils/emitter.js.map +1 -1
- package/esm/common/utils/mime-type-util.js +1 -1
- package/esm/common/utils/mime-type-util.js.map +1 -1
- package/esm/common/utils/mime-type.js +1 -1
- package/esm/common/utils/mime-type.js.map +1 -1
- package/esm/node/context/context.d.ts +11 -2
- package/esm/node/context/context.js +36 -12
- package/esm/node/context/context.js.map +1 -1
- package/esm/node/index.d.ts +0 -1
- package/esm/node/index.js +0 -1
- package/esm/node/index.js.map +1 -1
- package/lib/common/aop/aop.spec.d.ts +2 -0
- package/lib/common/aop/aop.spec.d.ts.map +1 -0
- package/lib/common/aop/aop.spec.js +170 -0
- package/lib/common/aop/aop.spec.js.map +1 -0
- package/lib/common/application/application-protocol.js +1 -1
- package/lib/common/application/application-protocol.js.map +1 -1
- package/lib/common/application/lifecycle.spec.d.ts +2 -0
- package/lib/common/application/lifecycle.spec.d.ts.map +1 -0
- package/lib/common/application/lifecycle.spec.js +155 -0
- package/lib/common/application/lifecycle.spec.js.map +1 -0
- package/lib/common/config/config-provider.js +2 -1
- package/lib/common/config/config-provider.js.map +1 -1
- package/lib/common/container/assembly.spec.d.ts +2 -0
- package/lib/common/container/assembly.spec.d.ts.map +1 -0
- package/lib/common/container/assembly.spec.js +464 -0
- package/lib/common/container/assembly.spec.js.map +1 -0
- package/lib/common/container/auto-bind.js +26 -12
- package/lib/common/container/auto-bind.js.map +1 -1
- package/lib/common/el/expression-compiler.d.ts +4 -15
- package/lib/common/el/expression-compiler.d.ts.map +1 -1
- package/lib/common/el/expression-compiler.js +6 -163
- package/lib/common/el/expression-compiler.js.map +1 -1
- package/lib/common/el/expression-handler.d.ts +7 -2
- package/lib/common/el/expression-handler.d.ts.map +1 -1
- package/lib/common/el/expression-handler.js +14 -56
- package/lib/common/el/expression-handler.js.map +1 -1
- package/lib/common/el/expression-handler.spec.d.ts +2 -0
- package/lib/common/el/expression-handler.spec.d.ts.map +1 -0
- package/lib/common/el/expression-handler.spec.js +99 -0
- package/lib/common/el/expression-handler.spec.js.map +1 -0
- package/lib/common/el/expression-util.d.ts +69 -0
- package/lib/common/el/expression-util.d.ts.map +1 -0
- package/lib/common/el/expression-util.js +352 -0
- package/lib/common/el/expression-util.js.map +1 -0
- package/lib/common/el/expression-util.spec.d.ts +2 -0
- package/lib/common/el/expression-util.spec.d.ts.map +1 -0
- package/lib/common/el/expression-util.spec.js +45 -0
- package/lib/common/el/expression-util.spec.js.map +1 -0
- package/lib/common/el/index.d.ts +1 -0
- package/lib/common/el/index.d.ts.map +1 -1
- package/lib/common/el/index.js +1 -0
- package/lib/common/el/index.js.map +1 -1
- package/lib/common/el/value-and-el.spec.d.ts +2 -0
- package/lib/common/el/value-and-el.spec.d.ts.map +1 -0
- package/lib/common/el/value-and-el.spec.js +216 -0
- package/lib/common/el/value-and-el.spec.js.map +1 -0
- package/lib/common/logger/abstract-logger.d.ts +4 -2
- package/lib/common/logger/abstract-logger.d.ts.map +1 -1
- package/lib/common/logger/abstract-logger.js +10 -5
- package/lib/common/logger/abstract-logger.js.map +1 -1
- package/lib/common/logger/logger-protocol.d.ts +4 -0
- package/lib/common/logger/logger-protocol.d.ts.map +1 -1
- package/lib/common/logger/logger-protocol.js +3 -1
- package/lib/common/logger/logger-protocol.js.map +1 -1
- package/lib/common/logger/logger.js +7 -7
- package/lib/common/logger/logger.js.map +1 -1
- package/lib/common/logger/logger.spec.d.ts +2 -0
- package/lib/common/logger/logger.spec.d.ts.map +1 -0
- package/lib/common/logger/logger.spec.js +57 -0
- package/lib/common/logger/logger.spec.js.map +1 -0
- package/lib/common/test/mock-logger.d.ts +1 -0
- package/lib/common/test/mock-logger.d.ts.map +1 -1
- package/lib/common/test/mock-logger.js +3 -0
- package/lib/common/test/mock-logger.js.map +1 -1
- package/lib/common/utils/emitter.d.ts +1 -10
- package/lib/common/utils/emitter.d.ts.map +1 -1
- package/lib/common/utils/emitter.js +1 -58
- package/lib/common/utils/emitter.js.map +1 -1
- package/lib/common/utils/mime-type-util.js +1 -1
- package/lib/common/utils/mime-type-util.js.map +1 -1
- package/lib/common/utils/mime-type.js +1 -1
- package/lib/common/utils/mime-type.js.map +1 -1
- package/lib/common/utils/utils-behavior.spec.d.ts +2 -0
- package/lib/common/utils/utils-behavior.spec.d.ts.map +1 -0
- package/lib/common/utils/utils-behavior.spec.js +232 -0
- package/lib/common/utils/utils-behavior.spec.js.map +1 -0
- package/lib/node/context/context.d.ts +11 -2
- package/lib/node/context/context.d.ts.map +1 -1
- package/lib/node/context/context.js +36 -10
- package/lib/node/context/context.js.map +1 -1
- package/lib/node/context/context.spec.d.ts +2 -0
- package/lib/node/context/context.spec.d.ts.map +1 -0
- package/lib/node/context/context.spec.js +202 -0
- package/lib/node/context/context.spec.js.map +1 -0
- package/lib/node/index.d.ts +0 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -1
- package/lib/node/index.js.map +1 -1
- package/package.json +7 -17
- package/src/common/aop/aop.spec.ts +145 -0
- package/src/common/application/application-protocol.ts +1 -1
- package/src/common/application/lifecycle.spec.ts +148 -0
- package/src/common/config/config-provider.ts +1 -1
- package/src/common/container/assembly.spec.ts +293 -0
- package/src/common/container/auto-bind.ts +23 -10
- package/src/common/el/expression-compiler.ts +6 -166
- package/src/common/el/expression-handler.spec.ts +110 -0
- package/src/common/el/expression-handler.ts +14 -51
- package/src/common/el/expression-util.spec.ts +45 -0
- package/src/common/el/expression-util.ts +363 -0
- package/src/common/el/index.ts +2 -1
- package/src/common/el/value-and-el.spec.ts +186 -0
- package/src/common/logger/abstract-logger.ts +12 -6
- package/src/common/logger/logger-protocol.ts +5 -0
- package/src/common/logger/logger.spec.ts +61 -0
- package/src/common/logger/logger.ts +7 -7
- package/src/common/test/mock-logger.ts +3 -0
- package/src/common/utils/emitter.ts +1 -63
- package/src/common/utils/mime-type-util.ts +1 -1
- package/src/common/utils/mime-type.ts +1 -1
- package/src/common/utils/utils-behavior.spec.ts +259 -0
- package/src/node/context/context.spec.ts +219 -0
- package/src/node/context/context.ts +35 -10
- package/src/node/index.ts +0 -1
- package/esm/node/utils/crc.d.ts +0 -1
- package/esm/node/utils/crc.js +0 -7
- package/esm/node/utils/crc.js.map +0 -1
- package/esm/node/utils/index.d.ts +0 -1
- package/esm/node/utils/index.js +0 -2
- package/esm/node/utils/index.js.map +0 -1
- package/lib/node/utils/crc.d.ts +0 -2
- package/lib/node/utils/crc.d.ts.map +0 -1
- package/lib/node/utils/crc.js +0 -10
- package/lib/node/utils/crc.js.map +0 -1
- package/lib/node/utils/index.d.ts +0 -2
- package/lib/node/utils/index.d.ts.map +0 -1
- package/lib/node/utils/index.js +0 -18
- package/lib/node/utils/index.js.map +0 -1
- package/src/node/utils/crc.ts +0 -7
- package/src/node/utils/index.ts +0 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
/**
|
|
7
|
+
* 请求上下文的约定,与实现无关(以前是 cls-hooked,现在是 AsyncLocalStorage)。
|
|
8
|
+
*
|
|
9
|
+
* cls-hooked 下这些用例有 4 条失败(2026-11-08 在 Node 24.13 和 Bun 1.3.11 上实测):run 里设置的上下文泄漏给
|
|
10
|
+
* await 它的调用方;Node 下外层 await 内层 run 之后看到内层的上下文;Bun 下并发的 run 之间没有隔离(请求之间串上下文);
|
|
11
|
+
* Context.run 没有返回值。换成 AsyncLocalStorage 之后全部通过。同一组场景在 Node 上的结果见
|
|
12
|
+
* cell-refactor/stage0/context-isolation/。
|
|
13
|
+
*/
|
|
14
|
+
const tick = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
+
/** 在 Context.run 里执行 fn,并等它完成。不依赖 run 的返回值,所以同一组用例也能验证以前没有返回值的实现。 */
|
|
16
|
+
function inRun(fn) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
context_1.Context.run(async () => {
|
|
19
|
+
try {
|
|
20
|
+
resolve(await fn());
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function named(name) {
|
|
29
|
+
const ctx = new context_1.Context();
|
|
30
|
+
ctx.name = name;
|
|
31
|
+
return ctx;
|
|
32
|
+
}
|
|
33
|
+
(0, bun_test_1.describe)('Context', () => {
|
|
34
|
+
(0, bun_test_1.it)('run 之外没有当前上下文', () => {
|
|
35
|
+
(0, chai_1.expect)(context_1.Context.getCurrent()).to.equal(undefined);
|
|
36
|
+
});
|
|
37
|
+
(0, bun_test_1.it)('run 里设置的上下文在 await、setTimeout 和 Promise 链之后仍然可见', async () => {
|
|
38
|
+
const ctx = named('a');
|
|
39
|
+
const seen = await inRun(async () => {
|
|
40
|
+
context_1.Context.setCurrent(ctx);
|
|
41
|
+
await tick();
|
|
42
|
+
const afterTimer = await new Promise(resolve => setTimeout(() => resolve(context_1.Context.getCurrent()), 1));
|
|
43
|
+
const afterChain = await Promise.resolve()
|
|
44
|
+
.then(() => tick())
|
|
45
|
+
.then(() => context_1.Context.getCurrent());
|
|
46
|
+
return [context_1.Context.getCurrent(), afterTimer, afterChain];
|
|
47
|
+
});
|
|
48
|
+
(0, chai_1.expect)(seen).to.deep.equal([ctx, ctx, ctx]);
|
|
49
|
+
(0, chai_1.expect)(seen.every(c => c === ctx)).to.equal(true);
|
|
50
|
+
});
|
|
51
|
+
(0, bun_test_1.it)('run 结束后上下文不会泄漏给 await 它的调用方', async () => {
|
|
52
|
+
await inRun(async () => {
|
|
53
|
+
context_1.Context.setCurrent(named('a'));
|
|
54
|
+
});
|
|
55
|
+
(0, chai_1.expect)(context_1.Context.getCurrent()).to.equal(undefined);
|
|
56
|
+
});
|
|
57
|
+
(0, bun_test_1.describe)('嵌套', () => {
|
|
58
|
+
(0, bun_test_1.it)('内层设置自己的上下文,不影响外层', async () => {
|
|
59
|
+
const outer = named('outer');
|
|
60
|
+
const inner = named('inner');
|
|
61
|
+
const seen = await inRun(async () => {
|
|
62
|
+
context_1.Context.setCurrent(outer);
|
|
63
|
+
const inside = await inRun(async () => {
|
|
64
|
+
context_1.Context.setCurrent(inner);
|
|
65
|
+
await tick();
|
|
66
|
+
return context_1.Context.getCurrent();
|
|
67
|
+
});
|
|
68
|
+
await tick();
|
|
69
|
+
return { inside, after: context_1.Context.getCurrent() };
|
|
70
|
+
});
|
|
71
|
+
(0, chai_1.expect)(seen.inside).to.equal(inner);
|
|
72
|
+
(0, chai_1.expect)(seen.after).to.equal(outer);
|
|
73
|
+
});
|
|
74
|
+
// 4.x 兼容语义(cls-hooked 一直如此):4.x 不改行为,AsyncLocalStorage 实现以外层的值为原型创建内层的值来保持它;5.0 再评估。
|
|
75
|
+
(0, bun_test_1.it)('内层在设置自己的上下文之前继承外层的上下文', async () => {
|
|
76
|
+
const outer = named('outer');
|
|
77
|
+
const inherited = await inRun(async () => {
|
|
78
|
+
context_1.Context.setCurrent(outer);
|
|
79
|
+
return inRun(async () => context_1.Context.getCurrent());
|
|
80
|
+
});
|
|
81
|
+
(0, chai_1.expect)(inherited).to.equal(outer);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
(0, bun_test_1.it)('并发的 run 互相隔离', async () => {
|
|
85
|
+
const contexts = Array.from({ length: 50 }, (_, i) => named(`c${i}`));
|
|
86
|
+
const seen = await Promise.all(contexts.map((ctx, i) => inRun(async () => {
|
|
87
|
+
context_1.Context.setCurrent(ctx);
|
|
88
|
+
await tick(i % 7);
|
|
89
|
+
const first = context_1.Context.getCurrent();
|
|
90
|
+
await tick((i * 3) % 5);
|
|
91
|
+
return [first, context_1.Context.getCurrent()];
|
|
92
|
+
})));
|
|
93
|
+
seen.forEach(([first, second], i) => {
|
|
94
|
+
(0, chai_1.expect)(first).to.equal(contexts[i]);
|
|
95
|
+
(0, chai_1.expect)(second).to.equal(contexts[i]);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
(0, bun_test_1.it)('run 之外 setCurrent 抛错', () => {
|
|
99
|
+
(0, chai_1.expect)(() => context_1.Context.setCurrent(new context_1.Context())).to.throw('No context available');
|
|
100
|
+
});
|
|
101
|
+
(0, bun_test_1.it)('Context.run 的 Promise 以 fn 的返回值 resolve', async () => {
|
|
102
|
+
(0, chai_1.expect)(await context_1.Context.run(async () => 42)).to.equal(42);
|
|
103
|
+
(0, chai_1.expect)(await context_1.Context.run(() => 'sync')).to.equal('sync');
|
|
104
|
+
});
|
|
105
|
+
(0, bun_test_1.it)('bind 的函数在 run 结束后调用,仍然看到绑定时的上下文', async () => {
|
|
106
|
+
const ctx = named('bound');
|
|
107
|
+
const bound = await inRun(async () => {
|
|
108
|
+
context_1.Context.setCurrent(ctx);
|
|
109
|
+
return context_1.Context.bind(() => context_1.Context.getCurrent());
|
|
110
|
+
});
|
|
111
|
+
(0, chai_1.expect)(bound()).to.equal(ctx);
|
|
112
|
+
(0, chai_1.expect)(await new Promise(resolve => setTimeout(() => resolve(bound()), 1))).to.equal(ctx);
|
|
113
|
+
});
|
|
114
|
+
(0, bun_test_1.describe)('异常', () => {
|
|
115
|
+
(0, bun_test_1.it)('run 里捕获的异常不影响当前上下文', async () => {
|
|
116
|
+
const ctx = named('a');
|
|
117
|
+
const seen = await inRun(async () => {
|
|
118
|
+
context_1.Context.setCurrent(ctx);
|
|
119
|
+
try {
|
|
120
|
+
await tick();
|
|
121
|
+
throw new Error('boom');
|
|
122
|
+
}
|
|
123
|
+
catch (_a) {
|
|
124
|
+
// 被调用方吞掉
|
|
125
|
+
}
|
|
126
|
+
return context_1.Context.getCurrent();
|
|
127
|
+
});
|
|
128
|
+
(0, chai_1.expect)(seen).to.equal(ctx);
|
|
129
|
+
});
|
|
130
|
+
(0, bun_test_1.it)('内层 run 的异常传到外层,外层上下文不变', async () => {
|
|
131
|
+
const outer = named('outer');
|
|
132
|
+
const boom = new Error('boom');
|
|
133
|
+
const seen = await inRun(async () => {
|
|
134
|
+
context_1.Context.setCurrent(outer);
|
|
135
|
+
let caught;
|
|
136
|
+
try {
|
|
137
|
+
await inRun(async () => {
|
|
138
|
+
context_1.Context.setCurrent(named('inner'));
|
|
139
|
+
await tick();
|
|
140
|
+
throw boom;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
caught = error;
|
|
145
|
+
}
|
|
146
|
+
return { caught, after: context_1.Context.getCurrent() };
|
|
147
|
+
});
|
|
148
|
+
(0, chai_1.expect)(seen.caught).to.equal(boom);
|
|
149
|
+
(0, chai_1.expect)(seen.after).to.equal(outer);
|
|
150
|
+
});
|
|
151
|
+
(0, bun_test_1.it)('Context.run 返回 Promise,fn 的异常让它 reject', async () => {
|
|
152
|
+
const boom = new Error('boom');
|
|
153
|
+
const result = context_1.Context.run(async () => {
|
|
154
|
+
throw boom;
|
|
155
|
+
});
|
|
156
|
+
(0, chai_1.expect)(result).to.be.instanceOf(Promise);
|
|
157
|
+
let caught;
|
|
158
|
+
await result.catch(error => {
|
|
159
|
+
caught = error;
|
|
160
|
+
});
|
|
161
|
+
(0, chai_1.expect)(caught).to.equal(boom);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
(0, bun_test_1.describe)('属性', () => {
|
|
165
|
+
(0, bun_test_1.it)('Request 作用域的属性只在本次 run 里可见,App 作用域跨 run 可见', async () => {
|
|
166
|
+
const key = `attr-${Date.now()}`;
|
|
167
|
+
await inRun(async () => {
|
|
168
|
+
context_1.Context.setCurrent(new context_1.Context());
|
|
169
|
+
context_1.Context.setAttr(key, 'request');
|
|
170
|
+
context_1.Context.setAttr(`${key}-app`, 'app', context_1.AttributeScope.App);
|
|
171
|
+
(0, chai_1.expect)(context_1.Context.getAttr(key, context_1.AttributeScope.Request)).to.equal('request');
|
|
172
|
+
});
|
|
173
|
+
const other = await inRun(async () => {
|
|
174
|
+
context_1.Context.setCurrent(new context_1.Context());
|
|
175
|
+
return [context_1.Context.getAttr(key, context_1.AttributeScope.Request), context_1.Context.getAttr(`${key}-app`, context_1.AttributeScope.App)];
|
|
176
|
+
});
|
|
177
|
+
(0, chai_1.expect)(other).to.deep.equal([undefined, 'app']);
|
|
178
|
+
});
|
|
179
|
+
(0, bun_test_1.it)('不指定作用域时先找 Request,再找 App', async () => {
|
|
180
|
+
const key = `fallback-${Date.now()}`;
|
|
181
|
+
context_1.Context.setAttr(key, 'app', context_1.AttributeScope.App);
|
|
182
|
+
const seen = await inRun(async () => {
|
|
183
|
+
context_1.Context.setCurrent(new context_1.Context());
|
|
184
|
+
const before = context_1.Context.getAttr(key);
|
|
185
|
+
context_1.Context.setAttr(key, 'request');
|
|
186
|
+
return [before, context_1.Context.getAttr(key)];
|
|
187
|
+
});
|
|
188
|
+
(0, chai_1.expect)(seen).to.deep.equal(['app', 'request']);
|
|
189
|
+
});
|
|
190
|
+
(0, bun_test_1.it)('AttributeScope.App 只读 App 作用域(App 的枚举值是 0,不能当成“不指定”)', async () => {
|
|
191
|
+
const key = `app-only-${Date.now()}`;
|
|
192
|
+
context_1.Context.setAttr(key, 'app', context_1.AttributeScope.App);
|
|
193
|
+
const seen = await inRun(async () => {
|
|
194
|
+
context_1.Context.setCurrent(new context_1.Context());
|
|
195
|
+
context_1.Context.setAttr(key, 'request');
|
|
196
|
+
return [context_1.Context.getAttr(key, context_1.AttributeScope.App), context_1.Context.getAttr(key, context_1.AttributeScope.Request)];
|
|
197
|
+
});
|
|
198
|
+
(0, chai_1.expect)(seen).to.deep.equal(['app', 'request']);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
//# sourceMappingURL=context.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.spec.js","sourceRoot":"","sources":["../../../src/node/context/context.spec.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,+BAA8B;AAC9B,uCAAoD;AAEpD;;;;;;;GAOG;AAEH,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEzE,qEAAqE;AACrE,SAAS,KAAK,CAAI,EAAoB;IAClC,OAAO,I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IAAI,GAAG,MAAM,KAAK,CAAC,KAAK,IAAI,EAAE;gBAChC,iBAAO,CAAC,UAAU,CAAC,IAAI,iBAAO,EAAE,CAAC,CAAC;gBAClC,iBAAO,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBAChC,OAAO,CAAC,iBAAO,CAAC,OAAO,CAAC,GAAG,EAAE,wBAAc,CAAC,GAAG,CAAC,EAAE,iBAAO,CAAC,OAAO,CAAC,GAAG,EAAE,wBAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACpG,CAAC,CAAC,CAAC;YACH,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/lib/node/index.d.ts
CHANGED
package/lib/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
package/lib/node/index.js
CHANGED
|
@@ -16,5 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./application"), exports);
|
|
18
18
|
__exportStar(require("./context"), exports);
|
|
19
|
-
__exportStar(require("./utils"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/lib/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -30,22 +30,12 @@
|
|
|
30
30
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@types/lodash.debounce": "4.0.3",
|
|
34
|
-
"@types/lodash.throttle": "^4.1.3",
|
|
35
|
-
"cls-hooked": "^4.2.2",
|
|
36
33
|
"inversify": "6.1.4",
|
|
37
34
|
"jexl": "2.3.0",
|
|
38
|
-
"
|
|
39
|
-
"lodash.throttle": "^4.1.1",
|
|
40
|
-
"reflect-metadata": "^0.1.13",
|
|
41
|
-
"setimmediate": "^1.0.5",
|
|
42
|
-
"source-map-support": "^0.5.13",
|
|
43
|
-
"traverse": "^0.6.7",
|
|
44
|
-
"tslib": "^2.8.0"
|
|
35
|
+
"reflect-metadata": "^0.1.13"
|
|
45
36
|
},
|
|
46
37
|
"devDependencies": {
|
|
47
|
-
"@types/jexl": "^2.2.0"
|
|
48
|
-
"@types/traverse": "^0.6.32"
|
|
38
|
+
"@types/jexl": "^2.2.0"
|
|
49
39
|
},
|
|
50
40
|
"publishConfig": {
|
|
51
41
|
"access": "public"
|
|
@@ -56,6 +46,10 @@
|
|
|
56
46
|
"default": "./lib/common/index.js"
|
|
57
47
|
},
|
|
58
48
|
"./package.json": "./package.json",
|
|
49
|
+
"./el": {
|
|
50
|
+
"import": "./esm/common/el/expression-util.js",
|
|
51
|
+
"default": "./lib/common/el/expression-util.js"
|
|
52
|
+
},
|
|
59
53
|
"./lib/browser": {
|
|
60
54
|
"import": "./esm/browser/index.js",
|
|
61
55
|
"default": "./lib/browser/index.js"
|
|
@@ -132,10 +126,6 @@
|
|
|
132
126
|
"import": "./esm/node/context/index.js",
|
|
133
127
|
"default": "./lib/node/context/index.js"
|
|
134
128
|
},
|
|
135
|
-
"./lib/node/utils": {
|
|
136
|
-
"import": "./esm/node/utils/index.js",
|
|
137
|
-
"default": "./lib/node/utils/index.js"
|
|
138
|
-
},
|
|
139
129
|
"./lib/*.js": {
|
|
140
130
|
"import": "./esm/*.js",
|
|
141
131
|
"default": "./lib/*.js"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, it } from 'bun:test';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { ApplicationFactory } from '../application/application-factory';
|
|
4
|
+
import { Component, Aspect } from '../annotation';
|
|
5
|
+
import { ContainerUtil } from '../container/container-util';
|
|
6
|
+
import { MethodBeforeAdvice, AfterReturningAdvice, AfterThrowsAdvice } from './aop-protocol';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* AOP 的约定(阶段 1.E 行为测试):@Aspect 登记通知,proxy: true 的组件被代理。
|
|
10
|
+
* 需要 cell.aop.enabled(core 的 cell.yml 默认 true;这里直接放进配置)。
|
|
11
|
+
*/
|
|
12
|
+
const AOP_ON = { cell: { aop: { enabled: true } } };
|
|
13
|
+
|
|
14
|
+
function recordingAspects(log: string[], pointcut?: string) {
|
|
15
|
+
const opt = <T>(id: T) => (pointcut ? { id, pointcut } : id) as any;
|
|
16
|
+
@Aspect(opt(MethodBeforeAdvice))
|
|
17
|
+
class Before implements MethodBeforeAdvice {
|
|
18
|
+
async before(method: string | number | symbol, args: any[]) {
|
|
19
|
+
log.push(`before:${String(method)}(${args.join(',')})`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
@Aspect(opt(AfterReturningAdvice))
|
|
23
|
+
class AfterReturning implements AfterReturningAdvice {
|
|
24
|
+
async afterReturning(returnValue: any, method: string | number | symbol) {
|
|
25
|
+
log.push(`after:${String(method)}=${returnValue}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
@Aspect(opt(AfterThrowsAdvice))
|
|
29
|
+
class AfterThrows implements AfterThrowsAdvice {
|
|
30
|
+
async afterThrows(error: any, method: string | number | symbol) {
|
|
31
|
+
log.push(`throws:${String(method)}:${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return [Before, AfterReturning, AfterThrows];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('core AOP', () => {
|
|
38
|
+
|
|
39
|
+
it('proxy: true 的组件:before → 方法 → afterReturning,通知拿到方法名、参数和返回值', async () => {
|
|
40
|
+
const log: string[] = [];
|
|
41
|
+
recordingAspects(log);
|
|
42
|
+
@Component({ proxy: true })
|
|
43
|
+
class Calc {
|
|
44
|
+
async add(a: number, b: number) {
|
|
45
|
+
log.push('run');
|
|
46
|
+
return a + b;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await ApplicationFactory.create(AOP_ON);
|
|
50
|
+
expect(await ContainerUtil.get(Calc).add(1, 2)).to.equal(3);
|
|
51
|
+
expect(log).to.deep.equal(['before:add(1,2)', 'run', 'after:add=3']);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('方法抛错:调用 afterThrows,然后把原错误抛给调用方,不调用 afterReturning', async () => {
|
|
55
|
+
const log: string[] = [];
|
|
56
|
+
recordingAspects(log);
|
|
57
|
+
@Component({ proxy: true })
|
|
58
|
+
class Failing {
|
|
59
|
+
async go() {
|
|
60
|
+
throw new Error('nope');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
await ApplicationFactory.create(AOP_ON);
|
|
64
|
+
let caught: Error | undefined;
|
|
65
|
+
try {
|
|
66
|
+
await ContainerUtil.get(Failing).go();
|
|
67
|
+
} catch (e) {
|
|
68
|
+
caught = e as Error;
|
|
69
|
+
}
|
|
70
|
+
expect(caught?.message).to.equal('nope');
|
|
71
|
+
expect(log).to.deep.equal(['before:go()', 'throws:go:nope']);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('现状:被代理后,同步方法也变成返回 Promise', async () => {
|
|
75
|
+
const log: string[] = [];
|
|
76
|
+
recordingAspects(log);
|
|
77
|
+
@Component({ proxy: true })
|
|
78
|
+
class Sync {
|
|
79
|
+
twice(n: number) { return n * 2; }
|
|
80
|
+
}
|
|
81
|
+
await ApplicationFactory.create(AOP_ON);
|
|
82
|
+
const result = ContainerUtil.get(Sync).twice(4) as unknown;
|
|
83
|
+
expect(result).to.be.instanceOf(Promise);
|
|
84
|
+
expect(await result).to.equal(8);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('没有 proxy: true 的组件不被代理;cell.aop.enabled 为 false 时也不代理', async () => {
|
|
88
|
+
const log: string[] = [];
|
|
89
|
+
recordingAspects(log);
|
|
90
|
+
@Component()
|
|
91
|
+
class NotProxied {
|
|
92
|
+
hi() { return 'hi'; }
|
|
93
|
+
}
|
|
94
|
+
await ApplicationFactory.create(AOP_ON);
|
|
95
|
+
expect(ContainerUtil.get(NotProxied).hi()).to.equal('hi');
|
|
96
|
+
|
|
97
|
+
recordingAspects(log);
|
|
98
|
+
@Component({ proxy: true })
|
|
99
|
+
class Disabled {
|
|
100
|
+
hi() { return 'hi'; }
|
|
101
|
+
}
|
|
102
|
+
await ApplicationFactory.create({ cell: { aop: { enabled: false } } });
|
|
103
|
+
expect(ContainerUtil.get(Disabled).hi()).to.equal('hi');
|
|
104
|
+
expect(log).to.deep.equal([]);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('没有任何通知时,proxy: true 的组件也不代理(ClassFilter 不匹配)', async () => {
|
|
108
|
+
@Component({ proxy: true })
|
|
109
|
+
class Lonely {
|
|
110
|
+
hi() { return 'hi'; }
|
|
111
|
+
}
|
|
112
|
+
await ApplicationFactory.create(AOP_ON);
|
|
113
|
+
expect(ContainerUtil.get(Lonely).hi()).to.equal('hi');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('pointcut:只作用于 sysTags 里带该标签的组件', async () => {
|
|
117
|
+
const log: string[] = [];
|
|
118
|
+
recordingAspects(log, 'Audited');
|
|
119
|
+
@Component({ proxy: true, sysTags: ['Audited'] })
|
|
120
|
+
class Audited {
|
|
121
|
+
async save(x: string) { return `saved ${x}`; }
|
|
122
|
+
}
|
|
123
|
+
@Component({ proxy: true })
|
|
124
|
+
class Other {
|
|
125
|
+
save(x: string) { return `other ${x}`; }
|
|
126
|
+
}
|
|
127
|
+
await ApplicationFactory.create(AOP_ON);
|
|
128
|
+
expect(await ContainerUtil.get(Audited).save('a')).to.equal('saved a');
|
|
129
|
+
expect(ContainerUtil.get(Other).save('b')).to.equal('other b');
|
|
130
|
+
expect(log).to.deep.equal(['before:save(a)', 'after:save=saved a']);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('非函数属性原样透出', async () => {
|
|
134
|
+
const log: string[] = [];
|
|
135
|
+
recordingAspects(log);
|
|
136
|
+
@Component({ proxy: true })
|
|
137
|
+
class WithField {
|
|
138
|
+
readonly label = 'L';
|
|
139
|
+
async m() { return 1; }
|
|
140
|
+
}
|
|
141
|
+
await ApplicationFactory.create(AOP_ON);
|
|
142
|
+
expect(ContainerUtil.get(WithField).label).to.equal('L');
|
|
143
|
+
expect(log).to.deep.equal([]);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -113,7 +113,7 @@ export abstract class AbstractApplicationStateService<T extends string> implemen
|
|
|
113
113
|
|
|
114
114
|
set state(state: T) {
|
|
115
115
|
if (state !== this._state) {
|
|
116
|
-
|
|
116
|
+
// A state that was reached stays reached: late `reachedState()` calls resolve at once.
|
|
117
117
|
this._state = state;
|
|
118
118
|
if (this.deferred[state] === undefined) {
|
|
119
119
|
this.deferred[state] = new Deferred();
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { describe, it } from 'bun:test';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { ApplicationFactory } from './application-factory';
|
|
4
|
+
import { ApplicationLifecycle, ApplicationStateService, ApplicationState, Application } from './application-protocol';
|
|
5
|
+
import { Component } from '../annotation';
|
|
6
|
+
import { ContainerUtil } from '../container/container-util';
|
|
7
|
+
import { Scope } from '../container/scope';
|
|
8
|
+
import { Logger } from '../logger/logger-protocol';
|
|
9
|
+
import { MockLogger } from '../test/mock-logger';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 应用生命周期的约定(阶段 1.E 行为测试):ApplicationLifecycle 的调用顺序、出错时的行为、状态变化。
|
|
13
|
+
*/
|
|
14
|
+
interface Recorder { events: string[], errors: string[] }
|
|
15
|
+
|
|
16
|
+
function recordingLogger(rec: Recorder) {
|
|
17
|
+
@Component({ id: Logger, rebind: true, scope: Scope.Transient })
|
|
18
|
+
class RecordingLogger extends MockLogger {
|
|
19
|
+
override error(message: any): void {
|
|
20
|
+
rec.errors.push(String(message));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return RecordingLogger;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('core 应用生命周期', () => {
|
|
27
|
+
|
|
28
|
+
it('start():先调用全部 initialize,再按顺序 await 每个 onStart;stop() 调用 onStop', async () => {
|
|
29
|
+
const rec: Recorder = { events: [], errors: [] };
|
|
30
|
+
recordingLogger(rec);
|
|
31
|
+
@Component(ApplicationLifecycle)
|
|
32
|
+
class First implements ApplicationLifecycle<Application> {
|
|
33
|
+
initialize() { rec.events.push('init:first'); }
|
|
34
|
+
async onStart() {
|
|
35
|
+
await new Promise(r => setTimeout(r, 5));
|
|
36
|
+
rec.events.push('start:first');
|
|
37
|
+
}
|
|
38
|
+
onStop() { rec.events.push('stop:first'); }
|
|
39
|
+
}
|
|
40
|
+
@Component(ApplicationLifecycle)
|
|
41
|
+
class Second implements ApplicationLifecycle<Application> {
|
|
42
|
+
initialize() { rec.events.push('init:second'); }
|
|
43
|
+
onStart() { rec.events.push('start:second'); }
|
|
44
|
+
onStop() { rec.events.push('stop:second'); }
|
|
45
|
+
}
|
|
46
|
+
const app = await ApplicationFactory.create({});
|
|
47
|
+
expect(rec.events).to.deep.equal([]);
|
|
48
|
+
await app.start();
|
|
49
|
+
const inits = rec.events.slice(0, 2);
|
|
50
|
+
expect(inits).to.have.members(['init:first', 'init:second']);
|
|
51
|
+
expect(rec.events.slice(2)).to.have.members(['start:first', 'start:second']);
|
|
52
|
+
await app.stop();
|
|
53
|
+
expect(rec.events.slice(4)).to.have.members(['stop:first', 'stop:second']);
|
|
54
|
+
expect(rec.errors).to.deep.equal([]);
|
|
55
|
+
expect([First, Second]).to.have.length(2);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('onStart 按 getAll 的顺序逐个 await(不是并发)', async () => {
|
|
59
|
+
const order: string[] = [];
|
|
60
|
+
let running = 0;
|
|
61
|
+
let maxRunning = 0;
|
|
62
|
+
for (const name of ['a', 'b', 'c']) {
|
|
63
|
+
@Component(ApplicationLifecycle)
|
|
64
|
+
class L implements ApplicationLifecycle<Application> {
|
|
65
|
+
async onStart() {
|
|
66
|
+
running++;
|
|
67
|
+
maxRunning = Math.max(maxRunning, running);
|
|
68
|
+
await new Promise(r => setTimeout(r, 2));
|
|
69
|
+
order.push(name);
|
|
70
|
+
running--;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
void L;
|
|
74
|
+
}
|
|
75
|
+
const app = await ApplicationFactory.create({});
|
|
76
|
+
await app.start();
|
|
77
|
+
expect(order).to.have.members(['a', 'b', 'c']);
|
|
78
|
+
expect(maxRunning).to.equal(1);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('initialize / onStart / onStop 抛错只记 error 日志,不影响其他生命周期,也不让 start() 失败', async () => {
|
|
82
|
+
const rec: Recorder = { events: [], errors: [] };
|
|
83
|
+
recordingLogger(rec);
|
|
84
|
+
@Component(ApplicationLifecycle)
|
|
85
|
+
class Broken implements ApplicationLifecycle<Application> {
|
|
86
|
+
initialize() { throw new Error('init boom'); }
|
|
87
|
+
onStart() { throw new Error('start boom'); }
|
|
88
|
+
onStop() { throw new Error('stop boom'); }
|
|
89
|
+
}
|
|
90
|
+
@Component(ApplicationLifecycle)
|
|
91
|
+
class Healthy implements ApplicationLifecycle<Application> {
|
|
92
|
+
initialize() { rec.events.push('init'); }
|
|
93
|
+
onStart() { rec.events.push('start'); }
|
|
94
|
+
onStop() { rec.events.push('stop'); }
|
|
95
|
+
}
|
|
96
|
+
const app = await ApplicationFactory.create({});
|
|
97
|
+
await app.start();
|
|
98
|
+
await app.stop();
|
|
99
|
+
expect(rec.events).to.deep.equal(['init', 'start', 'stop']);
|
|
100
|
+
expect(rec.errors).to.deep.equal(['Could not initialize lifecycle', 'Could not start lifecycle', 'Could not stop lifecycle']);
|
|
101
|
+
expect([Broken, Healthy]).to.have.length(2);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('没有任何 ApplicationLifecycle 时 start / stop 正常', async () => {
|
|
105
|
+
const app = await ApplicationFactory.create({});
|
|
106
|
+
await app.start();
|
|
107
|
+
await app.stop();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('状态:init → started → ready,stop 之后是 stoped;reachedState 与 onStateChanged', async () => {
|
|
111
|
+
const app = await ApplicationFactory.create({});
|
|
112
|
+
const states = ContainerUtil.get<ApplicationStateService<ApplicationState>>(ApplicationStateService);
|
|
113
|
+
expect(states.state).to.equal('init');
|
|
114
|
+
const seen: string[] = [];
|
|
115
|
+
states.onStateChanged(s => seen.push(s));
|
|
116
|
+
const ready = states.reachedState('ready');
|
|
117
|
+
const readyOrStopped = states.reachedAnyState('ready', 'stoped');
|
|
118
|
+
await app.start();
|
|
119
|
+
await ready;
|
|
120
|
+
await readyOrStopped;
|
|
121
|
+
expect(states.state).to.equal('ready');
|
|
122
|
+
await app.stop();
|
|
123
|
+
expect(states.state).to.equal('stoped');
|
|
124
|
+
expect(seen).to.deep.equal(['started', 'ready', 'stoped']);
|
|
125
|
+
// 当前状态再等会立刻 resolve
|
|
126
|
+
await states.reachedState('stoped');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('离开一个状态之后,再 reachedState(那个状态) 立即 resolve(F7)', async () => {
|
|
130
|
+
const app = await ApplicationFactory.create({});
|
|
131
|
+
const states = ContainerUtil.get<ApplicationStateService<ApplicationState>>(ApplicationStateService);
|
|
132
|
+
await app.start();
|
|
133
|
+
const race = (p: Promise<void>) => Promise.race([p.then(() => 'resolved'), new Promise(r => setTimeout(() => r('pending'), 20))]);
|
|
134
|
+
expect(await race(states.reachedState('ready'))).to.equal('resolved');
|
|
135
|
+
expect(await race(states.reachedState('started'))).to.equal('resolved');
|
|
136
|
+
expect(await race(states.reachedState('stoped'))).to.equal('pending');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('同一个状态重复设置不会重复通知', async () => {
|
|
140
|
+
await ApplicationFactory.create({});
|
|
141
|
+
const states = ContainerUtil.get<ApplicationStateService<ApplicationState>>(ApplicationStateService);
|
|
142
|
+
const seen: string[] = [];
|
|
143
|
+
states.onStateChanged(s => seen.push(s));
|
|
144
|
+
states.state = 'started';
|
|
145
|
+
states.state = 'started';
|
|
146
|
+
expect(seen).to.deep.equal(['started']);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -9,7 +9,7 @@ export class ConfigProviderImpl implements ConfigProvider {
|
|
|
9
9
|
protected readonly expressionHandler: ExpressionHandler;
|
|
10
10
|
|
|
11
11
|
get<T>(key: string, defaultValue?: T): T {
|
|
12
|
-
return this.expressionHandler.handle(`\${${key}}`)
|
|
12
|
+
return this.expressionHandler.handle(`\${${key}}`) ?? defaultValue;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
}
|