@dloizides/logo-kit 0.1.3 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ - Motion recipes: `brand.json` `motion.intro` / `motion.micro` may name a recipe instead of a beat list. Intro recipes `rim-then-ink`, `phase-wipe`, `faces-settle`, `turn-into-place`, `grow-from-circles`, `fly-in`, `spin-assemble`, `drop-bounce`, `flip-faces`, `slam-shake`; micro recipes `faces-part`, `breath`, `rim-glint`, `part-and-glint`.
6
+ - `motion.roles` (`base`, `parts`) names the layers a recipe acts on; without it, base is the first layer and parts are the rest. Distances scale with the viewBox size.
7
+ - New intro presets `fly-in`, `spin-assemble`, `drop-bounce`, `flip`, `slam-shake` (`BOLD_PRESETS`), each default within 1200 ms.
8
+ - `pulse` and `sweep` are micro presets again, reversing the 0.1.1 note: `MICRO_DEFAULTS` gives each a 300 ms hover beat, and the 300 ms micro cap is still enforced.
9
+ - `check`, `export` and `generate` exit 1 and name an unknown recipe or a `motion.roles` layer the mark does not have.
10
+
3
11
  ## 0.1.2
4
12
 
5
13
  - Fix: the hover micro no longer restarts or cuts short the intro. Micro CSS now animates dedicated wrappers (`<g class="lkmN">` per layer, `<g class="lkmm">` for the whole mark, `lkmsN` sweep overlays) instead of the intro's `.lN` / `#mark` / `.lksN` elements, so hover never changes the intro element's `animation-name`.
package/dist/cli.js CHANGED
@@ -208,6 +208,10 @@ function markSvg(mark, palette, mode, opts) {
208
208
  const style = opts.style !== void 0 ? `<style>${opts.style}</style>` : "";
209
209
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${mark.viewBox}" width="${size}" height="${size}" role="img" aria-label="${label}"><title>${label}</title>${style}${markBody(mark, palette, mode, opts)}${opts.overlay ?? ""}</svg>`;
210
210
  }
