@yahoo/uds-create-config 5.94.4 → 5.95.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.
@@ -1,5 +1,5 @@
1
1
  import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintFix, AuthoringLintGroup, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, ConfigReadLintRule, LintReads, LintRuleSettingNote, flatLintSeverities, lintReads, lintRuleSettingNotes, nestLintSeverities, ruleSeverity } from "./rules.js";
2
2
  import { ConfigLintFinding, ConfigLintOptions, LintIgnore, ignoredBy } from "./context.js";
3
- import { LintFixSite, fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, rulesOf, severityEdits } from "./edits.js";
3
+ import { LintFixSite, fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, retargetEdits, rulesOf, severityEdits } from "./edits.js";
4
4
  import { AuthoringLintEdit, AuthoringLintFinding, AuthoringLintResult, LintIgnoreProblem, LintRun, LintSources, lint, lintConfig } from "./lint.js";
5
- export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintEdit, AuthoringLintFinding, AuthoringLintFix, AuthoringLintGroup, AuthoringLintResult, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, type ConfigLintFinding, type ConfigLintOptions, ConfigReadLintRule, LintFixSite, type LintIgnore, LintIgnoreProblem, LintReads, LintRuleSettingNote, LintRun, LintSources, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, ruleSeverity, rulesOf, severityEdits };
5
+ export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, AuthoringLintEdit, AuthoringLintFinding, AuthoringLintFix, AuthoringLintGroup, AuthoringLintResult, AuthoringLintRule, AuthoringLintRuleSettings, AuthoringLintSeverity, CONFIG_LINT_RULES, ConfigLintCheck, type ConfigLintFinding, type ConfigLintOptions, ConfigReadLintRule, LintFixSite, type LintIgnore, LintIgnoreProblem, LintReads, LintRuleSettingNote, LintRun, LintSources, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
@@ -1,5 +1,5 @@
1
1
  import { ignoredBy } from "./context.js";
2
2
  import { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, flatLintSeverities, lintReads, lintRuleSettingNotes, nestLintSeverities, ruleSeverity } from "./rules.js";
3
- import { fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, rulesOf, severityEdits } from "./edits.js";
3
+ import { fixEdits, groupSeverity, hasFix, ignoreEdits, ignoreEntry, lintIgnores, lintSeverities, restoreEdits, retargetEdits, rulesOf, severityEdits } from "./edits.js";
4
4
  import { lint, lintConfig } from "./lint.js";
5
- export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, ruleSeverity, rulesOf, severityEdits };
5
+ export { AUTHORING_LINT_GROUPS, AUTHORING_LINT_RULES, CONFIG_LINT_RULES, fixEdits, flatLintSeverities, groupSeverity, hasFix, ignoreEdits, ignoreEntry, ignoredBy, lint, lintConfig, lintIgnores, lintReads, lintRuleSettingNotes, lintSeverities, nestLintSeverities, restoreEdits, retargetEdits, ruleSeverity, rulesOf, severityEdits };
@@ -1,6 +1,7 @@
1
1
  import { isRef } from "../framework/utils/refs.js";
2
2
  import { resolveTokenValueUnder, stylePropEntries } from "../framework/projections.js";
3
- import { contrastRatio } from "../framework/utils/color.js";
3
+ import { Token } from "../entities/system/Token.js";
4
+ import { contrastRatio, luminance } from "../framework/utils/color.js";
4
5
  import { parseCssLength } from "../framework/utils/css-length.js";
5
6
  import "../index.js";
6
7
  import { MIN_CONTRAST, SCALE_STEP, TRANSPARENT, written } from "./context.js";
@@ -388,7 +389,7 @@ function literalMatchesToken(ctx, value, report) {
388
389
  if (!match) return;
389
390
  report({
390
391
  at: value,
391
- message: `\`${value.bracketed}\` is what ${value.site.prop}'s \`${match.name}\` holds. Use the token, so a change to it reaches this layer.`,
392
+ message: `Matches a token. Use \`${match.name}\`, so a change to it reaches this layer.`,
392
393
  suggestion: match.name
393
394
  });
394
395
  }
