@rslsp1/fa-app-tools 1.3.10 → 1.3.12

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/index.d.mts CHANGED
@@ -479,6 +479,6 @@ declare function hfLoadMetadata(token: string): Promise<any[]>;
479
479
  declare function hfUploadImage(base64: string, id: string, token: string, mimeType?: string): Promise<void>;
480
480
  declare function hfLoadImageAsBase64(id: string, token: string): Promise<string | null>;
481
481
 
482
- declare const LIB_VERSION = "1.3.10";
482
+ declare const LIB_VERSION = "1.3.12";
483
483
 
484
484
  export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, type HFMetadataEntry, 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, getHFToken, groupGenerationsToLabItems, hfDeleteProject, hfDownloadProject, hfListProjects, hfLoadImageAsBase64, hfLoadMetadata, hfLoadTags, hfSaveMetadata, hfSaveTags, hfUploadImage, hfUploadProjectForm, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, setHFToken, useKeyboardNavigation, useOnClickOutside };
package/dist/index.d.ts CHANGED
@@ -479,6 +479,6 @@ declare function hfLoadMetadata(token: string): Promise<any[]>;
479
479
  declare function hfUploadImage(base64: string, id: string, token: string, mimeType?: string): Promise<void>;
480
480
  declare function hfLoadImageAsBase64(id: string, token: string): Promise<string | null>;
481
481
 
482
- declare const LIB_VERSION = "1.3.10";
482
+ declare const LIB_VERSION = "1.3.12";
483
483
 
484
484
  export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, type HFMetadataEntry, 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, getHFToken, groupGenerationsToLabItems, hfDeleteProject, hfDownloadProject, hfListProjects, hfLoadImageAsBase64, hfLoadMetadata, hfLoadTags, hfSaveMetadata, hfSaveTags, hfUploadImage, hfUploadProjectForm, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, setHFToken, useKeyboardNavigation, useOnClickOutside };
package/dist/index.js CHANGED
@@ -3991,7 +3991,12 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3991
3991
  const mergedMeta = [...existingMeta || [], ...newEntries];
3992
3992
  await hfSaveMetadata(mergedMeta, hfToken);
3993
3993
  setHfMetadata(mergedMeta);
3994
- if (workspaceTags) await hfSaveTags(workspaceTags, hfToken);
3994
+ if (workspaceTags) {
3995
+ const remoteTags = await hfLoadTags(hfToken).catch(() => null);
3996
+ const mergedTags = mergeWorkspaceTags(workspaceTags, remoteTags);
3997
+ await hfSaveTags(mergedTags, hfToken);
3998
+ setWorkspaceTags(mergedTags);
3999
+ }
3995
4000
  };