211
+ function markSizeOf(mark) {
212
+ const vb = viewBoxOf(mark);
213
+ return Math.max(vb.w, vb.h);
214
+ }
211
215
  function viewBoxOf(mark) {
212
216
  const [x = 0, y = 0, w = 1, h = 1] = mark.viewBox.trim().split(/[\s,]+/).map(Number);
213
217
  return { x, y, w, h };
@@ -250,9 +254,9 @@ function normalise(mask, w, h) {
250
254
  for (let gx = 0; gx < GRID; gx++) {
251
255
  let hits = 0;
252
256
  for (let s = 0; s < SAMPLES * SAMPLES; s++) {
253
- const px = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
257
+ const px2 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
254
258
  const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
255
- hits += px >= 0 && py >= 0 && px < w && py < h ? mask[py * w + px] ?? 0 : 0;
259
+ hits += px2 >= 0 && py >= 0 && px2 < w && py < h ? mask[py * w + px2] ?? 0 : 0;
256
260
  }
257
261
  out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
258
262
  }
@@ -413,9 +417,9 @@ function legibility(mark, size) {
413
417
  out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
414
418
  }
415
419
  mark.layers.forEach((layer, i) => {
416
- const px = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
417
- if (px < (MIN_LAYER_PX[size] ?? 1)) {
418
- out.push(`legible${size}: layer "${layer.name}" is ${px} px, lost at ${size} px`);
420
+ const px2 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
421
+ if (px2 < (MIN_LAYER_PX[size] ?? 1)) {
422
+ out.push(`legible${size}: layer "${layer.name}" is ${px2} px, lost at ${size} px`);
419
423
  }
420
424
  });
421
425
  return out;
@@ -457,6 +461,13 @@ function checkVariants(seed, variants, palette) {
457
461
  }
458
462
 
459
463
  // src/motion/MotionPreset.ts
464
+ var BOLD_PRESETS = [
465
+ "fly-in" /* FlyIn */,
466
+ "spin-assemble" /* SpinAssemble */,
467
+ "drop-bounce" /* DropBounce */,
468
+ "flip" /* Flip */,
469
+ "slam-shake" /* SlamShake */
470
+ ];
460
471
  var INTRO_PRESETS = [
461
472
  "draw" /* Draw */,
462
473
  "flood" /* Flood */,
@@ -466,9 +477,10 @@ var INTRO_PRESETS = [
466
477
  "wipe" /* Wipe */,
467
478
  "morph-from-circle" /* MorphFromCircle */,
468
479
  "sweep" /* Sweep */,
469
- "pulse" /* Pulse */
480
+ "pulse" /* Pulse */,
481
+ ...BOLD_PRESETS
470
482
  ];
471
- var MICRO_PRESETS = ["spread" /* Spread */];
483
+ var MICRO_PRESETS = ["spread" /* Spread */, "pulse" /* Pulse */, "sweep" /* Sweep */];
472
484
 
473
485
  // src/motion/defaults.ts
474
486
  var INTRO_CAP_MS = 1200;
@@ -476,6 +488,7 @@ var MICRO_CAP_MS = 300;
476
488
  var EASE = "cubic-bezier(0.2,0,0,1)";
477
489
  var EASE_IN_FIRST = "cubic-bezier(0,0,0,1)";
478
490
  var MARK_TARGET = "@mark";
491
+ var SPREAD_BEAT = { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 };
479
492
  var PRESET_DEFAULTS = {
480
493
  ["draw" /* Draw */]: { preset: "draw" /* Draw */, durationMs: 700, stepMs: 120 },
481
494
  ["flood" /* Flood */]: { preset: "flood" /* Flood */, durationMs: 500, delayMs: 300, stepMs: 80 },
@@ -486,12 +499,148 @@ var PRESET_DEFAULTS = {
486
499
  ["morph-from-circle" /* MorphFromCircle */]: { preset: "morph-from-circle" /* MorphFromCircle */, durationMs: 1200, stops: [0, 40, 100] },
487
500
  ["sweep" /* Sweep */]: { preset: "sweep" /* Sweep */, durationMs: 600, delayMs: 400, stepMs: 60, share: 0.12, width: 2 },
488
501
  ["pulse" /* Pulse */]: { preset: "pulse" /* Pulse */, durationMs: 400, delayMs: 700, layers: [MARK_TARGET], scale: 1.07 },
489
- ["spread" /* Spread */]: { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 }
502
+ ["spread" /* Spread */]: SPREAD_BEAT,
503
+ ["fly-in" /* FlyIn */]: { preset: "fly-in" /* FlyIn */, durationMs: 700, stepMs: 120 },
504
+ ["spin-assemble" /* SpinAssemble */]: { preset: "spin-assemble" /* SpinAssemble */, durationMs: 800, stepMs: 100 },
505
+ ["drop-bounce" /* DropBounce */]: { preset: "drop-bounce" /* DropBounce */, durationMs: 800, stepMs: 100 },
506
+ ["flip" /* Flip */]: { preset: "flip" /* Flip */, durationMs: 700, stepMs: 120 },
507
+ ["slam-shake" /* SlamShake */]: { preset: "slam-shake" /* SlamShake */, durationMs: 800, layers: [MARK_TARGET] }
490
508
  };
491
509
  var DEFAULT_MOTION_CONFIG = {
492
510
  intro: [{ preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 }],
493
511
  micro: [{ preset: "spread" /* Spread */, durationMs: 300, distance: 1.6, easing: EASE }]
494
512
  };
513
+
514
+ // src/motion/timeline.ts
515
+ function targetsOf(beat, layerNames) {
516
+ if (!beat.layers) {
517
+ return [...layerNames];
518
+ }
519
+ return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
520
+ }
521
+ function schedule(beat, layerNames) {
522
+ return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
523
+ }
524
+ function totalMs(beats, layerNames) {
525
+ return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
526
+ }
527
+ function fitBeat(beat, n, capMs) {
528
+ const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
529
+ const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
530
+ return { ...beat, stepMs: step2 };
531
+ }
532
+ function morphClashes(beats, layerNames) {
533
+ const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
534
+ const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
535
+ return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
536
+ }
537
+ function validateMotion(config, layerNames) {
538
+ const introMs = totalMs(config.intro, layerNames);
539
+ const microMs = totalMs(config.micro, layerNames);
540
+ const errors = [
541
+ ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
542
+ ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
543
+ ...config.recipeErrors ?? [],
544
+ ...morphClashes(config.intro, layerNames)
545
+ ];
546
+ const warnings = [];
547
+ if (introMs > INTRO_CAP_MS) {
548
+ const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
549
+ if (config.allowLongIntro !== void 0) {
550
+ warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
551
+ } else {
552
+ errors.push(message);
553
+ }
554
+ }
555
+ if (microMs > MICRO_CAP_MS) {
556
+ errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
557
+ }
558
+ return { introMs, microMs, errors, warnings };
559
+ }
560
+
561
+ // src/motion/recipes.ts
562
+ var REFERENCE_SIZE = 64;
563
+ var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
564
+ var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
565
+ var INTROS = {
566
+ ["rim-then-ink" /* RimThenInk */]: (ctx, k) => [
567
+ { preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 500, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE },
568
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 500, delayMs: 200, easing: EASE_IN_FIRST },
569
+ fit({ preset: "flood" /* Flood */, layers: ctx.roles.parts, durationMs: 400, delayMs: 600, stepMs: 100, easing: EASE })
570
+ ],
571
+ ["phase-wipe" /* PhaseWipe */]: (ctx, k) => [
572
+ { preset: "wipe" /* Wipe */, layers: ctx.roles.base, durationMs: 600, easing: EASE_IN_FIRST },
573
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 400, delayMs: 500, stepMs: 120, distance: 4 * k, easing: EASE })
574
+ ],
575
+ ["faces-settle" /* FacesSettle */]: (ctx, k) => [
576
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
577
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 500, delayMs: 300, stepMs: 150, distance: 6 * k, easing: EASE })
578
+ ],
579
+ ["turn-into-place" /* TurnIntoPlace */]: (ctx) => [fit({ preset: "orbit" /* Orbit */, layers: all(ctx), durationMs: 800, stepMs: 100, easing: EASE })],
580
+ ["grow-from-circles" /* GrowFromCircles */]: (ctx) => [
581
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
582
+ { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 800, delayMs: 300, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: EASE }
583
+ ],
584
+ ["fly-in" /* FlyIn */]: (ctx) => [fit({ preset: "fly-in" /* FlyIn */, layers: all(ctx), durationMs: 700, stepMs: 100 })],
585
+ ["spin-assemble" /* SpinAssemble */]: (ctx) => [
586
+ { preset: "scale-pop" /* ScalePop */, layers: ctx.roles.base, durationMs: 400 },
587
+ fit({ preset: "spin-assemble" /* SpinAssemble */, layers: ctx.roles.parts, durationMs: 700, delayMs: 200, stepMs: 100 })
588
+ ],
589
+ ["drop-bounce" /* DropBounce */]: (ctx) => [fit({ preset: "drop-bounce" /* DropBounce */, layers: all(ctx), durationMs: 800, stepMs: 100 })],
590
+ ["flip-faces" /* FlipFaces */]: (ctx) => [
591
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
592
+ fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
593
+ ],
594
+ ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }]
595
+ };
596
+ var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
597
+ var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
598
+ var MICROS = {
599
+ ["faces-part" /* FacesPart */]: (ctx, k) => [spread(ctx, k)],
600
+ ["breath" /* Breath */]: () => [{ preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 300, scale: 1.04, easing: EASE }],
601
+ ["rim-glint" /* RimGlint */]: (ctx, k) => [glint(ctx, k)],
602
+ ["part-and-glint" /* PartAndGlint */]: (ctx, k) => [spread(ctx, k), glint(ctx, k)]
603
+ };
604
+ var run = (table, name, ctx) => {
605
+ const recipe = table[name];
606
+ return recipe ? recipe(ctx, ctx.size / REFERENCE_SIZE) : null;
607
+ };
608
+ function introRecipe(name, ctx) {
609
+ return run(INTROS, name, ctx);
610
+ }
611
+ function microRecipe(name, ctx) {
612
+ return run(MICROS, name, ctx);
613
+ }
614
+
615
+ // src/motion/resolveMotion.ts
616
+ var KINDS = {
617
+ intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
618
+ micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
619
+ };
620
+ function resolve(kind, value, ctx) {
621
+ const { recipe, fallback } = KINDS[kind];
622
+ if (typeof value !== "string") {
623
+ return { beats: value ?? fallback };
624
+ }
625
+ const beats = recipe(value, ctx);
626
+ return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
627
+ }
628
+ function resolveMotion(raw, layerNames, size) {
629
+ const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
630
+ const ctx = { roles, size };
631
+ const intro = resolve("intro", raw?.intro, ctx);
632
+ const micro = resolve("micro", raw?.micro, ctx);
633
+ const errors = [
634
+ ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
635
+ ...[intro.error, micro.error].filter((e) => e !== void 0)
636
+ ];
637
+ return {
638
+ intro: intro.beats,
639
+ micro: micro.beats,
640
+ ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
641
+ ...errors.length > 0 ? { recipeErrors: errors } : {}
642
+ };
643
+ }
495
644
  function presetOf(id) {
496
645
  const preset = PRESETS[id];
497
646
  if (!preset) {
@@ -535,15 +684,16 @@ function toPalette(raw, name) {
535
684
  function parseBrand(raw, baseDir) {
536
685
  const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
537
686
  const small = raw.smallMark;
687
+ const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
538
688
  return {
539
689
  icons: { ...DEFAULT_ICONS, ...raw.icons },
540
690
  ...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
541
691
  name: raw.name,
542
692
  slug: raw.slug,
543
693
  wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
544
- mark: { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) },
694
+ mark,
545
695
  palette: toPalette(raw.palette, raw.slug),
546
- motion: { ...DEFAULT_MOTION_CONFIG, ...raw.motion },
696
+ motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
547
697
  generate: raw.generate ?? DEFAULT_GENERATE,
548
698
  tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "mooncube",
549
699
  baseDir
@@ -767,6 +917,61 @@ function centroid(pts) {
767
917
  return { x: pts.reduce((s, p) => s + p.x, 0) / n, y: pts.reduce((s, p) => s + p.y, 0) / n };
768
918
  }
769
919
 
920
+ // src/motion/boldPresets.ts
921
+ var fillBox = "transform-box:fill-box;transform-origin:center";
922
+ var px = (n) => `${n.toFixed(2)}px`;
923
+ var frames = (stops) => stops.map(([at, body]) => `${at}%{${body}}`).join("");
924
+ function outward(ctx) {
925
+ const pts = ctx.layer ? flattenPath(ctx.layer.d).flat() : [];
926
+ const c = pts.length > 0 ? centroid(pts) : ctx.markCentre;
927
+ const dx = c.x - ctx.markCentre.x;
928
+ const dy = c.y - ctx.markCentre.y;
929
+ const len = Math.hypot(dx, dy);
930
+ return len > 0 ? { x: dx / len, y: dy / len } : { x: -1, y: 0 };
931
+ }
932
+ function flyIn(beat, ctx) {
933
+ const u = outward(ctx);
934
+ const d = beat.distance ?? ctx.markSize * 0.5;
935
+ const at = (k) => `transform:translate(${px(u.x * d * k)},${px(u.y * d * k)})`;
936
+ const keyframes = frames([[0, `opacity:0;${at(1)}`], [60, `opacity:1;${at(-0.08)}`], [80, `opacity:1;${at(0.03)}`], [100, `opacity:1;${at(0)}`]]);
937
+ return { keyframes, timing: beat.easing ?? EASE };
938
+ }
939
+ function spinAssemble(beat) {
940
+ const keyframes = frames([[0, "opacity:0;transform:rotate(-540deg) scale(0.2)"], [75, "opacity:1;transform:rotate(12deg) scale(1.06)"], [100, "opacity:1;transform:rotate(0deg) scale(1)"]]);
941
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
942
+ }
943
+ function dropBounce(beat, ctx) {
944
+ const h = beat.distance ?? ctx.markSize * 0.6;
945
+ const y = (k) => `transform:translateY(${px(-h * k)})`;
946
+ const keyframes = frames([[0, `opacity:0;${y(1)}`], [45, `opacity:1;${y(0)}`], [60, `opacity:1;${y(0.18)}`], [75, `opacity:1;${y(0)}`], [87, `opacity:1;${y(0.05)}`], [100, `opacity:1;${y(0)}`]]);
947
+ return { keyframes, timing: beat.easing ?? "ease-in-out" };
948
+ }
949
+ function flip(beat) {
950
+ const keyframes = frames([[0, "opacity:0;transform:scale(0,1)"], [35, "opacity:1;transform:scale(-1,1)"], [65, "opacity:1;transform:scale(0,1)"], [100, "opacity:1;transform:scale(1,1)"]]);
951
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
952
+ }
953
+ function slamShake(beat, ctx) {
954
+ const s = beat.distance ?? ctx.markSize * 0.04;
955
+ const at = (k, scale) => `transform:translate(${px(s * k)},0px) scale(${scale})`;
956
+ const keyframes = frames([
957
+ [0, `opacity:0;${at(0, beat.scale ?? 2.4)}`],
958
+ [40, `opacity:1;${at(0, 0.94)}`],
959
+ [50, `opacity:1;${at(-1, 1)}`],
960
+ [62, `opacity:1;${at(1, 1)}`],
961
+ [74, `opacity:1;${at(-0.6, 1)}`],
962
+ [86, `opacity:1;${at(0.3, 1)}`],
963
+ [100, `opacity:1;${at(0, 1)}`]
964
+ ]);
965
+ return { keyframes, timing: beat.easing ?? "cubic-bezier(0.5,0,0.75,0)", extra: fillBox };
966
+ }
967
+ var BOLD_PRESET_FRAMES = {
968
+ ["fly-in" /* FlyIn */]: flyIn,
969
+ ["spin-assemble" /* SpinAssemble */]: spinAssemble,
970
+ ["drop-bounce" /* DropBounce */]: dropBounce,
971
+ ["flip" /* Flip */]: flip,
972
+ ["slam-shake" /* SlamShake */]: slamShake
973
+ };
974
+
770
975
  // src/motion/morph.ts
771
976
  var POINTS = 96;
772
977
  function startAtTop(poly, c) {
@@ -800,7 +1005,7 @@ function morphPair(d) {
800
1005
  }
801
1006
 
802
1007
  // src/motion/presets.ts
803
- var fillBox = "transform-box:fill-box;transform-origin:center";
1008
+ var fillBox2 = "transform-box:fill-box;transform-origin:center";
804
1009
  function morphFrames(beat, ctx) {
805
1010
  const layer = ctx.layer;
806
1011
  if (!layer) {
@@ -832,7 +1037,7 @@ var PRESETS2 = {
832
1037
  ["draw" /* Draw */]: (b) => ({ keyframes: "0%{stroke-dasharray:1 1;stroke-dashoffset:1}100%{stroke-dasharray:1 1;stroke-dashoffset:0}", timing: b.easing ?? EASE }),
833
1038
  ["flood" /* Flood */]: (b) => ({ keyframes: "0%{fill-opacity:0}100%{fill-opacity:1}", timing: b.easing ?? EASE }),
834
1039
  ["stagger-rise" /* StaggerRise */]: (b) => ({ keyframes: `0%{opacity:0;transform:translateY(${b.distance ?? 4}px)}100%{opacity:1;transform:none}`, timing: b.easing ?? EASE }),
835
- ["scale-pop" /* ScalePop */]: (b) => ({ keyframes: "0%{opacity:0;transform:scale(0.6)}70%{opacity:1;transform:scale(1.06)}100%{opacity:1;transform:scale(1)}", timing: b.easing ?? EASE, extra: fillBox }),
1040
+ ["scale-pop" /* ScalePop */]: (b) => ({ keyframes: "0%{opacity:0;transform:scale(0.6)}70%{opacity:1;transform:scale(1.06)}100%{opacity:1;transform:scale(1)}", timing: b.easing ?? EASE, extra: fillBox2 }),
836
1041
  ["orbit" /* Orbit */]: (b, ctx) => ({
837
1042
  keyframes: "0%{opacity:0;transform:rotate(-90deg)}100%{opacity:1;transform:rotate(0deg)}",
838
1043
  timing: b.easing ?? EASE,
@@ -841,8 +1046,9 @@ var PRESETS2 = {
841
1046
  ["wipe" /* Wipe */]: (b) => ({ keyframes: "0%{clip-path:inset(0 100% 0 0)}100%{clip-path:inset(0 0 0 0)}", timing: b.easing ?? EASE }),
842
1047
  ["morph-from-circle" /* MorphFromCircle */]: (b, ctx) => ({ keyframes: morphFrames(b, ctx), timing: "linear", supportsD: true }),
843
1048
  ["sweep" /* Sweep */]: (b) => ({ keyframes: `0%{stroke-dashoffset:${b.share ?? 0.12};opacity:1}99%{stroke-dashoffset:-1;opacity:1}100%{stroke-dashoffset:-1;opacity:0}`, timing: b.easing ?? "linear" }),
844
- ["pulse" /* Pulse */]: (b) => ({ keyframes: `0%{transform:scale(1)}50%{transform:scale(${b.scale ?? 1.07})}100%{transform:scale(1)}`, timing: b.easing ?? "ease-in-out", extra: fillBox }),
845
- ["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" })
1049
+ ["pulse" /* Pulse */]: (b) => ({ keyframes: `0%{transform:scale(1)}50%{transform:scale(${b.scale ?? 1.07})}100%{transform:scale(1)}`, timing: b.easing ?? "ease-in-out", extra: fillBox2 }),
1050
+ ["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" }),
1051
+ ...BOLD_PRESET_FRAMES
846
1052
  };
847
1053
  function presetFrames(beat, ctx) {
848
1054
  const fn = PRESETS2[beat.preset];
@@ -852,52 +1058,6 @@ function presetFrames(beat, ctx) {
852
1058
  return fn(beat, ctx);
853
1059
  }
854
1060
 
855
- // src/motion/timeline.ts
856
- function targetsOf(beat, layerNames) {
857
- if (!beat.layers) {
858
- return [...layerNames];
859
- }
860
- return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
861
- }
862
- function schedule(beat, layerNames) {
863
- return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
864
- }
865
- function totalMs(beats, layerNames) {
866
- return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
867
- }
868
- function fitBeat(beat, n, capMs) {
869
- const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
870
- const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
871
- return { ...beat, stepMs: step2 };
872
- }
873
- function morphClashes(beats, layerNames) {
874
- const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
875
- const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
876
- return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
877
- }
878
- function validateMotion(config, layerNames) {
879
- const introMs = totalMs(config.intro, layerNames);
880
- const microMs = totalMs(config.micro, layerNames);
881
- const errors = [
882
- ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
883
- ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
884
- ...morphClashes(config.intro, layerNames)
885
- ];
886
- const warnings = [];
887
- if (introMs > INTRO_CAP_MS) {
888
- const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
889
- if (config.allowLongIntro !== void 0) {
890
- warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
891
- } else {
892
- errors.push(message);
893
- }
894
- }
895
- if (microMs > MICRO_CAP_MS) {
896
- errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
897
- }
898
- return { introMs, microMs, errors, warnings };
899
- }
900
-
901
1061
  // src/motion/motionCss.ts
902
1062
  var REDUCED_MOTION = "@media (prefers-reduced-motion:reduce){*{animation:none!important}}";
903
1063
  var sweepClass = (index, hover) => `${hover ? "lkms" : "lks"}${index}`;
@@ -926,28 +1086,28 @@ function render(rules, keyframes) {
926
1086
  const morph = keyframes.filter((k) => k.supportsD).map((k) => k.body).join("");
927
1087
  const decls = (r) => [...r.extras, "animation:".concat(r.animations.join(","))].join(";");
928
1088
  const css = (list) => list.map((r) => `${r.selector}{${decls(r)}}`).join("");
929
- const all = [...rules.values()];
930
- const supports = all.filter((r) => r.supportsD);
1089
+ const all2 = [...rules.values()];
1090
+ const supports = all2.filter((r) => r.supportsD);
931
1091
  const wrapped = supports.length > 0 ? `@supports (d:path("M0 0")){${morph}${css(supports)}}` : "";
932
- return `${plain}${css(all.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
1092
+ return `${plain}${css(all2.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
933
1093
  }
934
1094
  function addSlot(ctx, beat, b, slot) {
935
1095
  const sweep = beat.preset === "sweep" /* Sweep */;
936
1096
  const index = ctx.names.indexOf(slot.target);
937
- const frames = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre });
1097
+ const frames2 = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre, markSize: ctx.markSize });
938
1098
  const suffix = slot.target === MARK_TARGET ? "m" : String(index);
939
1099
  const name = `lk${ctx.hover ? "m" : "i"}${b}-${suffix}`;
940
1100
  const selector = selectorOf(slot.target, index, ctx.hover, sweep);
941
1101
  const rule = ctx.rules.get(selector) ?? { selector, animations: [], extras: [], supportsD: false };
942
1102
  const delay = slot.delayMs > 0 ? ` ${slot.delayMs}ms` : "";
943
1103
  const fill = ctx.hover ? "" : " backwards";
944
- rule.animations.push(`${name} ${slot.durationMs}ms ${frames.timing}${delay} 1${fill}`);
945
- if (frames.extra !== void 0 && !rule.extras.includes(frames.extra)) {
946
- rule.extras.push(frames.extra);
1104
+ rule.animations.push(`${name} ${slot.durationMs}ms ${frames2.timing}${delay} 1${fill}`);
1105
+ if (frames2.extra !== void 0 && !rule.extras.includes(frames2.extra)) {
1106
+ rule.extras.push(frames2.extra);
947
1107
  }
948
- rule.supportsD = rule.supportsD || frames.supportsD === true;
1108
+ rule.supportsD = rule.supportsD || frames2.supportsD === true;
949
1109
  ctx.rules.set(selector, rule);
950
- ctx.keyframes.push({ body: `@keyframes ${name}{${frames.keyframes}}`, supportsD: frames.supportsD === true });
1110
+ ctx.keyframes.push({ body: `@keyframes ${name}{${frames2.keyframes}}`, supportsD: frames2.supportsD === true });
951
1111
  if (beat.preset === "draw" /* Draw */) {
952
1112
  ctx.drawLayers.add(slot.target);
953
1113
  }
@@ -962,6 +1122,7 @@ function motionCss(mark, beats, palette, mode, hover) {
962
1122
  mark,
963
1123
  names: mark.layers.map((l) => l.name),
964
1124
  markCentre: { x: vb.x + vb.w / 2, y: vb.y + vb.h / 2 },
1125
+ markSize: markSizeOf(mark),
965
1126
  colour: (role) => colours[role ?? "text"] ?? "#ffffff",
966
1127
  hover,
967
1128
  rules: /* @__PURE__ */ new Map(),
@@ -1450,6 +1611,10 @@ function generate(file, f, out) {
1450
1611
  out(`generated ${count}, passed ${report.passed.length}, dropped ${report.dropped.length} -> ${dir}`);
1451
1612
  return 0;
1452
1613
  }
1614
+ function motionRefusal(file) {
1615
+ const errors = loadBrand(file).motion.recipeErrors ?? [];
1616
+ return errors.length > 0 ? `motion: ${errors.join("; ")}` : null;
1617
+ }
1453
1618
  function check(file, out) {
1454
1619
  const brand = loadBrand(file);
1455
1620
  const result = runChecks(brand.mark, brand.palette);
@@ -1465,6 +1630,11 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1465
1630
  out(USAGE);
1466
1631
  return 2;
1467
1632
  }
1633
+ const refusal = cmd === "export" || cmd === "generate" ? motionRefusal(file) : null;
1634
+ if (refusal !== null) {
1635
+ out(refusal);
1636
+ return 1;
1637
+ }
1468
1638
  if (cmd === "export") {
1469
1639
  const files = exportBrand(loadBrand(file), f.get("out") ?? "export");
1470
1640
  files.forEach((x) => out(`${x.file} ${x.width}x${x.height}`));