@@ -406,7 +407,7 @@ function numberInBrackets(ctx, value, report) {
406
407
  const bare = bracketed.trim().replace(/px$/, "");
407
408
  report({
408
409
  at: value,
409
- message: `\`${site.prop}\` takes a number in ${reads === "px" ? "px" : "as it is"}: write \`${bare}\`.`,
410
+ message: `Write \`${bare}\` without the brackets. ${site.prop} takes a plain number${reads === "px" ? " in px" : ""}.`,
410
411
  suggestion: bare
411
412
  });
412
413
  }
@@ -425,7 +426,7 @@ function nearToken(ctx, value, report) {
425
426
  if (!nearest || nearest.off <= 0 || nearest.off > Math.max(1, nearest.px * .05) || tokens.some((one) => one.px === px)) return;
426
427
  report({
427
428
  at: value,
428
- message: `\`${written(site.value)}\` is ${Math.round(nearest.off * 100) / 100}px off ${site.prop}'s \`${nearest.name}\` (${nearest.literal}${/rem$/.test(nearest.literal) ? `, ${nearest.px}px at a 16px root` : ""}).`,
429
+ message: `\`${written(site.value)}\` is ${Math.round(nearest.off * 100) / 100}px off ${site.prop}'s \`${nearest.name}\` (${nearest.literal}${/rem$/.test(nearest.literal) ? `, ${nearest.px}px at a 16px root` : ""}). Use \`${nearest.name}\`.`,
429
430
  suggestion: nearest.name
430
431
  });
431
432
  }
@@ -453,7 +454,7 @@ function fixedInDarkMode(ctx, component, report) {
453
454
  if (!color || color[3] === 0) continue;
454
455
  report({
455
456
  at: value,
456
- message: value.token ? `\`${value.token}\` is ${literal} in ${dark} mode too, while ${changing.length} of this component's colors change.` : `\`${written(site.value)}\` is written as a color, so it stays ${literal} in ${dark} mode while ${changing.length} of this component's colors change.`
457
+ message: value.token ? `\`${value.token}\` stays ${literal} in ${dark} mode, while ${changing.length} other colors here change. Use a token with a ${dark} value.` : `Stays ${literal} in ${dark} mode, while ${changing.length} other colors here change. Use a token with a ${dark} value.`
457
458
  });
458
459
  }
459
460
  }
@@ -484,12 +485,23 @@ function lowContrast(ctx, layer, report) {
484
485
  change: "text",
485
486
  ...contrast
486
487
  });
