@rslsp1/fa-app-tools 1.3.0 → 1.3.2
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,22 @@ 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 { uploadFile } = await import("@huggingface/hub");
|
|
114
|
+
await uploadFile({
|
|
115
|
+
repo: { type: "dataset", name: HF_REPO },
|
|
116
|
+
credentials: { accessToken: token },
|
|
117
|
+
file: { path: filename, content: blob },
|
|
118
|
+
branch: "main",
|
|
119
|
+
commitTitle: `Upload ${filename}`
|
|
120
|
+
});
|
|
121
|
+
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size: bytes.length, isLfs: true };
|
|
122
|
+
}
|
|
99
123
|
async function hfDeleteProject(path, token) {
|
|
100
124
|
const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
101
125
|
method: "POST",
|
|
@@ -115,5 +139,6 @@ export {
|
|
|
115
139
|
hfListProjects,
|
|
116
140
|
hfDownloadProject,
|
|
117
141
|
hfUploadProject,
|
|
142
|
+
hfUploadProjectForm,
|
|
118
143
|
hfDeleteProject
|
|
119
144
|
};
|
|
@@ -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-JW5O3URT.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.2";
|
|
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.2";
|
|
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,22 @@ 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 { uploadFile } = await import("@huggingface/hub");
|
|
383
|
+
await uploadFile({
|
|
384
|
+
repo: { type: "dataset", name: HF_REPO },
|
|
385
|
+
credentials: { accessToken: token },
|
|
386
|
+
file: { path: filename, content: blob },
|
|
387
|
+
branch: "main",
|
|
388
|
+
commitTitle: `Upload ${filename}`
|
|
389
|
+
});
|
|
390
|
+
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size: bytes.length, isLfs: true };
|
|
391
|
+
}
|
|
367
392
|
async function hfDeleteProject(path, token) {
|
|
368
393
|
const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
369
394
|
method: "POST",
|
|
@@ -1952,7 +1977,7 @@ var ProjectSyncTab = ({
|
|
|
1952
1977
|
try {
|
|
1953
1978
|
const base64 = await onProjectExportBase64();
|
|
1954
1979
|
const name = hfSaveName.trim() || `project_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace("T", "_").replace(":", "")}`;
|
|
1955
|
-
await
|
|
1980
|
+
await hfUploadProjectForm(base64, name, hfToken);
|
|
1956
1981
|
setHfSaveName("");
|
|
1957
1982
|
await loadHfProjects(hfToken);
|
|
1958
1983
|
} catch (e) {
|
|
@@ -4603,7 +4628,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
|
|
|
4603
4628
|
}
|
|
4604
4629
|
|
|
4605
4630
|
// src/index.ts
|
|
4606
|
-
var LIB_VERSION = "1.3.
|
|
4631
|
+
var LIB_VERSION = "1.3.2";
|
|
4607
4632
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4608
4633
|
0 && (module.exports = {
|
|
4609
4634
|
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-JW5O3URT.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-UUDYKEMD.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-UUDYKEMD.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.2";
|
|
4169
4169
|
export {
|
|
4170
4170
|
AvatarArchitectApp,
|
|
4171
4171
|
CollapsibleCard,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslsp1/fa-app-tools",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Shared tools and hooks for Fine Art flow apps",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"react": ">=18"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"@huggingface/hub": "^2.13.0",
|
|
27
28
|
"jszip": "^3.10.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|