oneko 0.0.0-stage → 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.
Files changed (118) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/SKIN-CREDITS.md +61 -0
  4. package/dist/adapter.d.ts +1 -0
  5. package/dist/adapter.js +11 -0
  6. package/dist/cat-sounds/Cat_baby_ambient1.ogg +0 -0
  7. package/dist/cat-sounds/Cat_baby_ambient2.ogg +0 -0
  8. package/dist/cat-sounds/Cat_baby_ambient3.ogg +0 -0
  9. package/dist/cat-sounds/Cat_baby_ambient4.ogg +0 -0
  10. package/dist/cat-sounds/Cat_baby_ambient5.ogg +0 -0
  11. package/dist/cat-sounds/Cat_baby_ambient6.ogg +0 -0
  12. package/dist/cat-sounds/Cat_baby_ambient7.ogg +0 -0
  13. package/dist/cat-sounds/Cat_baby_death.ogg +0 -0
  14. package/dist/cat-sounds/Cat_baby_hurt1.ogg +0 -0
  15. package/dist/cat-sounds/Cat_baby_hurt2.ogg +0 -0
  16. package/dist/cat-sounds/Cat_baby_hurt3.ogg +0 -0
  17. package/dist/cat-sounds/Cat_beg1.ogg +0 -0
  18. package/dist/cat-sounds/Cat_beg2.ogg +0 -0
  19. package/dist/cat-sounds/Cat_beg3.ogg +0 -0
  20. package/dist/cat-sounds/Cat_eat1.ogg +0 -0
  21. package/dist/cat-sounds/Cat_eat2.ogg +0 -0
  22. package/dist/cat-sounds/Cat_hiss1.ogg +0 -0
  23. package/dist/cat-sounds/Cat_hiss2.ogg +0 -0
  24. package/dist/cat-sounds/Cat_hiss3.ogg +0 -0
  25. package/dist/cat-sounds/Cat_hurt1.ogg +0 -0
  26. package/dist/cat-sounds/Cat_hurt2.ogg +0 -0
  27. package/dist/cat-sounds/Cat_hurt3.ogg +0 -0
  28. package/dist/cat-sounds/Cat_idle1.ogg +0 -0
  29. package/dist/cat-sounds/Cat_idle2.ogg +0 -0
  30. package/dist/cat-sounds/Cat_idle3.ogg +0 -0
  31. package/dist/cat-sounds/Cat_idle4.ogg +0 -0
  32. package/dist/cat-sounds/Cat_purr1.ogg +0 -0
  33. package/dist/cat-sounds/Cat_purr2.ogg +0 -0
  34. package/dist/cat-sounds/Cat_purr3.ogg +0 -0
  35. package/dist/cat-sounds/Cat_purreow1.ogg +0 -0
  36. package/dist/cat-sounds/Cat_purreow2.ogg +0 -0
  37. package/dist/cat-sounds/Cat_royal_ambient1.ogg +0 -0
  38. package/dist/cat-sounds/Cat_royal_ambient2.ogg +0 -0
  39. package/dist/cat-sounds/Cat_royal_ambient3.ogg +0 -0
  40. package/dist/cat-sounds/Cat_royal_ambient4.ogg +0 -0
  41. package/dist/cat-sounds/Cat_royal_ambient5.ogg +1 -0
  42. package/dist/cat-sounds/Cat_royal_ambient6.ogg +1 -0
  43. package/dist/cat-sounds/Cat_royal_death.ogg +1 -0
  44. package/dist/cat-sounds/Cat_royal_hurt1.ogg +1 -0
  45. package/dist/cat-sounds/Cat_royal_hurt2.ogg +1 -0
  46. package/dist/cat-sounds/Cat_royal_hurt3.ogg +1 -0
  47. package/dist/cat-sounds/Stray_cat_idle1.ogg +1 -0
  48. package/dist/cat-sounds/Stray_cat_idle2.ogg +1 -0
  49. package/dist/cat-sounds/Stray_cat_idle3.ogg +1 -0
  50. package/dist/cat-sounds/Stray_cat_idle4.ogg +1 -0
  51. package/dist/chunks/skin-sheets-CG0yKeZb.js +71 -0
  52. package/dist/chunks/vanilla-CUrawvWx.js +2993 -0
  53. package/dist/index.js +286 -0
  54. package/dist/solid.js +17 -0
  55. package/dist/svelte/Oneko.svelte +17 -0
  56. package/dist/svelte/Oneko.svelte.d.ts +4 -0
  57. package/dist/types/components/laser-cursor.d.ts +3 -0
  58. package/dist/types/components/oneko.d.ts +11 -0
  59. package/dist/types/hooks/use-cat-animation.d.ts +23 -0
  60. package/dist/types/hooks/use-motion-allowed.d.ts +3 -0
  61. package/dist/types/hooks/use-oneko-props-sync.d.ts +14 -0
  62. package/dist/types/hooks/use-skin-source.d.ts +3 -0
  63. package/dist/types/hooks/use-sprite-appearance.d.ts +6 -0
  64. package/dist/types/lib/oneko/animation/activity.d.ts +5 -0
  65. package/dist/types/lib/oneko/animation/attention.d.ts +13 -0
  66. package/dist/types/lib/oneko/animation/bubbles.d.ts +5 -0
  67. package/dist/types/lib/oneko/animation/debug-render.d.ts +5 -0
  68. package/dist/types/lib/oneko/animation/deps.d.ts +21 -0
  69. package/dist/types/lib/oneko/animation/frame/interrupt-idle.d.ts +2 -0
  70. package/dist/types/lib/oneko/animation/frame/tick-laser.d.ts +2 -0
  71. package/dist/types/lib/oneko/animation/frame/tick-live-state.d.ts +3 -0
  72. package/dist/types/lib/oneko/animation/frame/tick-movement.d.ts +2 -0
  73. package/dist/types/lib/oneko/animation/frame/tick-prelude.d.ts +2 -0
  74. package/dist/types/lib/oneko/animation/frame/tick-sounds.d.ts +3 -0
  75. package/dist/types/lib/oneko/animation/frame.d.ts +2 -0
  76. package/dist/types/lib/oneko/animation/grid.d.ts +3 -0
  77. package/dist/types/lib/oneko/animation/idle.d.ts +4 -0
  78. package/dist/types/lib/oneko/animation/mouse.d.ts +2 -0
  79. package/dist/types/lib/oneko/animation/movement.d.ts +3 -0
  80. package/dist/types/lib/oneko/animation/sprites.d.ts +5 -0
  81. package/dist/types/lib/oneko/animation-loop.d.ts +5 -0
  82. package/dist/types/lib/oneko/constants.d.ts +118 -0
  83. package/dist/types/lib/oneko/debug-controls/bubble.d.ts +4 -0
  84. package/dist/types/lib/oneko/debug-controls/force-state.d.ts +4 -0
  85. package/dist/types/lib/oneko/debug-controls/index.d.ts +14 -0
  86. package/dist/types/lib/oneko/debug-controls/playback.d.ts +4 -0
  87. package/dist/types/lib/oneko/debug-controls/position.d.ts +4 -0
  88. package/dist/types/lib/oneko/debug-controls/speed.d.ts +4 -0
  89. package/dist/types/lib/oneko/debug-controls/ui.d.ts +5 -0
  90. package/dist/types/lib/oneko/defaults.d.ts +39 -0
  91. package/dist/types/lib/oneko/dom.d.ts +10 -0
  92. package/dist/types/lib/oneko/initial-state.d.ts +9 -0
  93. package/dist/types/lib/oneko/konami.d.ts +4 -0
  94. package/dist/types/lib/oneko/laser-cursor-dom.d.ts +1 -0
  95. package/dist/types/lib/oneko/obstacle-filters.d.ts +12 -0
  96. package/dist/types/lib/oneko/pack.d.ts +12 -0
  97. package/dist/types/lib/oneko/pathfinding.d.ts +6 -0
  98. package/dist/types/lib/oneko/persistence.d.ts +18 -0
  99. package/dist/types/lib/oneko/runtime-config.d.ts +28 -0
  100. package/dist/types/lib/oneko/skin-catalog.d.ts +98 -0
  101. package/dist/types/lib/oneko/skin-classic.json.d.ts +4 -0
  102. package/dist/types/lib/oneko/skin-sheets.json.d.ts +27 -0
  103. package/dist/types/lib/oneko/skins.d.ts +14 -0
  104. package/dist/types/lib/oneko/start-cat-animation.d.ts +24 -0
  105. package/dist/types/lib/oneko/teardown.d.ts +17 -0
  106. package/dist/types/lib/oneko/types.d.ts +183 -0
  107. package/dist/types/lib/oneko/vanilla.d.ts +13 -0
  108. package/dist/types/lib/oneko/zone-runtime.d.ts +20 -0
  109. package/dist/types/lib/oneko/zones.d.ts +26 -0
  110. package/dist/types/packages/oneko/src/adapter.d.ts +3 -0
  111. package/dist/types/packages/oneko/src/index.d.ts +3 -0
  112. package/dist/types/packages/oneko/src/solid.d.ts +3 -0
  113. package/dist/types/packages/oneko/src/vanilla.d.ts +7 -0
  114. package/dist/types/packages/oneko/src/vue.d.ts +173 -0
  115. package/dist/vanilla.d.ts +1 -0
  116. package/dist/vanilla.js +9 -0
  117. package/dist/vue.js +71 -0
  118. package/package.json +82 -4
