@liveblocks/core 3.8.0-next4 → 3.8.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 +68 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -4
- package/dist/index.d.ts +35 -4
- package/dist/index.js +67 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
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.8.0
|
|
9
|
+
var PKG_VERSION = "3.8.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -927,6 +927,9 @@ function isPlainObject(blob) {
|
|
|
927
927
|
function isStartsWithOperator(blob) {
|
|
928
928
|
return isPlainObject(blob) && typeof blob.startsWith === "string";
|
|
929
929
|
}
|
|
930
|
+
function isNumberOperator(blob) {
|
|
931
|
+
return isPlainObject(blob) && (typeof blob.lt === "number" || typeof blob.gt === "number" || typeof blob.lte === "number" || typeof blob.gte === "number");
|
|
932
|
+
}
|
|
930
933
|
|
|
931
934
|
// src/lib/autoRetry.ts
|
|
932
935
|
var HttpError = class _HttpError extends Error {
|
|
@@ -1281,7 +1284,7 @@ function objectToQuery(obj) {
|
|
|
1281
1284
|
if (isSimpleValue(value)) {
|
|
1282
1285
|
keyValuePairs.push([key, value]);
|
|
1283
1286
|
} else if (isPlainObject(value)) {
|
|
1284
|
-
if (isStartsWithOperator(value)) {
|
|
1287
|
+
if (isStartsWithOperator(value) || isNumberOperator(value)) {
|
|
1285
1288
|
keyValuePairsWithOperator.push([key, value]);
|
|
1286
1289
|
} else {
|
|
1287
1290
|
indexedKeys.push([key, value]);
|
|
@@ -1302,7 +1305,7 @@ function objectToQuery(obj) {
|
|
|
1302
1305
|
}
|
|
1303
1306
|
if (isSimpleValue(nestedValue)) {
|
|
1304
1307
|
nKeyValuePairs.push([formatFilterKey(key, nestedKey), nestedValue]);
|
|
1305
|
-
} else if (isStartsWithOperator(nestedValue)) {
|
|
1308
|
+
} else if (isStartsWithOperator(nestedValue) || isNumberOperator(nestedValue)) {
|
|
1306
1309
|
nKeyValuePairsWithOperator.push([
|
|
1307
1310
|
formatFilterKey(key, nestedKey),
|
|
1308
1311
|
nestedValue
|
|
@@ -1338,6 +1341,34 @@ var getFiltersFromKeyValuePairsWithOperator = (keyValuePairsWithOperator) => {
|
|
|
1338
1341
|
value: value.startsWith
|
|
1339
1342
|
});
|
|
1340
1343
|
}
|
|
1344
|
+
if ("lt" in value && typeof value.lt === "number") {
|
|
1345
|
+
filters.push({
|
|
1346
|
+
key,
|
|
1347
|
+
operator: "<",
|
|
1348
|
+
value: value.lt
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
if ("gt" in value && typeof value.gt === "number") {
|
|
1352
|
+
filters.push({
|
|
1353
|
+
key,
|
|
1354
|
+
operator: ">",
|
|
1355
|
+
value: value.gt
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
if ("gte" in value && typeof value.gte === "number") {
|
|
1359
|
+
filters.push({
|
|
1360
|
+
key,
|
|
1361
|
+
operator: ">=",
|
|
1362
|
+
value: value.gte
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
if ("lte" in value && typeof value.lte === "number") {
|
|
1366
|
+
filters.push({
|
|
1367
|
+
key,
|
|
1368
|
+
operator: "<=",
|
|
1369
|
+
value: value.lte
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1341
1372
|
});
|
|
1342
1373
|
return filters;
|
|
1343
1374
|
};
|
|
@@ -2143,7 +2174,7 @@ function createApiClient({
|
|
|
2143
2174
|
);
|
|
2144
2175
|
return await result.json();
|
|
2145
2176
|
}
|
|
2146
|
-
async function
|
|
2177
|
+
async function sendMessagesOverHTTP(options) {
|
|
2147
2178
|
return httpClient.rawPost(
|
|
2148
2179
|
url`/v2/c/rooms/${options.roomId}/send-message`,
|
|
2149
2180
|
await authManager.getAuthValue({
|
|
@@ -2394,7 +2425,7 @@ function createApiClient({
|
|
|
2394
2425
|
getChatAttachmentUrl,
|
|
2395
2426
|
// Room storage
|
|
2396
2427
|
streamStorage,
|
|
2397
|
-
|
|
2428
|
+
sendMessagesOverHTTP,
|
|
2398
2429
|
// Notifications
|
|
2399
2430
|
getInboxNotifications,
|
|
2400
2431
|
getInboxNotificationsSince,
|
|
@@ -7090,7 +7121,12 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7090
7121
|
const storageUpdate = {
|
|
7091
7122
|
node: this,
|
|
7092
7123
|
type: "LiveMap",
|
|
7093
|
-
updates: {
|
|
7124
|
+
updates: {
|
|
7125
|
+
[parentKey]: {
|
|
7126
|
+
type: "delete",
|
|
7127
|
+
deletedItem: liveNodeToLson(child)
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7094
7130
|
};
|
|
7095
7131
|
return { modified: storageUpdate, reverse };
|
|
7096
7132
|
}
|
|
@@ -7183,7 +7219,12 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7183
7219
|
storageUpdates.set(thisId, {
|
|
7184
7220
|
node: this,
|
|
7185
7221
|
type: "LiveMap",
|
|
7186
|
-
updates: {
|
|
7222
|
+
updates: {
|
|
7223
|
+
[key]: {
|
|
7224
|
+
type: "delete",
|
|
7225
|
+
deletedItem: liveNodeToLson(item)
|
|
7226
|
+
}
|
|
7227
|
+
}
|
|
7187
7228
|
});
|
|
7188
7229
|
this._pool.dispatch(
|
|
7189
7230
|
[
|
|
@@ -7587,13 +7628,13 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7587
7628
|
}
|
|
7588
7629
|
#applyDeleteObjectKey(op, isLocal) {
|
|
7589
7630
|
const key = op.key;
|
|
7590
|
-
|
|
7631
|
+
const oldValue = this.#map.get(key);
|
|
7632
|
+
if (oldValue === void 0) {
|
|
7591
7633
|
return { modified: false };
|
|
7592
7634
|
}
|
|
7593
7635
|
if (!isLocal && this.#propToLastUpdate.get(key) !== void 0) {
|
|
7594
7636
|
return { modified: false };
|
|
7595
7637
|
}
|
|
7596
|
-
const oldValue = this.#map.get(key);
|
|
7597
7638
|
const id = nn(this._id);
|
|
7598
7639
|
let reverse = [];
|
|
7599
7640
|
if (isLiveNode(oldValue)) {
|
|
@@ -7614,7 +7655,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7614
7655
|
modified: {
|
|
7615
7656
|
node: this,
|
|
7616
7657
|
type: "LiveObject",
|
|
7617
|
-
updates: {
|
|
7658
|
+
updates: {
|
|
7659
|
+
[op.key]: { type: "delete", deletedItem: oldValue }
|
|
7660
|
+
}
|
|
7618
7661
|
},
|
|
7619
7662
|
reverse
|
|
7620
7663
|
};
|
|
@@ -7679,7 +7722,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7679
7722
|
storageUpdates.set(this._id, {
|
|
7680
7723
|
node: this,
|
|
7681
7724
|
type: "LiveObject",
|
|
7682
|
-
updates: {
|
|
7725
|
+
updates: {
|
|
7726
|
+
[key]: { type: "delete", deletedItem: oldValue }
|
|
7727
|
+
}
|
|
7683
7728
|
});
|
|
7684
7729
|
this._pool.dispatch(
|
|
7685
7730
|
[
|
|
@@ -8759,13 +8804,22 @@ function createRoom(options, config) {
|
|
|
8759
8804
|
}
|
|
8760
8805
|
return;
|
|
8761
8806
|
}
|
|
8807
|
+
// NOTE: This strategy is experimental as it will not work in all situations.
|
|
8808
|
+
// It should only be used for broadcasting, presence updates, but isn't suitable
|
|
8809
|
+
// for Storage or Yjs updates yet (because through this channel the server does
|
|
8810
|
+
// not respond with acks or rejections, causing the client's reported status to
|
|
8811
|
+
// be stuck in "synchronizing" forever).
|
|
8762
8812
|
case "experimental-fallback-to-http": {
|
|
8763
8813
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8764
8814
|
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _187 => _187.dynamicSessionInfoSig, 'access', _188 => _188.get, 'call', _189 => _189(), 'optionalAccess', _190 => _190.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8765
|
-
void httpClient.
|
|
8815
|
+
void httpClient.sendMessagesOverHTTP({ roomId, nonce, messages }).then((resp) => {
|
|
8766
8816
|
if (!resp.ok && resp.status === 403) {
|
|
8767
8817
|
managedSocket.reconnect();
|
|
8768
8818
|
}
|
|
8819
|
+
}).catch((err) => {
|
|
8820
|
+
error2(
|
|
8821
|
+
`Failed to deliver message over HTTP: ${String(err)}`
|
|
8822
|
+
);
|
|
8769
8823
|
});
|
|
8770
8824
|
return;
|
|
8771
8825
|
}
|
|
@@ -10030,12 +10084,6 @@ function createClient(options) {
|
|
|
10030
10084
|
);
|
|
10031
10085
|
} else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
|
|
10032
10086
|
throw new StopRetrying("AI Copilots requires an ID or Access token");
|
|
10033
|
-
} else {
|
|
10034
|
-
if (!resp.token.parsed.ai) {
|
|
10035
|
-
throw new StopRetrying(
|
|
10036
|
-
"AI Copilots is not yet enabled for this account. To get started, see https://liveblocks.io/docs/get-started/ai-copilots#Quickstart"
|
|
10037
|
-
);
|
|
10038
|
-
}
|
|
10039
10087
|
}
|
|
10040
10088
|
return resp;
|
|
10041
10089
|
},
|
|
@@ -11272,5 +11320,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11272
11320
|
|
|
11273
11321
|
|
|
11274
11322
|
|
|
11275
|
-
|
|
11323
|
+
|
|
11324
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11276
11325
|
//# sourceMappingURL=index.cjs.map
|