@liveblocks/core 3.7.0-preview1 → 3.7.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/index.cjs +164 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -6
- package/dist/index.d.ts +19 -6
- package/dist/index.js +41 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -225,7 +225,7 @@ declare function makeEventSource<T>(): EventSource<T>;
|
|
|
225
225
|
type BatchStore<O, I> = {
|
|
226
226
|
subscribe: (callback: Callback<void>) => UnsubscribeCallback;
|
|
227
227
|
enqueue: (input: I) => Promise<void>;
|
|
228
|
-
|
|
228
|
+
setData: (entries: [I, O][]) => void;
|
|
229
229
|
getItemState: (input: I) => AsyncResult<O> | undefined;
|
|
230
230
|
getData: (input: I) => O | undefined;
|
|
231
231
|
invalidate: (inputs?: I[]) => void;
|
|
@@ -1723,6 +1723,10 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1723
1723
|
interface NotificationHttpApi<M extends BaseMetadata> {
|
|
1724
1724
|
getInboxNotifications(options?: {
|
|
1725
1725
|
cursor?: string;
|
|
1726
|
+
query?: {
|
|
1727
|
+
roomId?: string;
|
|
1728
|
+
kind?: string;
|
|
1729
|
+
};
|
|
1726
1730
|
}): Promise<{
|
|
1727
1731
|
inboxNotifications: InboxNotificationData[];
|
|
1728
1732
|
threads: ThreadData<M>[];
|
|
@@ -1732,6 +1736,10 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
1732
1736
|
}>;
|
|
1733
1737
|
getInboxNotificationsSince(options: {
|
|
1734
1738
|
since: Date;
|
|
1739
|
+
query?: {
|
|
1740
|
+
roomId?: string;
|
|
1741
|
+
kind?: string;
|
|
1742
|
+
};
|
|
1735
1743
|
signal?: AbortSignal;
|
|
1736
1744
|
}): Promise<{
|
|
1737
1745
|
inboxNotifications: {
|
|
@@ -2000,6 +2008,10 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2000
2008
|
*/
|
|
2001
2009
|
getInboxNotifications(options?: {
|
|
2002
2010
|
cursor?: string;
|
|
2011
|
+
query?: {
|
|
2012
|
+
roomId?: string;
|
|
2013
|
+
kind?: string;
|
|
2014
|
+
};
|
|
2003
2015
|
}): Promise<{
|
|
2004
2016
|
inboxNotifications: InboxNotificationData[];
|
|
2005
2017
|
threads: ThreadData<M>[];
|
|
@@ -2032,6 +2044,10 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2032
2044
|
*/
|
|
2033
2045
|
getInboxNotificationsSince(options: {
|
|
2034
2046
|
since: Date;
|
|
2047
|
+
query?: {
|
|
2048
|
+
roomId?: string;
|
|
2049
|
+
kind?: string;
|
|
2050
|
+
};
|
|
2035
2051
|
signal?: AbortSignal;
|
|
2036
2052
|
}): Promise<{
|
|
2037
2053
|
inboxNotifications: {
|
|
@@ -3849,13 +3865,10 @@ type AiTextDelta = {
|
|
|
3849
3865
|
type: "text-delta";
|
|
3850
3866
|
textDelta: string;
|
|
3851
3867
|
};
|
|
3852
|
-
type AiReasoningDelta =
|
|
3868
|
+
type AiReasoningDelta = {
|
|
3853
3869
|
type: "reasoning-delta";
|
|
3854
3870
|
textDelta: string;
|
|
3855
|
-
}
|
|
3856
|
-
type: "reasoning-delta";
|
|
3857
|
-
signature: string;
|
|
3858
|
-
}>;
|
|
3871
|
+
};
|
|
3859
3872
|
type AiToolInvocationStreamStart = {
|
|
3860
3873
|
type: "tool-stream";
|
|
3861
3874
|
invocationId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -225,7 +225,7 @@ declare function makeEventSource<T>(): EventSource<T>;
|
|
|
225
225
|
type BatchStore<O, I> = {
|
|
226
226
|
subscribe: (callback: Callback<void>) => UnsubscribeCallback;
|
|
227
227
|
enqueue: (input: I) => Promise<void>;
|
|
228
|
-
|
|
228
|
+
setData: (entries: [I, O][]) => void;
|
|
229
229
|
getItemState: (input: I) => AsyncResult<O> | undefined;
|
|
230
230
|
getData: (input: I) => O | undefined;
|
|
231
231
|
invalidate: (inputs?: I[]) => void;
|
|
@@ -1723,6 +1723,10 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
1723
1723
|
interface NotificationHttpApi<M extends BaseMetadata> {
|
|
1724
1724
|
getInboxNotifications(options?: {
|
|
1725
1725
|
cursor?: string;
|
|
1726
|
+
query?: {
|
|
1727
|
+
roomId?: string;
|
|
1728
|
+
kind?: string;
|
|
1729
|
+
};
|
|
1726
1730
|
}): Promise<{
|
|
1727
1731
|
inboxNotifications: InboxNotificationData[];
|
|
1728
1732
|
threads: ThreadData<M>[];
|
|
@@ -1732,6 +1736,10 @@ interface NotificationHttpApi<M extends BaseMetadata> {
|
|
|
1732
1736
|
}>;
|
|
1733
1737
|
getInboxNotificationsSince(options: {
|
|
1734
1738
|
since: Date;
|
|
1739
|
+
query?: {
|
|
1740
|
+
roomId?: string;
|
|
1741
|
+
kind?: string;
|
|
1742
|
+
};
|
|
1735
1743
|
signal?: AbortSignal;
|
|
1736
1744
|
}): Promise<{
|
|
1737
1745
|
inboxNotifications: {
|
|
@@ -2000,6 +2008,10 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2000
2008
|
*/
|
|
2001
2009
|
getInboxNotifications(options?: {
|
|
2002
2010
|
cursor?: string;
|
|
2011
|
+
query?: {
|
|
2012
|
+
roomId?: string;
|
|
2013
|
+
kind?: string;
|
|
2014
|
+
};
|
|
2003
2015
|
}): Promise<{
|
|
2004
2016
|
inboxNotifications: InboxNotificationData[];
|
|
2005
2017
|
threads: ThreadData<M>[];
|
|
@@ -2032,6 +2044,10 @@ type NotificationsApi<M extends BaseMetadata> = {
|
|
|
2032
2044
|
*/
|
|
2033
2045
|
getInboxNotificationsSince(options: {
|
|
2034
2046
|
since: Date;
|
|
2047
|
+
query?: {
|
|
2048
|
+
roomId?: string;
|
|
2049
|
+
kind?: string;
|
|
2050
|
+
};
|
|
2035
2051
|
signal?: AbortSignal;
|
|
2036
2052
|
}): Promise<{
|
|
2037
2053
|
inboxNotifications: {
|
|
@@ -3849,13 +3865,10 @@ type AiTextDelta = {
|
|
|
3849
3865
|
type: "text-delta";
|
|
3850
3866
|
textDelta: string;
|
|
3851
3867
|
};
|
|
3852
|
-
type AiReasoningDelta =
|
|
3868
|
+
type AiReasoningDelta = {
|
|
3853
3869
|
type: "reasoning-delta";
|
|
3854
3870
|
textDelta: string;
|
|
3855
|
-
}
|
|
3856
|
-
type: "reasoning-delta";
|
|
3857
|
-
signature: string;
|
|
3858
|
-
}>;
|
|
3871
|
+
};
|
|
3859
3872
|
type AiToolInvocationStreamStart = {
|
|
3860
3873
|
type: "tool-stream";
|
|
3861
3874
|
invocationId: string;
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.7.0
|
|
9
|
+
var PKG_VERSION = "3.7.0";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1127,9 +1127,15 @@ function createBatchStore(batch2) {
|
|
|
1127
1127
|
function getCacheKey(args) {
|
|
1128
1128
|
return stableStringify(args);
|
|
1129
1129
|
}
|
|
1130
|
-
function update(
|
|
1130
|
+
function update(entryOrEntries) {
|
|
1131
1131
|
signal.mutate((cache) => {
|
|
1132
|
-
|
|
1132
|
+
if (Array.isArray(entryOrEntries)) {
|
|
1133
|
+
for (const entry of entryOrEntries) {
|
|
1134
|
+
cache.set(entry.key, entry.state);
|
|
1135
|
+
}
|
|
1136
|
+
} else {
|
|
1137
|
+
cache.set(entryOrEntries.key, entryOrEntries.state);
|
|
1138
|
+
}
|
|
1133
1139
|
});
|
|
1134
1140
|
}
|
|
1135
1141
|
function invalidate(inputs) {
|
|
@@ -1150,19 +1156,23 @@ function createBatchStore(batch2) {
|
|
|
1150
1156
|
return;
|
|
1151
1157
|
}
|
|
1152
1158
|
try {
|
|
1153
|
-
update(cacheKey, { isLoading: true });
|
|
1159
|
+
update({ key: cacheKey, state: { isLoading: true } });
|
|
1154
1160
|
const result = await batch2.get(input);
|
|
1155
|
-
update(cacheKey, { isLoading: false, data: result });
|
|
1161
|
+
update({ key: cacheKey, state: { isLoading: false, data: result } });
|
|
1156
1162
|
} catch (error3) {
|
|
1157
|
-
update(
|
|
1158
|
-
|
|
1159
|
-
error: error3
|
|
1163
|
+
update({
|
|
1164
|
+
key: cacheKey,
|
|
1165
|
+
state: { isLoading: false, error: error3 }
|
|
1160
1166
|
});
|
|
1161
1167
|
}
|
|
1162
1168
|
}
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1165
|
-
|
|
1169
|
+
function setData(entries2) {
|
|
1170
|
+
update(
|
|
1171
|
+
entries2.map((entry) => ({
|
|
1172
|
+
key: getCacheKey(entry[0]),
|
|
1173
|
+
state: { isLoading: false, data: entry[1] }
|
|
1174
|
+
}))
|
|
1175
|
+
);
|
|
1166
1176
|
}
|
|
1167
1177
|
function getItemState(input) {
|
|
1168
1178
|
const cacheKey = getCacheKey(input);
|
|
@@ -1181,7 +1191,7 @@ function createBatchStore(batch2) {
|
|
|
1181
1191
|
return {
|
|
1182
1192
|
subscribe: signal.subscribe,
|
|
1183
1193
|
enqueue,
|
|
1184
|
-
|
|
1194
|
+
setData,
|
|
1185
1195
|
getItemState,
|
|
1186
1196
|
getData,
|
|
1187
1197
|
invalidate,
|
|
@@ -2148,18 +2158,21 @@ function createApiClient({
|
|
|
2148
2158
|
}
|
|
2149
2159
|
async function getInboxNotifications(options) {
|
|
2150
2160
|
const PAGE_SIZE = 50;
|
|
2161
|
+
let query;
|
|
2162
|
+
if (options?.query) {
|
|
2163
|
+
query = objectToQuery(options.query);
|
|
2164
|
+
}
|
|
2151
2165
|
const json = await httpClient.get(
|
|
2152
2166
|
url`/v2/c/inbox-notifications`,
|
|
2153
2167
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2154
2168
|
{
|
|
2155
2169
|
cursor: options?.cursor,
|
|
2156
|
-
limit: PAGE_SIZE
|
|
2170
|
+
limit: PAGE_SIZE,
|
|
2171
|
+
query
|
|
2157
2172
|
}
|
|
2158
2173
|
);
|
|
2159
2174
|
const groups = json.groups.map(convertToGroupData);
|
|
2160
|
-
|
|
2161
|
-
groupsStore.fill(group.id, group);
|
|
2162
|
-
}
|
|
2175
|
+
groupsStore.setData(groups.map((group) => [group.id, group]));
|
|
2163
2176
|
return {
|
|
2164
2177
|
inboxNotifications: json.inboxNotifications.map(
|
|
2165
2178
|
convertToInboxNotificationData
|
|
@@ -2171,10 +2184,14 @@ function createApiClient({
|
|
|
2171
2184
|
};
|
|
2172
2185
|
}
|
|
2173
2186
|
async function getInboxNotificationsSince(options) {
|
|
2187
|
+
let query;
|
|
2188
|
+
if (options?.query) {
|
|
2189
|
+
query = objectToQuery(options.query);
|
|
2190
|
+
}
|
|
2174
2191
|
const json = await httpClient.get(
|
|
2175
2192
|
url`/v2/c/inbox-notifications/delta`,
|
|
2176
2193
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2177
|
-
{ since: options.since.toISOString() },
|
|
2194
|
+
{ since: options.since.toISOString(), query },
|
|
2178
2195
|
{ signal: options.signal }
|
|
2179
2196
|
);
|
|
2180
2197
|
return {
|
|
@@ -4084,7 +4101,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
4084
4101
|
closePart(lastPart, now2);
|
|
4085
4102
|
content.push({
|
|
4086
4103
|
type: "reasoning",
|
|
4087
|
-
text: delta.textDelta
|
|
4104
|
+
text: delta.textDelta,
|
|
4088
4105
|
startedAt: now2
|
|
4089
4106
|
});
|
|
4090
4107
|
}
|
|
@@ -6468,13 +6485,14 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6468
6485
|
const previousKey = nn(child._parentKey);
|
|
6469
6486
|
const previousIndex = this.#items.indexOf(child);
|
|
6470
6487
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
6488
|
+
let actualNewKey = newKey;
|
|
6471
6489
|
if (existingItemIndex !== -1) {
|
|
6472
|
-
|
|
6473
|
-
|
|
6474
|
-
|
|
6490
|
+
actualNewKey = makePosition(
|
|
6491
|
+
newKey,
|
|
6492
|
+
this.#items[existingItemIndex + 1]?._parentPos
|
|
6475
6493
|
);
|
|
6476
6494
|
}
|
|
6477
|
-
child._setParentLink(this,
|
|
6495
|
+
child._setParentLink(this, actualNewKey);
|
|
6478
6496
|
this._sortItems();
|
|
6479
6497
|
const newIndex = this.#items.indexOf(child);
|
|
6480
6498
|
if (previousIndex === newIndex) {
|
|
@@ -9962,7 +9980,7 @@ function getBaseUrl(baseUrl) {
|
|
|
9962
9980
|
}
|
|
9963
9981
|
function createClient(options) {
|
|
9964
9982
|
const clientOptions = options;
|
|
9965
|
-
const throttleDelay = getThrottle(clientOptions.throttle ?? DEFAULT_THROTTLE);
|
|
9983
|
+
const throttleDelay = process.env.NODE_ENV !== "production" && clientOptions.__DANGEROUSLY_disableThrottling ? 0 : getThrottle(clientOptions.throttle ?? DEFAULT_THROTTLE);
|
|
9966
9984
|
const lostConnectionTimeout = getLostConnectionTimeout(
|
|
9967
9985
|
clientOptions.lostConnectionTimeout ?? DEFAULT_LOST_CONNECTION_TIMEOUT
|
|
9968
9986
|
);
|