@celljs/core 4.5.1 → 4.6.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 (278) hide show
  1. package/README.md +45 -49
  2. package/esm/browser/index.d.ts +0 -1
  3. package/esm/browser/index.js +0 -1
  4. package/esm/browser/index.js.map +1 -1
  5. package/esm/browser/shell/application-shell.d.ts +23 -3
  6. package/esm/browser/shell/application-shell.js +60 -4
  7. package/esm/browser/shell/application-shell.js.map +1 -1
  8. package/esm/browser/shell/index.d.ts +0 -1
  9. package/esm/browser/shell/index.js +0 -1
  10. package/esm/browser/shell/index.js.map +1 -1
  11. package/esm/common/annotation/autowired.d.ts +8 -2
  12. package/esm/common/annotation/autowired.js +7 -8
  13. package/esm/common/annotation/autowired.js.map +1 -1
  14. package/esm/common/annotation/detached/autowired-provider.js +1 -2
  15. package/esm/common/annotation/detached/autowired-provider.js.map +1 -1
  16. package/esm/common/annotation/value.d.ts +1 -0
  17. package/esm/common/annotation/value.js +3 -4
  18. package/esm/common/annotation/value.js.map +1 -1
  19. package/esm/common/aop/aop-proxy-factory.d.ts +2 -1
  20. package/esm/common/aop/aop-proxy-factory.js +10 -3
  21. package/esm/common/aop/aop-proxy-factory.js.map +1 -1
  22. package/esm/common/aop/class-filter.d.ts +2 -0
  23. package/esm/common/aop/class-filter.js +10 -3
  24. package/esm/common/aop/class-filter.js.map +1 -1
  25. package/esm/common/application/application-entry.js +0 -9
  26. package/esm/common/application/application-entry.js.map +1 -1
  27. package/esm/common/application/application-factory.d.ts +9 -3
  28. package/esm/common/application/application-factory.js +13 -6
  29. package/esm/common/application/application-factory.js.map +1 -1
  30. package/esm/common/application/application-protocol.d.ts +12 -0
  31. package/esm/common/application/application-protocol.js +1 -0
  32. package/esm/common/application/application-protocol.js.map +1 -1
  33. package/esm/common/application/application-state.d.ts +1 -1
  34. package/esm/common/application/application-state.js +4 -4
  35. package/esm/common/application/application-state.js.map +1 -1
  36. package/esm/common/application/application.d.ts +4 -2
  37. package/esm/common/application/application.js +19 -7
  38. package/esm/common/application/application.js.map +1 -1
  39. package/esm/common/application/index.d.ts +2 -0
  40. package/esm/common/application/index.js +2 -0
  41. package/esm/common/application/index.js.map +1 -1
  42. package/esm/common/config/config-util.d.ts +0 -1
  43. package/esm/common/config/config-util.js +0 -6
  44. package/esm/common/config/config-util.js.map +1 -1
  45. package/esm/common/container/container-error.d.ts +1 -1
  46. package/esm/common/container/container-error.js.map +1 -1
  47. package/esm/common/container/container.d.ts +1 -0
  48. package/esm/common/container/container.js +6 -1
  49. package/esm/common/container/container.js.map +1 -1
  50. package/esm/common/container/index.d.ts +0 -2
  51. package/esm/common/container/index.js +0 -2
  52. package/esm/common/container/index.js.map +1 -1
  53. package/esm/common/container/injection.d.ts +15 -1
  54. package/esm/common/container/injection.js +37 -1
  55. package/esm/common/container/injection.js.map +1 -1
  56. package/esm/common/el/core-context-initializer.d.ts +2 -1
  57. package/esm/common/el/core-context-initializer.js +5 -3
  58. package/esm/common/el/core-context-initializer.js.map +1 -1
  59. package/esm/common/provider/index.d.ts +0 -1
  60. package/esm/common/provider/index.js +0 -1
  61. package/esm/common/provider/index.js.map +1 -1
  62. package/esm/common/test/assembly-test-util.d.ts +16 -0
  63. package/esm/common/test/assembly-test-util.js +34 -0
  64. package/esm/common/test/assembly-test-util.js.map +1 -0
  65. package/esm/node/application/exit-signal-lifecycle.d.ts +5 -0
  66. package/esm/node/application/exit-signal-lifecycle.js +30 -0
  67. package/esm/node/application/exit-signal-lifecycle.js.map +1 -0
  68. package/esm/node/application/index.d.ts +1 -2
  69. package/esm/node/application/index.js +1 -2
  70. package/esm/node/application/index.js.map +1 -1
  71. package/lib/browser/index.d.ts +0 -1
  72. package/lib/browser/index.d.ts.map +1 -1
  73. package/lib/browser/index.js +0 -1
  74. package/lib/browser/index.js.map +1 -1
  75. package/lib/browser/shell/application-shell.d.ts +23 -3
  76. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  77. package/lib/browser/shell/application-shell.js +62 -5
  78. package/lib/browser/shell/application-shell.js.map +1 -1
  79. package/lib/browser/shell/index.d.ts +0 -1
  80. package/lib/browser/shell/index.d.ts.map +1 -1
  81. package/lib/browser/shell/index.js +0 -1
  82. package/lib/browser/shell/index.js.map +1 -1
  83. package/lib/common/annotation/autowired.d.ts +8 -2
  84. package/lib/common/annotation/autowired.d.ts.map +1 -1
  85. package/lib/common/annotation/autowired.js +7 -8
  86. package/lib/common/annotation/autowired.js.map +1 -1
  87. package/lib/common/annotation/detached/autowired-provider.d.ts.map +1 -1
  88. package/lib/common/annotation/detached/autowired-provider.js +1 -2
  89. package/lib/common/annotation/detached/autowired-provider.js.map +1 -1
  90. package/lib/common/annotation/value.d.ts +1 -0
  91. package/lib/common/annotation/value.d.ts.map +1 -1
  92. package/lib/common/annotation/value.js +3 -4
  93. package/lib/common/annotation/value.js.map +1 -1
  94. package/lib/common/aop/aop-proxy-factory.d.ts +2 -1
  95. package/lib/common/aop/aop-proxy-factory.d.ts.map +1 -1
  96. package/lib/common/aop/aop-proxy-factory.js +9 -2
  97. package/lib/common/aop/aop-proxy-factory.js.map +1 -1
  98. package/lib/common/aop/aop.spec.js +24 -18
  99. package/lib/common/aop/aop.spec.js.map +1 -1
  100. package/lib/common/aop/class-filter.d.ts +2 -0
  101. package/lib/common/aop/class-filter.d.ts.map +1 -1
  102. package/lib/common/aop/class-filter.js +9 -2
  103. package/lib/common/aop/class-filter.js.map +1 -1
  104. package/lib/common/application/application-entry.d.ts.map +1 -1
  105. package/lib/common/application/application-entry.js +0 -9
  106. package/lib/common/application/application-entry.js.map +1 -1
  107. package/lib/common/application/application-factory.d.ts +9 -3
  108. package/lib/common/application/application-factory.d.ts.map +1 -1
  109. package/lib/common/application/application-factory.js +13 -6
  110. package/lib/common/application/application-factory.js.map +1 -1
  111. package/lib/common/application/application-protocol.d.ts +12 -0
  112. package/lib/common/application/application-protocol.d.ts.map +1 -1
  113. package/lib/common/application/application-protocol.js +2 -1
  114. package/lib/common/application/application-protocol.js.map +1 -1
  115. package/lib/common/application/application-state.d.ts +1 -1
  116. package/lib/common/application/application-state.d.ts.map +1 -1
  117. package/lib/common/application/application-state.js +5 -5
  118. package/lib/common/application/application-state.js.map +1 -1
  119. package/lib/common/application/application.d.ts +4 -2
  120. package/lib/common/application/application.d.ts.map +1 -1
  121. package/lib/common/application/application.js +18 -6
  122. package/lib/common/application/application.js.map +1 -1
  123. package/lib/common/application/index.d.ts +2 -0
  124. package/lib/common/application/index.d.ts.map +1 -1
  125. package/lib/common/application/index.js +2 -0
  126. package/lib/common/application/index.js.map +1 -1
  127. package/lib/common/application/lifecycle.spec.js +18 -13
  128. package/lib/common/application/lifecycle.spec.js.map +1 -1
  129. package/lib/common/config/config-util.d.ts +0 -1
  130. package/lib/common/config/config-util.d.ts.map +1 -1
  131. package/lib/common/config/config-util.js +0 -6
  132. package/lib/common/config/config-util.js.map +1 -1
  133. package/lib/common/container/assembly.spec.js +115 -43
  134. package/lib/common/container/assembly.spec.js.map +1 -1
  135. package/lib/common/container/container-error.d.ts +1 -1
  136. package/lib/common/container/container-error.d.ts.map +1 -1
  137. package/lib/common/container/container-error.js.map +1 -1
  138. package/lib/common/container/container.d.ts +1 -0
  139. package/lib/common/container/container.d.ts.map +1 -1
  140. package/lib/common/container/container.js +6 -1
  141. package/lib/common/container/container.js.map +1 -1
  142. package/lib/common/container/container.spec.js +6 -1
  143. package/lib/common/container/container.spec.js.map +1 -1
  144. package/lib/common/container/index.d.ts +0 -2
  145. package/lib/common/container/index.d.ts.map +1 -1
  146. package/lib/common/container/index.js +0 -2
  147. package/lib/common/container/index.js.map +1 -1
  148. package/lib/common/container/injection.d.ts +15 -1
  149. package/lib/common/container/injection.d.ts.map +1 -1
  150. package/lib/common/container/injection.js +37 -1
  151. package/lib/common/container/injection.js.map +1 -1
  152. package/lib/common/el/core-context-initializer.d.ts +2 -1
  153. package/lib/common/el/core-context-initializer.d.ts.map +1 -1
  154. package/lib/common/el/core-context-initializer.js +5 -3
  155. package/lib/common/el/core-context-initializer.js.map +1 -1
  156. package/lib/common/el/value-and-el.spec.js +35 -26
  157. package/lib/common/el/value-and-el.spec.js.map +1 -1
  158. package/lib/common/provider/index.d.ts +0 -1
  159. package/lib/common/provider/index.d.ts.map +1 -1
  160. package/lib/common/provider/index.js +0 -1
  161. package/lib/common/provider/index.js.map +1 -1
  162. package/lib/common/test/assembly-test-util.d.ts +17 -0
  163. package/lib/common/test/assembly-test-util.d.ts.map +1 -0
  164. package/lib/common/test/assembly-test-util.js +37 -0
  165. package/lib/common/test/assembly-test-util.js.map +1 -0
  166. package/lib/node/application/exit-signal-lifecycle.d.ts +6 -0
  167. package/lib/node/application/exit-signal-lifecycle.d.ts.map +1 -0
  168. package/lib/node/application/exit-signal-lifecycle.js +33 -0
  169. package/lib/node/application/exit-signal-lifecycle.js.map +1 -0
  170. package/lib/node/application/index.d.ts +1 -2
  171. package/lib/node/application/index.d.ts.map +1 -1
  172. package/lib/node/application/index.js +1 -2
  173. package/lib/node/application/index.js.map +1 -1
  174. package/lib/package.spec.js +17 -2
  175. package/lib/package.spec.js.map +1 -1
  176. package/package.json +1 -5
  177. package/src/browser/index.ts +0 -1
  178. package/src/browser/shell/application-shell.ts +64 -5
  179. package/src/browser/shell/index.ts +0 -1
  180. package/src/common/annotation/autowired.ts +14 -11
  181. package/src/common/annotation/detached/autowired-provider.ts +1 -2
  182. package/src/common/annotation/value.ts +4 -4
  183. package/src/common/aop/aop-proxy-factory.ts +6 -4
  184. package/src/common/aop/aop.spec.ts +26 -18
  185. package/src/common/aop/class-filter.ts +6 -3
  186. package/src/common/application/application-entry.ts +1 -9
  187. package/src/common/application/application-factory.ts +15 -6
  188. package/src/common/application/application-protocol.ts +14 -1
  189. package/src/common/application/application-state.ts +1 -1
  190. package/src/common/application/application.ts +13 -3
  191. package/src/common/application/index.ts +2 -0
  192. package/src/common/application/lifecycle.spec.ts +20 -13
  193. package/src/common/config/config-util.ts +0 -6
  194. package/src/common/container/assembly.spec.ts +100 -44
  195. package/src/common/container/container-error.ts +3 -2
  196. package/src/common/container/container.spec.ts +8 -2
  197. package/src/common/container/container.ts +7 -2
  198. package/src/common/container/index.ts +0 -2
  199. package/src/common/container/injection.ts +40 -3
  200. package/src/common/el/core-context-initializer.ts +6 -4
  201. package/src/common/el/value-and-el.spec.ts +34 -25
  202. package/src/common/provider/index.ts +0 -1
  203. package/src/common/test/assembly-test-util.ts +41 -0
  204. package/src/node/application/exit-signal-lifecycle.ts +23 -0
  205. package/src/node/application/index.ts +1 -2
  206. package/src/package.spec.ts +16 -3
  207. package/esm/browser/application/frontend-application-state.d.ts +0 -4
  208. package/esm/browser/application/frontend-application-state.js +0 -14
  209. package/esm/browser/application/frontend-application-state.js.map +0 -1
  210. package/esm/browser/application/frontend-application.d.ts +0 -30
  211. package/esm/browser/application/frontend-application.js +0 -123
  212. package/esm/browser/application/frontend-application.js.map +0 -1
  213. package/esm/browser/application/index.d.ts +0 -2
  214. package/esm/browser/application/index.js +0 -3
  215. package/esm/browser/application/index.js.map +0 -1
  216. package/esm/browser/shell/shell-protocol.d.ts +0 -4
  217. package/esm/browser/shell/shell-protocol.js +0 -2
  218. package/esm/browser/shell/shell-protocol.js.map +0 -1
  219. package/esm/common/container/container-provider.d.ts +0 -7
  220. package/esm/common/container/container-provider.js +0 -24
  221. package/esm/common/container/container-provider.js.map +0 -1
  222. package/esm/common/container/container-util.d.ts +0 -7
  223. package/esm/common/container/container-util.js +0 -18
  224. package/esm/common/container/container-util.js.map +0 -1
  225. package/esm/common/provider/provider-util.d.ts +0 -5
  226. package/esm/common/provider/provider-util.js +0 -10
  227. package/esm/common/provider/provider-util.js.map +0 -1
  228. package/esm/node/application/backend-application-state.d.ts +0 -4
  229. package/esm/node/application/backend-application-state.js +0 -14
  230. package/esm/node/application/backend-application-state.js.map +0 -1
  231. package/esm/node/application/backend-application.d.ts +0 -10
  232. package/esm/node/application/backend-application.js +0 -52
  233. package/esm/node/application/backend-application.js.map +0 -1
  234. package/lib/browser/application/frontend-application-state.d.ts +0 -5
  235. package/lib/browser/application/frontend-application-state.d.ts.map +0 -1
  236. package/lib/browser/application/frontend-application-state.js +0 -17
  237. package/lib/browser/application/frontend-application-state.js.map +0 -1
  238. package/lib/browser/application/frontend-application.d.ts +0 -31
  239. package/lib/browser/application/frontend-application.d.ts.map +0 -1
  240. package/lib/browser/application/frontend-application.js +0 -126
  241. package/lib/browser/application/frontend-application.js.map +0 -1
  242. package/lib/browser/application/index.d.ts +0 -3
  243. package/lib/browser/application/index.d.ts.map +0 -1
  244. package/lib/browser/application/index.js +0 -19
  245. package/lib/browser/application/index.js.map +0 -1
  246. package/lib/browser/shell/shell-protocol.d.ts +0 -5
  247. package/lib/browser/shell/shell-protocol.d.ts.map +0 -1
  248. package/lib/browser/shell/shell-protocol.js +0 -5
  249. package/lib/browser/shell/shell-protocol.js.map +0 -1
  250. package/lib/common/container/container-provider.d.ts +0 -8
  251. package/lib/common/container/container-provider.d.ts.map +0 -1
  252. package/lib/common/container/container-provider.js +0 -27
  253. package/lib/common/container/container-provider.js.map +0 -1
  254. package/lib/common/container/container-util.d.ts +0 -8
  255. package/lib/common/container/container-util.d.ts.map +0 -1
  256. package/lib/common/container/container-util.js +0 -21
  257. package/lib/common/container/container-util.js.map +0 -1
  258. package/lib/common/provider/provider-util.d.ts +0 -6
  259. package/lib/common/provider/provider-util.d.ts.map +0 -1
  260. package/lib/common/provider/provider-util.js +0 -13
  261. package/lib/common/provider/provider-util.js.map +0 -1
  262. package/lib/node/application/backend-application-state.d.ts +0 -5
  263. package/lib/node/application/backend-application-state.d.ts.map +0 -1
  264. package/lib/node/application/backend-application-state.js +0 -17
  265. package/lib/node/application/backend-application-state.js.map +0 -1
  266. package/lib/node/application/backend-application.d.ts +0 -11
  267. package/lib/node/application/backend-application.d.ts.map +0 -1
  268. package/lib/node/application/backend-application.js +0 -55
  269. package/lib/node/application/backend-application.js.map +0 -1
  270. package/src/browser/application/frontend-application-state.ts +0 -11
  271. package/src/browser/application/frontend-application.ts +0 -121
  272. package/src/browser/application/index.ts +0 -2
  273. package/src/browser/shell/shell-protocol.ts +0 -5
  274. package/src/common/container/container-provider.ts +0 -25
  275. package/src/common/container/container-util.ts +0 -17
  276. package/src/common/provider/provider-util.ts +0 -10
  277. package/src/node/application/backend-application-state.ts +0 -9
  278. package/src/node/application/backend-application.ts +0 -43
