@wildwinter/toolkit 0.2.0 → 0.2.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.
@@ -396,7 +396,7 @@ function targetProblems(host, kind, target, path, settings, out) {
396
396
  if (!SCALAR_TYPES.includes(claim.type)) {
397
397
  out.push(err2("claim-type", atKey(at, "type"), "a claim presents a host field, which is a scalar"));
398
398
  } else {
399
- typeProblems(host, claim, at, false, out);
399
+ typeProblems(host, claim, at, false, out, true);
400
400
  }
401
401
  if (typeof claim.setting !== "string" || !settings.has(claim.setting)) {
402
402
  out.push(err2("claim-setting", atKey(at, "setting"), `a claim names its field through a setting, and "${String(claim.setting)}" is not one of the manifest's settings`));
@@ -439,7 +439,7 @@ function fieldListProblems(host, fields, path, topLevel, out) {
439
439
  }
440
440
  });
441
441
  }
442
- function typeProblems(host, decl, path, named, out) {
442
+ function typeProblems(host, decl, path, named, out, claim = false) {
443
443
  const typeAt = atKey(path, "type");
444
444
  if (decl.type === "string") {
445
445
  out.push(err2("string-type", typeAt, 'the text type is spelled "text"'));
@@ -455,6 +455,7 @@ function typeProblems(host, decl, path, named, out) {
455
455
  case "enum":
456
456
  case "flags": {
457
457
  const values = decl.values;
458
+ if (claim && values === void 0) break;
458
459
  if (!Array.isArray(values) || values.length === 0) {
459
460
  out.push(err2("values-empty", at("values"), `an ${decl.type === "enum" ? "enum" : "flags field"} lists its values`));
460
461
  sound = false;
@@ -473,6 +474,7 @@ function typeProblems(host, decl, path, named, out) {
473
474
  break;
474
475
  }
475
476
  case "quality": {
477
+ if (claim && decl.stages === void 0) break;
476
478
  for (const p of qualityDeclarationProblems(decl.stages)) {
477
479
  out.push(err2(
478
480
  `quality-${p.kind === "default-not-a-stage" ? "default" : p.kind}`,
@@ -532,7 +534,11 @@ function typeProblems(host, decl, path, named, out) {
532
534
  }
533
535
  }
534
536
  if (decl.renamedStages !== void 0) renamedStagesProblems(decl, at("renamedStages"), out);
535
- if (decl.valueHelp !== void 0) {
537
+ if (decl.valueHelp !== void 0 && claim) {
538
+ if (!isObject(decl.valueHelp) || !["enum", "flags", "quality"].includes(decl.type)) {
539
+ out.push(err2("value-help", at("valueHelp"), "value help describes the values of an enum or flags field, or a quality's stages"));
540
+ }
541
+ } else if (decl.valueHelp !== void 0) {
536
542
  const vocabulary = decl.type === "quality" ? decl.stages : decl.type === "enum" || decl.type === "flags" ? decl.values : void 0;
537
543
  if (vocabulary === void 0 || !isObject(decl.valueHelp)) {
538
544
  out.push(err2("value-help", at("valueHelp"), "value help describes the values of an enum or flags field, or a quality's stages"));
@@ -613,6 +619,14 @@ function targetOf(manifest, host, kind) {
613
619
  const kinds = manifest?.targets[host];
614
620
  return kinds !== void 0 && own(kinds, kind) ? kinds[kind] : void 0;
615
621
  }
622
+ function effectiveClaim(claim, hostDecl) {
623
+ return {
624
+ ...claim,
625
+ ...claim.values === void 0 && hostDecl.values !== void 0 ? { values: hostDecl.values } : {},
626
+ ...claim.stages === void 0 && hostDecl.stages !== void 0 ? { stages: hostDecl.stages } : {},
627
+ ...claim.default === void 0 && hostDecl.default !== void 0 ? { default: hostDecl.default } : {}
628
+ };
629
+ }
616
630
 
617
631
  // src/extensions/merge.ts
618
632
  var ATOMIC = { kind: "atomic" };
@@ -883,6 +897,6 @@ function orphanedEntries(data, exists) {
883
897
  return out;
884
898
  }
885
899
 
886
- export { ATOMIC, HOSTS, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, SCALAR_TYPES, SET, UNRESOLVED_KEY, VALUE_TYPES, atIndex, atKey, claimClashes, compileEntry, compiledTarget, defaultOf, entryProblems, extensionDataStrategy, keyedBy, manifestProblems, mapOf, markUnresolved, mergeExtensionData, mergeTree, objectOf, orphanedEntries, parseManifest, renameStages, resolvedClaims, settingValues, stableStringify, strategyForTarget, strategyForType, targetOf, unresolvedOf, unresolvedProblems, valueProblems, withoutMark };
900
+ export { ATOMIC, HOSTS, MANIFEST_FILE_SUFFIX, MANIFEST_SCHEMA, SCALAR_TYPES, SET, UNRESOLVED_KEY, VALUE_TYPES, atIndex, atKey, claimClashes, compileEntry, compiledTarget, defaultOf, effectiveClaim, entryProblems, extensionDataStrategy, keyedBy, manifestProblems, mapOf, markUnresolved, mergeExtensionData, mergeTree, objectOf, orphanedEntries, parseManifest, renameStages, resolvedClaims, settingValues, stableStringify, strategyForTarget, strategyForType, targetOf, unresolvedOf, unresolvedProblems, valueProblems, withoutMark };
887
901
  //# sourceMappingURL=extensions.js.map
888
902
  //# sourceMappingURL=extensions.js.map