svelte-adapter-uws 0.4.2 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-adapter-uws",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "SvelteKit adapter for uWebSockets.js - high-performance C++ HTTP server with built-in WebSocket support",
5
5
  "author": "Kevin Radziszewski",
6
6
  "license": "MIT",
@@ -97,7 +97,7 @@ export function cursor(topic, options) {
97
97
  targets.delete(key);
98
98
  continue;
99
99
  }
100
- entry.data = { ...entry.data, x: entry.data.x + dx * 0.3, y: entry.data.y + dy * 0.3 };
100
+ entry.data = { ...entry.data, x: entry.data.x + dx * 0.5, y: entry.data.y + dy * 0.5 };
101
101
  changed = true;
102
102
  }
103
103
  if (changed) output.set(new Map(cursorMap));
@@ -131,13 +131,21 @@ export function cursor(topic, options) {
131
131
  const { key, user, data } = event.data;
132
132
  timestamps.set(key, Date.now());
133
133
  if (interpolate && typeof data?.x === 'number' && typeof data?.y === 'number') {
134
- if (!cursorMap.has(key)) {
134
+ const existing = cursorMap.get(key);
135
+ if (!existing) {
135
136
  cursorMap.set(key, { user, data });
136
- output.set(new Map(cursorMap));
137
137
  } else {
138
- cursorMap.get(key).user = user;
138
+ const dx = data.x - existing.data.x;
139
+ const dy = data.y - existing.data.y;
140
+ existing.user = user;
141
+ existing.data = {
142
+ ...existing.data,
143
+ x: existing.data.x + dx * 0.5,
144
+ y: existing.data.y + dy * 0.5
145
+ };
139
146
  }
140
147
  targets.set(key, { x: data.x, y: data.y });
148
+ output.set(new Map(cursorMap));
141
149
  if (rafId === null) rafId = requestAnimationFrame(tick);
142
150
  } else {
143
151
  cursorMap.set(key, { user, data });