@@ -2,16 +2,25 @@ import { describe, it, afterAll } from 'bun:test';
2
2
  import { expect } from 'chai';
3
3
  import { ApplicationFactory } from '../application/application-factory';
4
4
  import { Component, Value } from '../annotation';
5
- import { ContainerUtil } from '../container/container-util';
6
5
  import { ConfigUtil } from '../config/config-util';
6
+ import { ConfigProvider } from '../config/config-protocol';
7
+ import { Container, ContainerModule } from '../container/container';
8
+ import { Application } from '../application/application-protocol';
7
9
  import { ExpressionHandler } from './expression-protocol';
8
10
 
11
+ let container: Container;
12
+ /** A new container for each test; the components registered since the previous one go into it. */
13
+ async function create(props: Record<string, any>, ...modules: ContainerModule[]): Promise<Application> {
14
+ container = ApplicationFactory.createContainer(props, ...modules);
15
+ return container.get<Application>(Application);
16
+ }
17
+
9
18
  /**
10
- * @Value、ConfigUtil 与 EL(${...},ExpressionEngine)的约定(阶段 1.E 行为测试)。
11
- * 配置就是 ApplicationFactory.create() 的第一个参数(CLI 生成的入口会把合并后的 cell.yml 传进来)。
19
+ * @Value、ConfigProvider 与 EL(${...},ExpressionEngine)的约定(阶段 1.E 行为测试)。
20
+ * 配置就是 create() 的第一个参数(CLI 生成的入口会把合并后的 cell.yml 传进来)。
12
21
  */
