@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.
@@ -4,11 +4,6 @@ import {
4
4
  import {
5
5
  logger
6
6
  } from "./chunk-TPBI6TOU.js";
7
- import {
8
- __async,
9
- __spreadProps,
10
- __spreadValues
11
- } from "./chunk-6FNC3XMI.js";
12
7
 
13
8
  // src/builder/config.ts
14
9
  function defineAppConfig(config) {
@@ -191,32 +186,30 @@ var OUT_ROOT = "build";
191
186
  var OUT_CLIENT = "build/client";
192
187
  var OUT_SERVER = "build/server";
193
188
  var ENGINE = /^@foxford\/den(\/|$)/;
194
- function loadAppConfig(root) {
195
- return __async(this, null, function* () {
196
- const configPath = path2.join(root, CONFIG_FILE);
197
- if (!fs2.existsSync(configPath)) {
198
- throw new Error(`den: ${CONFIG_FILE} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 \xAB${root}\xBB`);
199
- }
200
- const { createServer } = yield import("vite");
201
- const server = yield createServer({
202
- appType: "custom",
203
- configFile: false,
204
- logLevel: "silent",
205
- root,
206
- // Этот сервер только загружает конфиг; пересборкой в dev управляет watchSources.
207
- server: { middlewareMode: true, watch: null }
208
- });
209
- try {
210
- const loaded = yield server.ssrLoadModule(configPath);
211
- const config = loaded.default;
212
- if (!config) {
213
- throw new Error(`den: ${CONFIG_FILE} \u043D\u0435 \u043E\u0442\u0434\u0430\u0451\u0442 \u043A\u043E\u043D\u0444\u0438\u0433 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u2014 \u0441\u043E\u0431\u0438\u0440\u0430\u0442\u044C \u043D\u0435\u0447\u0435\u043C`);
214
- }
215
- return { config, configPath };
216
- } finally {
217
- yield server.close();
218
- }
189
+ async function loadAppConfig(root) {
190
+ const configPath = path2.join(root, CONFIG_FILE);
191
+ if (!fs2.existsSync(configPath)) {
192
+ throw new Error(`den: ${CONFIG_FILE} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 \xAB${root}\xBB`);
193
+ }
194
+ const { createServer } = await import("vite");
195
+ const server = await createServer({
196
+ appType: "custom",
197
+ configFile: false,
198
+ logLevel: "silent",
199
+ root,
200
+ // Этот сервер только загружает конфиг; пересборкой в dev управляет watchSources.
201
+ server: { middlewareMode: true, watch: null }
219
202
  });
203
+ try {
204
+ const loaded = await server.ssrLoadModule(configPath);
205
+ const config = loaded.default;
206
+ if (!config) {
207
+ throw new Error(`den: ${CONFIG_FILE} \u043D\u0435 \u043E\u0442\u0434\u0430\u0451\u0442 \u043A\u043E\u043D\u0444\u0438\u0433 \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F \u2014 \u0441\u043E\u0431\u0438\u0440\u0430\u0442\u044C \u043D\u0435\u0447\u0435\u043C`);
208
+ }
209
+ return { config, configPath };
210
+ } finally {
211
+ await server.close();
212
+ }
220
213
  }
221
214
  function dependenciesOf(root) {
222
215
  var _a, _b;
@@ -227,8 +220,9 @@ function dependenciesOf(root) {
227
220
  const manifest = JSON.parse(fs2.readFileSync(manifestPath, "utf-8"));
228
221
  return [...Object.keys((_a = manifest.dependencies) != null ? _a : {}), ...Object.keys((_b = manifest.devDependencies) != null ? _b : {})];
229
222
  }
230
- function viteConfigFor(options) {
223
+ async function viteConfigFor(options) {
231
224
  var _a, _b, _c, _d, _e, _f, _g;
225
+ const { foxfordBrowserBuild } = await import("@foxford/browserslist-config/vite");
232
226
  const { assets, base, config, configPath, entryFileNames, input, mode, outDir, root, target } = options;
233
227
  const entry = (_a = config.entry) != null ? _a : "src/index.ts";
234
228
  const external = (_c = (_b = config.server) == null ? void 0 : _b.external) != null ? _c : [];
@@ -244,9 +238,11 @@ function viteConfigFor(options) {
244
238
  outDir: path2.join(root, outDir),
245
239
  // Вход задаётся `input`, а не `build.ssr`: строку в `build.ssr` сборщик понимает как путь
246
240
  // к файлу, а входы у нас виртуальные — их резолвит плагин
247
- rollupOptions: __spreadValues(__spreadValues({
248
- input
249
- }, target === "server" ? { external: [ENGINE, ...external] } : {}), entryFileNames === void 0 ? {} : { output: { entryFileNames } }),
241
+ rollupOptions: {
242
+ input,
243
+ ...target === "server" ? { external: [ENGINE, ...external] } : {},
244
+ ...entryFileNames === void 0 ? {} : { output: { entryFileNames } }
245
+ },
250
246
  ssr: target === "server"
251
247
  },
252
248
  configFile: false,
@@ -263,59 +259,63 @@ function viteConfigFor(options) {
263
259
  noExternal: (_g = (_f = config.server) == null ? void 0 : _f.noExternal) != null ? _g : []
264
260
  }
265
261
  };
266
- return config.vite ? config.vite(composed, target) : composed;
262
+ const customized = config.vite ? config.vite(composed, target) : composed;
263
+ return {
264
+ ...customized,
265
+ plugins: [customized["plugins"], foxfordBrowserBuild({ env: mode })]
266
+ };
267
267
  }
268
- function buildApp(options) {
269
- return __async(this, null, function* () {
270
- var _a, _b, _c;
271
- const { mode = "production" } = options;
272
- process.env["NODE_ENV"] = mode;
273
- const root = path2.resolve(options.root);
274
- loadAppEnv(root);
275
- const { config, configPath } = yield loadAppConfig(root);
276
- const port = resolvePort((_a = config.server) == null ? void 0 : _a.port);
277
- const base = (_b = options.base) != null ? _b : "";
278
- const { preset } = config;
279
- const refusal = (_c = preset == null ? void 0 : preset.validate) == null ? void 0 : _c.call(preset, dependenciesOf(root));
280
- if (refusal !== void 0 && refusal !== null) {
281
- throw new Error(`den: ${refusal}`);
282
- }
283
- const { build } = yield import("vite");
284
- const shared = { base, config, configPath, mode, root };
285
- const empty = { css: [], js: [] };
286
- let assets = empty;
287
- if (preset) {
288
- logger.info(`\u0441\u0431\u043E\u0440\u043A\u0430 \u043A\u043B\u0438\u0435\u043D\u0442\u0441\u043A\u043E\u0433\u043E \u0432\u044B\u0445\u043E\u0434\u0430 (${preset.view})`);
289
- yield build(
290
- viteConfigFor(__spreadProps(__spreadValues({}, shared), { assets: empty, input: VIRTUAL_CLIENT, outDir: OUT_CLIENT, target: "client" }))
291
- );
292
- assets = collectAssets(path2.join(root, OUT_CLIENT), base);
293
- logger.info(`\u0430\u0440\u0442\u0435\u0444\u0430\u043A\u0442\u044B: ${String(assets.js.length)} js, ${String(assets.css.length)} css`);
294
- } else {
295
- logger.info("\u043A\u043B\u0438\u0435\u043D\u0442\u0441\u043A\u043E\u0433\u043E \u0432\u044B\u0445\u043E\u0434\u0430 \u043D\u0435\u0442: \u043F\u0440\u0435\u0441\u0435\u0442 \u043D\u0435 \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D, \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0441\u0432\u043E\u0435\u0433\u043E \u0444\u0440\u0430\u0433\u043C\u0435\u043D\u0442\u0430 \u043D\u0435 \u0440\u0438\u0441\u0443\u0435\u0442");
296
- }
297
- logger.info("\u0441\u0431\u043E\u0440\u043A\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043D\u043E\u0433\u043E \u0434\u0435\u0441\u043A\u0440\u0438\u043F\u0442\u043E\u0440\u0430");
298
- yield build(
299
- viteConfigFor(__spreadProps(__spreadValues({}, shared), {
300
- assets,
301
- entryFileNames: "index.mjs",
302
- input: VIRTUAL_SERVER_APP,
303
- outDir: OUT_SERVER,
304
- target: "server"
305
- }))
306
- );
307
- logger.info("\u0441\u0431\u043E\u0440\u043A\u0430 \u0442\u043E\u0447\u043A\u0438 \u0432\u0445\u043E\u0434\u0430 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0430");
308
- yield build(
309
- viteConfigFor(__spreadProps(__spreadValues({}, shared), {
310
- assets,
311
- entryFileNames: "server.mjs",
312
- input: VIRTUAL_SERVER_PROCESS,
313
- outDir: OUT_ROOT,
314
- target: "server"
315
- }))
268
+ async function buildApp(options) {
269
+ var _a, _b, _c;
270
+ const { mode = "production" } = options;
271
+ process.env["NODE_ENV"] = mode;
272
+ const root = path2.resolve(options.root);
273
+ loadAppEnv(root);
274
+ const { config, configPath } = await loadAppConfig(root);
275
+ const port = resolvePort((_a = config.server) == null ? void 0 : _a.port);
276
+ const base = (_b = options.base) != null ? _b : "";
277
+ const { preset } = config;
278
+ const refusal = (_c = preset == null ? void 0 : preset.validate) == null ? void 0 : _c.call(preset, dependenciesOf(root));
279
+ if (refusal !== void 0 && refusal !== null) {
280
+ throw new Error(`den: ${refusal}`);
281
+ }
282
+ const { build } = await import("vite");
283
+ const shared = { base, config, configPath, mode, root };
284
+ const empty = { css: [], js: [] };
285
+ let assets = empty;
286
+ if (preset) {
287
+ logger.info(`\u0441\u0431\u043E\u0440\u043A\u0430 \u043A\u043B\u0438\u0435\u043D\u0442\u0441\u043A\u043E\u0433\u043E \u0432\u044B\u0445\u043E\u0434\u0430 (${preset.view})`);
288
+ await build(
289
+ await viteConfigFor({ ...shared, assets: empty, input: VIRTUAL_CLIENT, outDir: OUT_CLIENT, target: "client" })
316
290
  );
317
- return { base, port };
318
- });
291
+ assets = collectAssets(path2.join(root, OUT_CLIENT), base);
292
+ logger.info(`\u0430\u0440\u0442\u0435\u0444\u0430\u043A\u0442\u044B: ${String(assets.js.length)} js, ${String(assets.css.length)} css`);
293
+ } else {
294
+ logger.info("\u043A\u043B\u0438\u0435\u043D\u0442\u0441\u043A\u043E\u0433\u043E \u0432\u044B\u0445\u043E\u0434\u0430 \u043D\u0435\u0442: \u043F\u0440\u0435\u0441\u0435\u0442 \u043D\u0435 \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D, \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \u0441\u0432\u043E\u0435\u0433\u043E \u0444\u0440\u0430\u0433\u043C\u0435\u043D\u0442\u0430 \u043D\u0435 \u0440\u0438\u0441\u0443\u0435\u0442");
295
+ }
296
+ logger.info("\u0441\u0431\u043E\u0440\u043A\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043D\u043E\u0433\u043E \u0434\u0435\u0441\u043A\u0440\u0438\u043F\u0442\u043E\u0440\u0430");
297
+ await build(
298
+ await viteConfigFor({
299
+ ...shared,
300
+ assets,
301
+ entryFileNames: "index.mjs",
302
+ input: VIRTUAL_SERVER_APP,
303
+ outDir: OUT_SERVER,
304
+ target: "server"
305
+ })
306
+ );
307
+ logger.info("\u0441\u0431\u043E\u0440\u043A\u0430 \u0442\u043E\u0447\u043A\u0438 \u0432\u0445\u043E\u0434\u0430 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0430");
308
+ await build(
309
+ await viteConfigFor({
310
+ ...shared,
311
+ assets,
312
+ entryFileNames: "server.mjs",
313
+ input: VIRTUAL_SERVER_PROCESS,
314
+ outDir: OUT_ROOT,
315
+ target: "server"
316
+ })
317
+ );
318
+ return { base, port };
319
319
  }
320
320
 
321
321
  // src/builder/dev.ts
@@ -384,33 +384,31 @@ var SHUTDOWN_TIMEOUT_MS = 5e3;
384
384
  function signalGroup(pid, signal) {
385
385
  try {
386
386
  process.kill(-pid, signal);
387
- } catch (e) {
387
+ } catch {
388
388
  }
389
389
  }
390
390
  function appProcess(entry) {
391
391
  let child = null;
392
- function stop() {
393
- return __async(this, null, function* () {
394
- const running = child;
395
- child = null;
396
- if (!running || running.exitCode !== null || running.pid === void 0) {
397
- return;
398
- }
399
- const { pid } = running;
400
- yield new Promise((resolve) => {
401
- const forced = setTimeout(() => signalGroup(pid, "SIGKILL"), SHUTDOWN_TIMEOUT_MS);
402
- running.once("exit", () => {
403
- clearTimeout(forced);
404
- resolve();
405
- });
406
- signalGroup(pid, "SIGTERM");
392
+ async function stop() {
393
+ const running = child;
394
+ child = null;
395
+ if (!running || running.exitCode !== null || running.pid === void 0) {
396
+ return;
397
+ }
398
+ const { pid } = running;
399
+ await new Promise((resolve) => {
400
+ const forced = setTimeout(() => signalGroup(pid, "SIGKILL"), SHUTDOWN_TIMEOUT_MS);
401
+ running.once("exit", () => {
402
+ clearTimeout(forced);
403
+ resolve();
407
404
  });
405
+ signalGroup(pid, "SIGTERM");
408
406
  });
409
407
  }
410
408
  function start(env) {
411
409
  const started = spawn(process.execPath, [...process.execArgv, entry], {
412
410
  detached: true,
413
- env: __spreadValues(__spreadValues({}, process.env), env),
411
+ env: { ...process.env, ...env },
414
412
  stdio: "inherit"
415
413
  });
416
414
  child = started;
@@ -458,98 +456,93 @@ function watchSources(root, onChange) {
458
456
  });
459
457
  }
460
458
  }
461
- function facts(root) {
462
- return __async(this, null, function* () {
463
- try {
464
- const loaded = yield import(pathToFileURL(path3.join(root, "build/server/index.mjs")).href);
465
- const app = loaded.default;
466
- return { assets: app == null ? void 0 : app.assets, name: app == null ? void 0 : app.name, routes: app == null ? void 0 : app.routes };
467
- } catch (e) {
468
- return {};
469
- }
470
- });
459
+ async function facts(root) {
460
+ try {
461
+ const loaded = await import(pathToFileURL(path3.join(root, "build/server/index.mjs")).href);
462
+ const app = loaded.default;
463
+ return { assets: app == null ? void 0 : app.assets, name: app == null ? void 0 : app.name, routes: app == null ? void 0 : app.routes };
464
+ } catch {
465
+ return {};
466
+ }
471
467
  }
472
468
  function describer(root) {
473
469
  let described = null;
474
- return () => __async(null, null, function* () {
475
- described != null ? described : described = yield facts(root);
470
+ return async () => {
471
+ described != null ? described : described = await facts(root);
476
472
  return described;
477
- });
473
+ };
478
474
  }
479
- function devApp(options) {
480
- return __async(this, null, function* () {
481
- logger.setDebug(true);
482
- const root = path3.resolve(options.root);
483
- let building = false;
484
- let dirty = false;
485
- const describe = describer(root);
486
- const app = appProcess(path3.join(root, SERVER_ENTRY));
487
- function show(lines) {
488
- process.stdout.write(`${lines.join("\n")}
475
+ async function devApp(options) {
476
+ logger.setDebug(true);
477
+ const root = path3.resolve(options.root);
478
+ let building = false;
479
+ let dirty = false;
480
+ const describe = describer(root);
481
+ const app = appProcess(path3.join(root, SERVER_ENTRY));
482
+ function show(lines) {
483
+ process.stdout.write(`${lines.join("\n")}
489
484
  `);
485
+ }
486
+ function listenForKeys() {
487
+ if (!process.stdin.isTTY) {
488
+ return;
490
489
  }
491
- function listenForKeys() {
492
- if (!process.stdin.isTTY) {
493
- return;
490
+ process.stdin.setEncoding("utf8");
491
+ process.stdin.on("data", (chunk) => {
492
+ const key = chunk.trim().toLowerCase();
493
+ if (key === "r") {
494
+ void rebuild();
494
495
  }
495
- process.stdin.setEncoding("utf8");
496
- process.stdin.on("data", (chunk) => {
497
- const key = chunk.trim().toLowerCase();
498
- if (key === "r") {
499
- void rebuild();
500
- }
501
- if (key === "h") {
502
- show(helpLines());
503
- }
504
- if (key === "q") {
505
- void app.stop().then(() => process.exit(0));
506
- }
507
- });
496
+ if (key === "h") {
497
+ show(helpLines());
498
+ }
499
+ if (key === "q") {
500
+ void app.stop().then(() => process.exit(0));
501
+ }
502
+ });
503
+ }
504
+ async function rebuild() {
505
+ var _a;
506
+ if (building) {
507
+ dirty = true;
508
+ return null;
508
509
  }
509
- function rebuild() {
510
- return __async(this, null, function* () {
511
- var _a;
512
- if (building) {
513
- dirty = true;
514
- return null;
515
- }
516
- building = true;
517
- let built = null;
510
+ building = true;
511
+ let built = null;
512
+ try {
513
+ do {
514
+ dirty = false;
515
+ await app.stop();
518
516
  try {
519
- do {
520
- dirty = false;
521
- yield app.stop();
522
- try {
523
- const result = yield buildApp(__spreadProps(__spreadValues({}, options), { mode: "development" }));
524
- app.start({ DEBUG: (_a = process.env["DEBUG"]) != null ? _a : debugPattern((yield describe()).name) });
525
- built = result;
526
- } catch (error) {
527
- logger.error("\u0441\u0431\u043E\u0440\u043A\u0430 \u043D\u0435 \u043F\u0440\u043E\u0448\u043B\u0430 \u2014 \u0441\u0435\u0440\u0432\u0438\u0441 \u041D\u0415 \u041F\u041E\u0414\u041D\u042F\u0422, \u0436\u0434\u0443 \u043F\u0440\u0430\u0432\u043A\u0438:", error);
528
- }
529
- } while (dirty);
530
- } finally {
531
- building = false;
517
+ const result = await buildApp({ ...options, mode: "development" });
518
+ app.start({ DEBUG: (_a = process.env["DEBUG"]) != null ? _a : debugPattern((await describe()).name) });
519
+ built = result;
520
+ } catch (error) {
521
+ logger.error("\u0441\u0431\u043E\u0440\u043A\u0430 \u043D\u0435 \u043F\u0440\u043E\u0448\u043B\u0430 \u2014 \u0441\u0435\u0440\u0432\u0438\u0441 \u041D\u0415 \u041F\u041E\u0414\u041D\u042F\u0422, \u0436\u0434\u0443 \u043F\u0440\u0430\u0432\u043A\u0438:", error);
532
522
  }
533
- return built;
534
- });
535
- }
536
- const startedAt = Date.now();
537
- const address = yield rebuild();
538
- const elapsed = Date.now() - startedAt;
539
- watchSources(root, () => void rebuild());
540
- if (address !== null) {
541
- show(
542
- bannerLines(__spreadValues({
543
- base: address.base,
544
- elapsedMs: elapsed,
545
- mode: "development",
546
- port: address.port,
547
- watched: WATCHED
548
- }, yield describe()))
549
- );
523
+ } while (dirty);
524
+ } finally {
525
+ building = false;
550
526
  }
551
- listenForKeys();
552
- });
527
+ return built;
528
+ }
529
+ const startedAt = Date.now();
530
+ const address = await rebuild();
531
+ const elapsed = Date.now() - startedAt;
532
+ watchSources(root, () => void rebuild());
533
+ if (address !== null) {
534
+ show(
535
+ bannerLines({
536
+ base: address.base,
537
+ elapsedMs: elapsed,
538
+ mode: "development",
539
+ port: address.port,
540
+ watched: WATCHED,
541
+ ...await describe()
542
+ })
543
+ );
544
+ }
545
+ listenForKeys();
553
546
  }
554
547
 
555
548
  export {
@@ -10,10 +10,6 @@ var _chunk6QV4L6R2cjs = require('./chunk-6QV4L6R2.cjs');
10
10
 
11
11
  var _chunkA6ZPAM6Zcjs = require('./chunk-A6ZPAM6Z.cjs');
12
12
 
13
-
14
-
15
- var _chunkT5QVCXVBcjs = require('./chunk-T5QVCXVB.cjs');
16
-
17
13
  // src/island/document.ts
18
14
  function isDocumentSource(value) {
19
15
  return typeof value === "object" && value !== null && typeof value.describeDocument === "function";
@@ -160,18 +156,16 @@ function hydrateIslandState(container, descriptor, denState) {
160
156
  }
161
157
  }
162
158
  }
163
- function activateIslandViewModels(_0, _1) {
164
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, arguments, function* (container, descriptor, route = EMPTY_ROUTE) {
165
- var _a;
166
- yield Promise.all(
167
- ((_a = descriptor.viewModels) != null ? _a : []).map((vm) => _chunkT5QVCXVBcjs.__async.call(void 0, null, null, function* () {
168
- var _a2;
169
- const instance = container.resolve(vm.token);
170
- _chunkA6ZPAM6Zcjs.unitLogger.call(void 0, container, vm.token.description).debug(`\u0430\u043A\u0442\u0438\u0432\u0430\u0446\u0438\u044F VM (${route.pathname || "\u2014"})`);
171
- yield (_a2 = instance.activate) == null ? void 0 : _a2.call(instance, route);
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
+ _chunkA6ZPAM6Zcjs.unitLogger.call(void 0, 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 = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, contribution.head), part.head);
191
+ contribution.head = { ...contribution.head, ...part.head };
198
192
  }
199
193
  if (part.data) {
200
- contribution.data = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, contribution.data), part.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
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, null, function* () {
243
- var _a, _b, _c;
244
- yield setupOnce(descriptor);
245
- const route = {
246
- params: (_a = request.params) != null ? _a : {},
247
- pathname: request.pathname,
248
- search: (_b = request.search) != null ? _b : ""
249
- };
250
- const inputs = islandInputsOf(descriptor, request.inputs);
251
- const container = createIslandContainer(descriptor, { context: request.context, inputs, parent: request.parent });
252
- if (container === null) {
253
- 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`);
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
- try {
256
- yield activateIslandViewModels(container, descriptor, route);
257
- const contribution = collectDocumentContribution(container, descriptor);
258
- const { data, head, redirect, status = STATUS_OK } = contribution;
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 = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, 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 = _chunkXOJ2VWX4cjs.resolveViewAdapter.call(void 0, 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 = _chunkXOJ2VWX4cjs.resolveViewAdapter.call(void 0, 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