@web-atoms/core 2.1.479 → 2.2.1

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 (296) hide show
  1. package/dist/App.js +189 -242
  2. package/dist/App.js.map +1 -1
  3. package/dist/Atom.js +123 -138
  4. package/dist/Atom.js.map +1 -1
  5. package/dist/MockApp.js +32 -32
  6. package/dist/MockApp.js.map +1 -1
  7. package/dist/Pack.js +11 -17
  8. package/dist/Pack.js.map +1 -1
  9. package/dist/core/AtomBinder.js +187 -199
  10. package/dist/core/AtomBinder.js.map +1 -1
  11. package/dist/core/AtomBridge.js +251 -274
  12. package/dist/core/AtomBridge.js.map +1 -1
  13. package/dist/core/AtomComponent.js +509 -592
  14. package/dist/core/AtomComponent.js.map +1 -1
  15. package/dist/core/AtomDispatcher.js +50 -54
  16. package/dist/core/AtomDispatcher.js.map +1 -1
  17. package/dist/core/AtomDisposableList.js +31 -36
  18. package/dist/core/AtomDisposableList.js.map +1 -1
  19. package/dist/core/AtomEnumerator.js +19 -21
  20. package/dist/core/AtomEnumerator.js.map +1 -1
  21. package/dist/core/AtomList.js +168 -232
  22. package/dist/core/AtomList.js.map +1 -1
  23. package/dist/core/AtomLoader.js +274 -257
  24. package/dist/core/AtomLoader.js.map +1 -1
  25. package/dist/core/AtomMap.js +15 -20
  26. package/dist/core/AtomMap.js.map +1 -1
  27. package/dist/core/AtomOnce.js +31 -71
  28. package/dist/core/AtomOnce.js.map +1 -1
  29. package/dist/core/AtomSelectableList.js +210 -223
  30. package/dist/core/AtomSelectableList.js.map +1 -1
  31. package/dist/core/AtomUri.js +78 -85
  32. package/dist/core/AtomUri.js.map +1 -1
  33. package/dist/core/AtomWatcher.js +112 -186
  34. package/dist/core/AtomWatcher.js.map +1 -1
  35. package/dist/core/Bind.js +288 -380
  36. package/dist/core/Bind.js.map +1 -1
  37. package/dist/core/BindableProperty.js +40 -59
  38. package/dist/core/BindableProperty.js.map +1 -1
  39. package/dist/core/CancelTokenFactory.js +42 -49
  40. package/dist/core/CancelTokenFactory.js.map +1 -1
  41. package/dist/core/Color.js +9 -13
  42. package/dist/core/Color.js.map +1 -1
  43. package/dist/core/Colors.js +254 -254
  44. package/dist/core/Colors.js.map +1 -1
  45. package/dist/core/Defer.js +37 -47
  46. package/dist/core/Defer.js.map +1 -1
  47. package/dist/core/EventScope.js +52 -49
  48. package/dist/core/EventScope.js.map +1 -1
  49. package/dist/core/ExpressionParser.js +152 -216
  50. package/dist/core/ExpressionParser.js.map +1 -1
  51. package/dist/core/FormattedError.js +17 -19
  52. package/dist/core/FormattedError.js.map +1 -1
  53. package/dist/core/FormattedString.js +14 -16
  54. package/dist/core/FormattedString.js.map +1 -1
  55. package/dist/core/IFetchEvent.js +9 -13
  56. package/dist/core/IFetchEvent.js.map +1 -1
  57. package/dist/core/IScreen.js +9 -13
  58. package/dist/core/IScreen.js.map +1 -1
  59. package/dist/core/IValueConverter.js +9 -13
  60. package/dist/core/IValueConverter.js.map +1 -1
  61. package/dist/core/InheritedProperty.js +83 -99
  62. package/dist/core/InheritedProperty.js.map +1 -1
  63. package/dist/core/InjectProperty.js +22 -29
  64. package/dist/core/InjectProperty.js.map +1 -1
  65. package/dist/core/KeyValuePairs.js +9 -13
  66. package/dist/core/KeyValuePairs.js.map +1 -1
  67. package/dist/core/Markdown.js +22 -24
  68. package/dist/core/Markdown.js.map +1 -1
  69. package/dist/core/MarkdownError.js +20 -20
  70. package/dist/core/MarkdownError.js.map +1 -1
  71. package/dist/core/PropertyBinding.js +11 -16
  72. package/dist/core/PropertyBinding.js.map +1 -1
  73. package/dist/core/PropertyMap.js +37 -44
  74. package/dist/core/PropertyMap.js.map +1 -1
  75. package/dist/core/SingleInvoker.js +51 -54
  76. package/dist/core/SingleInvoker.js.map +1 -1
  77. package/dist/core/StringHelper.js +36 -39
  78. package/dist/core/StringHelper.js.map +1 -1
  79. package/dist/core/TransientDisposable.js +23 -26
  80. package/dist/core/TransientDisposable.js.map +1 -1
  81. package/dist/core/WatchProperty.js +34 -34
  82. package/dist/core/WatchProperty.js.map +1 -1
  83. package/dist/core/WebImage.js +15 -17
  84. package/dist/core/WebImage.js.map +1 -1
  85. package/dist/core/XNode.js +129 -157
  86. package/dist/core/XNode.js.map +1 -1
  87. package/dist/core/sleep.js +34 -40
  88. package/dist/core/sleep.js.map +1 -1
  89. package/dist/core/types.js +80 -88
  90. package/dist/core/types.js.map +1 -1
  91. package/dist/di/DISingleton.js +23 -21
  92. package/dist/di/DISingleton.js.map +1 -1
  93. package/dist/di/DITransient.js +23 -21
  94. package/dist/di/DITransient.js.map +1 -1
  95. package/dist/di/IMockOrInject.js +9 -13
  96. package/dist/di/IMockOrInject.js.map +1 -1
  97. package/dist/di/IServiceProvider.js +9 -13
  98. package/dist/di/IServiceProvider.js.map +1 -1
  99. package/dist/di/Inject.js +79 -88
  100. package/dist/di/Inject.js.map +1 -1
  101. package/dist/di/Register.js +49 -51
  102. package/dist/di/Register.js.map +1 -1
  103. package/dist/di/RegisterScoped.js +20 -20
  104. package/dist/di/RegisterScoped.js.map +1 -1
  105. package/dist/di/RegisterSingleton.js +20 -20
  106. package/dist/di/RegisterSingleton.js.map +1 -1
  107. package/dist/di/ServiceCollection.js +46 -45
  108. package/dist/di/ServiceCollection.js.map +1 -1
  109. package/dist/di/ServiceProvider.js +111 -109
  110. package/dist/di/ServiceProvider.js.map +1 -1
  111. package/dist/di/TypeKey.js +20 -43
  112. package/dist/di/TypeKey.js.map +1 -1
  113. package/dist/services/BusyIndicatorService.js +26 -32
  114. package/dist/services/BusyIndicatorService.js.map +1 -1
  115. package/dist/services/CacheService.js +112 -98
  116. package/dist/services/CacheService.js.map +1 -1
  117. package/dist/services/JsonService.js +131 -133
  118. package/dist/services/JsonService.js.map +1 -1
  119. package/dist/services/MockNavigationService.js +152 -221
  120. package/dist/services/MockNavigationService.js.map +1 -1
  121. package/dist/services/NavigationService.js +140 -154
  122. package/dist/services/NavigationService.js.map +1 -1
  123. package/dist/services/ReferenceService.js +47 -50
  124. package/dist/services/ReferenceService.js.map +1 -1
  125. package/dist/services/http/AjaxOptions.js +12 -16
  126. package/dist/services/http/AjaxOptions.js.map +1 -1
  127. package/dist/services/http/JsonError.js +17 -19
  128. package/dist/services/http/JsonError.js.map +1 -1
  129. package/dist/services/http/RestService.js +395 -583
  130. package/dist/services/http/RestService.js.map +1 -1
  131. package/dist/style/StyleRule.js +1830 -1844
  132. package/dist/style/StyleRule.js.map +1 -1
  133. package/dist/test.js +9 -66
  134. package/dist/test.js.map +1 -1
  135. package/dist/tsconfig.tsbuildinfo +1 -1
  136. package/dist/unit/AtomTest.js +54 -36
  137. package/dist/unit/AtomTest.js.map +1 -1
  138. package/dist/unit/AtomWebTest.js +64 -43
  139. package/dist/unit/AtomWebTest.js.map +1 -1
  140. package/dist/view-model/Action.js +152 -134
  141. package/dist/view-model/Action.js.map +1 -1
  142. package/dist/view-model/AtomViewModel.js +318 -416
  143. package/dist/view-model/AtomViewModel.js.map +1 -1
  144. package/dist/view-model/AtomWindowViewModel.js +55 -90
  145. package/dist/view-model/AtomWindowViewModel.js.map +1 -1
  146. package/dist/view-model/BindableUrlParameter.js +25 -25
  147. package/dist/view-model/BindableUrlParameter.js.map +1 -1
  148. package/dist/view-model/Delay.js +34 -46
  149. package/dist/view-model/Delay.js.map +1 -1
  150. package/dist/view-model/Disposable.js +31 -39
  151. package/dist/view-model/Disposable.js.map +1 -1
  152. package/dist/view-model/Load.js +119 -123
  153. package/dist/view-model/Load.js.map +1 -1
  154. package/dist/view-model/Once.js +48 -53
  155. package/dist/view-model/Once.js.map +1 -1
  156. package/dist/view-model/baseTypes.js +15 -20
  157. package/dist/view-model/baseTypes.js.map +1 -1
  158. package/dist/view-model/bindPromise.js +42 -48
  159. package/dist/view-model/bindPromise.js.map +1 -1
  160. package/dist/view-model/bindProperty.js +17 -27
  161. package/dist/view-model/bindProperty.js.map +1 -1
  162. package/dist/view-model/bindUrlParameter.js +55 -66
  163. package/dist/view-model/bindUrlParameter.js.map +1 -1
  164. package/dist/web/WebApp.js +136 -135
  165. package/dist/web/WebApp.js.map +1 -1
  166. package/dist/web/controls/AtomAlertWindow.js +61 -90
  167. package/dist/web/controls/AtomAlertWindow.js.map +1 -1
  168. package/dist/web/controls/AtomComboBox.js +82 -86
  169. package/dist/web/controls/AtomComboBox.js.map +1 -1
  170. package/dist/web/controls/AtomContentControl.js +52 -50
  171. package/dist/web/controls/AtomContentControl.js.map +1 -1
  172. package/dist/web/controls/AtomControl.js +435 -476
  173. package/dist/web/controls/AtomControl.js.map +1 -1
  174. package/dist/web/controls/AtomFrame.js +224 -226
  175. package/dist/web/controls/AtomFrame.js.map +1 -1
  176. package/dist/web/controls/AtomGridSplitter.js +67 -65
  177. package/dist/web/controls/AtomGridSplitter.js.map +1 -1
  178. package/dist/web/controls/AtomGridView.js +228 -254
  179. package/dist/web/controls/AtomGridView.js.map +1 -1
  180. package/dist/web/controls/AtomItemsControl.js +622 -761
  181. package/dist/web/controls/AtomItemsControl.js.map +1 -1
  182. package/dist/web/controls/AtomListBox.js +56 -64
  183. package/dist/web/controls/AtomListBox.js.map +1 -1
  184. package/dist/web/controls/AtomNotification.js +59 -54
  185. package/dist/web/controls/AtomNotification.js.map +1 -1
  186. package/dist/web/controls/AtomPage.js +18 -20
  187. package/dist/web/controls/AtomPage.js.map +1 -1
  188. package/dist/web/controls/AtomPageLink.js +131 -107
  189. package/dist/web/controls/AtomPageLink.js.map +1 -1
  190. package/dist/web/controls/AtomTabbedPage.js +269 -246
  191. package/dist/web/controls/AtomTabbedPage.js.map +1 -1
  192. package/dist/web/controls/AtomTemplate.js +14 -17
  193. package/dist/web/controls/AtomTemplate.js.map +1 -1
  194. package/dist/web/controls/AtomTemplateControl.js +38 -40
  195. package/dist/web/controls/AtomTemplateControl.js.map +1 -1
  196. package/dist/web/controls/AtomToggleButtonBar.js +37 -37
  197. package/dist/web/controls/AtomToggleButtonBar.js.map +1 -1
  198. package/dist/web/controls/AtomViewPager.js +87 -67
  199. package/dist/web/controls/AtomViewPager.js.map +1 -1
  200. package/dist/web/controls/AtomViewStack.js +30 -32
  201. package/dist/web/controls/AtomViewStack.js.map +1 -1
  202. package/dist/web/controls/AtomWindow.js +218 -233
  203. package/dist/web/controls/AtomWindow.js.map +1 -1
  204. package/dist/web/core/AtomUI.js +160 -172
  205. package/dist/web/core/AtomUI.js.map +1 -1
  206. package/dist/web/core/Encoder.js +152 -199
  207. package/dist/web/core/Encoder.js.map +1 -1
  208. package/dist/web/core/HtmlNode.js +165 -161
  209. package/dist/web/core/HtmlNode.js.map +1 -1
  210. package/dist/web/images/Busy.js +13 -14
  211. package/dist/web/images/Busy.js.map +1 -1
  212. package/dist/web/images/BusyDataUrl.js +14 -882
  213. package/dist/web/images/BusyDataUrl.js.map +1 -1
  214. package/dist/web/images/Button.js +13 -15
  215. package/dist/web/images/Button.js.map +1 -1
  216. package/dist/web/images/ButtonDataUrl.js +14 -43
  217. package/dist/web/images/ButtonDataUrl.js.map +1 -1
  218. package/dist/web/images/CloseButton.js +13 -14
  219. package/dist/web/images/CloseButton.js.map +1 -1
  220. package/dist/web/images/CloseButtonDataUrl.js +14 -43
  221. package/dist/web/images/CloseButtonDataUrl.js.map +1 -1
  222. package/dist/web/images/CloseButtonHover.js +13 -14
  223. package/dist/web/images/CloseButtonHover.js.map +1 -1
  224. package/dist/web/images/CloseButtonHoverDataUrl.js +14 -37
  225. package/dist/web/images/CloseButtonHoverDataUrl.js.map +1 -1
  226. package/dist/web/samples/MovieService.js +60 -49
  227. package/dist/web/samples/MovieService.js.map +1 -1
  228. package/dist/web/samples/demo/app.js +23 -23
  229. package/dist/web/samples/demo/app.js.map +1 -1
  230. package/dist/web/samples/demo/views/MovieList.js +64 -67
  231. package/dist/web/samples/demo/views/MovieList.js.map +1 -1
  232. package/dist/web/samples/demo/views/MovieListViewModel.js +102 -82
  233. package/dist/web/samples/demo/views/MovieListViewModel.js.map +1 -1
  234. package/dist/web/samples/tabs/app.js +57 -39
  235. package/dist/web/samples/tabs/app.js.map +1 -1
  236. package/dist/web/samples/tabs/views/List.js +13 -14
  237. package/dist/web/samples/tabs/views/List.js.map +1 -1
  238. package/dist/web/samples/tabs/views/ListDataUrl.js +14 -18
  239. package/dist/web/samples/tabs/views/ListDataUrl.js.map +1 -1
  240. package/dist/web/samples/tabs/views/Page1.js +94 -74
  241. package/dist/web/samples/tabs/views/Page1.js.map +1 -1
  242. package/dist/web/samples/tabs/views/TabHost.js +82 -63
  243. package/dist/web/samples/tabs/views/TabHost.js.map +1 -1
  244. package/dist/web/samples/window/WindowSample.js +27 -23
  245. package/dist/web/samples/window/WindowSample.js.map +1 -1
  246. package/dist/web/services/MarkdownService.js +35 -51
  247. package/dist/web/services/MarkdownService.js.map +1 -1
  248. package/dist/web/services/NotificationPopup.js +48 -44
  249. package/dist/web/services/NotificationPopup.js.map +1 -1
  250. package/dist/web/services/PopupService.js +770 -940
  251. package/dist/web/services/PopupService.js.map +1 -1
  252. package/dist/web/services/WebBusyIndicatorService.js +80 -86
  253. package/dist/web/services/WebBusyIndicatorService.js.map +1 -1
  254. package/dist/web/services/WindowService.js +332 -418
  255. package/dist/web/services/WindowService.js.map +1 -1
  256. package/dist/web/styles/AtomAlertWindowStyle.js +44 -34
  257. package/dist/web/styles/AtomAlertWindowStyle.js.map +1 -1
  258. package/dist/web/styles/AtomFrameStyle.js +27 -20
  259. package/dist/web/styles/AtomFrameStyle.js.map +1 -1
  260. package/dist/web/styles/AtomListBoxStyle.js +34 -32
  261. package/dist/web/styles/AtomListBoxStyle.js.map +1 -1
  262. package/dist/web/styles/AtomNotificationStyle.js +33 -33
  263. package/dist/web/styles/AtomNotificationStyle.js.map +1 -1
  264. package/dist/web/styles/AtomPageLinkStyle.js +21 -22
  265. package/dist/web/styles/AtomPageLinkStyle.js.map +1 -1
  266. package/dist/web/styles/AtomPopupStyle.js +21 -23
  267. package/dist/web/styles/AtomPopupStyle.js.map +1 -1
  268. package/dist/web/styles/AtomStyle.js +69 -73
  269. package/dist/web/styles/AtomStyle.js.map +1 -1
  270. package/dist/web/styles/AtomStyleSheet.js +54 -57
  271. package/dist/web/styles/AtomStyleSheet.js.map +1 -1
  272. package/dist/web/styles/AtomTabbedPageStyle.js +110 -105
  273. package/dist/web/styles/AtomTabbedPageStyle.js.map +1 -1
  274. package/dist/web/styles/AtomTheme.js +62 -65
  275. package/dist/web/styles/AtomTheme.js.map +1 -1
  276. package/dist/web/styles/AtomToggleButtonBarStyle.js +68 -49
  277. package/dist/web/styles/AtomToggleButtonBarStyle.js.map +1 -1
  278. package/dist/web/styles/AtomWindowStyle.js +108 -117
  279. package/dist/web/styles/AtomWindowStyle.js.map +1 -1
  280. package/dist/web/styles/CSS.js +71 -81
  281. package/dist/web/styles/CSS.js.map +1 -1
  282. package/dist/web/styles/CommonStyles.js +60 -66
  283. package/dist/web/styles/CommonStyles.js.map +1 -1
  284. package/dist/web/styles/IStyleDeclaration.js +9 -13
  285. package/dist/web/styles/IStyleDeclaration.js.map +1 -1
  286. package/dist/web/styles/StyleBuilder.js +74 -75
  287. package/dist/web/styles/StyleBuilder.js.map +1 -1
  288. package/dist/xf/XFApp.js +54 -50
  289. package/dist/xf/XFApp.js.map +1 -1
  290. package/dist/xf/controls/AtomXFControl.js +233 -229
  291. package/dist/xf/controls/AtomXFControl.js.map +1 -1
  292. package/dist/xf/services/XFBusyIndicatorService.js +34 -34
  293. package/dist/xf/services/XFBusyIndicatorService.js.map +1 -1
  294. package/dist/xf/services/XFNavigationService.js +150 -133
  295. package/dist/xf/services/XFNavigationService.js.map +1 -1
  296. package/package.json +3 -2
