rwsdk 1.0.0-beta.3 → 1.0.0-beta.30

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 (126) hide show
  1. package/dist/lib/constants.d.mts +1 -0
  2. package/dist/lib/constants.mjs +7 -4
  3. package/dist/lib/e2e/browser.mjs +6 -2
  4. package/dist/lib/e2e/constants.d.mts +16 -0
  5. package/dist/lib/e2e/constants.mjs +77 -0
  6. package/dist/lib/e2e/dev.mjs +37 -49
  7. package/dist/lib/e2e/environment.d.mts +2 -0
  8. package/dist/lib/e2e/environment.mjs +202 -65
  9. package/dist/lib/e2e/index.d.mts +1 -0
  10. package/dist/lib/e2e/index.mjs +1 -0
  11. package/dist/lib/e2e/poll.d.mts +1 -1
  12. package/dist/lib/e2e/release.d.mts +1 -0
  13. package/dist/lib/e2e/release.mjs +16 -32
  14. package/dist/lib/e2e/tarball.mjs +2 -34
  15. package/dist/lib/e2e/testHarness.d.mts +36 -4
  16. package/dist/lib/e2e/testHarness.mjs +216 -128
  17. package/dist/lib/e2e/utils.d.mts +1 -0
  18. package/dist/lib/e2e/utils.mjs +15 -0
  19. package/dist/runtime/client/client.d.ts +35 -0
  20. package/dist/runtime/client/client.js +35 -0
  21. package/dist/runtime/client/navigation.d.ts +49 -0
  22. package/dist/runtime/client/navigation.js +80 -31
  23. package/dist/runtime/entries/clientSSR.d.ts +1 -0
  24. package/dist/runtime/entries/clientSSR.js +3 -0
  25. package/dist/runtime/entries/router.d.ts +1 -0
  26. package/dist/runtime/entries/routerClient.d.ts +1 -0
  27. package/dist/runtime/entries/routerClient.js +1 -0
  28. package/dist/runtime/entries/worker.d.ts +2 -0
  29. package/dist/runtime/entries/worker.js +2 -0
  30. package/dist/runtime/imports/__mocks__/use-client-lookup.d.ts +6 -0
  31. package/dist/runtime/imports/__mocks__/use-client-lookup.js +6 -0
  32. package/dist/runtime/lib/db/SqliteDurableObject.d.ts +2 -2
  33. package/dist/runtime/lib/db/SqliteDurableObject.js +2 -2
  34. package/dist/runtime/lib/db/createDb.d.ts +1 -2
  35. package/dist/runtime/lib/db/createDb.js +4 -0
  36. package/dist/runtime/lib/db/typeInference/builders/alterTable.d.ts +13 -3
  37. package/dist/runtime/lib/db/typeInference/builders/columnDefinition.d.ts +35 -21
  38. package/dist/runtime/lib/db/typeInference/builders/createTable.d.ts +9 -2
  39. package/dist/runtime/lib/db/typeInference/database.d.ts +16 -2
  40. package/dist/runtime/lib/db/typeInference/typetests/alterTable.typetest.js +80 -5
  41. package/dist/runtime/lib/db/typeInference/typetests/createTable.typetest.js +104 -2
  42. package/dist/runtime/lib/db/typeInference/typetests/testUtils.d.ts +1 -0
  43. package/dist/runtime/lib/db/typeInference/utils.d.ts +59 -9
  44. package/dist/runtime/lib/links.d.ts +18 -7
  45. package/dist/runtime/lib/links.js +70 -24
  46. package/dist/runtime/lib/links.test.js +20 -0
  47. package/dist/runtime/lib/manifest.d.ts +1 -1
  48. package/dist/runtime/lib/manifest.js +7 -4
  49. package/dist/runtime/lib/realtime/client.js +8 -2
  50. package/dist/runtime/lib/realtime/worker.d.ts +1 -1
  51. package/dist/runtime/lib/router.d.ts +147 -33
  52. package/dist/runtime/lib/router.js +169 -20
  53. package/dist/runtime/lib/router.test.js +241 -0
  54. package/dist/runtime/lib/stitchDocumentAndAppStreams.d.ts +66 -0
  55. package/dist/runtime/lib/stitchDocumentAndAppStreams.js +302 -35
  56. package/dist/runtime/lib/stitchDocumentAndAppStreams.test.d.ts +1 -0
  57. package/dist/runtime/lib/stitchDocumentAndAppStreams.test.js +418 -0
  58. package/dist/runtime/lib/{rwContext.d.ts → types.d.ts} +1 -0
  59. package/dist/runtime/lib/types.js +1 -0
  60. package/dist/runtime/render/renderDocumentHtmlStream.d.ts +1 -1
  61. package/dist/runtime/render/renderToStream.d.ts +4 -2
  62. package/dist/runtime/render/renderToStream.js +53 -24
  63. package/dist/runtime/render/renderToString.d.ts +3 -1
  64. package/dist/runtime/requestInfo/types.d.ts +4 -1
  65. package/dist/runtime/requestInfo/utils.d.ts +9 -0
  66. package/dist/runtime/requestInfo/utils.js +44 -0
  67. package/dist/runtime/requestInfo/worker.js +3 -2
  68. package/dist/runtime/script.d.ts +1 -3
  69. package/dist/runtime/script.js +1 -10
  70. package/dist/runtime/state.d.ts +3 -0
  71. package/dist/runtime/state.js +13 -0
  72. package/dist/runtime/worker.d.ts +3 -1
  73. package/dist/runtime/worker.js +26 -0
  74. package/dist/scripts/debug-sync.mjs +18 -20
  75. package/dist/scripts/worker-run.d.mts +1 -1
  76. package/dist/scripts/worker-run.mjs +52 -113
  77. package/dist/use-synced-state/SyncStateServer.d.mts +20 -0
  78. package/dist/use-synced-state/SyncStateServer.mjs +124 -0
  79. package/dist/use-synced-state/__tests__/SyncStateServer.test.d.mts +1 -0
  80. package/dist/use-synced-state/__tests__/SyncStateServer.test.mjs +109 -0
  81. package/dist/use-synced-state/__tests__/useSyncState.test.d.ts +1 -0
  82. package/dist/use-synced-state/__tests__/useSyncState.test.js +115 -0
  83. package/dist/use-synced-state/__tests__/useSyncedState.test.d.ts +1 -0
  84. package/dist/use-synced-state/__tests__/useSyncedState.test.js +115 -0
  85. package/dist/use-synced-state/__tests__/worker.test.d.mts +1 -0
  86. package/dist/use-synced-state/__tests__/worker.test.mjs +69 -0
  87. package/dist/use-synced-state/client.d.ts +28 -0
  88. package/dist/use-synced-state/client.js +39 -0
  89. package/dist/use-synced-state/constants.d.mts +1 -0
  90. package/dist/use-synced-state/constants.mjs +1 -0
  91. package/dist/use-synced-state/useSyncState.d.ts +20 -0
  92. package/dist/use-synced-state/useSyncState.js +58 -0
  93. package/dist/use-synced-state/useSyncedState.d.ts +20 -0
  94. package/dist/use-synced-state/useSyncedState.js +58 -0
  95. package/dist/use-synced-state/worker.d.mts +14 -0
  96. package/dist/use-synced-state/worker.mjs +73 -0
  97. package/dist/vite/buildApp.mjs +34 -2
  98. package/dist/vite/configPlugin.mjs +8 -14
  99. package/dist/vite/constants.d.mts +1 -0
  100. package/dist/vite/constants.mjs +1 -0
  101. package/dist/vite/directiveModulesDevPlugin.mjs +1 -1
  102. package/dist/vite/envResolvers.d.mts +11 -0
  103. package/dist/vite/envResolvers.mjs +20 -0
  104. package/dist/vite/getViteEsbuild.mjs +2 -1
  105. package/dist/vite/hmrStabilityPlugin.d.mts +2 -0
  106. package/dist/vite/hmrStabilityPlugin.mjs +68 -0
  107. package/dist/vite/knownDepsResolverPlugin.d.mts +0 -6
  108. package/dist/vite/knownDepsResolverPlugin.mjs +1 -12
  109. package/dist/vite/linkerPlugin.d.mts +2 -1
  110. package/dist/vite/linkerPlugin.mjs +11 -3
  111. package/dist/vite/linkerPlugin.test.mjs +15 -0
  112. package/dist/vite/miniflareHMRPlugin.mjs +1 -38
  113. package/dist/vite/moveStaticAssetsPlugin.mjs +14 -4
  114. package/dist/vite/redwoodPlugin.mjs +6 -10
  115. package/dist/vite/runDirectivesScan.mjs +59 -14
  116. package/dist/vite/ssrBridgePlugin.mjs +122 -34
  117. package/dist/vite/ssrBridgeWrapPlugin.d.mts +2 -0
  118. package/dist/vite/ssrBridgeWrapPlugin.mjs +85 -0
  119. package/dist/vite/staleDepRetryPlugin.d.mts +2 -0
  120. package/dist/vite/staleDepRetryPlugin.mjs +69 -0
  121. package/dist/vite/statePlugin.d.mts +4 -0
  122. package/dist/vite/statePlugin.mjs +62 -0
  123. package/package.json +26 -10
  124. package/dist/vite/manifestPlugin.d.mts +0 -4
  125. package/dist/vite/manifestPlugin.mjs +0 -63
  126. /package/dist/runtime/lib/{rwContext.js → links.test.d.ts} +0 -0
