pixelkiln 0.139.3 → 0.141.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
@@ -1745,6 +1745,88 @@ var AssetSchema = z.object({
1745
1745
  });
1746
1746
  var DEFAULT_HISTORY_LIMIT = 5;
1747
1747
  var HistoryLimitSchema = z.number().int().min(0).max(100);
1748
+ var ParallaxRunSpriteSchema = z.object({
1749
+ asset: z.string().min(1).optional(),
1750
+ /** The style the asset was generated under, when it was generated under more than one. */
1751
+ style: z.string().min(1).optional(),
1752
+ file: z.string().min(1).optional()
1753
+ }).strict().superRefine((sprite, ctx) => {
1754
+ if (sprite.asset === void 0 === (sprite.file === void 0)) {
1755
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "a run sprite needs exactly one of asset or file" });
1756
+ }
1757
+ if (sprite.style !== void 0 && sprite.asset === void 0) {
1758
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["style"], message: "style only applies to an asset sprite" });
1759
+ }
1760
+ });
1761
+ var RUN_ONLY = ["seed", "step", "gap", "jitter", "width"];
1762
+ var ParallaxLayerSchema = z.object({
1763
+ /** Names the layer in exports; defaults to the asset id, the file name, or "sky". */
1764
+ name: z.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/, "letters, digits, - and _, starting with a letter").optional(),
1765
+ /** A manifest asset, read from the lockfile once generated. */
1766
+ asset: z.string().min(1).optional(),
1767
+ /** The style the asset was generated under, when it was generated under more than one. */
1768
+ style: z.string().min(1).optional(),
1769
+ /** A picture on disk, relative to the manifest: a layer finished by hand or by script. */
1770
+ file: z.string().min(1).optional(),
1771
+ /** Flat colour bands, top to bottom, with a dithered step between neighbours. */
1772
+ sky: z.array(HexColorSchema).min(1).max(64).optional(),
1773
+ /**
1774
+ * Isolated silhouettes laid left to right in an overlapping run, each
1775
+ * flipped at random and never the same one twice in a row, so a long
1776
+ * level never shows the same stretch twice.
1777
+ */
1778
+ run: z.array(ParallaxRunSpriteSchema).min(1).max(32).optional(),
1779
+ /** Seeds a run's layout; the same seed lays the same run. Defaults to one taken from the layer's name. */
1780
+ seed: z.number().int().min(0).max(2 ** 32 - 1).optional(),
1781
+ /** How far across one sprite the next starts, as a fraction of its width; 0.72 by default. */
1782
+ step: z.number().min(0.1).max(2).optional(),
1783
+ /** Up to this many more pixels between sprites, at random; 16 by default. */
1784
+ gap: z.number().int().min(0).max(4096).optional(),
1785
+ /** Moves each sprite's foot up or down by up to this many pixels; 0 by default. */
1786
+ jitter: z.number().int().min(0).max(256).optional(),
1787
+ /** The run's length in pixels; by default as much as the camera sees of the layer. */
1788
+ width: z.number().int().min(1).max(1e5).optional(),
1789
+ speed: z.number().min(0).max(4),
1790
+ /** Vertical speed; 1, moving with the level, when the set does not climb. */
1791
+ speedY: z.number().min(0).max(4).optional(),
1792
+ /** Left edge on the set's canvas, whose origin is the view's top-left at the start. */
1793
+ x: z.number().int().min(-1e5).max(1e5).optional(),
1794
+ /** The canvas row the layer's bottom edge sits on; the view's height when absent. */
1795
+ bottom: z.number().int().min(-1e5).max(1e5).optional(),
1796
+ /**
1797
+ * Repeat the bottom row downward: true to the foot of the view, or this
1798
+ * many rows. A far range extended this way gives nearer
1799
+ * layers' feet distant land to dissolve into instead of floating.
1800
+ */
1801
+ extend: z.union([z.boolean(), z.number().int().min(1).max(4096)]).optional(),
1802
+ /** Repeat sideways (the default) so the layer loops. */
1803
+ repeat: z.boolean().optional(),
1804
+ /** Repeat vertically, for an endless climb. */
1805
+ repeatY: z.boolean().optional()
1806
+ }).strict().superRefine((layer, ctx) => {
1807
+ const sources = [layer.asset, layer.file, layer.sky, layer.run].filter((value) => value !== void 0).length;
1808
+ if (sources !== 1) {
1809
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "a layer needs exactly one of asset, file, sky, or run" });
1810
+ }
1811
+ if (layer.run === void 0) {
1812
+ for (const key3 of RUN_ONLY) {
1813
+ if (layer[key3] !== void 0) ctx.addIssue({ code: z.ZodIssueCode.custom, path: [key3], message: `${key3} only applies to a run layer` });
1814
+ }
1815
+ }
1816
+ if (layer.style !== void 0 && layer.asset === void 0) {
1817
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: ["style"], message: "style only applies to an asset layer" });
1818
+ }
1819
+ });
1820
+ var ParallaxSetSchema = z.object({
1821
+ /** The game's view in pixels, [width, height]. */
1822
+ view: z.tuple([z.number().int().min(8).max(4096), z.number().int().min(8).max(4096)]),
1823
+ /** How far the camera moves sideways across the level, in pixels. */
1824
+ travel: z.number().int().min(0).max(1e5).optional(),
1825
+ /** How far the camera climbs, in pixels. */
1826
+ climb: z.number().int().min(0).max(1e5).optional(),
1827
+ layers: z.array(ParallaxLayerSchema).min(1).max(32)
1828
+ }).strict();
1829
+ var ParallaxSetIdSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/, "a set id is letters, digits, - and _, starting with a letter or digit");
1748
1830
  var ManifestSchema = z.object({
1749
1831
  $schema: z.string().optional(),
1750
1832
  name: z.string(),
@@ -1753,7 +1835,9 @@ var ManifestSchema = z.object({
1753
1835
  /** Replaced generations kept per asset for this project; overrides PIXELKILN_HISTORY. 0 keeps none. */
1754
1836
  history: HistoryLimitSchema.optional(),
1755
1837
  styles: z.record(StyleSchema),
1756
- assets: z.record(AssetSchema)
1838
+ assets: z.record(AssetSchema),
1839
+ /** Parallax backgrounds built from the assets, by set id. */
1840
+ parallax: z.record(ParallaxSetIdSchema, ParallaxSetSchema).optional()
1757
1841
  }).strict();
1758
1842
  var ManifestInputSchema = z.object({
1759
1843
  $schema: z.string().optional(),
@@ -1761,7 +1845,8 @@ var ManifestInputSchema = z.object({
1761
1845
  provider: z.string().min(1).default("pixellab"),
1762
1846
  history: HistoryLimitSchema.optional(),
1763
1847
  styles: z.record(StyleInputSchema),
1764
- assets: z.record(AssetSchema)
1848
+ assets: z.record(AssetSchema),
1849
+ parallax: z.record(ParallaxSetIdSchema, ParallaxSetSchema).optional()
1765
1850
  }).strict();
1766
1851
  var LockOutputSchema = z.object({
1767
1852
  path: z.string(),
@@ -13614,6 +13699,28 @@ ${issues}`);
13614
13699
  connectVisited.add(assetId);
13615
13700
  };
13616
13701
  for (const assetId of Object.keys(parsed.data.assets)) visitConnections(assetId);
13702
+ for (const [setId, set] of Object.entries(parsed.data.parallax ?? {})) {
13703
+ const names = /* @__PURE__ */ new Set();
13704
+ set.layers.forEach((layer, index) => {
13705
+ const at2 = `parallax.${setId}.layers.${index}`;
13706
+ const checkAsset = (where, ref) => {
13707
+ if (ref.asset === void 0) return;
13708
+ const asset = parsed.data.assets[ref.asset];
13709
+ if (!asset) unknownReferences.push(`${where}.asset: unknown asset "${ref.asset}"`);
13710
+ else if (ref.style !== void 0 && !asset.styles.includes(ref.style)) {
13711
+ unknownReferences.push(`${where}.style: asset "${ref.asset}" is not generated under style "${ref.style}"`);
13712
+ } else if (ref.style === void 0 && asset.styles.length > 1) {
13713
+ unknownReferences.push(`${where}.style: asset "${ref.asset}" has ${asset.styles.length} styles; name one`);
13714
+ }
13715
+ };
13716
+ checkAsset(at2, layer);
13717
+ layer.run?.forEach((sprite, n) => checkAsset(`${at2}.run.${n}`, sprite));
13718
+ if (layer.name !== void 0) {
13719
+ if (names.has(layer.name)) unknownReferences.push(`${at2}.name: "${layer.name}" is used twice`);
13720
+ names.add(layer.name);
13721
+ }
13722
+ });
13723
+ }
13617
13724
  if (unknownReferences.length) {
13618
13725
  throw new ProjectError(`Manifest at ${abs} is invalid:
13619
13726
  ${unknownReferences.map((i) => ` ${i}`).join("\n")}`);
@@ -30106,6 +30213,10 @@ export {
30106
30213
  PIXEL_ART_FIXER_REVISION,
30107
30214
  PIXEL_ART_FIXER_URL,
30108
30215
  PRO_TIER_PRICES,
30216
+ ParallaxLayerSchema,
30217
+ ParallaxRunSpriteSchema,
30218
+ ParallaxSetIdSchema,
30219
+ ParallaxSetSchema,
30109
30220
  PixelKilnError,
30110
30221
  PixelLabClient,
30111
30222
  PixelLabError,