bun-plugin-stx 0.2.625 → 0.2.626

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 (2) hide show
  1. package/dist/serve.js +18 -13
  2. package/package.json +3 -3
package/dist/serve.js CHANGED
@@ -11435,19 +11435,21 @@ ${trailingPageScripts.join(`
11435
11435
  });
11436
11436
  }
11437
11437
  if (production && pageWarmup.enabled) {
11438
- const warmupStartedAt = performance.now();
11439
- const covered = pageWarmup.holdBind === "always" || options.reusePort === true && await portIsServed(port);
11440
- const warming = warmPages();
11441
- const done = !covered || await settleWithin(warming, pageWarmup.budgetMs);
11442
- if (!done) {
11443
- console.warn(`[stx] page warm-up still running after ${formatSeconds(pageWarmup.budgetMs)}; binding now and finishing it in the background.`);
11438
+ const holding = pageWarmup.holdBind === "always" || options.reusePort === true && await portIsServed(port);
11439
+ if (holding) {
11440
+ const warmupStartedAt = performance.now();
11441
+ const warmup = { stop: false };
11442
+ const warming = warmPages(warmup);
11443
+ if (!await settleWithin(warming, pageWarmup.budgetMs)) {
11444
+ warmup.stop = true;
11445
+ console.warn(`[stx] page warm-up stopped at its ${formatSeconds(pageWarmup.budgetMs)} budget; binding now, and the pages left render on their first visit.`);
11446
+ }
11447
+ warming.then(({ warmed, pages, failed }) => {
11448
+ console.log(`[stx] warmed ${warmed} of ${pages} pages in ${formatSeconds(performance.now() - warmupStartedAt)}${failed ? ` (${failed} answered 5xx or failed)` : ""}`);
11449
+ });
11444
11450
  }
11445
- warming.then(({ pages, failed }) => {
11446
- if (!options.quiet)
11447
- console.log(`[stx] warmed ${pages} pages in ${formatSeconds(performance.now() - warmupStartedAt)}${failed ? ` (${failed} answered 5xx or failed)` : ""}`);
11448
- });
11449
11451
  }
11450
- async function warmPages() {
11452
+ async function warmPages(control) {
11451
11453
  const files = await discoverFiles();
11452
11454
  const routes = [...new Set([
11453
11455
  ...files.map(stxViewFileToRoutePath).filter((routePath) => routePath !== null),
@@ -11456,10 +11458,11 @@ ${trailingPageScripts.join(`
11456
11458
  ])];
11457
11459
  const warm = listen(0, false, "127.0.0.1");
11458
11460
  let next = 0;
11461
+ let warmed = 0;
11459
11462
  let failed = 0;
11460
11463
  try {
11461
11464
  await Promise.all(Array.from({ length: Math.min(pageWarmup.concurrency, routes.length) }, async () => {
11462
- while (next < routes.length) {
11465
+ while (next < routes.length && !control.stop) {
11463
11466
  const routePath = routes[next++];
11464
11467
  try {
11465
11468
  const response = await fetch(`http://127.0.0.1:${warm.port}${routePath}`, {
@@ -11469,6 +11472,8 @@ ${trailingPageScripts.join(`
11469
11472
  await response.arrayBuffer();
11470
11473
  if (response.status >= 500)
11471
11474
  failed++;
11475
+ else
11476
+ warmed++;
11472
11477
  } catch {
11473
11478
  failed++;
11474
11479
  }
@@ -11477,7 +11482,7 @@ ${trailingPageScripts.join(`
11477
11482
  } finally {
11478
11483
  warm.stop(true);
11479
11484
  }
11480
- return { pages: routes.length, failed };
11485
+ return { warmed, pages: routes.length, failed };
11481
11486
  }
11482
11487
  const portAutoIncrement = options.autoIncrementPort ?? true;
11483
11488
  const maxPortAttempts = portAutoIncrement === false ? 1 : typeof portAutoIncrement === "number" ? Math.max(1, portAutoIncrement) : 10;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.625",
4
+ "version": "0.2.626",
5
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "typecheck": "bun tsc --noEmit"
75
75
  },
76
76
  "dependencies": {
77
- "@stacksjs/stx": "0.2.625",
78
- "stx-router": "0.2.625"
77
+ "@stacksjs/stx": "0.2.626",
78
+ "stx-router": "0.2.626"
79
79
  }
80
80
  }