@@ -7,5 +7,6 @@ export declare const VENDOR_CLIENT_BARREL_PATH: string;
7
7
  export declare const VENDOR_SERVER_BARREL_PATH: string;
8
8
  export declare const VENDOR_CLIENT_BARREL_EXPORT_PATH = "rwsdk/__vendor_client_barrel";
9
9
  export declare const VENDOR_SERVER_BARREL_EXPORT_PATH = "rwsdk/__vendor_server_barrel";
10
+ export declare const RW_STATE_EXPORT_PATH = "rwsdk/__state";
10
11
  export declare const INTERMEDIATE_SSR_BRIDGE_PATH: string;
11
12
  export declare const CLIENT_MANIFEST_RELATIVE_PATH: string;
@@ -1,13 +1,16 @@
1
- import path, { resolve } from "node:path";
2
- const __dirname = new URL(".", import.meta.url).pathname;
1
+ import { fileURLToPath } from "url";
2
+ import { dirname, resolve } from "path";
3
+ const __filename = fileURLToPath(import.meta.url);
4
+ const __dirname = dirname(__filename);
3
5
  export const ROOT_DIR = resolve(__dirname, "..", "..");
4
6
  export const SRC_DIR = resolve(ROOT_DIR, "src");
5
7
  export const DIST_DIR = resolve(ROOT_DIR, "dist");
