@yschimke/compose-design-map 1.56.1 → 1.57.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/README.md CHANGED
@@ -28,7 +28,7 @@ Every field the projection reads is defined in this repository:
28
28
  | `catalog.reference`, `referenceSet`, `noReference`, `referenceContentsOnly`, `kitAxis` | [`@CatalogComponent`](https://github.com/yschimke/compose-ai-tools/blob/main/api/preview-annotations/src/commonMain/kotlin/ee/schimke/composeai/preview/CatalogComponent.kt) |
29
29
  | `catalog.props`, `catalog.state`, `catalog.kitValue` | `@CatalogVariant` |
30
30
  | `overrides.seeds`, `overrides.props` | `@OverrideVariant` / `@PreviewAxis` |
31
- | `overrides.kitAxis`, `overrides.kitValue` | `@OverrideVariant` |
31
+ | `overrides.kitAxis`, `overrides.kitValue`, `overrides.noReference` | `@OverrideVariant` |
32
32
 
33
33
  Rename one of those and the projection has to change in the same commit. Keeping the two on
34
34
  opposite sides of a repo boundary is how a manifest reader goes quietly stale — and the reference
@@ -109,7 +109,10 @@ must match that string before reading it. One entry per component that has varia
109
109
  "basePreviewId": "…FilledButton_Light",
110
110
  "renders": [
111
111
  { "previewId": "…FilledButton_Light_VARIANT_l", "name": "l",
112
- "seeds": [{ "key": "size", "raw": "l" }, { "key": "shape", "raw": "round" }] }
112
+ "seeds": [{ "key": "size", "raw": "l" }, { "key": "shape", "raw": "round" }] },
113
+ { "previewId": "…FilledButton_Light_VARIANT_indeterminate", "name": "indeterminate",
114
+ "seeds": [{ "key": "progress", "raw": "indeterminate" }],
115
+ "noReference": "The kit publishes determinate progress cells only." }
113
116
  ]
114
117
  }
115
118
  ]
@@ -118,7 +121,9 @@ must match that string before reading it. One entry per component that has varia
118
121
 
119
122
  It is a separate file rather than another key on the map because the design-map schema sets
120
123
  `additionalProperties: false` — a map carrying an extra key would fail its own validator. No file is
121
- written when nothing declares an axis.
124
+ written when nothing declares an axis or a stated cell absence. A render carrying `noReference`
125
+ does not enter kit-node resolution; the reason is the result, and remains reportable alongside the
126
+ cells that do resolve.
122
127
 
123
128
  ## Two things worth knowing
124
129
 
package/design-map.mjs CHANGED
@@ -460,7 +460,7 @@ export function variantAbsenceId(preview) {
460
460
  // may hold a perfectly good reference: it reads as a finding about the parent, and says nothing
461
461
  // about which variant the reason belongs to. The function name is what distinguishes such a
462
462
  // variant, so it stands in for the axes it did not give.
463
- const label = axes || preview.functionName || captureIdentity(preview).subject;
463
+ const label = axes || preview.overrides?.name || preview.functionName || captureIdentity(preview).subject;
464
464
  return label ? `${parent} [${label}]` : parent;
465
465
  }
466
466
 
