@gallop.software/studio 2.1.7 → 2.1.9
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/dist/client/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
12
12
|
}
|
|
13
13
|
</style>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-Cug_vb5C.js"></script>
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
|
17
17
|
<div id="root"></div>
|
package/dist/server/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { fileURLToPath } from "url";
|
|
|
7
7
|
import { dirname } from "path";
|
|
8
8
|
import { existsSync, readFileSync } from "fs";
|
|
9
9
|
import { config as loadEnv } from "dotenv";
|
|
10
|
+
import { createServer } from "net";
|
|
10
11
|
|
|
11
12
|
// src/handlers/list.ts
|
|
12
13
|
import { promises as fs4 } from "fs";
|
|
@@ -2306,8 +2307,34 @@ async function handleGenerateFavicon(request) {
|
|
|
2306
2307
|
// src/server/index.ts
|
|
2307
2308
|
var __filename = fileURLToPath(import.meta.url);
|
|
2308
2309
|
var __dirname = dirname(__filename);
|
|
2310
|
+
function isPortAvailable(port) {
|
|
2311
|
+
return new Promise((resolve2) => {
|
|
2312
|
+
const server = createServer();
|
|
2313
|
+
server.once("error", () => {
|
|
2314
|
+
resolve2(false);
|
|
2315
|
+
});
|
|
2316
|
+
server.once("listening", () => {
|
|
2317
|
+
server.close();
|
|
2318
|
+
resolve2(true);
|
|
2319
|
+
});
|
|
2320
|
+
server.listen(port);
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
async function findAvailablePort(startPort, maxAttempts = 10) {
|
|
2324
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
2325
|
+
const port = startPort + i;
|
|
2326
|
+
if (await isPortAvailable(port)) {
|
|
2327
|
+
return port;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
throw new Error(`No available port found between ${startPort} and ${startPort + maxAttempts - 1}`);
|
|
2331
|
+
}
|
|
2309
2332
|
async function startServer(options) {
|
|
2310
|
-
const { port, workspace, open } = options;
|
|
2333
|
+
const { port: requestedPort, workspace, open } = options;
|
|
2334
|
+
const port = await findAvailablePort(requestedPort);
|
|
2335
|
+
if (port !== requestedPort) {
|
|
2336
|
+
console.log(`Port ${requestedPort} is in use, using port ${port} instead`);
|
|
2337
|
+
}
|
|
2311
2338
|
const app = express();
|
|
2312
2339
|
process.env.STUDIO_WORKSPACE = workspace;
|
|
2313
2340
|
const envLocalPath = join(workspace, ".env.local");
|
|
@@ -2345,10 +2372,10 @@ async function startServer(options) {
|
|
|
2345
2372
|
const htmlPath = join(clientDir, "index.html");
|
|
2346
2373
|
if (existsSync(htmlPath)) {
|
|
2347
2374
|
let html = readFileSync(htmlPath, "utf-8");
|
|
2348
|
-
const
|
|
2375
|
+
const siteUrl = process.env.NEXT_PUBLIC_PRODUCTION_URL || "";
|
|
2349
2376
|
const script = `<script>
|
|
2350
2377
|
window.__STUDIO_WORKSPACE__ = ${JSON.stringify(workspace)};
|
|
2351
|
-
window.
|
|
2378
|
+
window.__STUDIO_SITE_URL__ = ${JSON.stringify(siteUrl)};
|
|
2352
2379
|
</script>`;
|
|
2353
2380
|
html = html.replace("</head>", `${script}</head>`);
|
|
2354
2381
|
res.type("html").send(html);
|