6
8
  export const VITE_DIR = resolve(ROOT_DIR, "src", "vite");
7
9
  export const INTERMEDIATES_OUTPUT_DIR = resolve(DIST_DIR, "__intermediate_builds");
8
- export const VENDOR_CLIENT_BARREL_PATH = path.resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-client-barrel.js");
9
- export const VENDOR_SERVER_BARREL_PATH = path.resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-server-barrel.js");
10
+ export const VENDOR_CLIENT_BARREL_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-client-barrel.js");
11
+ export const VENDOR_SERVER_BARREL_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "rwsdk-vendor-server-barrel.js");
10
12
  export const VENDOR_CLIENT_BARREL_EXPORT_PATH = "rwsdk/__vendor_client_barrel";
11
13
  export const VENDOR_SERVER_BARREL_EXPORT_PATH = "rwsdk/__vendor_server_barrel";
14
+ export const RW_STATE_EXPORT_PATH = "rwsdk/__state";
12
15
  export const INTERMEDIATE_SSR_BRIDGE_PATH = resolve(INTERMEDIATES_OUTPUT_DIR, "ssr", "ssr_bridge.js");
13
16
  export const CLIENT_MANIFEST_RELATIVE_PATH = resolve("dist", "client", ".vite", "manifest.json");
@@ -1,14 +1,18 @@
1
1
  import { computeExecutablePath, detectBrowserPlatform, install, Browser as PuppeteerBrowser, resolveBuildId, } from "@puppeteer/browsers";
