pixelkiln 0.52.0 → 0.53.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/dist/cli.js CHANGED
@@ -10755,7 +10755,19 @@ var NewAssetSchema = z5.object({
10755
10755
  size: z5.number().int().optional(),
10756
10756
  tags: z5.array(z5.string()).optional(),
10757
10757
  /** Restrict to these styles; empty or omitted means every style. */
10758
- styles: z5.array(z5.string().min(1)).optional()
10758
+ styles: z5.array(z5.string().min(1)).optional(),
10759
+ /**
10760
+ * A controlled regeneration of another asset in the same manifest,
10761
+ * instead of a fresh generation. `inpaint` needs a mask upload the
10762
+ * gallery does not offer yet, so only `image-to-image` can be created
10763
+ * here; hand-edit the manifest for the other modes.
10764
+ */
10765
+ revision: z5.object({
10766
+ mode: z5.literal("image-to-image"),
10767
+ /** Asset id of the parent this revises; must already exist. */
10768
+ from: z5.string().min(1),
10769
+ strength: z5.number().min(0).max(1).optional()
10770
+ }).strict().optional()
10759
10771
  }).strict();
10760
10772
  var CANDIDATE_OPTION = {
10761
10773
  retrodiffusion: "numImages",
@@ -10921,6 +10933,9 @@ function applyEdit(raw, edit) {
10921
10933
  }
10922
10934
  asset2.styles = styles;
10923
10935
  }
10936
+ if (edit.asset.revision && !Object.hasOwn(raw.assets, edit.asset.revision.from)) {
10937
+ throw new ManifestEditError(`revision parent "${edit.asset.revision.from}" is not declared by the manifest`);
10938
+ }
10924
10939
  raw.assets[edit.assetId] = asset2;
10925
10940
  return;
10926
10941
  }
@@ -15581,6 +15596,25 @@ function normalizeTileRules(raw) {
15581
15596
  raw
15582
15597
  };
15583
15598
  }
15599
+ function normalizeTerrainTiles(metadata) {
15600
+ if (!isRecord2(metadata) || !Array.isArray(metadata.terrainTiles)) return null;
15601
+ const terrains = Array.isArray(metadata.terrainTypes) ? metadata.terrainTypes.filter((item) => typeof item === "string") : [];
15602
+ if (terrains.length < 2) return null;
15603
+ const masks = {};
15604
+ metadata.terrainTiles.forEach((tile, index) => {
15605
+ if (!isRecord2(tile) || !isRecord2(tile.corners)) return;
15606
+ const corners = tile.corners;
15607
+ const bit = (corner) => corners[corner] === terrains[0] ? 1 : 0;
15608
+ masks[index] = bit("NW") << 3 | bit("NE") << 2 | bit("SW") << 1 | bit("SE");
15609
+ });
15610
+ return {
15611
+ ruleType: "corner",
15612
+ arity: 4,
15613
+ terrains,
15614
+ masks,
15615
+ raw: metadata
15616
+ };
15617
+ }
15584
15618
  function exportTileset(entry, spec, options) {
15585
15619
  let outputs = resolveSpecEntryOutputs(entry, spec);
15586
15620
  if (!outputs.length) throw new Error(`${spec.styleId}/${spec.assetId} has no downloaded outputs`);
@@ -15601,14 +15635,16 @@ function exportTileset(entry, spec, options) {
15601
15635
  }
15602
15636
  const metadata = entry.providerMetadata?.[entry.provider];
15603
15637
  const rawRules = isRecord2(metadata) ? metadata.tileRules : void 0;
15604
- const rules = normalizeTileRules(rawRules);
15638
+ const terrainRules = normalizeTerrainTiles(metadata);
15639
+ const rules = normalizeTileRules(rawRules) ?? terrainRules;
15640
+ const providerRules = isRecord2(rawRules) ? rawRules : terrainRules ? metadata : null;
15605
15641
  const frames = packed.atlas.frames;
15606
15642
  const generic = buildGeneric(
15607
15643
  spec,
15608
15644
  options.imageName,
15609
15645
  packed.atlas,
15610
15646
  frames,
15611
- isRecord2(rawRules) ? rawRules : null,
15647
+ providerRules,
15612
15648
  rules
15613
15649
  );
15614
15650
  if (options.format === "generic") {
@@ -15621,7 +15657,7 @@ function exportTileset(entry, spec, options) {
15621
15657
  };
15622
15658
  }
15623
15659
  assertUniformTiles(generic);
15624
- if ((rawRules !== void 0 || entry.tileFeature) && !rules) {
15660
+ if ((rawRules !== void 0 || entry.tileFeature || entry.generator === "terrain") && !rules) {
15625
15661
  throw new Error(
15626
15662
  `${options.format} export needs recognized adjacency rules; use --format generic to retain this provider rule object without guessing`
15627
15663
  );