@dloizides/logo-kit 0.1.3 → 0.3.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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+
5
+ - Intro recipe `grow-settle` (Moon Cube option "Settle overshoot"): the base floods, the parts grow from circles, then the whole mark swells 4% and settles back; ends at 1180 ms.
6
+ - Wordmark reveal recipes `letter-stagger`, `slide-from-mark`, `typewriter`, `mask-wipe`, `tracking-settle` (`wordmarkReveal`): CSS for letters classed `<prefix>-l<i>`, word width from the letter advances, a configurable start offset; reduced motion shows the name at once. `brand.json` `motion.wordmark` takes a recipe name or `{ recipe, startMs }`.
7
+ - Idle recipes `rim-glint`, `faces-part`, `breath`, `orbit-spark` (`idleRecipe`), each at most 600 ms (`IDLE_CAP_MS`), played while a trigger class is on; `brand.json` `motion.idle` names one. Unknown wordmark or idle recipes are reported like intro and micro ones.
8
+ - Browser-safe subpath `@dloizides/logo-kit/runtime` (no fs, no resvg): `startIdle(el, { minMs, maxMs })` adds the idle class every 8-15 s by default, skips a run while the tab is hidden, never runs under prefers-reduced-motion, and returns `stop()`.
9
+
10
+ ## 0.2.0
11
+
12
+ - 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`.
13
+ - `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.
14
+ - New intro presets `fly-in`, `spin-assemble`, `drop-bounce`, `flip`, `slam-shake` (`BOLD_PRESETS`), each default within 1200 ms.
15
+ - `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.
16
+ - `check`, `export` and `generate` exit 1 and name an unknown recipe or a `motion.roles` layer the mark does not have.
17
+
3
18
  ## 0.1.2
4
19
 
5
20
  - 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,178 @@ 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/IdleRecipe.ts
515
+ var IDLE_RECIPES = ["rim-glint" /* RimGlint */, "faces-part" /* FacesPart */, "breath" /* Breath */, "orbit-spark" /* OrbitSpark */];
516
+
517
+ // src/motion/timeline.ts
518
+ function targetsOf(beat, layerNames) {
519
+ if (!beat.layers) {
520
+ return [...layerNames];
521
+ }
522
+ return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
523
+ }
524
+ function schedule(beat, layerNames) {
525
+ return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
526
+ }
527
+ function totalMs(beats, layerNames) {
528
+ return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
529
+ }
530
+ function fitBeat(beat, n, capMs) {
531
+ const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
532
+ const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
533
+ return { ...beat, stepMs: step2 };
534
+ }
535
+ function morphClashes(beats, layerNames) {
536
+ const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
537
+ const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
538
+ return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
539
+ }
540
+ function validateMotion(config, layerNames) {
541
+ const introMs = totalMs(config.intro, layerNames);
542
+ const microMs = totalMs(config.micro, layerNames);
543
+ const errors = [
544
+ ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
545
+ ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
546
+ ...config.recipeErrors ?? [],
547
+ ...morphClashes(config.intro, layerNames)
548
+ ];
549
+ const warnings = [];
550
+ if (introMs > INTRO_CAP_MS) {
551
+ const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
552
+ if (config.allowLongIntro !== void 0) {
553
+ warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
554
+ } else {
555
+ errors.push(message);
556
+ }
557
+ }
558
+ if (microMs > MICRO_CAP_MS) {
559
+ errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
560
+ }
561
+ return { introMs, microMs, errors, warnings };
562
+ }
563
+
564
+ // src/motion/recipes.ts
565
+ var REFERENCE_SIZE = 64;
566
+ var SETTLE_EASE = "cubic-bezier(0.23,1,0.32,1)";
567
+ var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
568
+ var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
569
+ var INTROS = {
570
+ ["rim-then-ink" /* RimThenInk */]: (ctx, k) => [
571
+ { preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 500, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE },
572
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 500, delayMs: 200, easing: EASE_IN_FIRST },
573
+ fit({ preset: "flood" /* Flood */, layers: ctx.roles.parts, durationMs: 400, delayMs: 600, stepMs: 100, easing: EASE })
574
+ ],
575
+ ["phase-wipe" /* PhaseWipe */]: (ctx, k) => [
576
+ { preset: "wipe" /* Wipe */, layers: ctx.roles.base, durationMs: 600, easing: EASE_IN_FIRST },
577
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 400, delayMs: 500, stepMs: 120, distance: 4 * k, easing: EASE })
578
+ ],
579
+ ["faces-settle" /* FacesSettle */]: (ctx, k) => [
580
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
581
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 500, delayMs: 300, stepMs: 150, distance: 6 * k, easing: EASE })
582
+ ],
583
+ ["turn-into-place" /* TurnIntoPlace */]: (ctx) => [fit({ preset: "orbit" /* Orbit */, layers: all(ctx), durationMs: 800, stepMs: 100, easing: EASE })],
584
+ ["grow-from-circles" /* GrowFromCircles */]: (ctx) => [
585
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
586
+ { 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 }
587
+ ],
588
+ ["fly-in" /* FlyIn */]: (ctx) => [fit({ preset: "fly-in" /* FlyIn */, layers: all(ctx), durationMs: 700, stepMs: 100 })],
589
+ ["spin-assemble" /* SpinAssemble */]: (ctx) => [
590
+ { preset: "scale-pop" /* ScalePop */, layers: ctx.roles.base, durationMs: 400 },
591
+ fit({ preset: "spin-assemble" /* SpinAssemble */, layers: ctx.roles.parts, durationMs: 700, delayMs: 200, stepMs: 100 })
592
+ ],
593
+ ["drop-bounce" /* DropBounce */]: (ctx) => [fit({ preset: "drop-bounce" /* DropBounce */, layers: all(ctx), durationMs: 800, stepMs: 100 })],
594
+ ["flip-faces" /* FlipFaces */]: (ctx) => [
595
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
596
+ fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
597
+ ],
598
+ ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }],
599
+ ["grow-settle" /* GrowSettle */]: (ctx) => [
600
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 360, easing: EASE_IN_FIRST },
601
+ { preset: "morph-from-circle" /* MorphFromCircle */, layers: ctx.roles.parts, durationMs: 700, delayMs: 240, stops: [0, 40, 100], fadeIn: ctx.roles.parts, easing: EASE_IN_FIRST, settleEasing: SETTLE_EASE },
602
+ { preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 260, delayMs: 920, scale: 1.04, easing: SETTLE_EASE }
603
+ ]
604
+ };
605
+ var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
606
+ var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
607
+ var MICROS = {
608
+ ["faces-part" /* FacesPart */]: (ctx, k) => [spread(ctx, k)],
609
+ ["breath" /* Breath */]: () => [{ preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 300, scale: 1.04, easing: EASE }],
610
+ ["rim-glint" /* RimGlint */]: (ctx, k) => [glint(ctx, k)],
611
+ ["part-and-glint" /* PartAndGlint */]: (ctx, k) => [spread(ctx, k), glint(ctx, k)]
612
+ };
613
+ var run = (table, name, ctx) => {
614
+ const recipe = table[name];
615
+ return recipe ? recipe(ctx, ctx.size / REFERENCE_SIZE) : null;
616
+ };
617
+ function introRecipe(name, ctx) {
618
+ return run(INTROS, name, ctx);
619
+ }
620
+ function microRecipe(name, ctx) {
621
+ return run(MICROS, name, ctx);
622
+ }
623
+
624
+ // src/motion/WordmarkRecipe.ts
625
+ var WORDMARK_RECIPES = [
626
+ "letter-stagger" /* LetterStagger */,
627
+ "slide-from-mark" /* SlideFromMark */,
628
+ "typewriter" /* Typewriter */,
629
+ "mask-wipe" /* MaskWipe */,
630
+ "tracking-settle" /* TrackingSettle */
631
+ ];
632
+
633
+ // src/motion/resolveMotion.ts
634
+ var KINDS = {
635
+ intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
636
+ micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
637
+ };
638
+ function resolve(kind, value, ctx) {
639
+ const { recipe, fallback } = KINDS[kind];
640
+ if (typeof value !== "string") {
641
+ return { beats: value ?? fallback };
642
+ }
643
+ const beats = recipe(value, ctx);
644
+ return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
645
+ }
646
+ function toWordmark(raw) {
647
+ if (raw === void 0) {
648
+ return void 0;
649
+ }
650
+ return typeof raw === "string" ? { recipe: raw, startMs: 0 } : { recipe: raw.recipe, startMs: raw.startMs ?? 0 };
651
+ }
652
+ var known = (list, kind, name) => name === void 0 || list.includes(name) ? [] : [`unknown ${kind} recipe "${name}"`];
653
+ function resolveMotion(raw, layerNames, size) {
654
+ const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
655
+ const ctx = { roles, size };
656
+ const intro = resolve("intro", raw?.intro, ctx);
657
+ const micro = resolve("micro", raw?.micro, ctx);
658
+ const wordmark = toWordmark(raw?.wordmark);
659
+ const errors = [
660
+ ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
661
+ ...[intro.error, micro.error].filter((e) => e !== void 0),
662
+ ...known(WORDMARK_RECIPES, "wordmark", wordmark?.recipe),
663
+ ...known(IDLE_RECIPES, "idle", raw?.idle)
664
+ ];
665
+ return {
666
+ intro: intro.beats,
667
+ micro: micro.beats,
668
+ ...wordmark !== void 0 ? { wordmark } : {},
669
+ ...raw?.idle !== void 0 ? { idle: { recipe: raw.idle } } : {},
670
+ ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
671
+ ...errors.length > 0 ? { recipeErrors: errors } : {}
672
+ };
673
+ }
495
674
  function presetOf(id) {
496
675
  const preset = PRESETS[id];
497
676
  if (!preset) {
@@ -535,15 +714,16 @@ function toPalette(raw, name) {
535
714
  function parseBrand(raw, baseDir) {
536
715
  const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
537
716
  const small = raw.smallMark;
717
+ const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
538
718
  return {
539
719
  icons: { ...DEFAULT_ICONS, ...raw.icons },
540
720
  ...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
541
721
  name: raw.name,
542
722
  slug: raw.slug,
543
723
  wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
544
- mark: { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) },
724
+ mark,
545
725
  palette: toPalette(raw.palette, raw.slug),
546
- motion: { ...DEFAULT_MOTION_CONFIG, ...raw.motion },
726
+ motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
547
727
  generate: raw.generate ?? DEFAULT_GENERATE,
548
728
  tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "mooncube",
549
729
  baseDir
@@ -767,6 +947,61 @@ function centroid(pts) {
767
947
  return { x: pts.reduce((s, p) => s + p.x, 0) / n, y: pts.reduce((s, p) => s + p.y, 0) / n };
768
948
  }
769
949
 
950
+ // src/motion/boldPresets.ts
951
+ var fillBox = "transform-box:fill-box;transform-origin:center";
952
+ var px = (n) => `${n.toFixed(2)}px`;
953
+ var frames = (stops) => stops.map(([at, body]) => `${at}%{${body}}`).join("");
954
+ function outward(ctx) {
955
+ const pts = ctx.layer ? flattenPath(ctx.layer.d).flat() : [];
956
+ const c = pts.length > 0 ? centroid(pts) : ctx.markCentre;
957
+ const dx = c.x - ctx.markCentre.x;
958
+ const dy = c.y - ctx.markCentre.y;
959
+ const len = Math.hypot(dx, dy);
960
+ return len > 0 ? { x: dx / len, y: dy / len } : { x: -1, y: 0 };
961
+ }
962
+ function flyIn(beat, ctx) {
963
+ const u = outward(ctx);
964
+ const d = beat.distance ?? ctx.markSize * 0.5;
965
+ const at = (k) => `transform:translate(${px(u.x * d * k)},${px(u.y * d * k)})`;
966
+ 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)}`]]);
967
+ return { keyframes, timing: beat.easing ?? EASE };
968
+ }
969
+ function spinAssemble(beat) {
970
+ 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)"]]);
971
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
972
+ }
973
+ function dropBounce(beat, ctx) {
974
+ const h = beat.distance ?? ctx.markSize * 0.6;
975
+ const y = (k) => `transform:translateY(${px(-h * k)})`;
976
+ 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)}`]]);
977
+ return { keyframes, timing: beat.easing ?? "ease-in-out" };
978
+ }
979
+ function flip(beat) {
980
+ 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)"]]);
981
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
982
+ }
983
+ function slamShake(beat, ctx) {
984
+ const s = beat.distance ?? ctx.markSize * 0.04;
985
+ const at = (k, scale) => `transform:translate(${px(s * k)},0px) scale(${scale})`;
986
+ const keyframes = frames([
987
+ [0, `opacity:0;${at(0, beat.scale ?? 2.4)}`],
988
+ [40, `opacity:1;${at(0, 0.94)}`],
989
+ [50, `opacity:1;${at(-1, 1)}`],
990
+ [62, `opacity:1;${at(1, 1)}`],
991
+ [74, `opacity:1;${at(-0.6, 1)}`],
992
+ [86, `opacity:1;${at(0.3, 1)}`],
993
+ [100, `opacity:1;${at(0, 1)}`]
994
+ ]);
995
+ return { keyframes, timing: beat.easing ?? "cubic-bezier(0.5,0,0.75,0)", extra: fillBox };
996
+ }
997
+ var BOLD_PRESET_FRAMES = {
998
+ ["fly-in" /* FlyIn */]: flyIn,
999
+ ["spin-assemble" /* SpinAssemble */]: spinAssemble,
1000
+ ["drop-bounce" /* DropBounce */]: dropBounce,
1001
+ ["flip" /* Flip */]: flip,
1002
+ ["slam-shake" /* SlamShake */]: slamShake
1003
+ };
1004
+
770
1005
  // src/motion/morph.ts
771
1006
  var POINTS = 96;
772
1007
  function startAtTop(poly, c) {
@@ -800,7 +1035,7 @@ function morphPair(d) {
800
1035
  }
801
1036
 
802
1037
  // src/motion/presets.ts
803
- var fillBox = "transform-box:fill-box;transform-origin:center";
1038
+ var fillBox2 = "transform-box:fill-box;transform-origin:center";
804
1039
  function morphFrames(beat, ctx) {
805
1040
  const layer = ctx.layer;
806
1041
  if (!layer) {
@@ -832,7 +1067,7 @@ var PRESETS2 = {
832
1067
  ["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
1068
  ["flood" /* Flood */]: (b) => ({ keyframes: "0%{fill-opacity:0}100%{fill-opacity:1}", timing: b.easing ?? EASE }),
834
1069
  ["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 }),
1070
+ ["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
1071
  ["orbit" /* Orbit */]: (b, ctx) => ({
837
1072
  keyframes: "0%{opacity:0;transform:rotate(-90deg)}100%{opacity:1;transform:rotate(0deg)}",
838
1073
  timing: b.easing ?? EASE,
@@ -841,8 +1076,9 @@ var PRESETS2 = {
841
1076
  ["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
1077
  ["morph-from-circle" /* MorphFromCircle */]: (b, ctx) => ({ keyframes: morphFrames(b, ctx), timing: "linear", supportsD: true }),
843
1078
  ["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" })
1079
+ ["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 }),
1080
+ ["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" }),
1081
+ ...BOLD_PRESET_FRAMES
846
1082
  };
847
1083
  function presetFrames(beat, ctx) {
848
1084
  const fn = PRESETS2[beat.preset];
@@ -852,52 +1088,6 @@ function presetFrames(beat, ctx) {
852
1088
  return fn(beat, ctx);
853
1089
  }
854
1090
 
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
1091
  // src/motion/motionCss.ts
902
1092
  var REDUCED_MOTION = "@media (prefers-reduced-motion:reduce){*{animation:none!important}}";
903
1093
  var sweepClass = (index, hover) => `${hover ? "lkms" : "lks"}${index}`;
@@ -926,28 +1116,28 @@ function render(rules, keyframes) {
926
1116
  const morph = keyframes.filter((k) => k.supportsD).map((k) => k.body).join("");
927
1117
  const decls = (r) => [...r.extras, "animation:".concat(r.animations.join(","))].join(";");
928
1118
  const css = (list) => list.map((r) => `${r.selector}{${decls(r)}}`).join("");
929
- const all = [...rules.values()];
930
- const supports = all.filter((r) => r.supportsD);
1119
+ const all2 = [...rules.values()];
1120
+ const supports = all2.filter((r) => r.supportsD);
931
1121
  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}`;
