@web-atoms/core 2.1.479 → 2.2.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 (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 +2 -1
@@ -1,610 +1,422 @@
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;
26
- }
27
- else if (typeof define === "function" && define.amd) {
28
- define(["require", "exports", "./AjaxOptions", "../../App", "../../Atom", "../../core/AtomBridge", "../../core/types", "../../di/Inject", "../../di/TypeKey", "../CacheService", "../JsonService", "./JsonError"], factory);
29
- }
30
- })(function (require, exports) {
31
- "use strict";
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.BaseService = exports.ServiceParameter = exports.Cancel = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.XmlBody = exports.BodyFormModel = exports.RawBody = exports.Body = exports.Queries = exports.Query = exports.Header = exports.Path = void 0;
34
- const AjaxOptions_1 = require("./AjaxOptions");
35
- const App_1 = require("../../App");
36
- const Atom_1 = require("../../Atom");
37
- const AtomBridge_1 = require("../../core/AtomBridge");
38
- const types_1 = require("../../core/types");
39
- const Inject_1 = require("../../di/Inject");
40
- const TypeKey_1 = require("../../di/TypeKey");
41
- const CacheService_1 = require("../CacheService");
42
- const JsonService_1 = require("../JsonService");
43
- const JsonError_1 = require("./JsonError");
44
- // tslint:disable-next-line
45
- function methodBuilder(method) {
46
- // tslint:disable-next-line
47
- return function (url, options) {
48
- // tslint:disable-next-line
49
- return function (target, propertyKey, descriptor) {
50
- target.methods = target.methods || {};
51
- const a = target.methods[propertyKey];
52
- const oldFunction = descriptor.value;
53
- // tslint:disable-next-line:typedef
54
- descriptor.value = function (...args) {
55
- if (this.testMode || Atom_1.Atom.designMode) {
56
- // tslint:disable-next-line:no-console
57
- console.log(`Test Design Mode: ${url} .. ${args.join(",")}`);
58
- const ro = oldFunction.apply(this, args);
59
- if (ro) {
60
- return ro;
61
- }
62
- }
63
- const jsCache = options ? options.jsCacheSeconds : 0;
64
- if (jsCache) {
65
- const cacheService = this.app.resolve(CacheService_1.default);
66
- const jArgs = args.map((arg) => arg instanceof types_1.CancelToken ? null : arg);
67
- const key = `${this.constructor.name}:${method}:${url}:${JSON.stringify(jArgs)}`;
68
- return cacheService.getOrCreate(key, (e) => {
69
- e.ttlSeconds = jsCache;
70
- return this.invoke(url, method, a, args, options);
71
- });
72
- }
73
- return this.invoke(url, method, a, args, options);
74
- };
75
- };
76
- };
77
- }
78
- // tslint:disable-next-line
79
- function parameterBuilder(paramName, defaultValue) {
80
- // tslint:disable-next-line
81
- return function (key) {
82
- // console.log("Declaration");
83
- // console.log({ key:key});
84
- // tslint:disable-next-line
85
- return function (target, propertyKey, parameterIndex) {
86
- // console.log("Instance");
87
- // console.log({ key:key, propertyKey: propertyKey,parameterIndex: parameterIndex });
88
- target.methods = target.methods || {};
89
- let a = target.methods[propertyKey];
90
- if (!a) {
91
- a = [];
92
- target.methods[propertyKey] = a;
93
- }
94
- a[parameterIndex] = new ServiceParameter(paramName, key, defaultValue);
95
- };
1
+ System.register(["./AjaxOptions", "../../App", "../../Atom", "../../core/AtomBridge", "../../core/types", "../../di/Inject", "../../di/TypeKey", "../CacheService", "../JsonService", "./JsonError"], function (_export, _context) {
2
+ "use strict";
3
+
4
+ var AjaxOptions, App, Atom, AtomBridge, CancelToken, Inject, TypeKey, CacheService, JsonService, JsonError, ServiceParameter, __decorate, __metadata, __param, __awaiter, Path, Header, Query, Queries, Body, RawBody, BodyFormModel, XmlBody, Post, Get, Delete, Put, Patch, globalNS, BaseService;
5
+ function methodBuilder(method) {
6
+ return function (url, options) {
7
+ return function (target, propertyKey, descriptor) {
8
+ target.methods = target.methods || {};
9
+ const a = target.methods[propertyKey];
10
+ const oldFunction = descriptor.value;
11
+ descriptor.value = function (...args) {
12
+ if (this.testMode || Atom.designMode) {
13
+ console.log(`Test Design Mode: ${url} .. ${args.join(",")}`);
14
+ const ro = oldFunction.apply(this, args);
15
+ if (ro) {
16
+ return ro;
17
+ }
18
+ }
19
+ const jsCache = options ? options.jsCacheSeconds : 0;
20
+ if (jsCache) {
21
+ const cacheService = this.app.resolve(CacheService);
22
+ const jArgs = args.map(arg => arg instanceof CancelToken ? null : arg);
23
+ const key = `${this.constructor.name}:${method}:${url}:${JSON.stringify(jArgs)}`;
24
+ return cacheService.getOrCreate(key, e => {
25
+ e.ttlSeconds = jsCache;
26
+ return this.invoke(url, method, a, args, options);
27
+ });
28
+ }
29
+ return this.invoke(url, method, a, args, options);
96
30
  };
97
- }
98
- /**
99
- * This will register Url path fragment on parameter.
100
- *
101
- * @example
102
- *
103
- * @Get("/api/products/{category}")
104
- * async getProducts(
105
- * @Path("category") category: number
106
- * ): Promise<Product[]> {
107
- * }
108
- *
109
- * @export
110
- * @function Path
111
- * @param {name} - Name of the parameter
112
- */
113
- exports.Path = parameterBuilder("Path");
114
- /**
115
- * This will register header on parameter.
116
- *
117
- * @example
118
- *
119
- * @Get("/api/products/{category}")
120
- * async getProducts(
121
- * @Header("x-http-auth") category: number
122
- * ): Promise<Product[]> {
123
- * }
124
- *
125
- * @export
126
- * @function Path
127
- * @param {name} - Name of the parameter
128
- */
129
- exports.Header = parameterBuilder("Header");
130
- /**
131
- * This will register Url query fragment on parameter.
132
- *
133
- * @example
134
- *
135
- * @Get("/api/products")
136
- * async getProducts(
137
- * @Query("category") category: number
138
- * ): Promise<Product[]> {
139
- * }
140
- *
141
- * @export
142
- * @function Query
143
- * @param {name} - Name of the parameter
144
- */
145
- exports.Query = parameterBuilder("Query");
146
- /**
147
- * This will register Url query fragments on parameter of type object
148
- *
149
- * @example
150
- *
151
- * @Get("/api/products")
152
- * async getProducts(
153
- * @Queries queries: { [key: string]: string | number | boolean | null }
154
- * ): Promise<Product[]> {
155
- * return null;
156
- * }
157
- */
158
- exports.Queries = parameterBuilder("Queries")("");
159
- /**
160
- * This will register data fragment on ajax.
161
- *
162
- * @example
163
- *
164
- * @Post("/api/products")
165
- * async getProducts(
166
- * @Query("id") id: number,
167
- * @Body product: Product
168
- * ): Promise<Product[]> {
169
- * }
170
- *
171
- * @export
172
- * @function Body
173
- */
174
- exports.Body = parameterBuilder("Body")("");
175
- exports.RawBody = parameterBuilder("RawBody")("");
176
- /**
177
- * This will register data fragment on ajax in old formModel way.
178
- *
179
- * @example
180
- *
181
- * @Post("/api/products")
182
- * async getProducts(
183
- * @Query("id") id: number,
184
- * @BodyFormModel product: Product
185
- * ): Promise<Product[]> {
186
- * }
187
- *
188
- * @export
189
- * @function BodyFormModel
190
- */
191
- exports.BodyFormModel = parameterBuilder("BodyFormModel")("");
192
- exports.XmlBody = parameterBuilder("XmlBody")("");
193
- /**
194
- * Http Post method
195
- * @example
196
- *
197
- * @Post("/api/products")
198
- * async saveProduct(
199
- * @Body product: Product
200
- * ): Promise<Product> {
201
- * }
202
- *
203
- * @export
204
- * @function Post
205
- * @param {url} - Url for the operation
206
- */
207
- exports.Post = methodBuilder("Post");
208
- /**
209
- * Http Get Method
210
- *
211
- * @example
212
- *
213
- * @Get("/api/products/{category}")
214
- * async getProducts(
215
- * @Path("category") category?:string
216
- * ): Promise<Product[]> {
217
- * }
218
- *
219
- * @export
220
- * @function Body
221
- */
222
- exports.Get = methodBuilder("Get");
223
- /**
224
- * Http Delete method
225
- * @example
226
- *
227
- * @Delete("/api/products")
228
- * async deleteProduct(
229
- * @Body product: Product
230
- * ): Promise<Product> {
231
- * }
232
- *
233
- * @export
234
- * @function Delete
235
- * @param {url} - Url for the operation
236
- */
237
- exports.Delete = methodBuilder("Delete");
238
- /**
239
- * Http Put method
240
- * @example
241
- *
242
- * @Put("/api/products")
243
- * async saveProduct(
244
- * @Body product: Product
245
- * ): Promise<Product> {
246
- * }
247
- *
248
- * @export
249
- * @function Put
250
- * @param {url} - Url for the operation
251
- */
252
- exports.Put = methodBuilder("Put");
253
- /**
254
- * Http Patch method
255
- * @example
256
- *
257
- * @Patch("/api/products")
258
- * async saveProduct(
259
- * @Body product: any
260
- * ): Promise<Product> {
261
- * }
262
- *
263
- * @export
264
- * @function Patch
265
- * @param {url} - Url for the operation
266
- */
267
- exports.Patch = methodBuilder("Patch");
268
- /**
269
- * Cancellation token
270
- * @example
271
- *
272
- * @Put("/api/products")
273
- * async saveProduct(
274
- * @Body product: Product
275
- * @Cancel cancel: CancelToken
276
- * ): Promise<Product> {
277
- * }
278
- *
279
- * @export
280
- * @function Put
281
- * @param {url} - Url for the operation
282
- */
283
- function Cancel(target, propertyKey, parameterIndex) {
284
- if (!target.methods) {
285
- target.methods = {};
286
- }
31
+ };
32
+ };
33
+ }
34
+ function parameterBuilder(paramName, defaultValue) {
35
+ return function (key) {
36
+ return function (target, propertyKey, parameterIndex) {
37
+ target.methods = target.methods || {};
287
38
  let a = target.methods[propertyKey];
288
39
  if (!a) {
289
- a = [];
290
- target.methods[propertyKey] = a;
40
+ a = [];
41
+ target.methods[propertyKey] = a;
291
42
  }
292
- a[parameterIndex] = new ServiceParameter("cancel", "");
43
+ a[parameterIndex] = new ServiceParameter(paramName, key, defaultValue);
44
+ };
45
+ };
46
+ }
47
+ function Cancel(target, propertyKey, parameterIndex) {
48
+ if (!target.methods) {
49
+ target.methods = {};
293
50
  }
294
- exports.Cancel = Cancel;
295
- class ServiceParameter {
296
- constructor(type, key, defaultValue) {
297
- this.type = type;
298
- this.key = key;
299
- this.defaultValue = defaultValue;
300
- this.type = type.toLowerCase();
301
- this.key = key;
302
- }
51
+ let a = target.methods[propertyKey];
52
+ if (!a) {
53
+ a = [];
54
+ target.methods[propertyKey] = a;
303
55
  }
304
- exports.ServiceParameter = ServiceParameter;
305
- function BaseUrl(baseUrl) {
306
- return (target) => {
307
- const key = TypeKey_1.TypeKey.get(target);
308
- BaseService.baseUrls[key] = baseUrl;
56
+ a[parameterIndex] = new ServiceParameter("cancel", "");
57
+ }
58
+ function BaseUrl(baseUrl) {
59
+ return target => {
60
+ const key = TypeKey.get(target);
61
+ BaseService.baseUrls[key] = baseUrl;
62
+ };
63
+ }
64
+ _export({
65
+ Cancel: Cancel,
66
+ ServiceParameter: void 0,
67
+ default: BaseUrl
68
+ });
69
+ return {
70
+ setters: [function (_AjaxOptions) {
71
+ AjaxOptions = _AjaxOptions.AjaxOptions;
72
+ }, function (_App) {
73
+ App = _App.App;
74
+ }, function (_Atom) {
75
+ Atom = _Atom.Atom;
76
+ }, function (_coreAtomBridge) {
77
+ AtomBridge = _coreAtomBridge.AtomBridge;
78
+ }, function (_coreTypes) {
79
+ CancelToken = _coreTypes.CancelToken;
80
+ }, function (_diInject) {
81
+ Inject = _diInject.Inject;
82
+ }, function (_diTypeKey) {
83
+ TypeKey = _diTypeKey.TypeKey;
84
+ }, function (_CacheService) {
85
+ CacheService = _CacheService.default;
86
+ }, function (_JsonService) {
87
+ JsonService = _JsonService.JsonService;
88
+ }, function (_JsonError) {
89
+ JsonError = _JsonError.default;
90
+ }],
91
+ execute: function () {
92
+ __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
93
+ var c = arguments.length,
94
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
95
+ d;
96
+ 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;
97
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
98
+ };
99
+ __metadata = void 0 && (void 0).__metadata || function (k, v) {
100
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
101
+ };
102
+ __param = void 0 && (void 0).__param || function (paramIndex, decorator) {
103
+ return function (target, key) {
104
+ decorator(target, key, paramIndex);
309
105
  };
310
- }
311
- exports.default = BaseUrl;
312
- const globalNS = (typeof global !== "undefined") ? global : window;
313
- if (!globalNS.XMLHttpRequest) {
314
- // tslint:disable-next-line: no-var-requires
106
+ };
107
+ __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
108
+ function adopt(value) {
109
+ return value instanceof P ? value : new P(function (resolve) {
110
+ resolve(value);
111
+ });
112
+ }
113
+ return new (P || (P = Promise))(function (resolve, reject) {
114
+ function fulfilled(value) {
115
+ try {
116
+ step(generator.next(value));
117
+ } catch (e) {
118
+ reject(e);
119
+ }
120
+ }
121
+ function rejected(value) {
122
+ try {
123
+ step(generator["throw"](value));
124
+ } catch (e) {
125
+ reject(e);
126
+ }
127
+ }
128
+ function step(result) {
129
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
130
+ }
131
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
132
+ });
133
+ };
134
+ _export("Path", Path = parameterBuilder("Path"));
135
+ _export("Header", Header = parameterBuilder("Header"));
136
+ _export("Query", Query = parameterBuilder("Query"));
137
+ _export("Queries", Queries = parameterBuilder("Queries")(""));
138
+ _export("Body", Body = parameterBuilder("Body")(""));
139
+ _export("RawBody", RawBody = parameterBuilder("RawBody")(""));
140
+ _export("BodyFormModel", BodyFormModel = parameterBuilder("BodyFormModel")(""));
141
+ _export("XmlBody", XmlBody = parameterBuilder("XmlBody")(""));
142
+ _export("Post", Post = methodBuilder("Post"));
143
+ _export("Get", Get = methodBuilder("Get"));
144
+ _export("Delete", Delete = methodBuilder("Delete"));
145
+ _export("Put", Put = methodBuilder("Put"));
146
+ _export("Patch", Patch = methodBuilder("Patch"));
147
+ _export("ServiceParameter", ServiceParameter = class ServiceParameter {
148
+ constructor(type, key, defaultValue) {
149
+ this.type = type;
150
+ this.key = key;
151
+ this.defaultValue = defaultValue;
152
+ this.type = type.toLowerCase();
153
+ this.key = key;
154
+ }
155
+ });
156
+ globalNS = typeof global !== "undefined" ? global : window;
157
+ if (!globalNS.XMLHttpRequest) {
315
158
  globalNS.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
316
- }
317
- /**
318
- *
319
- *
320
- * @export
321
- * @class BaseService
322
- */
323
- let BaseService = class BaseService {
159
+ }
160
+ _export("BaseService", BaseService = class BaseService {
324
161
  constructor(app, jsonService) {
325
- this.app = app;
326
- this.jsonService = jsonService;
327
- this.testMode = false;
328
- this.showProgress = true;
329
- this.showError = false;
330
- // bs
331
- this.methods = {};
332
- this.methodReturns = {};
333
- this.jsonOptions = null;
334
- this.headers = null;
335
- this.jsonOptions = Object.assign({}, this.jsonService.options);
162
+ this.app = app;
163
+ this.jsonService = jsonService;
164
+ this.testMode = false;
165
+ this.showProgress = true;
166
+ this.showError = false;
167
+ this.methods = {};
168
+ this.methodReturns = {};
169
+ this.jsonOptions = null;
170
+ this.headers = null;
171
+ this.jsonOptions = Object.assign({}, this.jsonService.options);
336
172
  }
337
173
  encodeData(o) {
338
- o.dataType = "application/json";
339
- o.data = this.jsonService.stringify(o.data, this.jsonOptions);
340
- o.contentType = "application/json";
341
- return o;
174
+ o.dataType = "application/json";
175
+ o.data = this.jsonService.stringify(o.data, this.jsonOptions);
176
+ o.contentType = "application/json";
177
+ return o;
342
178
  }
343
179
  sendResult(result, error) {
344
- return new Promise((resolve, reject) => {
345
- if (error) {
346
- setTimeout(() => {
347
- reject(error);
348
- }, 1);
349
- return;
350
- }
351
- setTimeout(() => {
352
- resolve(result);
353
- }, 1);
354
- });
180
+ return new Promise((resolve, reject) => {
181
+ if (error) {
182
+ setTimeout(() => {
183
+ reject(error);
184
+ }, 1);
185
+ return;
186
+ }
187
+ setTimeout(() => {
188
+ resolve(result);
189
+ }, 1);
190
+ });
355
191
  }
356
192
  invoke(url, method, bag, values, methodOptions) {
357
- var _a, _b, _c, _d, _e;
358
- return __awaiter(this, void 0, void 0, function* () {
359
- if (this.baseUrl === undefined) {
360
- let p = Object.getPrototypeOf(this);
361
- while (p) {
362
- const t = TypeKey_1.TypeKey.get(p.constructor || p);
363
- const bu = BaseService.baseUrls[t];
364
- if (bu) {
365
- this.baseUrl = bu;
366
- break;
367
- }
368
- p = Object.getPrototypeOf(p);
369
- }
370
- if (this.baseUrl === undefined) {
371
- this.baseUrl = null;
372
- }
373
- }
374
- if (this.baseUrl) {
375
- if (!/^\//.test(url)) {
376
- url = `${this.baseUrl}${url}`;
377
- }
193
+ var _a, _b, _c, _d, _e;
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ if (this.baseUrl === undefined) {
196
+ let p = Object.getPrototypeOf(this);
197
+ while (p) {
198
+ const t = TypeKey.get(p.constructor || p);
199
+ const bu = BaseService.baseUrls[t];
200
+ if (bu) {
201
+ this.baseUrl = bu;
202
+ break;
378
203
  }
379
- const busyIndicator = this.showProgress ? (this.app.createBusyIndicator({
380
- title: url,
381
- description: `${method} ${url}`
382
- })) : null;
383
- try {
384
- url = UMD.resolvePath(url);
385
- let options = new AjaxOptions_1.AjaxOptions();
386
- options.method = method;
387
- if (methodOptions) {
388
- options.headers = methodOptions.headers;
389
- options.dataType = methodOptions.accept;
390
- }
391
- const methodHeaders = (options.headers = options.headers || {});
392
- const headers = this.headers
393
- ? (Object.assign(Object.assign({}, this.headers), methodHeaders))
394
- : methodHeaders;
395
- // this is necessary to support IsAjaxRequest in ASP.NET MVC
396
- if (!headers["X-Requested-With"]) {
397
- headers["X-Requested-With"] = "XMLHttpRequest";
398
- }
399
- options.dataType = options.dataType || "application/json";
400
- const jsonOptions = Object.assign(Object.assign({}, this.jsonOptions), (methodOptions ? methodOptions.jsonOptions : {}));
401
- if (bag) {
402
- for (let i = 0; i < bag.length; i++) {
403
- const p = bag[i];
404
- const vi = values[i];
405
- const v = vi === undefined ? p.defaultValue : vi;
406
- if (v instanceof types_1.CancelToken) {
407
- options.cancel = v;
408
- continue;
409
- }
410
- switch (p.type) {
411
- case "path":
412
- if (v === undefined) {
413
- continue;
414
- }
415
- const vs = v + "";
416
- const replacer = `{${p.key}}`;
417
- url = url.split(replacer).join(vs);
418
- break;
419
- case "query":
420
- if (v === undefined) {
421
- continue;
422
- }
423
- if (url.indexOf("?") === -1) {
424
- url += "?";
425
- }
426
- if (!/(\&|\?)$/.test(url)) {
427
- url += "&";
428
- }
429
- url += `${encodeURIComponent(p.key)}=${encodeURIComponent(v)}`;
430
- break;
431
- case "queries":
432
- if (url.indexOf("?") === -1) {
433
- url += "?";
434
- }
435
- if (!/(\&|\?)$/.test(url)) {
436
- url += "&";
437
- }
438
- for (const key in v) {
439
- if (v.hasOwnProperty(key)) {
440
- const element = v[key];
441
- if (element !== undefined) {
442
- url += `${encodeURIComponent(key)}=${encodeURIComponent(element)}&`;
443
- }
444
- }
445
- }
446
- break;
447
- case "body":
448
- options.data = v;
449
- options = this.encodeData(options);
450
- break;
451
- case "bodyformmodel":
452
- options.data = v;
453
- break;
454
- case "rawbody":
455
- options.data = v;
456
- break;
457
- case "xmlbody":
458
- options.contentType = "text/xml";
459
- options.data = v;
460
- break;
461
- case "cancel":
462
- options.cancel = v;
463
- break;
464
- case "header":
465
- if (v === undefined) {
466
- continue;
467
- }
468
- headers[p.key] = v;
469
- break;
470
- }
471
- }
472
- }
473
- options.url = url;
474
- const xhr = yield this.ajax(url, options);
475
- if (/json/i.test(xhr.responseType)) {
476
- const text = xhr.responseText;
477
- const response = this.jsonService.parse(text, jsonOptions);
478
- if (xhr.status >= 400) {
479
- throw new JsonError_1.default(typeof response === "string"
480
- ? response
481
- : ((_e = (_d = (_c = (_b = (_a = response.title) !== null && _a !== void 0 ? _a : response.detail) !== null && _b !== void 0 ? _b : response.message) !== null && _c !== void 0 ? _c : response.exceptionMessage) !== null && _d !== void 0 ? _d : text) !== null && _e !== void 0 ? _e : "Json Server Error"), response);
482
- }
483
- if (methodOptions && methodOptions.returnHeaders) {
484
- return {
485
- headers: this.parseHeaders(xhr.responseHeaders),
486
- value: response
487
- };
204
+ p = Object.getPrototypeOf(p);
205
+ }
206
+ if (this.baseUrl === undefined) {
207
+ this.baseUrl = null;
208
+ }
209
+ }
210
+ if (this.baseUrl) {
211
+ if (!/^\//.test(url)) {
212
+ url = `${this.baseUrl}${url}`;
213
+ }
214
+ }
215
+ const busyIndicator = this.showProgress ? this.app.createBusyIndicator({
216
+ title: url,
217
+ description: `${method} ${url}`
218
+ }) : null;
219
+ try {
220
+ url = UMD.resolvePath(url);
221
+ let options = new AjaxOptions();
222
+ options.method = method;
223
+ if (methodOptions) {
224
+ options.headers = methodOptions.headers;
225
+ options.dataType = methodOptions.accept;
226
+ }
227
+ const methodHeaders = options.headers = options.headers || {};
228
+ const headers = this.headers ? Object.assign(Object.assign({}, this.headers), methodHeaders) : methodHeaders;
229
+ if (!headers["X-Requested-With"]) {
230
+ headers["X-Requested-With"] = "XMLHttpRequest";
231
+ }
232
+ options.dataType = options.dataType || "application/json";
233
+ const jsonOptions = Object.assign(Object.assign({}, this.jsonOptions), methodOptions ? methodOptions.jsonOptions : {});
234
+ if (bag) {
235
+ for (let i = 0; i < bag.length; i++) {
236
+ const p = bag[i];
237
+ const vi = values[i];
238
+ const v = vi === undefined ? p.defaultValue : vi;
239
+ if (v instanceof CancelToken) {
240
+ options.cancel = v;
241
+ continue;
242
+ }
243
+ switch (p.type) {
244
+ case "path":
245
+ if (v === undefined) {
246
+ continue;
247
+ }
248
+ const vs = v + "";
249
+ const replacer = `{${p.key}}`;
250
+ url = url.split(replacer).join(vs);
251
+ break;
252
+ case "query":
253
+ if (v === undefined) {
254
+ continue;
255
+ }
256
+ if (url.indexOf("?") === -1) {
257
+ url += "?";
258
+ }
259
+ if (!/(\&|\?)$/.test(url)) {
260
+ url += "&";
261
+ }
262
+ url += `${encodeURIComponent(p.key)}=${encodeURIComponent(v)}`;
263
+ break;
264
+ case "queries":
265
+ if (url.indexOf("?") === -1) {
266
+ url += "?";
267
+ }
268
+ if (!/(\&|\?)$/.test(url)) {
269
+ url += "&";
270
+ }
271
+ for (const key in v) {
272
+ if (v.hasOwnProperty(key)) {
273
+ const element = v[key];
274
+ if (element !== undefined) {
275
+ url += `${encodeURIComponent(key)}=${encodeURIComponent(element)}&`;
276
+ }
488
277
  }
489
- return response;
490
- }
491
- if (xhr.status >= 400) {
492
- throw new Error(xhr.responseText || "Server Error");
493
- }
494
- if (methodOptions && methodOptions.returnHeaders) {
495
- return {
496
- headers: this.parseHeaders(xhr.responseHeaders),
497
- value: xhr.responseText
498
- };
499
- }
500
- return xhr.responseText;
278
+ }
279
+ break;
280
+ case "body":
281
+ options.data = v;
282
+ options = this.encodeData(options);
283
+ break;
284
+ case "bodyformmodel":
285
+ options.data = v;
286
+ break;
287
+ case "rawbody":
288
+ options.data = v;
289
+ break;
290
+ case "xmlbody":
291
+ options.contentType = "text/xml";
292
+ options.data = v;
293
+ break;
294
+ case "cancel":
295
+ options.cancel = v;
296
+ break;
297
+ case "header":
298
+ if (v === undefined) {
299
+ continue;
300
+ }
301
+ headers[p.key] = v;
302
+ break;
303
+ }
501
304
  }
502
- finally {
503
- if (busyIndicator) {
504
- busyIndicator.dispose();
505
- }
305
+ }
306
+ options.url = url;
307
+ const xhr = yield this.ajax(url, options);
308
+ if (/json/i.test(xhr.responseType)) {
309
+ const text = xhr.responseText;
310
+ const response = this.jsonService.parse(text, jsonOptions);
311
+ if (xhr.status >= 400) {
312
+ throw new JsonError(typeof response === "string" ? response : (_e = (_d = (_c = (_b = (_a = response.title) !== null && _a !== void 0 ? _a : response.detail) !== null && _b !== void 0 ? _b : response.message) !== null && _c !== void 0 ? _c : response.exceptionMessage) !== null && _d !== void 0 ? _d : text) !== null && _e !== void 0 ? _e : "Json Server Error", response);
506
313
  }
507
- });
314
+ if (methodOptions && methodOptions.returnHeaders) {
315
+ return {
316
+ headers: this.parseHeaders(xhr.responseHeaders),
317
+ value: response
318
+ };
319
+ }
320
+ return response;
321
+ }
322
+ if (xhr.status >= 400) {
323
+ throw new Error(xhr.responseText || "Server Error");
324
+ }
325
+ if (methodOptions && methodOptions.returnHeaders) {
326
+ return {
327
+ headers: this.parseHeaders(xhr.responseHeaders),
328
+ value: xhr.responseText
329
+ };
330
+ }
331
+ return xhr.responseText;
332
+ } finally {
333
+ if (busyIndicator) {
334
+ busyIndicator.dispose();
335
+ }
336
+ }
337
+ });
508
338
  }
509
339
  parseHeaders(headers) {
510
- if (typeof headers === "object") {
511
- return headers;
512
- }
513
- return (headers || "")
514
- .split("\n")
515
- .reduce((pv, c) => {
516
- const cv = c.split(":");
517
- pv[cv[0]] = (cv[1] || "").trim();
518
- return pv;
519
- }, {});
340
+ if (typeof headers === "object") {
341
+ return headers;
342
+ }
343
+ return (headers || "").split("\n").reduce((pv, c) => {
344
+ const cv = c.split(":");
345
+ pv[cv[0]] = (cv[1] || "").trim();
346
+ return pv;
347
+ }, {});
520
348
  }
521
349
  ajax(url, options) {
522
- return __awaiter(this, void 0, void 0, function* () {
523
- // return new CancellablePromise();
524
- url = url || options.url;
525
- // no longer needed, watch must provide functionality of waiting and cancelling
526
- // await Atom.delay(1, options.cancel);
527
- if (options.cancel && options.cancel.cancelled) {
528
- throw new Error("cancelled");
350
+ return __awaiter(this, void 0, void 0, function* () {
351
+ url = url || options.url;
352
+ if (options.cancel && options.cancel.cancelled) {
353
+ throw new Error("cancelled");
354
+ }
355
+ if (AtomBridge.instance.ajax) {
356
+ return yield new Promise((resolve, reject) => {
357
+ AtomBridge.instance.ajax(url, options, r => {
358
+ resolve(options);
359
+ }, e => {
360
+ reject(e);
361
+ }, null);
362
+ });
363
+ }
364
+ const xhr = new XMLHttpRequest();
365
+ return yield new Promise((resolve, reject) => {
366
+ if (options.cancel && options.cancel.cancelled) {
367
+ reject(options.cancel.cancelled);
368
+ return;
369
+ }
370
+ if (options.cancel) {
371
+ options.cancel.registerForCancel(r => {
372
+ xhr.abort();
373
+ reject(r);
374
+ return;
375
+ });
376
+ }
377
+ xhr.onreadystatechange = e => {
378
+ if (xhr.readyState === XMLHttpRequest.DONE) {
379
+ options.status = xhr.status;
380
+ options.responseText = xhr.responseText;
381
+ options.responseHeaders = xhr.getAllResponseHeaders();
382
+ const ct = xhr.getResponseHeader("content-type");
383
+ options.responseType = ct || xhr.responseType;
384
+ resolve(options);
529
385
  }
530
- if (AtomBridge_1.AtomBridge.instance.ajax) {
531
- return yield new Promise((resolve, reject) => {
532
- AtomBridge_1.AtomBridge.instance.ajax(url, options, (r) => {
533
- resolve(options);
534
- }, (e) => {
535
- reject(e);
536
- }, null);
537
- });
386
+ };
387
+ xhr.open(options.method, url, true);
388
+ if (options.dataType) {
389
+ xhr.setRequestHeader("accept", options.dataType);
390
+ }
391
+ if (options.contentType) {
392
+ xhr.setRequestHeader("content-type", options.contentType);
393
+ }
394
+ const h = options.headers;
395
+ if (h) {
396
+ for (const key in h) {
397
+ if (h.hasOwnProperty(key)) {
398
+ const element = h[key];
399
+ xhr.setRequestHeader(key, element.toString());
400
+ }
538
401
  }
539
- const xhr = new XMLHttpRequest();
540
- return yield new Promise((resolve, reject) => {
541
- if (options.cancel && options.cancel.cancelled) {
542
- reject(options.cancel.cancelled);
543
- return;
544
- }
545
- if (options.cancel) {
546
- options.cancel.registerForCancel((r) => {
547
- xhr.abort();
548
- reject(r);
549
- return;
550
- });
551
- }
552
- xhr.onreadystatechange = (e) => {
553
- if (xhr.readyState === XMLHttpRequest.DONE) {
554
- options.status = xhr.status;
555
- options.responseText = xhr.responseText;
556
- // options.responseHeaders = (xhr.getAllResponseHeaders())
557
- // .split("\n")
558
- // .map((s) => s.trim().split(":"))
559
- // .reduce((pv, cv) => pv[cv[0]] = cv[1], {});
560
- options.responseHeaders = xhr.getAllResponseHeaders();
561
- const ct = xhr.getResponseHeader("content-type");
562
- options.responseType = ct || xhr.responseType;
563
- resolve(options);
564
- }
565
- };
566
- xhr.open(options.method, url, true);
567
- if (options.dataType) {
568
- xhr.setRequestHeader("accept", options.dataType);
569
- }
570
- if (options.contentType) {
571
- xhr.setRequestHeader("content-type", options.contentType);
572
- }
573
- const h = options.headers;
574
- if (h) {
575
- for (const key in h) {
576
- if (h.hasOwnProperty(key)) {
577
- const element = h[key];
578
- xhr.setRequestHeader(key, element.toString());
579
- }
580
- }
581
- }
582
- try {
583
- xhr.send(options.data);
584
- }
585
- catch (e) {
586
- options.status = xhr.status;
587
- options.responseText = xhr.responseText;
588
- // options.responseHeaders = (xhr.getAllResponseHeaders())
589
- // .split("\n")
590
- // .map((s) => s.trim().split(":"))
591
- // .reduce((pv, cv) => pv[cv[0]] = cv[1], {});
592
- options.responseHeaders = xhr.getAllResponseHeaders();
593
- const ct = xhr.getResponseHeader("content-type");
594
- options.responseType = ct || xhr.responseType;
595
- resolve(options);
596
- }
597
- });
402
+ }
403
+ try {
404
+ xhr.send(options.data);
405
+ } catch (e) {
406
+ options.status = xhr.status;
407
+ options.responseText = xhr.responseText;
408
+ options.responseHeaders = xhr.getAllResponseHeaders();
409
+ const ct = xhr.getResponseHeader("content-type");
410
+ options.responseType = ct || xhr.responseType;
411
+ resolve(options);
412
+ }
598
413
  });
414
+ });
599
415
  }
600
- };
601
- BaseService.baseUrls = {};
602
- BaseService = __decorate([
603
- __param(0, Inject_1.Inject),
604
- __param(1, Inject_1.Inject),
605
- __metadata("design:paramtypes", [App_1.App,
606
- JsonService_1.JsonService])
607
- ], BaseService);
608
- exports.BaseService = BaseService;
609
- });
610
- //# sourceMappingURL=RestService.js.map
416
+ });
417
+ BaseService.baseUrls = {};
418
+ _export("BaseService", BaseService = __decorate([__param(0, Inject), __param(1, Inject), __metadata("design:paramtypes", [App, JsonService])], BaseService));
419
+ }
420
+ };
421
+ });
422
+ //# sourceMappingURL=/home/runner/work/core/core/dist/services/http/RestService.js.map