@rslsp1/fa-app-tools 2.0.12 → 2.0.14
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/dist/{chunk-WCFXXLKN.mjs → chunk-D2WTLDI7.mjs} +20 -100
- package/dist/{hfStateService-6YYT6ATO.mjs → hfStateService-OAECMP4M.mjs} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +811 -447
- package/dist/index.mjs +774 -330
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/lib/hfStateService.ts
|
|
2
2
|
import JSZip from "jszip";
|
|
3
|
+
import { uploadFile } from "@huggingface/hub";
|
|
3
4
|
|
|
4
5
|
// src/lib/hfEventTypes.ts
|
|
5
6
|
var CURRENT_EVENT_VERSION = { major: 1, minor: 0 };
|
|
@@ -173,24 +174,14 @@ async function hfBootstrapFromLegacy(namespace, token, onProgress) {
|
|
|
173
174
|
const ts = snapshot.meta.consolidatedAt;
|
|
174
175
|
const stateFilename = `state-${new Date(ts).toISOString().replace(/:/g, "-").replace(".", "-")}.zip`;
|
|
175
176
|
const repoPath = `${namespace}${stateFilename}`;
|
|
176
|
-
let binary = "";
|
|
177
|
-
zipBytes.forEach((b) => {
|
|
178
|
-
binary += String.fromCharCode(b);
|
|
179
|
-
});
|
|
180
|
-
const b64 = btoa(binary);
|
|
181
177
|
log("Lade state.zip hoch \u2026");
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
].join("\n")
|
|
178
|
+
await uploadFile({
|
|
179
|
+
repo: { type: "dataset", name: HF_REPO },
|
|
180
|
+
credentials: { accessToken: token },
|
|
181
|
+
file: { path: repoPath, content: new Blob([zipBytes.buffer], { type: "application/zip" }) },
|
|
182
|
+
branch: "main",
|
|
183
|
+
commitTitle: `Bootstrap: initialer State aus Legacy-Daten`
|
|
189
184
|
});
|
|
190
|
-
if (!commitRes.ok) {
|
|
191
|
-
const err = await commitRes.text().catch(() => "");
|
|
192
|
-
throw new Error(`HF commit failed: ${commitRes.status} \u2014 ${err.slice(0, 300)}`);
|
|
193
|
-
}
|
|
194
185
|
log(`Fertig \u2014 ${stateFilename}`);
|
|
195
186
|
}
|
|
196
187
|
async function hfListProjects(token) {
|
|
@@ -221,65 +212,14 @@ async function hfUploadProject(zipBase64, name, token) {
|
|
|
221
212
|
const binary = atob(zipBase64);
|
|
222
213
|
const bytes = new Uint8Array(binary.length);
|
|
223
214
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const sample = btoa(sampleBinary);
|
|
231
|
-
const preRes = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/preupload/main`, {
|
|
232
|
-
method: "POST",
|
|
233
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
234
|
-
body: JSON.stringify({ files: [{ path: filename, size, sample }] })
|
|
215
|
+
await uploadFile({
|
|
216
|
+
repo: { type: "dataset", name: HF_REPO },
|
|
217
|
+
credentials: { accessToken: token },
|
|
218
|
+
file: { path: filename, content: new Blob([bytes], { type: "application/zip" }) },
|
|
219
|
+
branch: "main",
|
|
220
|
+
commitTitle: `Upload ${filename}`
|
|
235
221
|
});
|
|
236
|
-
|
|
237
|
-
const preData = await preRes.json();
|
|
238
|
-
const fileInfo = preData.files?.[0];
|
|
239
|
-
if (!fileInfo?.uploadMode) throw new Error(`HF preupload kein fileInfo: ${JSON.stringify(preData)}`);
|
|
240
|
-
if (fileInfo.uploadMode === "lfs" && fileInfo.uploadUrl) {
|
|
241
|
-
let uploadStatus = 0;
|
|
242
|
-
try {
|
|
243
|
-
const uploadRes = await fetch(fileInfo.uploadUrl, {
|
|
244
|
-
method: "PUT",
|
|
245
|
-
redirect: "follow",
|
|
246
|
-
headers: { "Content-Type": "application/octet-stream", ...fileInfo.header || {} },
|
|
247
|
-
body: bytes
|
|
248
|
-
});
|
|
249
|
-
uploadStatus = uploadRes.status;
|
|
250
|
-
if (!uploadRes.ok) {
|
|
251
|
-
const uploadErr = await uploadRes.text().catch(() => "");
|
|
252
|
-
throw new Error(`HF LFS upload failed: ${uploadRes.status} \u2014 ${uploadErr.slice(0, 300)}`);
|
|
253
|
-
}
|
|
254
|
-
} catch (e) {
|
|
255
|
-
if (uploadStatus === 0) throw new Error(`HF LFS upload network error (CORS/redirect?): ${e.message}`);
|
|
256
|
-
throw e;
|
|
257
|
-
}
|
|
258
|
-
if (fileInfo.verifyUrl) {
|
|
259
|
-
const verifyRes = await fetch(fileInfo.verifyUrl, {
|
|
260
|
-
method: "POST",
|
|
261
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", ...fileInfo.verifyHeader || {} },
|
|
262
|
-
body: JSON.stringify({ oid, size })
|
|
263
|
-
});
|
|
264
|
-
if (!verifyRes.ok) {
|
|
265
|
-
const verifyErr = await verifyRes.text().catch(() => "");
|
|
266
|
-
throw new Error(`HF LFS verify failed: ${verifyRes.status} \u2014 ${verifyErr.slice(0, 200)}`);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const commitRes = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
271
|
-
method: "POST",
|
|
272
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/x-ndjson" },
|
|
273
|
-
body: [
|
|
274
|
-
JSON.stringify({ key: "header", value: { summary: `Upload ${filename}`, description: "" } }),
|
|
275
|
-
JSON.stringify({ key: "lfsFile", value: { path: filename, algo: "sha256", oid, size } })
|
|
276
|
-
].join("\n")
|
|
277
|
-
});
|
|
278
|
-
if (!commitRes.ok) {
|
|
279
|
-
const err = await commitRes.text();
|
|
280
|
-
throw new Error(`HF commit failed: ${commitRes.status} \u2014 ${err}`);
|
|
281
|
-
}
|
|
282
|
-
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size, isLfs: true };
|
|
222
|
+
return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size: bytes.length, isLfs: true };
|
|
283
223
|
}
|
|
284
224
|
async function hfUploadProjectForm(_zipBase64, _name, _token) {
|
|
285
225
|
throw new Error("hfUploadProjectForm is deprecated. Use hfUploadProject instead.");
|
|
@@ -330,32 +270,12 @@ async function hfUploadImage(base64, id, token, mimeType = "image/jpeg") {
|
|
|
330
270
|
const binary = atob(base64);
|
|
331
271
|
const bytes = new Uint8Array(binary.length);
|
|
332
272
|
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
|
|
340
|
-
body: JSON.stringify({ files: [{ path: filename, size }] })
|
|
341
|
-
});
|
|
342
|
-
if (!preRes.ok) throw new Error(`HF preupload failed: ${preRes.status}`);
|
|
343
|
-
const preData = await preRes.json();
|
|
344
|
-
const fileInfo = preData.files?.[0];
|
|
345
|
-
if (fileInfo?.uploadUrl) {
|
|
346
|
-
await fetch(fileInfo.uploadUrl, {
|
|
347
|
-
method: "PUT",
|
|
348
|
-
headers: { "Content-Type": mimeType, ...fileInfo.header || {} },
|
|
349
|
-
body: bytes
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
|
|
353
|
-
method: "POST",
|
|
354
|
-
headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/x-ndjson" },
|
|
355
|
-
body: [
|
|
356
|
-
JSON.stringify({ key: "header", value: { summary: `Add image ${id}`, description: "" } }),
|
|
357
|
-
JSON.stringify({ key: "lfsFile", value: { path: filename, algo: "sha256", oid, size } })
|
|
358
|
-
].join("\n")
|
|
273
|
+
await uploadFile({
|
|
274
|
+
repo: { type: "dataset", name: HF_REPO },
|
|
275
|
+
credentials: { accessToken: token },
|
|
276
|
+
file: { path: `images/${id}.${ext}`, content: new Blob([bytes], { type: mimeType }) },
|
|
277
|
+
branch: "main",
|
|
278
|
+
commitTitle: `Add image ${id}`
|
|
359
279
|
});
|
|
360
280
|
}
|
|
361
281
|
async function hfLoadImageAsBase64(id, token) {
|
package/dist/index.d.mts
CHANGED
|
@@ -612,6 +612,6 @@ declare function findTips(dag: Dag): number[];
|
|
|
612
612
|
declare function findForks(dag: Dag): DagFork[];
|
|
613
613
|
declare function topoSort(events: HFEvent[]): HFEvent[];
|
|
614
614
|
|
|
615
|
-
declare const LIB_VERSION = "2.0.
|
|
615
|
+
declare const LIB_VERSION = "2.0.14";
|
|
616
616
|
|
|
617
617
|
export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type DagFork, type ExtractedCharacter, FaApp, type FaAppProps, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, type HFEvent, type HFEventVersion, type HFFileInfo$1 as HFFileInfo, type HFMetadataEntry, type HFStateMeta, type HFStateResult, type HFStateSnapshot, HistoryPanel, type ImageAddedPayload, InspectPanel, LIB_VERSION, LabBlend, LabCompare, type LabFrame, LabImagePicker, type LabItem, LabLoop, LabRemix, type LabServices, LabsTab, ListView, type MediaItem, MediaLibrary, type MetadataUpdatedPayload, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedLabImage, type SelectedTag, SetupPanel, type SyncDiff, TagManagerPanel, type TagOption, type TagUpsertedPayload, type WorkspaceTags, applyEvent, applyEvents, autoLabel, buildBlendInstruction, buildCompareInstruction, buildDag, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildLoopInstruction, buildPromptTabPayload, buildReferenceImageMediaIds, buildRemixInstruction, buildScanInstruction, cleanAiResponse, createFlowServices, exportProjectToZip, findForks, findTips, formatTreeToMarkdown, frameToGeneration, getFormattedTimestamp, getHFToken, getSessionClientId, groupGenerationsToLabItems, hfBatchArchive, hfBootstrapFromLegacy, hfDeleteProject, hfDownloadProject, hfListDir, hfListProjects, hfLoadImageAsBase64, hfUploadImage, hfUploadProjectForm, hfUploadSmallFile, importProjectFromZip, injectXMPMetadata, interpretSdkError, loadHFState, loadPendingEvents, parsePromptFile, parsePromptResponse, setHFToken, topoSort, tsFromEventPath, useHFState, useKeyboardNavigation, useOnClickOutside, writeHFEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -612,6 +612,6 @@ declare function findTips(dag: Dag): number[];
|
|
|
612
612
|
declare function findForks(dag: Dag): DagFork[];
|
|
613
613
|
declare function topoSort(events: HFEvent[]): HFEvent[];
|
|
614
614
|
|
|
615
|
-
declare const LIB_VERSION = "2.0.
|
|
615
|
+
declare const LIB_VERSION = "2.0.14";
|
|
616
616
|
|
|
617
617
|
export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type DagFork, type ExtractedCharacter, FaApp, type FaAppProps, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, type HFEvent, type HFEventVersion, type HFFileInfo$1 as HFFileInfo, type HFMetadataEntry, type HFStateMeta, type HFStateResult, type HFStateSnapshot, HistoryPanel, type ImageAddedPayload, InspectPanel, LIB_VERSION, LabBlend, LabCompare, type LabFrame, LabImagePicker, type LabItem, LabLoop, LabRemix, type LabServices, LabsTab, ListView, type MediaItem, MediaLibrary, type MetadataUpdatedPayload, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedLabImage, type SelectedTag, SetupPanel, type SyncDiff, TagManagerPanel, type TagOption, type TagUpsertedPayload, type WorkspaceTags, applyEvent, applyEvents, autoLabel, buildBlendInstruction, buildCompareInstruction, buildDag, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildLoopInstruction, buildPromptTabPayload, buildReferenceImageMediaIds, buildRemixInstruction, buildScanInstruction, cleanAiResponse, createFlowServices, exportProjectToZip, findForks, findTips, formatTreeToMarkdown, frameToGeneration, getFormattedTimestamp, getHFToken, getSessionClientId, groupGenerationsToLabItems, hfBatchArchive, hfBootstrapFromLegacy, hfDeleteProject, hfDownloadProject, hfListDir, hfListProjects, hfLoadImageAsBase64, hfUploadImage, hfUploadProjectForm, hfUploadSmallFile, importProjectFromZip, injectXMPMetadata, interpretSdkError, loadHFState, loadPendingEvents, parsePromptFile, parsePromptResponse, setHFToken, topoSort, tsFromEventPath, useHFState, useKeyboardNavigation, useOnClickOutside, writeHFEvent };
|