@web-atoms/core 2.6.24 → 2.6.25

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 (120) hide show
  1. package/dist-esm/App.js +231 -235
  2. package/dist-esm/Atom.js +93 -96
  3. package/dist-esm/MockApp.js +17 -18
  4. package/dist-esm/Pack.js +1 -3
  5. package/dist-esm/core/AtomBinder.js +189 -187
  6. package/dist-esm/core/AtomComponent.js +479 -502
  7. package/dist-esm/core/AtomDispatcher.js +46 -48
  8. package/dist-esm/core/AtomDisposableList.js +24 -25
  9. package/dist-esm/core/AtomEnumerator.js +15 -16
  10. package/dist-esm/core/AtomList.js +193 -192
  11. package/dist-esm/core/AtomLoader.js +229 -215
  12. package/dist-esm/core/AtomMap.js +7 -8
  13. package/dist-esm/core/AtomOnce.js +22 -24
  14. package/dist-esm/core/AtomSelectableList.js +240 -243
  15. package/dist-esm/core/AtomUri.js +70 -72
  16. package/dist-esm/core/AtomWatcher.js +105 -111
  17. package/dist-esm/core/Bind.js +271 -269
  18. package/dist-esm/core/BindableProperty.js +26 -27
  19. package/dist-esm/core/CancelTokenFactory.js +21 -24
  20. package/dist-esm/core/Color.js +1 -2
  21. package/dist-esm/core/Colors.js +545 -231
  22. package/dist-esm/core/Command.js +236 -223
  23. package/dist-esm/core/Defer.js +21 -22
  24. package/dist-esm/core/EventScope.js +96 -88
  25. package/dist-esm/core/ExpressionParser.js +132 -144
  26. package/dist-esm/core/ExtendControl.js +7 -8
  27. package/dist-esm/core/FormattedError.js +7 -8
  28. package/dist-esm/core/FormattedString.js +4 -5
  29. package/dist-esm/core/Hacks.js +41 -42
  30. package/dist-esm/core/IFetchEvent.js +1 -2
  31. package/dist-esm/core/IScreen.js +1 -2
  32. package/dist-esm/core/IValueConverter.js +1 -2
  33. package/dist-esm/core/InheritedProperty.js +61 -63
  34. package/dist-esm/core/InjectProperty.js +12 -13
  35. package/dist-esm/core/KeyValuePairs.js +1 -2
  36. package/dist-esm/core/Markdown.js +14 -17
  37. package/dist-esm/core/MarkdownError.js +6 -7
  38. package/dist-esm/core/PropertyBinding.js +1 -2
  39. package/dist-esm/core/PropertyMap.js +28 -27
  40. package/dist-esm/core/Route.js +149 -148
  41. package/dist-esm/core/SingleInvoker.js +32 -35
  42. package/dist-esm/core/StringHelper.js +49 -51
  43. package/dist-esm/core/TransientDisposable.js +14 -16
  44. package/dist-esm/core/WatchProperty.js +18 -17
  45. package/dist-esm/core/WebImage.js +7 -8
  46. package/dist-esm/core/XNode.js +134 -117
  47. package/dist-esm/core/sleep.js +21 -24
  48. package/dist-esm/core/types.js +102 -103
  49. package/dist-esm/di/DISingleton.js +7 -5
  50. package/dist-esm/di/DITransient.js +7 -5
  51. package/dist-esm/di/IMockOrInject.js +1 -2
  52. package/dist-esm/di/IServiceProvider.js +1 -2
  53. package/dist-esm/di/Inject.js +67 -67
  54. package/dist-esm/di/Register.js +25 -26
  55. package/dist-esm/di/RegisterScoped.js +4 -3
  56. package/dist-esm/di/RegisterSingleton.js +4 -3
  57. package/dist-esm/di/ServiceCollection.js +38 -37
  58. package/dist-esm/di/ServiceProvider.js +94 -94
  59. package/dist-esm/di/TypeKey.js +13 -12
  60. package/dist-esm/services/BusyIndicatorService.js +7 -11
  61. package/dist-esm/services/CacheService.js +54 -62
  62. package/dist-esm/services/FetchBuilder.js +327 -278
  63. package/dist-esm/services/JsonService.js +118 -116
  64. package/dist-esm/services/MockNavigationService.js +127 -126
  65. package/dist-esm/services/NavigationService.js +95 -102
  66. package/dist-esm/services/ReferenceService.js +30 -33
  67. package/dist-esm/services/http/AjaxOptions.js +1 -3
  68. package/dist-esm/services/http/JsonError.js +16 -15
  69. package/dist-esm/services/http/RestService.js +314 -323
  70. package/dist-esm/style/StyleRule.js +1 -2
  71. package/dist-esm/test.js +0 -1
  72. package/dist-esm/unit/AtomTest.js +10 -11
  73. package/dist-esm/view-model/Action.js +258 -223
  74. package/dist-esm/view-model/AtomViewModel.js +234 -232
  75. package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
  76. package/dist-esm/view-model/BindableUrlParameter.js +7 -8
  77. package/dist-esm/view-model/Delay.js +21 -25
  78. package/dist-esm/view-model/Disposable.js +28 -29
  79. package/dist-esm/view-model/Load.js +72 -73
  80. package/dist-esm/view-model/Once.js +33 -35
  81. package/dist-esm/view-model/baseTypes.js +4 -5
  82. package/dist-esm/view-model/bindPromise.js +24 -27
  83. package/dist-esm/view-model/bindProperty.js +3 -4
  84. package/dist-esm/view-model/bindUrlParameter.js +39 -43
  85. package/dist-esm/web/controls/AtomComboBox.js +56 -63
  86. package/dist-esm/web/controls/AtomControl.js +485 -490
  87. package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
  88. package/dist-esm/web/controls/AtomGridView.js +230 -222
  89. package/dist-esm/web/controls/AtomItemsControl.js +677 -688
  90. package/dist-esm/web/controls/AtomPage.js +6 -7
  91. package/dist-esm/web/controls/AtomTemplate.js +1 -3
  92. package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
  93. package/dist-esm/web/controls/AtomViewStack.js +19 -20
  94. package/dist-esm/web/core/AtomUI.js +200 -200
  95. package/dist-esm/web/core/Encoder.js +142 -152
  96. package/dist-esm/web/core/HtmlNode.js +141 -139
  97. package/dist-esm/web/images/Busy.js +1 -2
  98. package/dist-esm/web/images/BusyDataUrl.js +2 -869
  99. package/dist-esm/web/images/Button.js +1 -2
  100. package/dist-esm/web/images/ButtonDataUrl.js +2 -30
  101. package/dist-esm/web/images/CloseButton.js +1 -2
  102. package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
  103. package/dist-esm/web/images/CloseButtonHover.js +1 -2
  104. package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
  105. package/dist-esm/web/services/LastTarget.js +31 -29
  106. package/dist-esm/web/services/MarkdownService.js +19 -31
  107. package/dist-esm/web/services/NotificationPopup.js +28 -21
  108. package/dist-esm/web/services/PopupService.js +512 -478
  109. package/dist-esm/web/services/PopupWindow.js +266 -247
  110. package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
  111. package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
  112. package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
  113. package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
  114. package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
  115. package/dist-esm/web/styles/AtomStyle.js +61 -64
  116. package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
  117. package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
  118. package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
  119. package/dist-esm/web/styles/StyleBuilder.js +79 -80
  120. package/package.json +1 -1
