@rslsp1/fa-app-tools 2.0.22 → 2.0.24

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.
@@ -119,10 +119,10 @@ async function loadHFState(namespace, token) {
119
119
  async function loadPendingEvents(namespace, token, sinceTs) {
120
120
  const files = await hfListDir(namespace, "events", token);
121
121
  const pending = files.filter((f) => f.type === "file" && tsFromEventPath(f.path) > sinceTs).sort((a, b) => a.path.localeCompare(b.path));
122
- const events = await Promise.all(
122
+ const raw = await Promise.all(
123
123
  pending.map((f) => hfDownloadJsonByPath(f.path, token))
124
124
  );
125
- return events;
125
+ return raw.flatMap((e) => Array.isArray(e) ? e : [e]);
126
126
  }
127
127
  var SESSION_CLIENT_ID = `client-${crypto.randomUUID().slice(0, 8)}`;
128
128
  function getSessionClientId() {
@@ -279,23 +279,27 @@ async function hfUploadImage(base64, id, token, mimeType = "image/jpeg") {
279
279
  commitTitle: `Add image ${id}`
280
280
  });
281
281
  }
282
- async function hfLoadImageAsBase64(id, token) {
283
- for (const ext of ["jpg", "png"]) {
284
- try {
285
- const res = await fetch(
286
- `${HF_BASE}/datasets/${HF_REPO}/resolve/main/images/${id}.${ext}?download=true`,
287
- { headers: { Authorization: `Bearer ${token}` } }
288
- );
289
- if (!res.ok) continue;
290
- const blob = await res.blob();
291
- return new Promise((resolve, reject) => {
292
- const reader = new FileReader();
293
- reader.onload = () => resolve(reader.result.split(",")[1]);
294
- reader.onerror = reject;
295
- reader.readAsDataURL(blob);
296
- });
297
- } catch {
298
- continue;
282
+ async function hfLoadImageAsBase64(id, token, namespace) {
283
+ const paths = [`images/${id}`];
284
+ if (namespace) paths.push(`${namespace}images/${id}`);
285
+ for (const basePath of paths) {
286
+ for (const ext of ["jpg", "png"]) {
287
+ try {
288
+ const res = await fetch(
289
+ `${HF_BASE}/datasets/${HF_REPO}/resolve/main/${basePath}.${ext}?download=true`,
290
+ { headers: { Authorization: `Bearer ${token}` } }
291
+ );
292
+ if (!res.ok) continue;
293
+ const blob = await res.blob();
294
+ return new Promise((resolve, reject) => {
295
+ const reader = new FileReader();
296
+ reader.onload = () => resolve(reader.result.split(",")[1]);
297
+ reader.onerror = reject;
298
+ reader.readAsDataURL(blob);
299
+ });
300
+ } catch {
301
+ continue;
302
+ }
299
303
  }
300
304
  }
301
305
  return null;
@@ -24,7 +24,7 @@ import {
24
24
  setHFToken,
25
25
  tsFromEventPath,
26
26
  writeHFEvent
27
- } from "./chunk-I73HODO5.mjs";
27
+ } from "./chunk-UCEQOGPT.mjs";
28
28
  export {
29
29
  HF_TOKEN_KEY,
30
30
  getHFToken,
package/dist/index.d.mts CHANGED
@@ -438,6 +438,10 @@ declare function TagManagerPanel({ workspaceTags, onTagCreate, onTagUpdate, onTa
438
438
  interface LabsTabProps {
439
439
  services: LabServices;
440
440
  onResult?: (item: LabItem) => void;
441
+ /** Optional: pre-filtered video items for the Frames tab */
442
+ videoItems?: LabItem[];
443
+ /** Optional: resolve a mediaId to a playable video URL */
444
+ resolveVideoUrl?: (mediaId: string) => string;
441
445
  }
442
446
  declare const LabsTab: React.FC<LabsTabProps>;
443
447
 
@@ -465,6 +469,16 @@ interface LabLoopProps {
465
469
  }
466
470
  declare const LabLoop: React.FC<LabLoopProps>;
467
471
 
472
+ interface LabFrameExtractorProps {
473
+ /** Pre-filtered video items from the host app */
474
+ videoItems: LabItem[];
475
+ /** Called when the user selects a frame to use as output */
476
+ onResult?: (item: LabItem) => void;
477
+ /** Host-provided function to resolve a mediaId to a playable video URL */
478
+ resolveVideoUrl: (mediaId: string) => string;
479
+ }
480
+ declare const LabFrameExtractor: React.FC<LabFrameExtractorProps>;
481
+
468
482
  interface LabImagePickerProps {
469
483
  availableItems: LabItem[];
470
484
  recentItems: LabItem[];
@@ -575,7 +589,15 @@ declare function hfDownloadProject(path: string, token: string): Promise<File>;
575
589
  declare function hfUploadProjectForm(_zipBase64: string, _name: string, _token: string): Promise<HFProjectMeta>;
576
590
  declare function hfDeleteProject(path: string, token: string): Promise<void>;
577
591
  declare function hfUploadImage(base64: string, id: string, token: string, mimeType?: string): Promise<void>;
578
- declare function hfLoadImageAsBase64(id: string, token: string): Promise<string | null>;
592
+ declare function hfLoadImageAsBase64(id: string, token: string, namespace?: string): Promise<string | null>;
593
+
594
+ type FaServerEnv = 'prod' | 'dev';
595
+ declare function faServerGet<T>(path: string, env?: FaServerEnv): Promise<T>;
596
+ declare function faServerPost<T>(path: string, body: unknown, env?: FaServerEnv): Promise<T>;
597
+ declare function faServerPut<T>(path: string, body: unknown, env?: FaServerEnv): Promise<T>;
598
+ declare function faServerDelete<T>(path: string, env?: FaServerEnv): Promise<T>;
599
+
600
+ declare function ServerTab(): react_jsx_runtime.JSX.Element;
579
601
 
580
602
  interface HFStateResult {
581
603
  state: HFStateSnapshot | null;
@@ -614,6 +636,6 @@ declare function findTips(dag: Dag): number[];
614
636
  declare function findForks(dag: Dag): DagFork[];
615
637
  declare function topoSort(events: HFEvent[]): HFEvent[];
616
638
 
617
- declare const LIB_VERSION = "2.0.22";
639
+ declare const LIB_VERSION = "2.0.24";
618
640
 
619
- 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 };
641
+ export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type DagFork, type ExtractedCharacter, FaApp, type FaAppProps, type FaServerEnv, 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, LabFrameExtractor, type LabFrameExtractorProps, 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, ServerTab, 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, faServerDelete, faServerGet, faServerPost, faServerPut, 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
@@ -438,6 +438,10 @@ declare function TagManagerPanel({ workspaceTags, onTagCreate, onTagUpdate, onTa
438
438
  interface LabsTabProps {
439
439
  services: LabServices;
440
440
  onResult?: (item: LabItem) => void;
441
+ /** Optional: pre-filtered video items for the Frames tab */
442
+ videoItems?: LabItem[];
443
+ /** Optional: resolve a mediaId to a playable video URL */
444
+ resolveVideoUrl?: (mediaId: string) => string;
441
445
  }
442
446
  declare const LabsTab: React.FC<LabsTabProps>;
443
447
 
@@ -465,6 +469,16 @@ interface LabLoopProps {
465
469
  }
466
470
  declare const LabLoop: React.FC<LabLoopProps>;
467
471
 
472
+ interface LabFrameExtractorProps {
473
+ /** Pre-filtered video items from the host app */
474
+ videoItems: LabItem[];
475
+ /** Called when the user selects a frame to use as output */
476
+ onResult?: (item: LabItem) => void;
477
+ /** Host-provided function to resolve a mediaId to a playable video URL */
478
+ resolveVideoUrl: (mediaId: string) => string;
479
+ }
480
+ declare const LabFrameExtractor: React.FC<LabFrameExtractorProps>;
481
+
468
482
  interface LabImagePickerProps {
469
483
  availableItems: LabItem[];
470
484
  recentItems: LabItem[];
@@ -575,7 +589,15 @@ declare function hfDownloadProject(path: string, token: string): Promise<File>;
575
589
  declare function hfUploadProjectForm(_zipBase64: string, _name: string, _token: string): Promise<HFProjectMeta>;
576
590
  declare function hfDeleteProject(path: string, token: string): Promise<void>;
577
591
  declare function hfUploadImage(base64: string, id: string, token: string, mimeType?: string): Promise<void>;
578
- declare function hfLoadImageAsBase64(id: string, token: string): Promise<string | null>;
592
+ declare function hfLoadImageAsBase64(id: string, token: string, namespace?: string): Promise<string | null>;
593
+
594
+ type FaServerEnv = 'prod' | 'dev';
595
+ declare function faServerGet<T>(path: string, env?: FaServerEnv): Promise<T>;
596
+ declare function faServerPost<T>(path: string, body: unknown, env?: FaServerEnv): Promise<T>;
597
+ declare function faServerPut<T>(path: string, body: unknown, env?: FaServerEnv): Promise<T>;
598
+ declare function faServerDelete<T>(path: string, env?: FaServerEnv): Promise<T>;
599
+
600
+ declare function ServerTab(): react_jsx_runtime.JSX.Element;
579
601
 
580
602
  interface HFStateResult {
581
603
  state: HFStateSnapshot | null;
@@ -614,6 +636,6 @@ declare function findTips(dag: Dag): number[];
614
636
  declare function findForks(dag: Dag): DagFork[];
615
637
  declare function topoSort(events: HFEvent[]): HFEvent[];
616
638
 
617
- declare const LIB_VERSION = "2.0.22";
639
+ declare const LIB_VERSION = "2.0.24";
618
640
 
619
- 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 };
641
+ export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type DagFork, type ExtractedCharacter, FaApp, type FaAppProps, type FaServerEnv, 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, LabFrameExtractor, type LabFrameExtractorProps, 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, ServerTab, 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, faServerDelete, faServerGet, faServerPost, faServerPut, 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 };