@idle-screens/schema 3.4.1 → 3.4.3
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.d.ts +0 -7
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -493,13 +493,6 @@ interface IdleSequence {
|
|
|
493
493
|
segments: SequenceSegment[];
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
-
/**
|
|
497
|
-
* Validate an untrusted (agent- or JSON-authored) spec structurally + semantically.
|
|
498
|
-
* Returns typed errors and warnings; never throws. `compileSaver` refuses to run an invalid spec.
|
|
499
|
-
*
|
|
500
|
-
* Warnings are non-blocking advisories about unknown/misplaced properties and
|
|
501
|
-
* near-zero speeds. They don't prevent compilation but indicate likely authoring mistakes.
|
|
502
|
-
*/
|
|
503
496
|
declare function validateSpec(spec: unknown): ValidationResult;
|
|
504
497
|
/** Narrowing helper: validate + cast. Throws with a joined message when invalid. */
|
|
505
498
|
declare function assertValidSpec(spec: unknown): SaverSpec;
|
package/dist/index.js
CHANGED
|
@@ -237,7 +237,20 @@ var LAYER_PROPS_ON_SPRITE = /* @__PURE__ */ new Set(["blend", "trail", "alpha",
|
|
|
237
237
|
function unknownKeys(obj, known) {
|
|
238
238
|
return Object.keys(obj).filter((k) => !known.has(k));
|
|
239
239
|
}
|
|
240
|
+
function normalizeColors(spec) {
|
|
241
|
+
if (!isObj(spec) || !Array.isArray(spec.layers)) return;
|
|
242
|
+
for (const layer of spec.layers) {
|
|
243
|
+
if (!isObj(layer)) continue;
|
|
244
|
+
const sprite = layer.sprite;
|
|
245
|
+
if (!isObj(sprite)) continue;
|
|
246
|
+
const sp = sprite;
|
|
247
|
+
if (Array.isArray(sp.colors) && sp.colors.length > 0 && sp.color === void 0) {
|
|
248
|
+
sp.color = sp.colors[0];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
240
252
|
function validateSpec(spec) {
|
|
253
|
+
normalizeColors(spec);
|
|
241
254
|
const errors = [];
|
|
242
255
|
const warnings = [];
|
|
243
256
|
const err = (path, message) => void errors.push({ path, message });
|
|
@@ -783,6 +796,13 @@ ${r.errors.map((e) => ` ${e.path || "<root>"}: ${e.message}`).join("\n")}`);
|
|
|
783
796
|
return spec;
|
|
784
797
|
}
|
|
785
798
|
function validateSequence(seq) {
|
|
799
|
+
if (isObj(seq) && Array.isArray(seq.segments)) {
|
|
800
|
+
for (const seg of seq.segments) {
|
|
801
|
+
if (isObj(seg) && isObj(seg.scene)) {
|
|
802
|
+
normalizeColors(seg.scene);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
786
806
|
const errors = [];
|
|
787
807
|
const warnings = [];
|
|
788
808
|
const err = (path, message) => void errors.push({ path, message });
|
|
@@ -922,7 +942,7 @@ function weightedIndex(u, weights) {
|
|
|
922
942
|
return weights.length - 1;
|
|
923
943
|
}
|
|
924
944
|
function buildEntities(layer, rng, w, h, scale = 1, countScale = 1) {
|
|
925
|
-
const effectiveCount = countScale === 1 ? layer.count : Math.max(1, Math.min(
|
|
945
|
+
const effectiveCount = countScale === 1 || layer.layout?.type === "grid" ? layer.count : Math.max(1, Math.min(
|
|
926
946
|
Math.round(layer.count * countScale),
|
|
927
947
|
layer.links ? LIMITS.maxLinkLayerCount : LIMITS.maxPerLayer
|
|
928
948
|
));
|