2
2
  import debug from "debug";
3
3
  import { mkdirp, pathExists } from "fs-extra";
4
- import * as os from "os";
5
4
  import { join } from "path";
6
5
  import puppeteer from "puppeteer-core";
6
+ import { ensureTmpDir } from "./utils.mjs";
7
7
  const log = debug("rwsdk:e2e:browser");
8
8
  /**
9
9
  * Launch a browser instance
10
10
  */
11
11
  export async function launchBrowser(browserPath, headless = true) {
12
+ // Define a consistent cache directory path in system temp folder
13
+ const rwCacheDir = join(await ensureTmpDir(), "redwoodjs-smoke-test-cache");
14
+ await mkdirp(rwCacheDir);
15
+ log("Using cache directory: %s", rwCacheDir);
12
16
  // Get browser path if not provided
13
17
  if (!browserPath) {
14
18
  log("Getting browser executable path");
@@ -41,7 +45,7 @@ export async function getBrowserPath(testOptions) {
41
45
  }
42
46
  log("Detected platform: %s", platform);
43
47
  // Define a consistent cache directory path in system temp folder
44
- const rwCacheDir = join(os.tmpdir(), "redwoodjs-smoke-test-cache");
48
+ const rwCacheDir = join(await ensureTmpDir(), "redwoodjs-smoke-test-cache");
45
49
  await mkdirp(rwCacheDir);
46
50
  log("Using cache directory: %s", rwCacheDir);
47
51
  // Determine browser type based on headless option
@@ -0,0 +1,16 @@
1
+ export declare const IS_CI: boolean;
2
+ export declare const RWSDK_SKIP_DEV: boolean;
3
+ export declare const RWSDK_SKIP_DEPLOY: boolean;
4
+ export declare const IS_DEBUG_MODE: boolean;
5
+ export declare const SETUP_PLAYGROUND_ENV_TIMEOUT: number;
6
+ export declare const DEPLOYMENT_TIMEOUT: number;
7
+ export declare const DEPLOYMENT_MIN_TRIES: number;
8
+ export declare const DEPLOYMENT_CHECK_TIMEOUT: number;
9
+ export declare const PUPPETEER_TIMEOUT: number;
10
+ export declare const HYDRATION_TIMEOUT: number;
11
+ export declare const DEV_SERVER_TIMEOUT: number;
12
+ export declare const DEV_SERVER_MIN_TRIES: number;
13
+ export declare const SETUP_WAIT_TIMEOUT: number;
14
+ export declare const TEST_MAX_RETRIES: number;
15
+ export declare const TEST_MAX_RETRIES_PER_CODE: number;
16
+ export declare const INSTALL_DEPENDENCIES_RETRIES: number;
@@ -0,0 +1,77 @@
1
+ export const IS_CI = !!((process.env.CI && !process.env.NOT_CI) ||
2
+ process.env.GITHUB_ACTIONS ||
3
+ process.env.GITLAB_CI ||
4
+ process.env.CIRCLECI ||
5
+ process.env.TRAVIS ||
6
+ process.env.JENKINS_URL ||
7
+ process.env.NETLIFY);
8
+ export const RWSDK_SKIP_DEV = Boolean(process.env.RWSDK_SKIP_DEV);
9
+ export const RWSDK_SKIP_DEPLOY = process.env.RWSDK_SKIP_DEPLOY === "true" ||
10
+ process.env.RWSDK_SKIP_DEPLOY === "1";
11
+ export const IS_DEBUG_MODE = process.env.RWSDK_E2E_DEBUG
12
+ ? process.env.RWSDK_E2E_DEBUG === "true"
13
+ : !IS_CI;
14
+ export const SETUP_PLAYGROUND_ENV_TIMEOUT = process.env
15
+ .RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT
16
+ ? parseInt(process.env.RWSDK_SETUP_PLAYGROUND_ENV_TIMEOUT, 10)
17
+ : IS_DEBUG_MODE
18
+ ? 10 * 60 * 1000
19
+ : 15 * 60 * 1000;
20
+ export const DEPLOYMENT_TIMEOUT = process.env.RWSDK_DEPLOYMENT_TIMEOUT
21
+ ? parseInt(process.env.RWSDK_DEPLOYMENT_TIMEOUT, 10)
22
+ : IS_DEBUG_MODE
23
+ ? 5 * 30 * 1000
24
+ : 5 * 60 * 1000;
25
+ export const DEPLOYMENT_MIN_TRIES = process.env.RWSDK_DEPLOYMENT_MIN_TRIES
26
+ ? parseInt(process.env.RWSDK_DEPLOYMENT_MIN_TRIES, 10)
27
+ : IS_DEBUG_MODE
28
+ ? 1
29
+ : 5;
30
+ export const DEPLOYMENT_CHECK_TIMEOUT = process.env
31
+ .RWSDK_DEPLOYMENT_CHECK_TIMEOUT
32
+ ? parseInt(process.env.RWSDK_DEPLOYMENT_CHECK_TIMEOUT, 10)
33
+ : IS_DEBUG_MODE
34
+ ? 30 * 1000
35
+ : 5 * 60 * 1000;
36
+ export const PUPPETEER_TIMEOUT = process.env.RWSDK_PUPPETEER_TIMEOUT
37
+ ? parseInt(process.env.RWSDK_PUPPETEER_TIMEOUT, 10)
38
+ : IS_DEBUG_MODE
39
+ ? 30 * 1000
40
+ : 60 * 1000 * 2;
41
+ export const HYDRATION_TIMEOUT = process.env.RWSDK_HYDRATION_TIMEOUT
42
+ ? parseInt(process.env.RWSDK_HYDRATION_TIMEOUT, 10)
43
+ : IS_DEBUG_MODE
44
+ ? 2000
45
+ : 5000;
46
+ export const DEV_SERVER_TIMEOUT = process.env.RWSDK_DEV_SERVER_TIMEOUT
47
+ ? parseInt(process.env.RWSDK_DEV_SERVER_TIMEOUT, 10)
48
+ : IS_DEBUG_MODE
49
+ ? 60 * 1000
50
+ : 5 * 60 * 1000;
51
+ export const DEV_SERVER_MIN_TRIES = process.env.RWSDK_DEV_SERVER_MIN_TRIES
52
+ ? parseInt(process.env.RWSDK_DEV_SERVER_MIN_TRIES, 10)
53
+ : IS_DEBUG_MODE
54
+ ? 1
55
+ : 5;
56
+ export const SETUP_WAIT_TIMEOUT = process.env.RWSDK_SETUP_WAIT_TIMEOUT
57
+ ? parseInt(process.env.RWSDK_SETUP_WAIT_TIMEOUT, 10)
58
+ : IS_DEBUG_MODE
59
+ ? 60 * 1000
60
+ : 10 * 60 * 1000;
61
+ export const TEST_MAX_RETRIES = process.env.RWSDK_TEST_MAX_RETRIES
62
+ ? parseInt(process.env.RWSDK_TEST_MAX_RETRIES, 10)
63
+ : IS_DEBUG_MODE
64
+ ? 1
65
+ : 10;
66
+ export const TEST_MAX_RETRIES_PER_CODE = process.env
67
+ .RWSDK_TEST_MAX_RETRIES_PER_CODE
68
+ ? parseInt(process.env.RWSDK_TEST_MAX_RETRIES_PER_CODE, 10)
69
+ : IS_DEBUG_MODE
70
+ ? 0
71
+ : 6;
72
+ export const INSTALL_DEPENDENCIES_RETRIES = process.env
73
+ .RWSDK_INSTALL_DEPENDENCIES_RETRIES
74
+ ? parseInt(process.env.RWSDK_INSTALL_DEPENDENCIES_RETRIES, 10)
75
+ : IS_DEBUG_MODE
76
+ ? 1
77
+ : 10;
@@ -1,6 +1,6 @@
1
1
  import debug from "debug";
2
2
  import { setTimeout as sleep } from "node:timers/promises";
3
- import { $ } from "../../lib/$.mjs";
3
+ import { $, $sh } from "../../lib/$.mjs";
4
4
  import { poll } from "./poll.mjs";
5
5
  const DEV_SERVER_CHECK_TIMEOUT = process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT
6
6
  ? parseInt(process.env.RWSDK_DEV_SERVER_CHECK_TIMEOUT, 10)
@@ -21,43 +21,30 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
21
21
  return;
22
22
  }
23
23
  console.log("Stopping development server...");
24
- try {
25
- // Send a regular termination signal to the entire process group first
26
- process.kill(-devProcess.pid, "SIGTERM");
27
- }
28
- catch (e) {
29
- log("Could not send SIGTERM to dev server process group: %O", e);
30
- }
31
- // Wait for the process to terminate with a timeout
32
- const terminationTimeout = 5000; // 5 seconds
33
- const processExitPromise = devProcess.catch(() => {
34
- // We expect this promise to reject when the process is killed,
35
- // so we catch and ignore the error.
36
- });
37
- const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(undefined), terminationTimeout));
38
- await Promise.race([processExitPromise, timeoutPromise]);
39
- // Check if the process is still alive. We can't reliably check exitCode
40
- // on a detached process, so we try sending a signal 0, which errors
41
- // if the process doesn't exist.
42
- let isAlive = true;
43
- try {
44
- // Sending signal 0 doesn't kill the process, but checks if it exists
45
- process.kill(-devProcess.pid, 0);
46
- }
47
- catch (e) {
48
- isAlive = false;
24
+ if (process.platform === "win32") {
25
+ try {
26
+ await $sh(`taskkill /pid ${devProcess.pid} /f /t`);
27
+ }
28
+ catch (err) {
29
+ log("Failed to kill process tree with taskkill:", err);
30
+ }
49
31
  }
50
- // If not terminated within timeout, force kill the entire process group
51
- if (isAlive) {
52
- log("Dev server process did not terminate within timeout, force killing with SIGKILL");
53
- console.log("⚠️ Development server not responding after 5 seconds timeout, force killing...");
32
+ else {
33
+ // On Unix-like systems, we kill the entire process group by sending a signal
34
+ // to the negative PID. This is the equivalent of the `/t` flag for `taskkill` on Windows.
35
+ // This relies on `detached: true` being set in the execa options, which makes
36
+ // the child process the leader of a new process group.
54
37
  try {
55
38
  process.kill(-devProcess.pid, "SIGKILL");
56
39
  }
57
40
  catch (e) {
58
- log("Could not send SIGKILL to dev server process group: %O", e);
41
+ log("Failed to kill process group. This may happen if the process already exited. %O", e);
59
42
  }
60
43
  }
44
+ await devProcess.catch(() => {
45
+ // We expect this promise to reject when the process is killed,
46
+ // so we catch and ignore the error.
47
+ });
61
48
  console.log("Development server stopped");
62
49
  };
63
50
  try {
@@ -86,20 +73,23 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
86
73
  };
87
74
  const pm = getPackageManagerCommand(packageManager);
88
75
  // Use the provided cwd if available
89
- devProcess = $({
76
+ devProcess = $(pm, ["run", "dev"], {
90
77
  all: true,
91
- detached: true, // Run in a new process group so we can kill the entire group
92
- cleanup: false, // Don't auto-kill on exit
78
+ // On Windows, detached: true prevents stdio from being captured.
79
+ // On Unix, it's required for reliable cleanup by killing the process group.
80
+ detached: process.platform !== "win32",
81
+ cleanup: true, // Let execa handle cleanup
82
+ forceKillAfterTimeout: 2000, // Force kill if graceful shutdown fails
93
83
  cwd: cwd || process.cwd(), // Use provided directory or current directory
94
84
  env, // Pass the updated environment variables
95
85
  stdio: "pipe", // Ensure streams are piped
96
- }) `${pm} run dev`;
86
+ });
97
87
  devProcess.catch((error) => {
98
88
  if (!isErrorExpected) {
99
89
  // Don't re-throw. The error will be handled gracefully by the polling
100
90
  // logic in `waitForUrl`, which will detect that the process has exited.
101
91
  // Re-throwing here would cause an unhandled promise rejection.
102
- log("Dev server process exited unexpectedly:", error.shortMessage);
92
+ log("Dev server process exited unexpectedly: %O", error);
103
93
  }
104
94
  });
105
95
  log("Development server process spawned in directory: %s", cwd || process.cwd());
@@ -109,9 +99,9 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
109
99
  // Listen for all output to get the URL
110
100
  const handleOutput = (data, source) => {
111
101
  const output = data.toString();
112
- console.log(output);
102
+ // Raw output for debugging
103
+ process.stdout.write(`[dev:${source}] ` + output);
113
104
  allOutput += output; // Accumulate all output
114
- log("Received output from %s: %s", source, output.replace(/\n/g, "\\n"));
115
105
  if (!url) {
116
106
  // Multiple patterns to catch different package manager outputs
117
107
  const patterns = [
@@ -131,28 +121,17 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
131
121
  ];
132
122
  for (const pattern of patterns) {
133
123
  const match = output.match(pattern);
134
- log("Testing pattern %s against output: %s", pattern.source, output.replace(/\n/g, "\\n"));
135
124
  if (match) {
136
- log("Pattern matched: %s, groups: %o", pattern.source, match);
137
125
  if (match[1] && match[1].startsWith("http")) {
138
126
  url = match[1];
139
- log("Found development server URL with pattern %s: %s", pattern.source, url);
140
127
  break;
141
128
  }
142
129
  else if (match[1] && /^\d+$/.test(match[1])) {
143
130
  url = `http://localhost:${match[1]}`;
144
- log("Found development server URL with port pattern %s: %s", pattern.source, url);
145
131
  break;
146
132
  }
147
133
  }
148
134
  }
149
- // Log potential matches for debugging
150
- if (!url &&
151
- (output.includes("localhost") ||
152
- output.includes("Local") ||
153
- output.includes("server"))) {
154
- log("Potential URL pattern found but not matched: %s", output.trim());
155
- }
156
135
  }
157
136
  };
158
137
  // Listen to all possible output streams
@@ -163,6 +142,15 @@ export async function runDevServer(packageManager = "pnpm", cwd) {
163
142
  // Also try listening to the raw process output
164
143
  if (devProcess.child) {
165
144
  log("Setting up child process stream listeners");
145
+ devProcess.child.on("spawn", () => {
146
+ log("Child process spawned successfully.");
147
+ });
148
+ devProcess.child.on("error", (err) => {
149
+ log("Child process error: %O", err);
150
+ });
151
+ devProcess.child.on("exit", (code, signal) => {
152
+ log("Child process exited with code %s and signal %s", code, signal);
153
+ });
166
154
  devProcess.child.stdout?.on("data", (data) => handleOutput(data, "child.stdout"));
167
155
  devProcess.child.stderr?.on("data", (data) => handleOutput(data, "child.stderr"));
168
156
  }
@@ -1,5 +1,7 @@
1
1
  import tmp from "tmp-promise";
2
2
  import { PackageManager } from "./types.mjs";
3
+ export declare function getFilesRecursively(directory: string): Promise<string[]>;
4
+ export declare function getDirectoryHash(directory: string): Promise<string>;
3
5
  /**
4
6
  * Copy project to a temporary directory with a unique name
5
7
  */