3996
4001
  const handleComputeSyncDiff = async () => {
3997
4002
  if (!onFetchServerProjects || !onServerLoad) throw new Error("Server nicht konfiguriert");
@@ -4072,12 +4077,36 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
4072
4077
  (0, import_react21.useEffect)(() => {
4073
4078
  if (hfToken) loadFromHF(hfToken);
4074
4079
  }, [hfToken]);
4080
+ const mergeWorkspaceTags = (local, remote) => {
4081
+ if (!remote?.by_category) return local;
4082
+ const merged = {};
4083
+ const allCategories = /* @__PURE__ */ new Set([...Object.keys(local.by_category), ...Object.keys(remote.by_category)]);
4084
+ for (const cat of allCategories) {
4085
+ const localTags = local.by_category[cat] || [];
4086
+ const remoteTags = remote.by_category[cat] || [];
4087
+ const remoteMap = new Map(remoteTags.map((t) => [t.value, t]));
4088
+ const localValues = new Set(localTags.map((t) => t.value));
4089
+ const mergedLocal = localTags.map((t) => {
4090
+ const remote2 = remoteMap.get(t.value);
4091
+ return remote2?.is_deleted ? { ...t, is_deleted: true } : t;
4092
+ });
4093
+ const onlyInRemote = remoteTags.filter((t) => !localValues.has(t.value));
4094
+ merged[cat] = [...mergedLocal, ...onlyInRemote];
4095
+ }
4096
+ const all = Object.entries(merged).flatMap(([cat, tags]) => tags.map((t) => ({ ...t, category: cat })));
4097
+ return { by_category: merged, all };
4098
+ };
4075
4099
  (0, import_react21.useEffect)(() => {
4076
4100
  if (!hfToken || !workspaceTags) return;
4077
4101
  if (hfTagSaveTimer.current) clearTimeout(hfTagSaveTimer.current);
4078
- hfTagSaveTimer.current = setTimeout(() => {
4079
- hfSaveTags(workspaceTags, hfToken).catch(() => {
4102
+ hfTagSaveTimer.current = setTimeout(async () => {
4103
+ const remote = await hfLoadTags(hfToken).catch(() => null);
4104
+ const merged = mergeWorkspaceTags(workspaceTags, remote);
4105
+ await hfSaveTags(merged, hfToken).catch(() => {
4080
4106
  });
4107
+ if (Object.values(merged.by_category).some(
4108
+ (tags, i) => tags.length !== Object.values(workspaceTags.by_category)[i]?.length
4109
+ )) setWorkspaceTags(merged);
4081
4110
  }, 1500);
4082
4111
  return () => {
4083
4112
  if (hfTagSaveTimer.current) clearTimeout(hfTagSaveTimer.current);
@@ -4879,7 +4908,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
4879
4908
 
4880
4909
  // src/index.ts
4881
4910
  init_hfStateService();
4882
- var LIB_VERSION = "1.3.10";
4911
+ var LIB_VERSION = "1.3.12";
4883
4912
  // Annotate the CommonJS export names for ESM import in node:
4884
4913
  0 && (module.exports = {
4885
4914
  AvatarArchitectApp,
package/dist/index.mjs CHANGED
@@ -3434,7 +3434,12 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3434
3434
  const mergedMeta = [...existingMeta || [], ...newEntries];
3435
3435
  await hfSaveMetadata(mergedMeta, hfToken);
3436
3436
  setHfMetadata(mergedMeta);
3437
- if (workspaceTags) await hfSaveTags(workspaceTags, hfToken);
3437
+ if (workspaceTags) {
3438
+ const remoteTags = await hfLoadTags(hfToken).catch(() => null);
3439
+ const mergedTags = mergeWorkspaceTags(workspaceTags, remoteTags);
3440
+ await hfSaveTags(mergedTags, hfToken);
3441
+ setWorkspaceTags(mergedTags);
3442
+ }
3438
3443
  };
3439
3444
  const handleComputeSyncDiff = async () => {
3440
3445
  if (!onFetchServerProjects || !onServerLoad) throw new Error("Server nicht konfiguriert");
@@ -3515,12 +3520,36 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3515
3520
  useEffect5(() => {
3516
3521
  if (hfToken) loadFromHF(hfToken);
3517
3522
  }, [hfToken]);
3523
+ const mergeWorkspaceTags = (local, remote) => {
3524
+ if (!remote?.by_category) return local;
3525
+ const merged = {};
3526
+ const allCategories = /* @__PURE__ */ new Set([...Object.keys(local.by_category), ...Object.keys(remote.by_category)]);
3527
+ for (const cat of allCategories) {
3528
+ const localTags = local.by_category[cat] || [];
3529
+ const remoteTags = remote.by_category[cat] || [];
3530
+ const remoteMap = new Map(remoteTags.map((t) => [t.value, t]));
3531
+ const localValues = new Set(localTags.map((t) => t.value));
3532
+ const mergedLocal = localTags.map((t) => {
3533
+ const remote2 = remoteMap.get(t.value);
3534
+ return remote2?.is_deleted ? { ...t, is_deleted: true } : t;
3535
+ });
3536
+ const onlyInRemote = remoteTags.filter((t) => !localValues.has(t.value));
3537
+ merged[cat] = [...mergedLocal, ...onlyInRemote];
3538
+ }
3539
+ const all = Object.entries(merged).flatMap(([cat, tags]) => tags.map((t) => ({ ...t, category: cat })));
3540
+ return { by_category: merged, all };
3541
+ };
3518
3542
  useEffect5(() => {
3519
3543
  if (!hfToken || !workspaceTags) return;
3520
3544
  if (hfTagSaveTimer.current) clearTimeout(hfTagSaveTimer.current);
3521
- hfTagSaveTimer.current = setTimeout(() => {
3522
- hfSaveTags(workspaceTags, hfToken).catch(() => {
3545
+ hfTagSaveTimer.current = setTimeout(async () => {
3546
+ const remote = await hfLoadTags(hfToken).catch(() => null);
3547
+ const merged = mergeWorkspaceTags(workspaceTags, remote);
3548
+ await hfSaveTags(merged, hfToken).catch(() => {
3523
3549
  });
3550
+ if (Object.values(merged.by_category).some(
3551
+ (tags, i) => tags.length !== Object.values(workspaceTags.by_category)[i]?.length
3552
+ )) setWorkspaceTags(merged);
3524
3553
  }, 1500);
3525
3554
  return () => {
3526
3555
  if (hfTagSaveTimer.current) clearTimeout(hfTagSaveTimer.current);
@@ -4321,7 +4350,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
4321
4350
  }
4322
4351
 
4323
4352
  // src/index.ts
4324
- var LIB_VERSION = "1.3.10";
4353
+ var LIB_VERSION = "1.3.12";
4325
4354
  export {
4326
4355
  AvatarArchitectApp,
4327
4356
  CollapsibleCard,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslsp1/fa-app-tools",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "description": "Shared tools and hooks for Fine Art flow apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",