@worktile/planet 12.1.1 → 14.0.0-next.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 (317) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/application/planet-application-loader.d.ts +73 -0
  3. package/application/planet-application-loader.d.ts.map +1 -0
  4. package/application/planet-application-ref.d.ts +36 -0
  5. package/application/planet-application-ref.d.ts.map +1 -0
  6. package/application/planet-application.service.d.ts +22 -0
  7. package/application/planet-application.service.d.ts.map +1 -0
  8. package/{packages/planet/src/application/portal-application.ts → application/portal-application.d.ts} +5 -18
  9. package/application/portal-application.d.ts.map +1 -0
  10. package/assets-loader.d.ts +36 -0
  11. package/assets-loader.d.ts.map +1 -0
  12. package/component/planet-component-loader.d.ts +31 -0
  13. package/component/planet-component-loader.d.ts.map +1 -0
  14. package/component/planet-component-ref.d.ts +8 -0
  15. package/component/planet-component-ref.d.ts.map +1 -0
  16. package/{packages/planet/src/component/plant-component.config.ts → component/plant-component.config.d.ts} +4 -4
  17. package/component/plant-component.config.d.ts.map +1 -0
  18. package/debug.d.ts +22 -0
  19. package/debug.d.ts.map +1 -0
  20. package/empty/empty.component.d.ts +6 -0
  21. package/empty/empty.component.d.ts.map +1 -0
  22. package/esm2020/application/planet-application-loader.mjs +454 -0
  23. package/esm2020/application/planet-application-ref.mjs +94 -0
  24. package/esm2020/application/planet-application.service.mjs +85 -0
  25. package/esm2020/application/portal-application.mjs +16 -0
  26. package/esm2020/assets-loader.mjs +216 -0
  27. package/esm2020/component/planet-component-loader.mjs +153 -0
  28. package/esm2020/component/planet-component-ref.mjs +3 -0
  29. package/esm2020/component/plant-component.config.mjs +7 -0
  30. package/esm2020/debug.mjs +33 -0
  31. package/esm2020/empty/empty.component.mjs +15 -0
  32. package/esm2020/global-event-dispatcher.mjs +70 -0
  33. package/esm2020/global-planet.mjs +53 -0
  34. package/esm2020/helpers.mjs +119 -0
  35. package/esm2020/module.mjs +31 -0
  36. package/esm2020/planet.class.mjs +9 -0
  37. package/esm2020/planet.mjs +91 -0
  38. package/esm2020/public-api.mjs +18 -0
  39. package/esm2020/sandbox/constants.mjs +7 -0
  40. package/esm2020/sandbox/exec.mjs +15 -0
  41. package/esm2020/sandbox/index.mjs +20 -0
  42. package/esm2020/sandbox/proxy/patches/document.mjs +12 -0
  43. package/esm2020/sandbox/proxy/patches/eventListener.mjs +41 -0
  44. package/esm2020/sandbox/proxy/patches/index.mjs +11 -0
  45. package/esm2020/sandbox/proxy/patches/storage.mjs +40 -0
  46. package/esm2020/sandbox/proxy/patches/timer.mjs +43 -0
  47. package/esm2020/sandbox/proxy/proxies/common.mjs +132 -0
  48. package/esm2020/sandbox/proxy/proxies/document.mjs +126 -0
  49. package/esm2020/sandbox/proxy/proxies/window.mjs +158 -0
  50. package/esm2020/sandbox/proxy/proxy-sandbox.mjs +49 -0
  51. package/esm2020/sandbox/proxy/types.mjs +2 -0
  52. package/esm2020/sandbox/sandbox.mjs +7 -0
  53. package/esm2020/sandbox/snapshot/snapshot-sandbox.mjs +12 -0
  54. package/esm2020/sandbox/types.mjs +2 -0
  55. package/esm2020/worktile-planet.mjs +5 -0
  56. package/fesm2015/worktile-planet.mjs +2049 -0
  57. package/fesm2015/worktile-planet.mjs.map +1 -0
  58. package/fesm2020/worktile-planet.mjs +2046 -0
  59. package/fesm2020/worktile-planet.mjs.map +1 -0
  60. package/global-event-dispatcher.d.ts +23 -0
  61. package/global-event-dispatcher.d.ts.map +1 -0
  62. package/global-planet.d.ts +23 -0
  63. package/global-planet.d.ts.map +1 -0
  64. package/helpers.d.ts +39 -0
  65. package/helpers.d.ts.map +1 -0
  66. package/index.d.ts +6 -0
  67. package/module.d.ts +12 -0
  68. package/module.d.ts.map +1 -0
  69. package/package.json +27 -120
  70. package/{packages/planet/src/planet.class.ts → planet.class.d.ts} +5 -26
  71. package/planet.class.d.ts.map +1 -0
  72. package/planet.d.ts +28 -0
  73. package/planet.d.ts.map +1 -0
  74. package/{packages/planet/src/public-api.ts → public-api.d.ts} +1 -4
  75. package/public-api.d.ts.map +1 -0
  76. package/sandbox/constants.d.ts +7 -0
  77. package/sandbox/constants.d.ts.map +1 -0
  78. package/sandbox/exec.d.ts +3 -0
  79. package/sandbox/exec.d.ts.map +1 -0
  80. package/sandbox/index.d.ts +7 -0
  81. package/sandbox/index.d.ts.map +1 -0
  82. package/sandbox/proxy/patches/document.d.ts +3 -0
  83. package/sandbox/proxy/patches/document.d.ts.map +1 -0
  84. package/sandbox/proxy/patches/eventListener.d.ts +3 -0
  85. package/sandbox/proxy/patches/eventListener.d.ts.map +1 -0
  86. package/sandbox/proxy/patches/index.d.ts +3 -0
  87. package/sandbox/proxy/patches/index.d.ts.map +1 -0
  88. package/sandbox/proxy/patches/storage.d.ts +15 -0
  89. package/sandbox/proxy/patches/storage.d.ts.map +1 -0
  90. package/sandbox/proxy/patches/timer.d.ts +3 -0
  91. package/sandbox/proxy/patches/timer.d.ts.map +1 -0
  92. package/sandbox/proxy/proxies/common.d.ts +13 -0
  93. package/sandbox/proxy/proxies/common.d.ts.map +1 -0
  94. package/sandbox/proxy/proxies/document.d.ts +14 -0
  95. package/sandbox/proxy/proxies/document.d.ts.map +1 -0
  96. package/sandbox/proxy/proxies/window.d.ts +13 -0
  97. package/sandbox/proxy/proxies/window.d.ts.map +1 -0
  98. package/sandbox/proxy/proxy-sandbox.d.ts +16 -0
  99. package/sandbox/proxy/proxy-sandbox.d.ts.map +1 -0
  100. package/{packages/planet/src/sandbox/proxy/types.ts → sandbox/proxy/types.d.ts} +2 -8
  101. package/sandbox/proxy/types.d.ts.map +1 -0
  102. package/sandbox/sandbox.d.ts +12 -0
  103. package/sandbox/sandbox.d.ts.map +1 -0
  104. package/sandbox/snapshot/snapshot-sandbox.d.ts +9 -0
  105. package/sandbox/snapshot/snapshot-sandbox.d.ts.map +1 -0
  106. package/sandbox/types.d.ts +2 -0
  107. package/sandbox/types.d.ts.map +1 -0
  108. package/worktile-planet.d.ts.map +1 -0
  109. package/.all-contributorsrc +0 -84
  110. package/.circleci/config.yml +0 -17
  111. package/.coveralls.yml +0 -1
  112. package/.docgeni/public/assets/favicon.ico +0 -0
  113. package/.docgeni/public/index.html +0 -13
  114. package/.docgenirc.js +0 -35
  115. package/.dockerignore +0 -1
  116. package/.editorconfig +0 -22
  117. package/.github/FUNDING.yml +0 -12
  118. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  119. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  120. package/.prettierignore +0 -7
  121. package/.prettierrc +0 -28
  122. package/.travis.yml +0 -26
  123. package/.wpmrc.js +0 -11
  124. package/CODE_OF_CONDUCT.md +0 -76
  125. package/Dockerfile +0 -11
  126. package/README.zh-CN.md +0 -307
  127. package/SECURITY.md +0 -21
  128. package/angular.json +0 -373
  129. package/commitlint.config.js +0 -6
  130. package/docs/api/defineApplication.md +0 -46
  131. package/docs/api/globalEventDispatcher.md +0 -51
  132. package/docs/api/index.md +0 -5
  133. package/docs/api/planet.md +0 -117
  134. package/docs/guides/getting-started.md +0 -174
  135. package/docs/guides/index.md +0 -5
  136. package/docs/guides/intro.md +0 -216
  137. package/examples/app1/browserslist +0 -11
  138. package/examples/app1/extra-webpack.config.js +0 -33
  139. package/examples/app1/karma.conf.js +0 -31
  140. package/examples/app1/postcss.config.js +0 -1
  141. package/examples/app1/src/app/app.module.ts +0 -44
  142. package/examples/app1/src/app/app.routing.ts +0 -49
  143. package/examples/app1/src/app/counter.service.ts +0 -16
  144. package/examples/app1/src/app/dashboard/dashboard.component.html +0 -51
  145. package/examples/app1/src/app/dashboard/dashboard.component.ts +0 -70
  146. package/examples/app1/src/app/detail/detail.component.html +0 -8
  147. package/examples/app1/src/app/detail/detail.component.ts +0 -18
  148. package/examples/app1/src/app/overlay.ts +0 -26
  149. package/examples/app1/src/app/projects/dialog/projects-dialog.component.html +0 -10
  150. package/examples/app1/src/app/projects/dialog/projects-dialog.component.ts +0 -41
  151. package/examples/app1/src/app/projects/projects.component.ts +0 -33
  152. package/examples/app1/src/app/root/root.component.css +0 -3
  153. package/examples/app1/src/app/root/root.component.html +0 -16
  154. package/examples/app1/src/app/root/root.component.ts +0 -35
  155. package/examples/app1/src/app/services/initialized-data.resolver.ts +0 -15
  156. package/examples/app1/src/app/shared.module.ts +0 -57
  157. package/examples/app1/src/app/user/detail/user-detail.component.html +0 -5
  158. package/examples/app1/src/app/user/detail/user-detail.component.ts +0 -20
  159. package/examples/app1/src/app/user/user-list.component.html +0 -7
  160. package/examples/app1/src/app/user/user-list.component.ts +0 -20
  161. package/examples/app1/src/app/user/user.module.ts +0 -31
  162. package/examples/app1/src/assets/.gitkeep +0 -0
  163. package/examples/app1/src/assets/github.png +0 -0
  164. package/examples/app1/src/assets/main.css +0 -3
  165. package/examples/app1/src/environments/environment.prod.ts +0 -3
  166. package/examples/app1/src/environments/environment.ts +0 -16
  167. package/examples/app1/src/favicon.ico +0 -0
  168. package/examples/app1/src/index.html +0 -14
  169. package/examples/app1/src/main.ts +0 -35
  170. package/examples/app1/src/polyfills.ts +0 -84
  171. package/examples/app1/src/styles.scss +0 -35
  172. package/examples/app1/src/test.ts +0 -14
  173. package/examples/app1/temp.js +0 -221
  174. package/examples/app1/tsconfig.app.json +0 -10
  175. package/examples/app1/tsconfig.spec.json +0 -18
  176. package/examples/app1/tslint.json +0 -17
  177. package/examples/app1/webpack.config.js +0 -127
  178. package/examples/app2/browserslist +0 -11
  179. package/examples/app2/extra-webpack.config.js +0 -32
  180. package/examples/app2/karma.conf.js +0 -31
  181. package/examples/app2/src/app/app.module.ts +0 -90
  182. package/examples/app2/src/app/dashboard/dashboard.component.html +0 -21
  183. package/examples/app2/src/app/dashboard/dashboard.component.ts +0 -27
  184. package/examples/app2/src/app/overlay.ts +0 -26
  185. package/examples/app2/src/app/projects/detail/detail.component.html +0 -16
  186. package/examples/app2/src/app/projects/detail/detail.component.ts +0 -21
  187. package/examples/app2/src/app/projects/project-list.component.html +0 -29
  188. package/examples/app2/src/app/projects/project-list.component.ts +0 -58
  189. package/examples/app2/src/app/projects/project.resolver.ts +0 -15
  190. package/examples/app2/src/app/projects/projects.service.ts +0 -28
  191. package/examples/app2/src/app/projects/tasks/tasks.component.html +0 -10
  192. package/examples/app2/src/app/projects/tasks/tasks.component.ts +0 -16
  193. package/examples/app2/src/app/projects/view/view.component.html +0 -1
  194. package/examples/app2/src/app/projects/view/view.component.ts +0 -20
  195. package/examples/app2/src/app/root/root.component.html +0 -14
  196. package/examples/app2/src/app/root/root.component.scss +0 -12
  197. package/examples/app2/src/app/root/root.component.ts +0 -28
  198. package/examples/app2/src/app/shared.module.ts +0 -59
  199. package/examples/app2/src/assets/.gitkeep +0 -0
  200. package/examples/app2/src/environments/environment.prod.ts +0 -3
  201. package/examples/app2/src/environments/environment.ts +0 -16
  202. package/examples/app2/src/favicon.ico +0 -0
  203. package/examples/app2/src/index.html +0 -14
  204. package/examples/app2/src/main.ts +0 -36
  205. package/examples/app2/src/polyfills.ts +0 -84
  206. package/examples/app2/src/styles.scss +0 -28
  207. package/examples/app2/src/test.ts +0 -14
  208. package/examples/app2/tsconfig.app.json +0 -10
  209. package/examples/app2/tsconfig.spec.json +0 -18
  210. package/examples/app2/tslint.json +0 -7
  211. package/examples/app2/webpack.config.js +0 -92
  212. package/examples/common/app-root-context.ts +0 -10
  213. package/examples/common/cache.ts +0 -82
  214. package/examples/common/index.ts +0 -13
  215. package/examples/common/module.ts +0 -10
  216. package/examples/common/overlay-container.service.ts +0 -28
  217. package/examples/common/section-card/section-card.component.html +0 -5
  218. package/examples/common/section-card/section-card.component.scss +0 -15
  219. package/examples/common/section-card/section-card.component.ts +0 -11
  220. package/examples/common/utils.ts +0 -0
  221. package/examples/portal/src/app/a-detail/a-detail.component.html +0 -8
  222. package/examples/portal/src/app/a-detail/a-detail.component.ts +0 -18
  223. package/examples/portal/src/app/about/about.component.html +0 -27
  224. package/examples/portal/src/app/about/about.component.scss +0 -0
  225. package/examples/portal/src/app/about/about.component.spec.ts +0 -26
  226. package/examples/portal/src/app/about/about.component.ts +0 -26
  227. package/examples/portal/src/app/app-routing.module.ts +0 -57
  228. package/examples/portal/src/app/app.component.html +0 -73
  229. package/examples/portal/src/app/app.component.scss +0 -58
  230. package/examples/portal/src/app/app.component.spec.ts +0 -33
  231. package/examples/portal/src/app/app.component.ts +0 -111
  232. package/examples/portal/src/app/app.module.ts +0 -64
  233. package/examples/portal/src/app/custom-settings.service.ts +0 -44
  234. package/examples/portal/src/app/overlay.ts +0 -26
  235. package/examples/portal/src/app/settings/settings.component.html +0 -31
  236. package/examples/portal/src/app/settings/settings.component.scss +0 -3
  237. package/examples/portal/src/app/settings/settings.component.ts +0 -43
  238. package/examples/portal/src/assets/.gitkeep +0 -0
  239. package/examples/portal/src/assets/apps.json +0 -29
  240. package/examples/portal/src/assets/icons/sprite.defs.svg +0 -1
  241. package/examples/portal/src/assets/images/logo.svg +0 -16
  242. package/examples/portal/src/assets/ngx-planet-micro-front-end.gif +0 -0
  243. package/examples/portal/src/browserslist +0 -11
  244. package/examples/portal/src/environments/environment.prod.ts +0 -3
  245. package/examples/portal/src/environments/environment.ts +0 -16
  246. package/examples/portal/src/extra-webpack.config.js +0 -32
  247. package/examples/portal/src/favicon.ico +0 -0
  248. package/examples/portal/src/index.html +0 -14
  249. package/examples/portal/src/karma.conf.js +0 -31
  250. package/examples/portal/src/main.ts +0 -18
  251. package/examples/portal/src/polyfills.ts +0 -84
  252. package/examples/portal/src/reboot.scss +0 -14
  253. package/examples/portal/src/styles.scss +0 -14
  254. package/examples/portal/src/test.ts +0 -14
  255. package/examples/portal/src/tsconfig.app.json +0 -10
  256. package/examples/portal/src/tsconfig.spec.json +0 -9
  257. package/examples/portal/src/tslint.json +0 -7
  258. package/extra-webpack.config.js +0 -5
  259. package/nginx.conf +0 -17
  260. package/packages/planet/karma.conf.js +0 -37
  261. package/packages/planet/ng-package.json +0 -7
  262. package/packages/planet/package.json +0 -10
  263. package/packages/planet/src/application/planet-application-loader.spec.ts +0 -1102
  264. package/packages/planet/src/application/planet-application-loader.ts +0 -549
  265. package/packages/planet/src/application/planet-application-ref.spec.ts +0 -233
  266. package/packages/planet/src/application/planet-application-ref.ts +0 -131
  267. package/packages/planet/src/application/planet-application.service.spec.ts +0 -145
  268. package/packages/planet/src/application/planet-application.service.ts +0 -88
  269. package/packages/planet/src/application/portal-application.spec.ts +0 -53
  270. package/packages/planet/src/assets-loader.spec.ts +0 -689
  271. package/packages/planet/src/assets-loader.ts +0 -247
  272. package/packages/planet/src/component/planet-component-loader.spec.ts +0 -187
  273. package/packages/planet/src/component/planet-component-loader.ts +0 -173
  274. package/packages/planet/src/component/planet-component-ref.ts +0 -8
  275. package/packages/planet/src/debug.spec.ts +0 -58
  276. package/packages/planet/src/debug.ts +0 -66
  277. package/packages/planet/src/empty/empty.component.spec.ts +0 -34
  278. package/packages/planet/src/empty/empty.component.ts +0 -7
  279. package/packages/planet/src/global-event-dispatcher.spec.ts +0 -81
  280. package/packages/planet/src/global-event-dispatcher.ts +0 -82
  281. package/packages/planet/src/global-planet.spec.ts +0 -39
  282. package/packages/planet/src/global-planet.ts +0 -73
  283. package/packages/planet/src/helpers.spec.ts +0 -242
  284. package/packages/planet/src/helpers.ts +0 -125
  285. package/packages/planet/src/module.spec.ts +0 -79
  286. package/packages/planet/src/module.ts +0 -25
  287. package/packages/planet/src/planet.spec.ts +0 -226
  288. package/packages/planet/src/planet.ts +0 -113
  289. package/packages/planet/src/sandbox/constants.ts +0 -6
  290. package/packages/planet/src/sandbox/exec.ts +0 -22
  291. package/packages/planet/src/sandbox/index.ts +0 -24
  292. package/packages/planet/src/sandbox/proxy/patches/document.ts +0 -13
  293. package/packages/planet/src/sandbox/proxy/patches/eventListener.ts +0 -49
  294. package/packages/planet/src/sandbox/proxy/patches/index.ts +0 -13
  295. package/packages/planet/src/sandbox/proxy/patches/storage.ts +0 -53
  296. package/packages/planet/src/sandbox/proxy/patches/timer.ts +0 -50
  297. package/packages/planet/src/sandbox/proxy/proxies/common.ts +0 -137
  298. package/packages/planet/src/sandbox/proxy/proxies/document.ts +0 -140
  299. package/packages/planet/src/sandbox/proxy/proxies/window.ts +0 -176
  300. package/packages/planet/src/sandbox/proxy/proxy-sandbox.ts +0 -59
  301. package/packages/planet/src/sandbox/sandbox.ts +0 -20
  302. package/packages/planet/src/sandbox/snapshot/snapshot-sandbox.ts +0 -12
  303. package/packages/planet/src/sandbox/types.ts +0 -1
  304. package/packages/planet/src/test.ts +0 -16
  305. package/packages/planet/src/testing/app1.module.ts +0 -34
  306. package/packages/planet/src/testing/app2.module.ts +0 -24
  307. package/packages/planet/src/testing/applications.ts +0 -58
  308. package/packages/planet/src/testing/index.ts +0 -2
  309. package/packages/planet/src/testing/utils.ts +0 -31
  310. package/packages/planet/tsconfig.lib.json +0 -27
  311. package/packages/planet/tsconfig.lib.prod.json +0 -9
  312. package/packages/planet/tsconfig.spec.json +0 -17
  313. package/packages/planet/tslint.json +0 -7
  314. package/postcss.config.js +0 -3
  315. package/proxy.conf.js +0 -15
  316. package/tsconfig.json +0 -23
  317. package/tslint.json +0 -80