@@ -490,6 +490,10 @@ function variantName(preview, seeds) {
490
490
  * the exact failure `kitAxis` exists to remove.
491
491
  */
492
492
  export function declarationMisses(preview) {
493
+ // This cell declares that the kit publishes nothing for it, so none of its kit names are meant
494
+ // to enter resolution. Reporting them as unplaced would turn an authored absence back into the
495
+ // indistinguishable resolution failure `noReference` exists to prevent.
496
+ if (preview.overrides?.noReference) return [];
493
497
  const catalog = preview.catalog;
494
498
  const fold = catalog?.role === "VARIANT" ? foldSeeds(catalog).unattached : [];
495
499
  const cell = cellSeeds(preview.overrides, catalog).unattached;
@@ -629,9 +633,11 @@ export function variantRendersByComponent(
629
633
  if (!selection.participates(preview)) continue;
630
634
 
631
635
  // A variant that names no axis says only "this is different", which is not enough to look
632
- // anything up in a kit. Dropped rather than guessed at from the function name.
636
+ // anything up in a kit. Dropped rather than guessed at from the function name — unless it
637
+ // states that the kit publishes no cell for it. That statement itself belongs in the sidecar
638
+ // even though there is deliberately nothing to resolve.
633
639
  const seeds = variantSeeds(preview);
634
- if (!seeds.length) continue;
640
+ if (!seeds.length && !preview.overrides?.noReference) continue;
635
641
 
636
642
  // A `@CatalogVariant` may state its OWN kit correspondence, and either spelling changes what a
637
643
  // resolver should do with this render. Without reading them here a variant's declaration is
@@ -649,6 +655,12 @@ export function variantRendersByComponent(
649
655
  previewId: preview.id,
650
656
  name: variantName(preview, seeds),
651
657
  seeds,
658
+ // An authored finding about this CELL, not the parent component. A resolver must preserve it
659
+ // and skip node lookup; without the field a deliberate nodeless render is indistinguishable
660
+ // from a typo in kitAxis/kitValue/kitProps.
661
+ ...(isOverrideVariant && preview.overrides?.noReference
662
+ ? { noReference: preview.overrides.noReference }
663
+ : {}),
652
664
  // `reference` names the variant's own kit cell. Carried onto the render so a resolver pairs
653
665
  // that handle instead of deriving one from the parent's by seed. Additive to the sidecar's
654
666
  // shape — a resolver that does not read it sees exactly what it saw before, which is why the
@@ -812,6 +824,21 @@ export function projectDesignMap(previews, opts = {}) {
812
824
  unmapped.sort();
813
825
  statedAbsent.sort((a, b) => a.componentId.localeCompare(b.componentId));
814
826
 
827
+ /** Folded cells that deliberately correspond to nothing the kit published. */
828
+ const statedAbsentCells = previews
829
+ .filter(
830
+ (preview) =>
831
+ isVariantCapture(preview) &&
832
+ preview.overrides?.noReference &&
833
+ selection.participates(preview),
834
+ )
835
+ .map((preview) => ({
836
+ componentId: variantAbsenceId(preview),
837
+ previewId: preview.id,
838
+ reason: preview.overrides.noReference,
839
+ }))
840
+ .sort((a, b) => a.componentId.localeCompare(b.componentId));
841
+
815
842
  // Only the captures that participate: a variant declares once, and reporting its dark capture
816
843
  // beside its light one would double every line of a list that exists to be acted on.
817
844
  const unplacedDeclarations = previews
@@ -824,6 +851,10 @@ export function projectDesignMap(previews, opts = {}) {
824
851
  diagnostics: {
825
852
  unmapped,
826
853
  statedAbsent,
854
+ // Kept apart from component / `@CatalogVariant` absences. A folded cell is still valid
855
+ // inventory under plain --strict: its parent maps, its render is real, and its whole point is
856
+ // to record that the kit has no corresponding node.
857
+ statedAbsentCells,
827
858
  unplacedDeclarations,
828
859
  // Composables whose captures name no mode a reference could pair with — several modes, none
829
860
  // of them light. Reported rather than guessed at: pairing `Dark` when the kit drew `Coral`
@@ -188,6 +188,16 @@ if (diagnostics.statedAbsent.length) {
188
188
  }
189
189
  }
190
190
 
191
+ if (diagnostics.statedAbsentCells?.length) {
192
+ console.log(
193
+ `\n${diagnostics.statedAbsentCells.length} folded cell(s) have no design-kit node for a ` +
194
+ `stated reason — these are valid renders, not unresolved variant declarations:`,
195
+ );
196
+ for (const cell of diagnostics.statedAbsentCells) {
197
+ console.log(` - ${cell.componentId} — ${cell.reason}`);
198
+ }
199
+ }
200
+
191
201
  if (diagnostics.unplacedDeclarations?.length) {
192
202
  console.log(
193
203
  `\n${diagnostics.unplacedDeclarations.length} variant(s) name a kit axis or value that could ` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yschimke/compose-design-map",
3
- "version": "1.56.1",
3
+ "version": "1.57.0",
4
4
  "description": "Project a compose-preview discovery manifest into design-parity's design-map.json, plus a sidecar of unresolved variant declarations. Dependency-free.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",