-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.mjs
187 lines (125 loc) · 2.96 KB
/
module.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
//#region YI
/** @type {import('./config.mjs')['default']?} */
let config = null;
await import('./config.mjs')
.then(c => config = c.default)
.catch(e => e);
/** @type {import('./error.mjs')['default']?} */
let error = null;
await import('./error.mjs')
.then(i => error = i.default)
.catch(e => e);
//#endregion
//#region YT
/** ### YT
* - Тип `T`
* - Версия `0.0.0`
* - Модуль `module.mjs`
*
* Основной параметр модуля `Y`.
*
* @typedef YT
* @prop {YTT} Y
*
*/
/** ### YTT
* - Тип `TT`
* - Версия `0.0.0`
* - Модуль `module.mjs`
*
*
*
* @typedef {import('./class.mjs')['Y']} YTT
*
*/
//#endregion
//#region YV
//#endregion
//#region load 0.0.0
/** ### YTFLoad
* - Тип `TF`
* - Версия `0.0.0`
* - Модуль `module.mjs`
* ***
*
* Результирующие параметры функции `load`.
*
* @typedef {YTFULoad&YT} YTFLoad
*
*/
/** ### YTFULoad
* - Тип `TFU`
* - Версия `0.0.0`
* - Модуль `module.mjs`
*
* Уникальные параметры функции `load`.
*
* @typedef YTFULoad
* @prop {any} _
*/
/** @arg {YTFLoad} t */
async function loadDeceit(t) {
try {
return loadVerify(t);
} catch (e) {
if (config?.strict) {
throw e;
};
return undefined;
} finally {
};
};
/** @arg {YTFLoad} t */
async function loadVerify(t) {
const {
} = t;
return loadHandle(t);
};
/** @arg {YTFLoad} t */
async function loadHandle(t) {
const {
} = t;
return loadComply(t);
};
/** @arg {YTFLoad} t */
async function loadComply(t) {
const {
Y,
} = t;
if (Y) {
for (const module of Object.entries(config.modules)) {
if (module[1].load) {
module[0] = module[0][0].toUpperCase() + module[0].slice(1);
if (Y.hasOwnProperty(`Y${module[0]}`) && !Y[`Y${module[0]}`]) {
Y[`Y${module[0]}`] = (await import(`${module[1].path}class.mjs`))[`Y${module[0]}`];
};
if (Y.hasOwnProperty([`module${module[0]}`]) && !Y[`module${module[0]}`]) {
Y[`module${module[0]}`] = await import(`${module[1].path}module.mjs`);
};
};
};
};
return Y;
};
/**
* ### YLoad
* - Версия `0.0.0`
* - Цепочка `DVHCa`
* - Модуль `module.mjs`
* ***
*
* Внутренняя функция для загрузки модулей в `Y`.
*
* ***
* @arg {YTT} Y `Y`
* @protected
*/
export async function YLoad(Y) {
return loadDeceit({ Y });
};
//#endregion
/**
* @file module.mjs
* @author Yakhin Nikita Artemovich <mr.y.nikita@gmail.com>
* @copyright Yakhin Nikita Artemovich 2023
*/