@abraca/nuxt 2.53.0 → 2.54.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/dist/module.json
CHANGED
|
@@ -39,12 +39,14 @@ function computeViewportBlobs() {
|
|
|
39
39
|
}
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
|
+
const MAX_BLOBS = 16;
|
|
42
43
|
function computeWorldBlobs() {
|
|
43
44
|
const toScreen = props.toScreen;
|
|
44
45
|
if (!toScreen) return [];
|
|
45
46
|
const localId = provider.value?.awareness?.clientID;
|
|
46
47
|
const out = [];
|
|
47
48
|
for (const peer of worldStates.value) {
|
|
49
|
+
if (out.length >= MAX_BLOBS) break;
|
|
48
50
|
if (peer.clientId === localId) continue;
|
|
49
51
|
const raw = peer[props.worldChannel];
|
|
50
52
|
if (!raw || typeof raw !== "object") continue;
|
|
@@ -71,8 +73,13 @@ function isOffscreen(x, y) {
|
|
|
71
73
|
return x < -180 || y < -180 || x > vw + 180 || y > vh + 180;
|
|
72
74
|
}
|
|
73
75
|
let raf = 0;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
const WORLD_TICK_MS = 50;
|
|
77
|
+
let lastWorldTick = 0;
|
|
78
|
+
function bump(ts) {
|
|
79
|
+
if (ts - lastWorldTick >= WORLD_TICK_MS) {
|
|
80
|
+
lastWorldTick = ts;
|
|
81
|
+
tick.value++;
|
|
82
|
+
}
|
|
76
83
|
raf = requestAnimationFrame(bump);
|
|
77
84
|
}
|
|
78
85
|
function onScroll() {
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -14,13 +14,13 @@ type __VLS_Props = {
|
|
|
14
14
|
extraItems?: DropdownMenuItem[][];
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
logout: () => any;
|
|
17
18
|
"open-settings": () => any;
|
|
18
19
|
"open-account": () => any;
|
|
19
|
-
logout: () => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onLogout?: (() => any) | undefined;
|
|
21
22
|
"onOpen-settings"?: (() => any) | undefined;
|
|
22
23
|
"onOpen-account"?: (() => any) | undefined;
|
|
23
|
-
onLogout?: (() => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
color: string;
|
|
26
26
|
collapsed: boolean;
|
|
@@ -193,33 +193,55 @@ export function useSmoothedCursors(provider, posKey = "pos", lerpFactor = 0.3) {
|
|
|
193
193
|
const { states, setLocalState } = useAwarenessOf(provider);
|
|
194
194
|
const localId = computed(() => provider.value?.awareness?.clientID ?? 0);
|
|
195
195
|
const cursors = ref([]);
|
|
196
|
-
|
|
196
|
+
const byId = /* @__PURE__ */ new Map();
|
|
197
|
+
let frame = 0;
|
|
198
|
+
let running = false;
|
|
197
199
|
const EPS_SQ = 25e-4;
|
|
198
200
|
const tick = () => {
|
|
199
201
|
const activeIds = /* @__PURE__ */ new Set();
|
|
202
|
+
let unsettled = false;
|
|
200
203
|
for (const s of states.value) {
|
|
201
204
|
if (s.clientId === localId.value) continue;
|
|
202
205
|
const pos = s[posKey];
|
|
203
206
|
if (pos == null) continue;
|
|
204
207
|
activeIds.add(s.clientId);
|
|
205
|
-
const entry =
|
|
208
|
+
const entry = byId.get(s.clientId);
|
|
206
209
|
if (!entry) {
|
|
207
210
|
cursors.value.push({ clientId: s.clientId, x: pos.x, y: pos.y, state: s });
|
|
211
|
+
byId.set(s.clientId, cursors.value[cursors.value.length - 1]);
|
|
208
212
|
continue;
|
|
209
213
|
}
|
|
210
214
|
const dx = pos.x - entry.x;
|
|
211
215
|
const dy = pos.y - entry.y;
|
|
212
|
-
if (dx * dx + dy * dy < EPS_SQ
|
|
216
|
+
if (dx * dx + dy * dy < EPS_SQ) {
|
|
217
|
+
if (entry.state !== s) entry.state = s;
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
unsettled = true;
|
|
213
221
|
entry.x += dx * lerpFactor;
|
|
214
222
|
entry.y += dy * lerpFactor;
|
|
215
223
|
entry.state = s;
|
|
216
224
|
}
|
|
217
225
|
for (let i = cursors.value.length - 1; i >= 0; i--) {
|
|
218
|
-
|
|
226
|
+
const id = cursors.value[i].clientId;
|
|
227
|
+
if (!activeIds.has(id)) {
|
|
228
|
+
cursors.value.splice(i, 1);
|
|
229
|
+
byId.delete(id);
|
|
230
|
+
}
|
|
219
231
|
}
|
|
232
|
+
if (!unsettled) {
|
|
233
|
+
running = false;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
frame = requestAnimationFrame(tick);
|
|
237
|
+
};
|
|
238
|
+
const wake = () => {
|
|
239
|
+
if (running) return;
|
|
240
|
+
running = true;
|
|
220
241
|
frame = requestAnimationFrame(tick);
|
|
221
242
|
};
|
|
222
|
-
onMounted(
|
|
243
|
+
onMounted(wake);
|
|
244
|
+
watch(states, wake);
|
|
223
245
|
onBeforeUnmount(() => cancelAnimationFrame(frame));
|
|
224
246
|
return { cursors, states, setLocalState };
|
|
225
247
|
}
|