@liveblocks/client
Advanced tools
Comparing version 0.13.2 to 0.13.3
export { LiveObject } from "./LiveObject"; | ||
export { LiveMap } from "./LiveMap"; | ||
export { LiveList } from "./LiveList"; | ||
export type { Others, Presence, Room, Client, User } from "./types"; | ||
export type { Others, Presence, Room, Client, User, BroadcastOptions, } from "./types"; | ||
export { createClient } from "./client"; |
@@ -67,2 +67,3 @@ import { AbstractCrdt, Doc, ApplyResult } from "./AbstractCrdt"; | ||
delete(index: number): void; | ||
clear(): void; | ||
/** | ||
@@ -69,0 +70,0 @@ * Returns an Array of all the elements in the LiveList. |
@@ -259,2 +259,24 @@ "use strict"; | ||
} | ||
clear() { | ||
if (this._doc) { | ||
let ops = []; | ||
let reverseOps = []; | ||
for (const item of __classPrivateFieldGet(this, _LiveList_items, "f")) { | ||
item[0]._detach(); | ||
const childId = item[0]._id; | ||
if (childId) { | ||
ops.push({ id: childId, type: live_1.OpType.DeleteCrdt }); | ||
reverseOps.push(...item[0]._serialize(this._id, item[1])); | ||
} | ||
} | ||
__classPrivateFieldSet(this, _LiveList_items, [], "f"); | ||
this._doc.dispatch(ops, reverseOps, [this]); | ||
} | ||
else { | ||
for (const item of __classPrivateFieldGet(this, _LiveList_items, "f")) { | ||
item[0]._detach(); | ||
} | ||
__classPrivateFieldSet(this, _LiveList_items, [], "f"); | ||
} | ||
} | ||
/** | ||
@@ -261,0 +283,0 @@ * Returns an Array of all the elements in the LiveList. |
@@ -1,2 +0,2 @@ | ||
import { Others, Presence, ClientOptions, Room, MyPresenceCallback, OthersEventCallback, AuthEndpoint, EventCallback, User, Connection, ErrorCallback, AuthenticationToken, ConnectionCallback, StorageCallback, StorageUpdate } from "./types"; | ||
import { Others, Presence, ClientOptions, Room, MyPresenceCallback, OthersEventCallback, AuthEndpoint, EventCallback, User, Connection, ErrorCallback, AuthenticationToken, ConnectionCallback, StorageCallback, StorageUpdate, BroadcastOptions } from "./types"; | ||
import { ClientMessage, Op } from "./live"; | ||
@@ -121,3 +121,3 @@ import { LiveMap } from "./LiveMap"; | ||
} | undefined) => void; | ||
broadcastEvent: (event: any) => void; | ||
broadcastEvent: (event: any, options?: BroadcastOptions) => void; | ||
batch: (callback: () => void) => void; | ||
@@ -124,0 +124,0 @@ undo: () => void; |
@@ -61,2 +61,5 @@ "use strict"; | ||
}, | ||
[Symbol.iterator]() { | ||
return array[Symbol.iterator](); | ||
}, | ||
map(callback) { | ||
@@ -447,3 +450,5 @@ return array.map(callback); | ||
function authenticationFailure(error) { | ||
console.error(error); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.error("Call to authentication endpoint failed", error); | ||
} | ||
updateConnection({ state: "unavailable" }); | ||
@@ -614,3 +619,5 @@ state.numberOfRetry++; | ||
for (const listener of state.listeners.error) { | ||
console.error(`Liveblocks WebSocket connection closed. Reason: ${error.message} (code: ${error.code})`); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.error(`Connection to Liveblocks websocket server closed. Reason: ${error.message} (code: ${error.code})`); | ||
} | ||
listener(error); | ||
@@ -620,5 +627,9 @@ } | ||
else if (event.wasClean === false) { | ||
state.numberOfRetry++; | ||
const delay = getRetryDelay(); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn(`Connection to Liveblocks websocket server closed (code: ${event.code}). Retrying in ${delay}ms.`); | ||
} | ||
updateConnection({ state: "unavailable" }); | ||
state.numberOfRetry++; | ||
state.timeoutHandles.reconnect = effects.scheduleReconnect(getRetryDelay()); | ||
state.timeoutHandles.reconnect = effects.scheduleReconnect(delay); | ||
} | ||
@@ -765,4 +776,6 @@ else { | ||
} | ||
function broadcastEvent(event) { | ||
if (state.socket == null) { | ||
function broadcastEvent(event, options = { | ||
shouldQueueEventIfNotReady: false, | ||
}) { | ||
if (state.socket == null && options.shouldQueueEventIfNotReady == false) { | ||
return; | ||
@@ -769,0 +782,0 @@ } |
@@ -31,2 +31,10 @@ import type { LiveList } from "./LiveList"; | ||
}; | ||
export declare type BroadcastOptions = { | ||
/** | ||
* Whether or not event is queued if the connection is currently closed. | ||
* | ||
* ❗ We are not sure if we want to support this option in the future so it might be deprecated to be replaced by something else | ||
*/ | ||
shouldQueueEventIfNotReady: boolean; | ||
}; | ||
export declare type StorageUpdate = LiveMapUpdates | LiveObjectUpdates | LiveListUpdates; | ||
@@ -70,2 +78,6 @@ export declare type StorageCallback = (updates: StorageUpdate[]) => void; | ||
/** | ||
* Returns a new Iterator object that contains the users. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<User<TPresence>>; | ||
/** | ||
* Returns the array of connected users in room. | ||
@@ -428,3 +440,3 @@ */ | ||
*/ | ||
broadcastEvent: (event: any) => void; | ||
broadcastEvent: (event: any, options?: BroadcastOptions) => void; | ||
/** | ||
@@ -431,0 +443,0 @@ * Get the room's storage asynchronously. |
export { LiveObject } from "./LiveObject"; | ||
export { LiveMap } from "./LiveMap"; | ||
export { LiveList } from "./LiveList"; | ||
export type { Others, Presence, Room, Client, User } from "./types"; | ||
export type { Others, Presence, Room, Client, User, BroadcastOptions, } from "./types"; | ||
export { createClient } from "./client"; |
@@ -67,2 +67,3 @@ import { AbstractCrdt, Doc, ApplyResult } from "./AbstractCrdt"; | ||
delete(index: number): void; | ||
clear(): void; | ||
/** | ||
@@ -69,0 +70,0 @@ * Returns an Array of all the elements in the LiveList. |
@@ -256,2 +256,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
} | ||
clear() { | ||
if (this._doc) { | ||
let ops = []; | ||
let reverseOps = []; | ||
for (const item of __classPrivateFieldGet(this, _LiveList_items, "f")) { | ||
item[0]._detach(); | ||
const childId = item[0]._id; | ||
if (childId) { | ||
ops.push({ id: childId, type: OpType.DeleteCrdt }); | ||
reverseOps.push(...item[0]._serialize(this._id, item[1])); | ||
} | ||
} | ||
__classPrivateFieldSet(this, _LiveList_items, [], "f"); | ||
this._doc.dispatch(ops, reverseOps, [this]); | ||
} | ||
else { | ||
for (const item of __classPrivateFieldGet(this, _LiveList_items, "f")) { | ||
item[0]._detach(); | ||
} | ||
__classPrivateFieldSet(this, _LiveList_items, [], "f"); | ||
} | ||
} | ||
/** | ||
@@ -258,0 +280,0 @@ * Returns an Array of all the elements in the LiveList. |
@@ -1,2 +0,2 @@ | ||
import { Others, Presence, ClientOptions, Room, MyPresenceCallback, OthersEventCallback, AuthEndpoint, EventCallback, User, Connection, ErrorCallback, AuthenticationToken, ConnectionCallback, StorageCallback, StorageUpdate } from "./types"; | ||
import { Others, Presence, ClientOptions, Room, MyPresenceCallback, OthersEventCallback, AuthEndpoint, EventCallback, User, Connection, ErrorCallback, AuthenticationToken, ConnectionCallback, StorageCallback, StorageUpdate, BroadcastOptions } from "./types"; | ||
import { ClientMessage, Op } from "./live"; | ||
@@ -121,3 +121,3 @@ import { LiveMap } from "./LiveMap"; | ||
} | undefined) => void; | ||
broadcastEvent: (event: any) => void; | ||
broadcastEvent: (event: any, options?: BroadcastOptions) => void; | ||
batch: (callback: () => void) => void; | ||
@@ -124,0 +124,0 @@ undo: () => void; |
@@ -39,2 +39,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}, | ||
[Symbol.iterator]() { | ||
return array[Symbol.iterator](); | ||
}, | ||
map(callback) { | ||
@@ -425,3 +428,5 @@ return array.map(callback); | ||
function authenticationFailure(error) { | ||
console.error(error); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.error("Call to authentication endpoint failed", error); | ||
} | ||
updateConnection({ state: "unavailable" }); | ||
@@ -592,3 +597,5 @@ state.numberOfRetry++; | ||
for (const listener of state.listeners.error) { | ||
console.error(`Liveblocks WebSocket connection closed. Reason: ${error.message} (code: ${error.code})`); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.error(`Connection to Liveblocks websocket server closed. Reason: ${error.message} (code: ${error.code})`); | ||
} | ||
listener(error); | ||
@@ -598,5 +605,9 @@ } | ||
else if (event.wasClean === false) { | ||
state.numberOfRetry++; | ||
const delay = getRetryDelay(); | ||
if (process.env.NODE_ENV !== "production") { | ||
console.warn(`Connection to Liveblocks websocket server closed (code: ${event.code}). Retrying in ${delay}ms.`); | ||
} | ||
updateConnection({ state: "unavailable" }); | ||
state.numberOfRetry++; | ||
state.timeoutHandles.reconnect = effects.scheduleReconnect(getRetryDelay()); | ||
state.timeoutHandles.reconnect = effects.scheduleReconnect(delay); | ||
} | ||
@@ -743,4 +754,6 @@ else { | ||
} | ||
function broadcastEvent(event) { | ||
if (state.socket == null) { | ||
function broadcastEvent(event, options = { | ||
shouldQueueEventIfNotReady: false, | ||
}) { | ||
if (state.socket == null && options.shouldQueueEventIfNotReady == false) { | ||
return; | ||
@@ -747,0 +760,0 @@ } |
@@ -31,2 +31,10 @@ import type { LiveList } from "./LiveList"; | ||
}; | ||
export declare type BroadcastOptions = { | ||
/** | ||
* Whether or not event is queued if the connection is currently closed. | ||
* | ||
* ❗ We are not sure if we want to support this option in the future so it might be deprecated to be replaced by something else | ||
*/ | ||
shouldQueueEventIfNotReady: boolean; | ||
}; | ||
export declare type StorageUpdate = LiveMapUpdates | LiveObjectUpdates | LiveListUpdates; | ||
@@ -70,2 +78,6 @@ export declare type StorageCallback = (updates: StorageUpdate[]) => void; | ||
/** | ||
* Returns a new Iterator object that contains the users. | ||
*/ | ||
[Symbol.iterator](): IterableIterator<User<TPresence>>; | ||
/** | ||
* Returns the array of connected users in room. | ||
@@ -428,3 +440,3 @@ */ | ||
*/ | ||
broadcastEvent: (event: any) => void; | ||
broadcastEvent: (event: any, options?: BroadcastOptions) => void; | ||
/** | ||
@@ -431,0 +443,0 @@ * Get the room's storage asynchronously. |
{ | ||
"name": "@liveblocks/client", | ||
"version": "0.13.2", | ||
"version": "0.13.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
314734
62
8508
6