@@ -1,66 +0,0 @@
1
- import { isFunction } from './helpers';
2
-
3
- export interface Debugger {
4
- (formatter: any, ...args: any[]): void;
5
-
6
- // color: string;
7
- // enabled: boolean;
8
- // log: (...args: any[]) => any;
9
- // namespace: string;
10
- // destroy: () => boolean;
11
- // extend: (namespace: string, delimiter?: string) => Debugger;
12
- }
13
-
14
- export interface Formatters {
15
- [formatter: string]: (v: any) => string;
16
- }
17
-
18
- export interface Debug {
19
- (namespace: string): Debugger;
20
- coerce: (val: any) => any;
21
- disable: () => string;
22
- enable: (namespaces: string) => void;
23
- enabled: (namespaces: string) => boolean;
24
- log: (...args: any[]) => any;
25
-
26
- names: RegExp[];
27
- skips: RegExp[];
28
-
29
- formatters: Formatters;
30
- }
31
-
32
- /**
33
- * Debug factory for debug module
34
- */
35
- let _debugFactory: Debug | undefined;
36
- let _debuggerMap: Record<string, Debugger> = {};
37
-
38
- export function createDebug(namespace: string): Debugger {
39
- const key = `planet:${namespace}`;
40
- return function(formatter: any, ...args: any[]) {
41
- if (_debugFactory) {
42
- let debugDebugger = _debuggerMap[key];
43
- if (!debugDebugger) {
44
- debugDebugger = _debugFactory(key);
45
- _debuggerMap[key] = debugDebugger;
46
- }
47
- debugDebugger(formatter, args);
48
- }
49
- };
50
- }
51
-
52
- export function setDebugFactory(debug: Debug) {
53
- if (debug && !isFunction(debug)) {
54
- throw new Error('debug factory type is invalid, must be function');
55
- }
56
- _debugFactory = debug;
57
- }
58
-
59
- export function clearDebugFactory() {
60
- _debugFactory = undefined;
61
- _debuggerMap = {};
62
- }
63
-
64
- export function getDebugFactory() {
65
- return _debugFactory;
66
- }
@@ -1,34 +0,0 @@
1
- import { TestBed, ComponentFixture } from '@angular/core/testing';
2
- import { NgxPlanetModule } from '../module';
3
- import { Component } from '@angular/core';
4
- import { By } from '@angular/platform-browser';
5
- import { EmptyComponent } from './empty.component';
6
-
7
- @Component({
8
- selector: 'empty-component-basic',
9
- template: '<empty-component></empty-component>'
10
- })
11
- class EmptyComponentBasicComponent {}
12
-
13
- describe('empty-component', () => {
14
- let fixture: ComponentFixture<EmptyComponentBasicComponent>;
15
- beforeEach(() => {
16
- TestBed.configureTestingModule({
17
- declarations: [EmptyComponentBasicComponent],
18
- imports: [NgxPlanetModule]
19
- });
20
- fixture = TestBed.createComponent(EmptyComponentBasicComponent);
21
- TestBed.compileComponents();
22
- });
23
-
24
- it(`should create empty component`, () => {
25
- const emptyComponentDebugElement = fixture.debugElement.query(By.directive(EmptyComponent));
26
- expect(emptyComponentDebugElement).toBeTruthy();
27
- expect(emptyComponentDebugElement.componentInstance).toBeTruthy();
28
- });
29
-
30
- it(`should content is empty in empty component`, () => {
31
- const emptyComponentDebugElement = fixture.debugElement.query(By.directive(EmptyComponent));
32
- expect((emptyComponentDebugElement.nativeElement as HTMLElement).children.length).toBe(0);
33
- });
34
- });
@@ -1,7 +0,0 @@
1
- import { Component } from '@angular/core';
2
-
3
- @Component({
4
- selector: 'empty-component',
5
- template: ``
6
- })
7
- export class EmptyComponent {}
@@ -1,81 +0,0 @@
1
- import { GlobalEventDispatcher } from './global-event-dispatcher';
2
- import { NgZone } from '@angular/core';
3
- import { TestBed, inject } from '@angular/core/testing';
4
- import { CommonModule } from '@angular/common';
5
- import { Subject } from 'rxjs';
6
- import { takeUntil } from 'rxjs/operators';
7
-
8
- describe('GlobalEventDispatcher', () => {
9
- let ngZone: NgZone;
10
- let globalEventDispatcher: GlobalEventDispatcher;
11
- beforeEach(() => {
12
- TestBed.configureTestingModule({
13
- imports: [CommonModule]
14
- });
15
- });
16
-
17
- beforeEach(inject(
18
- [NgZone, GlobalEventDispatcher],
19
- (_ngZone: NgZone, _globalEventDispatcher: GlobalEventDispatcher) => {
20
- ngZone = _ngZone;
21
- globalEventDispatcher = _globalEventDispatcher;
22
- }
23
- ));
24
-
25
- it(`should create GlobalEventDispatcher`, () => {
26
- expect(globalEventDispatcher).toBeTruthy();
27
- });
28
-
29
- it(`should register event success`, () => {
30
- const testEventSpy = jasmine.createSpy('test-event spy');
31
- const addEventListenerApy = spyOn(window, 'addEventListener');
32
- expect(addEventListenerApy).not.toHaveBeenCalled();
33
- expect(globalEventDispatcher.getSubscriptionCount()).toEqual(0);
34
- globalEventDispatcher.register('test-event').subscribe(testEventSpy);
35
- expect(globalEventDispatcher.getSubscriptionCount()).toEqual(1);
36
- expect(testEventSpy).not.toHaveBeenCalled();
37
- expect(addEventListenerApy).toHaveBeenCalled();
38
- });
39
-
40
- it(`should remove event listener when unsubscribe event success`, () => {
41
- const unsubscribe$ = new Subject();
42
- const removeEventListenerSpy = spyOn(window, 'removeEventListener');
43
- globalEventDispatcher
44
- .register('test-event')
45
- .pipe(takeUntil(unsubscribe$))
46
- .subscribe();
47
- expect(removeEventListenerSpy).not.toHaveBeenCalled();
48
- expect(globalEventDispatcher.getSubscriptionCount()).toEqual(1);
49
- unsubscribe$.next();
50
- unsubscribe$.complete();
51
- expect(removeEventListenerSpy).toHaveBeenCalled();
52
- expect(globalEventDispatcher.getSubscriptionCount()).toEqual(0);
53
- });
54
-
55
- it(`should run in ngZone when dispatch event`, () => {
56
- const ngZoneRunSpy = spyOn(ngZone, 'run');
57
- const testEventSpy = jasmine.createSpy('test-event spy');
58
- globalEventDispatcher.register('test-event').subscribe(testEventSpy);
59
- expect(testEventSpy).not.toHaveBeenCalled();
60
- expect(ngZoneRunSpy).not.toHaveBeenCalled();
61
- globalEventDispatcher.dispatch('test-event');
62
- expect(ngZoneRunSpy).toHaveBeenCalled();
63
- });
64
-
65
- it(`should dispatch event success`, () => {
66
- const testEventSpy = jasmine.createSpy('test-event spy');
67
- globalEventDispatcher.register('test-event').subscribe(testEventSpy);
68
- expect(testEventSpy).not.toHaveBeenCalled();
69
- globalEventDispatcher.dispatch('test-event');
70
- expect(testEventSpy).toHaveBeenCalled();
71
- });
72
-
73
- it(`should dispatch event with parameters success`, () => {
74
- const testEventSpy = jasmine.createSpy('test-event spy');
75
- globalEventDispatcher.register('test-event').subscribe(testEventSpy);
76
- expect(testEventSpy).not.toHaveBeenCalled();
77
- globalEventDispatcher.dispatch('test-event', 'test-event-payload');
78
- expect(testEventSpy).toHaveBeenCalled();
79
- expect(testEventSpy).toHaveBeenCalledWith('test-event-payload');
80
- });
81
- });
@@ -1,82 +0,0 @@
1
- import { Subject, Observable } from 'rxjs';
2
- import { filter, map } from 'rxjs/operators';
3
- import { Injectable, NgZone } from '@angular/core';
4
-
5
- export interface GlobalDispatcherEvent {
6
- name: string;
7
- payload: any;
8
- }
9
-
10
- const CUSTOM_EVENT_NAME = 'PLANET_GLOBAL_EVENT_DISPATCHER';
11
-
12
- @Injectable({
13
- providedIn: 'root'
14
- })
15
- export class GlobalEventDispatcher {
16
- private subject$: Subject<GlobalDispatcherEvent> = new Subject();
17
-
18
- private hasAddGlobalEventListener = false;
19
-
20
- private subscriptionCount = 0;
21
-
22
- private globalEventListener = (event: CustomEvent) => {
23
- this.subject$.next(event.detail);
24
- };
25
-
26
- private addGlobalEventListener() {
27
- this.hasAddGlobalEventListener = true;
28
- window.addEventListener(CUSTOM_EVENT_NAME, this.globalEventListener);
29
- }
30
-
31
- private removeGlobalEventListener() {
32
- this.hasAddGlobalEventListener = false;
33
- window.removeEventListener(CUSTOM_EVENT_NAME, this.globalEventListener);
34
- }
35
-
36
- constructor(private ngZone: NgZone) {}
37
-
38
- dispatch<TPayload>(name: string, payload?: TPayload) {
39
- window.dispatchEvent(
40
- new CustomEvent(CUSTOM_EVENT_NAME, {
41
- detail: {
42
- name: name,
43
- payload: payload
44
- }
45
- })
46
- );
47
- }
48
-
49
- register<T>(eventName: string): Observable<T> {
50
- return new Observable(observer => {
51
- if (!this.hasAddGlobalEventListener) {
52
- this.addGlobalEventListener();
53
- }
54
- this.subscriptionCount++;
55
- const subscription = this.subject$
56
- .pipe(
57
- filter(event => {
58
- return event.name === eventName;
59
- }),
60
- map(event => {
61
- return event.payload;
62
- })
63
- )
64
- .subscribe(payload => {
65
- this.ngZone.run(() => {
66
- observer.next(payload);
67
- });
68
- });
69
- return () => {
70
- this.subscriptionCount--;
71
- subscription.unsubscribe();
72
- if (!this.subscriptionCount) {
73
- this.removeGlobalEventListener();
74
- }
75
- };
76
- });
77
- }
78
-
79
- getSubscriptionCount() {
80
- return this.subscriptionCount;
81
- }
82
- }
@@ -1,39 +0,0 @@
1
- import { defineApplication, clearGlobalPlanet } from './global-planet';
2
- import { PlanetPortalApplication } from './application/portal-application';
3
-
4
- describe('defineApplication', () => {
5
- afterEach(() => {
6
- clearGlobalPlanet();
7
- });
8
-
9
- it('should define application success', () => {
10
- defineApplication('app1', {
11
- template: '<app1-root></app1-root>',
12
- bootstrap: (portalApp?: PlanetPortalApplication) => {
13
- return new Promise(() => {});
14
- }
15
- });
16
- expect(window['planet'].apps['app1']).toBeTruthy();
17
- });
18
-
19
- it('should define application compatible success', () => {
20
- defineApplication('app1', (portalApp?: PlanetPortalApplication) => {
21
- return new Promise(() => {});
22
- });
23
- expect(window['planet'].apps['app1']).toBeTruthy();
24
- });
25
-
26
- it('should throw error when define application has exist', () => {
27
- defineApplication('app1', {
28
- template: '<app1-root></app1-root>',
29
- bootstrap: (portalApp?: PlanetPortalApplication) => {
30
- return new Promise(() => {});
31
- }
32
- });
33
- expect(() => {
34
- defineApplication('app1', (portalApp?: PlanetPortalApplication) => {
35
- return new Promise(() => {});
36
- });
37
- }).toThrowError('app1 application has exist.');
38
- });
39
- });
@@ -1,73 +0,0 @@
1
- import { PlanetApplicationRef, BootstrapAppModule, BootstrapOptions } from './application/planet-application-ref';
2
- import { PlanetPortalApplication } from './application/portal-application';
3
- import { PlanetApplicationLoader } from './application/planet-application-loader';
4
- import { PlanetApplicationService } from './application/planet-application.service';
5
- import { isFunction } from './helpers';
6
-
7
- declare const window: any;
8
-
9
- export interface GlobalPlanet {
10
- apps: { [key: string]: PlanetApplicationRef };
11
- portalApplication?: PlanetPortalApplication;
12
- applicationLoader: PlanetApplicationLoader;
13
- applicationService: PlanetApplicationService;
14
- }
15
-
16
- export const globalPlanet: GlobalPlanet = (window.planet = window.planet || {
17
- apps: {}
18
- });
19
-
20
- export function defineApplication(name: string, options: BootstrapAppModule | BootstrapOptions) {
21
- if (globalPlanet.apps[name]) {
22
- throw new Error(`${name} application has exist.`);
23
- }
24
- if (isFunction(options)) {
25
- options = {
26
- template: '',
27
- bootstrap: options as BootstrapAppModule
28
- };
29
- }
30
- const appRef = new PlanetApplicationRef(name, options as BootstrapOptions);
31
- globalPlanet.apps[name] = appRef;
32
- }
33
-
34
- export function getPlanetApplicationRef(appName: string): PlanetApplicationRef | null {
35
- if (globalPlanet && globalPlanet.apps && globalPlanet.apps[appName]) {
36
- return globalPlanet.apps[appName];
37
- } else {
38
- return null;
39
- }
40
- }
41
-
42
- export function setPortalApplicationData<T>(data: T) {
43
- if (globalPlanet.portalApplication) {
44
- globalPlanet.portalApplication.data = data;
45
- }
46
- }
47
-
48
- export function getPortalApplicationData<TData>(): TData {
49
- return globalPlanet.portalApplication?.data as TData;
50
- }
51
-
52
- export function setApplicationLoader(loader: PlanetApplicationLoader) {
53
- globalPlanet.applicationLoader = loader;
54
- }
55
-
56
- export function getApplicationLoader() {
57
- return globalPlanet.applicationLoader;
58
- }
59
-
60
- export function setApplicationService(service: PlanetApplicationService) {
61
- globalPlanet.applicationService = service;
62
- }
63
-
64
- export function getApplicationService() {
65
- return globalPlanet.applicationService;
66
- }
67
-
68
- export function clearGlobalPlanet() {
69
- window.planet.apps = {};
70
- window.planet.portalApplication = null;
71
- window.planet.applicationLoader = null;
72
- window.planet.applicationService = null;
73
- }
@@ -1,242 +0,0 @@
1
- import {
2
- hashCode,
3
- isEmpty,
4
- coerceArray,
5
- getHTMLElement,
6
- getResourceFileName,
7
- buildResourceFilePath,
8
- getScriptsAndStylesFullPaths,
9
- getTagNameByTemplate,
10
- createElementByTemplate
11
- } from './helpers';
12
-
13
- describe('helpers', () => {
14
- describe('hashCode', () => {
15
- it(`should get number hash code`, () => {
16
- const result = hashCode('/scripts/main.js');
17
- expect(result).toBeTruthy();
18
- expect(typeof result === 'number').toBeTruthy();
19
- expect(/\d{9}/.test(result.toString())).toBeTruthy();
20
- });
21
-
22
- it(`should get same hash code when input is same`, () => {
23
- const result1 = hashCode('/scripts/main.js');
24
- const result2 = hashCode('/scripts/main.js');
25
- expect(result1).toEqual(result2);
26
- });
27
-
28
- it(`should get different hash code when input is different`, () => {
29
- const result1 = hashCode('/scripts/main.js');
30
- const result2 = hashCode('/scripts/main1.js');
31
- expect(result1).not.toEqual(result2);
32
- });
33
- });
34
-
35
- describe(`isEmpty`, () => {
36
- it(`should is empty when value is undefined`, () => {
37
- const result = isEmpty(undefined);
38
- expect(result).toBe(true);
39
- });
40
-
41
- it(`should is empty when value is null`, () => {
42
- const result = isEmpty(null);
43
- expect(result).toBe(true);
44
- });
45
-
46
- it(`should is empty when value is 0`, () => {
47
- const result = isEmpty(0);
48
- expect(result).toBe(true);
49
- });
50
-
51
- it(`should is empty when value is false`, () => {
52
- const result = isEmpty(false);
53
- expect(result).toBe(true);
54
- });
55
-
56
- it(`should is not empty when value is true`, () => {
57
- const result = isEmpty(true);
58
- expect(result).toBe(false);
59
- });
60
-
61
- it(`should is empty when value is empty array`, () => {
62
- const result = isEmpty([]);
63
- expect(result).toBe(true);
64
- });
65
-
66
- it(`should is not empty when value is not empty array`, () => {
67
- const result = isEmpty([1]);
68
- expect(result).toBe(false);
69
- });
70
-
71
- it(`should is not empty when value is number`, () => {
72
- const result = isEmpty(1);
73
- expect(result).toBe(false);
74
- });
75
-
76
- it(`should is not empty when value is object`, () => {
77
- const result = isEmpty({});
78
- expect(result).toBe(false);
79
- });
80
- });
81
-
82
- describe('coerceArray', () => {
83
- it('should wrap a string in an array', () => {
84
- const stringVal = 'just a string';
85
- expect(coerceArray(stringVal)).toEqual([stringVal]);
86
- });
87
-
88
- it('should wrap a number in an array', () => {
89
- const numberVal = 42;
90
- expect(coerceArray(numberVal)).toEqual([numberVal]);
91
- });
92
-
93
- it('should wrap an object in an array', () => {
94
- const objectVal = { something: 'clever' };
95
- expect(coerceArray(objectVal)).toEqual([objectVal]);
96
- });
97
-
98
- it('should wrap a null value in an array', () => {
99
- const nullVal = null;
100
- expect(coerceArray(nullVal)).toEqual([nullVal]);
101
- });
102
-
103
- it('should wrap an undefined value in an array', () => {
104
- const undefinedVal = undefined;
105
- expect(coerceArray(undefinedVal)).toEqual([undefinedVal]);
106
- });
107
-
108
- it('should not wrap an array in an array', () => {
109
- const arrayVal = [1, 2, 3];
110
- expect(coerceArray(arrayVal)).toBe(arrayVal);
111
- });
112
- });
113
-
114
- describe('getHTMLElement', () => {
115
- it('should get HTMLElement when input is HTMLElement', () => {
116
- const htmlElement = document.createElement('div');
117
- const result = getHTMLElement(htmlElement);
118
- expect(result).toBe(htmlElement);
119
- });
120
-
121
- it('should call document querySelector when input is not HTMLElement', () => {
122
- const querySelectorSpy = spyOn(document, 'querySelector');
123
- expect(querySelectorSpy).toHaveBeenCalledTimes(0);
124
- getHTMLElement('.span');
125
- expect(querySelectorSpy).toHaveBeenCalledTimes(1);
126
- expect(querySelectorSpy).toHaveBeenCalledWith('.span');
127
- });
128
- });
129
-
130
- describe(`createElementByTemplate`, () => {
131
- it('should create html element success', () => {
132
- const element = createElementByTemplate(`<app1-root class='app1-root'></app1-root>`);
133
- expect(element.outerHTML).toBe(`<app1-root class="app1-root"></app1-root>`);
134
- });
135
-
136
- it('should create html element when template invalid', () => {
137
- expect(() => {
138
- createElementByTemplate(`app1-root`);
139
- }).toThrowError(`invalid template 'app1-root'`);
140
- });
141
-
142
- it('should create html element when template is empty', () => {
143
- const element = createElementByTemplate(``);
144
- expect(element).toBe(null);
145
- });
146
- });
147
-
148
- describe(`getTagNameByTemplate`, () => {
149
- it('should get tagName is APP1-ROOT', () => {
150
- const tagName = getTagNameByTemplate(`<app1-root></app1-root>`);
151
- expect(tagName).toBe('APP1-ROOT');
152
- });
153
-
154
- it('should get tagName when template is empty', () => {
155
- const tagName = getTagNameByTemplate(``);
156
- expect(tagName).toBe('');
157
- });
158
- });
159
-
160
- describe('getResourceFileName', () => {
161
- it('should get original path when path is "file.js"', () => {
162
- const path = 'file.js';
163
- const result = getResourceFileName(path);
164
- expect(result).toBe(path);
165
- });
166
-
167
- it('should get correct path when path is "assets/file.js"', () => {
168
- const path = 'assets/file.js';
169
- const result = getResourceFileName(path);
170
- expect(result).toBe('file.js');
171
- });
172
- });
173
-
174
- describe('buildResourceFilePath', () => {
175
- it('should get correct path input "main.js"', () => {
176
- const result = buildResourceFilePath('main.js', { 'main.js': 'main.h2d3f2232.js' });
177
- expect(result).toBe('main.h2d3f2232.js');
178
- });
179
-
180
- it('should get correct path when input "main.js" which has not exist in manifest', () => {
181
- const result = buildResourceFilePath('main.js', {});
182
- expect(result).toBe('main.js');
183
- });
184
-
185
- it('should get correct path input "assets/scripts/main.js"', () => {
186
- const result = buildResourceFilePath('assets/scripts/main.js', { 'main.js': 'main.h2d3f2232.js' });
187
- expect(result).toBe('assets/scripts/main.h2d3f2232.js');
188
- });
189
- });
190
-
191
- describe('getScriptsAndStylesFullPaths', () => {
192
- const app = {
193
- name: 'app1',
194
- hostParent: '.host-selector',
195
- selector: 'app1-root',
196
- routerPathPrefix: '/app1',
197
- hostClass: 'app1-host',
198
- preload: false,
199
- // resourcePathPrefix: '/static/app1/',
200
- styles: ['styles/main.css'],
201
- scripts: ['vendor.js', 'main.js'],
202
- extra: {
203
- appName: '应用1'
204
- }
205
- };
206
-
207
- it('should get correct full path without resourcePathPrefix', () => {
208
- const result = getScriptsAndStylesFullPaths({ ...app });
209
- expect(result).toEqual({
210
- scripts: ['vendor.js', 'main.js'],
211
- styles: ['styles/main.css']
212
- });
213
- });
214
-
215
- it('should get correct full path with resourcePathPrefix', () => {
216
- const result = getScriptsAndStylesFullPaths({ ...app, resourcePathPrefix: '/static/app1/' });
217
- expect(result).toEqual({
218
- scripts: ['/static/app1/vendor.js', '/static/app1/main.js'],
219
- styles: ['/static/app1/styles/main.css']
220
- });
221
- });
222
-
223
- it('should get correct full path with manifest', () => {
224
- const manifest = {
225
- 'vendor.js': `vendor.${randomString()}.js`,
226
- 'main.js': `main.${randomString()}.js`,
227
- 'main.css': `main.${randomString()}.css`
228
- };
229
- const result = getScriptsAndStylesFullPaths({ ...app, resourcePathPrefix: '/static/app1/' }, manifest);
230
- expect(result).toEqual({
231
- scripts: [`/static/app1/${manifest['vendor.js']}`, `/static/app1/${manifest['main.js']}`],
232
- styles: [`/static/app1/styles/${manifest['main.css']}`]
233
- });
234
- });
235
- });
236
- });
237
-
238
- function randomString() {
239
- return Math.random()
240
- .toString(36)
241
- .slice(-8);
242
- }