@liveblocks/client
Advanced tools
Comparing version 0.7.1 to 0.7.2
export type { Record, RecordData, List } from "./doc"; | ||
export { createClient } from "./client"; | ||
export { LiveStorageState } from "./types"; | ||
export type { Others, Presence, Room, InitialStorageFactory, Client, LiveStorage, } from "./types"; | ||
export type { Others, Presence, Room, InitialStorageFactory, Client, LiveStorage, User, } from "./types"; |
@@ -185,8 +185,12 @@ "use strict"; | ||
} | ||
updateUsers(); | ||
updateUsers({ | ||
type: "update", | ||
updates: message.data, | ||
user: state.users[message.actor], | ||
}); | ||
} | ||
function updateUsers() { | ||
function updateUsers(event) { | ||
state.others = makeOthers(state.users); | ||
for (const listener of state.listeners["others"]) { | ||
listener(state.others); | ||
listener(state.others, event); | ||
} | ||
@@ -196,4 +200,7 @@ } | ||
const userLeftMessage = message; | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers(); | ||
const user = state.users[userLeftMessage.actor]; | ||
if (user) { | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers({ type: "leave", user }); | ||
} | ||
} | ||
@@ -212,3 +219,3 @@ function onRoomStateMessage(message) { | ||
state.users = newUsers; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
} | ||
@@ -232,3 +239,3 @@ function onNavigatorOnline() { | ||
}; | ||
updateUsers(); | ||
updateUsers({ type: "enter", user: state.users[message.actor] }); | ||
if (state.me) { | ||
@@ -300,3 +307,3 @@ // Send current presence to new user | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
if (event.code >= 4000 && event.code <= 4100) { | ||
@@ -432,3 +439,3 @@ updateConnection({ state: "failed" }); | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
clearListeners(); | ||
@@ -435,0 +442,0 @@ } |
@@ -76,2 +76,15 @@ import { RecordData, Record, List } from "./doc"; | ||
}; | ||
export declare type OthersEvent<T extends Presence = Presence> = { | ||
type: "leave"; | ||
user: User<T>; | ||
} | { | ||
type: "enter"; | ||
user: User<T>; | ||
} | { | ||
type: "update"; | ||
user: User<T>; | ||
updates: Partial<T>; | ||
} | { | ||
type: "reset"; | ||
}; | ||
export declare type Room = { | ||
@@ -110,3 +123,3 @@ connect(): void; | ||
export declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void; | ||
export declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>) => void; | ||
export declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>, event: OthersEvent<T>) => void; | ||
export declare type EventCallback = ({ connectionId, event, }: { | ||
@@ -113,0 +126,0 @@ connectionId: number; |
export type { Record, RecordData, List } from "./doc"; | ||
export { createClient } from "./client"; | ||
export { LiveStorageState } from "./types"; | ||
export type { Others, Presence, Room, InitialStorageFactory, Client, LiveStorage, } from "./types"; | ||
export type { Others, Presence, Room, InitialStorageFactory, Client, LiveStorage, User, } from "./types"; |
@@ -163,8 +163,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
updateUsers(); | ||
updateUsers({ | ||
type: "update", | ||
updates: message.data, | ||
user: state.users[message.actor], | ||
}); | ||
} | ||
function updateUsers() { | ||
function updateUsers(event) { | ||
state.others = makeOthers(state.users); | ||
for (const listener of state.listeners["others"]) { | ||
listener(state.others); | ||
listener(state.others, event); | ||
} | ||
@@ -174,4 +178,7 @@ } | ||
const userLeftMessage = message; | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers(); | ||
const user = state.users[userLeftMessage.actor]; | ||
if (user) { | ||
delete state.users[userLeftMessage.actor]; | ||
updateUsers({ type: "leave", user }); | ||
} | ||
} | ||
@@ -190,3 +197,3 @@ function onRoomStateMessage(message) { | ||
state.users = newUsers; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
} | ||
@@ -210,3 +217,3 @@ function onNavigatorOnline() { | ||
}; | ||
updateUsers(); | ||
updateUsers({ type: "enter", user: state.users[message.actor] }); | ||
if (state.me) { | ||
@@ -278,3 +285,3 @@ // Send current presence to new user | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
if (event.code >= 4000 && event.code <= 4100) { | ||
@@ -410,3 +417,3 @@ updateConnection({ state: "failed" }); | ||
state.users = {}; | ||
updateUsers(); | ||
updateUsers({ type: "reset" }); | ||
clearListeners(); | ||
@@ -413,0 +420,0 @@ } |
@@ -76,2 +76,15 @@ import { RecordData, Record, List } from "./doc"; | ||
}; | ||
export declare type OthersEvent<T extends Presence = Presence> = { | ||
type: "leave"; | ||
user: User<T>; | ||
} | { | ||
type: "enter"; | ||
user: User<T>; | ||
} | { | ||
type: "update"; | ||
user: User<T>; | ||
updates: Partial<T>; | ||
} | { | ||
type: "reset"; | ||
}; | ||
export declare type Room = { | ||
@@ -110,3 +123,3 @@ connect(): void; | ||
export declare type MyPresenceCallback<T extends Presence = Presence> = (me: T) => void; | ||
export declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>) => void; | ||
export declare type OthersEventCallback<T extends Presence = Presence> = (others: Others<T>, event: OthersEvent<T>) => void; | ||
export declare type EventCallback = ({ connectionId, event, }: { | ||
@@ -113,0 +126,0 @@ connectionId: number; |
{ | ||
"name": "@liveblocks/client", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "main": "./lib/cjs/index.js", | ||
}, | ||
"license": "MIT", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
@@ -20,0 +20,0 @@ "@babel/core": "^7.12.16", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128549
3659