@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 +15 -0
- package/dist/cli.js +269 -69
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +121 -4
- package/dist/index.js +481 -82
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +17 -0
- package/dist/runtime.js +48 -0
- package/dist/runtime.js.map +1 -0
- package/package.json +5 -1
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,238 @@ 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 */]:
|
|
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/IdleRecipe.ts
|
|
468
|
+
var IdleRecipe = /* @__PURE__ */ ((IdleRecipe2) => {
|
|
469
|
+
IdleRecipe2["RimGlint"] = "rim-glint";
|
|
470
|
+
IdleRecipe2["FacesPart"] = "faces-part";
|
|
471
|
+
IdleRecipe2["Breath"] = "breath";
|
|
472
|
+
IdleRecipe2["OrbitSpark"] = "orbit-spark";
|
|
473
|
+
return IdleRecipe2;
|
|
474
|
+
})(IdleRecipe || {});
|
|
475
|
+
var IDLE_RECIPES = ["rim-glint" /* RimGlint */, "faces-part" /* FacesPart */, "breath" /* Breath */, "orbit-spark" /* OrbitSpark */];
|
|
476
|
+
var IDLE_CAP_MS = 600;
|
|
477
|
+
|
|
478
|
+
// src/motion/IntroRecipe.ts
|
|
479
|
+
var IntroRecipe = /* @__PURE__ */ ((IntroRecipe2) => {
|
|
480
|
+
IntroRecipe2["RimThenInk"] = "rim-then-ink";
|
|
481
|
+
IntroRecipe2["PhaseWipe"] = "phase-wipe";
|
|
482
|
+
IntroRecipe2["FacesSettle"] = "faces-settle";
|
|
483
|
+
IntroRecipe2["TurnIntoPlace"] = "turn-into-place";
|
|
484
|
+
IntroRecipe2["GrowFromCircles"] = "grow-from-circles";
|
|
485
|
+
IntroRecipe2["FlyIn"] = "fly-in";
|
|
486
|
+
IntroRecipe2["SpinAssemble"] = "spin-assemble";
|
|
487
|
+
IntroRecipe2["DropBounce"] = "drop-bounce";
|
|
488
|
+
IntroRecipe2["FlipFaces"] = "flip-faces";
|
|
489
|
+
IntroRecipe2["SlamShake"] = "slam-shake";
|
|
490
|
+
IntroRecipe2["GrowSettle"] = "grow-settle";
|
|
491
|
+
return IntroRecipe2;
|
|
492
|
+
})(IntroRecipe || {});
|
|
493
|
+
var INTRO_RECIPES = [
|
|
494
|
+
"rim-then-ink" /* RimThenInk */,
|
|
495
|
+
"phase-wipe" /* PhaseWipe */,
|
|
496
|
+
"faces-settle" /* FacesSettle */,
|
|
497
|
+
"turn-into-place" /* TurnIntoPlace */,
|
|
498
|
+
"grow-from-circles" /* GrowFromCircles */,
|
|
499
|
+
"fly-in" /* FlyIn */,
|
|
500
|
+
"spin-assemble" /* SpinAssemble */,
|
|
501
|
+
"drop-bounce" /* DropBounce */,
|
|
502
|
+
"flip-faces" /* FlipFaces */,
|
|
503
|
+
"slam-shake" /* SlamShake */,
|
|
504
|
+
"grow-settle" /* GrowSettle */
|
|
505
|
+
];
|
|
506
|
+
|
|
507
|
+
// src/motion/MicroRecipe.ts
|
|
508
|
+
var MicroRecipe = /* @__PURE__ */ ((MicroRecipe2) => {
|
|
509
|
+
MicroRecipe2["FacesPart"] = "faces-part";
|
|
510
|
+
MicroRecipe2["Breath"] = "breath";
|
|
511
|
+
MicroRecipe2["RimGlint"] = "rim-glint";
|
|
512
|
+
MicroRecipe2["PartAndGlint"] = "part-and-glint";
|
|
513
|
+
return MicroRecipe2;
|
|
514
|
+
})(MicroRecipe || {});
|
|
515
|
+
var MICRO_RECIPES = ["faces-part" /* FacesPart */, "breath" /* Breath */, "rim-glint" /* RimGlint */, "part-and-glint" /* PartAndGlint */];
|
|
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((n2) => beat.layers?.includes(n2));
|
|
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, n2, capMs) {
|
|
531
|
+
const room = capMs - (beat.delayMs ?? 0) - beat.durationMs;
|
|
532
|
+
const step2 = n2 > 1 ? Math.min(beat.stepMs ?? 0, Math.max(0, Math.floor(room / (n2 - 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 WordmarkRecipe = /* @__PURE__ */ ((WordmarkRecipe2) => {
|
|
626
|
+
WordmarkRecipe2["LetterStagger"] = "letter-stagger";
|
|
627
|
+
WordmarkRecipe2["SlideFromMark"] = "slide-from-mark";
|
|
628
|
+
WordmarkRecipe2["Typewriter"] = "typewriter";
|
|
629
|
+
WordmarkRecipe2["MaskWipe"] = "mask-wipe";
|
|
630
|
+
WordmarkRecipe2["TrackingSettle"] = "tracking-settle";
|
|
631
|
+
return WordmarkRecipe2;
|
|
632
|
+
})(WordmarkRecipe || {});
|
|
633
|
+
var WORDMARK_RECIPES = [
|
|
634
|
+
"letter-stagger" /* LetterStagger */,
|
|
635
|
+
"slide-from-mark" /* SlideFromMark */,
|
|
636
|
+
"typewriter" /* Typewriter */,
|
|
637
|
+
"mask-wipe" /* MaskWipe */,
|
|
638
|
+
"tracking-settle" /* TrackingSettle */
|
|
639
|
+
];
|
|
640
|
+
|
|
641
|
+
// src/motion/resolveMotion.ts
|
|
642
|
+
var KINDS = {
|
|
643
|
+
intro: { recipe: introRecipe, fallback: DEFAULT_MOTION_CONFIG.intro },
|
|
644
|
+
micro: { recipe: microRecipe, fallback: DEFAULT_MOTION_CONFIG.micro }
|
|
645
|
+
};
|
|
646
|
+
function resolve(kind, value, ctx) {
|
|
647
|
+
const { recipe, fallback } = KINDS[kind];
|
|
648
|
+
if (typeof value !== "string") {
|
|
649
|
+
return { beats: value ?? fallback };
|
|
650
|
+
}
|
|
651
|
+
const beats = recipe(value, ctx);
|
|
652
|
+
return beats !== null ? { beats } : { beats: [], error: `unknown ${kind} recipe "${value}"` };
|
|
653
|
+
}
|
|
654
|
+
function toWordmark(raw) {
|
|
655
|
+
if (raw === void 0) {
|
|
656
|
+
return void 0;
|
|
657
|
+
}
|
|
658
|
+
return typeof raw === "string" ? { recipe: raw, startMs: 0 } : { recipe: raw.recipe, startMs: raw.startMs ?? 0 };
|
|
659
|
+
}
|
|
660
|
+
var known = (list, kind, name) => name === void 0 || list.includes(name) ? [] : [`unknown ${kind} recipe "${name}"`];
|
|
661
|
+
function resolveMotion(raw, layerNames, size) {
|
|
662
|
+
const roles = { base: raw?.roles?.base ?? layerNames.slice(0, 1), parts: raw?.roles?.parts ?? layerNames.slice(1) };
|
|
663
|
+
const ctx = { roles, size };
|
|
664
|
+
const intro = resolve("intro", raw?.intro, ctx);
|
|
665
|
+
const micro = resolve("micro", raw?.micro, ctx);
|
|
666
|
+
const wordmark = toWordmark(raw?.wordmark);
|
|
667
|
+
const errors = [
|
|
668
|
+
...[...roles.base, ...roles.parts].filter((n2) => !layerNames.includes(n2)).map((n2) => `motion.roles names unknown layer "${n2}"`),
|
|
669
|
+
...[intro.error, micro.error].filter((e) => e !== void 0),
|
|
670
|
+
...known(WORDMARK_RECIPES, "wordmark", wordmark?.recipe),
|
|
671
|
+
...known(IDLE_RECIPES, "idle", raw?.idle)
|
|
672
|
+
];
|
|
673
|
+
return {
|
|
674
|
+
intro: intro.beats,
|
|
675
|
+
micro: micro.beats,
|
|
676
|
+
...wordmark !== void 0 ? { wordmark } : {},
|
|
677
|
+
...raw?.idle !== void 0 ? { idle: { recipe: raw.idle } } : {},
|
|
678
|
+
...raw?.allowLongIntro !== void 0 ? { allowLongIntro: raw.allowLongIntro } : {},
|
|
679
|
+
...errors.length > 0 ? { recipeErrors: errors } : {}
|
|
680
|
+
};
|
|
681
|
+
}
|
|
438
682
|
function presetOf(id) {
|
|
439
683
|
const preset = PRESETS[id];
|
|
440
684
|
if (!preset) {
|
|
@@ -478,15 +722,16 @@ function toPalette(raw, name) {
|
|
|
478
722
|
function parseBrand(raw, baseDir) {
|
|
479
723
|
const firstRef = Object.values(raw.palette.light).find((ref) => !ref.startsWith("#"));
|
|
480
724
|
const small = raw.smallMark;
|
|
725
|
+
const mark = { id: raw.slug, viewBox: raw.mark.viewBox, layers: raw.mark.layers.map(toLayer) };
|
|
481
726
|
return {
|
|
482
727
|
icons: { ...DEFAULT_ICONS, ...raw.icons },
|
|
483
728
|
...small ? { smallMark: { ...small, light: resolveToken(small.light), dark: resolveToken(small.dark) } } : {},
|
|
484
729
|
name: raw.name,
|
|
485
730
|
slug: raw.slug,
|
|
486
731
|
wordmark: raw.wordmark ?? { fontFamily: DEFAULT_FONT },
|
|
487
|
-
mark
|
|
732
|
+
mark,
|
|
488
733
|
palette: toPalette(raw.palette, raw.slug),
|
|
489
|
-
motion:
|
|
734
|
+
motion: resolveMotion(raw.motion, raw.mark.layers.map((l) => l.name), markSizeOf(mark)),
|
|
490
735
|
generate: raw.generate ?? DEFAULT_GENERATE,
|
|
491
736
|
tokens: raw.tokens ?? firstRef?.split(".")[0] ?? "mooncube",
|
|
492
737
|
baseDir
|
|
@@ -523,7 +768,7 @@ function polygonsToD(polys) {
|
|
|
523
768
|
const ring = (poly) => poly.map(point).join("L");
|
|
524
769
|
return polys.map((poly) => `M${ring(poly)}Z`).join("");
|
|
525
770
|
}
|
|
526
|
-
function resample(poly,
|
|
771
|
+
function resample(poly, n2) {
|
|
527
772
|
const first = poly[0] ?? { x: 0, y: 0 };
|
|
528
773
|
const closed = [...poly, first];
|
|
529
774
|
const lengths = closed.slice(1).map((p, k) => Math.hypot(p.x - (closed[k]?.x ?? 0), p.y - (closed[k]?.y ?? 0)));
|
|
@@ -531,8 +776,8 @@ function resample(poly, n) {
|
|
|
531
776
|
const out = [];
|
|
532
777
|
let seg = 0;
|
|
533
778
|
let walked = 0;
|
|
534
|
-
for (let k = 0; k <
|
|
535
|
-
const target = total * k /
|
|
779
|
+
for (let k = 0; k < n2; k++) {
|
|
780
|
+
const target = total * k / n2;
|
|
536
781
|
while (seg < lengths.length - 1 && walked + (lengths[seg] ?? 0) < target) {
|
|
537
782
|
walked += lengths[seg] ?? 0;
|
|
538
783
|
seg++;
|
|
@@ -545,15 +790,15 @@ function resample(poly, n) {
|
|
|
545
790
|
}
|
|
546
791
|
return out;
|
|
547
792
|
}
|
|
548
|
-
function circlePoints(c, r,
|
|
549
|
-
return Array.from({ length:
|
|
550
|
-
const t = -Math.PI / 2 + 2 * Math.PI * k /
|
|
793
|
+
function circlePoints(c, r, n2) {
|
|
794
|
+
return Array.from({ length: n2 }, (_, k) => {
|
|
795
|
+
const t = -Math.PI / 2 + 2 * Math.PI * k / n2;
|
|
551
796
|
return { x: c.x + r * Math.cos(t), y: c.y + r * Math.sin(t) };
|
|
552
797
|
});
|
|
553
798
|
}
|
|
554
799
|
function centroid(pts) {
|
|
555
|
-
const
|
|
556
|
-
return { x: pts.reduce((s, p) => s + p.x, 0) /
|
|
800
|
+
const n2 = Math.max(1, pts.length);
|
|
801
|
+
return { x: pts.reduce((s, p) => s + p.x, 0) / n2, y: pts.reduce((s, p) => s + p.y, 0) / n2 };
|
|
557
802
|
}
|
|
558
803
|
|
|
559
804
|
// src/generate/shapes.ts
|
|
@@ -561,12 +806,12 @@ var CIRCLE_N = 48;
|
|
|
561
806
|
var ORIGIN = { x: 0, y: 0 };
|
|
562
807
|
var SQRT3_2 = Math.sqrt(3) / 2;
|
|
563
808
|
var FACE_SHRINK = 0.9;
|
|
564
|
-
var ngon = (
|
|
809
|
+
var ngon = (n2, r, start = -Math.PI / 2) => Array.from({ length: n2 }, (_, k) => ({ x: r * Math.cos(start + 2 * Math.PI * k / n2), y: r * Math.sin(start + 2 * Math.PI * k / n2) }));
|
|
565
810
|
var shrink = (poly, s) => {
|
|
566
811
|
const c = poly.reduce((a, p) => ({ x: a.x + p.x / poly.length, y: a.y + p.y / poly.length }), ORIGIN);
|
|
567
812
|
return poly.map((p) => ({ x: c.x + (p.x - c.x) * s, y: c.y + (p.y - c.y) * s }));
|
|
568
813
|
};
|
|
569
|
-
var arcPts = (r, from, to,
|
|
814
|
+
var arcPts = (r, from, to, n2) => Array.from({ length: n2 + 1 }, (_, k) => ({ x: r * Math.cos(from + (to - from) * k / n2), y: r * Math.sin(from + (to - from) * k / n2) }));
|
|
570
815
|
function crescent(dx = 0.36, r = 0.83) {
|
|
571
816
|
const ix = (1 - r * r + dx * dx) / (2 * dx);
|
|
572
817
|
const theta = Math.acos(Math.min(1, ix));
|
|
@@ -583,7 +828,7 @@ function cubeFaces() {
|
|
|
583
828
|
}
|
|
584
829
|
var band = (outer, inner, start, end) => [[...arcPts(outer, start, end, CIRCLE_N), ...arcPts(inner, end, start, CIRCLE_N)]];
|
|
585
830
|
var rect = (x, y, w, h) => [{ x, y }, { x: x + w, y }, { x: x + w, y: y + h }, { x, y: y + h }];
|
|
586
|
-
var star = (
|
|
831
|
+
var star = (n2, inner) => ngon(2 * n2, 1).map((p, k) => k % 2 === 1 ? { x: p.x * inner, y: p.y * inner } : p);
|
|
587
832
|
var wave = () => {
|
|
588
833
|
const xs = Array.from({ length: 25 }, (_, k) => -1 + k / 12);
|
|
589
834
|
const back = [...xs];
|
|
@@ -643,9 +888,9 @@ var COMBINATORS = {
|
|
|
643
888
|
return [...parts(a, 0.72, 0, 0, "a"), ...parts(b, 0.24, 0.82 * Math.cos(t), 0.82 * Math.sin(t), "b")];
|
|
644
889
|
},
|
|
645
890
|
repeat: (r, a) => {
|
|
646
|
-
const
|
|
647
|
-
return Array.from({ length:
|
|
648
|
-
const t = -Math.PI / 2 + 2 * Math.PI * k /
|
|
891
|
+
const n2 = pick(r, [3, 4, 5, 6]);
|
|
892
|
+
return Array.from({ length: n2 }, (_, k) => {
|
|
893
|
+
const t = -Math.PI / 2 + 2 * Math.PI * k / n2;
|
|
649
894
|
return parts(a, 0.34, 0.6 * Math.cos(t), 0.6 * Math.sin(t), k % 2 === 0 ? "a" : "b").map((p) => ({ ...p, name: `${p.name}-${k}` }));
|
|
650
895
|
}).flat();
|
|
651
896
|
},
|
|
@@ -775,9 +1020,9 @@ function normalise(mask, w, h) {
|
|
|
775
1020
|
for (let gx = 0; gx < GRID; gx++) {
|
|
776
1021
|
let hits = 0;
|
|
777
1022
|
for (let s = 0; s < SAMPLES * SAMPLES; s++) {
|
|
778
|
-
const
|
|
1023
|
+
const px3 = Math.floor(ox + (gx + (s % SAMPLES + 0.5) / SAMPLES) * side / GRID);
|
|
779
1024
|
const py = Math.floor(oy + (gy + (Math.floor(s / SAMPLES) + 0.5) / SAMPLES) * side / GRID);
|
|
780
|
-
hits +=
|
|
1025
|
+
hits += px3 >= 0 && py >= 0 && px3 < w && py < h ? mask[py * w + px3] ?? 0 : 0;
|
|
781
1026
|
}
|
|
782
1027
|
out[gy * GRID + gx] = hits >= MAJORITY ? 1 : 0;
|
|
783
1028
|
}
|
|
@@ -835,8 +1080,8 @@ function visibleShare(tile, ink2) {
|
|
|
835
1080
|
// src/checks/symbols.ts
|
|
836
1081
|
var svg = (body) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">${body}</svg>`;
|
|
837
1082
|
var crescentBody = (dx, r) => `<mask id="c"><rect width="100" height="100" fill="#fff"/><circle cx="${50 + dx}" cy="50" r="${r}" fill="#000"/></mask><circle cx="50" cy="50" r="40" mask="url(#c)"/>`;
|
|
838
|
-
var starPoints = (cx, cy, r,
|
|
839
|
-
const t = -Math.PI / 2 + Math.PI * k /
|
|
1083
|
+
var starPoints = (cx, cy, r, n2, inner) => Array.from({ length: 2 * n2 }, (_, k) => {
|
|
1084
|
+
const t = -Math.PI / 2 + Math.PI * k / n2;
|
|
840
1085
|
const rr = k % 2 === 0 ? r : r * inner;
|
|
841
1086
|
return `${(cx + rr * Math.cos(t)).toFixed(2)},${(cy + rr * Math.sin(t)).toFixed(2)}`;
|
|
842
1087
|
}).join(" ");
|
|
@@ -938,9 +1183,9 @@ function legibility(mark, size) {
|
|
|
938
1183
|
out.push(`legible${size}: ink covers ${(cover * 100).toFixed(0)}% of the ${size} px tile`);
|
|
939
1184
|
}
|
|
940
1185
|
mark.layers.forEach((layer, i) => {
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
943
|
-
out.push(`legible${size}: layer "${layer.name}" is ${
|
|
1186
|
+
const px3 = ink(alphaMask(renderSvg(inkSvg(mark, i), size)));
|
|
1187
|
+
if (px3 < (MIN_LAYER_PX[size] ?? 1)) {
|
|
1188
|
+
out.push(`legible${size}: layer "${layer.name}" is ${px3} px, lost at ${size} px`);
|
|
944
1189
|
}
|
|
945
1190
|
});
|
|
946
1191
|
return out;
|
|
@@ -1042,52 +1287,195 @@ function generatorPalette(tokensId) {
|
|
|
1042
1287
|
};
|
|
1043
1288
|
}
|
|
1044
1289
|
|
|
1045
|
-
// src/motion/
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
|
|
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)));
|
|
1290
|
+
// src/motion/cssAnim.ts
|
|
1291
|
+
var SETTLE_OUT = "cubic-bezier(0.23,1,0.32,1)";
|
|
1292
|
+
var IN_OUT = "cubic-bezier(0.77,0,0.175,1)";
|
|
1293
|
+
var pct = (p) => `${Number.isInteger(p) ? p : p.toFixed(2)}%`;
|
|
1294
|
+
function cssAnim(name, selector, frames2, timing) {
|
|
1295
|
+
const body = frames2.map(([p, v]) => `${pct(p)}{${v}}`).join("");
|
|
1296
|
+
const run2 = `${name} ${Math.round(timing.durationMs)}ms ${timing.easing} ${Math.round(timing.delayMs ?? 0)}ms 1 both`;
|
|
1297
|
+
return `@keyframes ${name}{${body}}${selector}{animation:${run2}}`;
|
|
1057
1298
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1299
|
+
|
|
1300
|
+
// src/motion/wordmark.ts
|
|
1301
|
+
var REFERENCE_FONT = 17;
|
|
1302
|
+
var TYPE_SHARE = 0.7;
|
|
1303
|
+
var TYPE_STEP = 16;
|
|
1304
|
+
var STAGGER_STEP = 12;
|
|
1305
|
+
var STAGGER_MS = 240;
|
|
1306
|
+
var px = (v) => `${Number(v.toFixed(1))}px`;
|
|
1307
|
+
var letterCss = (c, frames2, durationMs, step2, easing) => c.xs.map((_, i) => cssAnim(`${c.p}-l${i}`, `.${c.p}-l${i}`, frames2(i), { durationMs, delayMs: c.at + i * step2, easing })).join("");
|
|
1308
|
+
function stagger(c) {
|
|
1309
|
+
const rise = px(7 * c.k);
|
|
1310
|
+
const css = letterCss(c, () => [[0, `opacity:0;transform:translateY(${rise})`], [100, "opacity:1;transform:none"]], STAGGER_MS, STAGGER_STEP, SETTLE_OUT);
|
|
1311
|
+
return { durationMs: (c.n - 1) * STAGGER_STEP + STAGGER_MS, letters: true, shown: [], hidden: [], css };
|
|
1312
|
+
}
|
|
1313
|
+
function slide(c) {
|
|
1314
|
+
const frames2 = [[0, `opacity:0;transform:translateX(${px(-56 * c.k)})`], [35, "opacity:1"], [100, "opacity:1;transform:none"]];
|
|
1315
|
+
const css = cssAnim(`${c.p}-g`, `.${c.p}-g`, frames2, { durationMs: 420, delayMs: c.at, easing: SETTLE_OUT });
|
|
1316
|
+
return { durationMs: 420, letters: false, shown: [`${c.p}-g`], hidden: [], css };
|
|
1317
|
+
}
|
|
1318
|
+
function typewriter(c) {
|
|
1319
|
+
const durationMs = Math.round(c.n * TYPE_STEP / TYPE_SHARE);
|
|
1320
|
+
const end = px(c.width);
|
|
1321
|
+
const steps = c.xs.map((x, i) => [i / c.n * TYPE_SHARE * 100, `transform:translateX(${px(x)});opacity:1`]);
|
|
1322
|
+
const caret = [[0, "transform:translateX(0);opacity:1"], ...steps, [TYPE_SHARE * 100, `transform:translateX(${end});opacity:1`], [100, `transform:translateX(${end});opacity:0`]];
|
|
1323
|
+
const letters = letterCss(c, () => [[0, "opacity:0"], [100, "opacity:1"]], 1, TYPE_STEP, "linear");
|
|
1324
|
+
const css = letters + cssAnim(`${c.p}-k`, `.${c.p}-k`, caret, { durationMs, delayMs: c.at, easing: "step-end" });
|
|
1325
|
+
return { durationMs, letters: true, shown: [], hidden: [`${c.p}-k`], css };
|
|
1326
|
+
}
|
|
1327
|
+
function wipe(c) {
|
|
1328
|
+
const end = px(c.width);
|
|
1329
|
+
const rect2 = cssAnim(`${c.p}-r`, `.${c.p}-r`, [[0, "transform:scaleX(0)"], [100, "transform:scaleX(1)"]], { durationMs: 380, delayMs: c.at, easing: SETTLE_OUT });
|
|
1330
|
+
const edgeFrames = [[0, "transform:translateX(0);opacity:1"], [73, `transform:translateX(${end});opacity:1`], [100, `transform:translateX(${end});opacity:0`]];
|
|
1331
|
+
const edge = cssAnim(`${c.p}-e`, `.${c.p}-e`, edgeFrames, { durationMs: 520, delayMs: c.at, easing: SETTLE_OUT });
|
|
1332
|
+
return { durationMs: 520, letters: false, shown: [`${c.p}-r`], hidden: [`${c.p}-e`], css: rect2 + edge };
|
|
1333
|
+
}
|
|
1334
|
+
function tracking(c) {
|
|
1335
|
+
const css = letterCss(c, (i) => [[0, `opacity:0;transform:translateX(${px(i * 2.2 * c.k)})`], [100, "opacity:1;transform:none"]], 440, 0, SETTLE_OUT);
|
|
1336
|
+
return { durationMs: 440, letters: true, shown: [], hidden: [], css };
|
|
1337
|
+
}
|
|
1338
|
+
var RECIPES = {
|
|
1339
|
+
["letter-stagger" /* LetterStagger */]: stagger,
|
|
1340
|
+
["slide-from-mark" /* SlideFromMark */]: slide,
|
|
1341
|
+
["typewriter" /* Typewriter */]: typewriter,
|
|
1342
|
+
["mask-wipe" /* MaskWipe */]: wipe,
|
|
1343
|
+
["tracking-settle" /* TrackingSettle */]: tracking
|
|
1344
|
+
};
|
|
1345
|
+
function reduced(c, b) {
|
|
1346
|
+
const shown = [...b.letters ? c.xs.map((_, i) => `${c.p}-l${i}`) : [], ...b.shown].map((s) => `.${s}`).join(",");
|
|
1347
|
+
const hidden = b.hidden.map((s) => `.${s}`).join(",");
|
|
1348
|
+
const show = shown !== "" ? `${shown}{animation:none!important;opacity:1!important;transform:none!important}` : "";
|
|
1349
|
+
const hide = hidden !== "" ? `${hidden}{animation:none!important;opacity:0!important}` : "";
|
|
1350
|
+
return `@media (prefers-reduced-motion:reduce){${show}${hide}}`;
|
|
1351
|
+
}
|
|
1352
|
+
var offsets = (advances) => advances.map((_, i) => advances.slice(0, i).reduce((s, a) => s + a, 0));
|
|
1353
|
+
function wordmarkReveal(name, options2) {
|
|
1354
|
+
const build = RECIPES[name];
|
|
1355
|
+
if (!build) {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
const startMs = options2.startMs ?? 0;
|
|
1359
|
+
const width = options2.advances.reduce((s, a) => s + a, 0);
|
|
1360
|
+
const k = (options2.fontSize ?? REFERENCE_FONT) / REFERENCE_FONT;
|
|
1361
|
+
const c = { p: options2.prefix ?? "lkw", at: startMs, k, n: options2.advances.length, xs: offsets(options2.advances), width };
|
|
1362
|
+
const b = build(c);
|
|
1363
|
+
return { recipe: name, startMs, durationMs: b.durationMs, classes: [...b.shown, ...b.hidden], css: b.css + reduced(c, b) };
|
|
1062
1364
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1365
|
+
|
|
1366
|
+
// src/motion/idle.ts
|
|
1367
|
+
var REFERENCE_SIZE2 = 64;
|
|
1368
|
+
var RIM_SHARE = 0.425;
|
|
1369
|
+
var PART_STEP = 1.2;
|
|
1370
|
+
var n = (v) => String(Number(v.toFixed(2)));
|
|
1371
|
+
function rimGlint(c) {
|
|
1372
|
+
const overlay = `<circle class="${c.p}-s" cx="${n(c.cx)}" cy="${n(c.cy)}" r="${n(RIM_SHARE * c.size)}" fill="none" stroke="${c.colour}" stroke-width="${n(1.6 * c.k)}" stroke-linecap="round" pathLength="100" stroke-dasharray="14 86" style="opacity:0"/>`;
|
|
1373
|
+
const frames2 = [[0, "stroke-dashoffset:100;opacity:0"], [20, "opacity:0.9"], [80, "opacity:0.9"], [100, "stroke-dashoffset:0;opacity:0"]];
|
|
1374
|
+
return { durationMs: 520, css: cssAnim(`${c.p}-s`, `.${c.on} .${c.p}-s`, frames2, { durationMs: 520, easing: SETTLE_OUT }), overlay };
|
|
1375
|
+
}
|
|
1376
|
+
function facesPart(c) {
|
|
1377
|
+
const one = (part, i) => {
|
|
1378
|
+
const frames2 = [[0, "transform:none"], [45, `transform:translate(${part.dx.toFixed(2)}px,${part.dy.toFixed(2)}px)`], [100, "transform:none"]];
|
|
1379
|
+
return cssAnim(`${c.p}-p${i}`, `.${c.on} #mark-${part.name}`, frames2, { durationMs: 420, easing: IN_OUT });
|
|
1380
|
+
};
|
|
1381
|
+
return { durationMs: 420, css: c.parts.map(one).join(""), overlay: "" };
|
|
1382
|
+
}
|
|
1383
|
+
function breath(c) {
|
|
1384
|
+
const origin = `.${c.on} #mark{transform-box:view-box;transform-origin:${n(c.cx)}px ${n(c.cy)}px}`;
|
|
1385
|
+
const frames2 = [[0, "transform:none"], [50, "transform:scale(1.05)"], [100, "transform:none"]];
|
|
1386
|
+
return { durationMs: 600, css: cssAnim(`${c.p}-b`, `.${c.on} #mark`, frames2, { durationMs: 600, easing: IN_OUT }) + origin, overlay: "" };
|
|
1387
|
+
}
|
|
1388
|
+
function orbitSpark(c) {
|
|
1389
|
+
const spark = `<circle cx="${n(c.cx)}" cy="${n(c.top + 1.6 * c.k)}" r="${n(1.8 * c.k)}" fill="${c.colour}"/>`;
|
|
1390
|
+
const overlay = `<g class="${c.p}-o" style="transform-box:view-box;transform-origin:${n(c.cx)}px ${n(c.cy)}px;opacity:0">${spark}</g>`;
|
|
1391
|
+
const frames2 = [[0, "transform:rotate(0deg);opacity:0"], [12, "opacity:1"], [85, "opacity:1"], [100, "transform:rotate(360deg);opacity:0"]];
|
|
1392
|
+
return { durationMs: 600, css: cssAnim(`${c.p}-o`, `.${c.on} .${c.p}-o`, frames2, { durationMs: 600, easing: "cubic-bezier(0.45,0,0.55,1)" }), overlay };
|
|
1393
|
+
}
|
|
1394
|
+
var RECIPES2 = {
|
|
1395
|
+
["rim-glint" /* RimGlint */]: rimGlint,
|
|
1396
|
+
["faces-part" /* FacesPart */]: facesPart,
|
|
1397
|
+
["breath" /* Breath */]: breath,
|
|
1398
|
+
["orbit-spark" /* OrbitSpark */]: orbitSpark
|
|
1399
|
+
};
|
|
1400
|
+
function context(ctx) {
|
|
1401
|
+
const vb = viewBoxOf(ctx.mark);
|
|
1402
|
+
const size = markSizeOf(ctx.mark);
|
|
1403
|
+
const k = size / REFERENCE_SIZE2;
|
|
1404
|
+
const cx = vb.x + vb.w / 2;
|
|
1405
|
+
const cy = vb.y + vb.h / 2;
|
|
1406
|
+
const names = ctx.roles?.parts ?? ctx.mark.layers.slice(1).map((l) => l.name);
|
|
1407
|
+
const parts2 = ctx.mark.layers.filter((l) => names.includes(l.name)).map((l) => {
|
|
1408
|
+
const c = centroid(flattenPath(l.d).flat());
|
|
1409
|
+
const len = Math.hypot(c.x - cx, c.y - cy) || 1;
|
|
1410
|
+
return { name: l.name, dx: (c.x - cx) / len * PART_STEP * k, dy: (c.y - cy) / len * PART_STEP * k };
|
|
1411
|
+
});
|
|
1412
|
+
return { p: ctx.prefix ?? "lki", on: ctx.trigger ?? "lk-idle", colour: ctx.colour ?? "currentColor", cx, cy, top: vb.y, size, k, parts: parts2 };
|
|
1067
1413
|
}
|
|
1068
|
-
function
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
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`);
|
|
1414
|
+
function idleRecipe(name, ctx) {
|
|
1415
|
+
const build = RECIPES2[name];
|
|
1416
|
+
if (!build) {
|
|
1417
|
+
return null;
|
|
1087
1418
|
}
|
|
1088
|
-
|
|
1419
|
+
const c = context(ctx);
|
|
1420
|
+
const b = build(c);
|
|
1421
|
+
return { recipe: name, durationMs: b.durationMs, overlay: b.overlay, css: `${b.css}@media (prefers-reduced-motion:reduce){.${c.on} *{animation:none!important}}` };
|
|
1089
1422
|
}
|
|
1090
1423
|
|
|
1424
|
+
// src/motion/boldPresets.ts
|
|
1425
|
+
var fillBox = "transform-box:fill-box;transform-origin:center";
|
|
1426
|
+
var px2 = (n2) => `${n2.toFixed(2)}px`;
|
|
1427
|
+
var frames = (stops) => stops.map(([at, body]) => `${at}%{${body}}`).join("");
|
|
1428
|
+
function outward(ctx) {
|
|
1429
|
+
const pts = ctx.layer ? flattenPath(ctx.layer.d).flat() : [];
|
|
1430
|
+
const c = pts.length > 0 ? centroid(pts) : ctx.markCentre;
|
|
1431
|
+
const dx = c.x - ctx.markCentre.x;
|
|
1432
|
+
const dy = c.y - ctx.markCentre.y;
|
|
1433
|
+
const len = Math.hypot(dx, dy);
|
|
1434
|
+
return len > 0 ? { x: dx / len, y: dy / len } : { x: -1, y: 0 };
|
|
1435
|
+
}
|
|
1436
|
+
function flyIn(beat, ctx) {
|
|
1437
|
+
const u = outward(ctx);
|
|
1438
|
+
const d = beat.distance ?? ctx.markSize * 0.5;
|
|
1439
|
+
const at = (k) => `transform:translate(${px2(u.x * d * k)},${px2(u.y * d * k)})`;
|
|
1440
|
+
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)}`]]);
|
|
1441
|
+
return { keyframes, timing: beat.easing ?? EASE };
|
|
1442
|
+
}
|
|
1443
|
+
function spinAssemble(beat) {
|
|
1444
|
+
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)"]]);
|
|
1445
|
+
return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
|
|
1446
|
+
}
|
|
1447
|
+
function dropBounce(beat, ctx) {
|
|
1448
|
+
const h = beat.distance ?? ctx.markSize * 0.6;
|
|
1449
|
+
const y = (k) => `transform:translateY(${px2(-h * k)})`;
|
|
1450
|
+
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)}`]]);
|
|
1451
|
+
return { keyframes, timing: beat.easing ?? "ease-in-out" };
|
|
1452
|
+
}
|
|
1453
|
+
function flip(beat) {
|
|
1454
|
+
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)"]]);
|
|
1455
|
+
return { keyframes, timing: beat.easing ?? EASE, extra: fillBox };
|
|
1456
|
+
}
|
|
1457
|
+
function slamShake(beat, ctx) {
|
|
1458
|
+
const s = beat.distance ?? ctx.markSize * 0.04;
|
|
1459
|
+
const at = (k, scale) => `transform:translate(${px2(s * k)},0px) scale(${scale})`;
|
|
1460
|
+
const keyframes = frames([
|
|
1461
|
+
[0, `opacity:0;${at(0, beat.scale ?? 2.4)}`],
|
|
1462
|
+
[40, `opacity:1;${at(0, 0.94)}`],
|
|
1463
|
+
[50, `opacity:1;${at(-1, 1)}`],
|
|
1464
|
+
[62, `opacity:1;${at(1, 1)}`],
|
|
1465
|
+
[74, `opacity:1;${at(-0.6, 1)}`],
|
|
1466
|
+
[86, `opacity:1;${at(0.3, 1)}`],
|
|
1467
|
+
[100, `opacity:1;${at(0, 1)}`]
|
|
1468
|
+
]);
|
|
1469
|
+
return { keyframes, timing: beat.easing ?? "cubic-bezier(0.5,0,0.75,0)", extra: fillBox };
|
|
1470
|
+
}
|
|
1471
|
+
var BOLD_PRESET_FRAMES = {
|
|
1472
|
+
["fly-in" /* FlyIn */]: flyIn,
|
|
1473
|
+
["spin-assemble" /* SpinAssemble */]: spinAssemble,
|
|
1474
|
+
["drop-bounce" /* DropBounce */]: dropBounce,
|
|
1475
|
+
["flip" /* Flip */]: flip,
|
|
1476
|
+
["slam-shake" /* SlamShake */]: slamShake
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1091
1479
|
// src/motion/morph.ts
|
|
1092
1480
|
var POINTS = 96;
|
|
1093
1481
|
function startAtTop(poly, c) {
|
|
@@ -1121,7 +1509,7 @@ function morphPair(d) {
|
|
|
1121
1509
|
}
|
|
1122
1510
|
|
|
1123
1511
|
// src/motion/presets.ts
|
|
1124
|
-
var
|
|
1512
|
+
var fillBox2 = "transform-box:fill-box;transform-origin:center";
|
|
1125
1513
|
function morphFrames(beat, ctx) {
|
|
1126
1514
|
const layer = ctx.layer;
|
|
1127
1515
|
if (!layer) {
|
|
@@ -1153,7 +1541,7 @@ var PRESETS2 = {
|
|
|
1153
1541
|
["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
1542
|
["flood" /* Flood */]: (b) => ({ keyframes: "0%{fill-opacity:0}100%{fill-opacity:1}", timing: b.easing ?? EASE }),
|
|
1155
1543
|
["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:
|
|
1544
|
+
["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
1545
|
["orbit" /* Orbit */]: (b, ctx) => ({
|
|
1158
1546
|
keyframes: "0%{opacity:0;transform:rotate(-90deg)}100%{opacity:1;transform:rotate(0deg)}",
|
|
1159
1547
|
timing: b.easing ?? EASE,
|
|
@@ -1162,8 +1550,9 @@ var PRESETS2 = {
|
|
|
1162
1550
|
["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
1551
|
["morph-from-circle" /* MorphFromCircle */]: (b, ctx) => ({ keyframes: morphFrames(b, ctx), timing: "linear", supportsD: true }),
|
|
1164
1552
|
["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:
|
|
1166
|
-
["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" })
|
|
1553
|
+
["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 }),
|
|
1554
|
+
["spread" /* Spread */]: (b, ctx) => ({ keyframes: spreadFrames(b, ctx), timing: "linear" }),
|
|
1555
|
+
...BOLD_PRESET_FRAMES
|
|
1167
1556
|
};
|
|
1168
1557
|
function presetFrames(beat, ctx) {
|
|
1169
1558
|
const fn = PRESETS2[beat.preset];
|
|
@@ -1201,28 +1590,28 @@ function render(rules, keyframes) {
|
|
|
1201
1590
|
const morph = keyframes.filter((k) => k.supportsD).map((k) => k.body).join("");
|
|
1202
1591
|
const decls = (r) => [...r.extras, "animation:".concat(r.animations.join(","))].join(";");
|
|
1203
1592
|
const css = (list) => list.map((r) => `${r.selector}{${decls(r)}}`).join("");
|
|
1204
|
-
const
|
|
1205
|
-
const supports =
|
|
1593
|
+
const all2 = [...rules.values()];
|
|
1594
|
+
const supports = all2.filter((r) => r.supportsD);
|
|
1206
1595
|
const wrapped = supports.length > 0 ? `@supports (d:path("M0 0")){${morph}${css(supports)}}` : "";
|
|
1207
|
-
return `${plain}${css(
|
|
1596
|
+
return `${plain}${css(all2.filter((r) => !r.supportsD))}${wrapped}${REDUCED_MOTION}`;
|
|
1208
1597
|
}
|
|
1209
1598
|
function addSlot(ctx, beat, b, slot) {
|
|
1210
1599
|
const sweep = beat.preset === "sweep" /* Sweep */;
|
|
1211
1600
|
const index = ctx.names.indexOf(slot.target);
|
|
1212
|
-
const
|
|
1601
|
+
const frames2 = presetFrames(beat, { layer: ctx.mark.layers[index] ?? null, markCentre: ctx.markCentre, markSize: ctx.markSize });
|
|
1213
1602
|
const suffix = slot.target === MARK_TARGET ? "m" : String(index);
|
|
1214
1603
|
const name = `lk${ctx.hover ? "m" : "i"}${b}-${suffix}`;
|
|
1215
1604
|
const selector = selectorOf(slot.target, index, ctx.hover, sweep);
|
|
1216
1605
|
const rule = ctx.rules.get(selector) ?? { selector, animations: [], extras: [], supportsD: false };
|
|
1217
1606
|
const delay = slot.delayMs > 0 ? ` ${slot.delayMs}ms` : "";
|
|
1218
1607
|
const fill = ctx.hover ? "" : " backwards";
|
|
1219
|
-
rule.animations.push(`${name} ${slot.durationMs}ms ${
|
|
1220
|
-
if (
|
|
1221
|
-
rule.extras.push(
|
|
1608
|
+
rule.animations.push(`${name} ${slot.durationMs}ms ${frames2.timing}${delay} 1${fill}`);
|
|
1609
|
+
if (frames2.extra !== void 0 && !rule.extras.includes(frames2.extra)) {
|
|
1610
|
+
rule.extras.push(frames2.extra);
|
|
1222
1611
|
}
|
|
1223
|
-
rule.supportsD = rule.supportsD ||
|
|
1612
|
+
rule.supportsD = rule.supportsD || frames2.supportsD === true;
|
|
1224
1613
|
ctx.rules.set(selector, rule);
|
|
1225
|
-
ctx.keyframes.push({ body: `@keyframes ${name}{${
|
|
1614
|
+
ctx.keyframes.push({ body: `@keyframes ${name}{${frames2.keyframes}}`, supportsD: frames2.supportsD === true });
|
|
1226
1615
|
if (beat.preset === "draw" /* Draw */) {
|
|
1227
1616
|
ctx.drawLayers.add(slot.target);
|
|
1228
1617
|
}
|
|
@@ -1237,6 +1626,7 @@ function motionCss(mark, beats, palette, mode, hover) {
|
|
|
1237
1626
|
mark,
|
|
1238
1627
|
names: mark.layers.map((l) => l.name),
|
|
1239
1628
|
markCentre: { x: vb.x + vb.w / 2, y: vb.y + vb.h / 2 },
|
|
1629
|
+
markSize: markSizeOf(mark),
|
|
1240
1630
|
colour: (role) => colours[role ?? "text"] ?? "#ffffff",
|
|
1241
1631
|
hover,
|
|
1242
1632
|
rules: /* @__PURE__ */ new Map(),
|
|
@@ -1527,10 +1917,10 @@ function colourStep(brand, mark, outDir) {
|
|
|
1527
1917
|
function motionStep(mark, palette, outDir) {
|
|
1528
1918
|
const still = frame(outDir, "motion-still", mark, palette);
|
|
1529
1919
|
fs2.mkdirSync(path3.join(outDir, "motion"), { recursive: true });
|
|
1530
|
-
const
|
|
1920
|
+
const n2 = mark.layers.length;
|
|
1531
1921
|
const options2 = MOTION_OPTIONS.map((preset) => {
|
|
1532
1922
|
const base = PRESET_DEFAULTS[preset] ?? { preset, durationMs: 600 };
|
|
1533
|
-
const beat = preset === "morph-from-circle" /* MorphFromCircle */ ? { ...base, fadeIn: mark.layers.slice(1).map((l) => l.name) } : fitBeat(base,
|
|
1923
|
+
const beat = preset === "morph-from-circle" /* MorphFromCircle */ ? { ...base, fadeIn: mark.layers.slice(1).map((l) => l.name) } : fitBeat(base, n2, INTRO_CAP_MS);
|
|
1534
1924
|
const rel = `motion/${preset}.svg`;
|
|
1535
1925
|
fs2.writeFileSync(path3.join(outDir, rel), frameSvg(mark, palette, [beat]));
|
|
1536
1926
|
return option(preset, `The ${preset} intro, ${beat.durationMs} ms per layer, ends on the still.`, still, { motion: rel, targetBox: void 0 });
|
|
@@ -1588,6 +1978,10 @@ function generate(file, f, out) {
|
|
|
1588
1978
|
out(`generated ${count}, passed ${report.passed.length}, dropped ${report.dropped.length} -> ${dir}`);
|
|
1589
1979
|
return 0;
|
|
1590
1980
|
}
|
|
1981
|
+
function motionRefusal(file) {
|
|
1982
|
+
const errors = loadBrand(file).motion.recipeErrors ?? [];
|
|
1983
|
+
return errors.length > 0 ? `motion: ${errors.join("; ")}` : null;
|
|
1984
|
+
}
|
|
1591
1985
|
function check(file, out) {
|
|
1592
1986
|
const brand = loadBrand(file);
|
|
1593
1987
|
const result = runChecks(brand.mark, brand.palette);
|
|
@@ -1603,6 +1997,11 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
|
|
|
1603
1997
|
out(USAGE);
|
|
1604
1998
|
return 2;
|
|
1605
1999
|
}
|
|
2000
|
+
const refusal = cmd === "export" || cmd === "generate" ? motionRefusal(file) : null;
|
|
2001
|
+
if (refusal !== null) {
|
|
2002
|
+
out(refusal);
|
|
2003
|
+
return 1;
|
|
2004
|
+
}
|
|
1606
2005
|
if (cmd === "export") {
|
|
1607
2006
|
const files = exportBrand(loadBrand(file), f.get("out") ?? "export");
|
|
1608
2007
|
files.forEach((x) => out(`${x.file} ${x.width}x${x.height}`));
|
|
@@ -1625,6 +2024,6 @@ function runCli(args, out = (line) => process.stdout.write(`${line}
|
|
|
1625
2024
|
return 2;
|
|
1626
2025
|
}
|
|
1627
2026
|
|
|
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 };
|
|
2027
|
+
export { BOLD_PRESETS, CVD_KINDS, CvdKind, IDLE_CAP_MS, IDLE_RECIPES, INTRO_CAP_MS, INTRO_PRESETS, INTRO_RECIPES, IdleRecipe, IntroRecipe, LOOKALIKE_THRESHOLD, MICRO_CAP_MS, MICRO_DEFAULTS, MICRO_PRESETS, MICRO_RECIPES, MODES, MicroRecipe, Mode, MotionPreset, PRESET_DEFAULTS, PRIMITIVES, SYMBOLS, WORDMARK_RECIPES, WordmarkRecipe, alphaMask, animatedSvg, buildPickPage, buildPickSpec, checkVariants, contrast, deltaE, exportBrand, fitBeat, flattenPath, generateVariants, generatorPalette, geometryModule, idleRecipe, introRecipe, introSvg, loadBrand, markSvg, microRecipe, microSvg, paletteVariants, parseBrand, parseTiming, pixelDiff, pngSize, primitiveMark, renderPng, renderSvg, resolveMotion, resolveToken, runChecks, runCli, schedule, simulateCvd, symbolMatches, symbolScores, totalMs, validateMotion, wordmarkReveal };
|
|
1629
2028
|
//# sourceMappingURL=index.js.map
|
|
1630
2029
|
//# sourceMappingURL=index.js.map
|