wissive 0.1.1 → 0.1.3
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 +86 -0
- package/dist/wissive.cjs +149 -131
- package/dist/wissive.cjs.map +1 -1
- package/dist/wissive.js +1412 -1087
- package/dist/wissive.js.map +1 -1
- package/dist/wissive.umd.js +149 -131
- package/dist/wissive.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const ALL_STATES: InteractionState[];
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const ALL_WANDERABLE_STATES: InteractionState[];
|
|
14
14
|
|
|
15
|
+
export declare const ANGLES: number[];
|
|
16
|
+
|
|
15
17
|
declare class AnimationLoop {
|
|
16
18
|
private callbacks;
|
|
17
19
|
private handle;
|
|
@@ -52,6 +54,11 @@ export declare const AUTONOMOUS_STATES: InteractionState[];
|
|
|
52
54
|
*/
|
|
53
55
|
export declare function blendColors(colorA: string, colorB: string, factor: number): string;
|
|
54
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Interpola linealmente entre dos conjuntos de 64 radios
|
|
59
|
+
*/
|
|
60
|
+
export declare function blendProfiles(a: number[], b: number[], t: number): number[];
|
|
61
|
+
|
|
55
62
|
/**
|
|
56
63
|
* Construye una definición de emoji personalizado: base neutra (Cota),
|
|
57
64
|
* silueta a elección (circle por default), con ojos/boca/animación tomados
|
|
@@ -69,8 +76,17 @@ export declare function checkContrast(bgColor: string, fgColor: string, minRatio
|
|
|
69
76
|
passes: boolean;
|
|
70
77
|
};
|
|
71
78
|
|
|
79
|
+
export declare const clamp: (v: number, lo?: number, hi?: number) => number;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Convierte polilínea cerrada de 64 puntos en curva Bézier cúbica Catmull-Rom cerrada continua
|
|
83
|
+
*/
|
|
84
|
+
export declare function closedCatmullRomPath(pts: Point[], tension?: number): string;
|
|
85
|
+
|
|
72
86
|
export declare type CoreInteractionState = 'idle' | 'near' | 'hover' | 'click';
|
|
73
87
|
|
|
88
|
+
export declare const COS: number[];
|
|
89
|
+
|
|
74
90
|
/**
|
|
75
91
|
* Construye (o reconstruye) un emoji personalizado, lo persiste en localStorage
|
|
76
92
|
* y lo registra en LIB para poder usarlo directamente con createEmoji(name, ...).
|
|
@@ -95,6 +111,8 @@ export declare function createSequencePlayer(hooks: {
|
|
|
95
111
|
applyStep: (params: Partial<FaceParameters>) => void;
|
|
96
112
|
}): SequencePlayer;
|
|
97
113
|
|
|
114
|
+
export declare function createStateManager(initialState?: InteractionState): StateManager;
|
|
115
|
+
|
|
98
116
|
export declare type CueSoundType = 'chime' | 'sparkle' | 'droplet' | 'bloom' | 'whisper' | 'tick' | 'press' | 'release' | 'toggle' | 'success' | 'error' | 'page' | 'loading' | 'ready' | 'pulse' | 'scan' | 'arrival';
|
|
99
117
|
|
|
100
118
|
export declare interface CustomEmojiOptions {
|
|
@@ -329,6 +347,8 @@ export declare interface FaceParameters {
|
|
|
329
347
|
* 24: cat-cup-smirk]
|
|
330
348
|
*/
|
|
331
349
|
mouthType: number;
|
|
350
|
+
/** Eyebrows visible toggle (0: hidden, 1: visible) */
|
|
351
|
+
showBrows: number;
|
|
332
352
|
/** Eyebrow Y offset */
|
|
333
353
|
browY: number;
|
|
334
354
|
/** Eyebrow tilt angle in degrees (+ is angry \ /, - is sad / \) */
|
|
@@ -361,6 +381,11 @@ export declare interface FaceParameters {
|
|
|
361
381
|
|
|
362
382
|
export declare type FrameCallback = (dt: number) => void;
|
|
363
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Genera el SVG `<path d="..." />` suave a partir de cualquier perfil de 64 radios
|
|
386
|
+
*/
|
|
387
|
+
export declare function generateSilhouettePath(radii: number[], cx?: number, cy?: number, radius?: number): string;
|
|
388
|
+
|
|
364
389
|
/**
|
|
365
390
|
* Calcula el ratio de contraste entre dos colores (e.g. 3:1, 4.5:1).
|
|
366
391
|
*/
|
|
@@ -380,11 +405,21 @@ export declare function getLuminance(color: string): number;
|
|
|
380
405
|
|
|
381
406
|
export declare function getSilhouettePath(silhouette: SilhouetteType): string;
|
|
382
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Devuelve el perfil radial de 64 muestras para una silueta dada
|
|
410
|
+
*/
|
|
411
|
+
export declare function getSilhouetteProfile(type: SilhouetteType): number[];
|
|
412
|
+
|
|
383
413
|
/**
|
|
384
414
|
* Obtiene el tema sugerido para un estado dado, con fallback a la paleta predeterminada del emoji.
|
|
385
415
|
*/
|
|
386
416
|
export declare function getThemeForState(_state: InteractionState, defaultBaseColor: string): EmojiTheme;
|
|
387
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Envolvente convexa de dos círculos (utilizado para cápsulas, gotas y peras)
|
|
420
|
+
*/
|
|
421
|
+
export declare function hullOfCircles(x1: number, y1: number, r1: number, x2: number, y2: number, r2v: number, steps?: number): Point[];
|
|
422
|
+
|
|
388
423
|
export declare const IDLE_MOTIONS: Record<MotionType, IdleMotionFn>;
|
|
389
424
|
|
|
390
425
|
/**
|
|
@@ -422,6 +457,8 @@ export declare function isReducedMotionPreferred(): boolean;
|
|
|
422
457
|
*/
|
|
423
458
|
export declare function isTouchDevice(): boolean;
|
|
424
459
|
|
|
460
|
+
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
461
|
+
|
|
425
462
|
export declare const LIB: Record<string, EmojiDefinition>;
|
|
426
463
|
|
|
427
464
|
export declare type LifecycleState = 'sleeping' | 'waking' | 'idle' | 'listening' | 'thinking' | 'searching' | 'working';
|
|
@@ -451,11 +488,17 @@ export declare type MotionType = 'bouncy' | 'flutter' | 'serene' | 'float' | 'ca
|
|
|
451
488
|
|
|
452
489
|
export declare interface MultiSpring<T extends Record<string, number>> {
|
|
453
490
|
getValues: () => T;
|
|
491
|
+
setConfig: (config: Partial<SpringConfig> | TransitionProfile) => void;
|
|
454
492
|
setTargets: (targets: Partial<T>) => void;
|
|
455
493
|
setValues: (values: Partial<T>) => void;
|
|
456
494
|
update: (dt: number) => boolean;
|
|
457
495
|
}
|
|
458
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Normaliza los radios para que el radio máximo o medio sea consistente
|
|
499
|
+
*/
|
|
500
|
+
export declare function normalizeRadii(radii: number[], targetMax?: number): number[];
|
|
501
|
+
|
|
459
502
|
export declare class ParticleEmitter {
|
|
460
503
|
private particles;
|
|
461
504
|
private canvas;
|
|
@@ -482,13 +525,29 @@ export declare const PERSONALITY_DRIVEN_STATES: InteractionState[];
|
|
|
482
525
|
/** Elige uno al azar de `pool`, evitando repetir `previous` cuando hay más de una opción */
|
|
483
526
|
export declare function pickWithoutRepeat<T>(pool: T[], previous: T | null): T;
|
|
484
527
|
|
|
528
|
+
export declare interface Point {
|
|
529
|
+
x: number;
|
|
530
|
+
y: number;
|
|
531
|
+
}
|
|
532
|
+
|
|
485
533
|
export declare type ProductCycleState = 'spawning' | 'humming' | 'loading' | 'dictating' | 'writing' | 'sending' | 'receiving' | 'uploading' | 'notifying' | 'alerting' | 'dragging' | 'bouncing' | 'powering-down';
|
|
486
534
|
|
|
535
|
+
export declare const PROFILE_SAMPLES = 64;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Perfil radial a partir de polígono 2D por raycasting desde el centro
|
|
539
|
+
*/
|
|
540
|
+
export declare function profileFromPolygon(poly: Point[], cx?: number, cy?: number): number[];
|
|
541
|
+
|
|
542
|
+
/** Round number to 2 decimals to keep SVG path string light & fast */
|
|
543
|
+
export declare const r2: (v: number) => number;
|
|
544
|
+
|
|
487
545
|
export declare type ReactionState = 'excited' | 'surprised' | 'suspicious' | 'angry' | 'drowsy' | 'happy' | 'curious' | 'confused' | 'bored' | 'proud' | 'shy' | 'sad' | 'laughing' | 'scared' | 'playful' | 'celebrate';
|
|
488
546
|
|
|
489
547
|
export declare interface RenderOptions {
|
|
490
548
|
flipX?: boolean;
|
|
491
549
|
emphasis?: boolean;
|
|
550
|
+
radii?: number[];
|
|
492
551
|
}
|
|
493
552
|
|
|
494
553
|
export declare function renderSvgElement(silhouette: SilhouetteType, baseColor: string, params: FaceParameters, size: number, renderOptions?: RenderOptions): string;
|
|
@@ -539,8 +598,15 @@ export declare function setGlobalVolume(volume: number): void;
|
|
|
539
598
|
|
|
540
599
|
export declare const sharedLoop: AnimationLoop;
|
|
541
600
|
|
|
601
|
+
/**
|
|
602
|
+
* Perfiles radiales precalculados (64 muestras cada uno)
|
|
603
|
+
*/
|
|
604
|
+
export declare const SILHOUETTE_PROFILES: Record<SilhouetteType, number[]>;
|
|
605
|
+
|
|
542
606
|
export declare type SilhouetteType = 'circle' | 'capsule' | 'rounded-squircle' | 'pear-blob' | 'egg-oval' | 'starburst-puff' | 'pill-vertical' | 'heart' | 'round-blob' | 'ghost-blob' | 'oval' | 'elongated-oval' | 'teardrop-blob' | 'flame-blob' | 'droopy-blob' | 'bear-blob' | 'spiky-blob' | 'cloud-blob' | 'wide-oval' | 'soft-round' | 'octopus-blob' | 'wave-blob';
|
|
543
607
|
|
|
608
|
+
export declare const SIN: number[];
|
|
609
|
+
|
|
544
610
|
export declare const SIZE_PRESETS: Record<WissivePresetSize, number>;
|
|
545
611
|
|
|
546
612
|
export declare class SoundEngine {
|
|
@@ -559,6 +625,8 @@ export declare class SoundEngine {
|
|
|
559
625
|
|
|
560
626
|
export declare const soundEngine: SoundEngine;
|
|
561
627
|
|
|
628
|
+
export declare const SPRING_PRESETS: Record<TransitionProfile, SpringConfig>;
|
|
629
|
+
|
|
562
630
|
export declare interface SpringConfig {
|
|
563
631
|
stiffness: number;
|
|
564
632
|
damping: number;
|
|
@@ -567,6 +635,7 @@ export declare interface SpringConfig {
|
|
|
567
635
|
|
|
568
636
|
export declare interface SpringInstance {
|
|
569
637
|
state: SpringState;
|
|
638
|
+
setConfig: (config: Partial<SpringConfig>) => void;
|
|
570
639
|
setTarget: (target: number) => void;
|
|
571
640
|
setCurrent: (value: number) => void;
|
|
572
641
|
update: (dt: number) => boolean;
|
|
@@ -602,6 +671,7 @@ export declare interface StateGroup {
|
|
|
602
671
|
export declare class StateManager {
|
|
603
672
|
private currentState;
|
|
604
673
|
private lastIndices;
|
|
674
|
+
constructor(initialState?: InteractionState);
|
|
605
675
|
getState(): InteractionState;
|
|
606
676
|
setState(newState: InteractionState): boolean;
|
|
607
677
|
resolvePool(expressions: Record<string, FaceParameters[]>, state?: InteractionState): FaceParameters[];
|
|
@@ -613,14 +683,28 @@ export declare class StateManager {
|
|
|
613
683
|
*/
|
|
614
684
|
export declare function subscribeToReducedMotion(onChange: (reduced: boolean) => void): () => void;
|
|
615
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Superellipse formula: |x/sx|^n + |y/sy|^n = 1
|
|
688
|
+
*/
|
|
689
|
+
export declare function superellipseProfile(n: number, sx?: number, sy?: number): number[];
|
|
690
|
+
|
|
616
691
|
/**
|
|
617
692
|
* Detecta si el dispositivo actual soporta hover real (puntero fino como mouse o trackpad).
|
|
618
693
|
* Devuelve false en dispositivos táctiles primarios (smartphones, tablets sin mouse).
|
|
619
694
|
*/
|
|
620
695
|
export declare function supportsHover(): boolean;
|
|
621
696
|
|
|
697
|
+
export declare const TAU: number;
|
|
698
|
+
|
|
622
699
|
export declare type ThemeOption = 'auto' | EmojiTheme;
|
|
623
700
|
|
|
701
|
+
/**
|
|
702
|
+
* Convierte un perfil de 64 radios en 64 puntos 2D en coordenadas de SVG (cx, cy, radio base)
|
|
703
|
+
*/
|
|
704
|
+
export declare function toPoints(radii: number[], cx?: number, cy?: number, baseRadius?: number, scaleX?: number, scaleY?: number): Point[];
|
|
705
|
+
|
|
706
|
+
export declare type TransitionProfile = 'smooth' | 'bouncy' | 'snappy' | 'gentle' | 'instant';
|
|
707
|
+
|
|
624
708
|
declare const Wissive: {
|
|
625
709
|
create: typeof createEmoji;
|
|
626
710
|
createGroup: typeof createEmojiGroup;
|
|
@@ -662,6 +746,8 @@ export declare interface WissiveInstance {
|
|
|
662
746
|
setReducedMotion: (setting: 'auto' | boolean) => void;
|
|
663
747
|
setTheme: (theme: ThemeOption) => void;
|
|
664
748
|
setSize: (size: WissiveSize) => void;
|
|
749
|
+
setSilhouette: (silhouette: SilhouetteType, duration?: number) => void;
|
|
750
|
+
setSpringConfig: (config: Partial<SpringConfig> | TransitionProfile) => void;
|
|
665
751
|
triggerParticles: (count?: number) => void;
|
|
666
752
|
playSequence: (steps: SequenceStep[], options?: SequenceOptions) => void;
|
|
667
753
|
stopSequence: () => void;
|