@jxsuite/server 0.11.0 → 0.14.0
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/package.json +1 -1
- package/src/resolve.js +1 -1
- package/src/studio-api.js +17 -6
package/package.json
CHANGED
package/src/resolve.js
CHANGED
|
@@ -40,7 +40,7 @@ export async function handleResolve(req, root) {
|
|
|
40
40
|
const docAbsDir = resolve(root, "." + docDir);
|
|
41
41
|
for (const [k, v] of Object.entries(config)) {
|
|
42
42
|
if (typeof v === "string" && (v.startsWith("./") || v.startsWith("../"))) {
|
|
43
|
-
config[k] = "./" + relative(process.cwd(), resolve(docAbsDir, v));
|
|
43
|
+
config[k] = "./" + relative(process.cwd(), resolve(docAbsDir, v)).split("\\").join("/");
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
package/src/studio-api.js
CHANGED
|
@@ -203,11 +203,13 @@ export async function handleStudioApi(req, url, root, activeProjectRoot = null)
|
|
|
203
203
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
204
204
|
if (!home) return Response.json({ path: null });
|
|
205
205
|
const glob = new Bun.Glob(`**/${name}/project.json`);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
206
|
+
try {
|
|
207
|
+
for await (const match of glob.scan({ cwd: home, dot: false })) {
|
|
208
|
+
if (match.includes("node_modules") || match.includes(".Trash")) continue;
|
|
209
|
+
const abs = resolve(home, dirname(match));
|
|
210
|
+
return Response.json({ path: abs });
|
|
211
|
+
}
|
|
212
|
+
} catch {}
|
|
211
213
|
return Response.json({ path: null });
|
|
212
214
|
} catch (/** @type {any} */ e) {
|
|
213
215
|
return Response.json({ error: e.message }, { status: 500 });
|
|
@@ -353,7 +355,7 @@ export async function handleStudioApi(req, url, root, activeProjectRoot = null)
|
|
|
353
355
|
// Shorthand: infer type from value
|
|
354
356
|
return { name, type: typeof d, default: d };
|
|
355
357
|
}
|
|
356
|
-
return { name, type: d.type, default: d.default };
|
|
358
|
+
return { name, type: d.type, default: d.default, format: d.format };
|
|
357
359
|
}),
|
|
358
360
|
hasElements: Array.isArray(content.$elements) && content.$elements.length > 0,
|
|
359
361
|
});
|
|
@@ -859,6 +861,15 @@ export async function handleStudioApi(req, url, root, activeProjectRoot = null)
|
|
|
859
861
|
return Response.json({ diff });
|
|
860
862
|
}
|
|
861
863
|
|
|
864
|
+
if (gitCmd === "show" && req.method === "GET") {
|
|
865
|
+
const fp = url.searchParams.get("path");
|
|
866
|
+
const ref = url.searchParams.get("ref") || "HEAD";
|
|
867
|
+
if (!fp) return Response.json({ error: "Missing path" }, { status: 400 });
|
|
868
|
+
if (fp.includes("..")) return Response.json({ error: "Invalid path" }, { status: 400 });
|
|
869
|
+
const content = await runGit(["show", `${ref}:${fp}`]);
|
|
870
|
+
return Response.json({ content, format: fp.endsWith(".md") ? "markdown" : "json" });
|
|
871
|
+
}
|
|
872
|
+
|
|
862
873
|
if (gitCmd === "discard" && req.method === "POST") {
|
|
863
874
|
const { files } = await req.json();
|
|
864
875
|
if (!Array.isArray(files) || files.length === 0)
|