Integrate graphics, RAW, audio and CAD Craft tools with protected saves

This commit is contained in:
SantaSpeen committed 2026-10-22 19:48:16 +03:00
1 parent 6e36b6c4b7
commit 852140c3a7
24 files changed
+600 -74

No files matched your search

+13 -3
View File
@@ -77,9 +77,19 @@ const currentView = computed(() => {
return FileListing;
}
if (
["wordcraft", "gridcraft", "deckcraft", "pdfcraft"].includes(
String(route.query.craft)
)
[
"wordcraft",
"gridcraft",
"deckcraft",
"pdfcraft",
"photocraft",
"vectorcraft",
"lightcraft",
"designcraft",
"figcraft",
"soundcraft",
"cadcraft",
].includes(String(route.query.craft))
)
return CraftEditor;
if (
+31 -15
View File
@@ -85,7 +85,12 @@ import { useAuthStore } from "@/stores/auth";
import { useAddonsStore } from "@/stores/addons";
import { baseURL } from "@/utils/constants";
import { fetchURL, StatusError } from "@/api/utils";
import { craftMessage, safeCraftName } from "@/utils/craft";
import {
addonAccepts,
craftSaveExtension,
craftMessage,
safeCraftName,
} from "@/utils/craft";
const route = useRoute(),
store = useAddonsStore(),
files = useFileStore(),
@@ -99,9 +104,7 @@ const file = files.req,
: file?.path || "";
const currentPath = ref(sourcePath),
currentName = ref(sourcePath.split("/").pop() || "");
const nativeExtension = computed(
() => store.items.find((item) => item.id === id)?.extension || ""
);
const activeTool = computed(() => store.items.find((item) => item.id === id));
const title = computed(
() => store.items.find((item) => item.id === id)?.name || id
);
@@ -214,7 +217,11 @@ async function persist() {
window.location.origin
);
authExpired.value = false;
if (payload.path.toLowerCase().endsWith(nativeExtension.value)) {
if (
id !== "lightcraft" &&
activeTool.value &&
addonAccepts(activeTool.value, payload.name)
) {
tag = response.headers.get("ETag") || "";
currentPath.value = payload.path;
currentName.value = payload.name;
@@ -247,9 +254,10 @@ async function persist() {
}
function confirmSaveAs() {
if (!pending.value) return;
const ext = pending.value.name.toLowerCase().endsWith(".pdf")
? ".pdf"
: nativeExtension.value;
const ext =
activeTool.value &&
craftSaveExtension(activeTool.value, pending.value.name);
if (!ext) return;
const name = safeCraftName(newName.value, ext);
if (!name) {
error.value = t("addons.invalidName");
@@ -307,15 +315,21 @@ function receive(event: MessageEvent) {
error.value = t("addons.tooLarge");
return;
}
const extension = message.name?.toLowerCase().endsWith(".pdf")
? ".pdf"
: nativeExtension.value;
const name = safeCraftName(message.name, extension);
const extension =
activeTool.value && craftSaveExtension(activeTool.value, message.name);
if (!extension) {
error.value = t("addons.invalidName");
return;
}
let name = safeCraftName(message.name, extension);
if (!name) {
error.value = t("addons.invalidName");
return;
}
const create = !!message.saveAs || name !== currentName.value;
if (id === "lightcraft" && name === currentName.value)
name = name.slice(0, -extension.length) + "-edited" + extension;
const create =
id === "lightcraft" || !!message.saveAs || name !== currentName.value;
pending.value = {
bytes: message.bytes,
name,
@@ -346,7 +360,7 @@ onMounted(async () => {
!addon ||
!auth.user?.perm.modify ||
!auth.user?.perm.download ||
!sourcePath.toLowerCase().endsWith(addon.extension)
!addonAccepts(addon, sourcePath)
)
throw new Error(t("addons.unavailable"));
// Bound streamed data even when Content-Length is missing.
@@ -387,7 +401,9 @@ onMounted(async () => {
id +
"/" +
addon.build +
"/index.html?host=parent&author=" +
"/index.html?host=parent" +
(id === "lightcraft" ? "&store=memory" : "") +
"&author=" +
encodeURIComponent(auth.user.profileName || auth.user.username);
startup = setTimeout(() => {
error.value = t("addons.startFailed");