@liveblocks/core 2.17.0-rc1 → 2.17.0-usrnotsettings2
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 +86 -4
- package/dist/index.d.ts +86 -4
- package/dist/index.js +153 -177
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -82
- 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.17.0-
|
|
9
|
+
var PKG_VERSION = "2.17.0-usrnotsettings2";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -181,6 +181,12 @@ function raise(msg) {
|
|
|
181
181
|
function entries(obj) {
|
|
182
182
|
return Object.entries(obj);
|
|
183
183
|
}
|
|
184
|
+
function keys(obj) {
|
|
185
|
+
return Object.keys(obj);
|
|
186
|
+
}
|
|
187
|
+
function values(obj) {
|
|
188
|
+
return Object.values(obj);
|
|
189
|
+
}
|
|
184
190
|
function mapValues(obj, mapFn) {
|
|
185
191
|
const result = {};
|
|
186
192
|
for (const pair of Object.entries(obj)) {
|
|
@@ -1058,9 +1064,9 @@ function urljoin(baseUrl, path, params) {
|
|
|
1058
1064
|
}
|
|
1059
1065
|
return url2.toString();
|
|
1060
1066
|
}
|
|
1061
|
-
function url(strings, ...
|
|
1067
|
+
function url(strings, ...values2) {
|
|
1062
1068
|
return strings.reduce(
|
|
1063
|
-
(result, str, i) => result + encodeURIComponent(
|
|
1069
|
+
(result, str, i) => result + encodeURIComponent(values2[i - 1] ?? "") + str
|
|
1064
1070
|
);
|
|
1065
1071
|
}
|
|
1066
1072
|
|
|
@@ -1705,6 +1711,21 @@ function createApiClient({
|
|
|
1705
1711
|
await authManager.getAuthValue({ requestedScope: "comments:read" })
|
|
1706
1712
|
);
|
|
1707
1713
|
}
|
|
1714
|
+
async function getUserNotificationSettings(options) {
|
|
1715
|
+
return httpClient.get(
|
|
1716
|
+
url`/v2/c/notification-settings`,
|
|
1717
|
+
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1718
|
+
void 0,
|
|
1719
|
+
{ signal: options?.signal }
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
async function updateUserNotificationSettings(settings) {
|
|
1723
|
+
return httpClient.post(
|
|
1724
|
+
url`/v2/c/notification-settings`,
|
|
1725
|
+
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
1726
|
+
settings
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1708
1729
|
async function getUserThreads_experimental(options) {
|
|
1709
1730
|
let query;
|
|
1710
1731
|
if (options?.query) {
|
|
@@ -1767,10 +1788,10 @@ function createApiClient({
|
|
|
1767
1788
|
removeReaction,
|
|
1768
1789
|
markThreadAsResolved,
|
|
1769
1790
|
markThreadAsUnresolved,
|
|
1770
|
-
// Room notifications
|
|
1771
1791
|
markRoomInboxNotificationAsRead,
|
|
1772
|
-
|
|
1792
|
+
// Room notifications
|
|
1773
1793
|
getNotificationSettings,
|
|
1794
|
+
updateNotificationSettings,
|
|
1774
1795
|
// Room text editor
|
|
1775
1796
|
createTextMention,
|
|
1776
1797
|
deleteTextMention,
|
|
@@ -1794,6 +1815,8 @@ function createApiClient({
|
|
|
1794
1815
|
markInboxNotificationAsRead,
|
|
1795
1816
|
deleteAllInboxNotifications,
|
|
1796
1817
|
deleteInboxNotification,
|
|
1818
|
+
getUserNotificationSettings,
|
|
1819
|
+
updateUserNotificationSettings,
|
|
1797
1820
|
// User threads
|
|
1798
1821
|
getUserThreads_experimental,
|
|
1799
1822
|
getUserThreadsSince_experimental
|
|
@@ -6320,7 +6343,7 @@ function defaultMessageFromContext(context) {
|
|
|
6320
6343
|
}
|
|
6321
6344
|
|
|
6322
6345
|
// src/room.ts
|
|
6323
|
-
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 -
|
|
6346
|
+
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 1024;
|
|
6324
6347
|
function makeIdFactory(connectionId) {
|
|
6325
6348
|
let count = 0;
|
|
6326
6349
|
return () => `${connectionId}:${count++}`;
|
|
@@ -6589,82 +6612,24 @@ function createRoom(options, config) {
|
|
|
6589
6612
|
async function createTextVersion() {
|
|
6590
6613
|
return httpClient.createTextVersion({ roomId });
|
|
6591
6614
|
}
|
|
6592
|
-
function* chunkOps(msg) {
|
|
6593
|
-
const { ops, ...rest } = msg;
|
|
6594
|
-
if (ops.length < 2) {
|
|
6595
|
-
throw new Error("Cannot split ops into smaller chunks");
|
|
6596
|
-
}
|
|
6597
|
-
const mid = Math.floor(ops.length / 2);
|
|
6598
|
-
const firstHalf = ops.slice(0, mid);
|
|
6599
|
-
const secondHalf = ops.slice(mid);
|
|
6600
|
-
for (const halfOps of [firstHalf, secondHalf]) {
|
|
6601
|
-
const half = { ops: halfOps, ...rest };
|
|
6602
|
-
const text = JSON.stringify([half]);
|
|
6603
|
-
if (!isTooBigForWebSocket(text)) {
|
|
6604
|
-
yield text;
|
|
6605
|
-
} else {
|
|
6606
|
-
yield* chunkOps(half);
|
|
6607
|
-
}
|
|
6608
|
-
}
|
|
6609
|
-
}
|
|
6610
|
-
function* chunkMessages(messages) {
|
|
6611
|
-
if (messages.length < 2) {
|
|
6612
|
-
if (messages[0].type === 201 /* UPDATE_STORAGE */) {
|
|
6613
|
-
yield* chunkOps(messages[0]);
|
|
6614
|
-
return;
|
|
6615
|
-
} else {
|
|
6616
|
-
throw new Error(
|
|
6617
|
-
"Cannot split into chunks smaller than the allowed message size"
|
|
6618
|
-
);
|
|
6619
|
-
}
|
|
6620
|
-
}
|
|
6621
|
-
const mid = Math.floor(messages.length / 2);
|
|
6622
|
-
const firstHalf = messages.slice(0, mid);
|
|
6623
|
-
const secondHalf = messages.slice(mid);
|
|
6624
|
-
for (const half of [firstHalf, secondHalf]) {
|
|
6625
|
-
const text = JSON.stringify(half);
|
|
6626
|
-
if (!isTooBigForWebSocket(text)) {
|
|
6627
|
-
yield text;
|
|
6628
|
-
} else {
|
|
6629
|
-
yield* chunkMessages(half);
|
|
6630
|
-
}
|
|
6631
|
-
}
|
|
6632
|
-
}
|
|
6633
|
-
function isTooBigForWebSocket(text) {
|
|
6634
|
-
if (text.length * 4 < MAX_SOCKET_MESSAGE_SIZE) {
|
|
6635
|
-
return false;
|
|
6636
|
-
}
|
|
6637
|
-
return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
|
|
6638
|
-
}
|
|
6639
6615
|
function sendMessages(messages) {
|
|
6640
|
-
const
|
|
6641
|
-
const
|
|
6642
|
-
if (
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
switch (strategy) {
|
|
6646
|
-
case "default": {
|
|
6647
|
-
error2("Message is too large for websockets, not sending. Configure largeMessageStrategy option to deal with this.");
|
|
6648
|
-
return;
|
|
6649
|
-
}
|
|
6650
|
-
case "split": {
|
|
6651
|
-
warn("Message is too large for websockets, splitting into smaller chunks");
|
|
6652
|
-
for (const chunk2 of chunkMessages(messages)) {
|
|
6653
|
-
managedSocket.send(chunk2);
|
|
6654
|
-
}
|
|
6655
|
-
return;
|
|
6656
|
-
}
|
|
6657
|
-
case "experimental-fallback-to-http": {
|
|
6658
|
-
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
6659
|
-
const nonce = context.dynamicSessionInfoSig.get()?.nonce ?? raise("Session is not authorized to send message over HTTP");
|
|
6616
|
+
const serializedPayload = JSON.stringify(messages);
|
|
6617
|
+
const nonce = context.dynamicSessionInfoSig.get()?.nonce;
|
|
6618
|
+
if (config.unstable_fallbackToHTTP && nonce) {
|
|
6619
|
+
const size = new TextEncoder().encode(serializedPayload).length;
|
|
6620
|
+
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
6660
6621
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
6661
6622
|
if (!resp.ok && resp.status === 403) {
|
|
6662
6623
|
managedSocket.reconnect();
|
|
6663
6624
|
}
|
|
6664
6625
|
});
|
|
6626
|
+
warn(
|
|
6627
|
+
"Message was too large for websockets and sent over HTTP instead"
|
|
6628
|
+
);
|
|
6665
6629
|
return;
|
|
6666
6630
|
}
|
|
6667
6631
|
}
|
|
6632
|
+
managedSocket.send(serializedPayload);
|
|
6668
6633
|
}
|
|
6669
6634
|
const self = DerivedSignal.from(
|
|
6670
6635
|
context.staticSessionInfoSig,
|
|
@@ -7935,7 +7900,7 @@ function createClient(options) {
|
|
|
7935
7900
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7936
7901
|
baseUrl,
|
|
7937
7902
|
errorEventSource: liveblocksErrorSource,
|
|
7938
|
-
|
|
7903
|
+
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7939
7904
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
7940
7905
|
roomHttpClient: httpClient,
|
|
7941
7906
|
createSyncSource
|
|
@@ -8069,6 +8034,9 @@ function createClient(options) {
|
|
|
8069
8034
|
markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
|
|
8070
8035
|
deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
|
|
8071
8036
|
deleteInboxNotification: httpClient.deleteInboxNotification,
|
|
8037
|
+
// Public channel notification settings API
|
|
8038
|
+
getNotificationSettings: httpClient.getUserNotificationSettings,
|
|
8039
|
+
updateNotificationSettings: httpClient.updateUserNotificationSettings,
|
|
8072
8040
|
// Advanced resolvers APIs
|
|
8073
8041
|
resolvers: {
|
|
8074
8042
|
invalidateUsers: invalidateResolvedUsers,
|
|
@@ -8265,9 +8233,9 @@ function escapeHtml(value) {
|
|
|
8265
8233
|
var HtmlSafeString = class {
|
|
8266
8234
|
#strings;
|
|
8267
8235
|
#values;
|
|
8268
|
-
constructor(strings,
|
|
8236
|
+
constructor(strings, values2) {
|
|
8269
8237
|
this.#strings = strings;
|
|
8270
|
-
this.#values =
|
|
8238
|
+
this.#values = values2;
|
|
8271
8239
|
}
|
|
8272
8240
|
toString() {
|
|
8273
8241
|
return this.#strings.reduce((result, str, i) => {
|
|
@@ -8275,8 +8243,8 @@ var HtmlSafeString = class {
|
|
|
8275
8243
|
});
|
|
8276
8244
|
}
|
|
8277
8245
|
};
|
|
8278
|
-
function html(strings, ...
|
|
8279
|
-
return new HtmlSafeString(strings,
|
|
8246
|
+
function html(strings, ...values2) {
|
|
8247
|
+
return new HtmlSafeString(strings, values2);
|
|
8280
8248
|
}
|
|
8281
8249
|
var markdownEscapables = {
|
|
8282
8250
|
_: "\\_",
|
|
@@ -8321,9 +8289,9 @@ function escapeMarkdown(value) {
|
|
|
8321
8289
|
var MarkdownSafeString = class {
|
|
8322
8290
|
#strings;
|
|
8323
8291
|
#values;
|
|
8324
|
-
constructor(strings,
|
|
8292
|
+
constructor(strings, values2) {
|
|
8325
8293
|
this.#strings = strings;
|
|
8326
|
-
this.#values =
|
|
8294
|
+
this.#values = values2;
|
|
8327
8295
|
}
|
|
8328
8296
|
toString() {
|
|
8329
8297
|
return this.#strings.reduce((result, str, i) => {
|
|
@@ -8331,8 +8299,8 @@ var MarkdownSafeString = class {
|
|
|
8331
8299
|
});
|
|
8332
8300
|
}
|
|
8333
8301
|
};
|
|
8334
|
-
function markdown(strings, ...
|
|
8335
|
-
return new MarkdownSafeString(strings,
|
|
8302
|
+
function markdown(strings, ...values2) {
|
|
8303
|
+
return new MarkdownSafeString(strings, values2);
|
|
8336
8304
|
}
|
|
8337
8305
|
function toAbsoluteUrl(url2) {
|
|
8338
8306
|
if (url2.startsWith("http://") || url2.startsWith("https://")) {
|
|
@@ -9058,6 +9026,11 @@ var SortedList = class _SortedList {
|
|
|
9058
9026
|
}
|
|
9059
9027
|
};
|
|
9060
9028
|
|
|
9029
|
+
// src/protocol/UserNotificationSettings.ts
|
|
9030
|
+
function isNotificationChannelEnabled(settings) {
|
|
9031
|
+
return values(settings).every((enabled) => enabled === true);
|
|
9032
|
+
}
|
|
9033
|
+
|
|
9061
9034
|
// src/types/Others.ts
|
|
9062
9035
|
var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
9063
9036
|
TextEditorType2["Lexical"] = "lexical";
|
|
@@ -9113,6 +9086,7 @@ export {
|
|
|
9113
9086
|
deprecate,
|
|
9114
9087
|
deprecateIf,
|
|
9115
9088
|
detectDupes,
|
|
9089
|
+
entries,
|
|
9116
9090
|
errorIf,
|
|
9117
9091
|
freeze,
|
|
9118
9092
|
generateCommentUrl,
|
|
@@ -9127,10 +9101,12 @@ export {
|
|
|
9127
9101
|
isJsonObject,
|
|
9128
9102
|
isJsonScalar,
|
|
9129
9103
|
isLiveNode,
|
|
9104
|
+
isNotificationChannelEnabled,
|
|
9130
9105
|
isPlainObject,
|
|
9131
9106
|
isRootCrdt,
|
|
9132
9107
|
isStartsWithOperator,
|
|
9133
9108
|
kInternal,
|
|
9109
|
+
keys,
|
|
9134
9110
|
legacy_patchImmutableObject,
|
|
9135
9111
|
lsonToJson,
|
|
9136
9112
|
makeEventSource,
|