neko-vue 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.1.5](https://github.com/AscaL/neko-vue/compare/v0.1.4...v0.1.5) (2026-04-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * implement viewport clamping for Neko sprite and enhance resize handling with tests ([086d2ca](https://github.com/AscaL/neko-vue/commit/086d2caddc44afd1043c18c633b9ab02cf505598))
11
+
12
+ ## [0.1.4](https://github.com/AscaL/neko-vue/compare/v0.1.3...v0.1.4) (2026-04-04)
13
+
5
14
  ## [0.1.3](https://github.com/AscaL/neko-vue/compare/v0.1.2...v0.1.3) (2026-04-04)
6
15
 
7
16
  ## [0.1.2](https://github.com/AscaL/neko-vue/compare/v0.1.1...v0.1.2) (2026-04-04)
@@ -1,6 +1,6 @@
1
1
  import { r as BehaviorMode, u as isBehaviorMode } from "./types-De8imAgT.mjs";
2
2
  import { n as resolveStartPosition, r as nekoVueDebug } from "./nekoPlacement-CW-BnKgW.mjs";
3
- import { t as loadNekoRuntime } from "./loadNekoRuntime-DGa5Lkfv.mjs";
3
+ import { t as loadNekoRuntime } from "./loadNekoRuntime-HLkvnBAb.mjs";
4
4
  import { computed, defineComponent, h, onBeforeUnmount, onMounted, readonly, ref, shallowRef, toValue, watch, watchEffect } from "vue";
5
5
  //#region src/utils/prefersReducedMotion.ts
6
6
  /**
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as DEFAULT_NEKO_BEHAVIOR_CYCLE, c as behaviorModeEnumName, i as BehaviorModes, l as formatBehaviorMode, n as BEHAVIOR_MODE_LABELS, o as NEKOJS_SPRITE_SIZE, r as BehaviorMode, s as behaviorCycleOf, t as BEHAVIOR_MODES_IN_ORDER, u as isBehaviorMode } from "./types-De8imAgT.mjs";
2
2
  import { n as resolveStartPosition, r as nekoVueDebug, t as cornerToStartXY } from "./nekoPlacement-CW-BnKgW.mjs";
3
- import { t as loadNekoRuntime } from "./loadNekoRuntime-DGa5Lkfv.mjs";
4
- import { n as useNeko, r as prefersReducedMotion, t as NekoPet_default } from "./NekoPet-Cvcz3rcT.mjs";
3
+ import { t as loadNekoRuntime } from "./loadNekoRuntime-HLkvnBAb.mjs";
4
+ import { n as useNeko, r as prefersReducedMotion, t as NekoPet_default } from "./NekoPet-KnIVLFl7.mjs";
5
5
  export { BEHAVIOR_MODES_IN_ORDER, BEHAVIOR_MODE_LABELS, BehaviorMode, BehaviorModes, DEFAULT_NEKO_BEHAVIOR_CYCLE, NEKOJS_SPRITE_SIZE, NekoPet_default as NekoPet, behaviorCycleOf, behaviorModeEnumName, cornerToStartXY, formatBehaviorMode, isBehaviorMode, loadNekoRuntime, nekoVueDebug, prefersReducedMotion, resolveStartPosition, useNeko };
@@ -12,7 +12,7 @@ let bundledLoadPromise = null;
12
12
  * Dynamically imports the bundled typed runtime (`./nekojsRuntime.ts`). Defines `window.createNeko`.
13
13
  */
14
14
  async function importBundledNeko() {
15
- await import("./nekojsRuntime-Dn8MVVS7.mjs");
15
+ await import("./nekojsRuntime-DgEZfkbs.mjs");
16
16
  const fn = getCreateNekoFromGlobal();
17
17
  if (!fn) throw new Error("neko-vue: bundled neko.js did not define `createNeko`.");
18
18
  return fn;
@@ -142,7 +142,7 @@ var Neko = class {
142
142
  cursorStandoffPx;
143
143
  /** Modes visited in order on each pet mousedown when behavior change is allowed. */
144
144
  behaviorCycle;
145
- /** Spawn / home top-left from `createNeko`; used by return-home behavior (mode 6). */
145
+ /** Spawn / home top-left from `createNeko`; used by return-home behavior (mode 6). Clamped on resize. */
146
146
  homeX;
147
147
  homeY;
148
148
  /**
@@ -172,8 +172,8 @@ var Neko = class {
172
172
  this.oldTargetY = this.y;
173
173
  this.moveDX = 0;
174
174
  this.moveDY = 0;
175
- this.boundsWidth = document.documentElement.clientWidth - SPRITE_SIZE;
176
- this.boundsHeight = window.innerHeight - SPRITE_SIZE;
175
+ this.boundsWidth = Math.max(0, document.documentElement.clientWidth - SPRITE_SIZE);
176
+ this.boundsHeight = Math.max(0, window.innerHeight - SPRITE_SIZE);
177
177
  this.mouseX = null;
178
178
  this.mouseY = null;
179
179
  this.hasMouseMoved = false;
@@ -207,6 +207,38 @@ var Neko = class {
207
207
  this.ballVY = 0;
208
208
  this.init();
209
209
  }
210
+ /**
211
+ * Keeps the sprite, home, chase targets, and ball inside the viewport after `innerWidth` /
212
+ * `innerHeight` change. Without this, a still pet (or `stop()`ped `rest` mode) can remain off-screen
213
+ * with no ticks to clamp position.
214
+ */
215
+ clampLayoutToViewport() {
216
+ const bw = Math.max(0, document.documentElement.clientWidth - SPRITE_SIZE);
217
+ const bh = Math.max(0, window.innerHeight - SPRITE_SIZE);
218
+ this.boundsWidth = bw;
219
+ this.boundsHeight = bh;
220
+ const clamp = (v, max) => max <= 0 ? 0 : Math.max(0, Math.min(max, v));
221
+ this.homeX = clamp(this.homeX, bw);
222
+ this.homeY = clamp(this.homeY, bh);
223
+ this.logicX = clamp(this.logicX, bw);
224
+ this.logicY = clamp(this.logicY, bh);
225
+ this.prevLogicX = this.logicX;
226
+ this.prevLogicY = this.logicY;
227
+ this.x = this.logicX;
228
+ this.y = this.logicY;
229
+ this.tickAccumulator = 0;
230
+ const footX = this.logicX + SPRITE_SIZE / 2;
231
+ const footY = this.logicY + SPRITE_SIZE - 1;
232
+ this.targetX = footX;
233
+ this.targetY = footY;
234
+ this.oldTargetX = footX;
235
+ this.oldTargetY = footY;
236
+ if (!(this.ballX === 0 && this.ballY === 0)) {
237
+ this.ballX = clamp(this.ballX, bw);
238
+ this.ballY = clamp(this.ballY, bh);
239
+ }
240
+ this.updatePosition();
241
+ }
210
242
  init() {
211
243
  this.element = document.createElement("div");
212
244
  this.element.className = "neko";
@@ -260,10 +292,7 @@ var Neko = class {
260
292
  this.mouseY = e.clientY;
261
293
  this.hasMouseMoved = true;
262
294
  }, { signal });
263
- window.addEventListener("resize", () => {
264
- this.boundsWidth = document.documentElement.clientWidth - SPRITE_SIZE;
265
- this.boundsHeight = window.innerHeight - SPRITE_SIZE;
266
- }, { signal });
295
+ window.addEventListener("resize", () => this.clampLayoutToViewport(), { signal });
267
296
  this.targetX = this.x + SPRITE_SIZE / 2;
268
297
  this.targetY = this.y + SPRITE_SIZE - 1;
269
298
  this.oldTargetX = this.targetX;
package/dist/runtime.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as loadNekoRuntime } from "./loadNekoRuntime-DGa5Lkfv.mjs";
1
+ import { t as loadNekoRuntime } from "./loadNekoRuntime-HLkvnBAb.mjs";
2
2
  export { loadNekoRuntime };
package/dist/vue.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as useNeko, t as NekoPet_default } from "./NekoPet-Cvcz3rcT.mjs";
1
+ import { n as useNeko, t as NekoPet_default } from "./NekoPet-KnIVLFl7.mjs";
2
2
  export { NekoPet_default as NekoPet, useNeko };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neko-vue",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Vue 3 desktop pet — typed runtime, composable, and NekoPet component.",
5
5
  "keywords": [
6
6
  "composable",