@gallop.software/studio 2.3.72 → 2.3.74

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.
@@ -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-BMEpS2q0.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-C8syz-vT.js"></script>
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -3903,6 +3903,23 @@ async function handleGenerateFavicon(request) {
3903
3903
  // src/handlers/featured-image.ts
3904
3904
  import puppeteer from "puppeteer";
3905
3905
  import fs10 from "fs/promises";
3906
+ function parseEnvFile(content) {
3907
+ const result = {};
3908
+ for (const line of content.split("\n")) {
3909
+ const trimmed = line.trim();
3910
+ if (!trimmed || trimmed.startsWith("#")) continue;
3911
+ const eqIndex = trimmed.indexOf("=");
3912
+ if (eqIndex > 0) {
3913
+ const key = trimmed.slice(0, eqIndex).trim();
3914
+ let value = trimmed.slice(eqIndex + 1).trim();
3915
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
3916
+ value = value.slice(1, -1);
3917
+ }
3918
+ result[key] = value;
3919
+ }
3920
+ }
3921
+ return result;
3922
+ }
3906
3923
  async function handleGenerateFeaturedImage(request) {
3907
3924
  const encoder = new TextEncoder();
3908
3925
  let customUrl;
@@ -4013,6 +4030,45 @@ async function handleGenerateFeaturedImage(request) {
4013
4030
  }
4014
4031
  });
4015
4032
  }
4033
+ async function handleGetFeaturedImageOptions() {
4034
+ try {
4035
+ const packageJsonPath2 = getWorkspacePath("package.json");
4036
+ const envLocalPath = getWorkspacePath(".env.local");
4037
+ const envProductionPath = getWorkspacePath(".env.production");
4038
+ let projectName = "featured-image";
4039
+ let devUrl = null;
4040
+ let productionUrl = null;
4041
+ try {
4042
+ const packageJsonContent = await fs10.readFile(packageJsonPath2, "utf8");
4043
+ const packageJson2 = JSON.parse(packageJsonContent);
4044
+ projectName = packageJson2.name || "featured-image";
4045
+ } catch {
4046
+ }
4047
+ try {
4048
+ const envLocalContent = await fs10.readFile(envLocalPath, "utf8");
4049
+ const envLocal = parseEnvFile(envLocalContent);
4050
+ devUrl = envLocal.NEXT_PUBLIC_PRODUCTION_URL || null;
4051
+ } catch {
4052
+ }
4053
+ try {
4054
+ const envProductionContent = await fs10.readFile(envProductionPath, "utf8");
4055
+ const envProduction = parseEnvFile(envProductionContent);
4056
+ productionUrl = envProduction.NEXT_PUBLIC_PRODUCTION_URL || null;
4057
+ } catch {
4058
+ }
4059
+ return jsonResponse({
4060
+ projectName,
4061
+ devUrl,
4062
+ productionUrl
4063
+ });
4064
+ } catch (error) {
4065
+ console.error("Get featured image options error:", error);
4066
+ return jsonResponse(
4067
+ { error: "Failed to get featured image options" },
4068
+ { status: 500 }
4069
+ );
4070
+ }
4071
+ }
4016
4072
  async function handleCheckFeaturedImage() {
4017
4073
  try {
4018
4074
  const packageJsonPath2 = getWorkspacePath("package.json");
@@ -4084,9 +4140,12 @@ async function startServer(options) {
4084
4140
  }
4085
4141
  const app = express();
4086
4142
  process.env.STUDIO_WORKSPACE = workspace;
4087
- const envStudioPath = join(workspace, ".env.studio");
4088
- if (existsSync(envStudioPath)) {
4089
- loadEnv({ path: envStudioPath, quiet: true });
4143
+ const envLocalPath = join(workspace, ".env.local");
4144
+ if (existsSync(envLocalPath)) {
4145
+ loadEnv({ path: envLocalPath, quiet: true });
4146
+ }
4147
+ if (!process.env.STUDIO_DEV_SITE_URL && process.env.NEXT_PUBLIC_PRODUCTION_URL) {
4148
+ process.env.STUDIO_DEV_SITE_URL = process.env.NEXT_PUBLIC_PRODUCTION_URL;
4090
4149
  }
4091
4150
  app.use((req, res, next) => {
4092
4151
  if (req.path === "/api/studio/upload") {
@@ -4112,6 +4171,10 @@ async function startServer(options) {
4112
4171
  "/api/studio/check-featured-image",
4113
4172
  wrapHandler(handleCheckFeaturedImage)
4114
4173
  );
4174
+ app.get(
4175
+ "/api/studio/featured-image-options",
4176
+ wrapHandler(handleGetFeaturedImageOptions)
4177
+ );
4115
4178
  app.post("/api/studio/upload", wrapRawHandler(handleUpload));
4116
4179
  app.post("/api/studio/create-folder", wrapHandler(handleCreateFolder));
4117
4180
  app.post("/api/studio/rename", wrapHandler(handleRename));