@@ -1,456 +1,358 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- (function (factory) {
23
- if (typeof module === "object" && typeof module.exports === "object") {
24
- var v = factory(require, exports);
25
- if (v !== undefined) module.exports = v;
1
+ System.register(["../App", "../Atom", "../core/AtomBinder", "../core/AtomDisposableList", "../core/AtomWatcher", "../core/BindableProperty", "../di/Inject", "./baseTypes"], function (_export, _context) {
2
+ "use strict";
3
+
4
+ var App, Atom, AtomBinder, AtomDisposableList, AtomWatcher, BindableProperty, Inject, registerInit, __decorate, __metadata, __param, __awaiter, AtomViewModel;
5
+ function runDecoratorInits() {
6
+ const v = this.constructor.prototype;
7
+ if (!v) {
8
+ return;
26
9
  }
27
- else if (typeof define === "function" && define.amd) {
28
- define(["require", "exports", "../App", "../Atom", "../core/AtomBinder", "../core/AtomDisposableList", "../core/AtomWatcher", "../core/BindableProperty", "../di/Inject", "./baseTypes"], factory);
10
+ const ris = v._$_inits;
11
+ if (ris) {
12
+ for (const ri of ris) {
13
+ ri.call(this, this);
14
+ }
29
15
  }
30
- })(function (require, exports) {
31
- "use strict";
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.Validate = exports.CachedWatch = exports.Watch = exports.BindableBroadcast = exports.BindableReceive = exports.Receive = exports.AtomViewModel = exports.waitForReady = void 0;
34
- const App_1 = require("../App");
35
- const Atom_1 = require("../Atom");
36
- const AtomBinder_1 = require("../core/AtomBinder");
37
- const AtomDisposableList_1 = require("../core/AtomDisposableList");
38
- const AtomWatcher_1 = require("../core/AtomWatcher");
39
- const BindableProperty_1 = require("../core/BindableProperty");
40
- const Inject_1 = require("../di/Inject");
41
- const baseTypes_1 = require("./baseTypes");
42
- function runDecoratorInits() {
43
- const v = this.constructor.prototype;
44
- if (!v) {
45
- return;
16
+ }
17
+ function privateInit() {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ try {
20
+ yield Atom.postAsync(this.app, () => __awaiter(this, void 0, void 0, function* () {
21
+ runDecoratorInits.apply(this);
22
+ }));
23
+ yield Atom.postAsync(this.app, () => __awaiter(this, void 0, void 0, function* () {
24
+ yield this.init();
25
+ this.onReady();
26
+ }));
27
+ if (this.postInit) {
28
+ for (const i of this.postInit) {
29
+ i();
30
+ }
31
+ this.postInit = null;
46
32
  }
47
- const ris = v._$_inits;
48
- if (ris) {
49
- for (const ri of ris) {
50
- ri.call(this, this);
51
- }
33
+ } finally {
34
+ const pi = this.pendingInits;
35
+ this.pendingInits = null;
36
+ for (const iterator of pi) {
37
+ iterator();
52
38
  }
53
- }
54
- function privateInit() {
55
- return __awaiter(this, void 0, void 0, function* () {
39
+ }
40
+ });
41
+ }
42
+ function waitForReady(vm) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ while (vm.pendingInits) {
45
+ yield Atom.delay(100);
46
+ }
47
+ });
48
+ }
49
+ function Receive(...channel) {
50
+ return (target, key) => {
51
+ registerInit(target, vm => {
52
+ const fx = vm[key];
53
+ const a = (ch, d) => {
54
+ const p = fx.call(vm, ch, d);
55
+ if (p && p.then && p.catch) {
56
+ p.catch(e => {
57
+ console.warn(e);
58
+ });
59
+ }
60
+ };
61
+ const ivm = vm;
62
+ for (const c of channel) {
63
+ ivm.registerDisposable(ivm.app.subscribe(c, a));
64
+ }
65
+ });
66
+ };
67
+ }
68
+ function BindableReceive(...channel) {
69
+ return (target, key) => {
70
+ const bp = BindableProperty(target, key);
71
+ registerInit(target, vm => {
72
+ const fx = (cx, m) => {
73
+ vm[key] = m;
74
+ };
75
+ const ivm = vm;
76
+ for (const c of channel) {
77
+ ivm.registerDisposable(ivm.app.subscribe(c, fx));
78
+ }
79
+ });
80
+ return bp;
81
+ };
82
+ }
83
+ function BindableBroadcast(...channel) {
84
+ return (target, key) => {
85
+ const bp = BindableProperty(target, key);
86
+ registerInit(target, vm => {
87
+ const fx = t => {
88
+ const v = vm[key];
89
+ for (const c of channel) {
90
+ vm.app.broadcast(c, v);
91
+ }
92
+ };
93
+ const d = new AtomWatcher(vm, [key.split(".")], fx);
94
+ d.init();
95
+ vm.registerDisposable(d);
96
+ });
97
+ return bp;
98
+ };
99
+ }
100
+ function Watch(target, key, descriptor) {
101
+ registerInit(target, vm => {
102
+ const ivm = vm;
103
+ if (descriptor && descriptor.get) {
104
+ ivm.setupWatch(descriptor.get, () => {
105
+ vm.refresh(key.toString());
106
+ });
107
+ return;
108
+ }
109
+ ivm.setupWatch(vm[key]);
110
+ });
111
+ }
112
+ function CachedWatch(target, key, descriptor) {
113
+ const getMethod = descriptor.get;
114
+ descriptor.get = () => null;
115
+ registerInit(target, vm => {
116
+ const ivm = vm;
117
+ const fieldName = `_${key}`;
118
+ Object.defineProperty(ivm, key, {
119
+ enumerable: true,
120
+ configurable: true,
121
+ get() {
122
+ const c = ivm[fieldName] || (ivm[fieldName] = {
123
+ value: getMethod.apply(ivm)
124
+ });
125
+ return c.value;
126
+ }
127
+ });
128
+ ivm.setupWatch(getMethod, () => {
129
+ ivm[fieldName] = null;
130
+ AtomBinder.refreshValue(ivm, key);
131
+ });
132
+ });
133
+ }
134
+ function Validate(target, key, descriptor) {
135
+ const getMethod = descriptor.get;
136
+ descriptor.get = () => null;
137
+ registerInit(target, vm => {
138
+ const initialized = {
139
+ i: false
140
+ };
141
+ const ivm = vm;
142
+ Object.defineProperty(ivm, key, {
143
+ enumerable: true,
144
+ configurable: true,
145
+ get() {
146
+ if (vm.mShouldValidate && initialized.i) {
147
+ return getMethod.apply(this);
148
+ }
149
+ return null;
150
+ }
151
+ });
152
+ ivm.setupWatch(getMethod, () => {
153
+ initialized.i = true;
154
+ vm.refresh(key.toString());
155
+ }, true, key.toString());
156
+ return;
157
+ });
158
+ }
159
+ _export({
160
+ waitForReady: waitForReady,
161
+ Receive: Receive,
162
+ BindableReceive: BindableReceive,
163
+ BindableBroadcast: BindableBroadcast,
164
+ Watch: Watch,
165
+ CachedWatch: CachedWatch,
166
+ Validate: Validate
167
+ });
168
+ return {
169
+ setters: [function (_App) {
170
+ App = _App.App;
171
+ }, function (_Atom) {
172
+ Atom = _Atom.Atom;
173
+ }, function (_coreAtomBinder) {
174
+ AtomBinder = _coreAtomBinder.AtomBinder;
175
+ }, function (_coreAtomDisposableList) {
176
+ AtomDisposableList = _coreAtomDisposableList.AtomDisposableList;
177
+ }, function (_coreAtomWatcher) {
178
+ AtomWatcher = _coreAtomWatcher.AtomWatcher;
179
+ }, function (_coreBindableProperty) {
180
+ BindableProperty = _coreBindableProperty.BindableProperty;
181
+ }, function (_diInject) {
182
+ Inject = _diInject.Inject;
183
+ }, function (_baseTypes) {
184
+ registerInit = _baseTypes.registerInit;
185
+ }],
186
+ execute: function () {
187
+ __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
188
+ var c = arguments.length,
189
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
190
+ d;
191
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);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;
192
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
193
+ };
194
+ __metadata = void 0 && (void 0).__metadata || function (k, v) {
195
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
196
+ };
197
+ __param = void 0 && (void 0).__param || function (paramIndex, decorator) {
198
+ return function (target, key) {
199
+ decorator(target, key, paramIndex);
200
+ };
201
+ };
202
+ __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
203
+ function adopt(value) {
204
+ return value instanceof P ? value : new P(function (resolve) {
205
+ resolve(value);
206
+ });
207
+ }
208
+ return new (P || (P = Promise))(function (resolve, reject) {
209
+ function fulfilled(value) {
56
210
  try {
57
- yield Atom_1.Atom.postAsync(this.app, () => __awaiter(this, void 0, void 0, function* () {
58
- runDecoratorInits.apply(this);
59
- // this.registerWatchers();
60
- }));
61
- yield Atom_1.Atom.postAsync(this.app, () => __awaiter(this, void 0, void 0, function* () {
62
- yield this.init();
63
- this.onReady();
64
- }));
65
- if (this.postInit) {
66
- for (const i of this.postInit) {
67
- i();
68
- }
69
- this.postInit = null;
70
- }
71
- }
72
- finally {
73
- const pi = this.pendingInits;
74
- this.pendingInits = null;
75
- for (const iterator of pi) {
76
- iterator();
77
- }
211
+ step(generator.next(value));
212
+ } catch (e) {
213
+ reject(e);
78
214
  }
79
- });
80
- }
81
- /**
82
- * Useful only for Unit testing, this function will await till initialization is
83
- * complete and all pending functions are executed
84
- */
85
- function waitForReady(vm) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- while (vm.pendingInits) {
88
- yield Atom_1.Atom.delay(100);
215
+ }
216
+ function rejected(value) {
217
+ try {
218
+ step(generator["throw"](value));
219
+ } catch (e) {
220
+ reject(e);
89
221
  }
222
+ }
223
+ function step(result) {
224
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
225
+ }
226
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
90
227
  });
91
- }
92
- exports.waitForReady = waitForReady;
93
- /**
94
- * ViewModel class supports initialization and supports {@link IDisposable} dispose pattern.
95
- * @export
96
- * @class AtomViewModel
97
- */
98
- let AtomViewModel = class AtomViewModel {
99
- /**
100
- * If it returns true, it means all pending initializations have finished
101
- */
228
+ };
229
+ _export("AtomViewModel", AtomViewModel = class AtomViewModel {
102
230
  get isReady() {
103
- return this.pendingInits === null;
231
+ return this.pendingInits === null;
104
232
  }
105
233
  get errors() {
106
- const e = [];
107
- if (!this.mShouldValidate) {
108
- return e;
234
+ const e = [];
235
+ if (!this.mShouldValidate) {
236
+ return e;
237
+ }
238
+ for (const v of this.validations) {
239
+ if (!v.initialized) {
240
+ return e;
109
241
  }
110
- for (const v of this.validations) {
111
- if (!v.initialized) {
112
- return e;
113
- }
114
- const error = this[v.name];
115
- if (error) {
116
- e.push({ name: v.name, error });
117
- }
242
+ const error = this[v.name];
243
+ if (error) {
244
+ e.push({
245
+ name: v.name,
246
+ error
247
+ });
118
248
  }
119
- return e;
249
+ }
250
+ return e;
120
251
  }
121
- /**
122
- * Returns parent AtomViewModel if it was initialized with one. This property is also
123
- * useful when you open an popup or window. Whenever a popup/window is opened, ViewModel
124
- * associated with the UI element that opened this popup/window becomes parent of ViewModel
125
- * of popup/window.
126
- */
127
252
  get parent() {
128
- return this.mParent;
253
+ return this.mParent;
129
254
  }
130
255
  set parent(v) {
131
- if (this.mParent && this.mParent.mChildren) {
132
- this.mParent.mChildren.remove(this);
133
- }
134
- this.mParent = v;
135
- if (v) {
136
- const c = v.mChildren || (v.mChildren = []);
137
- c.add(this);
138
- this.registerDisposable({
139
- dispose: () => {
140
- c.remove(this);
141
- }
142
- });
143
- }
256
+ if (this.mParent && this.mParent.mChildren) {
257
+ this.mParent.mChildren.remove(this);
258
+ }
259
+ this.mParent = v;
260
+ if (v) {
261
+ const c = v.mChildren || (v.mChildren = []);
262
+ c.add(this);
263
+ this.registerDisposable({
264
+ dispose: () => {
265
+ c.remove(this);
266
+ }
267
+ });
268
+ }
144
269
  }
145
- /**
146
- * Returns true if all validations didn't return any error. All validations
147
- * are decorated with @{@link Validate} decorator.
148
- */
149
270
  get isValid() {
150
- let valid = true;
151
- const validateWasFalse = this.mShouldValidate === false;
152
- this.mShouldValidate = true;
153
- for (const v of this.validations) {
154
- if (!v.initialized) {
155
- v.watcher.init(true);
156
- v.initialized = true;
157
- }
158
- if (this[v.name]) {
159
- if (validateWasFalse) {
160
- AtomBinder_1.AtomBinder.refreshValue(this, v.name);
161
- }
162
- valid = false;
163
- }
271
+ let valid = true;
272
+ const validateWasFalse = this.mShouldValidate === false;
273
+ this.mShouldValidate = true;
274
+ for (const v of this.validations) {
275
+ if (!v.initialized) {
276
+ v.watcher.init(true);
277
+ v.initialized = true;
164
278
  }
165
- if (this.mChildren) {
166
- for (const child of this.mChildren) {
167
- if (!child.isValid) {
168
- valid = false;
169
- }
170
- }
279
+ if (this[v.name]) {
280
+ if (validateWasFalse) {
281
+ AtomBinder.refreshValue(this, v.name);
282
+ }
283
+ valid = false;
171
284
  }
172
- AtomBinder_1.AtomBinder.refreshValue(this, "errors");
173
- return valid;
285
+ }
286
+ if (this.mChildren) {
287
+ for (const child of this.mChildren) {
288
+ if (!child.isValid) {
289
+ valid = false;
290
+ }
291
+ }
292
+ }
293
+ AtomBinder.refreshValue(this, "errors");
294
+ return valid;
174
295
  }
175
296
  constructor(app) {
176
- this.app = app;
177
- this.disposables = null;
178
- this.validations = [];
179
- this.pendingInits = [];
180
- this.mShouldValidate = false;
181
- this.app.runAsync(() => privateInit.apply(this));
297
+ this.app = app;
298
+ this.disposables = null;
299
+ this.validations = [];
300
+ this.pendingInits = [];
301
+ this.mShouldValidate = false;
302
+ this.app.runAsync(() => privateInit.apply(this));
182
303
  }
183
- /**
184
- * Resets validations and all errors are removed.
185
- * @param resetChildren reset child view models as well. Default is true.
186
- */
187
304
  resetValidations(resetChildren = true) {
188
- this.mShouldValidate = false;
189
- for (const v of this.validations) {
190
- this.refresh(v.name);
191
- }
192
- if (resetChildren && this.mChildren) {
193
- for (const iterator of this.mChildren) {
194
- iterator.resetValidations(resetChildren);
195
- }
305
+ this.mShouldValidate = false;
306
+ for (const v of this.validations) {
307
+ this.refresh(v.name);
308
+ }
309
+ if (resetChildren && this.mChildren) {
310
+ for (const iterator of this.mChildren) {
311
+ iterator.resetValidations(resetChildren);
196
312
  }
313
+ }
197
314
  }
198
- /**
199
- * Runs function after initialization is complete.
200
- * @param f function to execute
201
- */
202
315
  runAfterInit(f) {
203
- if (this.pendingInits) {
204
- this.pendingInits.push(f);
205
- return;
206
- }
207
- f();
316
+ if (this.pendingInits) {
317
+ this.pendingInits.push(f);
318
+ return;
319
+ }
320
+ f();
208
321
  }
209
- // /**
210
- // * Binds source property to target property with optional two ways
211
- // * @param target target whose property will be set
212
- // * @param propertyName name of target property
213
- // * @param source source to read property from
214
- // * @param path property path of source
215
- // * @param twoWays optional, two ways {@link IValueConverter}
216
- // */
217
- // public bind(
218
- // target: any,
219
- // propertyName: string,
220
- // source: any,
221
- // path: string[][],
222
- // twoWays?: IValueConverter | ((v: any) => any) ): IDisposable {
223
- // const pb = new PropertyBinding(
224
- // target,
225
- // null,
226
- // propertyName,
227
- // path,
228
- // (twoWays && typeof twoWays !== "function") ? true : false , twoWays, source);
229
- // return this.registerDisposable(pb);
230
- // }
231
- /**
232
- * Refreshes bindings associated with given property name
233
- * @param name name of property
234
- */
235
322
  refresh(name) {
236
- AtomBinder_1.AtomBinder.refreshValue(this, name);
323
+ AtomBinder.refreshValue(this, name);
237
324
  }
238
- /**
239
- * Put your asynchronous initialization here
240
- *
241
- * @returns {Promise<any>}
242
- * @memberof AtomViewModel
243
- */
244
- // tslint:disable-next-line:no-empty
245
325
  init() {
246
- return __awaiter(this, void 0, void 0, function* () {
247
- });
326
+ return __awaiter(this, void 0, void 0, function* () {});
248
327
  }
249
- /**
250
- * dispose method will be called when attached view will be disposed or
251
- * when a new view model will be assigned to view, old view model will be disposed.
252
- *
253
- * @memberof AtomViewModel
254
- */
255
328
  dispose() {
256
- if (this.disposables) {
257
- this.disposables.dispose();
258
- }
329
+ if (this.disposables) {
330
+ this.disposables.dispose();
331
+ }
259
332
  }
260
- // /**
261
- // * Internal method, do not use, instead use errors.hasErrors()
262
- // *
263
- // * @memberof AtomViewModel
264
- // */
265
- // public runValidation(): void {
266
- // for (const v of this.validations) {
267
- // v.watcher.evaluate(true);
268
- // }
269
- // }
270
- /**
271
- * Register a disposable to be disposed when view model will be disposed.
272
- *
273
- * @protected
274
- * @param {IDisposable} d
275
- * @memberof AtomViewModel
276
- */
277
333
  registerDisposable(d) {
278
- this.disposables = this.disposables || new AtomDisposableList_1.AtomDisposableList();
279
- return this.disposables.add(d);
334
+ this.disposables = this.disposables || new AtomDisposableList();
335
+ return this.disposables.add(d);
280
336
  }
281
- // tslint:disable-next-line:no-empty
282
- onReady() { }
283
- /**
284
- * Execute given expression whenever any bindable expression changes
285
- * in the expression.
286
- *
287
- * For correct generic type resolution, target must always be `this`.
288
- *
289
- * this.setupWatch(() => {
290
- * if(!this.data.fullName){
291
- * this.data.fullName = `${this.data.firstName} ${this.data.lastName}`;
292
- * }
293
- * });
294
- *
295
- * @protected
296
- * @template T
297
- * @param {() => any} ft
298
- * @returns {IDisposable}
299
- * @memberof AtomViewModel
300
- */
337
+ onReady() {}
301
338
  setupWatch(ft, proxy, forValidation, name) {
302
- const d = new AtomWatcher_1.AtomWatcher(this, ft, proxy, this);
303
- if (forValidation) {
304
- this.validations = this.validations || [];
305
- this.validations.push({ name, watcher: d, initialized: false });
306
- }
307
- else {
308
- d.init();
309
- }
310
- return this.registerDisposable(d);
311
- }
312
- // tslint:disable-next-line:no-empty
313
- onPropertyChanged(name) { }
314
- };
315
- AtomViewModel = __decorate([
316
- __param(0, Inject_1.Inject),
317
- __metadata("design:paramtypes", [App_1.App])
318
- ], AtomViewModel);
319
- exports.AtomViewModel = AtomViewModel;
320
- /**
321
- * Receive messages for given channel
322
- * @param {(string | RegExp)} channel
323
- * @returns {Function}
324
- */
325
- function Receive(...channel) {
326
- return (target, key) => {
327
- (0, baseTypes_1.registerInit)(target, (vm) => {
328
- // tslint:disable-next-line:ban-types
329
- const fx = vm[key];
330
- const a = (ch, d) => {
331
- const p = fx.call(vm, ch, d);
332
- if (p && p.then && p.catch) {
333
- p.catch((e) => {
334
- // tslint:disable-next-line: no-console
335
- console.warn(e);
336
- });
337
- }
338
- };
339
- const ivm = vm;
340
- for (const c of channel) {
341
- ivm.registerDisposable(ivm.app.subscribe(c, a));
342
- }
339
+ const d = new AtomWatcher(this, ft, proxy, this);
340
+ if (forValidation) {
341
+ this.validations = this.validations || [];
342
+ this.validations.push({
343
+ name,
344
+ watcher: d,
345
+ initialized: false
343
346
  });
344
- };
345
- }
346
- exports.Receive = Receive;
347
- function BindableReceive(...channel) {
348
- return (target, key) => {
349
- const bp = (0, BindableProperty_1.BindableProperty)(target, key);
350
- (0, baseTypes_1.registerInit)(target, (vm) => {
351
- const fx = (cx, m) => {
352
- vm[key] = m;
353
- };
354
- const ivm = vm;
355
- for (const c of channel) {
356
- ivm.registerDisposable(ivm.app.subscribe(c, fx));
357
- }
358
- });
359
- return bp;
360
- };
361
- }
362
- exports.BindableReceive = BindableReceive;
363
- function BindableBroadcast(...channel) {
364
- return (target, key) => {
365
- const bp = (0, BindableProperty_1.BindableProperty)(target, key);
366
- (0, baseTypes_1.registerInit)(target, (vm) => {
367
- const fx = (t) => {
368
- const v = vm[key];
369
- for (const c of channel) {
370
- vm.app.broadcast(c, v);
371
- }
372
- };
373
- const d = new AtomWatcher_1.AtomWatcher(vm, [key.split(".")], fx);
374
- d.init();
375
- vm.registerDisposable(d);
376
- });
377
- return bp;
378
- };
379
- }
380
- exports.BindableBroadcast = BindableBroadcast;
381
- function Watch(target, key, descriptor) {
382
- (0, baseTypes_1.registerInit)(target, (vm) => {
383
- const ivm = vm;
384
- if (descriptor && descriptor.get) {
385
- ivm.setupWatch(descriptor.get, () => {
386
- vm.refresh(key.toString());
387
- });
388
- return;
389
- }
390
- ivm.setupWatch(vm[key]);
391
- });
392
- }
393
- exports.Watch = Watch;
394
- /**
395
- * Cached watch must be used with async getters to avoid reloading of
396
- * resources unless the properties referenced are changed
397
- * @param target ViewModel
398
- * @param key name of property
399
- * @param descriptor descriptor of property
400
- */
401
- function CachedWatch(target, key, descriptor) {
402
- const getMethod = descriptor.get;
403
- descriptor.get = (() => null);
404
- (0, baseTypes_1.registerInit)(target, (vm) => {
405
- const ivm = vm;
406
- const fieldName = `_${key}`;
407
- Object.defineProperty(ivm, key, {
408
- enumerable: true,
409
- configurable: true,
410
- get() {
411
- const c = ivm[fieldName] || (ivm[fieldName] = {
412
- value: getMethod.apply(ivm)
413
- });
414
- return c.value;
415
- }
416
- });
417
- ivm.setupWatch(getMethod, () => {
418
- ivm[fieldName] = null;
419
- AtomBinder_1.AtomBinder.refreshValue(ivm, key);
420
- });
421
- });
422
- }
423
- exports.CachedWatch = CachedWatch;
424
- function Validate(target, key, descriptor) {
425
- // tslint:disable-next-line:ban-types
426
- const getMethod = descriptor.get;
427
- // // trick is to change property descriptor...
428
- // delete target[key];
429
- descriptor.get = () => null;
430
- // // replace it with dummy descriptor...
431
- // Object.defineProperty(target, key, descriptor);
432
- (0, baseTypes_1.registerInit)(target, (vm) => {
433
- const initialized = { i: false };
434
- const ivm = vm;
435
- Object.defineProperty(ivm, key, {
436
- enumerable: true,
437
- configurable: true,
438
- get() {
439
- if (vm.mShouldValidate && initialized.i) {
440
- return getMethod.apply(this);
441
- }
442
- return null;
443
- }
444
- });
445
- ivm.setupWatch(getMethod, () => {
446
- // descriptor.get = getMethod;
447
- // Object.defineProperty(target, key, descriptor);
448
- initialized.i = true;
449
- vm.refresh(key.toString());
450
- }, true, key.toString());
451
- return;
452
- });
347
+ } else {
348
+ d.init();
349
+ }
350
+ return this.registerDisposable(d);
351
+ }
352
+ onPropertyChanged(name) {}
353
+ });
354
+ _export("AtomViewModel", AtomViewModel = __decorate([__param(0, Inject), __metadata("design:paramtypes", [App])], AtomViewModel));
453
355
  }
454
- exports.Validate = Validate;
455
- });
456
- //# sourceMappingURL=AtomViewModel.js.map
356
+ };
357
+ });
358
+ //# sourceMappingURL=/home/runner/work/core/core/dist/view-model/AtomViewModel.js.map