@blinkk/root 3.0.1 → 3.0.3

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 (117) hide show
  1. package/dist/{chunk-FQBA5QSG.js → chunk-3Z5TNZEP.js} +3 -3
  2. package/dist/chunk-3Z5TNZEP.js.map +7 -0
  3. package/dist/{chunk-JCRXBB26.js → chunk-6NBKAR5Y.js} +2 -2
  4. package/dist/chunk-6NBKAR5Y.js.map +7 -0
  5. package/dist/chunk-6P3B7ZXL.js +1 -1
  6. package/dist/chunk-6P3B7ZXL.js.map +7 -1
  7. package/dist/{chunk-PVBPP5LN.js → chunk-7PSEEE6C.js} +10 -10
  8. package/dist/chunk-7PSEEE6C.js.map +7 -0
  9. package/dist/{chunk-M6WGW5VY.js → chunk-DU7JUEDY.js} +48 -6
  10. package/dist/chunk-DU7JUEDY.js.map +7 -0
  11. package/dist/{chunk-GSR74KEI.js → chunk-JTZWI4MH.js} +279 -73
  12. package/dist/chunk-JTZWI4MH.js.map +7 -0
  13. package/dist/{chunk-WAZTR3DX.js → chunk-KW7KTYGC.js} +2 -2
  14. package/dist/chunk-KW7KTYGC.js.map +7 -0
  15. package/dist/chunk-XSNCF7WU.js +1 -1
  16. package/dist/chunk-XSNCF7WU.js.map +7 -1
  17. package/dist/cli/build.d.ts +7 -0
  18. package/dist/cli/cli.d.ts +12 -0
  19. package/dist/cli/codegen.d.ts +5 -0
  20. package/dist/cli/create-package.d.ts +14 -0
  21. package/dist/cli/dev.d.ts +10 -0
  22. package/dist/cli/gae-deploy.d.ts +18 -0
  23. package/dist/cli/preview.d.ts +8 -0
  24. package/dist/cli/start.d.ts +8 -0
  25. package/dist/cli/startup/check-version.d.ts +17 -0
  26. package/dist/cli/startup/startup-tasks.d.ts +39 -0
  27. package/dist/cli.js +4 -4
  28. package/dist/cli.js.map +7 -1
  29. package/dist/core/components/Body.d.ts +23 -0
  30. package/dist/core/components/Head.d.ts +18 -0
  31. package/dist/core/components/Html.d.ts +24 -0
  32. package/dist/core/components/Script.d.ts +16 -0
  33. package/dist/core/config.d.ts +285 -0
  34. package/dist/core/core.d.ts +14 -0
  35. package/dist/core/hooks/useI18nContext.d.ts +11 -0
  36. package/dist/core/hooks/useRequestContext.d.ts +36 -0
  37. package/dist/core/hooks/useStringParams.d.ts +34 -0
  38. package/dist/core/hooks/useTranslations.d.ts +20 -0
  39. package/dist/core/hooks/useTranslationsMiddleware.d.ts +25 -0
  40. package/dist/core/pages/DevErrorPage.d.ts +9 -0
  41. package/dist/core/pages/DevNotFoundPage.d.ts +10 -0
  42. package/dist/core/pages/ErrorPage.d.ts +9 -0
  43. package/dist/core/plugin.d.ts +80 -0
  44. package/dist/core/pod.d.ts +54 -0
  45. package/dist/core/types.d.ts +228 -0
  46. package/dist/core.js +3 -3
  47. package/dist/core.js.map +7 -1
  48. package/dist/functions/functions.d.ts +1 -0
  49. package/dist/functions/server.d.ts +10 -0
  50. package/dist/functions.js +5 -5
  51. package/dist/functions.js.map +7 -1
  52. package/dist/jsx/jsx-dev-runtime.d.ts +10 -1
  53. package/dist/jsx/jsx-dev-runtime.js +2 -2
  54. package/dist/jsx/jsx-dev-runtime.js.map +7 -1
  55. package/dist/{jsx-C8BaDh-4.d.ts → jsx/jsx-render.d.ts} +3 -6
  56. package/dist/jsx/jsx-runtime.d.ts +120 -1
  57. package/dist/jsx/jsx-runtime.js +2 -2
  58. package/dist/jsx/jsx-runtime.js.map +7 -1
  59. package/dist/jsx/jsx.d.ts +37 -0
  60. package/dist/{jsx-dev-runtime-DUJrvx5P.d.ts → jsx/types.d.ts} +9 -125
  61. package/dist/jsx.js +3 -3
  62. package/dist/jsx.js.map +7 -1
  63. package/dist/middleware/common.d.ts +22 -0
  64. package/dist/middleware/hooks.d.ts +8 -0
  65. package/dist/middleware/middleware.d.ts +3 -0
  66. package/dist/middleware/multipart.d.ts +11 -0
  67. package/dist/middleware/redirects.d.ts +10 -0
  68. package/dist/middleware/session.d.ts +24 -0
  69. package/dist/middleware.js +2 -2
  70. package/dist/middleware.js.map +7 -1
  71. package/dist/node/element-graph.d.ts +51 -0
  72. package/dist/node/load-config.d.ts +17 -0
  73. package/dist/node/monorepo.d.ts +14 -0
  74. package/dist/node/node.d.ts +4 -0
  75. package/dist/node/pod-collector.d.ts +33 -0
  76. package/dist/node/pods-vite-plugin.d.ts +6 -0
  77. package/dist/node/vite-plugin-preact-alias.d.ts +10 -0
  78. package/dist/node/vite-plugin-prune-empty-chunks.d.ts +27 -0
  79. package/dist/node/vite-plugin-root-jsx-virtual.d.ts +16 -0
  80. package/dist/node/vite.d.ts +18 -0
  81. package/dist/node.js +2 -2
  82. package/dist/node.js.map +7 -1
  83. package/dist/render/accept-language.d.ts +8 -0
  84. package/dist/render/asset-map/asset-map.d.ts +25 -0
  85. package/dist/render/asset-map/build-asset-map.d.ts +47 -0
  86. package/dist/render/asset-map/dev-asset-map.d.ts +26 -0
  87. package/dist/render/countrie-language.d.ts +13 -0
  88. package/dist/render/html-minify.d.ts +3 -0
  89. package/dist/render/html-pretty.d.ts +3 -0
  90. package/dist/render/i18n-fallbacks.d.ts +11 -0
  91. package/dist/render/render.d.ts +91 -0
  92. package/dist/render/route-trie.d.ts +44 -0
  93. package/dist/render/router.d.ts +18 -0
  94. package/dist/render.js +9 -9
  95. package/dist/render.js.map +7 -1
  96. package/dist/utils/batch.d.ts +1 -0
  97. package/dist/utils/elements.d.ts +12 -0
  98. package/dist/utils/fsutils.d.ts +24 -0
  99. package/dist/utils/i18n.d.ts +8 -0
  100. package/dist/utils/ports.d.ts +8 -0
  101. package/dist/utils/rand.d.ts +10 -0
  102. package/dist/utils/url-path-params.d.ts +2 -0
  103. package/package.json +14 -15
  104. package/dist/chunk-FQBA5QSG.js.map +0 -1
  105. package/dist/chunk-GSR74KEI.js.map +0 -1
  106. package/dist/chunk-JCRXBB26.js.map +0 -1
  107. package/dist/chunk-M6WGW5VY.js.map +0 -1
  108. package/dist/chunk-PVBPP5LN.js.map +0 -1
  109. package/dist/chunk-WAZTR3DX.js.map +0 -1
  110. package/dist/cli.d.ts +0 -60
  111. package/dist/core.d.ts +0 -214
  112. package/dist/functions.d.ts +0 -14
  113. package/dist/jsx.d.ts +0 -2
  114. package/dist/middleware.d.ts +0 -43
  115. package/dist/node.d.ts +0 -91
  116. package/dist/render.d.ts +0 -8
  117. package/dist/types-Cksf99CK.d.ts +0 -827