1122
+ return `${plain}${css(all2.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
933
1123
  }
934
1124
  function addSlot(ctx, beat, b, slot) {
935
1125
  const sweep = beat.preset === "sweep" /* Sweep */;
936
1126
  const index = ctx.names.indexOf(slot.target);
937
- const frames = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre });
1127
+ const frames2 = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre, markSize: ctx.markSize });
938
1128
  const suffix = slot.target === MARK_TARGET ? "m" : String(index);
939
1129
  const name = `lk${ctx.hover ? "m" : "i"}${b}-${suffix}`;
940
1130
  const selector = selectorOf(slot.target, index, ctx.hover, sweep);
941
1131
  const rule = ctx.rules.get(selector) ?? { selector, animations: [], extras: [], supportsD: false };
942
1132
  const delay = slot.delayMs > 0 ? ` ${slot.delayMs}ms` : "";
943
1133
  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);
1134
+ rule.animations.push(`${name} ${slot.durationMs}ms ${frames2.timing}${delay} 1${fill}`);
1135
+ if (frames2.extra !== void 0 && !rule.extras.includes(frames2.extra)) {
1136
+ rule.extras.push(frames2.extra);
947
1137
  }
948
- rule.supportsD = rule.supportsD || frames.supportsD === true;
1138
+ rule.supportsD = rule.supportsD || frames2.supportsD === true;
949
1139
  ctx.rules.set(selector, rule);
950
- ctx.keyframes.push({ body: `@keyframes ${name}{${frames.keyframes}}`, supportsD: frames.supportsD === true });
1140
+ ctx.keyframes.push({ body: `@keyframes ${name}{${frames2.keyframes}}`, supportsD: frames2.supportsD === true });
951
1141
  if (beat.preset === "draw" /* Draw */) {
952
1142
  ctx.drawLayers.add(slot.target);
953
1143
  }
@@ -962,6 +1152,7 @@ function motionCss(mark, beats, palette, mode, hover) {
962
1152
  mark,
963
1153
  names: mark.layers.map((l) => l.name),
964
1154
  markCentre: { x: vb.x + vb.w / 2, y: vb.y + vb.h / 2 },
1155
+ markSize: markSizeOf(mark),
965
1156
  colour: (role) => colours[role ?? "text"] ?? "#ffffff",
966
1157
  hover,
967
1158
  rules: /* @__PURE__ */ new Map(),
@@ -1450,6 +1641,10 @@ function generate(file, f, out) {
1450
1641
  out(`generated ${count}, passed ${report.passed.length}, dropped ${report.dropped.length} -> ${dir}`);
1451
1642
  return 0;
1452
1643
  }
1644
+ function motionRefusal(file) {
1645
+ const errors = loadBrand(file).motion.recipeErrors ?? [];
1646
+ return errors.length > 0 ? `motion: ${errors.join("; ")}` : null;
1647
+ }
1453
1648
  function check(file, out) {
1454
1649
  const brand = loadBrand(file);
1455
1650
  const result = runChecks(brand.mark, brand.palette);
@@ -1465,6 +1660,11 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1465
1660
  out(USAGE);
1466
1661
  return 2;
1467
1662
  }
1663
+ const refusal = cmd === "export" || cmd === "generate" ? motionRefusal(file) : null;
1664
+ if (refusal !== null) {
1665
+ out(refusal);
1666
+ return 1;
1667
+ }
1468
1668
  if (cmd === "export") {
1469
1669
  const files = exportBrand(loadBrand(file), f.get("out") ?? "export");
1470
1670
  files.forEach((x) => out(`${x.file} ${x.width}x${x.height}`));