@shop-os/modelkit 0.7.3 → 0.7.4
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/CHANGELOG.md +7 -0
- package/dist/catalog.cjs +155 -150
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +155 -150
- package/dist/catalog.js.map +1 -1
- package/dist/index.cjs +193 -157
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +193 -157
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6549,6 +6549,161 @@ var MODEL3D_IMAGE_SLOTS = {
|
|
|
6549
6549
|
ordered: ["image", "left", "back", "right"],
|
|
6550
6550
|
unordered: ["image", "back", "left", "right", "top"]
|
|
6551
6551
|
};
|
|
6552
|
+
var MODEL3D_FAMILY_RULES = {
|
|
6553
|
+
trellis: {
|
|
6554
|
+
textPath: false,
|
|
6555
|
+
views: ["none"],
|
|
6556
|
+
multiImage: false,
|
|
6557
|
+
texture: null,
|
|
6558
|
+
pbr: false,
|
|
6559
|
+
seed: true,
|
|
6560
|
+
textureRef: false,
|
|
6561
|
+
resolutions: "integer"
|
|
6562
|
+
},
|
|
6563
|
+
hunyuan: {
|
|
6564
|
+
textPath: true,
|
|
6565
|
+
views: ["none", "named"],
|
|
6566
|
+
multiImage: false,
|
|
6567
|
+
// generate_type
|
|
6568
|
+
texture: { none: "Geometry", standard: "Normal" },
|
|
6569
|
+
pbr: true,
|
|
6570
|
+
seed: false,
|
|
6571
|
+
textureRef: false,
|
|
6572
|
+
resolutions: null
|
|
6573
|
+
},
|
|
6574
|
+
tripo: {
|
|
6575
|
+
textPath: true,
|
|
6576
|
+
views: ["none", "ordered"],
|
|
6577
|
+
multiImage: true,
|
|
6578
|
+
// texture_quality; null sends an untextured model.
|
|
6579
|
+
texture: { none: null, standard: "standard", detailed: "detailed" },
|
|
6580
|
+
pbr: true,
|
|
6581
|
+
seed: true,
|
|
6582
|
+
textureRef: false,
|
|
6583
|
+
resolutions: null
|
|
6584
|
+
},
|
|
6585
|
+
rodin: {
|
|
6586
|
+
textPath: true,
|
|
6587
|
+
views: ["none", "unordered"],
|
|
6588
|
+
multiImage: false,
|
|
6589
|
+
texture: null,
|
|
6590
|
+
pbr: false,
|
|
6591
|
+
seed: true,
|
|
6592
|
+
textureRef: false,
|
|
6593
|
+
resolutions: null
|
|
6594
|
+
},
|
|
6595
|
+
meshy: {
|
|
6596
|
+
textPath: true,
|
|
6597
|
+
views: ["none", "unordered"],
|
|
6598
|
+
multiImage: true,
|
|
6599
|
+
// The text endpoint's mode; the image endpoints take should_texture.
|
|
6600
|
+
texture: { none: "preview", standard: "full" },
|
|
6601
|
+
pbr: true,
|
|
6602
|
+
seed: true,
|
|
6603
|
+
textureRef: true,
|
|
6604
|
+
resolutions: null
|
|
6605
|
+
},
|
|
6606
|
+
hi3d: {
|
|
6607
|
+
textPath: false,
|
|
6608
|
+
views: ["none", "named"],
|
|
6609
|
+
multiImage: true,
|
|
6610
|
+
// enable_texture
|
|
6611
|
+
texture: { none: false, standard: true },
|
|
6612
|
+
pbr: true,
|
|
6613
|
+
seed: false,
|
|
6614
|
+
textureRef: false,
|
|
6615
|
+
resolutions: { quality: "2048quality", master: "2048master" }
|
|
6616
|
+
},
|
|
6617
|
+
sam: {
|
|
6618
|
+
textPath: false,
|
|
6619
|
+
views: ["none"],
|
|
6620
|
+
multiImage: false,
|
|
6621
|
+
texture: null,
|
|
6622
|
+
pbr: false,
|
|
6623
|
+
seed: true,
|
|
6624
|
+
textureRef: false,
|
|
6625
|
+
resolutions: null
|
|
6626
|
+
}
|
|
6627
|
+
};
|
|
6628
|
+
function model3dSpecIssues(spec) {
|
|
6629
|
+
const issues = [];
|
|
6630
|
+
const add = (path, message) => issues.push({ path, message });
|
|
6631
|
+
const rules = MODEL3D_FAMILY_RULES[spec.family];
|
|
6632
|
+
const promptOnly = spec.text && !spec.imageRequired;
|
|
6633
|
+
if (spec.endpoints.image === void 0)
|
|
6634
|
+
add(["endpoints", "image"], "every row needs an image endpoint");
|
|
6635
|
+
if (promptOnly && !rules.textPath) {
|
|
6636
|
+
add(
|
|
6637
|
+
["imageRequired"],
|
|
6638
|
+
`${spec.family} has no text-to-3D endpoint; a text row needs an image`
|
|
6639
|
+
);
|
|
6640
|
+
}
|
|
6641
|
+
if (promptOnly && spec.endpoints.text === void 0) {
|
|
6642
|
+
add(["endpoints", "text"], "a text row needs a text endpoint");
|
|
6643
|
+
}
|
|
6644
|
+
if (!rules.views.includes(spec.views)) {
|
|
6645
|
+
add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
|
|
6646
|
+
}
|
|
6647
|
+
if (spec.views === "none" && spec.maxImages !== 1) {
|
|
6648
|
+
add(["maxImages"], "a row without views takes 1 image");
|
|
6649
|
+
}
|
|
6650
|
+
if (spec.views === "unordered" && spec.maxImages < 2) {
|
|
6651
|
+
add(["maxImages"], "a row with views takes at least 2 images");
|
|
6652
|
+
}
|
|
6653
|
+
const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
|
|
6654
|
+
if (spec.views !== "none" && spec.maxImages > slots) {
|
|
6655
|
+
add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
|
|
6656
|
+
}
|
|
6657
|
+
if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
|
|
6658
|
+
add(
|
|
6659
|
+
["maxImages"],
|
|
6660
|
+
`a row with ${spec.views} views takes ${slots} images (front and three sides)`
|
|
6661
|
+
);
|
|
6662
|
+
}
|
|
6663
|
+
if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
|
|
6664
|
+
add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
|
|
6665
|
+
}
|
|
6666
|
+
if (rules.texture === null) {
|
|
6667
|
+
if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
|
|
6668
|
+
} else {
|
|
6669
|
+
const allowed = rules.texture;
|
|
6670
|
+
if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
|
|
6671
|
+
if (new Set(spec.texture).size !== spec.texture.length)
|
|
6672
|
+
add(["texture"], "texture options repeat");
|
|
6673
|
+
for (const t of spec.texture) {
|
|
6674
|
+
if (!Object.hasOwn(allowed, t))
|
|
6675
|
+
add(["texture"], `${spec.family} has no "${t}" texture`);
|
|
6676
|
+
}
|
|
6677
|
+
}
|
|
6678
|
+
if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
|
|
6679
|
+
if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
|
|
6680
|
+
add(["pbr"], "PBR needs a textured option");
|
|
6681
|
+
}
|
|
6682
|
+
if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
|
|
6683
|
+
if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
|
|
6684
|
+
if (spec.textureRef && !rules.textureRef)
|
|
6685
|
+
add(["textureRef"], `${spec.family} takes no texture reference`);
|
|
6686
|
+
const res = spec.resolutions;
|
|
6687
|
+
if (rules.resolutions === null) {
|
|
6688
|
+
if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
|
|
6689
|
+
} else if (res === void 0) {
|
|
6690
|
+
add(["resolutions"], `${spec.family} needs its resolution options`);
|
|
6691
|
+
} else {
|
|
6692
|
+
if (!res.options.includes(res.default)) {
|
|
6693
|
+
add(["resolutions", "default"], "default must be an option");
|
|
6694
|
+
}
|
|
6695
|
+
if (new Set(res.options).size !== res.options.length) {
|
|
6696
|
+
add(["resolutions", "options"], "resolution options repeat");
|
|
6697
|
+
}
|
|
6698
|
+
const allowed = rules.resolutions;
|
|
6699
|
+
for (const option of res.options) {
|
|
6700
|
+
const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : Object.hasOwn(allowed, option);
|
|
6701
|
+
if (!ok)
|
|
6702
|
+
add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
return issues;
|
|
6706
|
+
}
|
|
6552
6707
|
function model3dInputRefusal(spec, wired) {
|
|
6553
6708
|
const top = spec.views === "unordered" && wired.top === true;
|
|
6554
6709
|
const anyView = spec.views !== "none" && (wired.back || wired.left || wired.right || top);
|
|
@@ -7136,156 +7291,6 @@ var LanguageOptionSchema = z3.looseObject({
|
|
|
7136
7291
|
code: z3.string().min(1),
|
|
7137
7292
|
name: z3.string().min(1)
|
|
7138
7293
|
});
|
|
7139
|
-
var MODEL3D_FAMILY_RULES = {
|
|
7140
|
-
trellis: {
|
|
7141
|
-
textPath: false,
|
|
7142
|
-
views: ["none"],
|
|
7143
|
-
multiImage: false,
|
|
7144
|
-
texture: null,
|
|
7145
|
-
pbr: false,
|
|
7146
|
-
seed: true,
|
|
7147
|
-
textureRef: false,
|
|
7148
|
-
resolutions: "integer"
|
|
7149
|
-
},
|
|
7150
|
-
hunyuan: {
|
|
7151
|
-
textPath: true,
|
|
7152
|
-
views: ["none", "named"],
|
|
7153
|
-
multiImage: false,
|
|
7154
|
-
texture: ["none", "standard"],
|
|
7155
|
-
pbr: true,
|
|
7156
|
-
seed: false,
|
|
7157
|
-
textureRef: false,
|
|
7158
|
-
resolutions: null
|
|
7159
|
-
},
|
|
7160
|
-
tripo: {
|
|
7161
|
-
textPath: true,
|
|
7162
|
-
views: ["none", "ordered"],
|
|
7163
|
-
multiImage: true,
|
|
7164
|
-
texture: ["none", "standard", "detailed"],
|
|
7165
|
-
pbr: true,
|
|
7166
|
-
seed: true,
|
|
7167
|
-
textureRef: false,
|
|
7168
|
-
resolutions: null
|
|
7169
|
-
},
|
|
7170
|
-
rodin: {
|
|
7171
|
-
textPath: true,
|
|
7172
|
-
views: ["none", "unordered"],
|
|
7173
|
-
multiImage: false,
|
|
7174
|
-
texture: null,
|
|
7175
|
-
pbr: false,
|
|
7176
|
-
seed: true,
|
|
7177
|
-
textureRef: false,
|
|
7178
|
-
resolutions: null
|
|
7179
|
-
},
|
|
7180
|
-
meshy: {
|
|
7181
|
-
textPath: true,
|
|
7182
|
-
views: ["none", "unordered"],
|
|
7183
|
-
multiImage: true,
|
|
7184
|
-
texture: ["none", "standard"],
|
|
7185
|
-
pbr: true,
|
|
7186
|
-
seed: true,
|
|
7187
|
-
textureRef: true,
|
|
7188
|
-
resolutions: null
|
|
7189
|
-
},
|
|
7190
|
-
hi3d: {
|
|
7191
|
-
textPath: false,
|
|
7192
|
-
views: ["none", "named"],
|
|
7193
|
-
multiImage: true,
|
|
7194
|
-
texture: ["none", "standard"],
|
|
7195
|
-
pbr: true,
|
|
7196
|
-
seed: false,
|
|
7197
|
-
textureRef: false,
|
|
7198
|
-
resolutions: ["quality", "master"]
|
|
7199
|
-
},
|
|
7200
|
-
sam: {
|
|
7201
|
-
textPath: false,
|
|
7202
|
-
views: ["none"],
|
|
7203
|
-
multiImage: false,
|
|
7204
|
-
texture: null,
|
|
7205
|
-
pbr: false,
|
|
7206
|
-
seed: true,
|
|
7207
|
-
textureRef: false,
|
|
7208
|
-
resolutions: null
|
|
7209
|
-
}
|
|
7210
|
-
};
|
|
7211
|
-
function model3dSpecIssues(spec) {
|
|
7212
|
-
const issues = [];
|
|
7213
|
-
const add = (path, message) => issues.push({ path, message });
|
|
7214
|
-
const rules = MODEL3D_FAMILY_RULES[spec.family];
|
|
7215
|
-
const promptOnly = spec.text && !spec.imageRequired;
|
|
7216
|
-
if (spec.endpoints.image === void 0)
|
|
7217
|
-
add(["endpoints", "image"], "every row needs an image endpoint");
|
|
7218
|
-
if (promptOnly && !rules.textPath) {
|
|
7219
|
-
add(
|
|
7220
|
-
["imageRequired"],
|
|
7221
|
-
`${spec.family} has no text-to-3D endpoint; a text row needs an image`
|
|
7222
|
-
);
|
|
7223
|
-
}
|
|
7224
|
-
if (promptOnly && spec.endpoints.text === void 0) {
|
|
7225
|
-
add(["endpoints", "text"], "a text row needs a text endpoint");
|
|
7226
|
-
}
|
|
7227
|
-
if (!rules.views.includes(spec.views)) {
|
|
7228
|
-
add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
|
|
7229
|
-
}
|
|
7230
|
-
if (spec.views === "none" && spec.maxImages !== 1) {
|
|
7231
|
-
add(["maxImages"], "a row without views takes 1 image");
|
|
7232
|
-
}
|
|
7233
|
-
if (spec.views === "unordered" && spec.maxImages < 2) {
|
|
7234
|
-
add(["maxImages"], "a row with views takes at least 2 images");
|
|
7235
|
-
}
|
|
7236
|
-
const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
|
|
7237
|
-
if (spec.views !== "none" && spec.maxImages > slots) {
|
|
7238
|
-
add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
|
|
7239
|
-
}
|
|
7240
|
-
if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
|
|
7241
|
-
add(
|
|
7242
|
-
["maxImages"],
|
|
7243
|
-
`a row with ${spec.views} views takes ${slots} images (front and three sides)`
|
|
7244
|
-
);
|
|
7245
|
-
}
|
|
7246
|
-
if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
|
|
7247
|
-
add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
|
|
7248
|
-
}
|
|
7249
|
-
if (rules.texture === null) {
|
|
7250
|
-
if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
|
|
7251
|
-
} else {
|
|
7252
|
-
const allowed = rules.texture;
|
|
7253
|
-
if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
|
|
7254
|
-
if (new Set(spec.texture).size !== spec.texture.length)
|
|
7255
|
-
add(["texture"], "texture options repeat");
|
|
7256
|
-
for (const t of spec.texture) {
|
|
7257
|
-
if (!allowed.includes(t)) add(["texture"], `${spec.family} has no "${t}" texture`);
|
|
7258
|
-
}
|
|
7259
|
-
}
|
|
7260
|
-
if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
|
|
7261
|
-
if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
|
|
7262
|
-
add(["pbr"], "PBR needs a textured option");
|
|
7263
|
-
}
|
|
7264
|
-
if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
|
|
7265
|
-
if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
|
|
7266
|
-
if (spec.textureRef && !rules.textureRef)
|
|
7267
|
-
add(["textureRef"], `${spec.family} takes no texture reference`);
|
|
7268
|
-
const res = spec.resolutions;
|
|
7269
|
-
if (rules.resolutions === null) {
|
|
7270
|
-
if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
|
|
7271
|
-
} else if (res === void 0) {
|
|
7272
|
-
add(["resolutions"], `${spec.family} needs its resolution options`);
|
|
7273
|
-
} else {
|
|
7274
|
-
if (!res.options.includes(res.default)) {
|
|
7275
|
-
add(["resolutions", "default"], "default must be an option");
|
|
7276
|
-
}
|
|
7277
|
-
if (new Set(res.options).size !== res.options.length) {
|
|
7278
|
-
add(["resolutions", "options"], "resolution options repeat");
|
|
7279
|
-
}
|
|
7280
|
-
const allowed = rules.resolutions;
|
|
7281
|
-
for (const option of res.options) {
|
|
7282
|
-
const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : allowed.includes(option);
|
|
7283
|
-
if (!ok)
|
|
7284
|
-
add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
|
|
7285
|
-
}
|
|
7286
|
-
}
|
|
7287
|
-
return issues;
|
|
7288
|
-
}
|
|
7289
7294
|
var VideoToolConstraintsSchema = z3.looseObject({
|
|
7290
7295
|
kind: z3.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles"]),
|
|
7291
7296
|
upscaleFactor: RangeSchema.optional(),
|
|
@@ -10687,6 +10692,19 @@ function specOf(ctx) {
|
|
|
10687
10692
|
return spec;
|
|
10688
10693
|
}
|
|
10689
10694
|
var present = (v) => v !== void 0 && v.length > 0;
|
|
10695
|
+
function wireValue(row2, values, option, what) {
|
|
10696
|
+
const value = option !== void 0 && Object.hasOwn(values, option) ? values[option] : void 0;
|
|
10697
|
+
if (value === void 0) {
|
|
10698
|
+
throw new ModelKitError({
|
|
10699
|
+
code: "unsupported_option",
|
|
10700
|
+
message: `${row2.id} has no ${what} "${option ?? ""}" to send`,
|
|
10701
|
+
provider: "fal",
|
|
10702
|
+
model: row2.id,
|
|
10703
|
+
retryable: false
|
|
10704
|
+
});
|
|
10705
|
+
}
|
|
10706
|
+
return value;
|
|
10707
|
+
}
|
|
10690
10708
|
function model3dCall(row2, spec, req) {
|
|
10691
10709
|
const prompt = req.prompt?.trim() || void 0;
|
|
10692
10710
|
const texture = model3dTexture(spec, req.texture);
|
|
@@ -10730,7 +10748,15 @@ function model3dCall(row2, spec, req) {
|
|
|
10730
10748
|
}
|
|
10731
10749
|
};
|
|
10732
10750
|
case "hunyuan": {
|
|
10733
|
-
const opts = {
|
|
10751
|
+
const opts = {
|
|
10752
|
+
generate_type: wireValue(
|
|
10753
|
+
row2,
|
|
10754
|
+
MODEL3D_FAMILY_RULES.hunyuan.texture,
|
|
10755
|
+
texture,
|
|
10756
|
+
"texture"
|
|
10757
|
+
),
|
|
10758
|
+
enable_pbr: pbr
|
|
10759
|
+
};
|
|
10734
10760
|
if (!present(req.image)) {
|
|
10735
10761
|
return {
|
|
10736
10762
|
endpoint: endpoint(spec.endpoints.text),
|
|
@@ -10749,12 +10775,11 @@ function model3dCall(row2, spec, req) {
|
|
|
10749
10775
|
};
|
|
10750
10776
|
}
|
|
10751
10777
|
case "tripo": {
|
|
10778
|
+
const quality = wireValue(row2, MODEL3D_FAMILY_RULES.tripo.texture, texture, "texture");
|
|
10752
10779
|
const opts = {
|
|
10753
10780
|
texture: textured,
|
|
10754
10781
|
pbr,
|
|
10755
|
-
...
|
|
10756
|
-
texture_quality: texture === "detailed" ? "detailed" : "standard"
|
|
10757
|
-
},
|
|
10782
|
+
...quality !== null && { texture_quality: quality },
|
|
10758
10783
|
...seed !== void 0 && { model_seed: seed }
|
|
10759
10784
|
};
|
|
10760
10785
|
if (!present(req.image)) {
|
|
@@ -10790,6 +10815,7 @@ function model3dCall(row2, spec, req) {
|
|
|
10790
10815
|
};
|
|
10791
10816
|
}
|
|
10792
10817
|
case "meshy": {
|
|
10818
|
+
const mode = wireValue(row2, MODEL3D_FAMILY_RULES.meshy.texture, texture, "texture");
|
|
10793
10819
|
const texturePrompt = req.texturePrompt?.trim() || void 0;
|
|
10794
10820
|
const opts = {
|
|
10795
10821
|
enable_pbr: pbr,
|
|
@@ -10801,7 +10827,7 @@ function model3dCall(row2, spec, req) {
|
|
|
10801
10827
|
endpoint: endpoint(spec.endpoints.text),
|
|
10802
10828
|
input: {
|
|
10803
10829
|
prompt: prompt ?? "",
|
|
10804
|
-
mode
|
|
10830
|
+
mode,
|
|
10805
10831
|
...opts,
|
|
10806
10832
|
...seed !== void 0 && { seed }
|
|
10807
10833
|
}
|
|
@@ -10817,8 +10843,18 @@ function model3dCall(row2, spec, req) {
|
|
|
10817
10843
|
}
|
|
10818
10844
|
case "hi3d": {
|
|
10819
10845
|
const opts = {
|
|
10820
|
-
resolution:
|
|
10821
|
-
|
|
10846
|
+
resolution: wireValue(
|
|
10847
|
+
row2,
|
|
10848
|
+
MODEL3D_FAMILY_RULES.hi3d.resolutions,
|
|
10849
|
+
resolution,
|
|
10850
|
+
"resolution"
|
|
10851
|
+
),
|
|
10852
|
+
enable_texture: wireValue(
|
|
10853
|
+
row2,
|
|
10854
|
+
MODEL3D_FAMILY_RULES.hi3d.texture,
|
|
10855
|
+
texture,
|
|
10856
|
+
"texture"
|
|
10857
|
+
),
|
|
10822
10858
|
enable_pbr: pbr,
|
|
10823
10859
|
export_format: "glb"
|
|
10824
10860
|
};
|