@liveblocks/core 2.9.3-emails1 → 2.10.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.d.mts +41 -38
- package/dist/index.d.ts +41 -38
- package/dist/index.js +51 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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 = "2.
|
|
9
|
+
var PKG_VERSION = "2.10.0";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1881,6 +1881,16 @@ function createBatchStore(batch) {
|
|
|
1881
1881
|
cache.set(cacheKey, state);
|
|
1882
1882
|
eventSource2.notify();
|
|
1883
1883
|
}
|
|
1884
|
+
function invalidate(inputs) {
|
|
1885
|
+
if (Array.isArray(inputs)) {
|
|
1886
|
+
for (const input of inputs) {
|
|
1887
|
+
cache.delete(getCacheKey(input));
|
|
1888
|
+
}
|
|
1889
|
+
} else {
|
|
1890
|
+
cache.clear();
|
|
1891
|
+
}
|
|
1892
|
+
eventSource2.notify();
|
|
1893
|
+
}
|
|
1884
1894
|
async function get(input) {
|
|
1885
1895
|
const cacheKey = getCacheKey(input);
|
|
1886
1896
|
if (cache.has(cacheKey)) {
|
|
@@ -1901,10 +1911,15 @@ function createBatchStore(batch) {
|
|
|
1901
1911
|
const cacheKey = getCacheKey(input);
|
|
1902
1912
|
return cache.get(cacheKey);
|
|
1903
1913
|
}
|
|
1914
|
+
function _cacheKeys() {
|
|
1915
|
+
return [...cache.keys()];
|
|
1916
|
+
}
|
|
1904
1917
|
return {
|
|
1905
1918
|
...eventSource2.observable,
|
|
1906
1919
|
get,
|
|
1907
|
-
getState
|
|
1920
|
+
getState,
|
|
1921
|
+
invalidate,
|
|
1922
|
+
_cacheKeys
|
|
1908
1923
|
};
|
|
1909
1924
|
}
|
|
1910
1925
|
|
|
@@ -2868,15 +2883,15 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2868
2883
|
this._implicitlyDeletedItems.add(
|
|
2869
2884
|
this._items[indexOfItemWithSamePosition]
|
|
2870
2885
|
);
|
|
2871
|
-
this._items.splice(indexOfItemWithSamePosition, 1);
|
|
2872
|
-
delta.push(deleteDelta(indexOfItemWithSamePosition));
|
|
2886
|
+
const [prevNode] = this._items.splice(indexOfItemWithSamePosition, 1);
|
|
2887
|
+
delta.push(deleteDelta(indexOfItemWithSamePosition, prevNode));
|
|
2873
2888
|
}
|
|
2874
|
-
const
|
|
2889
|
+
const prevIndex = this._items.indexOf(existingItem);
|
|
2875
2890
|
existingItem._setParentLink(this, op.parentKey);
|
|
2876
2891
|
this._sortItems();
|
|
2877
2892
|
const newIndex = this._items.indexOf(existingItem);
|
|
2878
|
-
if (newIndex !==
|
|
2879
|
-
delta.push(moveDelta(
|
|
2893
|
+
if (newIndex !== prevIndex) {
|
|
2894
|
+
delta.push(moveDelta(prevIndex, newIndex, existingItem));
|
|
2880
2895
|
}
|
|
2881
2896
|
return {
|
|
2882
2897
|
modified: delta.length > 0 ? makeUpdate(this, delta) : false,
|
|
@@ -3105,11 +3120,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3105
3120
|
modified: false
|
|
3106
3121
|
};
|
|
3107
3122
|
}
|
|
3108
|
-
this._items.splice(indexToDelete, 1);
|
|
3123
|
+
const [previousNode] = this._items.splice(indexToDelete, 1);
|
|
3109
3124
|
this.invalidate();
|
|
3110
3125
|
child._detach();
|
|
3111
3126
|
return {
|
|
3112
|
-
modified: makeUpdate(this, [deleteDelta(indexToDelete)]),
|
|
3127
|
+
modified: makeUpdate(this, [deleteDelta(indexToDelete, previousNode)]),
|
|
3113
3128
|
reverse
|
|
3114
3129
|
};
|
|
3115
3130
|
}
|
|
@@ -3387,7 +3402,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3387
3402
|
}
|
|
3388
3403
|
const item = this._items[index];
|
|
3389
3404
|
item._detach();
|
|
3390
|
-
this._items.splice(index, 1);
|
|
3405
|
+
const [prev] = this._items.splice(index, 1);
|
|
3391
3406
|
this.invalidate();
|
|
3392
3407
|
if (this._pool) {
|
|
3393
3408
|
const childRecordId = item._id;
|
|
@@ -3395,7 +3410,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3395
3410
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
3396
3411
|
storageUpdates.set(
|
|
3397
3412
|
nn(this._id),
|
|
3398
|
-
makeUpdate(this, [deleteDelta(index)])
|
|
3413
|
+
makeUpdate(this, [deleteDelta(index, prev)])
|
|
3399
3414
|
);
|
|
3400
3415
|
this._pool.dispatch(
|
|
3401
3416
|
[
|
|
@@ -3429,7 +3444,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3429
3444
|
reverseOps.push(
|
|
3430
3445
|
...item._toOps(nn(this._id), item._getParentKeyOrThrow())
|
|
3431
3446
|
);
|
|
3432
|
-
updateDelta.push(deleteDelta(0));
|
|
3447
|
+
updateDelta.push(deleteDelta(0, item));
|
|
3433
3448
|
}
|
|
3434
3449
|
}
|
|
3435
3450
|
this._items = [];
|
|
@@ -3654,10 +3669,11 @@ function setDelta(index, item) {
|
|
|
3654
3669
|
item: item instanceof LiveRegister ? item.data : item
|
|
3655
3670
|
};
|
|
3656
3671
|
}
|
|
3657
|
-
function deleteDelta(index) {
|
|
3672
|
+
function deleteDelta(index, deletedNode) {
|
|
3658
3673
|
return {
|
|
3674
|
+
type: "delete",
|
|
3659
3675
|
index,
|
|
3660
|
-
|
|
3676
|
+
deletedItem: deletedNode instanceof LiveRegister ? deletedNode.data : deletedNode
|
|
3661
3677
|
};
|
|
3662
3678
|
}
|
|
3663
3679
|
function insertDelta(index, item) {
|
|
@@ -3669,10 +3685,10 @@ function insertDelta(index, item) {
|
|
|
3669
3685
|
}
|
|
3670
3686
|
function moveDelta(previousIndex, index, item) {
|
|
3671
3687
|
return {
|
|
3672
|
-
index,
|
|
3673
3688
|
type: "move",
|
|
3674
|
-
|
|
3675
|
-
item: item instanceof LiveRegister ? item.data : item
|
|
3689
|
+
index,
|
|
3690
|
+
item: item instanceof LiveRegister ? item.data : item,
|
|
3691
|
+
previousIndex
|
|
3676
3692
|
};
|
|
3677
3693
|
}
|
|
3678
3694
|
function HACK_addIntentAndDeletedIdToOperation(ops, deletedId) {
|
|
@@ -7329,6 +7345,9 @@ function createClient(options) {
|
|
|
7329
7345
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7330
7346
|
);
|
|
7331
7347
|
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7348
|
+
function invalidateResolvedUsers(userIds) {
|
|
7349
|
+
usersStore.invalidate(userIds);
|
|
7350
|
+
}
|
|
7332
7351
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7333
7352
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7334
7353
|
() => !resolveRoomsInfo,
|
|
@@ -7344,15 +7363,29 @@ function createClient(options) {
|
|
|
7344
7363
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7345
7364
|
);
|
|
7346
7365
|
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7366
|
+
function invalidateResolvedRoomsInfo(roomIds) {
|
|
7367
|
+
roomsInfoStore.invalidate(roomIds);
|
|
7368
|
+
}
|
|
7369
|
+
const mentionSuggestionsCache = /* @__PURE__ */ new Map();
|
|
7370
|
+
function invalidateResolvedMentionSuggestions() {
|
|
7371
|
+
mentionSuggestionsCache.clear();
|
|
7372
|
+
}
|
|
7347
7373
|
return Object.defineProperty(
|
|
7348
7374
|
{
|
|
7349
7375
|
enterRoom,
|
|
7350
7376
|
getRoom,
|
|
7351
7377
|
logout,
|
|
7352
7378
|
...httpClientLike,
|
|
7379
|
+
// Advanced resolvers APIs
|
|
7380
|
+
resolvers: {
|
|
7381
|
+
invalidateUsers: invalidateResolvedUsers,
|
|
7382
|
+
invalidateRoomsInfo: invalidateResolvedRoomsInfo,
|
|
7383
|
+
invalidateMentionSuggestions: invalidateResolvedMentionSuggestions
|
|
7384
|
+
},
|
|
7353
7385
|
// Internal
|
|
7354
7386
|
[kInternal]: {
|
|
7355
7387
|
currentUserIdStore,
|
|
7388
|
+
mentionSuggestionsCache,
|
|
7356
7389
|
resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
|
|
7357
7390
|
usersStore,
|
|
7358
7391
|
roomsInfoStore,
|
|
@@ -7730,22 +7763,6 @@ async function stringifyCommentBody(body, options) {
|
|
|
7730
7763
|
return blocks.join(separator);
|
|
7731
7764
|
}
|
|
7732
7765
|
|
|
7733
|
-
// src/comments/comment-url.ts
|
|
7734
|
-
var PLACEHOLDER_BASE_URL = "https://localhost:9999";
|
|
7735
|
-
var ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
|
|
7736
|
-
function generateCommentUrl({
|
|
7737
|
-
roomUrl,
|
|
7738
|
-
commentId
|
|
7739
|
-
}) {
|
|
7740
|
-
const isAbsolute = ABSOLUTE_URL_REGEX.test(roomUrl);
|
|
7741
|
-
const urlObject = new URL(
|
|
7742
|
-
roomUrl,
|
|
7743
|
-
isAbsolute ? void 0 : PLACEHOLDER_BASE_URL
|
|
7744
|
-
);
|
|
7745
|
-
urlObject.hash = `#${commentId}`;
|
|
7746
|
-
return isAbsolute ? urlObject.href : urlObject.href.replace(PLACEHOLDER_BASE_URL, "");
|
|
7747
|
-
}
|
|
7748
|
-
|
|
7749
7766
|
// src/crdts/utils.ts
|
|
7750
7767
|
function toPlainLson(lson) {
|
|
7751
7768
|
if (lson instanceof LiveObject) {
|
|
@@ -8203,7 +8220,6 @@ export {
|
|
|
8203
8220
|
LiveObject,
|
|
8204
8221
|
NotificationsApiError,
|
|
8205
8222
|
OpCode,
|
|
8206
|
-
Promise_withResolvers,
|
|
8207
8223
|
ServerMsgCode,
|
|
8208
8224
|
StopRetrying2 as StopRetrying,
|
|
8209
8225
|
WebsocketCloseCodes,
|
|
@@ -8231,14 +8247,8 @@ export {
|
|
|
8231
8247
|
detectDupes,
|
|
8232
8248
|
errorIf,
|
|
8233
8249
|
freeze,
|
|
8234
|
-
generateCommentUrl,
|
|
8235
8250
|
getMentionedIdsFromCommentBody,
|
|
8236
|
-
html,
|
|
8237
|
-
htmlSafe,
|
|
8238
8251
|
isChildCrdt,
|
|
8239
|
-
isCommentBodyLink,
|
|
8240
|
-
isCommentBodyMention,
|
|
8241
|
-
isCommentBodyText,
|
|
8242
8252
|
isJsonArray,
|
|
8243
8253
|
isJsonObject,
|
|
8244
8254
|
isJsonScalar,
|
|
@@ -8258,12 +8268,10 @@ export {
|
|
|
8258
8268
|
objectToQuery,
|
|
8259
8269
|
patchLiveObjectKey,
|
|
8260
8270
|
raise,
|
|
8261
|
-
resolveUsersInCommentBody,
|
|
8262
8271
|
shallow,
|
|
8263
8272
|
stringify,
|
|
8264
8273
|
stringifyCommentBody,
|
|
8265
8274
|
throwUsageError,
|
|
8266
|
-
toAbsoluteUrl,
|
|
8267
8275
|
toPlainLson,
|
|
8268
8276
|
tryParseJson,
|
|
8269
8277
|
url,
|