@foxford/den 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.mdx +13 -0
- package/adapter.cjs +0 -1
- package/adapter.js +0 -1
- package/bin/den.cjs +27 -32
- package/bin/den.js +27 -32
- package/builder/index.cjs +2 -3
- package/builder/index.d.cts +3 -2
- package/builder/index.d.ts +3 -2
- package/builder/index.js +1 -2
- package/{chunk-IATA5QZ7.cjs → chunk-2PK3VIG2.cjs} +174 -181
- package/{chunk-A2CYL5LY.js → chunk-AE6GKDIG.js} +47 -55
- package/{chunk-7FOG2MJV.js → chunk-HFORUNJV.js} +175 -182
- package/{chunk-QTWJTYZW.cjs → chunk-I42ZL2FS.cjs} +43 -51
- package/{chunk-XQ7EHXHG.js → chunk-TEVB76QF.js} +44 -52
- package/{chunk-HJFBEJT6.cjs → chunk-WS6QCYBR.cjs} +48 -56
- package/define.cjs +0 -1
- package/define.js +0 -1
- package/index.cjs +50 -67
- package/index.js +51 -68
- package/island/index.cjs +3 -6
- package/island/index.js +2 -5
- package/ops/index.cjs +2 -3
- package/ops/index.js +1 -2
- package/package.json +18 -16
- package/serve/index.cjs +257 -270
- package/serve/index.js +254 -267
- package/chunk-6FNC3XMI.js +0 -45
- package/chunk-T5QVCXVB.cjs +0 -45
|
@@ -9,10 +9,6 @@ import {
|
|
|
9
9
|
logger,
|
|
10
10
|
unitLogger
|
|
11
11
|
} from "./chunk-TPBI6TOU.js";
|
|
12
|
-
import {
|
|
13
|
-
__async,
|
|
14
|
-
__spreadValues
|
|
15
|
-
} from "./chunk-6FNC3XMI.js";
|
|
16
12
|
|
|
17
13
|
// src/island/document.ts
|
|
18
14
|
function isDocumentSource(value) {
|
|
@@ -160,18 +156,16 @@ function hydrateIslandState(container, descriptor, denState) {
|
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
|
-
function activateIslandViewModels(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
);
|
|
174
|
-
});
|
|
159
|
+
async function activateIslandViewModels(container, descriptor, route = EMPTY_ROUTE) {
|
|
160
|
+
var _a;
|
|
161
|
+
await Promise.all(
|
|
162
|
+
((_a = descriptor.viewModels) != null ? _a : []).map(async (vm) => {
|
|
163
|
+
var _a2;
|
|
164
|
+
const instance = container.resolve(vm.token);
|
|
165
|
+
unitLogger(container, vm.token.description).debug(`\u0430\u043A\u0442\u0438\u0432\u0430\u0446\u0438\u044F VM (${route.pathname || "\u2014"})`);
|
|
166
|
+
await ((_a2 = instance.activate) == null ? void 0 : _a2.call(instance, route));
|
|
167
|
+
})
|
|
168
|
+
);
|
|
175
169
|
}
|
|
176
170
|
function collectIslandState(container, descriptor) {
|
|
177
171
|
var _a, _b;
|
|
@@ -194,10 +188,10 @@ function collectDocumentContribution(container, descriptor) {
|
|
|
194
188
|
}
|
|
195
189
|
const part = instance.describeDocument();
|
|
196
190
|
if (part.head) {
|
|
197
|
-
contribution.head =
|
|
191
|
+
contribution.head = { ...contribution.head, ...part.head };
|
|
198
192
|
}
|
|
199
193
|
if (part.data) {
|
|
200
|
-
contribution.data =
|
|
194
|
+
contribution.data = { ...contribution.data, ...part.data };
|
|
201
195
|
}
|
|
202
196
|
if (part.assets && contribution.assets === void 0) {
|
|
203
197
|
contribution.assets = part.assets;
|
|
@@ -238,41 +232,39 @@ function setupOnce(descriptor) {
|
|
|
238
232
|
}
|
|
239
233
|
return started;
|
|
240
234
|
}
|
|
241
|
-
function renderApp(descriptor, request) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
235
|
+
async function renderApp(descriptor, request) {
|
|
236
|
+
var _a, _b, _c;
|
|
237
|
+
await setupOnce(descriptor);
|
|
238
|
+
const route = {
|
|
239
|
+
params: (_a = request.params) != null ? _a : {},
|
|
240
|
+
pathname: request.pathname,
|
|
241
|
+
search: (_b = request.search) != null ? _b : ""
|
|
242
|
+
};
|
|
243
|
+
const inputs = islandInputsOf(descriptor, request.inputs);
|
|
244
|
+
const container = createIslandContainer(descriptor, { context: request.context, inputs, parent: request.parent });
|
|
245
|
+
if (container === null) {
|
|
246
|
+
throw new Error(`den/island: \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${descriptor.name}\xBB \u043D\u0435 \u0441\u043E\u0431\u0440\u0430\u043B\u043E\u0441\u044C \u2014 \u0440\u0435\u043D\u0434\u0435\u0440 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D`);
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
await activateIslandViewModels(container, descriptor, route);
|
|
250
|
+
const contribution = collectDocumentContribution(container, descriptor);
|
|
251
|
+
const { data, head, redirect, status = STATUS_OK } = contribution;
|
|
252
|
+
if (status !== STATUS_OK) {
|
|
253
|
+
return { data, head, html: "", redirect, state: {}, status };
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (status !== STATUS_OK) {
|
|
260
|
-
return { data, head, html: "", redirect, state: {}, status };
|
|
261
|
-
}
|
|
262
|
-
const assets = (_c = contribution.assets) != null ? _c : descriptor.assets;
|
|
263
|
-
const state = __spreadValues(__spreadValues({}, inputs), collectIslandState(container, descriptor));
|
|
264
|
-
if (descriptor.view === void 0 || descriptor.viewLayer === void 0) {
|
|
265
|
-
return { assets, data, head, html: "", state, status };
|
|
266
|
-
}
|
|
267
|
-
const rendered = resolveViewAdapter(container).renderIsland(descriptor, {
|
|
268
|
-
container,
|
|
269
|
-
slots: request.slots
|
|
270
|
-
});
|
|
271
|
-
return { assets, data, head, headHtml: rendered.head, html: rendered.html, state, status };
|
|
272
|
-
} finally {
|
|
273
|
-
yield container.dispose();
|
|
255
|
+
const assets = (_c = contribution.assets) != null ? _c : descriptor.assets;
|
|
256
|
+
const state = { ...inputs, ...collectIslandState(container, descriptor) };
|
|
257
|
+
if (descriptor.view === void 0 || descriptor.viewLayer === void 0) {
|
|
258
|
+
return { assets, data, head, html: "", state, status };
|
|
274
259
|
}
|
|
275
|
-
|
|
260
|
+
const rendered = resolveViewAdapter(container).renderIsland(descriptor, {
|
|
261
|
+
container,
|
|
262
|
+
slots: request.slots
|
|
263
|
+
});
|
|
264
|
+
return { assets, data, head, headHtml: rendered.head, html: rendered.html, state, status };
|
|
265
|
+
} finally {
|
|
266
|
+
await container.dispose();
|
|
267
|
+
}
|
|
276
268
|
}
|
|
277
269
|
|
|
278
270
|
// src/island/routes.ts
|
|
@@ -296,7 +288,7 @@ function decodeParams(groups) {
|
|
|
296
288
|
}
|
|
297
289
|
try {
|
|
298
290
|
params[name] = decodeURIComponent(value);
|
|
299
|
-
} catch
|
|
291
|
+
} catch {
|
|
300
292
|
params[name] = value;
|
|
301
293
|
}
|
|
302
294
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var _chunkT5QVCXVBcjs = require('./chunk-T5QVCXVB.cjs');
|
|
4
|
-
|
|
5
|
-
// src/ops/index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/ops/index.ts
|
|
6
2
|
var _http = require('http');
|
|
7
3
|
var _client = require('@prometheus-io/client');
|
|
8
4
|
|
|
@@ -169,64 +165,60 @@ function clusterMetrics(metrics = getProcessMetrics()) {
|
|
|
169
165
|
shutdown: () => lifecycle.shutdown()
|
|
170
166
|
};
|
|
171
167
|
}
|
|
172
|
-
function startOpsServer() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
168
|
+
async function startOpsServer(options = {}) {
|
|
169
|
+
var _a;
|
|
170
|
+
const metrics = (_a = options.metrics) != null ? _a : getProcessMetrics();
|
|
171
|
+
const server = _http.createServer.call(void 0, (req, res) => {
|
|
172
|
+
var _a2, _b, _c, _d;
|
|
173
|
+
const path = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0];
|
|
174
|
+
res.setHeader("cache-control", "no-store");
|
|
175
|
+
if (req.method !== "GET" || !["/healthz", "/livez", "/metrics"].includes(path != null ? path : "")) {
|
|
176
|
+
res.writeHead(404).end();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (path !== "/metrics") {
|
|
180
|
+
res.writeHead(path === "/livez" && ((_b = options.isLive) == null ? void 0 : _b.call(options)) === false ? 503 : 200, {
|
|
181
|
+
"content-type": "text/plain; charset=utf-8"
|
|
182
|
+
}).end("ok");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
|
|
186
|
+
var _a3;
|
|
187
|
+
if (!res.destroyed) {
|
|
188
|
+
res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
|
|
183
189
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}).end("ok");
|
|
188
|
-
return;
|
|
190
|
+
}).catch(() => {
|
|
191
|
+
if (!res.destroyed) {
|
|
192
|
+
res.writeHead(503).end("metrics unavailable");
|
|
189
193
|
}
|
|
190
|
-
void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
|
|
191
|
-
var _a3;
|
|
192
|
-
if (!res.destroyed) {
|
|
193
|
-
res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
|
|
194
|
-
}
|
|
195
|
-
}).catch(() => {
|
|
196
|
-
if (!res.destroyed) {
|
|
197
|
-
res.writeHead(503).end("metrics unavailable");
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
194
|
});
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
195
|
+
});
|
|
196
|
+
await new Promise((resolve, reject) => {
|
|
197
|
+
var _a2, _b;
|
|
198
|
+
server.once("error", reject);
|
|
199
|
+
server.listen((_a2 = options.port) != null ? _a2 : 9090, (_b = options.host) != null ? _b : "0.0.0.0", () => {
|
|
200
|
+
server.removeListener("error", reject);
|
|
201
|
+
resolve();
|
|
208
202
|
});
|
|
209
|
-
return server;
|
|
210
203
|
});
|
|
204
|
+
return server;
|
|
211
205
|
}
|
|
212
|
-
function closeHttpServer(server, timeoutMs = 5e3) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
server.closeIdleConnections();
|
|
206
|
+
async function closeHttpServer(server, timeoutMs = 5e3) {
|
|
207
|
+
if (!server.listening) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
await new Promise((resolve, reject) => {
|
|
211
|
+
const timer = setTimeout(() => server.closeAllConnections(), timeoutMs);
|
|
212
|
+
timer.unref();
|
|
213
|
+
server.close((error) => {
|
|
214
|
+
clearTimeout(timer);
|
|
215
|
+
if (error) {
|
|
216
|
+
reject(error);
|
|
217
|
+
} else {
|
|
218
|
+
resolve();
|
|
219
|
+
}
|
|
229
220
|
});
|
|
221
|
+
server.closeIdleConnections();
|
|
230
222
|
});
|
|
231
223
|
}
|
|
232
224
|
|
package/define.cjs
CHANGED
package/define.js
CHANGED
package/index.cjs
CHANGED
|
@@ -21,9 +21,6 @@ var _chunkXOJ2VWX4cjs = require('./chunk-XOJ2VWX4.cjs');
|
|
|
21
21
|
var _chunk6QV4L6R2cjs = require('./chunk-6QV4L6R2.cjs');
|
|
22
22
|
require('./chunk-A6ZPAM6Z.cjs');
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
var _chunkT5QVCXVBcjs = require('./chunk-T5QVCXVB.cjs');
|
|
26
|
-
|
|
27
24
|
// src/core/state-registry.ts
|
|
28
25
|
var StateRegistry = class {
|
|
29
26
|
constructor() {
|
|
@@ -94,15 +91,13 @@ var ContainerManagerImpl = class {
|
|
|
94
91
|
* Если контейнер не найден — no-op.
|
|
95
92
|
* @param routeId - Идентификатор маршрута
|
|
96
93
|
*/
|
|
97
|
-
destroyPageContainer(routeId) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
yield container.dispose();
|
|
105
|
-
});
|
|
94
|
+
async destroyPageContainer(routeId) {
|
|
95
|
+
const container = this.pageContainers.get(routeId);
|
|
96
|
+
if (container === void 0) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.pageContainers.delete(routeId);
|
|
100
|
+
await container.dispose();
|
|
106
101
|
}
|
|
107
102
|
/**
|
|
108
103
|
* Создаёт дочерний контейнер для HTTP-запроса с забинженным RequestContext.
|
|
@@ -133,15 +128,13 @@ var ContainerManagerImpl = class {
|
|
|
133
128
|
* Если контейнер не найден — no-op.
|
|
134
129
|
* @param requestId - Уникальный идентификатор запроса
|
|
135
130
|
*/
|
|
136
|
-
destroyRequestContainer(requestId) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
yield container.dispose();
|
|
144
|
-
});
|
|
131
|
+
async destroyRequestContainer(requestId) {
|
|
132
|
+
const container = this.requestContainers.get(requestId);
|
|
133
|
+
if (container === void 0) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.requestContainers.delete(requestId);
|
|
137
|
+
await container.dispose();
|
|
145
138
|
}
|
|
146
139
|
/**
|
|
147
140
|
* Создаёт page container для SSR как дочерний от заданного родителя.
|
|
@@ -166,15 +159,13 @@ var ContainerManagerImpl = class {
|
|
|
166
159
|
* Если контейнер не найден — no-op.
|
|
167
160
|
* @param requestId - Уникальный идентификатор запроса
|
|
168
161
|
*/
|
|
169
|
-
destroySsrPageContainer(requestId) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
yield container.dispose();
|
|
177
|
-
});
|
|
162
|
+
async destroySsrPageContainer(requestId) {
|
|
163
|
+
const container = this.ssrPageContainers.get(requestId);
|
|
164
|
+
if (container === void 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.ssrPageContainers.delete(requestId);
|
|
168
|
+
await container.dispose();
|
|
178
169
|
}
|
|
179
170
|
};
|
|
180
171
|
|
|
@@ -194,17 +185,15 @@ var GuardRunnerImpl = class {
|
|
|
194
185
|
* @param params - Параметры маршрута
|
|
195
186
|
* @param container - Опциональный контейнер для резолвинга guards
|
|
196
187
|
*/
|
|
197
|
-
runGuards(tokens, params, container) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return results;
|
|
207
|
-
});
|
|
188
|
+
async runGuards(tokens, params, container) {
|
|
189
|
+
const resolveFrom = container != null ? container : this.container;
|
|
190
|
+
const results = await Promise.all(
|
|
191
|
+
tokens.map(async (token) => {
|
|
192
|
+
const guard = await resolveFrom.resolve(token);
|
|
193
|
+
return guard.check(params);
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
return results;
|
|
208
197
|
}
|
|
209
198
|
};
|
|
210
199
|
|
|
@@ -286,12 +275,10 @@ var NavigationManagerImpl = class {
|
|
|
286
275
|
* Проверяет актуальность текущего состояния.
|
|
287
276
|
* Состояние считается актуальным если история и текущий элемент согласованы.
|
|
288
277
|
*/
|
|
289
|
-
checkFreshness() {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return lastEntry === this.current;
|
|
294
|
-
});
|
|
278
|
+
async checkFreshness() {
|
|
279
|
+
var _a;
|
|
280
|
+
const lastEntry = (_a = this._history.at(-1)) != null ? _a : null;
|
|
281
|
+
return lastEntry === this.current;
|
|
295
282
|
}
|
|
296
283
|
/**
|
|
297
284
|
* Регистрирует interceptor для перехвата навигации (leave guard).
|
|
@@ -316,16 +303,14 @@ var NavigationManagerImpl = class {
|
|
|
316
303
|
* @param to - Маршрут назначения
|
|
317
304
|
* @returns Результат проверки
|
|
318
305
|
*/
|
|
319
|
-
runLeaveGuards(from, to) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return { allow: false, reason: result.reason };
|
|
325
|
-
}
|
|
306
|
+
async runLeaveGuards(from, to) {
|
|
307
|
+
for (const interceptor of this.interceptors) {
|
|
308
|
+
const result = await interceptor.beforeNavigate(from, to);
|
|
309
|
+
if (!result.allow) {
|
|
310
|
+
return { allow: false, reason: result.reason };
|
|
326
311
|
}
|
|
327
|
-
|
|
328
|
-
}
|
|
312
|
+
}
|
|
313
|
+
return { allow: true };
|
|
329
314
|
}
|
|
330
315
|
/**
|
|
331
316
|
* Инициализирует обработчики браузерных событий навигации.
|
|
@@ -462,17 +447,15 @@ var StateSerializerImpl = class {
|
|
|
462
447
|
* @param container - Контейнер, участники которого активируются
|
|
463
448
|
* @param params - Параметры маршрута
|
|
464
449
|
*/
|
|
465
|
-
activateAll(container, params) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}));
|
|
475
|
-
});
|
|
450
|
+
async activateAll(container, params) {
|
|
451
|
+
const registry = this.getRegistry(container);
|
|
452
|
+
if (registry === void 0) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
await Promise.all([...registry.all().values()].map((participant) => {
|
|
456
|
+
var _a;
|
|
457
|
+
return (_a = participant.activate) == null ? void 0 : _a.call(participant, params);
|
|
458
|
+
}));
|
|
476
459
|
}
|
|
477
460
|
};
|
|
478
461
|
|
package/index.js
CHANGED
|
@@ -20,9 +20,6 @@ import {
|
|
|
20
20
|
StateSerializerToken
|
|
21
21
|
} from "./chunk-3RX2OSUL.js";
|
|
22
22
|
import "./chunk-TPBI6TOU.js";
|
|
23
|
-
import {
|
|
24
|
-
__async
|
|
25
|
-
} from "./chunk-6FNC3XMI.js";
|
|
26
23
|
|
|
27
24
|
// src/core/state-registry.ts
|
|
28
25
|
var StateRegistry = class {
|
|
@@ -94,15 +91,13 @@ var ContainerManagerImpl = class {
|
|
|
94
91
|
* Если контейнер не найден — no-op.
|
|
95
92
|
* @param routeId - Идентификатор маршрута
|
|
96
93
|
*/
|
|
97
|
-
destroyPageContainer(routeId) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
yield container.dispose();
|
|
105
|
-
});
|
|
94
|
+
async destroyPageContainer(routeId) {
|
|
95
|
+
const container = this.pageContainers.get(routeId);
|
|
96
|
+
if (container === void 0) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.pageContainers.delete(routeId);
|
|
100
|
+
await container.dispose();
|
|
106
101
|
}
|
|
107
102
|
/**
|
|
108
103
|
* Создаёт дочерний контейнер для HTTP-запроса с забинженным RequestContext.
|
|
@@ -133,15 +128,13 @@ var ContainerManagerImpl = class {
|
|
|
133
128
|
* Если контейнер не найден — no-op.
|
|
134
129
|
* @param requestId - Уникальный идентификатор запроса
|
|
135
130
|
*/
|
|
136
|
-
destroyRequestContainer(requestId) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
yield container.dispose();
|
|
144
|
-
});
|
|
131
|
+
async destroyRequestContainer(requestId) {
|
|
132
|
+
const container = this.requestContainers.get(requestId);
|
|
133
|
+
if (container === void 0) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.requestContainers.delete(requestId);
|
|
137
|
+
await container.dispose();
|
|
145
138
|
}
|
|
146
139
|
/**
|
|
147
140
|
* Создаёт page container для SSR как дочерний от заданного родителя.
|
|
@@ -166,15 +159,13 @@ var ContainerManagerImpl = class {
|
|
|
166
159
|
* Если контейнер не найден — no-op.
|
|
167
160
|
* @param requestId - Уникальный идентификатор запроса
|
|
168
161
|
*/
|
|
169
|
-
destroySsrPageContainer(requestId) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
yield container.dispose();
|
|
177
|
-
});
|
|
162
|
+
async destroySsrPageContainer(requestId) {
|
|
163
|
+
const container = this.ssrPageContainers.get(requestId);
|
|
164
|
+
if (container === void 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.ssrPageContainers.delete(requestId);
|
|
168
|
+
await container.dispose();
|
|
178
169
|
}
|
|
179
170
|
};
|
|
180
171
|
|
|
@@ -194,17 +185,15 @@ var GuardRunnerImpl = class {
|
|
|
194
185
|
* @param params - Параметры маршрута
|
|
195
186
|
* @param container - Опциональный контейнер для резолвинга guards
|
|
196
187
|
*/
|
|
197
|
-
runGuards(tokens, params, container) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return results;
|
|
207
|
-
});
|
|
188
|
+
async runGuards(tokens, params, container) {
|
|
189
|
+
const resolveFrom = container != null ? container : this.container;
|
|
190
|
+
const results = await Promise.all(
|
|
191
|
+
tokens.map(async (token) => {
|
|
192
|
+
const guard = await resolveFrom.resolve(token);
|
|
193
|
+
return guard.check(params);
|
|
194
|
+
})
|
|
195
|
+
);
|
|
196
|
+
return results;
|
|
208
197
|
}
|
|
209
198
|
};
|
|
210
199
|
|
|
@@ -286,12 +275,10 @@ var NavigationManagerImpl = class {
|
|
|
286
275
|
* Проверяет актуальность текущего состояния.
|
|
287
276
|
* Состояние считается актуальным если история и текущий элемент согласованы.
|
|
288
277
|
*/
|
|
289
|
-
checkFreshness() {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
return lastEntry === this.current;
|
|
294
|
-
});
|
|
278
|
+
async checkFreshness() {
|
|
279
|
+
var _a;
|
|
280
|
+
const lastEntry = (_a = this._history.at(-1)) != null ? _a : null;
|
|
281
|
+
return lastEntry === this.current;
|
|
295
282
|
}
|
|
296
283
|
/**
|
|
297
284
|
* Регистрирует interceptor для перехвата навигации (leave guard).
|
|
@@ -316,16 +303,14 @@ var NavigationManagerImpl = class {
|
|
|
316
303
|
* @param to - Маршрут назначения
|
|
317
304
|
* @returns Результат проверки
|
|
318
305
|
*/
|
|
319
|
-
runLeaveGuards(from, to) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return { allow: false, reason: result.reason };
|
|
325
|
-
}
|
|
306
|
+
async runLeaveGuards(from, to) {
|
|
307
|
+
for (const interceptor of this.interceptors) {
|
|
308
|
+
const result = await interceptor.beforeNavigate(from, to);
|
|
309
|
+
if (!result.allow) {
|
|
310
|
+
return { allow: false, reason: result.reason };
|
|
326
311
|
}
|
|
327
|
-
|
|
328
|
-
}
|
|
312
|
+
}
|
|
313
|
+
return { allow: true };
|
|
329
314
|
}
|
|
330
315
|
/**
|
|
331
316
|
* Инициализирует обработчики браузерных событий навигации.
|
|
@@ -378,7 +363,7 @@ var NavigationManagerImpl = class {
|
|
|
378
363
|
let url;
|
|
379
364
|
try {
|
|
380
365
|
url = new URL(href);
|
|
381
|
-
} catch
|
|
366
|
+
} catch {
|
|
382
367
|
return;
|
|
383
368
|
}
|
|
384
369
|
if (url.origin !== window.location.origin) return;
|
|
@@ -462,17 +447,15 @@ var StateSerializerImpl = class {
|
|
|
462
447
|
* @param container - Контейнер, участники которого активируются
|
|
463
448
|
* @param params - Параметры маршрута
|
|
464
449
|
*/
|
|
465
|
-
activateAll(container, params) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}));
|
|
475
|
-
});
|
|
450
|
+
async activateAll(container, params) {
|
|
451
|
+
const registry = this.getRegistry(container);
|
|
452
|
+
if (registry === void 0) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
await Promise.all([...registry.all().values()].map((participant) => {
|
|
456
|
+
var _a;
|
|
457
|
+
return (_a = participant.activate) == null ? void 0 : _a.call(participant, params);
|
|
458
|
+
}));
|
|
476
459
|
}
|
|
477
460
|
};
|
|
478
461
|
|