@@ -3,128 +3,127 @@ import Map from "./AtomMap.js";
3
3
  export const ignoreValue = Symbol("ignore");
4
4
  export const errorHandled = Symbol("errorHandled");
5
5
  export class CancelToken {
6
- static isCancelled(e) {
7
- if (e[errorHandled]) {
8
- return true;
9
- }
10
- if (/^(cancelled$|canceled$|aborterror\:)/i.test(e.message ?? e.toString().trim())) {
11
- return true;
12
- }
13
- if (e.name === "AbortError") {
14
- return true;
15
- }
6
+ static isCancelled(e) {
7
+ if (e[errorHandled]) {
8
+ return true;
16
9
  }
17
- get cancelled() {
18
- return this.mCancelled;
10
+ if (/^(cancelled$|canceled$|aborterror\:)/i.test(e.message ?? e.toString().trim())) {
11
+ return true;
19
12
  }
20
- constructor(timeout = -1) {
21
- this.listeners = [];
22
- this.mCancelled = null;
23
- this.cancelTimeout = null;
24
- if (timeout > 0) {
25
- this.cancelTimeout = setTimeout(() => {
26
- this.cancelTimeout = null;
27
- this.cancel("timeout");
28
- }, timeout);
29
- }
13
+ if (e.name === "AbortError") {
14
+ return true;
30
15
  }
31
- cancel(r = "cancelled") {
32
- this.mCancelled = r;
33
- const existing = this.listeners.slice(0);
34
- this.listeners.length = 0;
35
- for (const fx of existing) {
36
- fx(r);
37
- }
38
- this.dispose();
16
+ }
17
+ get cancelled() {
18
+ return this.mCancelled;
19
+ }
20
+ constructor(timeout = -1) {
21
+ this.listeners = [];
22
+ this.mCancelled = null;
23
+ this.cancelTimeout = null;
24
+ if (timeout > 0) {
25
+ this.cancelTimeout = setTimeout(() => {
26
+ this.cancelTimeout = null;
27
+ this.cancel("timeout");
28
+ }, timeout);
39
29
  }
40
- reset() {
41
- this.mCancelled = null;
42
- this.dispose();
30
+ }
31
+ cancel(r = "cancelled") {
32
+ this.mCancelled = r;
33
+ const existing = this.listeners.slice(0);
34
+ this.listeners.length = 0;
35
+ for (const fx of existing) {
36
+ fx(r);
43
37
  }
44
- dispose() {
45
- this.listeners.length = 0;
46
- if (this.cancelTimeout) {
47
- clearTimeout(this.cancelTimeout);
48
- }
38
+ this.dispose();
39
+ }
40
+ reset() {
41
+ this.mCancelled = null;
42
+ this.dispose();
43
+ }
44
+ dispose() {
45
+ this.listeners.length = 0;
46
+ if (this.cancelTimeout) {
47
+ clearTimeout(this.cancelTimeout);
49
48
  }
50
- registerForCancel(f) {
51
- if (this.mCancelled) {
52
- f(this.mCancelled);
53
- this.cancel();
54
- return;
55
- }
56
- this.listeners.push(f);
49
+ }
50
+ registerForCancel(f) {
51
+ if (this.mCancelled) {
52
+ f(this.mCancelled);
53
+ this.cancel();
54
+ return;
57
55
  }
56
+ this.listeners.push(f);
57
+ }
58
58
  }
59
59
  export class ArrayHelper {
60
- static remove(a, filter) {
61
- for (let i = 0; i < a.length; i++) {
62
- const item = a[i];
63
- if (filter(item)) {
64
- a.splice(i, 1);
65
- return true;
66
- }
67
- }
68
- return false;
60
+ static remove(a, filter) {
61
+ for (let i = 0; i < a.length; i++) {
62
+ const item = a[i];
63
+ if (filter(item)) {
64
+ a.splice(i, 1);
65
+ return true;
66
+ }
69
67
  }
68
+ return false;
69
+ }
70
70
  }
71
71
  Object.values ??= function (t) {
72
- const r = [];
73
- for (const key in t) {
74
- if (Object.prototype.hasOwnProperty.call(t, key)) {
75
- const element = t[key];
76
- r.push(element);
77
- }
72
+ const r = [];
73
+ for (const key in t) {
74
+ if (Object.prototype.hasOwnProperty.call(t, key)) {
75
+ const element = t[key];
76
+ r.push(element);
78
77
  }
79
- return r;
78
+ }
79
+ return r;
80
80
  };
81
81
  const flat = Array.prototype.flat ?? function (depth = 1) {
82
- const r = [];
83
- const flat = depth > 0;
84
- const nestDepth = depth - 1;
85
- const nestFlat = nestDepth > 0;
86
- for (const iterator of this) {
87
- if (flat && Array.isArray(iterator)) {
88
- if (nestFlat) {
89
- r.push(...iterator.flat(nestDepth));
90
- continue;
91
- }
92
- r.push(...iterator);
93
- continue;
94
- }
95
- r.push(iterator);
82
+ const r = [];
83
+ const flat = depth > 0;
84
+ const nestDepth = depth - 1;
85
+ const nestFlat = nestDepth > 0;
86
+ for (const iterator of this) {
87
+ if (flat && Array.isArray(iterator)) {
88
+ if (nestFlat) {
89
+ r.push(...iterator.flat(nestDepth));
90
+ continue;
91
+ }
92
+ r.push(...iterator);
93
+ continue;
96
94
  }
97
- return r;
95
+ r.push(iterator);
96
+ }
97
+ return r;
98
98
  };
99
99
  const groupBy = Array.prototype.groupBy ?? function (keySelector) {
100
- const map = new Map();
101
- const groups = [];
102
- for (const iterator of this) {
103
- const key = keySelector(iterator);
104
- let g = map.get(key);
105
- if (!g) {
106
- g = [];
107
- g.key = key;
108
- groups.push(g);
109
- map.set(key, g);
110
- }
111
- g.push(iterator);
100
+ const map = new Map();
101
+ const groups = [];
102
+ for (const iterator of this) {
103
+ const key = keySelector(iterator);
104
+ let g = map.get(key);
105
+ if (!g) {
106
+ g = [];
107
+ g.key = key;
108
+ groups.push(g);
109
+ map.set(key, g);
112
110
  }
113
- map.clear();
114
- return groups;
111
+ g.push(iterator);
112
+ }
113
+ map.clear();
114
+ return groups;
115
115
  };
116
116
  Object.defineProperties(Array.prototype, {
117
- flat: {
118
- enumerable: false,
119
- value: flat,
120
- configurable: true
121
- },
122
- groupBy: {
123
- enumerable: false,
124
- value: groupBy,
125
- configurable: true
126
- }
117
+ flat: {
118
+ enumerable: false,
119
+ value: flat,
120
+ configurable: true
121
+ },
122
+ groupBy: {
123
+ enumerable: false,
124
+ value: groupBy,
125
+ configurable: true
126
+ }
127
127
  });
128
- const globalNS = (typeof window !== "undefined" ? window : global);
129
- export const UMD = (globalNS).UMD;
130
- //# sourceMappingURL=types.js.map
128
+ const globalNS = typeof window !== "undefined" ? window : global;
129
+ export const UMD = globalNS.UMD;
@@ -1,8 +1,10 @@
1
1
  import { Register } from "./Register.js";
2
2
  import { Scope } from "./ServiceCollection.js";
3
3
  export default function DISingleton(mockOrInject) {
4
- return (target) => {
5
- Register({ scope: Scope.Global, mockOrInject })(target);
6
- };
7
- }
8
- //# sourceMappingURL=DISingleton.js.map
4
+ return target => {
5
+ Register({
6
+ scope: Scope.Global,
7
+ mockOrInject
8
+ })(target);
9
+ };
10
+ }
@@ -1,8 +1,10 @@
1
1
  import { Register } from "./Register.js";
2
2
  import { Scope } from "./ServiceCollection.js";
3
3
  export default function DITransient(mockOrInject) {
4
- return (target) => {
5
- Register({ scope: Scope.Transient, mockOrInject })(target);
6
- };
7
- }
8
- //# sourceMappingURL=DITransient.js.map
4
+ return target => {
5
+ Register({
6
+ scope: Scope.Transient,
7
+ mockOrInject
8
+ })(target);
9
+ };
10
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=IMockOrInject.js.map
1
+ export {};
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=IServiceProvider.js.map
1
+ export {};
@@ -1,77 +1,77 @@
1
1
  import { TypeKey } from "./TypeKey.js";
2
2
  export class InjectedTypes {
3
- static { this.paramList = {}; }
4
- static { this.propertyList = {}; }
5
- static getParamList(key, typeKey1) {
6
- let plist = InjectedTypes.paramList[typeKey1];
7
- let type = key;
8
- while (plist === undefined) {
9
- type = Object.getPrototypeOf(type);
10
- if (!type) {
11
- break;
12
- }
13
- const typeKey = TypeKey.get(type);
14
- plist = InjectedTypes.paramList[typeKey];
15
- if (!plist) {
16
- InjectedTypes.paramList[typeKey] = plist;
17
- }
18
- }
19
- return plist;
3
+ static {
4
+ this.paramList = {};
5
+ }
6
+ static {
7
+ this.propertyList = {};
8
+ }
9
+ static getParamList(key, typeKey1) {
10
+ let plist = InjectedTypes.paramList[typeKey1];
11
+ let type = key;
12
+ while (plist === undefined) {
13
+ type = Object.getPrototypeOf(type);
14
+ if (!type) {
15
+ break;
16
+ }
17
+ const typeKey = TypeKey.get(type);
18
+ plist = InjectedTypes.paramList[typeKey];
19
+ if (!plist) {
20
+ InjectedTypes.paramList[typeKey] = plist;
21
+ }
20
22
  }
21
- static getPropertyList(key, typeKey1) {
22
- let plist = InjectedTypes.propertyList[typeKey1];
23
- let type = key;
24
- while (plist === undefined) {
25
- type = Object.getPrototypeOf(type);
26
- if (!type) {
27
- break;
28
- }
29
- const typeKey = TypeKey.get(type);
30
- plist = InjectedTypes.propertyList[typeKey];
31
- if (!plist) {
32
- InjectedTypes.propertyList[typeKey] = plist;
33
- }
34
- }
35
- return plist;
23
+ return plist;
24
+ }
25
+ static getPropertyList(key, typeKey1) {
26
+ let plist = InjectedTypes.propertyList[typeKey1];
27
+ let type = key;
28
+ while (plist === undefined) {
29
+ type = Object.getPrototypeOf(type);
30
+ if (!type) {
31
+ break;
32
+ }
33
+ const typeKey = TypeKey.get(type);
34
+ plist = InjectedTypes.propertyList[typeKey];
35
+ if (!plist) {
36
+ InjectedTypes.propertyList[typeKey] = plist;
37
+ }
36
38
  }
39
+ return plist;
40
+ }
37
41
  }
38
42
  export function Inject(target, name, index) {
39
- if (index !== undefined) {
40
- const key = TypeKey.get(target);
41
- const plist = Reflect.getMetadata("design:paramtypes", target, name);
42
- if (typeof index === "number") {
43
- const pSavedList = InjectedTypes.paramList[key] || (InjectedTypes.paramList[key] = []);
44
- pSavedList[index] = plist[index];
45
- }
46
- else {
47
- throw new Error("Inject can only be applied on constructor" +
48
- "parameter or a property without get/set methods");
49
- }
43
+ if (index !== undefined) {
44
+ const key = TypeKey.get(target);
45
+ const plist = Reflect.getMetadata("design:paramtypes", target, name);
46
+ if (typeof index === "number") {
47
+ const pSavedList = InjectedTypes.paramList[key] || (InjectedTypes.paramList[key] = []);
48
+ pSavedList[index] = plist[index];
49
+ } else {
50
+ throw new Error("Inject can only be applied on constructor" + "parameter or a property without get/set methods");
50
51
  }
51
- else {
52
- const key = TypeKey.get(target.constructor);
53
- const plist = Reflect.getMetadata("design:type", target, name);
54
- const p = InjectedTypes.propertyList[key] || (InjectedTypes.propertyList[key] = {});
55
- p[name] = plist;
56
- let base = target.constructor;
57
- while (true) {
58
- base = Object.getPrototypeOf(base);
59
- if (!base) {
60
- break;
61
- }
62
- const baseKey = TypeKey.get(base);
63
- const bp = InjectedTypes.propertyList[baseKey];
64
- if (bp) {
65
- for (const pKey in bp) {
66
- if (bp.hasOwnProperty(pKey)) {
67
- const element = bp[pKey];
68
- if (!p[pKey]) {
69
- p[pKey] = element;
70
- }
71
- }
72
- }
52
+ } else {
53
+ const key = TypeKey.get(target.constructor);
54
+ const plist = Reflect.getMetadata("design:type", target, name);
55
+ const p = InjectedTypes.propertyList[key] || (InjectedTypes.propertyList[key] = {});
56
+ p[name] = plist;
57
+ let base = target.constructor;
58
+ while (true) {
59
+ base = Object.getPrototypeOf(base);
60
+ if (!base) {
61
+ break;
62
+ }
63
+ const baseKey = TypeKey.get(base);
64
+ const bp = InjectedTypes.propertyList[baseKey];
65
+ if (bp) {
66
+ for (const pKey in bp) {
67
+ if (bp.hasOwnProperty(pKey)) {
68
+ const element = bp[pKey];
69
+ if (!p[pKey]) {
70
+ p[pKey] = element;
73
71
  }
72
+ }
74
73
  }
74
+ }
75
75
  }
76
- }
77
- //# sourceMappingURL=Inject.js.map
76
+ }
77
+ }
@@ -1,33 +1,32 @@
1
1
  import { Scope, ServiceCollection } from "./ServiceCollection.js";
2
- const globalNS = (typeof global === "undefined") ? window : global;
2
+ const globalNS = typeof global === "undefined" ? window : global;
3
3
  function evalGlobal(path) {
4
- if (typeof path === "string") {
5
- let r = globalNS;
6
- for (const iterator of path.split(".")) {
7
- r = r[iterator];
8
- if (r === undefined || r === null) {
9
- return r;
10
- }
11
- }
4
+ if (typeof path === "string") {
5
+ let r = globalNS;
6
+ for (const iterator of path.split(".")) {
7
+ r = r[iterator];
8
+ if (r === undefined || r === null) {
12
9
  return r;
10
+ }
13
11
  }
14
- return path;
12
+ return r;
13
+ }
14
+ return path;
15
15
  }
16
16
  export function Register(id, scope) {
17
- return (target) => {
18
- if (typeof id === "object") {
19
- if (scope) {
20
- id.scope = scope;
21
- }
22
- ServiceCollection.instance.register(id.for || target, id.for ? (sp) => sp.create(target) : null, id.scope || Scope.Transient, id.id);
23
- if (id.mockOrInject) {
24
- if (id.mockOrInject.globalVar) {
25
- ServiceCollection.instance.register(id.for || target, (sp) => evalGlobal(id.mockOrInject.globalVar), id.scope || Scope.Global, id.id);
26
- }
27
- }
28
- return;
17
+ return target => {
18
+ if (typeof id === "object") {
19
+ if (scope) {
20
+ id.scope = scope;
21
+ }
22
+ ServiceCollection.instance.register(id.for || target, id.for ? sp => sp.create(target) : null, id.scope || Scope.Transient, id.id);
23
+ if (id.mockOrInject) {
24
+ if (id.mockOrInject.globalVar) {
25
+ ServiceCollection.instance.register(id.for || target, sp => evalGlobal(id.mockOrInject.globalVar), id.scope || Scope.Global, id.id);
29
26
  }
30
- ServiceCollection.instance.register(target, null, scope, id);
31
- };
32
- }
33
- //# sourceMappingURL=Register.js.map
27
+ }
28
+ return;
29
+ }
30
+ ServiceCollection.instance.register(target, null, scope, id);
31
+ };
32
+ }
@@ -1,6 +1,7 @@
1
1
  import { Register } from "./Register.js";
2
2
  import { Scope } from "./ServiceCollection.js";
3
3
  export function RegisterScoped(id) {
4
- Register({ scope: Scope.Scoped })(id);
5
- }
6
- //# sourceMappingURL=RegisterScoped.js.map
4
+ Register({
5
+ scope: Scope.Scoped
6
+ })(id);
7
+ }
@@ -1,6 +1,7 @@
1
1
  import { Register } from "./Register.js";
2
2
  import { Scope } from "./ServiceCollection.js";
3
3
  export function RegisterSingleton(target) {
4
- Register({ scope: Scope.Global })(target);
5
- }
6
- //# sourceMappingURL=RegisterSingleton.js.map
4
+ Register({
5
+ scope: Scope.Global
6
+ })(target);
7
+ }
@@ -2,45 +2,46 @@ import { ArrayHelper } from "../core/types.js";
2
2
  import { TypeKey } from "./TypeKey.js";
3
3
  export var Scope;
4
4
  (function (Scope) {
5
- Scope[Scope["Global"] = 1] = "Global";
6
- Scope[Scope["Scoped"] = 2] = "Scoped";
7
- Scope[Scope["Transient"] = 3] = "Transient";
5
+ Scope[Scope["Global"] = 1] = "Global";
6
+ Scope[Scope["Scoped"] = 2] = "Scoped";
7
+ Scope[Scope["Transient"] = 3] = "Transient";
8
8
  })(Scope || (Scope = {}));
9
9
  export class ServiceDescription {
10
- constructor(id, scope, type, factory) {
11
- this.id = id;
12
- this.scope = scope;
13
- this.type = type;
14
- this.factory = factory;
15
- this.factory = this.factory || ((sp) => {
16
- return sp.create(type);
17
- });
18
- }
10
+ constructor(id, scope, type, factory) {
11
+ this.id = id;
12
+ this.scope = scope;
13
+ this.type = type;
14
+ this.factory = factory;
15
+ this.factory = this.factory || (sp => {
16
+ return sp.create(type);
17
+ });
18
+ }
19
19
  }
20
20
  export class ServiceCollection {
21
- constructor() {
22
- this.registrations = [];
23
- this.ids = 1;
24
- }
25
- static { this.instance = new ServiceCollection(); }
26
- register(type, factory, scope = Scope.Transient, id) {
27
- ArrayHelper.remove(this.registrations, (r) => id ? r.id === id : r.type === type);
28
- if (!id) {
29
- id = TypeKey.get(type);
30
- this.ids++;
31
- }
32
- const sd = new ServiceDescription(id, scope, type, factory);
33
- this.registrations.push(sd);
34
- return sd;
35
- }
36
- registerScoped(type, factory, id) {
37
- return this.register(type, factory, Scope.Scoped, id);
21
+ constructor() {
22
+ this.registrations = [];
23
+ this.ids = 1;
24
+ }
25
+ static {
26
+ this.instance = new ServiceCollection();
27
+ }
28
+ register(type, factory, scope = Scope.Transient, id) {
29
+ ArrayHelper.remove(this.registrations, r => id ? r.id === id : r.type === type);
30
+ if (!id) {
31
+ id = TypeKey.get(type);
32
+ this.ids++;
38
33
  }
39
- registerSingleton(type, factory, id) {
40
- return this.register(type, factory, Scope.Global, id);
41
- }
42
- get(type) {
43
- return this.registrations.find((s) => s.id === type || s.type === type);
44
- }
45
- }
46
- //# sourceMappingURL=ServiceCollection.js.map
34
+ const sd = new ServiceDescription(id, scope, type, factory);
35
+ this.registrations.push(sd);
36
+ return sd;
37
+ }
38
+ registerScoped(type, factory, id) {
39
+ return this.register(type, factory, Scope.Scoped, id);
40
+ }
41
+ registerSingleton(type, factory, id) {
42
+ return this.register(type, factory, Scope.Global, id);
43
+ }
44
+ get(type) {
45
+ return this.registrations.find(s => s.id === type || s.type === type);
46
+ }
47
+ }