Hono & Nextjs

getting type error: Property '#private' in type 'Registry' refers to a different member that cannot be accessed from within type 'Registry'. versions:
"@rivetkit/actor": "^0.9.8",
"@rivetkit/react": "^0.9.8",
"@rivetkit/actor": "^0.9.8",
"@rivetkit/react": "^0.9.8",
13 Replies
yzziK
yzziKOP•5mo ago
@Nathan trying to make multi cursors using actor core.
...

export const cursors = actor({
state: { cursors: {} } as CursorsState,
createVars: () => ({
cleanupInterval: null as NodeJS.Timeout | null,
}),
onStart: (c) => {
if (c.vars.cleanupInterval) clearInterval(c.vars.cleanupInterval);
c.vars.cleanupInterval = setInterval(() => {
const now = Date.now();
let changed = false;
for (const id in c.state.cursors) {
let lastUpdate = c.state.cursors[id]?.lastUpdate || Date.now();
if (now - lastUpdate > STALE_CURSOR_THRESHOLD_MS) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
changed = true;
}
}
if (changed)
c.saveState({
immediate: true,
});
}, 10000);
},
onConnect: (c, conn) => {
conn.send("cursors-update", {
type: "sync",
cursors: c.state.cursors,
});
},
onDisconnect: (c, conn) => {
const id = conn.id;
if (c.state.cursors[id]) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
}
},
actions: {
updatePosition: (c, x: number, y: number, pointer: "mouse" | "touch") => {
const now = Date.now();
const id = c.conn.id;
const existing = c.state.cursors[id];
if (existing && now - existing.lastUpdate < UPDATE_THROTTLE_MS) {
return;
}
const cursorData: Cursor = { x, y, pointer, lastUpdate: now };
c.state.cursors[id] = cursorData;
c.broadcast("cursors-update", { type: "update", id, ...cursorData });
},
leave: (c) => {
const id = c.conn.id;
if (c.state.cursors[id]) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
}
},
},
});
...

export const cursors = actor({
state: { cursors: {} } as CursorsState,
createVars: () => ({
cleanupInterval: null as NodeJS.Timeout | null,
}),
onStart: (c) => {
if (c.vars.cleanupInterval) clearInterval(c.vars.cleanupInterval);
c.vars.cleanupInterval = setInterval(() => {
const now = Date.now();
let changed = false;
for (const id in c.state.cursors) {
let lastUpdate = c.state.cursors[id]?.lastUpdate || Date.now();
if (now - lastUpdate > STALE_CURSOR_THRESHOLD_MS) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
changed = true;
}
}
if (changed)
c.saveState({
immediate: true,
});
}, 10000);
},
onConnect: (c, conn) => {
conn.send("cursors-update", {
type: "sync",
cursors: c.state.cursors,
});
},
onDisconnect: (c, conn) => {
const id = conn.id;
if (c.state.cursors[id]) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
}
},
actions: {
updatePosition: (c, x: number, y: number, pointer: "mouse" | "touch") => {
const now = Date.now();
const id = c.conn.id;
const existing = c.state.cursors[id];
if (existing && now - existing.lastUpdate < UPDATE_THROTTLE_MS) {
return;
}
const cursorData: Cursor = { x, y, pointer, lastUpdate: now };
c.state.cursors[id] = cursorData;
c.broadcast("cursors-update", { type: "update", id, ...cursorData });
},
leave: (c) => {
const id = c.conn.id;
if (c.state.cursors[id]) {
delete c.state.cursors[id];
c.broadcast("cursors-update", { type: "remove", id });
}
},
},
});
saw https://discord.com/channels/822914074136018994/1399082694440255648 and rechecked rivetkit version but it's the same on server and nextjs side so thats not it nvm fixed
Nathan
Nathan•5mo ago
what was the issue?
yzziK
yzziKOP•5mo ago
composite: false, switched to pnpm workspaces
Nathan
Nathan•5mo ago
haha funny how pnpm always fixes everything alright thx, we keep having people run in to this issue. sounds like we should add a tip in the docs cheers
yzziK
yzziKOP•5mo ago
one way to streamline is release nextjs package 😛 my ai suggested that and after all the setup i get this package doesn't even exist
yzziK
yzziKOP•5mo ago
Nathan
Nathan•5mo ago
oof yeah we'll get that done thx!
yzziK
yzziKOP•5mo ago
is there any way to disable cors or use * because hono router does not work, i switched to no router which works but then if i use two origins the rivet client rejects the response, i dont need auth and im forced to use credentials: true
jog1t
jog1t•5mo ago
you can also use
origin: (origin) => origin
origin: (origin) => origin
ill add option to disable cors, in a few hours, will ping you
yzziK
yzziKOP•5mo ago
okayy
jog1t
jog1t•5mo ago
what package manager you have used initially? you were running the example inside the rivetkit repo, or your own example? trying to reproduce the issue with the typescript, but so far can't figure out your scenario.
yzziK
yzziKOP•4mo ago
it was npm, two folders(not a workspace) - client, actor, imported using relative paths ../../actor/index.ts

Did you find this page helpful?