@rig-c/parts 1.60.2 → 1.61.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/src/config.ts CHANGED
@@ -268,6 +268,8 @@ export interface AlternateSetConfig {
268
268
  full?: string;
269
269
  head?: string;
270
270
  parts?: string[];
271
+ /** Per covered output part, the layer in its existing source run (issue #666). */
272
+ layers?: Record<string, string>;
271
273
  hides?: string[];
272
274
  head_box?: [number, number, number, number];
273
275
  cuts?: Cut[];
@@ -2171,7 +2173,7 @@ function checkAlternates(
2171
2173
  const seenNames = new Map<string, number>();
2172
2174
  (v as Json[]).forEach((entry, i) => {
2173
2175
  const at = `${p}[${i}]`;
2174
- const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'anchor', 'drawn', 'tips', 'front']);
2176
+ const e = c.object(at, entry, ['name'], ['source', 'full', 'head', 'parts', 'hides', 'head_box', 'cuts', 'skeleton', 'anchor', 'drawn', 'tips', 'front', 'layers']);
2175
2177
  if (e === null) return;
2176
2178
  if ('name' in e && c.string(`${at}.name`, e.name)) {
2177
2179
  if (!partNameOk(e.name)) c.fail('CONFIG_PART_NAME', `${at}.name`, `names the set ${show(e.name)}; a set name is a file prefix, so it may not be empty, start with "." or hold a slash`);
@@ -2272,6 +2274,16 @@ function checkAlternates(
2272
2274
  } else seenHides.add(hn);
2273
2275
  });
2274
2276
  }
2277
+ if ('layers' in e) {
2278
+ if (!isPlainObject(e.layers)) c.fail('CONFIG_FIELD_TYPE', `${at}.layers`, `is ${show(e.layers)}; an object of covered part -> layer name is required`);
2279
+ else for (const [part, layer] of Object.entries(e.layers)) {
2280
+ const path = `${at}.layers.${part}`;
2281
+ const covered = ('parts' in e ? seenParts : allSlots).has(part) && !seenHides.has(part);
2282
+ if (!covered) c.fail('CONFIG_SET_LAYERS', path, `names "${part}", which the set does not cover; name a covered, nonhidden part`);
2283
+ if (made.patches.includes(part)) c.fail('CONFIG_SET_LAYERS', path, `names the painting patch "${part}", which has no run layer source; declare a layer-backed plan part instead`);
2284
+ if (typeof layer !== 'string' || readLayerTag(layer) === null) c.fail('CONFIG_TAG_KNOWN', path, `is ${show(layer)}; a See-through v3 tag or "${AUTHOR_PREFIX}<label>" is required; ${AUTHOR_LABEL_RULE}`);
2285
+ }
2286
+ }
2275
2287
  // Issue #664: a part the set draws on its front slot is one the set covers and a limb declares a front slot for.
2276
2288
  if ('front' in e) {
2277
2289
  if (!Array.isArray(e.front) || e.front.length === 0) {