487
- let advice = "";
488
- if (backdrop) advice = ` \`${backdrop.token}\` is the closest background that clears it in every mode.`;
489
- else if (recolor) advice = ` \`${recolor.token}\` is the closest text color that clears it in every mode.`;
488
+ const issue = `Fails ${minimum === 4.5 ? "text" : "icon"} contrast in ${mode.label} mode (${(Math.floor(ratio * 100) / 100).toFixed(2)}:1, needs ${minimum}:1).`;
489
+ let fixLabel;
490
+ if (backdrop) fixLabel = `Use \`${backdrop.token}\` for the background.`;
491
+ else if (recolor) fixLabel = `Use \`${recolor.token}\`.`;
492
+ else if (luminance(fg) > luminance(bg)) fixLabel = "Use a darker background or lighter text.";
493
+ else fixLabel = "Use a lighter background or darker text.";
494
+ const retarget = retargetOf({
495
+ ctx,
496
+ value: backdrop ? background : text,
497
+ to: (backdrop ?? recolor)?.token
498
+ });
490
499
  report({
491
500
  at: text,
492
- message: `\`${written(text.site.value)}\` on \`${written(background.site.value)}\` is ${(Math.floor(ratio * 100) / 100).toFixed(2)}:1 in ${mode.label} mode${layer.where ? ` (${layer.where})` : ""}; ${minimum === 4.5 ? "text" : "an icon"} needs ${minimum}:1.${advice}`,
501
+ message: `${issue} ${retarget ? `${fixLabel.slice(0, -1)}, or ${retarget.label.charAt(0).toLowerCase()}${retarget.label.slice(1)}` : fixLabel}`,
502
+ issue,
503
+ fixLabel,
504
+ ...retarget ? { retarget } : {},
493
505
  ...backdrop ? {
494
506
  suggestion: backdrop.name,
495
507
  fixAt: background
@@ -499,16 +511,32 @@ function lowContrast(ctx, layer, report) {
499
511
  return;
500
512
  }
501
513
  }
514
+ /**
515
+ * The token a fixed value names, repointed at the fix: offered when the value names a token whose own
516
+ * value is another token (`positive` → `spectrum/green/9`), so changing it is a choice about the
517
+ * system rather than about one palette step every other token reads.
518
+ */
519
+ function retargetOf({ ctx, value, to }) {
520
+ const token = value.token;
521
+ if (!token || !to || token === to) return void 0;
522
+ const stored = Token.get(ctx.config, token)?.value;
523
+ if (!isRef(stored)) return void 0;
524
+ return {
525
+ token,
526
+ to,
527
+ label: `Update \`${written(value.site.value)}\` to \`${to}\`.`
528
+ };
529
+ }
502
530
  /** small-tap-target: the root of something you press, under the platform's minimum. */
503
531
  function smallTapTarget(ctx, layer, report) {
504
532
  if (!layer.pressable) return;
505
533
  const { minTarget, unit } = ctx.platform;
506
- for (const [value, reads] of [[layer.height, "tall"], [layer.width, "wide"]]) {
534
+ for (const value of [layer.height, layer.width]) {
507
535
  const px = value?.px();
508
536
  if (!value || px === void 0 || px <= 0 || px >= minTarget) continue;
509
537
  report({
510
538
  at: value,
511
- message: `${layer.where ? `At ${layer.where}, it` : "It"}'s ${px}${unit} ${reads}; a target you press needs ${minTarget}${unit}.`
539
+ message: `Increase to ${minTarget}${unit} (currently ${px}${unit}) for touch compliance.`
512
540
  });
513
541
  }
514
542
  }
@@ -538,7 +566,7 @@ function duplicateToken(ctx, report) {
538
566
  token,
539
567
  prop: key,
540
568
  value: signature.split("|")[0],
541
- message: `\`${token}\` holds ${signature.split("|")[0]}, as \`${first}\` does${modes.length > 1 ? " in every mode" : ""}, and ${key} offers both.`,
569
+ message: `Same value as \`${first}\`${modes.length > 1 ? " in every mode" : ""} (${signature.split("|")[0]}). Use \`${first}\`, so ${key} offers each value once.`,
542
570
  suggestion: first
543
571
  });
544
572
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * An addition only, so the envelope passes through as it is: a variant value's body may carry
3
+ * `boolean: true`, on a value named `true` or `false`. The value is that boolean, and a condition or
4
+ * default on it holds the boolean. The list form takes `true` and `false` and stores them so.
5
+ */
6
+ import type { SchemaMigration } from '../framework/schema-version';
7
+ export declare const VARIANT_BOOLEANS_VERSION = 20261112154943;
8
+ export declare const variantBooleansMigration: SchemaMigration;
@@ -0,0 +1,10 @@
1
+ //#region src/migrations/20261112154943_variant_booleans.ts
2
+ const VARIANT_BOOLEANS_VERSION = 20261112154943;
3
+ const variantBooleansMigration = {
4
+ version: VARIANT_BOOLEANS_VERSION,
5
+ up(json) {
6
+ return json;
7
+ }
8
+ };
9
+ //#endregion
10
+ export { VARIANT_BOOLEANS_VERSION, variantBooleansMigration };