@@ -10,7 +10,7 @@ import {
10
10
  rootProjectMiddleware,
11
11
  sessionMiddleware,
12
12
  trailingSlashMiddleware
13
- } from "./chunk-JCRXBB26.js";
13
+ } from "./chunk-6NBKAR5Y.js";
14
14
  import {
15
15
  bundleRootConfig,
16
16
  collectPods,
@@ -33,7 +33,7 @@ import {
33
33
  rootPodsVitePlugin,
34
34
  writeFile,
35
35
  writeJson
36
- } from "./chunk-PVBPP5LN.js";
36
+ } from "./chunk-7PSEEE6C.js";
37
37
  import {
38
38
  configureServerPlugins,
39
39
  getVitePlugins
@@ -44,16 +44,16 @@ import { Command, InvalidArgumentError } from "commander";
44
44
  import { bgGreen, black } from "kleur/colors";
45
45
 
46
46
  // src/cli/build.ts
47
- import path3 from "path";
48
- import { fileURLToPath } from "url";
47
+ import path3 from "node:path";
48
+ import { fileURLToPath } from "node:url";
49
49
  import fsExtra from "fs-extra";
50
- import { dim, cyan } from "kleur/colors";
50
+ import { dim as dim2, cyan } from "kleur/colors";
51
51
  import glob2 from "tiny-glob";
52
52
  import { build as viteBuild } from "vite";
53
53
 
54
54
  // src/node/element-graph.ts
55
- import fs from "fs";
56
- import path from "path";
55
+ import fs from "node:fs";
56
+ import path from "node:path";
57
57
  import glob from "tiny-glob";
58
58
  import { searchForWorkspaceRoot } from "vite";
59
59
  var ElementGraph = class _ElementGraph {
@@ -167,9 +167,74 @@ function getElementsDirs(rootConfig, pods) {
167
167
  return elementsDirs;
168
168
  }
169
169
 
170
+ // src/node/vite-plugin-prune-empty-chunks.ts
171
+ import { dim } from "kleur/colors";
172
+ function pruneEmptyChunksPlugin() {
173
+ return {
174
+ name: "root:prune-empty-chunks",
175
+ generateBundle: {
176
+ // Run before Vite's manifest plugin so the manifest reflects removals.
177
+ order: "pre",
178
+ handler(_options, bundle) {
179
+ const emptyChunks = /* @__PURE__ */ new Set();
180
+ for (const [fileName, item] of Object.entries(bundle)) {
181
+ if (item.type !== "chunk" || item.code.trim() !== "") {
182
+ continue;
183
+ }
184
+ const css = item.viteMetadata?.importedCss;
185
+ const assets = item.viteMetadata?.importedAssets;
186
+ if (css && css.size > 0 || assets && assets.size > 0) {
187
+ continue;
188
+ }
189
+ emptyChunks.add(fileName);
190
+ }
191
+ if (emptyChunks.size === 0) {
192
+ return;
193
+ }
194
+ for (const item of Object.values(bundle)) {
195
+ if (item.type !== "chunk") {
196
+ continue;
197
+ }
198
+ const referenced = new Set(
199
+ [...item.imports || [], ...item.dynamicImports || []].filter(
200
+ (fileName) => emptyChunks.has(fileName)
201
+ )
202
+ );
203
+ for (const emptyFileName of referenced) {
204
+ item.code = removeSideEffectImport(item.code, emptyFileName);
205
+ }
206
+ if (item.imports) {
207
+ item.imports = item.imports.filter((f) => !emptyChunks.has(f));
208
+ }
209
+ if (item.dynamicImports) {
210
+ item.dynamicImports = item.dynamicImports.filter(
211
+ (f) => !emptyChunks.has(f)
212
+ );
213
+ }
214
+ }
215
+ for (const fileName of emptyChunks) {
216
+ delete bundle[fileName];
217
+ }
218
+ const removed = Array.from(emptyChunks).sort();
219
+ console.log(
220
+ `${dim("\u2503")} pruned ${removed.length} empty chunk(s): ${dim(
221
+ removed.join(", ")
222
+ )}`
223
+ );
224
+ }
225
+ }
226
+ };
227
+ }
228
+ function removeSideEffectImport(code, fileName) {
229
+ const base = fileName.split("/").pop() || fileName;
230
+ const escaped = base.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
231
+ const re = new RegExp(`import\\s*["'][^"']*${escaped}["']\\s*;?`, "g");
232
+ return code.replace(re, "");
233
+ }
234
+
170
235
  // src/render/asset-map/build-asset-map.ts
171
- import fs2 from "fs";
172
- import path2 from "path";
236
+ import fs2 from "node:fs";
237
+ import path2 from "node:path";
173
238
  var BuildAssetMap = class _BuildAssetMap {
174
239
  rootConfig;
175
240
  srcToAsset;
@@ -356,9 +421,9 @@ async function build(rootProjectDir, options) {
356
421
  const distDir = path3.join(rootDir, "dist");
357
422
  const ssrOnly = options?.ssrOnly || false;
358
423
  console.log();
359
- console.log(`${dim("\u2503")} project: ${rootDir}`);
360
- console.log(`${dim("\u2503")} output: ${distDir}/html`);
361
- console.log(`${dim("\u2503")} mode: ${mode}`);
424
+ console.log(`${dim2("\u2503")} project: ${rootDir}`);
425
+ console.log(`${dim2("\u2503")} output: ${distDir}/html`);
426
+ console.log(`${dim2("\u2503")} mode: ${mode}`);
362
427
  console.log();
363
428
  await rmDir(distDir);
364
429
  await makeDir(distDir);
@@ -408,7 +473,8 @@ async function build(rootProjectDir, options) {
408
473
  preactToRootJsxPlugin({ useRootJsx: !!rootConfig.jsxRenderer?.mode }),
409
474
  rootPodsVitePlugin(rootConfig),
410
475
  ...viteConfig.plugins || [],
411
- ...getVitePlugins(rootPlugins)
476
+ ...getVitePlugins(rootPlugins),
477
+ pruneEmptyChunksPlugin()
412
478
  ];
413
479
  const baseConfig = {
414
480
  ...viteConfig,
@@ -733,7 +799,8 @@ async function build(rootProjectDir, options) {
733
799
  e
734
800
  );
735
801
  throw new Error(
736
- `BuildError: ${urlPath} (${sitemapItem.route.src}) failed to build.`
802
+ `BuildError: ${urlPath} (${sitemapItem.route.src}) failed to build.`,
803
+ { cause: e }
737
804
  );
738
805
  }
739
806
  }
@@ -792,7 +859,7 @@ function printFileOutput(fileSize2, outputDir, outputFile) {
792
859
  const indent = " ".repeat(2);
793
860
  const paddedSize = fileSize2.padStart(9, " ");
794
861
  console.log(
795
- `${indent}${dim(paddedSize)} ${dim(outputDir)}${cyan(outputFile)}`
862
+ `${indent}${dim2(paddedSize)} ${dim2(outputDir)}${cyan(outputFile)}`
796
863
  );
797
864
  }
798
865
  function sanitizeFileName(name) {
@@ -827,9 +894,9 @@ function formatParams(params) {
827
894
  }
828
895
 
829
896
  // src/cli/codegen.ts
830
- import { promises as fs3 } from "fs";
831
- import path4 from "path";
832
- import { fileURLToPath as fileURLToPath2 } from "url";
897
+ import { promises as fs3 } from "node:fs";
898
+ import path4 from "node:path";
899
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
833
900
  import glob3 from "tiny-glob";
834
901
  var __dirname2 = path4.dirname(fileURLToPath2(import.meta.url));
835
902
  async function codegen(type, name, options) {
@@ -907,8 +974,8 @@ function toTitleCase(str) {
907
974
  }
908
975
 
909
976
  // src/cli/create-package.ts
910
- import { promises as fs4 } from "fs";
911
- import path5 from "path";
977
+ import { promises as fs4 } from "node:fs";
978
+ import path5 from "node:path";
912
979
  import { build as esbuild } from "esbuild";
913
980
  async function createPackage(rootProjectDir, options) {
914
981
  const mode = options?.mode || "production";
@@ -1040,11 +1107,11 @@ async function bundleTsFile(srcPath, outPath) {
1040
1107
  }
1041
1108
 
1042
1109
  // src/cli/dev.ts
1043
- import path7 from "path";
1044
- import { fileURLToPath as fileURLToPath3 } from "url";
1110
+ import path8 from "node:path";
1111
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
1045
1112
  import cookieParser from "cookie-parser";
1046
1113
  import { default as express } from "express";
1047
- import { dim as dim2 } from "kleur/colors";
1114
+ import { dim as dim4 } from "kleur/colors";
1048
1115
  import sirv from "sirv";
1049
1116
  import glob4 from "tiny-glob";
1050
1117
 
@@ -1134,7 +1201,7 @@ function testIsRedirectValid(url) {
1134
1201
  }
1135
1202
 
1136
1203
  // src/render/asset-map/dev-asset-map.ts
1137
- import path6 from "path";
1204
+ import path6 from "node:path";
1138
1205
  import { searchForWorkspaceRoot as searchForWorkspaceRoot2 } from "vite";
1139
1206
  var DevServerAssetMap = class {
1140
1207
  rootConfig;
@@ -1264,7 +1331,7 @@ var DevServerAsset = class _DevServerAsset {
1264
1331
  };
1265
1332
 
1266
1333
  // src/utils/ports.ts
1267
- import { createServer } from "net";
1334
+ import { createServer } from "node:net";
1268
1335
  function isPortOpen(port) {
1269
1336
  return new Promise((resolve, reject) => {
1270
1337
  const server = createServer();
@@ -1301,7 +1368,7 @@ async function findOpenPort(min, max) {
1301
1368
  }
1302
1369
 
1303
1370
  // src/utils/rand.ts
1304
- import crypto from "crypto";
1371
+ import crypto from "node:crypto";
1305
1372
  function randString(len) {
1306
1373
  const result = [];
1307
1374
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@@ -1324,17 +1391,153 @@ function getSessionCookieSecret(rootConfig, rootDir) {
1324
1391
  return randString(36);
1325
1392
  }
1326
1393
 
1394
+ // src/cli/startup/startup-tasks.ts
1395
+ import os from "node:os";
1396
+ import path7 from "node:path";
1397
+
1398
+ // src/cli/startup/check-version.ts
1399
+ import { dim as dim3, green, yellow } from "kleur/colors";
1400
+ var PACKAGE_NAME = "@blinkk/root";
1401
+ var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
1402
+ var REGISTRY_TIMEOUT_MS = 3e3;
1403
+ var checkVersionTask = {
1404
+ name: "check-version",
1405
+ throttle: ONE_DAY_MS,
1406
+ // Skip the check when disabled via env var, when the version is unknown, or
1407
+ // for pre-release (alpha/beta/rc) builds that are intentionally ahead of the
1408
+ // latest stable release.
1409
+ enabled(ctx) {
1410
+ return !isVersionCheckDisabled() && !!ctx.version && !isPrerelease(ctx.version);
1411
+ },
1412
+ async run(ctx) {
1413
+ const current = ctx.version;
1414
+ const latest = await fetchLatestVersion();
1415
+ if (current && latest && isNewerVersion(current, latest)) {
1416
+ printUpdateNotice(current, latest);
1417
+ }
1418
+ }
1419
+ };
1420
+ function isVersionCheckDisabled() {
1421
+ return isEnvEnabled("ROOT_DISABLE_VERSION_CHECK") || isEnvEnabled("NO_UPDATE_NOTIFIER");
1422
+ }
1423
+ function isEnvEnabled(name) {
1424
+ const value = (process.env[name] || "").trim().toLowerCase();
1425
+ return value !== "" && value !== "0" && value !== "false";
1426
+ }
1427
+ async function fetchLatestVersion() {
1428
+ const controller = new AbortController();
1429
+ const timeout = setTimeout(() => controller.abort(), REGISTRY_TIMEOUT_MS);
1430
+ try {
1431
+ const url = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
1432
+ const res = await fetch(url, { signal: controller.signal });
1433
+ if (!res.ok) {
1434
+ return null;
1435
+ }
1436
+ const data = await res.json();
1437
+ return data.version || null;
1438
+ } catch {
1439
+ return null;
1440
+ } finally {
1441
+ clearTimeout(timeout);
1442
+ }
1443
+ }
1444
+ function isNewerVersion(current, latest) {
1445
+ const a = parseVersion(latest);
1446
+ const b = parseVersion(current);
1447
+ for (let i = 0; i < 3; i++) {
1448
+ if (a[i] > b[i]) {
1449
+ return true;
1450
+ }
1451
+ if (a[i] < b[i]) {
1452
+ return false;
1453
+ }
1454
+ }
1455
+ return false;
1456
+ }
1457
+ function isPrerelease(version) {
1458
+ return /-(alpha|beta|rc)\b/i.test(version);
1459
+ }
1460
+ function parseVersion(version) {
1461
+ const main = version.split("-")[0];
1462
+ const parts = main.split(".");
1463
+ const toInt = (value) => {
1464
+ const num = parseInt(value || "0", 10);
1465
+ return isNaN(num) ? 0 : num;
1466
+ };
1467
+ return [toInt(parts[0]), toInt(parts[1]), toInt(parts[2])];
1468
+ }
1469
+ function printUpdateNotice(current, latest) {
1470
+ const bar = dim3("\u2503");
1471
+ const label = yellow(`Update available for ${PACKAGE_NAME}:`);
1472
+ console.log();
1473
+ console.log(`${bar} ${label} ${dim3(current)} \u2192 ${green(latest)}`);
1474
+ console.log();
1475
+ }
1476
+
1477
+ // src/cli/startup/startup-tasks.ts
1478
+ var STARTUP_TASKS = [checkVersionTask];
1479
+ var STATE_FILE = path7.join(os.homedir(), ".root", "startup-tasks.json");
1480
+ async function runStartupTasks(ctx) {
1481
+ try {
1482
+ const state = await readState();
1483
+ const now = Date.now();
1484
+ const dueTasks = STARTUP_TASKS.filter(
1485
+ (task) => isEnabled(task, ctx) && isDue(task, state.lastRun[task.name], now)
1486
+ );
1487
+ if (dueTasks.length === 0) {
1488
+ return;
1489
+ }
1490
+ await Promise.all(
1491
+ dueTasks.map(async (task) => {
1492
+ try {
1493
+ await task.run(ctx);
1494
+ } catch {
1495
+ }
1496
+ state.lastRun[task.name] = Date.now();
1497
+ })
1498
+ );
1499
+ await writeState(state);
1500
+ } catch {
1501
+ }
1502
+ }
1503
+ function isEnabled(task, ctx) {
1504
+ return !task.enabled || task.enabled(ctx);
1505
+ }
1506
+ function isDue(task, lastRun, now) {
1507
+ if (!task.throttle || !lastRun) {
1508
+ return true;
1509
+ }
1510
+ return now - lastRun >= task.throttle;
1511
+ }
1512
+ async function readState() {
1513
+ if (await fileExists(STATE_FILE)) {
1514
+ try {
1515
+ const state = await loadJson(STATE_FILE);
1516
+ return { lastRun: state.lastRun || {} };
1517
+ } catch {
1518
+ }
1519
+ }
1520
+ return { lastRun: {} };
1521
+ }
1522
+ async function writeState(state) {
1523
+ try {
1524
+ await writeJson(STATE_FILE, state);
1525
+ } catch {
1526
+ }
1527
+ }
1528
+
1327
1529
  // src/cli/dev.ts
1328
- var __dirname3 = path7.dirname(fileURLToPath3(import.meta.url));
1530
+ var __dirname3 = path8.dirname(fileURLToPath3(import.meta.url));
1329
1531
  var DEV_SERVER_404_LOG_IGNORE_PATHS = /* @__PURE__ */ new Set([
1330
1532
  "/.well-known/appspecific/com.chrome.devtools.json"
1331
1533
  ]);
1332
1534
  async function dev(rootProjectDir, options) {
1333
1535
  process.env.NODE_ENV = "development";
1334
- const rootDir = path7.resolve(rootProjectDir || process.cwd());
1536
+ const rootDir = path8.resolve(rootProjectDir || process.cwd());
1335
1537
  const defaultPort = parseInt(process.env.PORT || "4007");
1336
1538
  const host = options?.host || "localhost";
1337
1539
  const port = await findOpenPort(defaultPort, defaultPort + 10);
1540
+ void runStartupTasks({ rootDir, version: options?.version });
1338
1541
  let currentServer = null;
1339
1542
  let currentViteServer = null;
1340
1543
  async function start2() {
@@ -1345,19 +1548,19 @@ async function dev(rootProjectDir, options) {
1345
1548
  const basePath = rootConfig.base || "";
1346
1549
  const homePagePath = rootConfig.server?.homePagePath || basePath;
1347
1550
  console.log();
1348
- console.log(`${dim2("\u2503")} project: ${rootDir}`);
1349
- console.log(`${dim2("\u2503")} server: http://${host}:${port}${homePagePath}`);
1551
+ console.log(`${dim4("\u2503")} project: ${rootDir}`);
1552
+ console.log(`${dim4("\u2503")} server: http://${host}:${port}${homePagePath}`);
1350
1553
  if (testCmsEnabled(rootConfig)) {
1351
- console.log(`${dim2("\u2503")} cms: http://${host}:${port}/cms/`);
1554
+ console.log(`${dim4("\u2503")} cms: http://${host}:${port}/cms/`);
1352
1555
  }
1353
- console.log(`${dim2("\u2503")} mode: development`);
1556
+ console.log(`${dim4("\u2503")} mode: development`);
1354
1557
  console.log();
1355
1558
  currentServer = server.listen(port, host);
1356
1559
  const rootConfigDependencies = server.get(
1357
1560
  "rootConfigDependencies"
1358
1561
  );
1359
1562
  const dependencies = [
1360
- path7.resolve(rootDir, "root.config.ts"),
1563
+ path8.resolve(rootDir, "root.config.ts"),
1361
1564
  ...rootConfigDependencies
1362
1565
  ];
1363
1566
  viteServer.watcher.add(dependencies);
@@ -1365,7 +1568,7 @@ async function dev(rootProjectDir, options) {
1365
1568
  if (dependencies.includes(file)) {
1366
1569
  console.log(
1367
1570
  `
1368
- ${dim2("\u2503")} root.config.ts changed. restarting server...`
1571
+ ${dim4("\u2503")} root.config.ts changed. restarting server...`
1369
1572
  );
1370
1573
  await restart();
1371
1574
  }
@@ -1385,7 +1588,7 @@ ${dim2("\u2503")} root.config.ts changed. restarting server...`
1385
1588
  await start2();
1386
1589
  }
1387
1590
  async function createDevServer(options) {
1388
- const rootDir = path7.resolve(options?.rootDir || process.cwd());
1591
+ const rootDir = path8.resolve(options?.rootDir || process.cwd());
1389
1592
  const { rootConfig, dependencies } = await loadRootConfigWithDeps(rootDir, {
1390
1593
  command: "dev"
1391
1594
  });
@@ -1421,7 +1624,7 @@ async function createDevServer(options) {
1421
1624
  if (rootConfig.server?.headers) {
1422
1625
  server.use(headersMiddleware({ rootConfig }));
1423
1626
  }
1424
- const publicDir = path7.join(rootDir, "public");
1627
+ const publicDir = path8.join(rootDir, "public");
1425
1628
  if (await dirExists(publicDir)) {
1426
1629
  server.use(rootPublicDirMiddleware({ publicDir, viteServer }));
1427
1630
  }
@@ -1449,10 +1652,10 @@ async function createViteMiddleware(options) {
1449
1652
  return sourceFile.relPath;
1450
1653
  });
1451
1654
  const bundleScripts = [];
1452
- if (await isDirectory(path7.join(rootDir, "bundles"))) {
1655
+ if (await isDirectory(path8.join(rootDir, "bundles"))) {
1453
1656
  const bundleFiles = await glob4("bundles/*", { cwd: rootDir });
1454
1657
  bundleFiles.forEach((file) => {
1455
- const parts = path7.parse(file);
1658
+ const parts = path8.parse(file);
1456
1659
  if (isJsFile(parts.base)) {
1457
1660
  bundleScripts.push(file);
1458
1661
  }
@@ -1469,7 +1672,7 @@ async function createViteMiddleware(options) {
1469
1672
  optimizeDeps
1470
1673
  });
1471
1674
  function isInElementsDir(changedFilePath) {
1472
- const filePath = path7.resolve(changedFilePath);
1675
+ const filePath = path8.resolve(changedFilePath);
1473
1676
  const elementsDirs = getElementsDirs(rootConfig, pods);
1474
1677
  return elementsDirs.some((dirPath) => filePath.startsWith(dirPath));
1475
1678
  }
@@ -1488,7 +1691,7 @@ async function createViteMiddleware(options) {
1488
1691
  const viteMiddleware = async (req, res, next) => {
1489
1692
  try {
1490
1693
  req.viteServer = viteServer;
1491
- const renderModulePath = path7.resolve(__dirname3, "./render.js");
1694
+ const renderModulePath = path8.resolve(__dirname3, "./render.js");
1492
1695
  const render = await viteServer.ssrLoadModule(
1493
1696
  renderModulePath
1494
1697
  );
@@ -1512,7 +1715,7 @@ function rootPublicDirMiddleware(options) {
1512
1715
  handler = sirv(publicDir, sirvOptions);
1513
1716
  }, 1e3);
1514
1717
  function isInPublicDir(changedFilePath) {
1515
- const filePath = path7.resolve(changedFilePath);
1718
+ const filePath = path8.resolve(changedFilePath);
1516
1719
  return filePath.startsWith(publicDir);
1517
1720
  }
1518
1721
  const watcher = options.viteServer.watcher;
@@ -1544,7 +1747,7 @@ function rootDevServer404Middleware() {
1544
1747
  }
1545
1748
  if (req.renderer) {
1546
1749
  const url = req.path;
1547
- const ext = path7.extname(url);
1750
+ const ext = path8.extname(url);
1548
1751
  if (!ext) {
1549
1752
  const renderer = req.renderer;
1550
1753
  const data = await renderer.renderDevServer404(req);
@@ -1562,7 +1765,7 @@ function rootDevServer500Middleware() {
1562
1765
  console.error(String(err.stack || err));
1563
1766
  if (req.renderer) {
1564
1767
  const url = req.path;
1565
- const ext = path7.extname(url);
1768
+ const ext = path8.extname(url);
1566
1769
  if (!ext) {
1567
1770
  const renderer = req.renderer;
1568
1771
  const data = await renderer.renderDevServer500(req, err);
@@ -1587,8 +1790,8 @@ function debounce(fn, timeout) {
1587
1790
  }
1588
1791
 
1589
1792
  // src/cli/gae-deploy.ts
1590
- import { execSync } from "child_process";
1591
- import fs5 from "fs";
1793
+ import { execSync } from "node:child_process";
1794
+ import fs5 from "node:fs";
1592
1795
  import yaml from "js-yaml";
1593
1796
  async function gaeDeploy(appDir, options) {
1594
1797
  if (!appDir) {
@@ -1756,29 +1959,29 @@ function testManagedVersion(service, appInfo, prefix) {
1756
1959
  }
1757
1960
 
1758
1961
  // src/cli/preview.ts
1759
- import path8 from "path";
1962
+ import path9 from "node:path";
1760
1963
  import compression from "compression";
1761
1964
  import cookieParser2 from "cookie-parser";
1762
1965
  import { default as express2 } from "express";
1763
- import { dim as dim3 } from "kleur/colors";
1966
+ import { dim as dim5 } from "kleur/colors";
1764
1967
  import sirv2 from "sirv";
1765
1968
  async function preview(rootProjectDir, options) {
1766
1969
  process.env.NODE_ENV = "development";
1767
- const rootDir = path8.resolve(rootProjectDir || process.cwd());
1970
+ const rootDir = path9.resolve(rootProjectDir || process.cwd());
1768
1971
  const server = await createPreviewServer({ rootDir });
1769
1972
  const port = parseInt(process.env.PORT || "4007");
1770
1973
  const host = options?.host || "localhost";
1771
1974
  console.log();
1772
- console.log(`${dim3("\u2503")} project: ${rootDir}`);
1773
- console.log(`${dim3("\u2503")} server: http://${host}:${port}`);
1774
- console.log(`${dim3("\u2503")} mode: preview`);
1975
+ console.log(`${dim5("\u2503")} project: ${rootDir}`);
1976
+ console.log(`${dim5("\u2503")} server: http://${host}:${port}`);
1977
+ console.log(`${dim5("\u2503")} mode: preview`);
1775
1978
  console.log();
1776
1979
  server.listen(port, host);
1777
1980
  }
1778
1981
  async function createPreviewServer(options) {
1779
1982
  const rootDir = options.rootDir;
1780
1983
  const rootConfig = await loadBundledConfig(rootDir, { command: "preview" });
1781
- const distDir = path8.join(rootDir, "dist");
1984
+ const distDir = path9.join(rootDir, "dist");
1782
1985
  const server = express2();
1783
1986
  server.disable("x-powered-by");
1784
1987
  server.use(compression());
@@ -1804,7 +2007,7 @@ async function createPreviewServer(options) {
1804
2007
  if (rootConfig.server?.headers) {
1805
2008
  server.use(headersMiddleware({ rootConfig }));
1806
2009
  }
1807
- const publicDir = path8.join(distDir, "html");
2010
+ const publicDir = path9.join(distDir, "html");
1808
2011
  server.use(sirv2(publicDir, { dev: false }));
1809
2012
  server.use(trailingSlashMiddleware({ rootConfig }));
1810
2013
  server.use(rootPreviewServerMiddleware());
@@ -1823,14 +2026,14 @@ async function createPreviewServer(options) {
1823
2026
  }
1824
2027
  async function rootPreviewRendererMiddleware(options) {
1825
2028
  const { distDir, rootConfig } = options;
1826
- const render = await import(path8.join(distDir, "server/render.js"));
1827
- const manifestPath = path8.join(distDir, ".root/manifest.json");
2029
+ const render = await import(path9.join(distDir, "server/render.js"));
2030
+ const manifestPath = path9.join(distDir, ".root/manifest.json");
1828
2031
  if (!await fileExists(manifestPath)) {
1829
2032
  throw new Error(
1830
2033
  `could not find ${manifestPath}. run \`root build\` before \`root preview\`.`
1831
2034
  );
1832
2035
  }
1833
- const elementGraphJsonPath = path8.join(distDir, ".root/elements.json");
2036
+ const elementGraphJsonPath = path9.join(distDir, ".root/elements.json");
1834
2037
  if (!await fileExists(elementGraphJsonPath)) {
1835
2038
  throw new Error(
1836
2039
  `could not find ${elementGraphJsonPath}. run \`root build\` before \`root preview\`.`
@@ -1870,7 +2073,7 @@ function rootPreviewServer404Middleware() {
1870
2073
  console.error(`\u2753 404 ${req.originalUrl}`);
1871
2074
  if (req.renderer) {
1872
2075
  const url = req.path;
1873
- const ext = path8.extname(url);
2076
+ const ext = path9.extname(url);
1874
2077
  if (!ext) {
1875
2078
  const renderer = req.renderer;
1876
2079
  const data = await renderer.render404({ currentPath: url });
@@ -1888,7 +2091,7 @@ function rootPreviewServer500Middleware() {
1888
2091
  console.error(String(err.stack || err));
1889
2092
  if (req.renderer) {
1890
2093
  const url = req.path;
1891
- const ext = path8.extname(url);
2094
+ const ext = path9.extname(url);
1892
2095
  if (!ext) {
1893
2096
  const renderer = req.renderer;
1894
2097
  const data = await renderer.renderDevServer500(req, err);
@@ -1902,29 +2105,29 @@ function rootPreviewServer500Middleware() {
1902
2105
  }
1903
2106
 
1904
2107
  // src/cli/start.ts
1905
- import path9 from "path";
2108
+ import path10 from "node:path";
1906
2109
  import compression2 from "compression";
1907
2110
  import cookieParser3 from "cookie-parser";
1908
2111
  import { default as express3 } from "express";
1909
- import { dim as dim4 } from "kleur/colors";
2112
+ import { dim as dim6 } from "kleur/colors";
1910
2113
  import sirv3 from "sirv";
1911
2114
  async function start(rootProjectDir, options) {
1912
2115
  process.env.NODE_ENV = "production";
1913
- const rootDir = path9.resolve(rootProjectDir || process.cwd());
2116
+ const rootDir = path10.resolve(rootProjectDir || process.cwd());
1914
2117
  const server = await createProdServer({ rootDir });
1915
2118
  const port = parseInt(process.env.PORT || "4007");
1916
2119
  const host = options?.host || "localhost";
1917
2120
  console.log();
1918
- console.log(`${dim4("\u2503")} project: ${rootDir}`);
1919
- console.log(`${dim4("\u2503")} server: http://${host}:${port}`);
1920
- console.log(`${dim4("\u2503")} mode: production`);
2121
+ console.log(`${dim6("\u2503")} project: ${rootDir}`);
2122
+ console.log(`${dim6("\u2503")} server: http://${host}:${port}`);
2123
+ console.log(`${dim6("\u2503")} mode: production`);
1921
2124
  console.log();
1922
2125
  server.listen(port, host);
1923
2126
  }
1924
2127
  async function createProdServer(options) {
1925
2128
  const rootDir = options.rootDir;
1926
2129
  const rootConfig = await loadBundledConfig(rootDir, { command: "start" });
1927
- const distDir = path9.join(rootDir, "dist");
2130
+ const distDir = path10.join(rootDir, "dist");
1928
2131
  const server = express3();
1929
2132
  server.disable("x-powered-by");
1930
2133
  server.use(compression2());
@@ -1950,7 +2153,7 @@ async function createProdServer(options) {
1950
2153
  if (rootConfig.server?.headers) {
1951
2154
  server.use(headersMiddleware({ rootConfig }));
1952
2155
  }
1953
- const publicDir = path9.join(distDir, "html");
2156
+ const publicDir = path10.join(distDir, "html");
1954
2157
  server.use(sirv3(publicDir, { dev: false }));
1955
2158
  server.use(trailingSlashMiddleware({ rootConfig }));
1956
2159
  server.use(rootProdServerMiddleware());
@@ -1969,14 +2172,14 @@ async function createProdServer(options) {
1969
2172
  }
1970
2173
  async function rootProdRendererMiddleware(options) {
1971
2174
  const { distDir, rootConfig } = options;
1972
- const render = await import(path9.join(distDir, "server/render.js"));
1973
- const manifestPath = path9.join(distDir, ".root/manifest.json");
2175
+ const render = await import(path10.join(distDir, "server/render.js"));
2176
+ const manifestPath = path10.join(distDir, ".root/manifest.json");
1974
2177
  if (!await fileExists(manifestPath)) {
1975
2178
  throw new Error(
1976
2179
  `could not find ${manifestPath}. run \`root build\` before \`root start\`.`
1977
2180
  );
1978
2181
  }
1979
- const elementGraphJsonPath = path9.join(distDir, ".root/elements.json");
2182
+ const elementGraphJsonPath = path10.join(distDir, ".root/elements.json");
1980
2183
  if (!await fileExists(elementGraphJsonPath)) {
1981
2184
  throw new Error(
1982
2185
  `could not find ${elementGraphJsonPath}. run \`root build\` before \`root start\`.`
@@ -2016,7 +2219,7 @@ function rootProdServer404Middleware() {
2016
2219
  console.error(`\u2753 404 ${req.originalUrl}`);
2017
2220
  if (req.renderer) {
2018
2221
  const url = req.path;
2019
- const ext = path9.extname(url);
2222
+ const ext = path10.extname(url);
2020
2223
  if (!ext) {
2021
2224
  const renderer = req.renderer;
2022
2225
  const data = await renderer.render404({ currentPath: url });
@@ -2034,7 +2237,7 @@ function rootProdServer500Middleware() {
2034
2237
  console.error(String(err.stack || err));
2035
2238
  if (req.renderer) {
2036
2239
  const url = req.path;
2037
- const ext = path9.extname(url);
2240
+ const ext = path10.extname(url);
2038
2241
  if (!ext) {
2039
2242
  const renderer = req.renderer;
2040
2243
  const data = await renderer.renderError(err);
@@ -2093,7 +2296,10 @@ var CliRunner = class {
2093
2296
  program.command("dev [path]").description("starts the server in development mode").option(
2094
2297
  "--host <host>",
2095
2298
  "network address the server should listen on, e.g. 127.0.0.1"
2096
- ).action(dev);
2299
+ ).action((rootProjectDir, options) => {
2300
+ options.version = this.version;
2301
+ dev(rootProjectDir, options);
2302
+ });
2097
2303
  program.command("gae-deploy <appdir>").description(
2098
2304
  "appengine deploy utility that can optionally run healthchecks before diverting traffic to the new version and clean up old versions"
2099
2305
  ).option("--project <project>", "GCP project id").option("--prefix <prefix>", "prefix to append the version").option(
@@ -2137,4 +2343,4 @@ export {
2137
2343
  createProdServer,
2138
2344
  CliRunner
2139
2345
  };
2140
- //# sourceMappingURL=chunk-GSR74KEI.js.map
2346
+ //# sourceMappingURL=chunk-JTZWI4MH.js.map