@leyyo/common 1.3.8 → 1.3.10

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 (211) hide show
  1. package/dist/base/index.d.ts +3 -3
  2. package/dist/base/index.js +3 -20
  3. package/dist/base/index.types.d.ts +36 -18
  4. package/dist/base/index.types.js +1 -3
  5. package/dist/base/leyyo.d.ts +1 -1
  6. package/dist/base/leyyo.js +35 -26
  7. package/dist/base/leyyo.types.d.ts +3 -3
  8. package/dist/base/leyyo.types.js +1 -3
  9. package/dist/class/index.d.ts +2 -2
  10. package/dist/class/index.js +2 -19
  11. package/dist/class/index.types.d.ts +1 -1
  12. package/dist/class/index.types.js +1 -3
  13. package/dist/class/list.d.ts +1 -1
  14. package/dist/class/list.js +1 -6
  15. package/dist/class/logger.instance.d.ts +5 -5
  16. package/dist/class/logger.instance.js +8 -12
  17. package/dist/common/deploy.common.d.ts +2 -2
  18. package/dist/common/deploy.common.js +14 -16
  19. package/dist/common/enum.pool.d.ts +5 -3
  20. package/dist/common/enum.pool.js +36 -48
  21. package/dist/common/error.common.d.ts +4 -4
  22. package/dist/common/error.common.js +45 -85
  23. package/dist/common/error.pool.d.ts +5 -3
  24. package/dist/common/error.pool.js +12 -23
  25. package/dist/common/event.common.d.ts +2 -2
  26. package/dist/common/event.common.js +25 -28
  27. package/dist/common/index.d.ts +11 -11
  28. package/dist/common/index.js +11 -28
  29. package/dist/common/index.types.d.ts +42 -6
  30. package/dist/common/index.types.js +1 -3
  31. package/dist/common/inert.d.ts +4 -2
  32. package/dist/common/inert.js +97 -110
  33. package/dist/common/lifecycle.common.d.ts +2 -2
  34. package/dist/common/lifecycle.common.js +48 -61
  35. package/dist/common/literal.pool.d.ts +6 -3
  36. package/dist/common/literal.pool.js +37 -48
  37. package/dist/common/log.common.d.ts +4 -4
  38. package/dist/common/log.common.js +63 -60
  39. package/dist/common/repo.common.d.ts +3 -3
  40. package/dist/common/repo.common.js +50 -52
  41. package/dist/const/index.js +26 -30
  42. package/dist/enum/index.d.ts +1 -1
  43. package/dist/enum/index.js +1 -18
  44. package/dist/enum/log-level.js +1 -5
  45. package/dist/error/caused.error.d.ts +2 -2
  46. package/dist/error/caused.error.js +2 -7
  47. package/dist/error/developer.error.d.ts +3 -3
  48. package/dist/error/developer.error.js +9 -9
  49. package/dist/error/http.error.d.ts +2 -2
  50. package/dist/error/http.error.js +9 -15
  51. package/dist/error/index.d.ts +7 -7
  52. package/dist/error/index.js +7 -24
  53. package/dist/error/index.types.d.ts +3 -3
  54. package/dist/error/index.types.js +1 -3
  55. package/dist/error/invalid-value.error.d.ts +1 -1
  56. package/dist/error/invalid-value.error.js +6 -13
  57. package/dist/error/leyyo.error.d.ts +5 -5
  58. package/dist/error/leyyo.error.js +45 -34
  59. package/dist/error/multiple.error.d.ts +2 -2
  60. package/dist/error/multiple.error.js +6 -12
  61. package/dist/function/define-loader.d.ts +1 -1
  62. package/dist/function/define-loader.js +7 -10
  63. package/dist/function/delay.js +2 -6
  64. package/dist/function/delete-prop.js +9 -15
  65. package/dist/function/{empty.fn.js → empty-fn.js} +1 -5
  66. package/dist/function/extended-type.d.ts +1 -1
  67. package/dist/function/extended-type.js +8 -12
  68. package/dist/function/get-fqn.d.ts +1 -1
  69. package/dist/function/get-fqn.js +7 -12
  70. package/dist/function/get-prop.js +10 -16
  71. package/dist/function/has-fqn.d.ts +1 -1
  72. package/dist/function/has-fqn.js +7 -11
  73. package/dist/function/index.d.ts +38 -28
  74. package/dist/function/index.js +38 -45
  75. package/dist/function/index.types.d.ts +2 -2
  76. package/dist/function/index.types.js +1 -3
  77. package/dist/function/is-anonymous-name.js +3 -7
  78. package/dist/function/is-class.d.ts +7 -0
  79. package/dist/function/is-class.js +18 -0
  80. package/dist/function/is-empty.d.ts +12 -0
  81. package/dist/function/is-empty.js +18 -0
  82. package/dist/function/is-filled-arr.d.ts +10 -0
  83. package/dist/function/is-filled-arr.js +12 -0
  84. package/dist/function/is-filled-obj.d.ts +10 -0
  85. package/dist/function/is-filled-obj.js +13 -0
  86. package/dist/function/is-obj.d.ts +9 -0
  87. package/dist/function/is-obj.js +11 -0
  88. package/dist/function/is-test.js +2 -7
  89. package/dist/function/is-text.d.ts +11 -0
  90. package/dist/function/is-text.js +17 -0
  91. package/dist/function/jitter-interval.js +2 -6
  92. package/dist/function/leyyo-fn.d.ts +1 -1
  93. package/dist/function/leyyo-fn.js +2 -7
  94. package/dist/function/on-fqn-set.d.ts +1 -1
  95. package/dist/function/on-fqn-set.js +9 -13
  96. package/dist/function/one-or-more.d.ts +1 -1
  97. package/dist/function/one-or-more.js +1 -5
  98. package/dist/function/opt-add.d.ts +10 -0
  99. package/dist/function/opt-add.js +29 -0
  100. package/dist/function/opt-append.d.ts +9 -0
  101. package/dist/function/opt-append.js +24 -0
  102. package/dist/function/opt-check.d.ts +8 -0
  103. package/dist/function/opt-check.js +31 -0
  104. package/dist/function/opt-clone.d.ts +8 -0
  105. package/dist/function/opt-clone.js +12 -0
  106. package/dist/function/opt-field.d.ts +11 -0
  107. package/dist/function/opt-field.js +31 -0
  108. package/dist/function/opt-fn.d.ts +8 -0
  109. package/dist/function/opt-fn.js +11 -0
  110. package/dist/function/random-test-no.js +1 -5
  111. package/dist/function/remove-fqn.d.ts +1 -1
  112. package/dist/function/remove-fqn.js +10 -14
  113. package/dist/function/run-exporter.d.ts +1 -1
  114. package/dist/function/run-exporter.js +12 -27
  115. package/dist/function/secure-clone.d.ts +1 -1
  116. package/dist/function/secure-clone.js +2 -7
  117. package/dist/function/secure-json.js +6 -12
  118. package/dist/function/set-anonymous-fqn.d.ts +1 -1
  119. package/dist/function/set-anonymous-fqn.js +15 -19
  120. package/dist/function/set-anonymous-name.d.ts +1 -1
  121. package/dist/function/set-anonymous-name.js +23 -26
  122. package/dist/function/set-fqn.d.ts +1 -1
  123. package/dist/function/set-fqn.js +28 -31
  124. package/dist/function/set-prop.js +9 -15
  125. package/dist/function/stamp-loader.d.ts +1 -1
  126. package/dist/function/stamp-loader.js +4 -8
  127. package/dist/function/test-case.js +5 -9
  128. package/dist/function/test-name.js +4 -8
  129. package/dist/function/trigger-fqn.d.ts +1 -1
  130. package/dist/function/trigger-fqn.js +5 -9
  131. package/dist/index.d.ts +19 -19
  132. package/dist/index.foretell.js +10 -88
  133. package/dist/index.js +22 -40
  134. package/dist/index.loader.d.ts +1 -1
  135. package/dist/index.loader.js +6 -43
  136. package/dist/init/index.js +3 -7
  137. package/dist/internal.js +1 -5
  138. package/package.json +26 -16
  139. package/dist/assets/.gitkeep +0 -0
  140. package/dist/base/index.js.map +0 -1
  141. package/dist/base/index.types.js.map +0 -1
  142. package/dist/base/leyyo.js.map +0 -1
  143. package/dist/base/leyyo.types.js.map +0 -1
  144. package/dist/class/index.js.map +0 -1
  145. package/dist/class/index.types.js.map +0 -1
  146. package/dist/class/list.js.map +0 -1
  147. package/dist/class/logger.instance.js.map +0 -1
  148. package/dist/common/deploy.common.js.map +0 -1
  149. package/dist/common/enum.pool.js.map +0 -1
  150. package/dist/common/error.common.js.map +0 -1
  151. package/dist/common/error.pool.js.map +0 -1
  152. package/dist/common/event.common.js.map +0 -1
  153. package/dist/common/index.js.map +0 -1
  154. package/dist/common/index.types.js.map +0 -1
  155. package/dist/common/inert.js.map +0 -1
  156. package/dist/common/lifecycle.common.js.map +0 -1
  157. package/dist/common/literal.pool.js.map +0 -1
  158. package/dist/common/log.common.js.map +0 -1
  159. package/dist/common/repo.common.js.map +0 -1
  160. package/dist/const/index.js.map +0 -1
  161. package/dist/enum/index.js.map +0 -1
  162. package/dist/enum/log-level.js.map +0 -1
  163. package/dist/error/caused.error.js.map +0 -1
  164. package/dist/error/developer.error.js.map +0 -1
  165. package/dist/error/http.error.js.map +0 -1
  166. package/dist/error/index.js.map +0 -1
  167. package/dist/error/index.types.js.map +0 -1
  168. package/dist/error/invalid-value.error.js.map +0 -1
  169. package/dist/error/leyyo.error.js.map +0 -1
  170. package/dist/error/multiple.error.js.map +0 -1
  171. package/dist/function/define-loader.js.map +0 -1
  172. package/dist/function/delay.js.map +0 -1
  173. package/dist/function/delete-prop.js.map +0 -1
  174. package/dist/function/empty.fn.js.map +0 -1
  175. package/dist/function/extended-type.js.map +0 -1
  176. package/dist/function/get-fqn.js.map +0 -1
  177. package/dist/function/get-prop.js.map +0 -1
  178. package/dist/function/has-fqn.js.map +0 -1
  179. package/dist/function/index.js.map +0 -1
  180. package/dist/function/index.types.js.map +0 -1
  181. package/dist/function/is-anonymous-name.js.map +0 -1
  182. package/dist/function/is-test.js.map +0 -1
  183. package/dist/function/is.fn.d.ts +0 -59
  184. package/dist/function/is.fn.js +0 -93
  185. package/dist/function/is.fn.js.map +0 -1
  186. package/dist/function/jitter-interval.js.map +0 -1
  187. package/dist/function/leyyo-fn.js.map +0 -1
  188. package/dist/function/on-fqn-set.js.map +0 -1
  189. package/dist/function/one-or-more.js.map +0 -1
  190. package/dist/function/opt.fn.d.ts +0 -49
  191. package/dist/function/opt.fn.js +0 -142
  192. package/dist/function/opt.fn.js.map +0 -1
  193. package/dist/function/random-test-no.js.map +0 -1
  194. package/dist/function/remove-fqn.js.map +0 -1
  195. package/dist/function/run-exporter.js.map +0 -1
  196. package/dist/function/secure-clone.js.map +0 -1
  197. package/dist/function/secure-json.js.map +0 -1
  198. package/dist/function/set-anonymous-fqn.js.map +0 -1
  199. package/dist/function/set-anonymous-name.js.map +0 -1
  200. package/dist/function/set-fqn.js.map +0 -1
  201. package/dist/function/set-prop.js.map +0 -1
  202. package/dist/function/stamp-loader.js.map +0 -1
  203. package/dist/function/test-case.js.map +0 -1
  204. package/dist/function/test-name.js.map +0 -1
  205. package/dist/function/trigger-fqn.js.map +0 -1
  206. package/dist/index.foretell.js.map +0 -1
  207. package/dist/index.js.map +0 -1
  208. package/dist/index.loader.js.map +0 -1
  209. package/dist/init/index.js.map +0 -1
  210. package/dist/internal.js.map +0 -1
  211. /package/dist/function/{empty.fn.d.ts → empty-fn.d.ts} +0 -0