@@ -0,0 +1,14 @@
1
+ import type { CatRuntimeState } from "../types";
2
+ export interface DebugControlsParams {
3
+ stateRef: {
4
+ current: CatRuntimeState;
5
+ };
6
+ el: HTMLDivElement;
7
+ bubbleEl: HTMLDivElement;
8
+ bubbleTextEl: HTMLDivElement;
9
+ frame: () => void;
10
+ showBubble: () => void;
11
+ hideBubble: () => void;
12
+ bubbleDisplayFrames: number;
13
+ }
14
+ export declare function createDebugControls({ stateRef, el, bubbleEl, bubbleTextEl, frame, showBubble, hideBubble, bubbleDisplayFrames, }: DebugControlsParams): HTMLDivElement;
@@ -0,0 +1,4 @@
1
+ import type { CatRuntimeState } from "../types";
2
+ export declare function appendPlaybackSection(body: HTMLElement, stateRef: {
3
+ current: CatRuntimeState;
4
+ }, frame: () => void): void;
@@ -0,0 +1,4 @@
1
+ import type { CatRuntimeState } from "../types";
2
+ export declare function appendPositionSection(body: HTMLElement, stateRef: {
3
+ current: CatRuntimeState;
4
+ }, el: HTMLDivElement): void;
@@ -0,0 +1,4 @@
1
+ import type { CatRuntimeState } from "../types";
2
+ export declare function appendSpeedSection(body: HTMLElement, stateRef: {
3
+ current: CatRuntimeState;
4
+ }): void;
@@ -0,0 +1,5 @@
1
+ export declare const BASE_STYLE: string;
2
+ export declare const selectStyle: string;
3
+ export declare function sectionLabel(text: string): HTMLDivElement;
4
+ export declare function makeRow(...children: HTMLElement[]): HTMLDivElement;
5
+ export declare function makeBtn(label: string, onClick: () => void): HTMLButtonElement;
@@ -0,0 +1,39 @@
1
+ import type { OnekoProps } from "./types";
2
+ export declare const ONEKO_DEFAULTS: {
3
+ paused: boolean;
4
+ followCursor: boolean;
5
+ sleepEnabled: boolean;
6
+ bubblePlacement: NonNullable<OnekoProps["bubblePlacement"]>;
7
+ bubbleScale: number;
8
+ soundBasePath: string;
9
+ storageKey: string;
10
+ zoneAttractionChance: number;
11
+ zoneAttractionDuration: number;
12
+ skin: NonNullable<OnekoProps["skin"]>;
13
+ persistPosition: boolean;
14
+ reducedMotion: NonNullable<OnekoProps["reducedMotion"]>;
15
+ zIndex: number;
16
+ speed: number;
17
+ scale: number;
18
+ opacity: number;
19
+ rotationAmount: number;
20
+ idleThreshold: number;
21
+ meow: boolean;
22
+ freerunChance: number;
23
+ freerunDuration: number;
24
+ bubbleEnabled: boolean;
25
+ bubbleDisplayFrames: number;
26
+ bubbleCooldown: number;
27
+ hueRotate: number;
28
+ bubbleChance: number;
29
+ followDistance: number;
30
+ animationSpeed: number;
31
+ bubbleText: string;
32
+ volume: number;
33
+ laserPointer: boolean;
34
+ chase: NonNullable<OnekoProps["chase"]>;
35
+ napWhileTyping: boolean;
36
+ followFocus: boolean;
37
+ perchOnHover: boolean;
38
+ pettable: boolean;
39
+ };
@@ -0,0 +1,10 @@
1
+ import type { CatRuntimeState } from "./types";
2
+ export interface BubbleElements {
3
+ wrapper: HTMLDivElement;
4
+ textEl: HTMLDivElement;
5
+ tailWrap: HTMLDivElement;
6
+ }
7
+ export declare function createCatElement(state: CatRuntimeState, zIndex: number): HTMLDivElement;
8
+ export declare function createDebugSVG(zIndex: number): SVGSVGElement;
9
+ export declare function createBubble(zIndex: number): BubbleElements;
10
+ export declare function createDebugHUD(): HTMLDivElement;
@@ -0,0 +1,9 @@
1
+ import { type CatRuntimeConfig } from "./runtime-config";
2
+ import type { CatRuntimeState } from "./types";
3
+ export type InitialCatStateOptions = CatRuntimeConfig & {
4
+ initialPos?: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ };
9
+ export declare function createInitialCatState(options: InitialCatStateOptions): CatRuntimeState;
@@ -0,0 +1,4 @@
1
+ import type { CatRuntimeState } from "./types";
2
+ export declare function createKonamiHandler(stateRef: {
3
+ current: CatRuntimeState;
4
+ }, debugSVG: SVGSVGElement, debugWrapper: HTMLDivElement): (e: KeyboardEvent) => void;
@@ -0,0 +1 @@
1
+ export declare function mountLaserCursor(zIndex: number): () => void;
@@ -0,0 +1,12 @@
1
+ import type { ObstacleRect } from "./types";
2
+ type RectLike = {
3
+ left: number;
4
+ top: number;
5
+ right: number;
6
+ bottom: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ export declare function shouldIncludeObstacleRect(rect: RectLike, viewportWidth: number, viewportHeight: number): boolean;
11
+ export declare function toObstacleRect(rect: RectLike): ObstacleRect;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { CatRuntimeState, PathPoint } from "./types";
2
+ export declare function joinPack(state: CatRuntimeState): () => void;
3
+ /** Where the cat ahead of this one is, or null when it leads (or chases the cursor). */
4
+ export declare function leaderPosition(state: CatRuntimeState): PathPoint | null;
5
+ /** True when another cat is asleep close enough to curl up next to. */
6
+ export declare function napmateNearby(state: CatRuntimeState): boolean;
7
+ /** Visitor preference, shared by every cat on the site and remembered across visits. */
8
+ export declare const HIDDEN_STORAGE_KEY = "oneko:hidden";
9
+ export declare function areCatsHidden(): boolean;
10
+ export declare function setCatsHidden(hidden: boolean): void;
11
+ /** Calls back when cats are hidden or shown, in this tab or another one. */
12
+ export declare function onCatsHiddenChange(callback: () => void): () => void;
@@ -0,0 +1,6 @@
1
+ import type { ObstacleRect, PathPoint } from "./types";
2
+ export declare function collectObstacles(): ObstacleRect[];
3
+ export declare function buildGrid(rects: ObstacleRect[], cols: number, rows: number): Uint8Array;
4
+ export declare function worldToCell(worldX: number, worldY: number, cols: number, rows: number): number;
5
+ export declare function nearestWalkable(startIdx: number, grid: Uint8Array, cols: number, rows: number): number;
6
+ export declare function findRoute(startIdx: number, goalIdx: number, grid: Uint8Array, cols: number, rows: number): PathPoint[];
@@ -0,0 +1,18 @@
1
+ import type { CatRuntimeState } from "./types";
2
+ export type PersistedPosition = {
3
+ version: 1;
4
+ x: number;
5
+ y: number;
6
+ };
7
+ export declare function parsePersistedPosition(value: unknown): PersistedPosition | null;
8
+ /** Saved position clamped to the viewport, or null when absent or invalid. */
9
+ export declare function readPersistedPosition(storageKey?: string): {
10
+ x: number;
11
+ y: number;
12
+ } | null;
13
+ export declare function loadPersistedCatState(stateRef: {
14
+ current: CatRuntimeState;
15
+ }, el: HTMLDivElement, storageKey?: string): void;
16
+ export declare function createPersistHandler(stateRef: {
17
+ current: CatRuntimeState;
18
+ }, storageKey?: string): () => void;
@@ -0,0 +1,28 @@
1
+ import type { OnekoZone } from "./zones";
2
+ import type { CatRuntimeState, OnekoProps } from "./types";
3
+ type RuntimeConfigStateFields = Pick<CatRuntimeState, "pausedCfg" | "followCursorCfg" | "sleepEnabledCfg" | "bubblePlacementCfg" | "bubbleScaleCfg" | "soundBasePathCfg" | "currentSpeed" | "scale" | "opacity" | "rotationAmount" | "idleThresholdMs" | "freerunChanceCfg" | "freerunDurationCfg" | "bubbleEnabledCfg" | "bubbleDisplayFramesCfg" | "bubbleCooldownFramesCfg" | "bubbleChanceCfg" | "followDistanceCfg" | "animationSpeedCfg" | "customBubbleText" | "currentRotation" | "enableMeow" | "soundVolumeCfg" | "soundCooldown" | "bubbleTimer" | "bubbleCooldown" | "bubbleVisible" | "lastBubbleMsg" | "laserPointerCfg" | "laserCaught" | "chaseCfg" | "napWhileTypingCfg" | "followFocusCfg" | "perchOnHoverCfg">;
4
+ export declare function defaultRuntimeConfigState(): RuntimeConfigStateFields;
5
+ export type CatRuntimeConfig = Pick<OnekoProps, "paused" | "followCursor" | "sleepEnabled" | "bubblePlacement" | "bubbleScale" | "soundBasePath" | "chase" | "napWhileTyping" | "followFocus" | "perchOnHover"> & {
6
+ zones?: readonly OnekoZone[];
7
+ zoneAttractionChance?: number;
8
+ zoneAttractionDuration?: number;
9
+ speed: number;
10
+ scale: number;
11
+ opacity: number;
12
+ rotationAmount: number;
13
+ idleThreshold: number;
14
+ freerunChance: number;
15
+ freerunDuration: number;
16
+ bubbleEnabled: boolean;
17
+ bubbleDisplayFrames: number;
18
+ bubbleCooldown: number;
19
+ bubbleChance: number;
20
+ followDistance: number;
21
+ animationSpeed: number;
22
+ bubbleText: NonNullable<OnekoProps["bubbleText"]>;
23
+ meow: boolean;
24
+ volume: number;
25
+ laserPointer: boolean;
26
+ };
27
+ export declare function applyRuntimeConfig(state: CatRuntimeState, config: CatRuntimeConfig): void;
28
+ export {};
@@ -0,0 +1,98 @@
1
+ /** Labels stay independent of the bundled sheets so registry variants share one implementation. */
2
+ export declare const SKIN_CATALOG: readonly [{
3
+ readonly id: "classic";
4
+ readonly name: "Classic";
5
+ readonly description: "The little cat that started it all";
6
+ }, {
7
+ readonly id: "black";
8
+ readonly name: "Black";
9
+ readonly description: "A tiny midnight shadow";
10
+ }, {
11
+ readonly id: "gray";
12
+ readonly name: "Gray";
13
+ readonly description: "Soft fur, softer footsteps";
14
+ }, {
15
+ readonly id: "calico";
16
+ readonly name: "Calico";
17
+ readonly description: "A patchwork of mischief";
18
+ }, {
19
+ readonly id: "tora";
20
+ readonly name: "Tora";
21
+ readonly description: "A little tiger at heart";
22
+ }, {
23
+ readonly id: "catppuccin";
24
+ readonly name: "Catppuccin";
25
+ readonly description: "A warm cup of cat";
26
+ }, {
27
+ readonly id: "ghost";
28
+ readonly name: "Ghost";
29
+ readonly description: "A pleasantly spooky companion";
30
+ }, {
31
+ readonly id: "silver";
32
+ readonly name: "Silver";
33
+ readonly description: "Moonlight on little paws";
34
+ }, {
35
+ readonly id: "spirit";
36
+ readonly name: "Spirit";
37
+ readonly description: "A curious little daydream";
38
+ }, {
39
+ readonly id: "valentine";
40
+ readonly name: "Valentine";
41
+ readonly description: "Wears a heart on every paw";
42
+ }, {
43
+ readonly id: "maia";
44
+ readonly name: "Maia";
45
+ readonly description: "Small paws, big personality";
46
+ }, {
47
+ readonly id: "vaporwave";
48
+ readonly name: "Vaporwave";
49
+ readonly description: "Dreaming in pink and purple";
50
+ }, {
51
+ readonly id: "ginger";
52
+ readonly name: "Ginger";
53
+ readonly description: "Golden fur and cream-colored paws";
54
+ }, {
55
+ readonly id: "sage";
56
+ readonly name: "Sage";
57
+ readonly description: "A little garden companion";
58
+ }, {
59
+ readonly id: "siamese";
60
+ readonly name: "Siamese";
61
+ readonly description: "Chocolate points and bright blue eyes";
62
+ }, {
63
+ readonly id: "strawberry-milk";
64
+ readonly name: "Strawberry Milk";
65
+ readonly description: "Soft pink with a splash of cream";
66
+ }, {
67
+ readonly id: "blue-frost";
68
+ readonly name: "Blue Frost";
69
+ readonly description: "Snowy paws and an icy blue coat";
70
+ }, {
71
+ readonly id: "lavender";
72
+ readonly name: "Lavender";
73
+ readonly description: "Lilac fur and a little daydream";
74
+ }, {
75
+ readonly id: "tuxedo";
76
+ readonly name: "Tuxedo";
77
+ readonly description: "Dressed up in a white bib and socks";
78
+ }, {
79
+ readonly id: "peach";
80
+ readonly name: "Peach";
81
+ readonly description: "Apricot fur with a touch of vanilla";
82
+ }, {
83
+ readonly id: "honey";
84
+ readonly name: "Honey";
85
+ readonly description: "Golden fur and a sunny disposition";
86
+ }, {
87
+ readonly id: "mocha";
88
+ readonly name: "Mocha";
89
+ readonly description: "Cocoa fur with a splash of milk";
90
+ }, {
91
+ readonly id: "mint";
92
+ readonly name: "Mint";
93
+ readonly description: "Fresh turquoise and snowy little paws";
94
+ }, {
95
+ readonly id: "midnight-blue";
96
+ readonly name: "Midnight Blue";
97
+ readonly description: "Navy fur with a silver lining";
98
+ }];
@@ -0,0 +1,4 @@
1
+ declare const sheets: {
2
+ "classic": string;
3
+ };
4
+ export = sheets;
@@ -0,0 +1,27 @@
1
+ declare const sheets: {
2
+ "classic": string;
3
+ "black": string;
4
+ "gray": string;
5
+ "calico": string;
6
+ "tora": string;
7
+ "catppuccin": string;
8
+ "ghost": string;
9
+ "silver": string;
10
+ "spirit": string;
11
+ "valentine": string;
12
+ "maia": string;
13
+ "vaporwave": string;
14
+ "ginger": string;
15
+ "sage": string;
16
+ "siamese": string;
17
+ "strawberry-milk": string;
18
+ "blue-frost": string;
19
+ "lavender": string;
20
+ "tuxedo": string;
21
+ "peach": string;
22
+ "honey": string;
23
+ "mocha": string;
24
+ "mint": string;
25
+ "midnight-blue": string;
26
+ };
27
+ export = sheets;
@@ -0,0 +1,14 @@
1
+ import { SKIN_CATALOG } from "./skin-catalog";
2
+ /** Type-only: the sheets themselves load on demand in `loadSkinSource`. */
3
+ export type OnekoSkin = keyof typeof import("./skin-sheets.json");
4
+ type AvailableSkin = Extract<(typeof SKIN_CATALOG)[number], {
5
+ id: OnekoSkin;
6
+ }>;
7
+ /** Only expose coats included in this installation. See docs/oneko-skins.md for credits. */
8
+ export declare const ONEKO_SKINS: AvailableSkin[];
9
+ export declare function isOnekoSkin(value: unknown): value is OnekoSkin;
10
+ /** Sprite sheet for a skin if it is ready, otherwise undefined. Unknown IDs use classic. */
11
+ export declare function getSkinSource(skin?: OnekoSkin): string | undefined;
12
+ /** Resolve a skin's sprite sheet, loading the bundled sheets once when needed. */
13
+ export declare function loadSkinSource(skin?: OnekoSkin): Promise<string>;
14
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { CatActivityState, CatLiveState, CatRuntimeState } from "./types";
2
+ export interface StartCatAnimationOptions {
3
+ stateRef: {
4
+ current: CatRuntimeState;
5
+ };
6
+ elRef: {
7
+ current: HTMLDivElement | null;
8
+ };
9
+ lastStateRef: {
10
+ current: CatActivityState;
11
+ };
12
+ onStateChangeRef: {
13
+ current: ((state: CatActivityState) => void) | undefined;
14
+ };
15
+ liveStateRef?: {
16
+ current: CatLiveState;
17
+ };
18
+ persistPosition: boolean;
19
+ storageKey?: string;
20
+ zIndex: number;
21
+ /** Make the cat a keyboard-reachable "Pet the cat" button. */
22
+ pettable?: boolean;
23
+ }
24
+ export declare function startCatAnimation({ stateRef, elRef, lastStateRef, onStateChangeRef, liveStateRef, persistPosition, storageKey, zIndex, pettable, }: StartCatAnimationOptions): () => void;
@@ -0,0 +1,17 @@
1
+ type CatAnimationElements = {
2
+ el: HTMLDivElement;
3
+ debugSVG: SVGSVGElement;
4
+ debugWrapper: HTMLDivElement;
5
+ bubbleEl: HTMLDivElement;
6
+ };
7
+ type CatAnimationListeners = {
8
+ onMouseMove: (ev: MouseEvent) => void;
9
+ onPointerDown: (event: PointerEvent) => void;
10
+ onKeyDown: (e: KeyboardEvent) => void;
11
+ invalidateObstacles: () => void;
12
+ persist: (() => void) | null;
13
+ onVisibilityChange: () => void;
14
+ stopAnimationLoop: () => void;
15
+ };
16
+ export declare function teardownCatAnimation({ el, debugSVG, debugWrapper, bubbleEl }: CatAnimationElements, { onMouseMove, onPointerDown, onKeyDown, invalidateObstacles, persist, onVisibilityChange, stopAnimationLoop, }: CatAnimationListeners): void;
17
+ export {};
@@ -0,0 +1,183 @@
1
+ import type { OnekoZone } from "./zones";
2
+ import type { ZoneRuntimeState } from "./zone-runtime";
3
+ import type { OnekoSkin } from "./skins";
4
+ export type CatActivityState = "idle" | "moving" | "sleeping" | "scratchSelf" | "tired" | "alert" | "scratchWallN" | "scratchWallS" | "scratchWallE" | "scratchWallW" | "freerun";
5
+ export type IdleActivityState = Exclude<CatActivityState, "idle" | "moving" | "freerun">;
6
+ export interface CatLiveState {
7
+ state: CatActivityState;
8
+ posX: number;
9
+ posY: number;
10
+ velMag: number;
11
+ idleTime: number;
12
+ distToMouse: number;
13
+ frameCount: number;
14
+ freerunActive: boolean;
15
+ freerunTimer: number;
16
+ bubbleVisible: boolean;
17
+ pathLength: number;
18
+ obstacleCount: number;
19
+ }
20
+ export interface OnekoProps {
21
+ /** Freeze animation in place without unmounting. Default false. */
22
+ paused?: boolean;
23
+ /** Chase the pointer and visit favorite spots. False keeps the cat resting in place. Default true. */
24
+ followCursor?: boolean;
25
+ /** Allow the cat to nap while idle. Default true. */
26
+ sleepEnabled?: boolean;
27
+ /** Preferred bubble side; auto chooses the side with room. Default auto. */
28
+ bubblePlacement?: "auto" | "above" | "below";
29
+ /** Bubble size multiplier, in addition to scale (0.5–2). Default 1. */
30
+ bubbleScale?: number;
31
+ /** Directory URL for the optional .ogg sounds. Default /cat-sounds. */
32
+ soundBasePath?: string;
33
+ /** localStorage key for position persistence. Default oneko. */
34
+ storageKey?: string;
35
+ /** Strict keep-out areas and occasional favorite spots. DOM data-oneko-zone attributes also work. */
36
+ zones?: readonly OnekoZone[];
37
+ /** Chance to visit a favorite at each five-second check (0–1). Default 0.3. */
38
+ zoneAttractionChance?: number;
39
+ /** Time spent pursuing a favorite, in milliseconds. Default 4000. */
40
+ zoneAttractionDuration?: number;
41
+ /** Built-in pixel-art skin. Default classic. */
42
+ skin?: OnekoSkin;
43
+ /** Custom 256×128 sprite-sheet URL using the classic 8×4 layout. Overrides skin. */
44
+ spriteSrc?: string;
45
+ persistPosition?: boolean;
46
+ zIndex?: number;
47
+ initialPos?: {
48
+ x: number;
49
+ y: number;
50
+ };
51
+ speed?: number;
52
+ scale?: number;
53
+ opacity?: number;
54
+ rotationAmount?: number;
55
+ idleThreshold?: number;
56
+ /** Enable optional sound assets supplied by the host app. Default false. */
57
+ meow?: boolean;
58
+ onStateChange?: (state: CatActivityState) => void;
59
+ /** Probability per frame cat enters freerun mode (0–1). Default 0.06 */
60
+ freerunChance?: number;
61
+ /** Duration of freerun in frames. Default 40 */
62
+ freerunDuration?: number;
63
+ /** Whether chat bubbles are enabled. Default true */
64
+ bubbleEnabled?: boolean;
65
+ /** How many frames a bubble stays visible. Default 180 */
66
+ bubbleDisplayFrames?: number;
67
+ /** Cooldown frames between bubbles. Default 120 */
68
+ bubbleCooldown?: number;
69
+ /** CSS hue-rotate degrees (0–360). Default 0 */
70
+ hueRotate?: number;
71
+ /** Mutable ref that oneko writes live state to every frame */
72
+ liveStateRef?: {
73
+ current: CatLiveState;
74
+ };
75
+ /** Bubble trigger probability while idle (0–1). Default 0.5 */
76
+ bubbleChance?: number;
77
+ /** Distance in px at which cat stops chasing cursor. Default 20 */
78
+ followDistance?: number;
79
+ /** Multiplier for idle animation speed (0.5–2). Default 1 */
80
+ animationSpeed?: number;
81
+ /** Custom awake bubble text, or a pool of thoughts picked without immediate repeats. */
82
+ bubbleText?: string | readonly string[];
83
+ /** Sound volume (0–1). Default 0.5 */
84
+ volume?: number;
85
+ /** Show a red laser dot in place of the system cursor. Default false */
86
+ laserPointer?: boolean;
87
+ /** With reduced motion: "hide" the cat, or let it "rest" as a still, sleeping sprite. Default "hide" */
88
+ reducedMotion?: "hide" | "rest";
89
+ /** What to chase: the cursor, or the cat mounted just before this one. Default "cursor" */
90
+ chase?: "cursor" | "cat";
91
+ /** Doze off while the visitor types in a field; wake on the next pointer move. Default false */
92
+ napWhileTyping?: boolean;
93
+ /** Walk over to whatever receives keyboard focus. Default false */
94
+ followFocus?: boolean;
95
+ /** Sit on a link or button after the pointer rests on it. Default false */
96
+ perchOnHover?: boolean;
97
+ /** Make the cat a keyboard-reachable "Pet the cat" button. Default false */
98
+ pettable?: boolean;
99
+ }
100
+ export interface ObstacleRect {
101
+ left: number;
102
+ top: number;
103
+ right: number;
104
+ bottom: number;
105
+ }
106
+ export interface PathPoint {
107
+ x: number;
108
+ y: number;
109
+ }
110
+ export interface CatRuntimeState {
111
+ zoneState: ZoneRuntimeState;
112
+ nekoPosX: number;
113
+ nekoPosY: number;
114
+ nekoVelX: number;
115
+ nekoVelY: number;
116
+ mousePosX: number;
117
+ mousePosY: number;
118
+ frameCount: number;
119
+ idleTime: number;
120
+ idleAnimation: IdleActivityState | null;
121
+ idleAnimationFrame: number;
122
+ obstacleRects: ObstacleRect[];
123
+ lastObstacleRefresh: number;
124
+ grid: Uint8Array | null;
125
+ gridCols: number;
126
+ gridRows: number;
127
+ currentPath: PathPoint[];
128
+ pathWaypointIdx: number;
129
+ lastPathRecalcFrame: number;
130
+ lastPathTargetCol: number;
131
+ lastPathTargetRow: number;
132
+ debugMode: boolean;
133
+ paused: boolean;
134
+ pausedCfg: boolean;
135
+ followCursorCfg: boolean;
136
+ sleepEnabledCfg: boolean;
137
+ bubblePlacementCfg: NonNullable<OnekoProps["bubblePlacement"]>;
138
+ bubbleScaleCfg: number;
139
+ soundBasePathCfg: string;
140
+ stateLocked: boolean;
141
+ noFollow: boolean;
142
+ currentSpeed: number;
143
+ scale: number;
144
+ opacity: number;
145
+ rotationAmount: number;
146
+ idleThresholdMs: number;
147
+ freerunChanceCfg: number;
148
+ freerunDurationCfg: number;
149
+ bubbleEnabledCfg: boolean;
150
+ bubbleDisplayFramesCfg: number;
151
+ bubbleCooldownFramesCfg: number;
152
+ bubbleChanceCfg: number;
153
+ followDistanceCfg: number;
154
+ animationSpeedCfg: number;
155
+ customBubbleText: string | readonly string[];
156
+ currentRotation: number;
157
+ enableMeow: boolean;
158
+ soundVolumeCfg: number;
159
+ soundCooldown: number;
160
+ bubbleTimer: number;
161
+ bubbleCooldown: number;
162
+ bubbleVisible: boolean;
163
+ lastBubbleMsg: number;
164
+ loopPrevAngle: number | null;
165
+ mouseCircleWinding: number;
166
+ freerunMode: boolean;
167
+ freerunTimer: number;
168
+ lastFreerunMsg: number;
169
+ laserPointerCfg: boolean;
170
+ laserCaught: boolean;
171
+ chaseCfg: NonNullable<OnekoProps["chase"]>;
172
+ napWhileTypingCfg: boolean;
173
+ followFocusCfg: boolean;
174
+ perchOnHoverCfg: boolean;
175
+ /** Dozing because the visitor is typing; cleared by pointer movement. */
176
+ typingNap: boolean;
177
+ /** Holding still while keyboard focus is on the cat. */
178
+ held: boolean;
179
+ /** Top of the hovered element the cat walks to and sits on. */
180
+ perchTarget: PathPoint | null;
181
+ /** Position of the cat this one chases, when chase is "cat" and one exists. */
182
+ leaderTarget: PathPoint | null;
183
+ }
@@ -0,0 +1,13 @@
1
+ import type { OnekoProps } from "./types";
2
+ export type OnekoOptions = Omit<OnekoProps, "liveStateRef">;
3
+ export interface OnekoInstance {
4
+ /** Merge new options into the running cat; undefined resets one. Engine-level options restart it in place. */
5
+ update(options: OnekoOptions): void;
6
+ /** Remove the cat, bubble, laser, and listeners. Saves the position when persistence is on. */
7
+ destroy(): void;
8
+ }
9
+ /**
10
+ * Mount a cat on document.body. `base` overrides the built-in defaults, so options passed as
11
+ * undefined (now or in a later update) return to the base value.
12
+ */
13
+ export declare function createOneko(initial?: OnekoOptions, base?: OnekoOptions): OnekoInstance;
@@ -0,0 +1,20 @@
1
+ import { type OnekoZone, type ResolvedZone } from "./zones";
2
+ import type { CatRuntimeState, ObstacleRect, PathPoint } from "./types";
3
+ import type { CatAnimationDeps } from "./animation/deps";
4
+ export declare const EMPTY_ZONES: readonly OnekoZone[];
5
+ export type ZoneRuntimeState = {
6
+ definitions: readonly OnekoZone[];
7
+ blocked: ObstacleRect[];
8
+ favorites: ResolvedZone[];
9
+ signature: string;
10
+ targetId: string | null;
11
+ visitFrames: number;
12
+ cooldownFrames: number;
13
+ chance: number;
14
+ duration: number;
15
+ movementTarget: PathPoint;
16
+ };
17
+ export declare function createZoneState(): ZoneRuntimeState;
18
+ export declare function refreshZones(deps: CatAnimationDeps): boolean;
19
+ /** Favorites are sampled every five seconds, with a quiet gap after each visit. */
20
+ export declare function updateZoneTarget(s: CatRuntimeState, width: number, height: number, random?: () => number): void;
@@ -0,0 +1,26 @@
1
+ import type { ObstacleRect, PathPoint } from "./types";
2
+ export type OnekoZone = {
3
+ id: string;
4
+ type: "avoid" | "attract";
5
+ /** CSS selector. All matching visible elements become zones. */
6
+ selector?: string;
7
+ /** Fixed viewport coordinates in CSS pixels; selector takes precedence. */
8
+ rect?: ObstacleRect;
9
+ /** Extra space outside a keep-out zone, in pixels. */
10
+ padding?: number;
11
+ };
12
+ export type ResolvedZone = {
13
+ id: string;
14
+ type: OnekoZone["type"];
15
+ rect: ObstacleRect;
16
+ };
17
+ export declare function isValidRect(rect: ObstacleRect): boolean;
18
+ export declare function expandRect(rect: ObstacleRect, padding: number): ObstacleRect;
19
+ export declare function containsPoint(rect: ObstacleRect, point: PathPoint): boolean;
20
+ /** Conservative radius also protects the corners when a scaled cat tilts. */
21
+ export declare function catZoneRadius(scale: number): number;
22
+ export declare function collectZones(zones: readonly OnekoZone[]): ResolvedZone[];
23
+ /** Find a safe center even when zones overlap or appear around a resting cat. */
24
+ export declare function nearestSafePoint(point: PathPoint, blocked: ObstacleRect[], width: number, height: number, margin: number): PathPoint | null;
25
+ /** Swept collision: a fast cat cannot jump over a thin forbidden zone between ticks. */
26
+ export declare function constrainZoneMovement(from: PathPoint, to: PathPoint, blocked: ObstacleRect[]): PathPoint;
@@ -0,0 +1,3 @@
1
+ import type { OnekoInstance, OnekoOptions } from "./vanilla";
2
+ /** Removed props return to engine defaults, just like a prop explicitly set to undefined. */
3
+ export declare function createPropsUpdater(cat: OnekoInstance): (next: OnekoOptions) => void;
@@ -0,0 +1,3 @@
1
+ export { default, default as Oneko, useCatsHidden } from "../../../components/oneko";
2
+ export type { OnekoProps, CatLiveState } from "../../../lib/oneko/types";
3
+ export * from "./vanilla";
@@ -0,0 +1,3 @@
1
+ import { type OnekoOptions } from "./vanilla";
2
+ export default function Oneko(props: OnekoOptions): null;
3
+ export type { OnekoOptions } from "./vanilla";
@@ -0,0 +1,7 @@
1
+ export { createOneko } from "../../../lib/oneko/vanilla";
2
+ export type { OnekoInstance, OnekoOptions } from "../../../lib/oneko/vanilla";
3
+ export { areCatsHidden, setCatsHidden, onCatsHiddenChange } from "../../../lib/oneko/pack";
4
+ export { ONEKO_SKINS, isOnekoSkin } from "../../../lib/oneko/skins";
5
+ export type { OnekoSkin } from "../../../lib/oneko/skins";
6
+ export type { CatActivityState } from "../../../lib/oneko/types";
7
+ export type { OnekoZone } from "../../../lib/oneko/zones";