pixelkiln 0.140.0 → 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.cjs CHANGED
@@ -137,6 +137,7 @@ __export(index_exports, {
137
137
  PIXEL_ART_FIXER_URL: () => PIXEL_ART_FIXER_URL,
138
138
  PRO_TIER_PRICES: () => PRO_TIER_PRICES,
139
139
  ParallaxLayerSchema: () => ParallaxLayerSchema,
140
+ ParallaxRunSpriteSchema: () => ParallaxRunSpriteSchema,
140
141
  ParallaxSetIdSchema: () => ParallaxSetIdSchema,
141
142
  ParallaxSetSchema: () => ParallaxSetSchema,
142
143
  PixelKilnError: () => PixelKilnError,
@@ -2246,6 +2247,20 @@ var AssetSchema = import_zod.z.object({
2246
2247
  });
2247
2248
  var DEFAULT_HISTORY_LIMIT = 5;
2248
2249
  var HistoryLimitSchema = import_zod.z.number().int().min(0).max(100);
2250
+ var ParallaxRunSpriteSchema = import_zod.z.object({
2251
+ asset: import_zod.z.string().min(1).optional(),
2252
+ /** The style the asset was generated under, when it was generated under more than one. */
2253
+ style: import_zod.z.string().min(1).optional(),
2254
+ file: import_zod.z.string().min(1).optional()
2255
+ }).strict().superRefine((sprite, ctx) => {
2256
+ if (sprite.asset === void 0 === (sprite.file === void 0)) {
2257
+ ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a run sprite needs exactly one of asset or file" });
2258
+ }
2259
+ if (sprite.style !== void 0 && sprite.asset === void 0) {
2260
+ ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, path: ["style"], message: "style only applies to an asset sprite" });
2261
+ }
2262
+ });
2263
+ var RUN_ONLY = ["seed", "step", "gap", "jitter", "width"];
2249
2264
  var ParallaxLayerSchema = import_zod.z.object({
2250
2265
  /** Names the layer in exports; defaults to the asset id, the file name, or "sky". */
2251
2266
  name: import_zod.z.string().regex(/^[A-Za-z][A-Za-z0-9_-]*$/, "letters, digits, - and _, starting with a letter").optional(),
@@ -2257,6 +2272,22 @@ var ParallaxLayerSchema = import_zod.z.object({
2257
2272
  file: import_zod.z.string().min(1).optional(),
2258
2273
  /** Flat colour bands, top to bottom, with a dithered step between neighbours. */
2259
2274
  sky: import_zod.z.array(HexColorSchema).min(1).max(64).optional(),
2275
+ /**
2276
+ * Isolated silhouettes laid left to right in an overlapping run, each
2277
+ * flipped at random and never the same one twice in a row, so a long
2278
+ * level never shows the same stretch twice.
2279
+ */
2280
+ run: import_zod.z.array(ParallaxRunSpriteSchema).min(1).max(32).optional(),
2281
+ /** Seeds a run's layout; the same seed lays the same run. Defaults to one taken from the layer's name. */
2282
+ seed: import_zod.z.number().int().min(0).max(2 ** 32 - 1).optional(),
2283
+ /** How far across one sprite the next starts, as a fraction of its width; 0.72 by default. */
2284
+ step: import_zod.z.number().min(0.1).max(2).optional(),
2285
+ /** Up to this many more pixels between sprites, at random; 16 by default. */
2286
+ gap: import_zod.z.number().int().min(0).max(4096).optional(),
2287
+ /** Moves each sprite's foot up or down by up to this many pixels; 0 by default. */
2288
+ jitter: import_zod.z.number().int().min(0).max(256).optional(),
2289
+ /** The run's length in pixels; by default as much as the camera sees of the layer. */
2290
+ width: import_zod.z.number().int().min(1).max(1e5).optional(),
2260
2291
  speed: import_zod.z.number().min(0).max(4),
2261
2292
  /** Vertical speed; 1, moving with the level, when the set does not climb. */
2262
2293
  speedY: import_zod.z.number().min(0).max(4).optional(),
@@ -2275,9 +2306,14 @@ var ParallaxLayerSchema = import_zod.z.object({
2275
2306
  /** Repeat vertically, for an endless climb. */
2276
2307
  repeatY: import_zod.z.boolean().optional()
2277
2308
  }).strict().superRefine((layer, ctx) => {
2278
- const sources = [layer.asset, layer.file, layer.sky].filter((value) => value !== void 0).length;
2309
+ const sources = [layer.asset, layer.file, layer.sky, layer.run].filter((value) => value !== void 0).length;
2279
2310
  if (sources !== 1) {
2280
- ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a layer needs exactly one of asset, file, or sky" });
2311
+ ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, message: "a layer needs exactly one of asset, file, sky, or run" });
2312
+ }
2313
+ if (layer.run === void 0) {
2314
+ for (const key3 of RUN_ONLY) {
2315
+ if (layer[key3] !== void 0) ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, path: [key3], message: `${key3} only applies to a run layer` });
2316
+ }
2281
2317
  }
2282
2318
  if (layer.style !== void 0 && layer.asset === void 0) {
2283
2319
  ctx.addIssue({ code: import_zod.z.ZodIssueCode.custom, path: ["style"], message: "style only applies to an asset layer" });
@@ -14169,15 +14205,18 @@ ${issues}`);
14169
14205
  const names = /* @__PURE__ */ new Set();
14170
14206
  set.layers.forEach((layer, index) => {
14171
14207
  const at2 = `parallax.${setId}.layers.${index}`;
14172
- if (layer.asset !== void 0) {
14173
- const asset = parsed.data.assets[layer.asset];
14174
- if (!asset) unknownReferences.push(`${at2}.asset: unknown asset "${layer.asset}"`);
14175
- else if (layer.style !== void 0 && !asset.styles.includes(layer.style)) {
14176
- unknownReferences.push(`${at2}.style: asset "${layer.asset}" is not generated under style "${layer.style}"`);
14177
- } else if (layer.style === void 0 && asset.styles.length > 1) {
14178
- unknownReferences.push(`${at2}.style: asset "${layer.asset}" has ${asset.styles.length} styles; name one`);
14208
+ const checkAsset = (where, ref) => {
14209
+ if (ref.asset === void 0) return;
14210
+ const asset = parsed.data.assets[ref.asset];
14211
+ if (!asset) unknownReferences.push(`${where}.asset: unknown asset "${ref.asset}"`);
14212
+ else if (ref.style !== void 0 && !asset.styles.includes(ref.style)) {
14213
+ unknownReferences.push(`${where}.style: asset "${ref.asset}" is not generated under style "${ref.style}"`);
14214
+ } else if (ref.style === void 0 && asset.styles.length > 1) {
14215
+ unknownReferences.push(`${where}.style: asset "${ref.asset}" has ${asset.styles.length} styles; name one`);
14179
14216
  }
14180
- }
14217
+ };
14218
+ checkAsset(at2, layer);
14219
+ layer.run?.forEach((sprite, n) => checkAsset(`${at2}.run.${n}`, sprite));
14181
14220
  if (layer.name !== void 0) {
14182
14221
  if (names.has(layer.name)) unknownReferences.push(`${at2}.name: "${layer.name}" is used twice`);
14183
14222
  names.add(layer.name);
@@ -30678,6 +30717,7 @@ async function workspaceStatus(ws, dir) {
30678
30717
  PIXEL_ART_FIXER_URL,
30679
30718
  PRO_TIER_PRICES,
30680
30719
  ParallaxLayerSchema,
30720
+ ParallaxRunSpriteSchema,
30681
30721
  ParallaxSetIdSchema,
30682
30722
  ParallaxSetSchema,
30683
30723
  PixelKilnError,