@rslsp1/fa-app-tools 1.3.0 → 1.3.1
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.
|
@@ -61,14 +61,22 @@ async function hfUploadProject(zipBase64, name, token) {
|
|
|
61
61
|
const debugInfo = JSON.stringify({ uploadMode: fileInfo?.uploadMode, hasUploadUrl: !!fileInfo?.uploadUrl, hasVerifyUrl: !!fileInfo?.verifyUrl, headerKeys: Object.keys(fileInfo?.header || {}), verifyHeaderKeys: Object.keys(fileInfo?.verifyHeader || {}) });
|
|
62
62
|
if (!fileInfo?.uploadMode) throw new Error(`HF preupload kein fileInfo: ${JSON.stringify(preData)}`);
|
|
63
63
|
if (fileInfo.uploadMode === "lfs" && fileInfo.uploadUrl) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
let uploadStatus = 0;
|
|
65
|
+
try {
|
|
66
|
+
const uploadRes = await fetch(fileInfo.uploadUrl, {
|
|
67
|
+
method: "PUT",
|
|
68
|
+
redirect: "follow",
|
|
69
|
+
headers: { "Content-Type": "application/octet-stream", ...fileInfo.header || {} },
|
|
70
|
+
body: bytes
|
|
71
|
+
});
|
|
72
|
+
uploadStatus = uploadRes.status;
|
|
73
|
+
if (!uploadRes.ok) {
|
|
74
|
+
const uploadErr = await uploadRes.text().catch(() => "");
|
|
75
|
+
throw new Error(`HF LFS upload failed: ${uploadRes.status} \u2014 ${uploadErr.slice(0, 300)}`);
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (uploadStatus === 0) throw new Error(`HF LFS upload network error (CORS/redirect?): ${e.message}`);
|
|
79
|
+
throw e;
|
|
72
80
|
}
|
|
73
81
|
if (fileInfo.verifyUrl) {
|
|
74
82
|
const verifyRes = await fetch(fileInfo.verifyUrl, {
|
|
@@ -96,6 +104,24 @@ async function hfUploadProject(zipBase64, name, token) {
|
|
|
96
104
|
}
|
|
97
105
|
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size, isLfs: true };
|
|
98
106
|
}
|
|
107
|
+
async function hfUploadProjectForm(zipBase64, name, token) {
|
|
108
|
+
const filename = name.endsWith(".zip") ? name : `${name}.zip`;
|
|
109
|
+
const binary = atob(zipBase64);
|
|
110
|
+
const bytes = new Uint8Array(binary.length);
|
|
111
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
112
|
+
const blob = new Blob([bytes], { type: "application/zip" });
|
|
113
|
+
const form = new FormData();
|
|
114
|
+
form.append("files[]", blob, filename);
|
|
115
|
+
const res = await fetch(
|
|
116
|
+
`${HF_BASE}/api/datasets/${HF_REPO}/upload/main`,
|
|
117
|
+
{ method: "POST", headers: { Authorization: `Bearer ${token}` }, body: form }
|
|
118
|
+
);
|
|
119
|
+
if (!res.ok) {
|
|
120
|
+
const err = await res.text().catch(() => "");
|
|
121
|
+
throw new Error(`HF FormData upload failed: ${res.status} \u2014 ${err.slice(0, 300)}`);
|
|
122
|
+
}
|
|
123
|
+
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size: bytes.length, isLfs: true };
|
|
124
|
+
}
|
|
99
125
|
async function hfDeleteProject(path, token) {
|
|
100
126
|
const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
101
127
|
method: "POST",
|
|
@@ -115,5 +141,6 @@ export {
|
|
|
115
141
|
hfListProjects,
|
|
116
142
|
hfDownloadProject,
|
|
117
143
|
hfUploadProject,
|
|
144
|
+
hfUploadProjectForm,
|
|
118
145
|
hfDeleteProject
|
|
119
146
|
};
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
hfDownloadProject,
|
|
6
6
|
hfListProjects,
|
|
7
7
|
hfUploadProject,
|
|
8
|
+
hfUploadProjectForm,
|
|
8
9
|
setHFToken
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-4MIV2ED3.mjs";
|
|
10
11
|
export {
|
|
11
12
|
HF_TOKEN_KEY,
|
|
12
13
|
getHFToken,
|
|
@@ -14,5 +15,6 @@ export {
|
|
|
14
15
|
hfDownloadProject,
|
|
15
16
|
hfListProjects,
|
|
16
17
|
hfUploadProject,
|
|
18
|
+
hfUploadProjectForm,
|
|
17
19
|
setHFToken
|
|
18
20
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -448,6 +448,6 @@ declare function buildLoopInstruction(rounds: Array<{
|
|
|
448
448
|
declare function autoLabel(index: number): string;
|
|
449
449
|
declare function buildReferenceImageMediaIds(images: SelectedLabImage[]): string[];
|
|
450
450
|
|
|
451
|
-
declare const LIB_VERSION = "1.3.
|
|
451
|
+
declare const LIB_VERSION = "1.3.1";
|
|
452
452
|
|
|
453
453
|
export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, LIB_VERSION, LabBlend, LabCompare, type LabFrame, LabImagePicker, type LabItem, LabLoop, LabRemix, type LabServices, LabsTab, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedLabImage, type SelectedTag, SetupPanel, type SyncDiff, TagManagerPanel, type TagOption, type WorkspaceTags, autoLabel, buildBlendInstruction, buildCompareInstruction, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildLoopInstruction, buildPromptTabPayload, buildReferenceImageMediaIds, buildRemixInstruction, buildScanInstruction, cleanAiResponse, createFlowServices, exportProjectToZip, formatTreeToMarkdown, frameToGeneration, getFormattedTimestamp, groupGenerationsToLabItems, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
|
package/dist/index.d.ts
CHANGED
|
@@ -448,6 +448,6 @@ declare function buildLoopInstruction(rounds: Array<{
|
|
|
448
448
|
declare function autoLabel(index: number): string;
|
|
449
449
|
declare function buildReferenceImageMediaIds(images: SelectedLabImage[]): string[];
|
|
450
450
|
|
|
451
|
-
declare const LIB_VERSION = "1.3.
|
|
451
|
+
declare const LIB_VERSION = "1.3.1";
|
|
452
452
|
|
|
453
453
|
export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, LIB_VERSION, LabBlend, LabCompare, type LabFrame, LabImagePicker, type LabItem, LabLoop, LabRemix, type LabServices, LabsTab, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedLabImage, type SelectedTag, SetupPanel, type SyncDiff, TagManagerPanel, type TagOption, type WorkspaceTags, autoLabel, buildBlendInstruction, buildCompareInstruction, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildLoopInstruction, buildPromptTabPayload, buildReferenceImageMediaIds, buildRemixInstruction, buildScanInstruction, cleanAiResponse, createFlowServices, exportProjectToZip, formatTreeToMarkdown, frameToGeneration, getFormattedTimestamp, groupGenerationsToLabItems, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
|
package/dist/index.js
CHANGED
|
@@ -268,6 +268,7 @@ __export(hfStateService_exports, {
|
|
|
268
268
|
hfDownloadProject: () => hfDownloadProject,
|
|
269
269
|
hfListProjects: () => hfListProjects,
|
|
270
270
|
hfUploadProject: () => hfUploadProject,
|
|
271
|
+
hfUploadProjectForm: () => hfUploadProjectForm,
|
|
271
272
|
setHFToken: () => setHFToken
|
|
272
273
|
});
|
|
273
274
|
function getHFToken() {
|
|
@@ -329,14 +330,22 @@ async function hfUploadProject(zipBase64, name, token) {
|
|
|
329
330
|
const debugInfo = JSON.stringify({ uploadMode: fileInfo?.uploadMode, hasUploadUrl: !!fileInfo?.uploadUrl, hasVerifyUrl: !!fileInfo?.verifyUrl, headerKeys: Object.keys(fileInfo?.header || {}), verifyHeaderKeys: Object.keys(fileInfo?.verifyHeader || {}) });
|
|
330
331
|
if (!fileInfo?.uploadMode) throw new Error(`HF preupload kein fileInfo: ${JSON.stringify(preData)}`);
|
|
331
332
|
if (fileInfo.uploadMode === "lfs" && fileInfo.uploadUrl) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
let uploadStatus = 0;
|
|
334
|
+
try {
|
|
335
|
+
const uploadRes = await fetch(fileInfo.uploadUrl, {
|
|
336
|
+
method: "PUT",
|
|
337
|
+
redirect: "follow",
|
|
338
|
+
headers: { "Content-Type": "application/octet-stream", ...fileInfo.header || {} },
|
|
339
|
+
body: bytes
|
|
340
|
+
});
|
|
341
|
+
uploadStatus = uploadRes.status;
|
|
342
|
+
if (!uploadRes.ok) {
|
|
343
|
+
const uploadErr = await uploadRes.text().catch(() => "");
|
|
344
|
+
throw new Error(`HF LFS upload failed: ${uploadRes.status} \u2014 ${uploadErr.slice(0, 300)}`);
|
|
345
|
+
}
|
|
346
|
+
} catch (e) {
|
|
347
|
+
if (uploadStatus === 0) throw new Error(`HF LFS upload network error (CORS/redirect?): ${e.message}`);
|
|
348
|
+
throw e;
|
|
340
349
|
}
|
|
341
350
|
if (fileInfo.verifyUrl) {
|
|
342
351
|
const verifyRes = await fetch(fileInfo.verifyUrl, {
|
|
@@ -364,6 +373,24 @@ async function hfUploadProject(zipBase64, name, token) {
|
|
|
364
373
|
}
|
|
365
374
|
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size, isLfs: true };
|
|
366
375
|
}
|
|
376
|
+
async function hfUploadProjectForm(zipBase64, name, token) {
|
|
377
|
+
const filename = name.endsWith(".zip") ? name : `${name}.zip`;
|
|
378
|
+
const binary = atob(zipBase64);
|
|
379
|
+
const bytes = new Uint8Array(binary.length);
|
|
380
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
381
|
+
const blob = new Blob([bytes], { type: "application/zip" });
|
|
382
|
+
const form = new FormData();
|
|
383
|
+
form.append("files[]", blob, filename);
|
|
384
|
+
const res = await fetch(
|
|
385
|
+
`${HF_BASE}/api/datasets/${HF_REPO}/upload/main`,
|
|
386
|
+
{ method: "POST", headers: { Authorization: `Bearer ${token}` }, body: form }
|
|
387
|
+
);
|
|
388
|
+
if (!res.ok) {
|
|
389
|
+
const err = await res.text().catch(() => "");
|
|
390
|
+
throw new Error(`HF FormData upload failed: ${res.status} \u2014 ${err.slice(0, 300)}`);
|
|
391
|
+
}
|
|
392
|
+
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size: bytes.length, isLfs: true };
|
|
393
|
+
}
|
|
367
394
|
async function hfDeleteProject(path, token) {
|
|
368
395
|
const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
369
396
|
method: "POST",
|
|
@@ -1952,7 +1979,7 @@ var ProjectSyncTab = ({
|
|
|
1952
1979
|
try {
|
|
1953
1980
|
const base64 = await onProjectExportBase64();
|
|
1954
1981
|
const name = hfSaveName.trim() || `project_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace("T", "_").replace(":", "")}`;
|
|
1955
|
-
await
|
|
1982
|
+
await hfUploadProjectForm(base64, name, hfToken);
|
|
1956
1983
|
setHfSaveName("");
|
|
1957
1984
|
await loadHfProjects(hfToken);
|
|
1958
1985
|
} catch (e) {
|
|
@@ -4603,7 +4630,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
|
|
|
4603
4630
|
}
|
|
4604
4631
|
|
|
4605
4632
|
// src/index.ts
|
|
4606
|
-
var LIB_VERSION = "1.3.
|
|
4633
|
+
var LIB_VERSION = "1.3.1";
|
|
4607
4634
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4608
4635
|
0 && (module.exports = {
|
|
4609
4636
|
AvatarArchitectApp,
|
package/dist/index.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
hfDeleteProject,
|
|
8
8
|
hfListProjects,
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
hfUploadProjectForm
|
|
10
|
+
} from "./chunk-4MIV2ED3.mjs";
|
|
11
11
|
|
|
12
12
|
// src/hooks/useOnClickOutside.ts
|
|
13
13
|
import { useEffect } from "react";
|
|
@@ -1518,7 +1518,7 @@ var ProjectSyncTab = ({
|
|
|
1518
1518
|
try {
|
|
1519
1519
|
const base64 = await onProjectExportBase64();
|
|
1520
1520
|
const name = hfSaveName.trim() || `project_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace("T", "_").replace(":", "")}`;
|
|
1521
|
-
await
|
|
1521
|
+
await hfUploadProjectForm(base64, name, hfToken);
|
|
1522
1522
|
setHfSaveName("");
|
|
1523
1523
|
await loadHfProjects(hfToken);
|
|
1524
1524
|
} catch (e) {
|
|
@@ -1547,7 +1547,7 @@ var ProjectSyncTab = ({
|
|
|
1547
1547
|
{
|
|
1548
1548
|
onClick: async () => {
|
|
1549
1549
|
try {
|
|
1550
|
-
const { hfDownloadProject } = await import("./hfStateService-
|
|
1550
|
+
const { hfDownloadProject } = await import("./hfStateService-UKEBY3QR.mjs");
|
|
1551
1551
|
const file = await hfDownloadProject(p.path, hfToken);
|
|
1552
1552
|
onHfLoad(file);
|
|
1553
1553
|
} catch (e) {
|
|
@@ -3507,7 +3507,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
|
|
|
3507
3507
|
onClick: async () => {
|
|
3508
3508
|
setIsLoadingFromHF(true);
|
|
3509
3509
|
try {
|
|
3510
|
-
const { hfListProjects: hfListProjects2, hfDownloadProject } = await import("./hfStateService-
|
|
3510
|
+
const { hfListProjects: hfListProjects2, hfDownloadProject } = await import("./hfStateService-UKEBY3QR.mjs");
|
|
3511
3511
|
const projects = await hfListProjects2(hfToken);
|
|
3512
3512
|
if (projects.length > 0) {
|
|
3513
3513
|
const file = await hfDownloadProject(projects[0].path, hfToken);
|
|
@@ -4165,7 +4165,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
|
|
|
4165
4165
|
}
|
|
4166
4166
|
|
|
4167
4167
|
// src/index.ts
|
|
4168
|
-
var LIB_VERSION = "1.3.
|
|
4168
|
+
var LIB_VERSION = "1.3.1";
|
|
4169
4169
|
export {
|
|
4170
4170
|
AvatarArchitectApp,
|
|
4171
4171
|
CollapsibleCard,
|