@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/dist/index.d.ts CHANGED
@@ -8,8 +8,14 @@ declare const enum MotionPreset {
8
8
  MorphFromCircle = "morph-from-circle",
9
9
  Sweep = "sweep",
10
10
  Pulse = "pulse",
11
- Spread = "spread"
12
- }
11
+ Spread = "spread",
12
+ FlyIn = "fly-in",
13
+ SpinAssemble = "spin-assemble",
14
+ DropBounce = "drop-bounce",
15
+ Flip = "flip",
16
+ SlamShake = "slam-shake"
17
+ }
18
+ declare const BOLD_PRESETS: readonly MotionPreset[];
13
19
  declare const INTRO_PRESETS: readonly MotionPreset[];
14
20
  declare const MICRO_PRESETS: readonly MotionPreset[];
15
21
 
@@ -65,6 +71,7 @@ interface MotionConfig {
65
71
  intro: MotionBeat[];
66
72
  micro: MotionBeat[];
67
73
  allowLongIntro?: string;
74
+ recipeErrors?: string[];
68
75
  }
69
76
  interface GenerateConfig {
70
77
  seed: number;
@@ -153,6 +160,28 @@ interface MarkSvgOptions {
153
160
  /** Returns a standalone SVG of the mark in one mode, with optional motion style and overlay. */
154
161
  declare function markSvg(mark: Mark, palette: Palette, mode: Mode, opts: MarkSvgOptions): string;
155
162
 
163
+ interface MotionRoles {
164
+ base: string[];
165
+ parts: string[];
166
+ }
167
+ interface RecipeContext {
168
+ roles: MotionRoles;
169
+ size: number;
170
+ }
171
+ /** Returns the intro beats of a named recipe on the brand's layer roles, or null for an unknown name. */
172
+ declare function introRecipe(name: string, ctx: RecipeContext): MotionBeat[] | null;
173
+ /** Returns the hover beats of a named recipe on the brand's layer roles, or null for an unknown name. */
174
+ declare function microRecipe(name: string, ctx: RecipeContext): MotionBeat[] | null;
175
+
176
+ interface RawMotion {
177
+ intro?: MotionBeat[] | string;
178
+ micro?: MotionBeat[] | string;
179
+ roles?: Partial<MotionRoles>;
180
+ allowLongIntro?: string;
181
+ }
182
+ /** Returns the motion config with recipe names turned into beats on the brand's layer roles. */
183
+ declare function resolveMotion(raw: RawMotion | undefined, layerNames: readonly string[], size: number): MotionConfig;
184
+
156
185
  interface RawLayer {
157
186
  name: string;
158
187
  d: string;
@@ -178,7 +207,7 @@ interface RawBrand {
178
207
  dark: Record<string, string>;
179
208
  mono?: string;
180
209
  };
181
- motion?: Partial<MotionConfig>;
210
+ motion?: RawMotion;
182
211
  generate?: {
183
212
  seed: number;
184
213
  count: number;
@@ -258,6 +287,8 @@ declare const INTRO_CAP_MS = 1200;
258
287
  declare const MICRO_CAP_MS = 300;
259
288
  /** Default beat for each preset, timed so a four-layer mark stays inside the intro and micro caps. */
260
289
  declare const PRESET_DEFAULTS: Readonly<Partial<Record<MotionPreset, MotionBeat>>>;
290
+ /** Default hover beat for each micro preset, timed inside the 300 ms micro cap. */
291
+ declare const MICRO_DEFAULTS: Readonly<Partial<Record<MotionPreset, MotionBeat>>>;
261
292
 
262
293
  interface Slot {
263
294
  target: string;
@@ -279,6 +310,28 @@ interface MotionReport {
279
310
  /** Checks a motion config: known presets, intro <= 1200 ms (or a named reason), micro <= 300 ms, no morph clash. */
280
311
  declare function validateMotion(config: MotionConfig, layerNames: readonly string[]): MotionReport;
281
312
 
313
+ declare const enum IntroRecipe {
314
+ RimThenInk = "rim-then-ink",
315
+ PhaseWipe = "phase-wipe",
316
+ FacesSettle = "faces-settle",
317
+ TurnIntoPlace = "turn-into-place",
318
+ GrowFromCircles = "grow-from-circles",
319
+ FlyIn = "fly-in",
320
+ SpinAssemble = "spin-assemble",
321
+ DropBounce = "drop-bounce",
322
+ FlipFaces = "flip-faces",
323
+ SlamShake = "slam-shake"
324
+ }
325
+ declare const INTRO_RECIPES: readonly IntroRecipe[];
326
+
327
+ declare const enum MicroRecipe {
328
+ FacesPart = "faces-part",
329
+ Breath = "breath",
330
+ RimGlint = "rim-glint",
331
+ PartAndGlint = "part-and-glint"
332
+ }
333
+ declare const MICRO_RECIPES: readonly MicroRecipe[];
334
+
282
335
  interface MotionSvgOptions {
283
336
  label: string;
284
337
  size?: number;
@@ -361,4 +414,4 @@ type Out = (line: string) => void;
361
414
  /** Runs the logo-kit command line and returns its exit code. */
362
415
  declare function runCli(args: readonly string[], out?: Out): number;
363
416
 
364
- export { type AnimationTiming, type Bitmap, type Brand, CVD_KINDS, type CheckResult, type ChecksReport, CvdKind, type ExportedFile, INTRO_CAP_MS, INTRO_PRESETS, LOOKALIKE_THRESHOLD, type LayerPaint, MICRO_CAP_MS, MICRO_PRESETS, MODES, type Mark, type MarkLayer, Mode, type MotionBeat, type MotionConfig, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, type PaintItem, type Palette, type PickSpec, type Pt, SYMBOLS, type TimingMap, type Variant, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introSvg, loadBrand, markSvg, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
417
+ export { type AnimationTiming, BOLD_PRESETS, type Bitmap, type Brand, CVD_KINDS, type CheckResult, type ChecksReport, CvdKind, type ExportedFile, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IntroRecipe, LOOKALIKE_THRESHOLD, type LayerPaint, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, type Mark, type MarkLayer, MicroRecipe, Mode, type MotionBeat, type MotionConfig, MotionPreset, type MotionRoles, PRESET_DEFAULTS, PRIMITIVES, type PaintItem, type Palette, type PickSpec, type Pt, type RawMotion, type RecipeContext, SYMBOLS, type TimingMap, type Variant, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
package/dist/index.js CHANGED
@@ -378,6 +378,10 @@ function markSvg(mark, palette, mode, opts) {
378
378
  const style = opts.style !== void 0 ? `<style>${opts.style}</style>` : "";
379
379
  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>`;
380
380
  }
381
+ function markSizeOf(mark) {
382
+ const vb = viewBoxOf(mark);
383
+ return Math.max(vb.w, vb.h);
384
+ }
381
385
  function viewBoxOf(mark) {
382
386
  const [x = 0, y = 0, w = 1, h = 1] = mark.viewBox.trim().split(/[\s,]+/).map(Number);
383
387
  return { x, y, w, h };
@@ -398,8 +402,20 @@ var MotionPreset = /* @__PURE__ */ ((MotionPreset2) => {
398
402
  MotionPreset2["Sweep"] = "sweep";
399
403
  MotionPreset2["Pulse"] = "pulse";
400
404
  MotionPreset2["Spread"] = "spread";
405
+ MotionPreset2["FlyIn"] = "fly-in";
406
+ MotionPreset2["SpinAssemble"] = "spin-assemble";
407
+ MotionPreset2["DropBounce"] = "drop-bounce";
408
+ MotionPreset2["Flip"] = "flip";
409
+ MotionPreset2["SlamShake"] = "slam-shake";
401
410
  return MotionPreset2;
402
411
  })(MotionPreset || {});
412
+ var BOLD_PRESETS = [
413
+ "fly-in" /* FlyIn */,
414
+ "spin-assemble" /* SpinAssemble */,
415
+ "drop-bounce" /* DropBounce */,
416
+ "flip" /* Flip */,
417
+ "slam-shake" /* SlamShake */
418
+ ];
403
419
  var INTRO_PRESETS = [
404
420
  "draw" /* Draw */,
405
421
  "flood" /* Flood */,
@@ -409,9 +425,10 @@ var INTRO_PRESETS = [
409
425
  "wipe" /* Wipe */,
410
426
  "morph-from-circle" /* MorphFromCircle */,
411
427
  "sweep" /* Sweep */,
412
- "pulse" /* Pulse */
428
+ "pulse" /* Pulse */,
429
+ ...BOLD_PRESETS
413
430
  ];
414
- var MICRO_PRESETS = ["spread" /* Spread */];
431
+ var MICRO_PRESETS = ["spread" /* Spread */, "pulse" /* Pulse */, "sweep" /* Sweep */];
415
432
 
416
433
  // src/motion/defaults.ts
417
434
  var INTRO_CAP_MS = 1200;
@@ -419,6 +436,7 @@ var MICRO_CAP_MS = 300;
419
436
  var EASE = "cubic-bezier(0.2,0,0,1)";
420
437
  var EASE_IN_FIRST = "cubic-bezier(0,0,0,1)";
421
438
  var MARK_TARGET = "@mark";
439
+ var SPREAD_BEAT = { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 };
422
440
  var PRESET_DEFAULTS = {
423
441
  ["draw" /* Draw */]: { preset: "draw" /* Draw */, durationMs: 700, stepMs: 120 },
424
442
  ["flood" /* Flood */]: { preset: "flood" /* Flood */, durationMs: 500, delayMs: 300, stepMs: 80 },
@@ -429,12 +447,190 @@ var PRESET_DEFAULTS = {
429
447
  ["morph-from-circle" /* MorphFromCircle */]: { preset: "morph-from-circle" /* MorphFromCircle */, durationMs: 1200, stops: [0, 40, 100] },
430
448
  ["sweep" /* Sweep */]: { preset: "sweep" /* Sweep */, durationMs: 600, delayMs: 400, stepMs: 60, share: 0.12, width: 2 },
431
449
  ["pulse" /* Pulse */]: { preset: "pulse" /* Pulse */, durationMs: 400, delayMs: 700, layers: [MARK_TARGET], scale: 1.07 },
432
- ["spread" /* Spread */]: { preset: "spread" /* Spread */, durationMs: 300, distance: 1.6 }
450
+ ["spread" /* Spread */]: SPREAD_BEAT,
451
+ ["fly-in" /* FlyIn */]: { preset: "fly-in" /* FlyIn */, durationMs: 700, stepMs: 120 },
452
+ ["spin-assemble" /* SpinAssemble */]: { preset: "spin-assemble" /* SpinAssemble */, durationMs: 800, stepMs: 100 },
453
+ ["drop-bounce" /* DropBounce */]: { preset: "drop-bounce" /* DropBounce */, durationMs: 800, stepMs: 100 },
454
+ ["flip" /* Flip */]: { preset: "flip" /* Flip */, durationMs: 700, stepMs: 120 },
455
+ ["slam-shake" /* SlamShake */]: { preset: "slam-shake" /* SlamShake */, durationMs: 800, layers: [MARK_TARGET] }
456
+ };
457
+ var MICRO_DEFAULTS = {
458
+ ["spread" /* Spread */]: SPREAD_BEAT,
459
+ ["pulse" /* Pulse */]: { preset: "pulse" /* Pulse */, durationMs: 300, layers: [MARK_TARGET], scale: 1.04 },
460
+ ["sweep" /* Sweep */]: { preset: "sweep" /* Sweep */, durationMs: 300, share: 0.2, width: 1.5, colour: "text" }
433
461
  };
434
462
  var DEFAULT_MOTION_CONFIG = {
435
463
  intro: [{ preset: "stagger-rise" /* StaggerRise */, durationMs: 600, stepMs: 150, distance: 4 }],
436
464
  micro: [{ preset: "spread" /* Spread */, durationMs: 300, distance: 1.6, easing: EASE }]
437
465
  };
466
+
467
+ // src/motion/IntroRecipe.ts
468
+ var IntroRecipe = /* @__PURE__ */ ((IntroRecipe2) => {
469
+ IntroRecipe2["RimThenInk"] = "rim-then-ink";
470
+ IntroRecipe2["PhaseWipe"] = "phase-wipe";
471
+ IntroRecipe2["FacesSettle"] = "faces-settle";
472
+ IntroRecipe2["TurnIntoPlace"] = "turn-into-place";
473
+ IntroRecipe2["GrowFromCircles"] = "grow-from-circles";
474
+ IntroRecipe2["FlyIn"] = "fly-in";
475
+ IntroRecipe2["SpinAssemble"] = "spin-assemble";
476
+ IntroRecipe2["DropBounce"] = "drop-bounce";
477
+ IntroRecipe2["FlipFaces"] = "flip-faces";
478
+ IntroRecipe2["SlamShake"] = "slam-shake";
479
+ return IntroRecipe2;
480
+ })(IntroRecipe || {});
481
+ var INTRO_RECIPES = [
482
+ "rim-then-ink" /* RimThenInk */,
483
+ "phase-wipe" /* PhaseWipe */,
484
+ "faces-settle" /* FacesSettle */,
485
+ "turn-into-place" /* TurnIntoPlace */,
486
+ "grow-from-circles" /* GrowFromCircles */,
487
+ "fly-in" /* FlyIn */,
488
+ "spin-assemble" /* SpinAssemble */,
489
+ "drop-bounce" /* DropBounce */,
490
+ "flip-faces" /* FlipFaces */,
491
+ "slam-shake" /* SlamShake */
492
+ ];
493
+
494
+ // src/motion/MicroRecipe.ts
495
+ var MicroRecipe = /* @__PURE__ */ ((MicroRecipe2) => {
496
+ MicroRecipe2["FacesPart"] = "faces-part";
497
+ MicroRecipe2["Breath"] = "breath";
498
+ MicroRecipe2["RimGlint"] = "rim-glint";
499
+ MicroRecipe2["PartAndGlint"] = "part-and-glint";
500
+ return MicroRecipe2;
501
+ })(MicroRecipe || {});
502
+ var MICRO_RECIPES = ["faces-part" /* FacesPart */, "breath" /* Breath */, "rim-glint" /* RimGlint */, "part-and-glint" /* PartAndGlint */];
503
+
504
+ // src/motion/timeline.ts
505
+ function targetsOf(beat, layerNames) {
506
+ if (!beat.layers) {
507
+ return [...layerNames];
508
+ }
509
+ return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
510
+ }
511
+ function schedule(beat, layerNames) {
512
+ return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
513
+ }
514
+ function totalMs(beats, layerNames) {
515
+ return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
516
+ }
517
+ function fitBeat(beat, n, capMs) {
518
+ const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
519
+ const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
520
+ return { ...beat, stepMs: step2 };
521
+ }
522
+ function morphClashes(beats, layerNames) {
523
+ const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
524
+ const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
525
+ return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
526
+ }
527
+ function validateMotion(config, layerNames) {
528
+ const introMs = totalMs(config.intro, layerNames);
529
+ const microMs = totalMs(config.micro, layerNames);
530
+ const errors = [
531
+ ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
532
+ ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
533
+ ...config.recipeErrors ?? [],
534
+ ...morphClashes(config.intro, layerNames)
535
+ ];
536
+ const warnings = [];
537
+ if (introMs > INTRO_CAP_MS) {
538
+ const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
539
+ if (config.allowLongIntro !== void 0) {
540
+ warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
541
+ } else {
542
+ errors.push(message);
543
+ }
544
+ }
545
+ if (microMs > MICRO_CAP_MS) {
546
+ errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
547
+ }
548
+ return { introMs, microMs, errors, warnings };
549
+ }
550
+
551
+ // src/motion/recipes.ts
552
+ var REFERENCE_SIZE = 64;
553
+ var fit = (beat) => fitBeat(beat, beat.layers?.length ?? 1, INTRO_CAP_MS);
554
+ var all = (ctx) => [...ctx.roles.base, ...ctx.roles.parts];
555
+ var INTROS = {
556
+ ["rim-then-ink" /* RimThenInk */]: (ctx, k) => [
557
+ { preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 500, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE },
558
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 500, delayMs: 200, easing: EASE_IN_FIRST },
559
+ fit({ preset: "flood" /* Flood */, layers: ctx.roles.parts, durationMs: 400, delayMs: 600, stepMs: 100, easing: EASE })
560
+ ],
561
+ ["phase-wipe" /* PhaseWipe */]: (ctx, k) => [
562
+ { preset: "wipe" /* Wipe */, layers: ctx.roles.base, durationMs: 600, easing: EASE_IN_FIRST },
563
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 400, delayMs: 500, stepMs: 120, distance: 4 * k, easing: EASE })
564
+ ],
565
+ ["faces-settle" /* FacesSettle */]: (ctx, k) => [
566
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
567
+ fit({ preset: "stagger-rise" /* StaggerRise */, layers: ctx.roles.parts, durationMs: 500, delayMs: 300, stepMs: 150, distance: 6 * k, easing: EASE })
568
+ ],
569
+ ["turn-into-place" /* TurnIntoPlace */]: (ctx) => [fit({ preset: "orbit" /* Orbit */, layers: all(ctx), durationMs: 800, stepMs: 100, easing: EASE })],
570
+ ["grow-from-circles" /* GrowFromCircles */]: (ctx) => [
571
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
572
+ { 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 }
573
+ ],
574
+ ["fly-in" /* FlyIn */]: (ctx) => [fit({ preset: "fly-in" /* FlyIn */, layers: all(ctx), durationMs: 700, stepMs: 100 })],
575
+ ["spin-assemble" /* SpinAssemble */]: (ctx) => [
576
+ { preset: "scale-pop" /* ScalePop */, layers: ctx.roles.base, durationMs: 400 },
577
+ fit({ preset: "spin-assemble" /* SpinAssemble */, layers: ctx.roles.parts, durationMs: 700, delayMs: 200, stepMs: 100 })
578
+ ],
579
+ ["drop-bounce" /* DropBounce */]: (ctx) => [fit({ preset: "drop-bounce" /* DropBounce */, layers: all(ctx), durationMs: 800, stepMs: 100 })],
580
+ ["flip-faces" /* FlipFaces */]: (ctx) => [
581
+ { preset: "flood" /* Flood */, layers: ctx.roles.base, durationMs: 400, easing: EASE_IN_FIRST },
582
+ fit({ preset: "flip" /* Flip */, layers: ctx.roles.parts, durationMs: 700, delayMs: 250, stepMs: 100 })
583
+ ],
584
+ ["slam-shake" /* SlamShake */]: () => [{ preset: "slam-shake" /* SlamShake */, layers: [MARK_TARGET], durationMs: 800 }]
585
+ };
586
+ var spread = (ctx, k) => ({ preset: "spread" /* Spread */, layers: ctx.roles.parts, durationMs: 300, distance: 1.6 * k, easing: EASE });
587
+ var glint = (ctx, k) => ({ preset: "sweep" /* Sweep */, layers: ctx.roles.base, durationMs: 300, share: 0.2, width: 1.5 * k, colour: "text", easing: EASE });
588
+ var MICROS = {
589
+ ["faces-part" /* FacesPart */]: (ctx, k) => [spread(ctx, k)],
590
+ ["breath" /* Breath */]: () => [{ preset: "pulse" /* Pulse */, layers: [MARK_TARGET], durationMs: 300, scale: 1.04, easing: EASE }],
591
+ ["rim-glint" /* RimGlint */]: (ctx, k) => [glint(ctx, k)],
592
+ ["part-and-glint" /* PartAndGlint */]: (ctx, k) => [spread(ctx, k), glint(ctx, k)]
593
+ };
594
+ var run = (table, name, ctx) => {
595
+ const recipe = table[name];
596
+ return recipe ? recipe(ctx, ctx.size / REFERENCE_SIZE) : null;
597
+ };
598
+ function introRecipe(name, ctx) {
599
+ return run(INTROS, name, ctx);
600
+ }
601
+ function microRecipe(name, ctx) {
602
+ return run(MICROS, name, ctx);
603
+ }
604
+
605
+ // src/motion/resolveMotion.ts
606
+ var KINDS = {
607
+ intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
608
+ micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
609
+ };
610
+ function resolve(kind, value, ctx) {
611
+ const { recipe, fallback } = KINDS[kind];
612
+ if (typeof value !== "string") {
613
+ return { beats: value ?? fallback };
614
+ }
615
+ const beats = recipe(value, ctx);
616
+ return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
617
+ }
618
+ function resolveMotion(raw, layerNames, size) {
619
+ const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
620
+ const ctx = { roles, size };
621
+ const intro = resolve("intro", raw?.intro, ctx);
622
+ const micro = resolve("micro", raw?.micro, ctx);
623
+ const errors = [
624
+ ...[...roles.base, ...roles.parts].filter((n) => !layerNames.includes(n)).map((n) => `motion.roles names unknown layer "${n}"`),
625
+ ...[intro.error, micro.error].filter((e) => e !== void 0)
626
+ ];
627
+ return {
628
+ intro: intro.beats,
629
+ micro: micro.beats,
630
+ ...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
631
+ ...errors.length > 0 ? { recipeErrors: errors } : {}
632
+ };
633
+ }
438
634
  function presetOf(id) {
439
635
  const preset = PRESETS[id];
440
636
  if (!preset) {
@@ -478,15 +674,16 @@ function toPalette(raw, name) {
478
674
  function parseBrand(raw, baseDir) {
479
675
  const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
480
676
  const small = raw.smallMark;
677
+ const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
481
678
  return {
482
679
  icons: { ...DEFAULT_ICONS, ...raw.icons },
483
680
  ...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
484
681
  name: raw.name,
485
682
  slug: raw.slug,
486
683
  wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
487
- mark: { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) },
684
+ mark,
488
685
  palette: toPalette(raw.palette, raw.slug),
489
- motion: { ...DEFAULT_MOTION_CONFIG, ...raw.motion },
686
+ motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
490
687
  generate: raw.generate ?? DEFAULT_GENERATE,
491
688
  tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "mooncube",
492
689
  baseDir
@@ -775,9 +972,9 @@ function normalise(mask, w, h) {
775
972
  for (let gx = 0; gx < GRID; gx++) {
776
973
  let hits = 0;
777
974
  for (let s = 0; s < SAMPLES * SAMPLES; s++) {
778
- const px = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
975
+ const px2 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
779
976
  const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
780
- hits += px >= 0 && py >= 0 && px < w && py < h ? mask[py * w + px] ?? 0 : 0;
977
+ hits += px2 >= 0 && py >= 0 && px2 < w && py < h ? mask[py * w + px2] ?? 0 : 0;
781
978
  }
782
979
  out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
783
980
  }
@@ -938,9 +1135,9 @@ function legibility(mark, size) {
938
1135
  out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
939
1136
  }
940
1137
  mark.layers.forEach((layer, i) => {
941
- const px = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
942
- if (px < (MIN_LAYER_PX[size] ?? 1)) {
943
- out.push(`legible${size}: layer "${layer.name}" is ${px} px, lost at ${size} px`);
1138
+ const px2 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
1139
+ if (px2 < (MIN_LAYER_PX[size] ?? 1)) {
1140
+ out.push(`legible${size}: layer "${layer.name}" is ${px2} px, lost at ${size} px`);
944
1141
  }
945
1142
  });
946
1143
  return out;
@@ -1042,51 +1239,60 @@ function generatorPalette(tokensId) {
1042
1239
  };
1043
1240
  }
1044
1241
 
1045
- // src/motion/timeline.ts
1046
- function targetsOf(beat, layerNames) {
1047
- if (!beat.layers) {
1048
- return [...layerNames];
1049
- }
1050
- return beat.layers.includes(MARK_TARGET) ? [MARK_TARGET] : layerNames.filter((n) => beat.layers?.includes(n));
1051
- }
1052
- function schedule(beat, layerNames) {
1053
- return targetsOf(beat, layerNames).map((target, k) => ({ target, delayMs: (beat.delayMs ?? 0) + k * (beat.stepMs ?? 0), durationMs: beat.durationMs }));
1054
- }
1055
- function totalMs(beats, layerNames) {
1056
- return Math.max(0, ...beats.flatMap((b) => schedule(b, layerNames).map((s) => s.delayMs + s.durationMs)));
1057
- }
1058
- function fitBeat(beat, n, capMs) {
1059
- const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
1060
- const step2 = n > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n - 1)))) : beat.stepMs ?? 0;
1061
- return { ...beat, stepMs: step2 };
1062
- }
1063
- function morphClashes(beats, layerNames) {
1064
- const morph = new Set(beats.filter((b) => b.preset === "morph-from-circle" /* MorphFromCircle */).flatMap((b) => targetsOf(b, layerNames)));
1065
- const other = beats.filter((b) => b.preset !== "morph-from-circle" /* MorphFromCircle */ && b.preset !== "sweep" /* Sweep */).flatMap((b) => targetsOf(b, layerNames));
1066
- return other.filter((t) => morph.has(t)).map((t) => `layer "${t}" has morph-from-circle and another preset`);
1067
- }
1068
- function validateMotion(config, layerNames) {
1069
- const introMs = totalMs(config.intro, layerNames);
1070
- const microMs = totalMs(config.micro, layerNames);
1071
- const errors = [
1072
- ...config.intro.filter((b) => !INTRO_PRESETS.includes(b.preset)).map((b) => `unknown intro preset "${b.preset}"`),
1073
- ...config.micro.filter((b) => !MICRO_PRESETS.includes(b.preset)).map((b) => `unknown micro preset "${b.preset}"`),
1074
- ...morphClashes(config.intro, layerNames)
1075
- ];
1076
- const warnings = [];
1077
- if (introMs > INTRO_CAP_MS) {
1078
- const message = `intro runs ${introMs} ms, cap ${INTRO_CAP_MS} ms`;
1079
- if (config.allowLongIntro !== void 0) {
1080
- warnings.push(`${message} (allowed: ${config.allowLongIntro})`);
1081
- } else {
1082
- errors.push(message);
1083
- }
1084
- }
1085
- if (microMs > MICRO_CAP_MS) {
1086
- errors.push(`micro runs ${microMs} ms, cap ${MICRO_CAP_MS} ms`);
1087
- }
1088
- return { introMs, microMs, errors, warnings };
1089
- }
1242
+ // src/motion/boldPresets.ts
1243
+ var fillBox = "transform-box:fill-box;transform-origin:center";
1244
+ var px = (n) => `${n.toFixed(2)}px`;
1245
+ var frames = (stops) => stops.map(([at, body]) => `${at}%{${body}}`).join("");
1246
+ function outward(ctx) {
1247
+ const pts = ctx.layer ? flattenPath(ctx.layer.d).flat() : [];
1248
+ const c = pts.length > 0 ? centroid(pts) : ctx.markCentre;
1249
+ const dx = c.x - ctx.markCentre.x;
1250
+ const dy = c.y - ctx.markCentre.y;
1251
+ const len = Math.hypot(dx, dy);
1252
+ return len > 0 ? { x: dx / len, y: dy / len } : { x: -1, y: 0 };
1253
+ }
1254
+ function flyIn(beat, ctx) {
1255
+ const u = outward(ctx);
1256
+ const d = beat.distance ?? ctx.markSize * 0.5;
1257
+ const at = (k) => `transform:translate(${px(u.x * d * k)},${px(u.y * d * k)})`;
1258
+ 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)}`]]);
1259
+ return { keyframes, timing: beat.easing ?? EASE };
1260
+ }
1261
+ function spinAssemble(beat) {
1262
+ 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)"]]);
1263
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
1264
+ }
1265
+ function dropBounce(beat, ctx) {
1266
+ const h = beat.distance ?? ctx.markSize * 0.6;
1267
+ const y = (k) => `transform:translateY(${px(-h * k)})`;
1268
+ 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)}`]]);
1269
+ return { keyframes, timing: beat.easing ?? "ease-in-out" };
1270
+ }
1271
+ function flip(beat) {
1272
+ 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)"]]);
1273
+ return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
1274
+ }
1275
+ function slamShake(beat, ctx) {
1276
+ const s = beat.distance ?? ctx.markSize * 0.04;
1277
+ const at = (k, scale) => `transform:translate(${px(s * k)},0px) scale(${scale})`;
1278
+ const keyframes = frames([
1279
+ [0, `opacity:0;${at(0, beat.scale ?? 2.4)}`],
1280
+ [40, `opacity:1;${at(0, 0.94)}`],
1281
+ [50, `opacity:1;${at(-1, 1)}`],
1282
+ [62, `opacity:1;${at(1, 1)}`],
1283
+ [74, `opacity:1;${at(-0.6, 1)}`],
1284
+ [86, `opacity:1;${at(0.3, 1)}`],
1285
+ [100, `opacity:1;${at(0, 1)}`]
1286
+ ]);
1287
+ return { keyframes, timing: beat.easing ?? "cubic-bezier(0.5,0,0.75,0)", extra: fillBox };
1288
+ }
1289
+ var BOLD_PRESET_FRAMES = {
1290
+ ["fly-in" /* FlyIn */]: flyIn,
1291
+ ["spin-assemble" /* SpinAssemble */]: spinAssemble,
1292
+ ["drop-bounce" /* DropBounce */]: dropBounce,
1293
+ ["flip" /* Flip */]: flip,
1294
+ ["slam-shake" /* SlamShake */]: slamShake
1295
+ };
1090
1296
 
1091
1297
  // src/motion/morph.ts
1092
1298
  var POINTS = 96;
@@ -1121,7 +1327,7 @@ function morphPair(d) {
1121
1327
  }
1122
1328
 
1123
1329
  // src/motion/presets.ts
1124
- var fillBox = "transform-box:fill-box;transform-origin:center";
1330
+ var fillBox2 = "transform-box:fill-box;transform-origin:center";
1125
1331
  function morphFrames(beat, ctx) {
1126
1332
  const layer = ctx.layer;
1127
1333
  if (!layer) {
@@ -1153,7 +1359,7 @@ var PRESETS2 = {
1153
1359
  ["draw" /* Draw */]: (b) => ({ keyframes: "0%{stroke-dasharray:1 1;stroke-dashoffset:1}100%{stroke-dasharray:1 1;stroke-dashoffset:0}", timing: b.easing ?? EASE }),
1154
1360
  ["flood" /* Flood */]: (b) => ({ keyframes: "0%{fill-opacity:0}100%{fill-opacity:1}", timing: b.easing ?? EASE }),
1155
1361
  ["stagger-rise" /* StaggerRise */]: (b) => ({ keyframes: `0%{opacity:0;transform:translateY(${b.distance ?? 4}px)}100%{opacity:1;transform:none}`, timing: b.easing ?? EASE }),
1156
- ["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 }),
1362
+ ["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 }),
1157
1363
  ["orbit" /* Orbit */]: (b, ctx) => ({
1158
1364
  keyframes: "0%{opacity:0;transform:rotate(-90deg)}100%{opacity:1;transform:rotate(0deg)}",
1159
1365
  timing: b.easing ?? EASE,
@@ -1162,8 +1368,9 @@ var PRESETS2 = {
1162
1368
  ["wipe" /* Wipe */]: (b) => ({ keyframes: "0%{clip-path:inset(0 100% 0 0)}100%{clip-path:inset(0 0 0 0)}", timing: b.easing ?? EASE }),
1163
1369
  ["morph-from-circle" /* MorphFromCircle */]: (b, ctx) => ({ keyframes: morphFrames(b, ctx), timing: "linear", supportsD: true }),
1164
1370
  ["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" }),
1165
- ["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 }),
1166
- ["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" })
1371
+ ["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 }),
1372
+ ["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" }),
1373
+ ...BOLD_PRESET_FRAMES
1167
1374
  };
1168
1375
  function presetFrames(beat, ctx) {
1169
1376
  const fn = PRESETS2[beat.preset];
@@ -1201,28 +1408,28 @@ function render(rules, keyframes) {
1201
1408
  const morph = keyframes.filter((k) => k.supportsD).map((k) => k.body).join("");
1202
1409
  const decls = (r) => [...r.extras, "animation:".concat(r.animations.join(","))].join(";");
1203
1410
  const css = (list) => list.map((r) => `${r.selector}{${decls(r)}}`).join("");
1204
- const all = [...rules.values()];
1205
- const supports = all.filter((r) => r.supportsD);
1411
+ const all2 = [...rules.values()];
1412
+ const supports = all2.filter((r) => r.supportsD);
1206
1413
  const wrapped = supports.length > 0 ? `@supports (d:path("M0 0")){${morph}${css(supports)}}` : "";
1207
- return `${plain}${css(all.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
1414
+ return `${plain}${css(all2.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
1208
1415
  }
1209
1416
  function addSlot(ctx, beat, b, slot) {
1210
1417
  const sweep = beat.preset === "sweep" /* Sweep */;
1211
1418
  const index = ctx.names.indexOf(slot.target);
1212
- const frames = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre });
1419
+ const frames2 = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre, markSize: ctx.markSize });
1213
1420
  const suffix = slot.target === MARK_TARGET ? "m" : String(index);
1214
1421
  const name = `lk${ctx.hover ? "m" : "i"}${b}-${suffix}`;
1215
1422
  const selector = selectorOf(slot.target, index, ctx.hover, sweep);
1216
1423
  const rule = ctx.rules.get(selector) ?? { selector, animations: [], extras: [], supportsD: false };
1217
1424
  const delay = slot.delayMs > 0 ? ` ${slot.delayMs}ms` : "";
1218
1425
  const fill = ctx.hover ? "" : " backwards";
1219
- rule.animations.push(`${name} ${slot.durationMs}ms ${frames.timing}${delay} 1${fill}`);
1220
- if (frames.extra !== void 0 && !rule.extras.includes(frames.extra)) {
1221
- rule.extras.push(frames.extra);
1426
+ rule.animations.push(`${name} ${slot.durationMs}ms ${frames2.timing}${delay} 1${fill}`);
1427
+ if (frames2.extra !== void 0 && !rule.extras.includes(frames2.extra)) {
1428
+ rule.extras.push(frames2.extra);
1222
1429
  }
1223
- rule.supportsD = rule.supportsD || frames.supportsD === true;
1430
+ rule.supportsD = rule.supportsD || frames2.supportsD === true;
1224
1431
  ctx.rules.set(selector, rule);
1225
- ctx.keyframes.push({ body: `@keyframes ${name}{${frames.keyframes}}`, supportsD: frames.supportsD === true });
1432
+ ctx.keyframes.push({ body: `@keyframes ${name}{${frames2.keyframes}}`, supportsD: frames2.supportsD === true });
1226
1433
  if (beat.preset === "draw" /* Draw */) {
1227
1434
  ctx.drawLayers.add(slot.target);
1228
1435
  }
@@ -1237,6 +1444,7 @@ function motionCss(mark, beats, palette, mode, hover) {
1237
1444
  mark,
1238
1445
  names: mark.layers.map((l) => l.name),
1239
1446
  markCentre: { x: vb.x + vb.w / 2, y: vb.y + vb.h / 2 },
1447
+ markSize: markSizeOf(mark),
1240
1448
  colour: (role) => colours[role ?? "text"] ?? "#ffffff",
1241
1449
  hover,
1242
1450
  rules: /* @__PURE__ */ new Map(),
@@ -1588,6 +1796,10 @@ function generate(file, f, out) {
1588
1796
  out(`generated ${count}, passed ${report.passed.length}, dropped ${report.dropped.length} -> ${dir}`);
1589
1797
  return 0;
1590
1798
  }
1799
+ function motionRefusal(file) {
1800
+ const errors = loadBrand(file).motion.recipeErrors ?? [];
1801
+ return errors.length > 0 ? `motion: ${errors.join("; ")}` : null;
1802
+ }
1591
1803
  function check(file, out) {
1592
1804
  const brand = loadBrand(file);
1593
1805
  const result = runChecks(brand.mark, brand.palette);
@@ -1603,6 +1815,11 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1603
1815
  out(USAGE);
1604
1816
  return 2;
1605
1817
  }
1818
+ const refusal = cmd === "export" || cmd === "generate" ? motionRefusal(file) : null;
1819
+ if (refusal !== null) {
1820
+ out(refusal);
1821
+ return 1;
1822
+ }
1606
1823
  if (cmd === "export") {
1607
1824
  const files = exportBrand(loadBrand(file), f.get("out") ?? "export");
1608
1825
  files.forEach((x) => out(`${x.file} ${x.width}x${x.height}`));
@@ -1625,6 +1842,6 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
1625
1842
  return 2;
1626
1843
  }
1627
1844
 
1628
- export { CVD_KINDS, CvdKind, INTRO_CAP_MS, INTRO_PRESETS, LOOKALIKE_THRESHOLD, MICRO_CAP_MS, MICRO_PRESETS, MODES, Mode, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, SYMBOLS, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introSvg, loadBrand, markSvg, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
1845
+ export { BOLD_PRESETS, CVD_KINDS, CvdKind, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IntroRecipe, LOOKALIKE_THRESHOLD, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, MicroRecipe, Mode, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, SYMBOLS, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion };
1629
1846
  //# sourceMappingURL=index.js.map
1630
1847
  //# sourceMappingURL=index.js.map