@@ -1,20 +1,13 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Inert = void 0;
13
- const internal_1 = require("../internal");
14
- const function_1 = require("../function");
15
- const where = `${internal_1.FQN}.Inert`;
1
+ import { FQN } from "../internal.js";
2
+ import { getFqn, isFilledArr, isFilledObj, isObj, isText, onFqnSet, setAnonymousName, setFqn, testCase } from "../function/index.js";
3
+ const where = `${FQN}.Inert`;
16
4
  // noinspection JSUnusedGlobalSymbols
17
- class Inert {
5
+ export class Inert {
6
+ leyyo;
7
+ cluster;
8
+ options;
9
+ _repo;
10
+ static _pool;
18
11
  /**
19
12
  * Constructor
20
13
  *
@@ -26,21 +19,21 @@ class Inert {
26
19
  this.leyyo = leyyo;
27
20
  this.cluster = cluster;
28
21
  this.options = options;
29
- if (!(0, function_1.isText)(this.cluster)) {
30
- throw new this.leyyo.developerError('Invalid cluster name', (0, function_1.testCase)(internal_1.FQN, 'XXX'), where);
22
+ if (!isText(this.cluster)) {
23
+ throw new this.leyyo.developerError('Invalid cluster name', testCase(FQN, 'XXX'), where);
31
24
  }
32
- if ((0, function_1.isObj)(this.options)) {
25
+ if (isObj(this.options)) {
33
26
  this.options = {};
34
27
  }
35
- if (this.options.anonymousName && !(0, function_1.isText)(this.options.anonymousName)) {
36
- throw new this.leyyo.developerError('Invalid anonymous name', (0, function_1.testCase)(internal_1.FQN, 'XXX'), where);
28
+ if (this.options.anonymousName && !isText(this.options.anonymousName)) {
29
+ throw new this.leyyo.developerError('Invalid anonymous name', testCase(FQN, 'XXX'), where);
37
30
  }
38
31
  const repo = this.leyyo.repoCommon;
39
32
  if (!Inert._pool) {
40
33
  Inert._pool = repo.newMap(`${where}.pool`);
41
34
  }
42
35
  if (Inert._pool.has(this.cluster)) {
43
- throw new this.leyyo.developerError(`Duplicated cluster [${this.cluster}]`, (0, function_1.testCase)(internal_1.FQN, 'XXX'), where);
36
+ throw new this.leyyo.developerError(`Duplicated cluster [${this.cluster}]`, testCase(FQN, 'XXX'), where);
44
37
  }
45
38
  this._repo = {
46
39
  uniqueLoaded: repo.newSet(`${where}.${this.cluster}.uniqueLoaded`),
@@ -54,16 +47,16 @@ class Inert {
54
47
  }
55
48
  // region private
56
49
  _inFqnStage(item) {
57
- item.full = (0, function_1.getFqn)(item.target);
50
+ item.full = getFqn(item.target);
58
51
  if (!item.full || !item.full.includes('.')) {
59
- if ((0, function_1.isText)(item.fqn)) {
60
- item.full = (0, function_1.setFqn)(item.target, item.fqn);
52
+ if (isText(item.fqn)) {
53
+ item.full = setFqn(item.target, item.fqn);
61
54
  }
62
55
  else {
63
56
  const { pendingFqn } = this._repo;
64
57
  pendingFqn.set(item.name, item);
65
58
  item.stage = 'fqn-waiting';
66
- (0, function_1.onFqnSet)(item.target, f => this._afterFqnSet(f));
59
+ onFqnSet(item.target, f => this._afterFqnSet(f));
67
60
  this._afterTargetFound(item);
68
61
  return true;
69
62
  }
@@ -71,7 +64,7 @@ class Inert {
71
64
  return false;
72
65
  }
73
66
  _afterFqnSet(full) {
74
- if (!(0, function_1.isText)(full)) {
67
+ if (!isText(full)) {
75
68
  return;
76
69
  }
77
70
  const { pendingFqn } = this._repo;
@@ -83,19 +76,19 @@ class Inert {
83
76
  this._onFqnCompleted(item);
84
77
  }
85
78
  else {
86
- new this.leyyo.developerError(`Inert could not be found after come back, [${full}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where).log();
79
+ new this.leyyo.developerError(`Inert could not be found after come back, [${full}]`, testCase(FQN, 'ZZZ'), where).log();
87
80
  }
88
81
  }
89
82
  _onFqnCompleted(item) {
90
83
  let ignore;
91
84
  const { fullNames, basicNames, aliases } = this._repo;
92
- if ((0, function_1.isText)(item.full)) {
85
+ if (isText(item.full)) {
93
86
  ignore = false;
94
87
  if (fullNames.has(item.full)) {
95
88
  const anotherItem = fullNames.get(item.full);
96
89
  if (anotherItem.target !== item.target) {
97
90
  ignore = true;
98
- new this.leyyo.developerError(`Duplicated full name [${item.full}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where).log();
91
+ new this.leyyo.developerError(`Duplicated full name [${item.full}]`, testCase(FQN, 'ZZZ'), where).log();
99
92
  }
100
93
  }
101
94
  if (!ignore) {
@@ -107,25 +100,24 @@ class Inert {
107
100
  const anotherItem = basicNames.get(item.name);
108
101
  if (anotherItem.target !== item.target) {
109
102
  ignore = true;
110
- new this.leyyo.developerError(`Duplicated basic name [${item.name}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where).log();
103
+ new this.leyyo.developerError(`Duplicated basic name [${item.name}]`, testCase(FQN, 'ZZZ'), where).log();
111
104
  }
112
105
  }
113
106
  if (!ignore) {
114
107
  basicNames.set(item.name, item);
115
108
  }
116
- if ((0, function_1.isFilledArr)(item.aliases)) {
109
+ if (isFilledArr(item.aliases)) {
117
110
  item.aliases.forEach(alias => {
118
- var _a;
119
111
  ignore = false;
120
112
  if (aliases.has(alias)) {
121
113
  const anotherName = aliases.get(alias);
122
114
  if (![item.name, item.full].includes(anotherName)) {
123
115
  ignore = true;
124
- new this.leyyo.developerError(`Duplicated alias [${item.name}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where).log();
116
+ new this.leyyo.developerError(`Duplicated alias [${item.name}]`, testCase(FQN, 'ZZZ'), where).log();
125
117
  }
126
118
  }
127
119
  if (!ignore) {
128
- aliases.set(alias, (_a = item.full) !== null && _a !== void 0 ? _a : item.name);
120
+ aliases.set(alias, item.full ?? item.name);
129
121
  }
130
122
  });
131
123
  }
@@ -134,8 +126,8 @@ class Inert {
134
126
  /** @inheritDoc */
135
127
  register(options) {
136
128
  const { uniqueLoaded } = this._repo;
137
- if (!(0, function_1.isFilledObj)(options)) {
138
- throw new this.leyyo.developerError('Invalid inert options', (0, function_1.testCase)(internal_1.FQN, 'XXX'), where);
129
+ if (!isFilledObj(options)) {
130
+ throw new this.leyyo.developerError('Invalid inert options', testCase(FQN, 'XXX'), where);
139
131
  }
140
132
  // target
141
133
  if (this._validate(options.target)) {
@@ -148,18 +140,18 @@ class Inert {
148
140
  }
149
141
  let basicName = this._getName(options.target);
150
142
  if (!basicName) {
151
- if ((0, function_1.isText)(options.name)) {
143
+ if (isText(options.name)) {
152
144
  basicName = options.name;
153
145
  this._setName(options.target, options.name);
154
146
  }
155
147
  else if (this.options.anonymousName) {
156
- basicName = (0, function_1.setAnonymousName)(options.target, this.options.anonymousName);
148
+ basicName = setAnonymousName(options.target, this.options.anonymousName);
157
149
  }
158
150
  }
159
151
  if (!basicName) {
160
- throw new this.leyyo.developerError('Empty name', (0, function_1.testCase)(internal_1.FQN, 220), where);
152
+ throw new this.leyyo.developerError('Empty name', testCase(FQN, 220), where);
161
153
  }
162
- const item = Object.assign(Object.assign({}, options), { name: basicName, stage: undefined, mode: 'eager' });
154
+ const item = { ...options, name: basicName, stage: undefined, mode: 'eager' };
163
155
  if (this._inFqnStage(item)) {
164
156
  return;
165
157
  }
@@ -169,45 +161,44 @@ class Inert {
169
161
  }
170
162
  // lazy target
171
163
  else if (options.lazyTarget instanceof Promise) {
172
- if (!(0, function_1.isText)(options.name)) {
173
- throw new this.leyyo.developerError('Invalid inert name', (0, function_1.testCase)(internal_1.FQN, 'XXX'), where);
164
+ if (!isText(options.name)) {
165
+ throw new this.leyyo.developerError('Invalid inert name', testCase(FQN, 'XXX'), where);
174
166
  }
175
167
  // it's already pending to be loaded
176
168
  const { pendingLazy } = this._repo;
177
169
  if (pendingLazy.has(options.name)) {
178
170
  return;
179
171
  }
180
- const item = Object.assign(Object.assign({}, options), { stage: 'loading-waiting', mode: 'lazy' });
172
+ const item = { ...options, stage: 'loading-waiting', mode: 'lazy' };
181
173
  pendingLazy.set(options.name, item);
182
174
  }
183
175
  else {
184
- throw new this.leyyo.developerError(`Invalid target or lazy target [${options.name}]`, (0, function_1.testCase)(internal_1.FQN, 224), where);
176
+ throw new this.leyyo.developerError(`Invalid target or lazy target [${options.name}]`, testCase(FQN, 224), where);
185
177
  }
186
178
  }
187
179
  /** @inheritDoc */
180
+ lazy(fqn, name, lazyTarget, opt) {
181
+ this.register({ ...(opt ?? {}), fqn, name, lazyTarget });
182
+ }
183
+ /** @inheritDoc */
188
184
  isLazy(name) {
189
- var _a;
190
- return ((_a = this.get(name)) === null || _a === void 0 ? void 0 : _a.mode) === 'lazy';
185
+ return this.get(name)?.mode === 'lazy';
191
186
  }
192
187
  /** @inheritDoc */
193
188
  isInvalid(name) {
194
- var _a;
195
- return ['failed', 'conflicted'].includes((_a = this.get(name)) === null || _a === void 0 ? void 0 : _a.mode);
189
+ return ['failed', 'conflicted'].includes(this.get(name)?.mode);
196
190
  }
197
191
  /** @inheritDoc */
198
192
  isFailed(name) {
199
- var _a;
200
- return ((_a = this.get(name)) === null || _a === void 0 ? void 0 : _a.mode) === 'failed';
193
+ return this.get(name)?.mode === 'failed';
201
194
  }
202
195
  /** @inheritDoc */
203
196
  isConflicted(name) {
204
- var _a;
205
- return ((_a = this.get(name)) === null || _a === void 0 ? void 0 : _a.mode) === 'conflicted';
197
+ return this.get(name)?.mode === 'conflicted';
206
198
  }
207
199
  /** @inheritDoc */
208
200
  isEager(name) {
209
- var _a;
210
- return ((_a = this.get(name)) === null || _a === void 0 ? void 0 : _a.mode) === 'eager';
201
+ return this.get(name)?.mode === 'eager';
211
202
  }
212
203
  /** @inheritDoc */
213
204
  has(name) {
@@ -215,7 +206,7 @@ class Inert {
215
206
  }
216
207
  /** @inheritDoc */
217
208
  get(name) {
218
- if (!(0, function_1.isText)(name)) {
209
+ if (!isText(name)) {
219
210
  return undefined;
220
211
  }
221
212
  const { fullNames, basicNames, pendingFqn, pendingLazy, aliases } = this._repo;
@@ -238,65 +229,61 @@ class Inert {
238
229
  return basicNames.get(name);
239
230
  }
240
231
  /** @inheritDoc */
241
- load(name) {
242
- return __awaiter(this, void 0, void 0, function* () {
243
- if (!(0, function_1.isText)(name)) {
244
- throw new this.leyyo.developerError(`Invalid lazy name`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where);
245
- }
246
- const { pendingLazy, uniqueLoaded } = this._repo;
247
- const item = this.get(name);
248
- if (!item) {
249
- throw new this.leyyo.developerError(`Lazy was not defined [${name}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where);
250
- }
251
- // It was already loaded
252
- if (item.mode === 'eager') {
253
- return item;
254
- }
255
- try {
256
- item.target = yield item.lazyTarget;
257
- if (this._validate(item.target)) {
258
- item.mode = 'eager';
259
- delete item.lazyTarget;
260
- // remove from pending
261
- if (pendingLazy.has(name)) {
262
- pendingLazy.delete(name);
263
- }
264
- yield this._nextLoad(item);
265
- // already loaded
266
- if (uniqueLoaded.has(item.target)) {
267
- return item;
268
- }
232
+ async load(name) {
233
+ if (!isText(name)) {
234
+ throw new this.leyyo.developerError(`Invalid lazy name`, testCase(FQN, 'ZZZ'), where);
235
+ }
236
+ const { pendingLazy, uniqueLoaded } = this._repo;
237
+ const item = this.get(name);
238
+ if (!item) {
239
+ throw new this.leyyo.developerError(`Lazy was not defined [${name}]`, testCase(FQN, 'ZZZ'), where);
240
+ }
241
+ // It was already loaded
242
+ if (item.mode === 'eager') {
243
+ return item;
244
+ }
245
+ try {
246
+ item.target = await item.lazyTarget;
247
+ if (this._validate(item.target)) {
248
+ item.mode = 'eager';
249
+ delete item.lazyTarget;
250
+ // remove from pending
251
+ if (pendingLazy.has(name)) {
252
+ pendingLazy.delete(name);
269
253
  }
270
- else {
271
- item.mode = 'conflicted';
254
+ await this._nextLoad(item);
255
+ // already loaded
256
+ if (uniqueLoaded.has(item.target)) {
257
+ return item;
272
258
  }
273
259
  }
274
- catch (e) {
275
- item.mode = 'failed';
276
- new this.leyyo.developerError(`Callback inert during loading lazy class [${name}]`, (0, function_1.testCase)(internal_1.FQN, 227), where).log(e);
277
- }
278
- // file could not be loaded
279
- if (!item.target) {
280
- return undefined;
260
+ else {
261
+ item.mode = 'conflicted';
281
262
  }
282
- let realName = this._getName(item.target);
283
- if (item.name !== realName) {
284
- if (!realName) {
285
- realName = this._setName(item.target, item.name);
286
- }
287
- if (!realName) {
288
- new this.leyyo.developerError(`Conflict in names [${item.name} vs ${realName}]`, (0, function_1.testCase)(internal_1.FQN, 'ZZZ'), where).log();
289
- }
263
+ }
264
+ catch (e) {
265
+ item.mode = 'failed';
266
+ new this.leyyo.developerError(`Callback inert during loading lazy class [${name}]`, testCase(FQN, 227), where).log(e);
267
+ }
268
+ // file could not be loaded
269
+ if (!item.target) {
270
+ return undefined;
271
+ }
272
+ let realName = this._getName(item.target);
273
+ if (item.name !== realName) {
274
+ if (!realName) {
275
+ realName = this._setName(item.target, item.name);
290
276
  }
291
- if (this._inFqnStage(item)) {
292
- return;
277
+ if (!realName) {
278
+ new this.leyyo.developerError(`Conflict in names [${item.name} vs ${realName}]`, testCase(FQN, 'ZZZ'), where).log();
293
279
  }
294
- item.stage = 'persistent';
295
- this._onFqnCompleted(item);
296
- this._afterTargetFound(item);
297
- return item;
298
- });
280
+ }
281
+ if (this._inFqnStage(item)) {
282
+ return;
283
+ }
284
+ item.stage = 'persistent';
285
+ this._onFqnCompleted(item);
286
+ this._afterTargetFound(item);
287
+ return item;
299
288
  }
300
289
  }
301
- exports.Inert = Inert;
302
- //# sourceMappingURL=inert.js.map
@@ -1,5 +1,5 @@
1
- import { LifecycleCommonLike, LifecycleSortLambda, LifecycleStage } from "./index.types";
2
- import { Fnc, LeyyoLike } from "../base";
1
+ import { LifecycleCommonLike, LifecycleSortLambda, LifecycleStage } from "./index.types.js";
2
+ import { Fnc, LeyyoLike } from "../base/index.js";
3
3
  /**
4
4
  * Lifecycle common interface
5
5
  * */
@@ -1,23 +1,14 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LifecycleCommon = void 0;
13
- const internal_1 = require("../internal");
14
- const function_1 = require("../function");
15
- const where = `${internal_1.FQN}.LifecycleFn`;
1
+ import { FQN } from "../internal.js";
2
+ import { isText, testCase } from "../function/index.js";
3
+ const where = `${FQN}.LifecycleFn`;
16
4
  // noinspection JSUnusedGlobalSymbols
17
5
  /**
18
6
  * Lifecycle common interface
19
7
  * */
20
- class LifecycleCommon {
8
+ export class LifecycleCommon {
9
+ leyyo;
10
+ _stages;
11
+ _sortLambda;
21
12
  /**
22
13
  * Constructor
23
14
  * */
@@ -45,17 +36,17 @@ class LifecycleCommon {
45
36
  }
46
37
  /** @inheritDoc */
47
38
  addStage(stage, name, callback) {
48
- if (!(0, function_1.isText)(stage)) {
49
- throw new this.leyyo.developerError('Invalid lifecycle stage', (0, function_1.testCase)(internal_1.FQN, 100), where);
39
+ if (!isText(stage)) {
40
+ throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 100), where);
50
41
  }
51
42
  if (!this._stages.has(stage)) {
52
- throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 101), where);
43
+ throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 101), where);
53
44
  }
54
- if (!(0, function_1.isText)(name)) {
55
- throw new this.leyyo.developerError(`Invalid lifecycle name [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 102), where);
45
+ if (!isText(name)) {
46
+ throw new this.leyyo.developerError(`Invalid lifecycle name [${stage}]`, testCase(FQN, 102), where);
56
47
  }
57
48
  if (typeof callback !== 'function') {
58
- throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}/${name}]`, (0, function_1.testCase)(internal_1.FQN, 103), where);
49
+ throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}/${name}]`, testCase(FQN, 103), where);
59
50
  }
60
51
  const item = this._stages.get(stage);
61
52
  if (!item.has(name)) {
@@ -64,61 +55,57 @@ class LifecycleCommon {
64
55
  item.get(name).push(callback);
65
56
  }
66
57
  /** @inheritDoc */
67
- runStage(stage, ...params) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- if (!(0, function_1.isText)(stage)) {
70
- throw new this.leyyo.developerError('Invalid lifecycle stage', (0, function_1.testCase)(internal_1.FQN, 104), where);
58
+ async runStage(stage, ...params) {
59
+ if (!isText(stage)) {
60
+ throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 104), where);
61
+ }
62
+ if (!this._stages.has(stage)) {
63
+ throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 105), where);
64
+ }
65
+ let count = 0;
66
+ const item = this._stages.get(stage);
67
+ if (item.size < 1) {
68
+ return count;
69
+ }
70
+ let sorted;
71
+ if (this._sortLambda) {
72
+ try {
73
+ sorted = this._sortLambda(this._stages.get(stage));
71
74
  }
72
- if (!this._stages.has(stage)) {
73
- throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 105), where);
75
+ catch (e) {
76
+ new this.leyyo.developerError(`Callback error during lifecycle order lambda [${stage}]`, testCase(FQN, 106), where).log(e);
74
77
  }
75
- let count = 0;
76
- const item = this._stages.get(stage);
77
- if (item.size < 1) {
78
- return count;
78
+ }
79
+ if (!sorted) {
80
+ sorted = [];
81
+ for (const [name, callbacks] of item.entries()) {
82
+ sorted.push([name, callbacks]);
79
83
  }
80
- let sorted;
81
- if (this._sortLambda) {
84
+ }
85
+ for (const [name, callbacks] of sorted) {
86
+ for (const callback of callbacks) {
82
87
  try {
83
- sorted = this._sortLambda(this._stages.get(stage));
88
+ await callback(...params);
89
+ count++;
84
90
  }
85
91
  catch (e) {
86
- new this.leyyo.developerError(`Callback error during lifecycle order lambda [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 106), where).log(e);
87
- }
88
- }
89
- if (!sorted) {
90
- sorted = [];
91
- for (const [name, callbacks] of item.entries()) {
92
- sorted.push([name, callbacks]);
92
+ new this.leyyo.developerError(`Callback error during lifecycle callback [${stage}/${name}]`, testCase(FQN, 107), where).log(e);
93
93
  }
94
94
  }
95
- for (const [name, callbacks] of sorted) {
96
- for (const callback of callbacks) {
97
- try {
98
- yield callback(...params);
99
- count++;
100
- }
101
- catch (e) {
102
- new this.leyyo.developerError(`Callback error during lifecycle callback [${stage}/${name}]`, (0, function_1.testCase)(internal_1.FQN, 107), where).log(e);
103
- }
104
- }
105
- }
106
- return count;
107
- });
95
+ }
96
+ return count;
108
97
  }
109
98
  /** @inheritDoc */
110
99
  setOrderLambda(stage, lambda) {
111
- if (!(0, function_1.isText)(stage)) {
112
- throw new this.leyyo.developerError('Invalid lifecycle stage', (0, function_1.testCase)(internal_1.FQN, 108), where);
100
+ if (!isText(stage)) {
101
+ throw new this.leyyo.developerError('Invalid lifecycle stage', testCase(FQN, 108), where);
113
102
  }
114
103
  if (!this._stages.has(stage)) {
115
- throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 109), where);
104
+ throw new this.leyyo.developerError(`Lifecycle stage could not be found [${stage}]`, testCase(FQN, 109), where);
116
105
  }
117
106
  if (typeof lambda !== 'function') {
118
- throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}]`, (0, function_1.testCase)(internal_1.FQN, 110), where);
107
+ throw new this.leyyo.developerError(`Invalid lifecycle callback [${stage}]`, testCase(FQN, 110), where);
119
108
  }
120
109
  this._sortLambda = lambda;
121
110
  }
122
111
  }
123
- exports.LifecycleCommon = LifecycleCommon;
124
- //# sourceMappingURL=lifecycle.common.js.map
@@ -1,6 +1,6 @@
1
- import { Inert } from "./inert";
2
- import { Literal, LiteralItemConfig, LiteralPoolItem, LiteralPoolLike, LiteralPoolOpt } from "./index.types";
3
- import { LeyyoLike } from "../base";
1
+ import { Inert } from "./inert.js";
2
+ import { Literal, LiteralItemConfig, LiteralPoolItem, LiteralPoolLike, LiteralPoolOpt } from "./index.types.js";
3
+ import { LeyyoLike } from "../base/index.js";
4
4
  /**
5
5
  * Literal pool for call with name and lazy loading
6
6
  * */
@@ -19,5 +19,8 @@ export declare class LiteralPool extends Inert<LiteralPoolItem, Literal, Literal
19
19
  protected _validate(lit: Literal): boolean;
20
20
  /** @inheritDoc */
21
21
  setConfigItem(lit: Literal, conf: LiteralItemConfig): void;
22
+ /** @inheritDoc */
22
23
  getConfigItem(lit: Literal): LiteralItemConfig;
24
+ /** @inheritDoc */
25
+ define(fqn: string, name: string, target: Literal, opt?: Omit<LiteralPoolOpt, 'name' | 'target' | 'lazyTarget' | 'fqn'>): void;
23
26
  }