@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/dist/catalog.js CHANGED
@@ -6550,6 +6550,161 @@ var MODEL3D_IMAGE_SLOTS = {
6550
6550
  ordered: ["image", "left", "back", "right"],
6551
6551
  unordered: ["image", "back", "left", "right", "top"]
6552
6552
  };
6553
+ var MODEL3D_FAMILY_RULES = {
6554
+ trellis: {
6555
+ textPath: false,
6556
+ views: ["none"],
6557
+ multiImage: false,
6558
+ texture: null,
6559
+ pbr: false,
6560
+ seed: true,
6561
+ textureRef: false,
6562
+ resolutions: "integer"
6563
+ },
6564
+ hunyuan: {
6565
+ textPath: true,
6566
+ views: ["none", "named"],
6567
+ multiImage: false,
6568
+ // generate_type
6569
+ texture: { none: "Geometry", standard: "Normal" },
6570
+ pbr: true,
6571
+ seed: false,
6572
+ textureRef: false,
6573
+ resolutions: null
6574
+ },
6575
+ tripo: {
6576
+ textPath: true,
6577
+ views: ["none", "ordered"],
6578
+ multiImage: true,
6579
+ // texture_quality; null sends an untextured model.
6580
+ texture: { none: null, standard: "standard", detailed: "detailed" },
6581
+ pbr: true,
6582
+ seed: true,
6583
+ textureRef: false,
6584
+ resolutions: null
6585
+ },
6586
+ rodin: {
6587
+ textPath: true,
6588
+ views: ["none", "unordered"],
6589
+ multiImage: false,
6590
+ texture: null,
6591
+ pbr: false,
6592
+ seed: true,
6593
+ textureRef: false,
6594
+ resolutions: null
6595
+ },
6596
+ meshy: {
6597
+ textPath: true,
6598
+ views: ["none", "unordered"],
6599
+ multiImage: true,
6600
+ // The text endpoint's mode; the image endpoints take should_texture.
6601
+ texture: { none: "preview", standard: "full" },
6602
+ pbr: true,
6603
+ seed: true,
6604
+ textureRef: true,
6605
+ resolutions: null
6606
+ },
6607
+ hi3d: {
6608
+ textPath: false,
6609
+ views: ["none", "named"],
6610
+ multiImage: true,
6611
+ // enable_texture
6612
+ texture: { none: false, standard: true },
6613
+ pbr: true,
6614
+ seed: false,
6615
+ textureRef: false,
6616
+ resolutions: { quality: "2048quality", master: "2048master" }
6617
+ },
6618
+ sam: {
6619
+ textPath: false,
6620
+ views: ["none"],
6621
+ multiImage: false,
6622
+ texture: null,
6623
+ pbr: false,
6624
+ seed: true,
6625
+ textureRef: false,
6626
+ resolutions: null
6627
+ }
6628
+ };
6629
+ function model3dSpecIssues(spec) {
6630
+ const issues = [];
6631
+ const add = (path, message) => issues.push({ path, message });
6632
+ const rules = MODEL3D_FAMILY_RULES[spec.family];
6633
+ const promptOnly = spec.text && !spec.imageRequired;
6634
+ if (spec.endpoints.image === void 0)
6635
+ add(["endpoints", "image"], "every row needs an image endpoint");
6636
+ if (promptOnly && !rules.textPath) {
6637
+ add(
6638
+ ["imageRequired"],
6639
+ `${spec.family} has no text-to-3D endpoint; a text row needs an image`
6640
+ );
6641
+ }
6642
+ if (promptOnly && spec.endpoints.text === void 0) {
6643
+ add(["endpoints", "text"], "a text row needs a text endpoint");
6644
+ }
6645
+ if (!rules.views.includes(spec.views)) {
6646
+ add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
6647
+ }
6648
+ if (spec.views === "none" && spec.maxImages !== 1) {
6649
+ add(["maxImages"], "a row without views takes 1 image");
6650
+ }
6651
+ if (spec.views === "unordered" && spec.maxImages < 2) {
6652
+ add(["maxImages"], "a row with views takes at least 2 images");
6653
+ }
6654
+ const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
6655
+ if (spec.views !== "none" && spec.maxImages > slots) {
6656
+ add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
6657
+ }
6658
+ if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
6659
+ add(
6660
+ ["maxImages"],
6661
+ `a row with ${spec.views} views takes ${slots} images (front and three sides)`
6662
+ );
6663
+ }
6664
+ if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
6665
+ add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
6666
+ }
6667
+ if (rules.texture === null) {
6668
+ if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
6669
+ } else {
6670
+ const allowed = rules.texture;
6671
+ if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
6672
+ if (new Set(spec.texture).size !== spec.texture.length)
6673
+ add(["texture"], "texture options repeat");
6674
+ for (const t of spec.texture) {
6675
+ if (!Object.hasOwn(allowed, t))
6676
+ add(["texture"], `${spec.family} has no "${t}" texture`);
6677
+ }
6678
+ }
6679
+ if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
6680
+ if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
6681
+ add(["pbr"], "PBR needs a textured option");
6682
+ }
6683
+ if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
6684
+ if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
6685
+ if (spec.textureRef && !rules.textureRef)
6686
+ add(["textureRef"], `${spec.family} takes no texture reference`);
6687
+ const res = spec.resolutions;
6688
+ if (rules.resolutions === null) {
6689
+ if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
6690
+ } else if (res === void 0) {
6691
+ add(["resolutions"], `${spec.family} needs its resolution options`);
6692
+ } else {
6693
+ if (!res.options.includes(res.default)) {
6694
+ add(["resolutions", "default"], "default must be an option");
6695
+ }
6696
+ if (new Set(res.options).size !== res.options.length) {
6697
+ add(["resolutions", "options"], "resolution options repeat");
6698
+ }
6699
+ const allowed = rules.resolutions;
6700
+ for (const option of res.options) {
6701
+ const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : Object.hasOwn(allowed, option);
6702
+ if (!ok)
6703
+ add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
6704
+ }
6705
+ }
6706
+ return issues;
6707
+ }
6553
6708
  function model3dInputRefusal(spec, wired) {
6554
6709
  const top = spec.views === "unordered" && wired.top === true;
6555
6710
  const anyView = spec.views !== "none" && (wired.back || wired.left || wired.right || top);
@@ -7131,156 +7286,6 @@ var LanguageOptionSchema = z3.looseObject({
7131
7286
  code: z3.string().min(1),
7132
7287
  name: z3.string().min(1)
7133
7288
  });
7134
- var MODEL3D_FAMILY_RULES = {
7135
- trellis: {
7136
- textPath: false,
7137
- views: ["none"],
7138
- multiImage: false,
7139
- texture: null,
7140
- pbr: false,
7141
- seed: true,
7142
- textureRef: false,
7143
- resolutions: "integer"
7144
- },
7145
- hunyuan: {
7146
- textPath: true,
7147
- views: ["none", "named"],
7148
- multiImage: false,
7149
- texture: ["none", "standard"],
7150
- pbr: true,
7151
- seed: false,
7152
- textureRef: false,
7153
- resolutions: null
7154
- },
7155
- tripo: {
7156
- textPath: true,
7157
- views: ["none", "ordered"],
7158
- multiImage: true,
7159
- texture: ["none", "standard", "detailed"],
7160
- pbr: true,
7161
- seed: true,
7162
- textureRef: false,
7163
- resolutions: null
7164
- },
7165
- rodin: {
7166
- textPath: true,
7167
- views: ["none", "unordered"],
7168
- multiImage: false,
7169
- texture: null,
7170
- pbr: false,
7171
- seed: true,
7172
- textureRef: false,
7173
- resolutions: null
7174
- },
7175
- meshy: {
7176
- textPath: true,
7177
- views: ["none", "unordered"],
7178
- multiImage: true,
7179
- texture: ["none", "standard"],
7180
- pbr: true,
7181
- seed: true,
7182
- textureRef: true,
7183
- resolutions: null
7184
- },
7185
- hi3d: {
7186
- textPath: false,
7187
- views: ["none", "named"],
7188
- multiImage: true,
7189
- texture: ["none", "standard"],
7190
- pbr: true,
7191
- seed: false,
7192
- textureRef: false,
7193
- resolutions: ["quality", "master"]
7194
- },
7195
- sam: {
7196
- textPath: false,
7197
- views: ["none"],
7198
- multiImage: false,
7199
- texture: null,
7200
- pbr: false,
7201
- seed: true,
7202
- textureRef: false,
7203
- resolutions: null
7204
- }
7205
- };
7206
- function model3dSpecIssues(spec) {
7207
- const issues = [];
7208
- const add = (path, message) => issues.push({ path, message });
7209
- const rules = MODEL3D_FAMILY_RULES[spec.family];
7210
- const promptOnly = spec.text && !spec.imageRequired;
7211
- if (spec.endpoints.image === void 0)
7212
- add(["endpoints", "image"], "every row needs an image endpoint");
7213
- if (promptOnly && !rules.textPath) {
7214
- add(
7215
- ["imageRequired"],
7216
- `${spec.family} has no text-to-3D endpoint; a text row needs an image`
7217
- );
7218
- }
7219
- if (promptOnly && spec.endpoints.text === void 0) {
7220
- add(["endpoints", "text"], "a text row needs a text endpoint");
7221
- }
7222
- if (!rules.views.includes(spec.views)) {
7223
- add(["views"], `${spec.family} takes views ${rules.views.join(" or ")}`);
7224
- }
7225
- if (spec.views === "none" && spec.maxImages !== 1) {
7226
- add(["maxImages"], "a row without views takes 1 image");
7227
- }
7228
- if (spec.views === "unordered" && spec.maxImages < 2) {
7229
- add(["maxImages"], "a row with views takes at least 2 images");
7230
- }
7231
- const slots = MODEL3D_IMAGE_SLOTS[spec.views].length;
7232
- if (spec.views !== "none" && spec.maxImages > slots) {
7233
- add(["maxImages"], `a row with ${spec.views} views sends at most ${slots} images`);
7234
- }
7235
- if ((spec.views === "named" || spec.views === "ordered") && spec.maxImages < slots) {
7236
- add(
7237
- ["maxImages"],
7238
- `a row with ${spec.views} views takes ${slots} images (front and three sides)`
7239
- );
7240
- }
7241
- if (spec.views !== "none" && rules.multiImage && spec.endpoints.multiImage === void 0) {
7242
- add(["endpoints", "multiImage"], `${spec.family} sends views to a multi-image endpoint`);
7243
- }
7244
- if (rules.texture === null) {
7245
- if (spec.texture.length > 0) add(["texture"], `${spec.family} has no texture switch`);
7246
- } else {
7247
- const allowed = rules.texture;
7248
- if (spec.texture.length === 0) add(["texture"], `${spec.family} needs its texture options`);
7249
- if (new Set(spec.texture).size !== spec.texture.length)
7250
- add(["texture"], "texture options repeat");
7251
- for (const t of spec.texture) {
7252
- if (!allowed.includes(t)) add(["texture"], `${spec.family} has no "${t}" texture`);
7253
- }
7254
- }
7255
- if (spec.pbr && !rules.pbr) add(["pbr"], `${spec.family} has no PBR switch`);
7256
- if (spec.pbr && !spec.texture.some((t) => t !== "none")) {
7257
- add(["pbr"], "PBR needs a textured option");
7258
- }
7259
- if (spec.seed && !rules.seed) add(["seed"], `${spec.family} takes no seed`);
7260
- if (spec.seedMax !== void 0 && !spec.seed) add(["seedMax"], "seedMax needs seed");
7261
- if (spec.textureRef && !rules.textureRef)
7262
- add(["textureRef"], `${spec.family} takes no texture reference`);
7263
- const res = spec.resolutions;
7264
- if (rules.resolutions === null) {
7265
- if (res !== void 0) add(["resolutions"], `${spec.family} has no resolution option`);
7266
- } else if (res === void 0) {
7267
- add(["resolutions"], `${spec.family} needs its resolution options`);
7268
- } else {
7269
- if (!res.options.includes(res.default)) {
7270
- add(["resolutions", "default"], "default must be an option");
7271
- }
7272
- if (new Set(res.options).size !== res.options.length) {
7273
- add(["resolutions", "options"], "resolution options repeat");
7274
- }
7275
- const allowed = rules.resolutions;
7276
- for (const option of res.options) {
7277
- const ok = allowed === "integer" ? /^[1-9][0-9]*$/.test(option) : allowed.includes(option);
7278
- if (!ok)
7279
- add(["resolutions", "options"], `${spec.family} has no "${option}" resolution`);
7280
- }
7281
- }
7282
- return issues;
7283
- }
7284
7289
  var VideoToolConstraintsSchema = z3.looseObject({
7285
7290
  kind: z3.enum(["upscale", "interpolate", "hdr", "bg-remove", "subtitles"]),
7286
7291
  upscaleFactor: RangeSchema.optional(),