@enslo/sd-metadata 1.8.0 → 1.8.1

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/README.ja.md CHANGED
@@ -149,7 +149,7 @@ if (result.status === 'success') {
149
149
  > 本番環境では `@latest` の代わりに特定のバージョンを指定してください:
150
150
  >
151
151
  > ```text
152
- > https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@1.8.0/dist/index.js
152
+ > https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@1.8.1/dist/index.js
153
153
  > ```
154
154
 
155
155
  ### 応用例
package/README.md CHANGED
@@ -148,7 +148,7 @@ if (result.status === 'success') {
148
148
  > For production use, pin to a specific version instead of `@latest`:
149
149
  >
150
150
  > ```text
151
- > https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@1.8.0/dist/index.js
151
+ > https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@1.8.1/dist/index.js
152
152
  > ```
153
153
 
154
154
  ### Advanced Examples
package/dist/index.js CHANGED
@@ -18,10 +18,6 @@ function parseA1111(entries) {
18
18
  if (!text) {
19
19
  return Result.error({ type: "unsupportedFormat" });
20
20
  }
21
- const hasAIMarkers = text.includes("Steps:") || text.includes("Sampler:") || text.includes("Negative prompt:");
22
- if (!hasAIMarkers) {
23
- return Result.error({ type: "unsupportedFormat" });
24
- }
25
21
  const { prompt, negativePrompt, settings } = parseParametersText(text);
26
22
  const settingsMap = parseSettings(settings);
27
23
  const size = settingsMap.get("Size") ?? "0x0";
@@ -393,9 +389,6 @@ function parseComfyUI(entries) {
393
389
  });
394
390
  }
395
391
  const prompt = parsed.value;
396
- if (!Object.values(prompt).some((node) => "class_type" in node)) {
397
- return Result.error({ type: "unsupportedFormat" });
398
- }
399
392
  const comfyMetadata = extractComfyUIMetadata(prompt);
400
393
  const civitaiMetadata = extractCivitaiMetadata(
401
394
  extractExtraMetadata(prompt, entries)
@@ -618,24 +611,22 @@ function detectFromCommentJson(comment) {
618
611
  return null;
619
612
  }
620
613
  function detectComfyUIEntries(entryRecord) {
621
- if ("prompt" in entryRecord && "workflow" in entryRecord) {
614
+ if ("prompt" in entryRecord && "workflow" in entryRecord || "Prompt" in entryRecord && "Workflow" in entryRecord) {
622
615
  return "comfyui";
623
616
  }
624
- if ("workflow" in entryRecord) {
617
+ if ("workflow" in entryRecord || "Workflow" in entryRecord) {
625
618
  return "comfyui";
626
619
  }
627
- if ("prompt" in entryRecord) {
628
- const promptText = entryRecord.prompt;
629
- if (promptText?.startsWith("{")) {
630
- if (promptText.includes(M_SWARMUI)) {
631
- return "swarmui";
632
- }
633
- if (promptText.includes(`"${M_CIVITAI_EXTRA}"`)) {
634
- return "civitai";
635
- }
636
- if (promptText.includes(M_COMFYUI_NODE)) {
637
- return "comfyui";
638
- }
620
+ const promptText = entryRecord.prompt ?? entryRecord.Prompt;
621
+ if (promptText?.startsWith("{")) {
622
+ if (promptText.includes(M_SWARMUI)) {
623
+ return "swarmui";
624
+ }
625
+ if (promptText.includes(`"${M_CIVITAI_EXTRA}"`)) {
626
+ return "civitai";
627
+ }
628
+ if (promptText.includes(M_COMFYUI_NODE)) {
629
+ return "comfyui";
639
630
  }
640
631
  }
641
632
  return null;
@@ -696,7 +687,7 @@ function detectFromA1111Format(text) {
696
687
  if (text.includes(M_CIVITAI_RESOURCES)) {
697
688
  return "civitai";
698
689
  }
699
- if (text.includes("Steps:") && text.includes("Sampler:")) {
690
+ if (text.includes("Steps:") || text.includes("Sampler:") || text.includes("Negative prompt:")) {
700
691
  return "sd-webui";
701
692
  }
702
693
  return null;
@@ -771,9 +762,6 @@ function parseFooocus(entries) {
771
762
  });
772
763
  }
773
764
  const json = parsed.value;
774
- if (!json.base_model && !json.prompt) {
775
- return Result.error({ type: "unsupportedFormat" });
776
- }
777
765
  const metadata = {
778
766
  software: "fooocus",
779
767
  prompt: json.prompt?.trim() ?? "",
@@ -905,9 +893,6 @@ function buildUpscale(data) {
905
893
 
906
894
  // src/parsers/novelai.ts
907
895
  function parseNovelAI(entries) {
908
- if (!entries.Software?.startsWith("NovelAI")) {
909
- return Result.error({ type: "unsupportedFormat" });
910
- }
911
896
  const commentText = entries.UserComment ?? entries.Comment;
912
897
  if (!commentText) {
913
898
  return Result.error({
@@ -968,9 +953,6 @@ function parseRuinedFooocus(entries) {
968
953
  });
969
954
  }
970
955
  const json = parsed.value;
971
- if (json.software !== "RuinedFooocus") {
972
- return Result.error({ type: "unsupportedFormat" });
973
- }
974
956
  const metadata = {
975
957
  software: "ruined-fooocus",
976
958
  prompt: json.Prompt?.trim() ?? "",
@@ -1179,23 +1161,8 @@ function parseMetadata(entries) {
1179
1161
  return parseFooocus(entries);
1180
1162
  case "ruined-fooocus":
1181
1163
  return parseRuinedFooocus(entries);
1182
- default: {
1183
- const a1111Result = parseA1111(entries);
1184
- if (a1111Result.ok) return a1111Result;
1185
- const comfyResult = parseComfyUI(entries);
1186
- if (comfyResult.ok) return comfyResult;
1187
- const invokeResult = parseInvokeAI(entries);
1188
- if (invokeResult.ok) return invokeResult;
1189
- const swarmResult = parseSwarmUI(entries);
1190
- if (swarmResult.ok) return swarmResult;
1191
- const tensorResult = parseTensorArt(entries);
1192
- if (tensorResult.ok) return tensorResult;
1193
- const stabilityResult = parseStabilityMatrix(entries);
1194
- if (stabilityResult.ok) return stabilityResult;
1195
- const novelaiResult = parseNovelAI(entries);
1196
- if (novelaiResult.ok) return novelaiResult;
1164
+ default:
1197
1165
  return Result.error({ type: "unsupportedFormat" });
1198
- }
1199
1166
  }
1200
1167
  }
1201
1168