13
- const boot = (props: Record<string, any>) => ApplicationFactory.create(props);
14
- const el = () => ContainerUtil.get<ExpressionHandler>(ExpressionHandler);
22
+ const boot = (props: Record<string, any>) => create(props);
23
+ const el = () => container.get<ExpressionHandler>(ExpressionHandler);
15
24
 
16
25
  describe('core @Value 与配置', () => {
17
26
 
@@ -24,7 +33,7 @@ describe('core @Value 与配置', () => {
24
33
  readonly port: number;
25
34
  }
26
35
  await boot({ cell: { name: 'demo' }, port: 8080 });
27
- const s = ContainerUtil.get(Settings);
36
+ const s = container.get(Settings);
28
37
  expect(s.name).to.equal('demo');
29
38
  expect(s.port).to.equal(8080);
30
39
  });
@@ -38,7 +47,7 @@ describe('core @Value 与配置', () => {
38
47
  readonly chain: string;
39
48
  }
40
49
  await boot({ cell: { host: 'example.com', url: 'https://${cell.host}:443/api', chain: '${cell.url}', } });
41
- const u = ContainerUtil.get(Urls);
50
+ const u = container.get(Urls);
42
51
  expect(u.url).to.equal('https://example.com:443/api');
43
52
  expect(u.chain).to.equal('https://example.com:443/api');
44
53
  });
