@rslsp1/fa-app-tools 0.1.13 → 0.1.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/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +54 -0
- package/dist/index.mjs +49 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -65,6 +65,12 @@ declare function exportProjectToZip(nodes: any[], edges: any[], history: any[],
|
|
|
65
65
|
}>;
|
|
66
66
|
declare function importProjectFromZip(file: File): Promise<any>;
|
|
67
67
|
|
|
68
|
+
declare function buildGenerationPrompt(hierarchyText: string, mode?: 'literal' | 'creative'): string;
|
|
69
|
+
declare function buildFallbackPrompt(hierarchyText: string): string;
|
|
70
|
+
declare function cleanAiResponse(text: string): string;
|
|
71
|
+
declare function buildImageGenerationOptions(prompt: string, aspectRatio: string, model: string, referenceMediaId?: string): Record<string, any>;
|
|
72
|
+
declare function interpretSdkError(err: any): Error;
|
|
73
|
+
|
|
68
74
|
interface ExtractedCharacter {
|
|
69
75
|
name: string;
|
|
70
76
|
prompts: {
|
|
@@ -183,4 +189,4 @@ interface AvatarArchitectAppProps {
|
|
|
183
189
|
}
|
|
184
190
|
declare function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onSelectMedia }: AvatarArchitectAppProps): react_jsx_runtime.JSX.Element;
|
|
185
191
|
|
|
186
|
-
export { AvatarArchitectApp, type AvatarArchitectAppProps, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectSettings, SectionLabel, SetupPanel, type WorkspaceTags, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, parsePromptFile, useKeyboardNavigation, useOnClickOutside };
|
|
192
|
+
export { AvatarArchitectApp, type AvatarArchitectAppProps, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectSettings, SectionLabel, SetupPanel, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, cleanAiResponse, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, useKeyboardNavigation, useOnClickOutside };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,12 @@ declare function exportProjectToZip(nodes: any[], edges: any[], history: any[],
|
|
|
65
65
|
}>;
|
|
66
66
|
declare function importProjectFromZip(file: File): Promise<any>;
|
|
67
67
|
|
|
68
|
+
declare function buildGenerationPrompt(hierarchyText: string, mode?: 'literal' | 'creative'): string;
|
|
69
|
+
declare function buildFallbackPrompt(hierarchyText: string): string;
|
|
70
|
+
declare function cleanAiResponse(text: string): string;
|
|
71
|
+
declare function buildImageGenerationOptions(prompt: string, aspectRatio: string, model: string, referenceMediaId?: string): Record<string, any>;
|
|
72
|
+
declare function interpretSdkError(err: any): Error;
|
|
73
|
+
|
|
68
74
|
interface ExtractedCharacter {
|
|
69
75
|
name: string;
|
|
70
76
|
prompts: {
|
|
@@ -183,4 +189,4 @@ interface AvatarArchitectAppProps {
|
|
|
183
189
|
}
|
|
184
190
|
declare function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onSelectMedia }: AvatarArchitectAppProps): react_jsx_runtime.JSX.Element;
|
|
185
191
|
|
|
186
|
-
export { AvatarArchitectApp, type AvatarArchitectAppProps, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectSettings, SectionLabel, SetupPanel, type WorkspaceTags, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, parsePromptFile, useKeyboardNavigation, useOnClickOutside };
|
|
192
|
+
export { AvatarArchitectApp, type AvatarArchitectAppProps, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectSettings, SectionLabel, SetupPanel, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, cleanAiResponse, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, useKeyboardNavigation, useOnClickOutside };
|
package/dist/index.js
CHANGED
|
@@ -41,11 +41,16 @@ __export(index_exports, {
|
|
|
41
41
|
PillButton: () => PillButton,
|
|
42
42
|
SectionLabel: () => SectionLabel,
|
|
43
43
|
SetupPanel: () => SetupPanel,
|
|
44
|
+
buildFallbackPrompt: () => buildFallbackPrompt,
|
|
45
|
+
buildGenerationPrompt: () => buildGenerationPrompt,
|
|
46
|
+
buildImageGenerationOptions: () => buildImageGenerationOptions,
|
|
47
|
+
cleanAiResponse: () => cleanAiResponse,
|
|
44
48
|
exportProjectToZip: () => exportProjectToZip,
|
|
45
49
|
formatTreeToMarkdown: () => formatTreeToMarkdown,
|
|
46
50
|
getFormattedTimestamp: () => getFormattedTimestamp,
|
|
47
51
|
importProjectFromZip: () => importProjectFromZip,
|
|
48
52
|
injectXMPMetadata: () => injectXMPMetadata,
|
|
53
|
+
interpretSdkError: () => interpretSdkError,
|
|
49
54
|
parsePromptFile: () => parsePromptFile,
|
|
50
55
|
useKeyboardNavigation: () => useKeyboardNavigation,
|
|
51
56
|
useOnClickOutside: () => useOnClickOutside
|
|
@@ -314,6 +319,50 @@ async function importProjectFromZip(file) {
|
|
|
314
319
|
return data;
|
|
315
320
|
}
|
|
316
321
|
|
|
322
|
+
// src/lib/aiHelpers.ts
|
|
323
|
+
function buildGenerationPrompt(hierarchyText, mode = "creative") {
|
|
324
|
+
const safe = hierarchyText.length > 2500 ? hierarchyText.slice(0, 2500) + "..." : hierarchyText;
|
|
325
|
+
if (mode === "literal") {
|
|
326
|
+
return `Translate this hierarchy into a literal image generation prompt. Output ONLY the raw prompt string. No chat.
|
|
327
|
+
|
|
328
|
+
HIERARCHY:
|
|
329
|
+
${safe}`;
|
|
330
|
+
}
|
|
331
|
+
return `Create a cinematic, high-quality image generation prompt based on this hierarchy. Translate everything to English. Output ONLY the prompt string. No chat.
|
|
332
|
+
|
|
333
|
+
HIERARCHY:
|
|
334
|
+
${safe}`;
|
|
335
|
+
}
|
|
336
|
+
function buildFallbackPrompt(hierarchyText) {
|
|
337
|
+
const lines = hierarchyText.split("\n");
|
|
338
|
+
const firstConcept = lines.find((l) => l.includes("-"))?.replace(/^[-\s]+/, "") || "character concept";
|
|
339
|
+
return `Cinematic professional photograph of ${firstConcept}, masterpiece, highly detailed, fine art style`;
|
|
340
|
+
}
|
|
341
|
+
function cleanAiResponse(text) {
|
|
342
|
+
return text.replace(/^["']|["']$/g, "").replace(/```/g, "").trim();
|
|
343
|
+
}
|
|
344
|
+
function buildImageGenerationOptions(prompt, aspectRatio, model, referenceMediaId) {
|
|
345
|
+
const options = {
|
|
346
|
+
prompt: prompt.replace(/\n/g, " ").trim().slice(0, 1500),
|
|
347
|
+
aspectRatio,
|
|
348
|
+
modelDisplayName: model
|
|
349
|
+
};
|
|
350
|
+
if (referenceMediaId && referenceMediaId.length > 5) {
|
|
351
|
+
options.referenceImageMediaIds = [referenceMediaId];
|
|
352
|
+
}
|
|
353
|
+
return options;
|
|
354
|
+
}
|
|
355
|
+
function interpretSdkError(err) {
|
|
356
|
+
const msg = err?.message || "Generierung fehlgeschlagen";
|
|
357
|
+
if (msg.includes("PUBLIC_ERROR_SOMETHING_WENT_WRONG")) {
|
|
358
|
+
return new Error("Plattform-Fehler: Die Anfrage wurde abgelehnt. M\xF6gliche Ursachen: Sicherheitsfilter (Prompt-Inhalt) oder tempor\xE4re \xDCberlastung. Versuche einen neutraleren Prompt.");
|
|
359
|
+
}
|
|
360
|
+
if (msg.includes("PUBLIC_ERROR")) {
|
|
361
|
+
return new Error(`Plattform-Fehler: ${msg}`);
|
|
362
|
+
}
|
|
363
|
+
return new Error(msg);
|
|
364
|
+
}
|
|
365
|
+
|
|
317
366
|
// src/lib/parserService.ts
|
|
318
367
|
function parsePromptFile(text) {
|
|
319
368
|
const characters = [];
|
|
@@ -1081,11 +1130,16 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
|
|
|
1081
1130
|
PillButton,
|
|
1082
1131
|
SectionLabel,
|
|
1083
1132
|
SetupPanel,
|
|
1133
|
+
buildFallbackPrompt,
|
|
1134
|
+
buildGenerationPrompt,
|
|
1135
|
+
buildImageGenerationOptions,
|
|
1136
|
+
cleanAiResponse,
|
|
1084
1137
|
exportProjectToZip,
|
|
1085
1138
|
formatTreeToMarkdown,
|
|
1086
1139
|
getFormattedTimestamp,
|
|
1087
1140
|
importProjectFromZip,
|
|
1088
1141
|
injectXMPMetadata,
|
|
1142
|
+
interpretSdkError,
|
|
1089
1143
|
parsePromptFile,
|
|
1090
1144
|
useKeyboardNavigation,
|
|
1091
1145
|
useOnClickOutside
|
package/dist/index.mjs
CHANGED
|
@@ -260,6 +260,50 @@ async function importProjectFromZip(file) {
|
|
|
260
260
|
return data;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
// src/lib/aiHelpers.ts
|
|
264
|
+
function buildGenerationPrompt(hierarchyText, mode = "creative") {
|
|
265
|
+
const safe = hierarchyText.length > 2500 ? hierarchyText.slice(0, 2500) + "..." : hierarchyText;
|
|
266
|
+
if (mode === "literal") {
|
|
267
|
+
return `Translate this hierarchy into a literal image generation prompt. Output ONLY the raw prompt string. No chat.
|
|
268
|
+
|
|
269
|
+
HIERARCHY:
|
|
270
|
+
${safe}`;
|
|
271
|
+
}
|
|
272
|
+
return `Create a cinematic, high-quality image generation prompt based on this hierarchy. Translate everything to English. Output ONLY the prompt string. No chat.
|
|
273
|
+
|
|
274
|
+
HIERARCHY:
|
|
275
|
+
${safe}`;
|
|
276
|
+
}
|
|
277
|
+
function buildFallbackPrompt(hierarchyText) {
|
|
278
|
+
const lines = hierarchyText.split("\n");
|
|
279
|
+
const firstConcept = lines.find((l) => l.includes("-"))?.replace(/^[-\s]+/, "") || "character concept";
|
|
280
|
+
return `Cinematic professional photograph of ${firstConcept}, masterpiece, highly detailed, fine art style`;
|
|
281
|
+
}
|
|
282
|
+
function cleanAiResponse(text) {
|
|
283
|
+
return text.replace(/^["']|["']$/g, "").replace(/```/g, "").trim();
|
|
284
|
+
}
|
|
285
|
+
function buildImageGenerationOptions(prompt, aspectRatio, model, referenceMediaId) {
|
|
286
|
+
const options = {
|
|
287
|
+
prompt: prompt.replace(/\n/g, " ").trim().slice(0, 1500),
|
|
288
|
+
aspectRatio,
|
|
289
|
+
modelDisplayName: model
|
|
290
|
+
};
|
|
291
|
+
if (referenceMediaId && referenceMediaId.length > 5) {
|
|
292
|
+
options.referenceImageMediaIds = [referenceMediaId];
|
|
293
|
+
}
|
|
294
|
+
return options;
|
|
295
|
+
}
|
|
296
|
+
function interpretSdkError(err) {
|
|
297
|
+
const msg = err?.message || "Generierung fehlgeschlagen";
|
|
298
|
+
if (msg.includes("PUBLIC_ERROR_SOMETHING_WENT_WRONG")) {
|
|
299
|
+
return new Error("Plattform-Fehler: Die Anfrage wurde abgelehnt. M\xF6gliche Ursachen: Sicherheitsfilter (Prompt-Inhalt) oder tempor\xE4re \xDCberlastung. Versuche einen neutraleren Prompt.");
|
|
300
|
+
}
|
|
301
|
+
if (msg.includes("PUBLIC_ERROR")) {
|
|
302
|
+
return new Error(`Plattform-Fehler: ${msg}`);
|
|
303
|
+
}
|
|
304
|
+
return new Error(msg);
|
|
305
|
+
}
|
|
306
|
+
|
|
263
307
|
// src/lib/parserService.ts
|
|
264
308
|
function parsePromptFile(text) {
|
|
265
309
|
const characters = [];
|
|
@@ -1026,11 +1070,16 @@ export {
|
|
|
1026
1070
|
PillButton,
|
|
1027
1071
|
SectionLabel,
|
|
1028
1072
|
SetupPanel,
|
|
1073
|
+
buildFallbackPrompt,
|
|
1074
|
+
buildGenerationPrompt,
|
|
1075
|
+
buildImageGenerationOptions,
|
|
1076
|
+
cleanAiResponse,
|
|
1029
1077
|
exportProjectToZip,
|
|
1030
1078
|
formatTreeToMarkdown,
|
|
1031
1079
|
getFormattedTimestamp,
|
|
1032
1080
|
importProjectFromZip,
|
|
1033
1081
|
injectXMPMetadata,
|
|
1082
|
+
interpretSdkError,
|
|
1034
1083
|
parsePromptFile,
|
|
1035
1084
|
useKeyboardNavigation,
|
|
1036
1085
|
useOnClickOutside
|