pixelkiln 0.98.0 → 0.99.0

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.js CHANGED
@@ -524,6 +524,24 @@ var RevisionSchema = z.object({
524
524
  removalTask: z.enum(["simple", "complex"]).optional(),
525
525
  /** `normal-map` only: `opengl` (green up; PixelLab's default) or `directx` (green down, for Unreal). */
526
526
  convention: NormalMapConventionSchema.optional(),
527
+ /**
528
+ * `normal-map` only: `lite` (PixelLab's default, 0.1 generation) makes the
529
+ * map from the art alone; `pro` (0.5) plans each part's shape, what is in
530
+ * front and what is sunk.
531
+ */
532
+ normalMapMode: z.enum(["lite", "pro"]).optional(),
533
+ /** `normal-map` only: what the picture is. Left out, PixelLab reads it from the picture; set it for sidescroller, isometric and UI art. */
534
+ normalMapKind: z.enum(["character", "object", "topdown", "side", "iso", "ui"]).optional(),
535
+ /** `normal-map` only: how far every pixel tilts away from facing the viewer, 0 to 2 (the API refuses more). */
536
+ normalMapStrength: z.number().min(0).max(2).optional(),
537
+ /** `normal-map` only: how much the outline rounds off, 0 to 3; 0 keeps it flat to the edge. */
538
+ outlineRounding: z.number().min(0).max(3).optional(),
539
+ /** `normal-map` only: how much the sprite's 3D parts (a round head, an arm) add, 0 to 2. */
540
+ partShapes: z.number().min(0).max(2).optional(),
541
+ /** `normal-map` only: the art's own light and dark as bumps, 0 to 2; 0 for a smooth surface. */
542
+ surfaceDetail: z.number().min(0).max(2).optional(),
543
+ /** `normal-map` only: how far that detail is blurred, 0.6 to 3 px. */
544
+ detailSoftness: z.number().min(0.6).max(3).optional(),
527
545
  /**
528
546
  * `animate-skeleton`: what the character *looks like*, a noun
529
547
  * phrase (colours, clothing, held items) — distinct from the asset's
@@ -684,6 +702,15 @@ var RevisionSchema = z.object({
684
702
  path: ["convention"]
685
703
  });
686
704
  }
705
+ for (const field of ["normalMapMode", "normalMapKind", "normalMapStrength", "outlineRounding", "partShapes", "surfaceDetail", "detailSoftness"]) {
706
+ if (revision[field] !== void 0 && revision.mode !== "normal-map") {
707
+ context.addIssue({
708
+ code: z.ZodIssueCode.custom,
709
+ message: `${field} applies to normal-map revisions only`,
710
+ path: [field]
711
+ });
712
+ }
713
+ }
687
714
  if (revision.description !== void 0 && revision.mode !== "animate-skeleton" && revision.mode !== "remove-background") {
688
715
  context.addIssue({
689
716
  code: z.ZodIssueCode.custom,
@@ -2394,6 +2421,14 @@ function targetPaletteBody(palette) {
2394
2421
  }
2395
2422
  };
2396
2423
  }
2424
+ var NORMAL_MAP_MODES = ["lite", "pro"];
2425
+ var NORMAL_MAP_KINDS = ["character", "object", "topdown", "side", "iso", "ui"];
2426
+ var NORMAL_MAP_SHAPE_RANGES = {
2427
+ outlineRounding: [0, 3],
2428
+ partShapes: [0, 2],
2429
+ surfaceDetail: [0, 2],
2430
+ detailSoftness: [0.6, 3]
2431
+ };
2397
2432
  var PixelLabClient = class {
2398
2433
  constructor(apiKey, timeoutMs = 12e4) {
2399
2434
  this.apiKey = apiKey;
@@ -3472,8 +3507,15 @@ var PixelLabClient = class {
3472
3507
  */
3473
3508
  async normalMap(args) {
3474
3509
  const body = { image: args.image };
3510
+ if (args.mode) body.mode = args.mode;
3511
+ if (args.kind) body.kind = args.kind;
3512
+ if (args.shape?.strength != null) body.strength = args.shape.strength;
3475
3513
  if (args.frames != null && args.frames !== 1) body.frames = args.frames;
3476
3514
  if (args.convention) body.convention = args.convention;
3515
+ if (args.shape?.outlineRounding != null) body.outline_rounding = args.shape.outlineRounding;
3516
+ if (args.shape?.partShapes != null) body.part_shapes = args.shape.partShapes;
3517
+ if (args.shape?.surfaceDetail != null) body.surface_detail = args.shape.surfaceDetail;
3518
+ if (args.shape?.detailSoftness != null) body.detail_softness = args.shape.detailSoftness;
3477
3519
  return validateResponse(
3478
3520
  RevisionJobSubmitSchema,
3479
3521
  await this.request("/normal-map", { method: "POST", body: JSON.stringify(body) }),
@@ -4737,6 +4779,14 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
4737
4779
  description: spec.revision.description,
4738
4780
  removalTask: spec.revision.removalTask,
4739
4781
  convention: spec.revision.convention,
4782
+ // Each only when set, so normal-map revisions made before them keep their hash.
4783
+ normalMapMode: spec.revision.normalMapMode,
4784
+ normalMapKind: spec.revision.normalMapKind,
4785
+ normalMapStrength: spec.revision.normalMapStrength,
4786
+ outlineRounding: spec.revision.outlineRounding,
4787
+ partShapes: spec.revision.partShapes,
4788
+ surfaceDetail: spec.revision.surfaceDetail,
4789
+ detailSoftness: spec.revision.detailSoftness,
4740
4790
  driftThreshold: spec.revision.driftThreshold,
4741
4791
  subjectDescription: spec.revision.subjectDescription,
4742
4792
  initialPose: spec.revision.initialPose,
@@ -5513,6 +5563,9 @@ async function pixelateFile(client2, input, opts = {}) {
5513
5563
  await sleep3(interval);
5514
5564
  }
5515
5565
  }
5566
+ function normalMapCost(mode2) {
5567
+ return mode2 === "pro" ? 0.5 : 0.1;
5568
+ }
5516
5569
  var NORMAL_MAP_COST_GENERATIONS = 0.5;
5517
5570
  var NORMAL_MAP_MIN_SIDE = 8;
5518
5571
  var NORMAL_MAP_MAX_SIDE = 512;
@@ -5557,7 +5610,10 @@ async function normalMapFile(client2, input, opts = {}) {
5557
5610
  const submitted = await client2.normalMap({
5558
5611
  image: { base64: bytes.toString("base64"), format: "png" },
5559
5612
  frames,
5560
- convention: opts.convention
5613
+ convention: opts.convention,
5614
+ shape: opts.shape,
5615
+ mode: opts.mode,
5616
+ kind: opts.kind
5561
5617
  });
5562
5618
  const jobId = submitted.background_job_id;
5563
5619
  const started = Date.now();
@@ -5822,7 +5878,7 @@ var PixelLabProvider = class _PixelLabProvider {
5822
5878
  return { unit: "generations", amount: 1, candidates: 1 };
5823
5879
  }
5824
5880
  if (spec.revision?.mode === "normal-map") {
5825
- return { unit: "generations", amount: NORMAL_MAP_COST_GENERATIONS, candidates: 1 };
5881
+ return { unit: "generations", amount: normalMapCost(spec.revision.normalMapMode), candidates: 1 };
5826
5882
  }
5827
5883
  if (spec.revision?.mode === "reduce-colors" || spec.revision?.mode === "correct-pixelart") {
5828
5884
  return { unit: "generations", amount: 0.1, candidates: 1 };
@@ -7296,7 +7352,20 @@ var PixelLabProvider = class _PixelLabProvider {
7296
7352
  }
7297
7353
  if (revision.mode === "normal-map") {
7298
7354
  const strip = roles ? { base64: joinStripPng(images.map((member) => Buffer.from(member.base64, "base64"))).toString("base64"), format: "png" } : image;
7299
- const res2 = await this.client.normalMap({ image: strip, frames: roles?.length ?? 1, convention: revision.convention });
7355
+ const res2 = await this.client.normalMap({
7356
+ image: strip,
7357
+ frames: roles?.length ?? 1,
7358
+ convention: revision.convention,
7359
+ mode: revision.normalMapMode,
7360
+ kind: revision.normalMapKind,
7361
+ shape: {
7362
+ strength: revision.normalMapStrength,
7363
+ outlineRounding: revision.outlineRounding,
7364
+ partShapes: revision.partShapes,
7365
+ surfaceDetail: revision.surfaceDetail,
7366
+ detailSoftness: revision.detailSoftness
7367
+ }
7368
+ });
7300
7369
  return {
7301
7370
  jobId: res2.background_job_id,
7302
7371
  metadata: roles ? { revisionMembers: roles, ...revision.sourceFps != null ? { revisionFps: revision.sourceFps } : {} } : {}
@@ -11955,6 +12024,13 @@ async function resolveSpecs(loaded, filter) {
11955
12024
  ...asset.revision.description ? { description: asset.revision.description } : {},
11956
12025
  ...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
11957
12026
  ...asset.revision.convention ? { convention: asset.revision.convention } : {},
12027
+ ...asset.revision.normalMapMode ? { normalMapMode: asset.revision.normalMapMode } : {},
12028
+ ...asset.revision.normalMapKind ? { normalMapKind: asset.revision.normalMapKind } : {},
12029
+ ...asset.revision.normalMapStrength == null ? {} : { normalMapStrength: asset.revision.normalMapStrength },
12030
+ ...asset.revision.outlineRounding == null ? {} : { outlineRounding: asset.revision.outlineRounding },
12031
+ ...asset.revision.partShapes == null ? {} : { partShapes: asset.revision.partShapes },
12032
+ ...asset.revision.surfaceDetail == null ? {} : { surfaceDetail: asset.revision.surfaceDetail },
12033
+ ...asset.revision.detailSoftness == null ? {} : { detailSoftness: asset.revision.detailSoftness },
11958
12034
  ...asset.revision.driftThreshold == null ? {} : { driftThreshold: asset.revision.driftThreshold },
11959
12035
  ...asset.revision.subjectDescription ? { subjectDescription: asset.revision.subjectDescription } : {},
11960
12036
  ...asset.revision.initialPose ? { initialPose: asset.revision.initialPose } : {},
@@ -23041,9 +23117,12 @@ export {
23041
23117
  MediaType,
23042
23118
  NORMAL_MAP_CONVENTIONS,
23043
23119
  NORMAL_MAP_COST_GENERATIONS,
23120
+ NORMAL_MAP_KINDS,
23044
23121
  NORMAL_MAP_MAX_FRAMES,
23045
23122
  NORMAL_MAP_MAX_SIDE,
23046
23123
  NORMAL_MAP_MIN_SIDE,
23124
+ NORMAL_MAP_MODES,
23125
+ NORMAL_MAP_SHAPE_RANGES,
23047
23126
  NormalMapConventionSchema,
23048
23127
  OverwriteRefusedError,
23049
23128
  PIXELATE_COST_GENERATIONS,
@@ -23211,6 +23290,7 @@ export {
23211
23290
  mountStyle,
23212
23291
  musicCost,
23213
23292
  musicOutputPaths,
23293
+ normalMapCost,
23214
23294
  normalMapFile,
23215
23295
  normalMapResultPng,
23216
23296
  normalMapSizeProblem,