@@ -52,7 +61,7 @@ describe('core @Value 与配置', () => {
52
61
  readonly missing?: unknown;
53
62
  }
54
63
  await boot({ cell: { region: 'eu', db: { host: 'db.${cell.region}.local', port: 5432, hosts: ['a.${cell.region}', 'b'] } } });
55
- const d = ContainerUtil.get(Db);
64
+ const d = container.get(Db);
56
65
  expect(d.db).to.deep.equal({ host: 'db.eu.local', port: 5432, hosts: ['a.eu', 'b'] });
57
66
  expect(d.missing).to.equal(undefined);
58
67
  });
@@ -63,26 +72,25 @@ describe('core @Value 与配置', () => {
63
72
  constructor(@Value('cell.size') readonly size: number) { }
64
73
  }
65
74
  await boot({ cell: { size: 3 } });
66
- expect(ContainerUtil.get(WithCtor).size).to.equal(3);
75
+ expect(container.get(WithCtor).size).to.equal(3);
67
76
  });
68
77
 
69
- it('detached 的 @Value:不在容器里的对象每次读取都取当前容器的配置', async () => {
70
- class Plain {
78
+ it('detached 的 @Value:每次读取都从创建实例的容器取配置', async () => {
79
+ @Component()
80
+ class Lazy {
71
81
  @Value({ el: 'cell.mode', detached: true })
72
82
  readonly mode: string;
73
83
  }
74
- const p = new Plain();
75
84
  await boot({ cell: { mode: 'a' } });
76
- expect(p.mode).to.equal('a');
77
- await boot({ cell: { mode: 'b' } });
78
- expect(p.mode).to.equal('b');
85
+ expect(container.get(Lazy).mode).to.equal('a');
79
86
  });
80
87
 
81
- it('ConfigUtil.get:取值、默认值', async () => {
88
+ it('ConfigProvider.get:取值、默认值', async () => {
82
89
  await boot({ cell: { a: 1, ref: '${cell.a}' } });
83
- expect(ConfigUtil.get('cell.a')).to.equal(1);
84
- expect(ConfigUtil.get('cell.ref')).to.equal(1);
85
- expect(ConfigUtil.get('cell.none', 'dflt')).to.equal('dflt');
90
+ const config = container.get<ConfigProvider>(ConfigProvider);
91
+ expect(config.get('cell.a')).to.equal(1);
92
+ expect(config.get('cell.ref')).to.equal(1);
93
+ expect(config.get('cell.none', 'dflt')).to.equal('dflt');
86
94
  });
87
95
 
88
96
  it('现状:create() 过程中第一次求值就会就地改写传入的配置对象,getRaw() 拿到的也是求值后的结果', async () => {
@@ -95,7 +103,7 @@ describe('core @Value 与配置', () => {
95
103
  expect(props.cell.nested[0]).to.equal(1);
96
104
  });
97
105
 
98
- it('false、0、空串都是有效的值:@Value 拿得到,ConfigUtil.get 只在值为 undefined 时用默认值(F3)', async () => {
106
+ it('false、0、空串都是有效的值:@Value 拿得到,ConfigProvider.get 只在值为 undefined 时用默认值(F3)', async () => {
99
107
  @Component()
100
108
  class Flags {
101
109
  @Value('cell.enabled')
@@ -106,13 +114,14 @@ describe('core @Value 与配置', () => {
106
114
  readonly prefix: string;
107
115
  }
108
116
  await boot({ cell: { enabled: false, retries: 0, prefix: '' } });
109
- const f = ContainerUtil.get(Flags);
117
+ const f = container.get(Flags);
110
118
  expect(f.enabled).to.equal(false);
111
119
  expect(f.retries).to.equal(0);
112
120
  expect(f.prefix).to.equal('');
113
- expect(ConfigUtil.get('cell.retries', 3)).to.equal(0);
114
- expect(ConfigUtil.get('cell.enabled', true)).to.equal(false);
115
- expect(ConfigUtil.get('cell.missing', 3)).to.equal(3);
121
+ const config = container.get<ConfigProvider>(ConfigProvider);
122
+ expect(config.get('cell.retries', 3)).to.equal(0);
123
+ expect(config.get('cell.enabled', true)).to.equal(false);
124
+ expect(config.get('cell.missing', 3)).to.equal(3);
116
125
  });
117
126
  });
118
127
 
@@ -183,4 +192,4 @@ describe('core EL(ExpressionHandler)', () => {
183
192
  expect(el().handle('${cell.viaEnv}')).to.equal('${cell.other}');
184
193
  expect(el().handle('${cell.viaKey}')).to.equal('${cell.other}');
185
194
  });
186
- });
195
+ });
@@ -1,4 +1,3 @@
1
1
  export * from './component-filter-registry';
2
2
  export * from './provider';
3
3
  export * from './provider-protocol';
4
- export * from './provider-util';
@@ -0,0 +1,41 @@
1
+ import { Binding, Container, ContainerModule } from '../container/container';
2
+ import { ContainerError } from '../container/container-error';
3
+
4
+ /**
5
+ * The assembly test of a package: its DI module loads after those of its dependencies (in the order the
6
+ * toolchain loads them) and every binding resolves, as `cell check` checks a project.
7
+ */
8
+ export namespace AssemblyTestUtil {
9
+
10
+ export interface Result {
11
+ /** The container with the dependencies and the module. */
12
+ container: Container;
13
+ /** The identifiers whose bindings the module adds or replaces. */
14
+ changed: number;
15
+ /** `CELL_DI_*` errors, one line per identifier. Others (a value made for an injection point) are not wiring errors. */
16
+ errors: string[];
17
+ }
18
+
19
+ export function check(dependencies: ContainerModule[], module: ContainerModule): Result {
20
+ const before = new Container(...dependencies).bindings();
21
+ const container = new Container(...dependencies, module);
22
+ const describe = (bindings: readonly Binding[] | undefined) => (bindings ?? []).map(b => Container.describe(b)).join('\n');
23
+ let changed = 0;
24
+ for (const [id, bindings] of container.bindings()) {
25
+ if (describe(bindings) !== describe(before.get(id))) {
26
+ changed++;
27
+ }
28
+ }
29
+ const errors: string[] = [];
30
+ for (const id of container.bindings().keys()) {
31
+ try {
32
+ container.getAll(id);
33
+ } catch (error) {
34
+ if (ContainerError.is(error)) {
35
+ errors.push(`${Container.idName(id)}: ${error.code} ${error.message}`);
36
+ }
37
+ }
38
+ }
39
+ return { container, changed, errors };
40
+ }
41
+ }
@@ -0,0 +1,23 @@
1
+ import { Application, ApplicationLifecycle, Component } from '../../common';
2
+
3
+ const TAG = Symbol('ExitSignalLifecycle');
4
+
5
+ /** Stops the application, then the process, on SIGINT and SIGTERM. A new application replaces the handlers of the previous one. */
6
+ @Component(ApplicationLifecycle)
7
+ export class ExitSignalLifecycle implements ApplicationLifecycle<Application> {
8
+
9
+ onStart(application: Application): void {
10
+ for (const signal of ['SIGINT', 'SIGTERM'] as const) {
11
+ for (const listener of process.listeners(signal)) {
12
+ if ((listener as any)[TAG]) {
13
+ process.removeListener(signal, listener);
14
+ }
15
+ }
16
+ const listener = () => {
17
+ void application.stop().finally(() => process.exit(0));
18
+ };
19
+ (listener as any)[TAG] = true;
20
+ process.once(signal, listener);
21
+ }
22
+ }
23
+ }
@@ -1,2 +1 @@
1
- export * from './backend-application';
2
- export * from './backend-application-state';
1
+ export * from './exit-signal-lifecycle';
@@ -1,5 +1,18 @@
1
- import { describe, it } from 'bun:test';
2
- describe('core package', () => {
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { Application, currentThis } from './common';
3
+ import { AssemblyTestUtil } from './common/test/assembly-test-util';
4
+ import commonStatic from './common/static-module';
5
+ import nodeStatic from './node/static-module';
6
+ import { ExitSignalLifecycle } from './node';
3
7
 
4
- it('support code coverage statistics', () => {});
8
+ currentThis.cellProps = {};
9
+
10
+ describe('@celljs/core', () => {
11
+ it('the static modules of the backend load and every binding resolves', () => {
12
+ const { container, changed, errors } = AssemblyTestUtil.check([commonStatic], nodeStatic);
13
+ expect(errors).toEqual([]);
14
+ expect(changed).toBeGreaterThan(0);
15
+ expect(container.get(Application)).toBeDefined();
16
+ expect(container.get(ExitSignalLifecycle)).toBeInstanceOf(ExitSignalLifecycle);
17
+ });
5
18
  });
@@ -1,4 +0,0 @@
1
- import { ApplicationState, AbstractApplicationStateService } from '../../common/index.js';
2
- export type FrontendApplicationState = ApplicationState | 'attached_shell' | 'closing_window';
3
- export declare class FrontendApplicationStateService extends AbstractApplicationStateService<FrontendApplicationState> {
4
- }
@@ -1,14 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Component, AbstractApplicationStateService, ApplicationStateService } from '../../common/index.js';
8
- let FrontendApplicationStateService = class FrontendApplicationStateService extends AbstractApplicationStateService {
9
- };
10
- FrontendApplicationStateService = __decorate([
11
- Component(ApplicationStateService)
12
- ], FrontendApplicationStateService);
13
- export { FrontendApplicationStateService };
14
- //# sourceMappingURL=frontend-application-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontend-application-state.js","sourceRoot":"","sources":["../../../src/browser/application/frontend-application-state.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAoB,+BAA+B,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAQ9G,IAAM,+BAA+B,GAArC,MAAM,+BAAgC,SAAQ,+BAAyD;CAE7G,CAAA;AAFY,+BAA+B;IAD3C,SAAS,CAAC,uBAAuB,CAAC;GACtB,+BAA+B,CAE3C"}
@@ -1,30 +0,0 @@
1
- import { ApplicationShell } from '../shell/index.js';
2
- import { FrontendApplicationStateService } from './frontend-application-state.js';
3
- import { MaybePromise, AbstractApplication, Application, ApplicationLifecycle } from '../../common/index.js';
4
- export declare class FrontendApplication extends AbstractApplication {
5
- protected readonly _shell: ApplicationShell;
6
- protected readonly stateService: FrontendApplicationStateService;
7
- protected readonly hostDomId: string;
8
- get shell(): ApplicationShell;
9
- start(): Promise<void>;
10
- /**
11
- * Return a promise to the host element to which the application shell is attached.
12
- */
13
- protected getHost(): Promise<HTMLElement>;
14
- /**
15
- * Return an HTML element that indicates the startup phase, e.g. with an animation or a splash screen.
16
- */
17
- protected getStartupIndicator(host: HTMLElement): HTMLElement | undefined;
18
- /**
19
- * Register global event listeners.
20
- */
21
- protected registerEventListeners(): void;
22
- /**
23
- * If a startup indicator is present, it is first hidden with the `cell-hidden` CSS class and then
24
- * removed after a while. The delay until removal is taken from the CSS transition duration.
25
- */
26
- protected revealShell(host: HTMLElement): Promise<void>;
27
- protected startLifecycle(lifecycle: ApplicationLifecycle<Application>): Promise<void>;
28
- protected measure<T>(name: string, fn: () => MaybePromise<T>): Promise<T>;
29
- stop(): Promise<void>;
30
- }
@@ -1,123 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { ApplicationShell } from '../shell/index.js';
11
- import { FrontendApplicationStateService } from './frontend-application-state.js';
12
- import { parseCssTime } from '../browser.js';
13
- import { Component, Autowired, ApplicationStateService, AbstractApplication, Application, Value } from '../../common/index.js';
14
- let FrontendApplication = class FrontendApplication extends AbstractApplication {
15
- get shell() {
16
- return this._shell;
17
- }
18
- async start() {
19
- await this.doStart();
20
- this.stateService.state = 'started';
21
- const host = await this.getHost();
22
- this._shell.attach(host);
23
- await new Promise(resolve => requestAnimationFrame(() => resolve()));
24
- this.stateService.state = 'attached_shell';
25
- await this.revealShell(host);
26
- this.registerEventListeners();
27
- this.stateService.state = 'ready';
28
- }
29
- /**
30
- * Return a promise to the host element to which the application shell is attached.
31
- */
32
- getHost() {
33
- if (document.body) {
34
- return Promise.resolve(document.getElementById(this.hostDomId) || document.body);
35
- }
36
- return new Promise(resolve => window.addEventListener('load', () => resolve(document.getElementById(this.hostDomId) || document.body), { once: true }));
37
- }
38
- /**
39
- * Return an HTML element that indicates the startup phase, e.g. with an animation or a splash screen.
40
- */
41
- getStartupIndicator(host) {
42
- const startupElements = host.getElementsByClassName('cell-preload');
43
- return startupElements.length === 0 ? undefined : startupElements[0];
44
- }
45
- /**
46
- * Register global event listeners.
47
- */
48
- registerEventListeners() {
49
- // pagehide, not unload: browsers deprecate unload and block it by permissions policy.
50
- window.addEventListener('pagehide', () => {
51
- this.stateService.state = 'closing_window';
52
- this.doStop();
53
- });
54
- }
55
- /**
56
- * If a startup indicator is present, it is first hidden with the `cell-hidden` CSS class and then
57
- * removed after a while. The delay until removal is taken from the CSS transition duration.
58
- */
59
- revealShell(host) {
60
- const startupElem = this.getStartupIndicator(host);
61
- if (startupElem) {
62
- return new Promise(resolve => {
63
- window.requestAnimationFrame(() => {
64
- startupElem.classList.add('cell-hidden');
65
- const preloadStyle = window.getComputedStyle(startupElem);
66
- const transitionDuration = parseCssTime(preloadStyle.transitionDuration, 0);
67
- window.setTimeout(() => {
68
- const parent = startupElem.parentElement;
69
- if (parent) {
70
- parent.removeChild(startupElem);
71
- }
72
- resolve();
73
- }, transitionDuration);
74
- });
75
- });
76
- }
77
- else {
78
- return Promise.resolve();
79
- }
80
- }
81
- startLifecycle(lifecycle) {
82
- return this.measure(`${lifecycle.constructor.name}.onStart`, () => lifecycle.onStart(this));
83
- }
84
- async measure(name, fn) {
85
- const startMark = name + '-start';
86
- const endMark = name + '-end';
87
- performance.mark(startMark);
88
- const result = await fn();
89
- performance.mark(endMark);
90
- performance.measure(name, startMark, endMark);
91
- for (const item of performance.getEntriesByName(name)) {
92
- if (item.duration > 100) {
93
- console.warn(item.name + ' is slow, took: ' + item.duration + ' ms');
94
- }
95
- else {
96
- console.debug(item.name + ' took ' + item.duration + ' ms');
97
- }
98
- }
99
- performance.clearMeasures(name);
100
- return result;
101
- }
102
- async stop() {
103
- this.doStop();
104
- this.stateService.state = 'stopped';
105
- }
106
- };
107
- __decorate([
108
- Autowired(ApplicationShell),
109
- __metadata("design:type", Object)
110
- ], FrontendApplication.prototype, "_shell", void 0);
111
- __decorate([
112
- Autowired(ApplicationStateService),
113
- __metadata("design:type", FrontendApplicationStateService)
114
- ], FrontendApplication.prototype, "stateService", void 0);
115
- __decorate([
116
- Value('html.rootId'),
117
- __metadata("design:type", String)
118
- ], FrontendApplication.prototype, "hostDomId", void 0);
119
- FrontendApplication = __decorate([
120
- Component(Application)
121
- ], FrontendApplication);
122
- export { FrontendApplication };
123
- //# sourceMappingURL=frontend-application.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontend-application.js","sourceRoot":"","sources":["../../../src/browser/application/frontend-application.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EACzB,uBAAuB,EAAE,mBAAmB,EAAE,WAAW,EAAwB,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1G,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,mBAAmB;IAWxD,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;QAEpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,qBAAqB,CAAC,GAAG,E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C1B,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9C,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,kBAAkB,GAAG,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;YAChE,CAAC;QACL,CAAC;QACD,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;IACxC,CAAC;CAEJ,CAAA;AA9GsB;IADlB,SAAS,CAAC,gBAAgB,CAAC;;mDACgB;AAGzB;IADlB,SAAS,CAAC,uBAAuB,CAAC;8BACF,+BAA+B;yDAAC;AAG9C;IADlB,KAAK,CAAC,aAAa,CAAC;;sDACgB;AAT5B,mBAAmB;IAD/B,SAAS,CAAC,WAAW,CAAC;GACV,mBAAmB,CAiH/B"}
@@ -1,2 +0,0 @@
1
- export * from './frontend-application.js';
2
- export * from './frontend-application-state.js';
@@ -1,3 +0,0 @@
1
- export * from './frontend-application.js';
2
- export * from './frontend-application-state.js';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/browser/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const ApplicationShell: unique symbol;
2
- export interface ApplicationShell {
3
- attach(host: HTMLElement): void;
4
- }
@@ -1,2 +0,0 @@
1
- export const ApplicationShell = Symbol('ApplicationShell');
2
- //# sourceMappingURL=shell-protocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-protocol.js","sourceRoot":"","sources":["../../../src/browser/shell/shell-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import type { Container } from './container.js';
2
- /** The container of the running application, for code that is not a component. */
3
- export declare namespace ContainerProvider {
4
- function set(container: Container): void;
5
- function provide(): Container;
6
- function asyncProvide(): Promise<Container>;
7
- }
@@ -1,24 +0,0 @@
1
- import { Deferred } from '../utils/promise-util.js';
2
- let _container;
3
- const _containerDeferred = new Deferred();
4
- /** The container of the running application, for code that is not a component. */
5
- export var ContainerProvider;
6
- (function (ContainerProvider) {
7
- function set(container) {
8
- _container = container;
9
- _containerDeferred.resolve(container);
10
- }
11
- ContainerProvider.set = set;
12
- function provide() {
13
- if (!_container) {
14
- throw new Error('Container is not ready yet, the timing is incorrect.');
15
- }
16
- return _container;
17
- }
18
- ContainerProvider.provide = provide;
19
- function asyncProvide() {
20
- return _containerDeferred.promise;
21
- }
22
- ContainerProvider.asyncProvide = asyncProvide;
23
- })(ContainerProvider || (ContainerProvider = {}));
24
- //# sourceMappingURL=container-provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container-provider.js","sourceRoot":"","sources":["../../../src/common/container/container-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,IAAI,UAAiC,CAAC;AAEtC,MAAM,kBAAkB,GAAG,IAAI,QAAQ,EAAa,CAAC;AAErD,kFAAkF;AAClF,MAAM,KAAW,iBAAiB,CAgBjC;AAhBD,WAAiB,iBAAiB;IAC9B,SAAgB,GAAG,CAAC,SAAoB;QACpC,UAAU,GAAG,SAAS,CAAC;QACvB,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAHe,kBAAA,GAAG,MAGlB,CAAA;IAED,SAAgB,OAAO;QACnB,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IALe,kBAAA,OAAO,UAKtB,CAAA;IAED,SAAgB,YAAY;QACxB,OAAO,kBAAkB,CAAC,OAAO,CAAC;IACtC,CAAC;IAFe,kBAAA,YAAY,eAE3B,CAAA;AACL,CAAC,EAhBgB,iBAAiB,KAAjB,iBAAiB,QAgBjC"}
@@ -1,7 +0,0 @@
1
- import type { BindingQuery, ComponentId } from './container.js';
2
- /** Components of the running application's container, for code that is not a component. */
3
- export declare namespace ContainerUtil {
4
- function get<T>(id: ComponentId<T>, query?: BindingQuery): T;
5
- function getAll<T>(id: ComponentId<T>, query?: BindingQuery): T[];
6
- function isBound(id: ComponentId, query?: BindingQuery): boolean;
7
- }
@@ -1,18 +0,0 @@
1
- import { ContainerProvider } from './container-provider.js';
2
- /** Components of the running application's container, for code that is not a component. */
3
- export var ContainerUtil;
4
- (function (ContainerUtil) {
5
- function get(id, query) {
6
- return ContainerProvider.provide().get(id, query);
7
- }
8
- ContainerUtil.get = get;
9
- function getAll(id, query) {
10
- return ContainerProvider.provide().getAll(id, query);
11
- }
12
- ContainerUtil.getAll = getAll;
13
- function isBound(id, query) {
14
- return ContainerProvider.provide().isBound(id, query);
15
- }
16
- ContainerUtil.isBound = isBound;
17
- })(ContainerUtil || (ContainerUtil = {}));
18
- //# sourceMappingURL=container-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container-util.js","sourceRoot":"","sources":["../../../src/common/container/container-util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,2FAA2F;AAC3F,MAAM,KAAW,aAAa,CAY7B;AAZD,WAAiB,aAAa;IAC1B,SAAgB,GAAG,CAAI,EAAkB,EAAE,KAAoB;QAC3D,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAFe,cAAA,GAAG,MAElB,CAAA;IAED,SAAgB,MAAM,CAAI,EAAkB,EAAE,KAAoB;QAC9D,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAFe,cAAA,MAAM,SAErB,CAAA;IAED,SAAgB,OAAO,CAAC,EAAe,EAAE,KAAoB;QACzD,OAAO,iBAAiB,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IAFe,cAAA,OAAO,UAEtB,CAAA;AACL,CAAC,EAZgB,aAAa,KAAb,aAAa,QAY7B"}
@@ -1,5 +0,0 @@
1
- import type { ComponentId } from '../container/container.js';
2
- import { Provider } from './provider-protocol.js';
3
- export declare namespace ProviderUtil {
4
- function get<T extends Object>(componentId: ComponentId<T>): Provider<T>;
5
- }
@@ -1,10 +0,0 @@
1
- import { PROVIDER, ID_KEY } from '../annotation/autowired-provider.js';
2
- import { ContainerUtil } from '../container/container-util.js';
3
- export var ProviderUtil;
4
- (function (ProviderUtil) {
5
- function get(componentId) {
6
- return ContainerUtil.get(PROVIDER, { tags: { [ID_KEY]: componentId } });
7
- }
8
- ProviderUtil.get = get;
9
- })(ProviderUtil || (ProviderUtil = {}));
10
- //# sourceMappingURL=provider-util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider-util.js","sourceRoot":"","sources":["../../../src/common/provider/provider-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,MAAM,KAAW,YAAY,CAI5B;AAJD,WAAiB,YAAY;IACzB,SAAgB,GAAG,CAAmB,WAA2B;QAC7D,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAFe,aAAA,GAAG,MAElB,CAAA;AACL,CAAC,EAJgB,YAAY,KAAZ,YAAY,QAI5B"}
@@ -1,4 +0,0 @@
1
- import { ApplicationState, AbstractApplicationStateService } from '../../common/index.js';
2
- export type BackendApplicationState = ApplicationState;
3
- export declare class BackendApplicationStateService extends AbstractApplicationStateService<BackendApplicationState> {
4
- }
@@ -1,14 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { AbstractApplicationStateService, ApplicationStateService, Component } from '../../common/index.js';
8
- let BackendApplicationStateService = class BackendApplicationStateService extends AbstractApplicationStateService {
9
- };
10
- BackendApplicationStateService = __decorate([
11
- Component(ApplicationStateService)
12
- ], BackendApplicationStateService);
13
- export { BackendApplicationStateService };
14
- //# sourceMappingURL=backend-application-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backend-application-state.js","sourceRoot":"","sources":["../../../src/node/application/backend-application-state.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAoB,+BAA+B,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK9G,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,+BAAwD;CAE3G,CAAA;AAFY,8BAA8B;IAD1C,SAAS,CAAC,uBAAuB,CAAC;GACtB,8BAA8B,CAE1C"}
@@ -1,10 +0,0 @@
1
- import { AbstractApplication } from '../../common/index.js';
2
- import { BackendApplicationStateService } from './backend-application-state.js';
3
- export declare class BackendApplication extends AbstractApplication {
4
- protected readonly stateService: BackendApplicationStateService;
5
- start(): Promise<void>;
6
- protected removeListeners(event: NodeJS.Signals): void;
7
- protected setupExitSignals(): void;
8
- protected doExit(): void;
9
- stop(): Promise<void>;
10
- }
@@ -1,52 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var BackendApplication_1;
11
- import { ApplicationStateService, AbstractApplication, Application, Component, Autowired } from '../../common/index.js';
12
- import { BackendApplicationStateService } from './backend-application-state.js';
13
- let BackendApplication = BackendApplication_1 = class BackendApplication extends AbstractApplication {
14
- async start() {
15
- this.setupExitSignals();
16
- await this.doStart();
17
- this.stateService.state = 'started';
18
- this.stateService.state = 'ready';
19
- }
20
- removeListeners(event) {
21
- for (const l of process.listeners(event)) {
22
- if (l._tag === BackendApplication_1.name) {
23
- process.removeListener(event, l);
24
- }
25
- }
26
- }
27
- setupExitSignals() {
28
- this.removeListeners('SIGINT');
29
- this.removeListeners('SIGTERM');
30
- const l = this.doExit.bind(this);
31
- l._tag = BackendApplication_1.name;
32
- process.once('SIGINT', l);
33
- process.once('SIGTERM', l);
34
- }
35
- doExit() {
36
- this.doStop();
37
- process.exit(0);
38
- }
39
- async stop() {
40
- this.doStop();
41
- this.stateService.state = 'stopped';
42
- }
43
- };
44
- __decorate([
45
- Autowired(ApplicationStateService),
46
- __metadata("design:type", BackendApplicationStateService)
47
- ], BackendApplication.prototype, "stateService", void 0);
48
- BackendApplication = BackendApplication_1 = __decorate([
49
- Component(Application)
50
- ], BackendApplication);
51
- export { BackendApplication };
52
- //# sourceMappingURL=backend-application.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backend-application.js","sourceRoot":"","sources":["../../../src/node/application/backend-application.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAGtE,IAAM,kBAAkB,0BAAxB,MAAM,kBAAmB,SAAQ,mBAAmB;IAKvD,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,SAAS,CAAC;QACpC,IAAI,CAAC,YAAY,CAAC,KAAK,GAAG,OAAO,CAAC;IACtC,CAAC;IAES,eAAe,CAAC,KAAqB;QAC3C,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACvC,IAAK,CAAS,CAAC,IAAI,KAAK,qBAAmB,IAAI,EAAE,CAAC;gBAC9C,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACrC,CAAC;QACL,CAAC;IACL,CAAC;IAES,gBAAgB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