@liveblocks/core 3.22.0-file1 → 3.22.0-rc1
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 +305 -577
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +216 -287
- package/dist/index.d.ts +216 -287
- package/dist/index.js +143 -415
- 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.22.0-
|
|
9
|
+
var PKG_VERSION = "3.22.0-rc1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1309,7 +1309,6 @@ var nanoid = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce(
|
|
|
1309
1309
|
var THREAD_ID_PREFIX = "th";
|
|
1310
1310
|
var COMMENT_ID_PREFIX = "cm";
|
|
1311
1311
|
var COMMENT_ATTACHMENT_ID_PREFIX = "at";
|
|
1312
|
-
var STORAGE_FILE_ID_PREFIX = "fl";
|
|
1313
1312
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
1314
1313
|
function createOptimisticId(prefix) {
|
|
1315
1314
|
return `${prefix}_${nanoid()}`;
|
|
@@ -1323,9 +1322,6 @@ function createCommentId() {
|
|
|
1323
1322
|
function createCommentAttachmentId() {
|
|
1324
1323
|
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
1325
1324
|
}
|
|
1326
|
-
function createStorageFileId() {
|
|
1327
|
-
return createOptimisticId(STORAGE_FILE_ID_PREFIX);
|
|
1328
|
-
}
|
|
1329
1325
|
function createInboxNotificationId() {
|
|
1330
1326
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
1331
1327
|
}
|
|
@@ -1571,120 +1567,6 @@ function isUrl(string) {
|
|
|
1571
1567
|
}
|
|
1572
1568
|
|
|
1573
1569
|
// src/api-client.ts
|
|
1574
|
-
var ROOM_FILE_PART_SIZE = 5 * 1024 * 1024;
|
|
1575
|
-
var ROOM_FILE_RETRY_ATTEMPTS = 10;
|
|
1576
|
-
var ROOM_FILE_RETRY_DELAYS = [
|
|
1577
|
-
2e3,
|
|
1578
|
-
2e3,
|
|
1579
|
-
2e3,
|
|
1580
|
-
2e3,
|
|
1581
|
-
2e3,
|
|
1582
|
-
2e3,
|
|
1583
|
-
2e3,
|
|
1584
|
-
2e3,
|
|
1585
|
-
2e3,
|
|
1586
|
-
2e3
|
|
1587
|
-
];
|
|
1588
|
-
async function uploadRoomFile({
|
|
1589
|
-
file,
|
|
1590
|
-
signal,
|
|
1591
|
-
abortErrorMessage,
|
|
1592
|
-
uploadSingle,
|
|
1593
|
-
createMultipartUpload,
|
|
1594
|
-
uploadMultipartPart,
|
|
1595
|
-
completeMultipartUpload,
|
|
1596
|
-
abortMultipartUpload
|
|
1597
|
-
}) {
|
|
1598
|
-
const abortError = createAbortError(abortErrorMessage);
|
|
1599
|
-
if (_optionalChain([signal, 'optionalAccess', _15 => _15.aborted])) {
|
|
1600
|
-
throw abortError;
|
|
1601
|
-
}
|
|
1602
|
-
const handleRetryError = (err) => {
|
|
1603
|
-
if (_optionalChain([signal, 'optionalAccess', _16 => _16.aborted])) {
|
|
1604
|
-
throw abortError;
|
|
1605
|
-
}
|
|
1606
|
-
if (err instanceof HttpError && err.status === 413) {
|
|
1607
|
-
throw err;
|
|
1608
|
-
}
|
|
1609
|
-
return false;
|
|
1610
|
-
};
|
|
1611
|
-
if (file.size <= ROOM_FILE_PART_SIZE) {
|
|
1612
|
-
return autoRetry(
|
|
1613
|
-
uploadSingle,
|
|
1614
|
-
ROOM_FILE_RETRY_ATTEMPTS,
|
|
1615
|
-
ROOM_FILE_RETRY_DELAYS,
|
|
1616
|
-
handleRetryError
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
let uploadId;
|
|
1620
|
-
const uploadedParts = [];
|
|
1621
|
-
const multipartUpload = await autoRetry(
|
|
1622
|
-
createMultipartUpload,
|
|
1623
|
-
ROOM_FILE_RETRY_ATTEMPTS,
|
|
1624
|
-
ROOM_FILE_RETRY_DELAYS,
|
|
1625
|
-
handleRetryError
|
|
1626
|
-
);
|
|
1627
|
-
try {
|
|
1628
|
-
uploadId = multipartUpload.uploadId;
|
|
1629
|
-
if (_optionalChain([signal, 'optionalAccess', _17 => _17.aborted])) {
|
|
1630
|
-
throw abortError;
|
|
1631
|
-
}
|
|
1632
|
-
const batches = chunk(splitFileIntoParts(file), 5);
|
|
1633
|
-
for (const parts of batches) {
|
|
1634
|
-
const uploadedPartsPromises = [];
|
|
1635
|
-
for (const { part, partNumber } of parts) {
|
|
1636
|
-
uploadedPartsPromises.push(
|
|
1637
|
-
autoRetry(
|
|
1638
|
-
() => uploadMultipartPart(multipartUpload.uploadId, partNumber, part),
|
|
1639
|
-
ROOM_FILE_RETRY_ATTEMPTS,
|
|
1640
|
-
ROOM_FILE_RETRY_DELAYS,
|
|
1641
|
-
handleRetryError
|
|
1642
|
-
)
|
|
1643
|
-
);
|
|
1644
|
-
}
|
|
1645
|
-
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1646
|
-
}
|
|
1647
|
-
if (_optionalChain([signal, 'optionalAccess', _18 => _18.aborted])) {
|
|
1648
|
-
throw abortError;
|
|
1649
|
-
}
|
|
1650
|
-
return completeMultipartUpload(
|
|
1651
|
-
uploadId,
|
|
1652
|
-
uploadedParts.sort((a, b) => a.partNumber - b.partNumber)
|
|
1653
|
-
);
|
|
1654
|
-
} catch (error3) {
|
|
1655
|
-
if (uploadId && isAbortOrTimeoutError(error3)) {
|
|
1656
|
-
try {
|
|
1657
|
-
await abortMultipartUpload(uploadId);
|
|
1658
|
-
} catch (e8) {
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
throw error3;
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
function splitFileIntoParts(file) {
|
|
1665
|
-
const parts = [];
|
|
1666
|
-
let start = 0;
|
|
1667
|
-
while (start < file.size) {
|
|
1668
|
-
const end = Math.min(start + ROOM_FILE_PART_SIZE, file.size);
|
|
1669
|
-
parts.push({
|
|
1670
|
-
partNumber: parts.length + 1,
|
|
1671
|
-
part: file.slice(start, end)
|
|
1672
|
-
});
|
|
1673
|
-
start = end;
|
|
1674
|
-
}
|
|
1675
|
-
return parts;
|
|
1676
|
-
}
|
|
1677
|
-
function isAbortOrTimeoutError(error3) {
|
|
1678
|
-
return error3 instanceof Error && (error3.name === "AbortError" || error3.name === "TimeoutError");
|
|
1679
|
-
}
|
|
1680
|
-
function createAbortError(message) {
|
|
1681
|
-
if (typeof DOMException === "function") {
|
|
1682
|
-
return new DOMException(message, "AbortError");
|
|
1683
|
-
}
|
|
1684
|
-
const error3 = new Error(message);
|
|
1685
|
-
error3.name = "AbortError";
|
|
1686
|
-
return error3;
|
|
1687
|
-
}
|
|
1688
1570
|
function commentsResourceForVisibility(visibility) {
|
|
1689
1571
|
if (visibility === "private") {
|
|
1690
1572
|
return "comments:private";
|
|
@@ -1745,7 +1627,7 @@ function createApiClient({
|
|
|
1745
1627
|
url`/v2/c/rooms/${options.roomId}/threads`,
|
|
1746
1628
|
await authManager.getAuthValue({
|
|
1747
1629
|
roomId: options.roomId,
|
|
1748
|
-
resource: commentsResourceForVisibility(_optionalChain([options, 'access',
|
|
1630
|
+
resource: commentsResourceForVisibility(_optionalChain([options, 'access', _15 => _15.query, 'optionalAccess', _16 => _16.visibility])),
|
|
1749
1631
|
access: "read"
|
|
1750
1632
|
}),
|
|
1751
1633
|
{
|
|
@@ -1803,7 +1685,7 @@ function createApiClient({
|
|
|
1803
1685
|
hasMentions: options.query.hasMentions
|
|
1804
1686
|
})
|
|
1805
1687
|
},
|
|
1806
|
-
{ signal: _optionalChain([requestOptions, 'optionalAccess',
|
|
1688
|
+
{ signal: _optionalChain([requestOptions, 'optionalAccess', _17 => _17.signal]) }
|
|
1807
1689
|
);
|
|
1808
1690
|
return result;
|
|
1809
1691
|
}
|
|
@@ -2000,128 +1882,151 @@ function createApiClient({
|
|
|
2000
1882
|
}
|
|
2001
1883
|
async function uploadAttachment(options) {
|
|
2002
1884
|
const roomId = options.roomId;
|
|
1885
|
+
const abortSignal = options.signal;
|
|
2003
1886
|
const attachment = options.attachment;
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
{
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
abortMultipartUpload: async (uploadId) => {
|
|
2052
|
-
await httpClient.rawDelete(
|
|
2053
|
-
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
1887
|
+
const abortError = abortSignal ? new DOMException(
|
|
1888
|
+
`Upload of attachment ${options.attachment.id} was aborted.`,
|
|
1889
|
+
"AbortError"
|
|
1890
|
+
) : void 0;
|
|
1891
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _18 => _18.aborted])) {
|
|
1892
|
+
throw abortError;
|
|
1893
|
+
}
|
|
1894
|
+
const handleRetryError = (err) => {
|
|
1895
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _19 => _19.aborted])) {
|
|
1896
|
+
throw abortError;
|
|
1897
|
+
}
|
|
1898
|
+
if (err instanceof HttpError && err.status === 413) {
|
|
1899
|
+
throw err;
|
|
1900
|
+
}
|
|
1901
|
+
return false;
|
|
1902
|
+
};
|
|
1903
|
+
const ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
|
|
1904
|
+
const RETRY_ATTEMPTS = 10;
|
|
1905
|
+
const RETRY_DELAYS = [
|
|
1906
|
+
2e3,
|
|
1907
|
+
2e3,
|
|
1908
|
+
2e3,
|
|
1909
|
+
2e3,
|
|
1910
|
+
2e3,
|
|
1911
|
+
2e3,
|
|
1912
|
+
2e3,
|
|
1913
|
+
2e3,
|
|
1914
|
+
2e3,
|
|
1915
|
+
2e3
|
|
1916
|
+
];
|
|
1917
|
+
function splitFileIntoParts(file) {
|
|
1918
|
+
const parts = [];
|
|
1919
|
+
let start = 0;
|
|
1920
|
+
while (start < file.size) {
|
|
1921
|
+
const end = Math.min(start + ATTACHMENT_PART_SIZE, file.size);
|
|
1922
|
+
parts.push({
|
|
1923
|
+
partNumber: parts.length + 1,
|
|
1924
|
+
part: file.slice(start, end)
|
|
1925
|
+
});
|
|
1926
|
+
start = end;
|
|
1927
|
+
}
|
|
1928
|
+
return parts;
|
|
1929
|
+
}
|
|
1930
|
+
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
1931
|
+
return autoRetry(
|
|
1932
|
+
async () => httpClient.putBlob(
|
|
1933
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
2054
1934
|
await authManager.getAuthValue({
|
|
2055
1935
|
roomId,
|
|
2056
1936
|
resource: "comments",
|
|
2057
1937
|
access: "write"
|
|
2058
|
-
})
|
|
1938
|
+
}),
|
|
1939
|
+
attachment.file,
|
|
1940
|
+
{ fileSize: attachment.size },
|
|
1941
|
+
{ signal: abortSignal }
|
|
1942
|
+
),
|
|
1943
|
+
RETRY_ATTEMPTS,
|
|
1944
|
+
RETRY_DELAYS,
|
|
1945
|
+
handleRetryError
|
|
1946
|
+
);
|
|
1947
|
+
} else {
|
|
1948
|
+
let uploadId;
|
|
1949
|
+
const uploadedParts = [];
|
|
1950
|
+
const createMultiPartUpload = await autoRetry(
|
|
1951
|
+
async () => httpClient.post(
|
|
1952
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
1953
|
+
await authManager.getAuthValue({
|
|
1954
|
+
roomId,
|
|
1955
|
+
resource: "comments",
|
|
1956
|
+
access: "write"
|
|
1957
|
+
}),
|
|
1958
|
+
void 0,
|
|
1959
|
+
{ signal: abortSignal },
|
|
1960
|
+
{ fileSize: attachment.size }
|
|
1961
|
+
),
|
|
1962
|
+
RETRY_ATTEMPTS,
|
|
1963
|
+
RETRY_DELAYS,
|
|
1964
|
+
handleRetryError
|
|
1965
|
+
);
|
|
1966
|
+
try {
|
|
1967
|
+
uploadId = createMultiPartUpload.uploadId;
|
|
1968
|
+
const parts = splitFileIntoParts(attachment.file);
|
|
1969
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _20 => _20.aborted])) {
|
|
1970
|
+
throw abortError;
|
|
1971
|
+
}
|
|
1972
|
+
const batches = chunk(parts, 5);
|
|
1973
|
+
for (const parts2 of batches) {
|
|
1974
|
+
const uploadedPartsPromises = [];
|
|
1975
|
+
for (const { part, partNumber } of parts2) {
|
|
1976
|
+
uploadedPartsPromises.push(
|
|
1977
|
+
autoRetry(
|
|
1978
|
+
async () => httpClient.putBlob(
|
|
1979
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${createMultiPartUpload.uploadId}/${String(partNumber)}`,
|
|
1980
|
+
await authManager.getAuthValue({
|
|
1981
|
+
roomId,
|
|
1982
|
+
resource: "comments",
|
|
1983
|
+
access: "write"
|
|
1984
|
+
}),
|
|
1985
|
+
part,
|
|
1986
|
+
void 0,
|
|
1987
|
+
{ signal: abortSignal }
|
|
1988
|
+
),
|
|
1989
|
+
RETRY_ATTEMPTS,
|
|
1990
|
+
RETRY_DELAYS,
|
|
1991
|
+
handleRetryError
|
|
1992
|
+
)
|
|
1993
|
+
);
|
|
1994
|
+
}
|
|
1995
|
+
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1996
|
+
}
|
|
1997
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _21 => _21.aborted])) {
|
|
1998
|
+
throw abortError;
|
|
1999
|
+
}
|
|
2000
|
+
const sortedUploadedParts = uploadedParts.sort(
|
|
2001
|
+
(a, b) => a.partNumber - b.partNumber
|
|
2059
2002
|
);
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
}
|
|
2063
|
-
async function uploadFile(options) {
|
|
2064
|
-
const roomId = options.roomId;
|
|
2065
|
-
const file = options.file;
|
|
2066
|
-
const fileId = createStorageFileId();
|
|
2067
|
-
return uploadRoomFile({
|
|
2068
|
-
file,
|
|
2069
|
-
signal: options.signal,
|
|
2070
|
-
abortErrorMessage: `Upload of file ${fileId} was aborted.`,
|
|
2071
|
-
uploadSingle: async () => httpClient.putBlob(
|
|
2072
|
-
url`/v2/c/rooms/${roomId}/storage-files/${fileId}/upload/${encodeURIComponent(file.name)}`,
|
|
2073
|
-
await authManager.getAuthValue({
|
|
2074
|
-
roomId,
|
|
2075
|
-
resource: "storage",
|
|
2076
|
-
access: "write"
|
|
2077
|
-
}),
|
|
2078
|
-
file,
|
|
2079
|
-
{ fileSize: file.size },
|
|
2080
|
-
{ signal: options.signal }
|
|
2081
|
-
),
|
|
2082
|
-
createMultipartUpload: async () => httpClient.post(
|
|
2083
|
-
url`/v2/c/rooms/${roomId}/storage-files/${fileId}/multipart/${encodeURIComponent(file.name)}`,
|
|
2084
|
-
await authManager.getAuthValue({
|
|
2085
|
-
roomId,
|
|
2086
|
-
resource: "storage",
|
|
2087
|
-
access: "write"
|
|
2088
|
-
}),
|
|
2089
|
-
void 0,
|
|
2090
|
-
{ signal: options.signal },
|
|
2091
|
-
{ fileSize: file.size }
|
|
2092
|
-
),
|
|
2093
|
-
uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
|
|
2094
|
-
url`/v2/c/rooms/${roomId}/storage-files/${fileId}/multipart/${uploadId}/${String(partNumber)}`,
|
|
2095
|
-
await authManager.getAuthValue({
|
|
2096
|
-
roomId,
|
|
2097
|
-
resource: "storage",
|
|
2098
|
-
access: "write"
|
|
2099
|
-
}),
|
|
2100
|
-
part,
|
|
2101
|
-
void 0,
|
|
2102
|
-
{ signal: options.signal }
|
|
2103
|
-
),
|
|
2104
|
-
completeMultipartUpload: async (uploadId, parts) => httpClient.post(
|
|
2105
|
-
url`/v2/c/rooms/${roomId}/storage-files/${fileId}/multipart/${uploadId}/complete`,
|
|
2106
|
-
await authManager.getAuthValue({
|
|
2107
|
-
roomId,
|
|
2108
|
-
resource: "storage",
|
|
2109
|
-
access: "write"
|
|
2110
|
-
}),
|
|
2111
|
-
{ parts },
|
|
2112
|
-
{ signal: options.signal }
|
|
2113
|
-
),
|
|
2114
|
-
abortMultipartUpload: async (uploadId) => {
|
|
2115
|
-
await httpClient.rawDelete(
|
|
2116
|
-
url`/v2/c/rooms/${roomId}/storage-files/${fileId}/multipart/${uploadId}`,
|
|
2003
|
+
return httpClient.post(
|
|
2004
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
2117
2005
|
await authManager.getAuthValue({
|
|
2118
2006
|
roomId,
|
|
2119
|
-
resource: "
|
|
2007
|
+
resource: "comments",
|
|
2120
2008
|
access: "write"
|
|
2121
|
-
})
|
|
2009
|
+
}),
|
|
2010
|
+
{ parts: sortedUploadedParts },
|
|
2011
|
+
{ signal: abortSignal }
|
|
2122
2012
|
);
|
|
2013
|
+
} catch (error3) {
|
|
2014
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _22 => _22.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
2015
|
+
try {
|
|
2016
|
+
await httpClient.rawDelete(
|
|
2017
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
2018
|
+
await authManager.getAuthValue({
|
|
2019
|
+
roomId,
|
|
2020
|
+
resource: "comments",
|
|
2021
|
+
access: "write"
|
|
2022
|
+
})
|
|
2023
|
+
);
|
|
2024
|
+
} catch (e8) {
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
throw error3;
|
|
2123
2028
|
}
|
|
2124
|
-
}
|
|
2029
|
+
}
|
|
2125
2030
|
}
|
|
2126
2031
|
const attachmentUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
|
|
2127
2032
|
const batch2 = new Batch(
|
|
@@ -2151,34 +2056,6 @@ function createApiClient({
|
|
|
2151
2056
|
const batch2 = getOrCreateAttachmentUrlsStore(options.roomId).batch;
|
|
2152
2057
|
return batch2.get(options.attachmentId);
|
|
2153
2058
|
}
|
|
2154
|
-
const fileUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
|
|
2155
|
-
const batch2 = new Batch(
|
|
2156
|
-
async (batchedFileIds) => {
|
|
2157
|
-
const fileIds = batchedFileIds.flat();
|
|
2158
|
-
const { urls } = await httpClient.post(
|
|
2159
|
-
url`/v2/c/rooms/${roomId}/storage-files/presigned-urls`,
|
|
2160
|
-
await authManager.getAuthValue({
|
|
2161
|
-
roomId,
|
|
2162
|
-
resource: "storage",
|
|
2163
|
-
access: "read"
|
|
2164
|
-
}),
|
|
2165
|
-
{ fileIds }
|
|
2166
|
-
);
|
|
2167
|
-
return urls.map(
|
|
2168
|
-
(url2) => _nullishCoalesce(url2, () => ( new Error("There was an error while getting this file's URL")))
|
|
2169
|
-
);
|
|
2170
|
-
},
|
|
2171
|
-
{ delay: 50 }
|
|
2172
|
-
);
|
|
2173
|
-
return createBatchStore(batch2);
|
|
2174
|
-
});
|
|
2175
|
-
function getOrCreateFileUrlsStore(roomId) {
|
|
2176
|
-
return fileUrlsBatchStoresByRoom.getOrCreate(roomId);
|
|
2177
|
-
}
|
|
2178
|
-
function getFileUrl(options) {
|
|
2179
|
-
const batch2 = getOrCreateFileUrlsStore(options.roomId).batch;
|
|
2180
|
-
return batch2.get(options.fileId);
|
|
2181
|
-
}
|
|
2182
2059
|
async function getSubscriptionSettings(options) {
|
|
2183
2060
|
return httpClient.get(
|
|
2184
2061
|
url`/v2/c/rooms/${options.roomId}/subscription-settings`,
|
|
@@ -2367,14 +2244,14 @@ function createApiClient({
|
|
|
2367
2244
|
async function getInboxNotifications(options) {
|
|
2368
2245
|
const PAGE_SIZE = 50;
|
|
2369
2246
|
let query;
|
|
2370
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2247
|
+
if (_optionalChain([options, 'optionalAccess', _23 => _23.query])) {
|
|
2371
2248
|
query = objectToQuery(options.query);
|
|
2372
2249
|
}
|
|
2373
2250
|
const json = await httpClient.get(
|
|
2374
2251
|
url`/v2/c/inbox-notifications`,
|
|
2375
2252
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2376
2253
|
{
|
|
2377
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2254
|
+
cursor: _optionalChain([options, 'optionalAccess', _24 => _24.cursor]),
|
|
2378
2255
|
limit: PAGE_SIZE,
|
|
2379
2256
|
query
|
|
2380
2257
|
}
|
|
@@ -2393,7 +2270,7 @@ function createApiClient({
|
|
|
2393
2270
|
}
|
|
2394
2271
|
async function getInboxNotificationsSince(options) {
|
|
2395
2272
|
let query;
|
|
2396
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2273
|
+
if (_optionalChain([options, 'optionalAccess', _25 => _25.query])) {
|
|
2397
2274
|
query = objectToQuery(options.query);
|
|
2398
2275
|
}
|
|
2399
2276
|
const json = await httpClient.get(
|
|
@@ -2422,14 +2299,14 @@ function createApiClient({
|
|
|
2422
2299
|
}
|
|
2423
2300
|
async function getUnreadInboxNotificationsCount(options) {
|
|
2424
2301
|
let query;
|
|
2425
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2302
|
+
if (_optionalChain([options, 'optionalAccess', _26 => _26.query])) {
|
|
2426
2303
|
query = objectToQuery(options.query);
|
|
2427
2304
|
}
|
|
2428
2305
|
const { count } = await httpClient.get(
|
|
2429
2306
|
url`/v2/c/inbox-notifications/count`,
|
|
2430
2307
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2431
2308
|
{ query },
|
|
2432
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2309
|
+
{ signal: _optionalChain([options, 'optionalAccess', _27 => _27.signal]) }
|
|
2433
2310
|
);
|
|
2434
2311
|
return count;
|
|
2435
2312
|
}
|
|
@@ -2479,7 +2356,7 @@ function createApiClient({
|
|
|
2479
2356
|
url`/v2/c/notification-settings`,
|
|
2480
2357
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2481
2358
|
void 0,
|
|
2482
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2359
|
+
{ signal: _optionalChain([options, 'optionalAccess', _28 => _28.signal]) }
|
|
2483
2360
|
);
|
|
2484
2361
|
}
|
|
2485
2362
|
async function updateNotificationSettings(settings) {
|
|
@@ -2491,7 +2368,7 @@ function createApiClient({
|
|
|
2491
2368
|
}
|
|
2492
2369
|
async function getUserThreads_experimental(options) {
|
|
2493
2370
|
let query;
|
|
2494
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2371
|
+
if (_optionalChain([options, 'optionalAccess', _29 => _29.query])) {
|
|
2495
2372
|
query = objectToQuery(options.query);
|
|
2496
2373
|
}
|
|
2497
2374
|
const PAGE_SIZE = 50;
|
|
@@ -2499,7 +2376,7 @@ function createApiClient({
|
|
|
2499
2376
|
url`/v2/c/threads`,
|
|
2500
2377
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2501
2378
|
{
|
|
2502
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2379
|
+
cursor: _optionalChain([options, 'optionalAccess', _30 => _30.cursor]),
|
|
2503
2380
|
query,
|
|
2504
2381
|
limit: PAGE_SIZE
|
|
2505
2382
|
}
|
|
@@ -2607,10 +2484,6 @@ function createApiClient({
|
|
|
2607
2484
|
getAttachmentUrl,
|
|
2608
2485
|
uploadAttachment,
|
|
2609
2486
|
getOrCreateAttachmentUrlsStore,
|
|
2610
|
-
// Room storage files
|
|
2611
|
-
getFileUrl,
|
|
2612
|
-
uploadFile,
|
|
2613
|
-
getOrCreateFileUrlsStore,
|
|
2614
2487
|
// Room storage
|
|
2615
2488
|
streamStorage,
|
|
2616
2489
|
// Notifications
|
|
@@ -2676,7 +2549,7 @@ var HttpClient = class {
|
|
|
2676
2549
|
// These headers are default, but can be overriden by custom headers
|
|
2677
2550
|
"Content-Type": "application/json; charset=utf-8",
|
|
2678
2551
|
// Possible header overrides
|
|
2679
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2552
|
+
..._optionalChain([options, 'optionalAccess', _31 => _31.headers]),
|
|
2680
2553
|
// Cannot be overriden by custom headers
|
|
2681
2554
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2682
2555
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -2684,7 +2557,7 @@ var HttpClient = class {
|
|
|
2684
2557
|
});
|
|
2685
2558
|
const xwarn = response.headers.get("X-LB-Warn");
|
|
2686
2559
|
if (xwarn) {
|
|
2687
|
-
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2560
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _32 => _32.method, 'optionalAccess', _33 => _33.toUpperCase, 'call', _34 => _34()]), () => ( "GET"));
|
|
2688
2561
|
const msg = `${xwarn} (${method} ${endpoint})`;
|
|
2689
2562
|
if (response.ok) {
|
|
2690
2563
|
warn(msg);
|
|
@@ -3166,7 +3039,7 @@ var FSM = class {
|
|
|
3166
3039
|
});
|
|
3167
3040
|
}
|
|
3168
3041
|
#getTargetFn(eventName) {
|
|
3169
|
-
return _optionalChain([this, 'access',
|
|
3042
|
+
return _optionalChain([this, 'access', _35 => _35.#allowedTransitions, 'access', _36 => _36.get, 'call', _37 => _37(this.currentState), 'optionalAccess', _38 => _38.get, 'call', _39 => _39(eventName)]);
|
|
3170
3043
|
}
|
|
3171
3044
|
/**
|
|
3172
3045
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -3185,7 +3058,7 @@ var FSM = class {
|
|
|
3185
3058
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3186
3059
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
3187
3060
|
for (let i = 0; i < levels; i++) {
|
|
3188
|
-
_optionalChain([this, 'access',
|
|
3061
|
+
_optionalChain([this, 'access', _40 => _40.#cleanupStack, 'access', _41 => _41.pop, 'call', _42 => _42(), 'optionalCall', _43 => _43(patchableContext)]);
|
|
3189
3062
|
const entryTime = this.#entryTimesStack.pop();
|
|
3190
3063
|
if (entryTime !== void 0 && // ...but avoid computing state names if nobody is listening
|
|
3191
3064
|
this.#eventHub.didExitState.count() > 0) {
|
|
@@ -3213,7 +3086,7 @@ var FSM = class {
|
|
|
3213
3086
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3214
3087
|
for (const pattern of enterPatterns) {
|
|
3215
3088
|
const enterFn = this.#enterFns.get(pattern);
|
|
3216
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
3089
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _44 => _44(patchableContext)]);
|
|
3217
3090
|
if (typeof cleanupFn === "function") {
|
|
3218
3091
|
this.#cleanupStack.push(cleanupFn);
|
|
3219
3092
|
} else {
|
|
@@ -3640,7 +3513,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3640
3513
|
}
|
|
3641
3514
|
function waitForActorId(event) {
|
|
3642
3515
|
const serverMsg = tryParseJson(event.data);
|
|
3643
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
3516
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _45 => _45.type]) === ServerMsgCode.ROOM_STATE) {
|
|
3644
3517
|
if (options.enableDebugLogging && socketOpenAt !== null) {
|
|
3645
3518
|
const elapsed = performance.now() - socketOpenAt;
|
|
3646
3519
|
warn(
|
|
@@ -3768,12 +3641,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3768
3641
|
const sendHeartbeat = {
|
|
3769
3642
|
target: "@ok.awaiting-pong",
|
|
3770
3643
|
effect: (ctx) => {
|
|
3771
|
-
_optionalChain([ctx, 'access',
|
|
3644
|
+
_optionalChain([ctx, 'access', _46 => _46.socket, 'optionalAccess', _47 => _47.send, 'call', _48 => _48("ping")]);
|
|
3772
3645
|
}
|
|
3773
3646
|
};
|
|
3774
3647
|
const maybeHeartbeat = () => {
|
|
3775
3648
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
3776
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
3649
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _49 => _49.visibilityState]) === "hidden" && delegates.canZombie();
|
|
3777
3650
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
3778
3651
|
};
|
|
3779
3652
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -3813,7 +3686,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3813
3686
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
3814
3687
|
// not. When still OPEN, don't transition.
|
|
3815
3688
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
3816
|
-
if (_optionalChain([context, 'access',
|
|
3689
|
+
if (_optionalChain([context, 'access', _50 => _50.socket, 'optionalAccess', _51 => _51.readyState]) === 1) {
|
|
3817
3690
|
return IGNORE;
|
|
3818
3691
|
}
|
|
3819
3692
|
return {
|
|
@@ -3865,17 +3738,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3865
3738
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
3866
3739
|
}
|
|
3867
3740
|
function onVisibilityChange() {
|
|
3868
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
3741
|
+
if (_optionalChain([doc, 'optionalAccess', _52 => _52.visibilityState]) === "visible") {
|
|
3869
3742
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3870
3743
|
}
|
|
3871
3744
|
}
|
|
3872
|
-
_optionalChain([win, 'optionalAccess',
|
|
3873
|
-
_optionalChain([win, 'optionalAccess',
|
|
3874
|
-
_optionalChain([root, 'optionalAccess',
|
|
3745
|
+
_optionalChain([win, 'optionalAccess', _53 => _53.addEventListener, 'call', _54 => _54("online", onNetworkBackOnline)]);
|
|
3746
|
+
_optionalChain([win, 'optionalAccess', _55 => _55.addEventListener, 'call', _56 => _56("offline", onNetworkOffline)]);
|
|
3747
|
+
_optionalChain([root, 'optionalAccess', _57 => _57.addEventListener, 'call', _58 => _58("visibilitychange", onVisibilityChange)]);
|
|
3875
3748
|
return () => {
|
|
3876
|
-
_optionalChain([root, 'optionalAccess',
|
|
3877
|
-
_optionalChain([win, 'optionalAccess',
|
|
3878
|
-
_optionalChain([win, 'optionalAccess',
|
|
3749
|
+
_optionalChain([root, 'optionalAccess', _59 => _59.removeEventListener, 'call', _60 => _60("visibilitychange", onVisibilityChange)]);
|
|
3750
|
+
_optionalChain([win, 'optionalAccess', _61 => _61.removeEventListener, 'call', _62 => _62("online", onNetworkBackOnline)]);
|
|
3751
|
+
_optionalChain([win, 'optionalAccess', _63 => _63.removeEventListener, 'call', _64 => _64("offline", onNetworkOffline)]);
|
|
3879
3752
|
teardownSocket(ctx.socket);
|
|
3880
3753
|
};
|
|
3881
3754
|
});
|
|
@@ -3964,7 +3837,7 @@ var ManagedSocket = class {
|
|
|
3964
3837
|
* message if this is somehow impossible.
|
|
3965
3838
|
*/
|
|
3966
3839
|
send(data) {
|
|
3967
|
-
const socket = _optionalChain([this, 'access',
|
|
3840
|
+
const socket = _optionalChain([this, 'access', _65 => _65.#machine, 'access', _66 => _66.context, 'optionalAccess', _67 => _67.socket]);
|
|
3968
3841
|
if (socket === null) {
|
|
3969
3842
|
warn("Cannot send: not connected yet", data);
|
|
3970
3843
|
} else if (socket.readyState !== 1) {
|
|
@@ -4426,7 +4299,7 @@ function createStore_forKnowledge() {
|
|
|
4426
4299
|
}
|
|
4427
4300
|
function getKnowledgeForChat(chatId) {
|
|
4428
4301
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
4429
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
4302
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _68 => _68.get, 'call', _69 => _69(chatId), 'optionalAccess', _70 => _70.get, 'call', _71 => _71()]), () => ( []));
|
|
4430
4303
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
4431
4304
|
}
|
|
4432
4305
|
return {
|
|
@@ -4451,7 +4324,7 @@ function createStore_forTools() {
|
|
|
4451
4324
|
return DerivedSignal.from(() => {
|
|
4452
4325
|
return (
|
|
4453
4326
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4454
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4327
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _72 => _72.get, 'call', _73 => _73()]), () => ( // ...or a globally registered tool
|
|
4455
4328
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4456
4329
|
);
|
|
4457
4330
|
});
|
|
@@ -4481,8 +4354,8 @@ function createStore_forTools() {
|
|
|
4481
4354
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4482
4355
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4483
4356
|
return Array.from([
|
|
4484
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4485
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4357
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _74 => _74.entries, 'call', _75 => _75()]), () => ( [])),
|
|
4358
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _76 => _76.entries, 'call', _77 => _77()]), () => ( []))
|
|
4486
4359
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4487
4360
|
const tool = tool\u03A3.get();
|
|
4488
4361
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4585,7 +4458,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4585
4458
|
} else {
|
|
4586
4459
|
continue;
|
|
4587
4460
|
}
|
|
4588
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4461
|
+
const executeFn = _optionalChain([toolsStore, 'access', _78 => _78.getTool\u03A3, 'call', _79 => _79(toolInvocation.name, message.chatId), 'access', _80 => _80.get, 'call', _81 => _81(), 'optionalAccess', _82 => _82.execute]);
|
|
4589
4462
|
if (executeFn) {
|
|
4590
4463
|
(async () => {
|
|
4591
4464
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4684,8 +4557,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4684
4557
|
const spine = [];
|
|
4685
4558
|
let lastVisitedMessage = null;
|
|
4686
4559
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4687
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4688
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4560
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _83 => _83(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _84 => _84.id]), () => ( null));
|
|
4561
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _85 => _85(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _86 => _86.id]), () => ( null));
|
|
4689
4562
|
if (!message2.deletedAt || prev || next) {
|
|
4690
4563
|
const node = {
|
|
4691
4564
|
...message2,
|
|
@@ -4751,7 +4624,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4751
4624
|
const latest = pool.sorted.findRight(
|
|
4752
4625
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4753
4626
|
);
|
|
4754
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4627
|
+
return _optionalChain([latest, 'optionalAccess', _87 => _87.copilotId]);
|
|
4755
4628
|
}
|
|
4756
4629
|
return {
|
|
4757
4630
|
// Readers
|
|
@@ -4782,11 +4655,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4782
4655
|
*getAutoExecutingMessageIds() {
|
|
4783
4656
|
for (const messageId of myMessages) {
|
|
4784
4657
|
const message = getMessageById(messageId);
|
|
4785
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4658
|
+
if (_optionalChain([message, 'optionalAccess', _88 => _88.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4786
4659
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4787
4660
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4788
4661
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4789
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4662
|
+
return typeof _optionalChain([tool, 'optionalAccess', _89 => _89.execute]) === "function";
|
|
4790
4663
|
}
|
|
4791
4664
|
return false;
|
|
4792
4665
|
});
|
|
@@ -4934,7 +4807,7 @@ function createAi(config) {
|
|
|
4934
4807
|
flushPendingDeltas();
|
|
4935
4808
|
switch (msg.event) {
|
|
4936
4809
|
case "cmd-failed":
|
|
4937
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4810
|
+
_optionalChain([pendingCmd, 'optionalAccess', _90 => _90.reject, 'call', _91 => _91(new Error(msg.error))]);
|
|
4938
4811
|
break;
|
|
4939
4812
|
case "settle": {
|
|
4940
4813
|
context.messagesStore.upsert(msg.message);
|
|
@@ -5011,7 +4884,7 @@ function createAi(config) {
|
|
|
5011
4884
|
return assertNever(msg, "Unhandled case");
|
|
5012
4885
|
}
|
|
5013
4886
|
}
|
|
5014
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4887
|
+
_optionalChain([pendingCmd, 'optionalAccess', _92 => _92.resolve, 'call', _93 => _93(msg)]);
|
|
5015
4888
|
}
|
|
5016
4889
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
5017
4890
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -5087,9 +4960,9 @@ function createAi(config) {
|
|
|
5087
4960
|
invocationId,
|
|
5088
4961
|
result,
|
|
5089
4962
|
generationOptions: {
|
|
5090
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5091
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5092
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4963
|
+
copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
|
|
4964
|
+
stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
|
|
4965
|
+
timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
|
|
5093
4966
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
5094
4967
|
// from the global context
|
|
5095
4968
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -5107,7 +4980,7 @@ function createAi(config) {
|
|
|
5107
4980
|
}
|
|
5108
4981
|
}
|
|
5109
4982
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
5110
|
-
_optionalChain([win, 'optionalAccess',
|
|
4983
|
+
_optionalChain([win, 'optionalAccess', _97 => _97.addEventListener, 'call', _98 => _98("beforeunload", handleBeforeUnload, { once: true })]);
|
|
5111
4984
|
return Object.defineProperty(
|
|
5112
4985
|
{
|
|
5113
4986
|
[kInternal]: {
|
|
@@ -5126,7 +4999,7 @@ function createAi(config) {
|
|
|
5126
4999
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
5127
5000
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
5128
5001
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
5129
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
5002
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _99 => _99.knowledge]) || [];
|
|
5130
5003
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
5131
5004
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
5132
5005
|
messagesStore.markMine(targetMessageId);
|
|
@@ -5136,9 +5009,9 @@ function createAi(config) {
|
|
|
5136
5009
|
sourceMessage: userMessage,
|
|
5137
5010
|
targetMessageId,
|
|
5138
5011
|
generationOptions: {
|
|
5139
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5140
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5141
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
5012
|
+
copilotId: _optionalChain([options, 'optionalAccess', _100 => _100.copilotId]),
|
|
5013
|
+
stream: _optionalChain([options, 'optionalAccess', _101 => _101.stream]),
|
|
5014
|
+
timeout: _optionalChain([options, 'optionalAccess', _102 => _102.timeout]),
|
|
5142
5015
|
// Combine global knowledge with request-specific knowledge
|
|
5143
5016
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
5144
5017
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -5210,7 +5083,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
5210
5083
|
}
|
|
5211
5084
|
}
|
|
5212
5085
|
function closePart(prevPart, endedAt) {
|
|
5213
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
5086
|
+
if (_optionalChain([prevPart, 'optionalAccess', _103 => _103.type]) === "reasoning") {
|
|
5214
5087
|
prevPart.endedAt ??= endedAt;
|
|
5215
5088
|
}
|
|
5216
5089
|
}
|
|
@@ -5225,7 +5098,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5225
5098
|
const lastPart = parts[parts.length - 1];
|
|
5226
5099
|
switch (delta.type) {
|
|
5227
5100
|
case "text-delta":
|
|
5228
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5101
|
+
if (_optionalChain([lastPart, 'optionalAccess', _104 => _104.type]) === "text") {
|
|
5229
5102
|
lastPart.text += delta.textDelta;
|
|
5230
5103
|
} else {
|
|
5231
5104
|
closePart(lastPart, now2);
|
|
@@ -5233,7 +5106,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5233
5106
|
}
|
|
5234
5107
|
break;
|
|
5235
5108
|
case "reasoning-delta":
|
|
5236
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5109
|
+
if (_optionalChain([lastPart, 'optionalAccess', _105 => _105.type]) === "reasoning") {
|
|
5237
5110
|
lastPart.text += delta.textDelta;
|
|
5238
5111
|
} else {
|
|
5239
5112
|
closePart(lastPart, now2);
|
|
@@ -5253,8 +5126,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
5253
5126
|
break;
|
|
5254
5127
|
}
|
|
5255
5128
|
case "tool-delta": {
|
|
5256
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5257
|
-
_optionalChain([lastPart, 'access',
|
|
5129
|
+
if (_optionalChain([lastPart, 'optionalAccess', _106 => _106.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
5130
|
+
_optionalChain([lastPart, 'access', _107 => _107.__appendDelta, 'optionalCall', _108 => _108(delta.delta)]);
|
|
5258
5131
|
}
|
|
5259
5132
|
break;
|
|
5260
5133
|
}
|
|
@@ -5609,7 +5482,7 @@ function explicitAccessForResource(source, resource) {
|
|
|
5609
5482
|
}
|
|
5610
5483
|
function permissionForAccessLevel(resource, access, field = resource) {
|
|
5611
5484
|
const permissions = PERMISSIONS_BY_RESOURCE[resource][access];
|
|
5612
|
-
const permission = _optionalChain([permissions, 'optionalAccess',
|
|
5485
|
+
const permission = _optionalChain([permissions, 'optionalAccess', _109 => _109[0]]);
|
|
5613
5486
|
if (permission !== void 0) {
|
|
5614
5487
|
return permission;
|
|
5615
5488
|
}
|
|
@@ -5719,7 +5592,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5719
5592
|
return void 0;
|
|
5720
5593
|
}
|
|
5721
5594
|
async function makeAuthRequest(options) {
|
|
5722
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
5595
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _110 => _110.polyfills, 'optionalAccess', _111 => _111.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
5723
5596
|
if (authentication.type === "private") {
|
|
5724
5597
|
if (fetcher === void 0) {
|
|
5725
5598
|
throw new StopRetrying(
|
|
@@ -5732,14 +5605,14 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5732
5605
|
const parsed = parseAuthToken(response.token);
|
|
5733
5606
|
if (seenTokens.has(parsed.raw)) {
|
|
5734
5607
|
const cachedToken = getCachedToken(options);
|
|
5735
|
-
if (_optionalChain([cachedToken, 'optionalAccess',
|
|
5608
|
+
if (_optionalChain([cachedToken, 'optionalAccess', _112 => _112.raw]) === parsed.raw) {
|
|
5736
5609
|
return cachedToken;
|
|
5737
5610
|
}
|
|
5738
5611
|
throw new StopRetrying(
|
|
5739
5612
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
5740
5613
|
);
|
|
5741
5614
|
}
|
|
5742
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5615
|
+
_optionalChain([onAuthenticate, 'optionalCall', _113 => _113(parsed.parsed)]);
|
|
5743
5616
|
return parsed;
|
|
5744
5617
|
}
|
|
5745
5618
|
if (authentication.type === "custom") {
|
|
@@ -5747,7 +5620,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5747
5620
|
if (response && typeof response === "object") {
|
|
5748
5621
|
if (typeof response.token === "string") {
|
|
5749
5622
|
const parsed = parseAuthToken(response.token);
|
|
5750
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5623
|
+
_optionalChain([onAuthenticate, 'optionalCall', _114 => _114(parsed.parsed)]);
|
|
5751
5624
|
return parsed;
|
|
5752
5625
|
} else if (typeof response.error === "string") {
|
|
5753
5626
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5942,15 +5815,13 @@ var OpCode = Object.freeze({
|
|
|
5942
5815
|
DELETE_CRDT: 5,
|
|
5943
5816
|
DELETE_OBJECT_KEY: 6,
|
|
5944
5817
|
CREATE_MAP: 7,
|
|
5945
|
-
CREATE_REGISTER: 8
|
|
5946
|
-
// 9 and 10 are reserved for the parallel LiveText work.
|
|
5947
|
-
CREATE_FILE: 11
|
|
5818
|
+
CREATE_REGISTER: 8
|
|
5948
5819
|
});
|
|
5949
5820
|
function isIgnoredOp(op) {
|
|
5950
5821
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5951
5822
|
}
|
|
5952
5823
|
function isCreateOp(op) {
|
|
5953
|
-
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.
|
|
5824
|
+
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_LIST;
|
|
5954
5825
|
}
|
|
5955
5826
|
|
|
5956
5827
|
// src/protocol/StorageNode.ts
|
|
@@ -5958,9 +5829,7 @@ var CrdtType = Object.freeze({
|
|
|
5958
5829
|
OBJECT: 0,
|
|
5959
5830
|
LIST: 1,
|
|
5960
5831
|
MAP: 2,
|
|
5961
|
-
REGISTER: 3
|
|
5962
|
-
// 4 is reserved for the parallel LiveText work.
|
|
5963
|
-
FILE: 5
|
|
5832
|
+
REGISTER: 3
|
|
5964
5833
|
});
|
|
5965
5834
|
function isRootStorageNode(node) {
|
|
5966
5835
|
return node[0] === "root";
|
|
@@ -5977,9 +5846,6 @@ function isMapStorageNode(node) {
|
|
|
5977
5846
|
function isRegisterStorageNode(node) {
|
|
5978
5847
|
return node[1].type === CrdtType.REGISTER;
|
|
5979
5848
|
}
|
|
5980
|
-
function isFileStorageNode(node) {
|
|
5981
|
-
return node[1].type === CrdtType.FILE;
|
|
5982
|
-
}
|
|
5983
5849
|
function isCompactRootNode(node) {
|
|
5984
5850
|
return node[0] === "root";
|
|
5985
5851
|
}
|
|
@@ -6002,9 +5868,6 @@ function* compactNodesToNodeStream(compactNodes) {
|
|
|
6002
5868
|
case CrdtType.REGISTER:
|
|
6003
5869
|
yield [cnode[0], { type: CrdtType.REGISTER, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6004
5870
|
break;
|
|
6005
|
-
case CrdtType.FILE:
|
|
6006
|
-
yield [cnode[0], { type: CrdtType.FILE, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6007
|
-
break;
|
|
6008
5871
|
default:
|
|
6009
5872
|
}
|
|
6010
5873
|
}
|
|
@@ -6033,10 +5896,6 @@ function* nodeStreamToCompactNodes(nodes) {
|
|
|
6033
5896
|
const id = node[0];
|
|
6034
5897
|
const crdt = node[1];
|
|
6035
5898
|
yield [id, CrdtType.REGISTER, crdt.parentId, crdt.parentKey, crdt.data];
|
|
6036
|
-
} else if (isFileStorageNode(node)) {
|
|
6037
|
-
const id = node[0];
|
|
6038
|
-
const crdt = node[1];
|
|
6039
|
-
yield [id, CrdtType.FILE, crdt.parentId, crdt.parentKey, crdt.data];
|
|
6040
5899
|
} else {
|
|
6041
5900
|
}
|
|
6042
5901
|
}
|
|
@@ -6275,12 +6134,12 @@ ${parentKey}`;
|
|
|
6275
6134
|
if (isCreateOp(op)) {
|
|
6276
6135
|
const posKey = this.#posKey(op.parentId, op.parentKey);
|
|
6277
6136
|
const atPosition = this.#createOpsByPosition.get(posKey);
|
|
6278
|
-
_optionalChain([atPosition, 'optionalAccess',
|
|
6137
|
+
_optionalChain([atPosition, 'optionalAccess', _115 => _115.delete, 'call', _116 => _116(opId)]);
|
|
6279
6138
|
if (atPosition !== void 0 && atPosition.size === 0) {
|
|
6280
6139
|
this.#createOpsByPosition.delete(posKey);
|
|
6281
6140
|
}
|
|
6282
6141
|
const inParent = this.#createOpsByParent.get(op.parentId);
|
|
6283
|
-
_optionalChain([inParent, 'optionalAccess',
|
|
6142
|
+
_optionalChain([inParent, 'optionalAccess', _117 => _117.delete, 'call', _118 => _118(opId)]);
|
|
6284
6143
|
if (inParent !== void 0 && inParent.size === 0) {
|
|
6285
6144
|
this.#createOpsByParent.delete(op.parentId);
|
|
6286
6145
|
}
|
|
@@ -6292,14 +6151,14 @@ ${parentKey}`;
|
|
|
6292
6151
|
* Empty if none.
|
|
6293
6152
|
*/
|
|
6294
6153
|
getByParentIdAndKey(parentId, parentKey) {
|
|
6295
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6154
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _119 => _119.#createOpsByPosition, 'access', _120 => _120.get, 'call', _121 => _121(this.#posKey(parentId, parentKey)), 'optionalAccess', _122 => _122.values, 'call', _123 => _123()]), () => ( []));
|
|
6296
6155
|
}
|
|
6297
6156
|
/**
|
|
6298
6157
|
* The still-unacknowledged Create ops with the given `parentId` (across all
|
|
6299
6158
|
* positions), in dispatch order. O(1) lookup. Empty if none.
|
|
6300
6159
|
*/
|
|
6301
6160
|
getByParentId(parentId) {
|
|
6302
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6161
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _124 => _124.#createOpsByParent, 'access', _125 => _125.get, 'call', _126 => _126(parentId), 'optionalAccess', _127 => _127.values, 'call', _128 => _128()]), () => ( []));
|
|
6303
6162
|
}
|
|
6304
6163
|
/** All still-unacknowledged ops, in dispatch order. */
|
|
6305
6164
|
values() {
|
|
@@ -6340,7 +6199,7 @@ function createManagedPool(roomId, options) {
|
|
|
6340
6199
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
6341
6200
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
6342
6201
|
dispatch(ops, reverse, storageUpdates) {
|
|
6343
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
6202
|
+
_optionalChain([onDispatch, 'optionalCall', _129 => _129(ops, reverse, storageUpdates)]);
|
|
6344
6203
|
},
|
|
6345
6204
|
assertStorageIsWritable: () => {
|
|
6346
6205
|
if (!isStorageWritable()) {
|
|
@@ -6549,91 +6408,6 @@ var AbstractCrdt = class {
|
|
|
6549
6408
|
}
|
|
6550
6409
|
};
|
|
6551
6410
|
|
|
6552
|
-
// src/crdts/LiveFile.ts
|
|
6553
|
-
var LiveFile = class _LiveFile extends AbstractCrdt {
|
|
6554
|
-
#data;
|
|
6555
|
-
constructor(data) {
|
|
6556
|
-
super();
|
|
6557
|
-
this.#data = Object.freeze({ ...data });
|
|
6558
|
-
}
|
|
6559
|
-
get data() {
|
|
6560
|
-
return this.#data;
|
|
6561
|
-
}
|
|
6562
|
-
get id() {
|
|
6563
|
-
return this.#data.id;
|
|
6564
|
-
}
|
|
6565
|
-
get name() {
|
|
6566
|
-
return this.#data.name;
|
|
6567
|
-
}
|
|
6568
|
-
get size() {
|
|
6569
|
-
return this.#data.size;
|
|
6570
|
-
}
|
|
6571
|
-
get mimeType() {
|
|
6572
|
-
return this.#data.mimeType;
|
|
6573
|
-
}
|
|
6574
|
-
/** @internal */
|
|
6575
|
-
static _deserialize([id, item], _parentToChildren, pool) {
|
|
6576
|
-
const file = new _LiveFile(item.data);
|
|
6577
|
-
file._attach(id, pool);
|
|
6578
|
-
return file;
|
|
6579
|
-
}
|
|
6580
|
-
/** @internal */
|
|
6581
|
-
_toOps(parentId, parentKey) {
|
|
6582
|
-
if (this._id === void 0) {
|
|
6583
|
-
throw new Error("Cannot serialize LiveFile if parent is missing");
|
|
6584
|
-
}
|
|
6585
|
-
return [
|
|
6586
|
-
{
|
|
6587
|
-
type: OpCode.CREATE_FILE,
|
|
6588
|
-
id: this._id,
|
|
6589
|
-
parentId,
|
|
6590
|
-
parentKey,
|
|
6591
|
-
data: this.#data
|
|
6592
|
-
}
|
|
6593
|
-
];
|
|
6594
|
-
}
|
|
6595
|
-
/** @internal */
|
|
6596
|
-
_serialize() {
|
|
6597
|
-
if (this.parent.type !== "HasParent") {
|
|
6598
|
-
throw new Error("Cannot serialize LiveFile if parent is missing");
|
|
6599
|
-
}
|
|
6600
|
-
return {
|
|
6601
|
-
type: CrdtType.FILE,
|
|
6602
|
-
parentId: nn(this.parent.node._id, "Parent node expected to have ID"),
|
|
6603
|
-
parentKey: this.parent.key,
|
|
6604
|
-
data: this.#data
|
|
6605
|
-
};
|
|
6606
|
-
}
|
|
6607
|
-
/** @internal */
|
|
6608
|
-
_attachChild(_op) {
|
|
6609
|
-
throw new Error("Method not implemented.");
|
|
6610
|
-
}
|
|
6611
|
-
/** @internal */
|
|
6612
|
-
_detachChild(_crdt) {
|
|
6613
|
-
throw new Error("Method not implemented.");
|
|
6614
|
-
}
|
|
6615
|
-
/** @internal */
|
|
6616
|
-
_apply(op, isLocal) {
|
|
6617
|
-
return super._apply(op, isLocal);
|
|
6618
|
-
}
|
|
6619
|
-
/** @internal */
|
|
6620
|
-
_toTreeNode(key) {
|
|
6621
|
-
return {
|
|
6622
|
-
type: "Json",
|
|
6623
|
-
id: _nullishCoalesce(this._id, () => ( nanoid())),
|
|
6624
|
-
key,
|
|
6625
|
-
payload: this.#data
|
|
6626
|
-
};
|
|
6627
|
-
}
|
|
6628
|
-
/** @internal */
|
|
6629
|
-
_toJSON() {
|
|
6630
|
-
return this.#data;
|
|
6631
|
-
}
|
|
6632
|
-
clone() {
|
|
6633
|
-
return new _LiveFile(this.#data);
|
|
6634
|
-
}
|
|
6635
|
-
};
|
|
6636
|
-
|
|
6637
6411
|
// src/crdts/LiveRegister.ts
|
|
6638
6412
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
6639
6413
|
#data;
|
|
@@ -7149,7 +6923,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7149
6923
|
#applyInsertUndoRedo(op) {
|
|
7150
6924
|
const { id, parentKey: key } = op;
|
|
7151
6925
|
const child = creationOpToLiveNode(op);
|
|
7152
|
-
if (_optionalChain([this, 'access',
|
|
6926
|
+
if (_optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.getNode, 'call', _132 => _132(id)]) !== void 0) {
|
|
7153
6927
|
return { modified: false };
|
|
7154
6928
|
}
|
|
7155
6929
|
child._attach(id, nn(this._pool));
|
|
@@ -7157,8 +6931,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7157
6931
|
const existingItemIndex = this._indexOfPosition(key);
|
|
7158
6932
|
let newKey = key;
|
|
7159
6933
|
if (existingItemIndex !== -1) {
|
|
7160
|
-
const before2 = _optionalChain([this, 'access',
|
|
7161
|
-
const after2 = _optionalChain([this, 'access',
|
|
6934
|
+
const before2 = _optionalChain([this, 'access', _133 => _133.#items, 'access', _134 => _134.at, 'call', _135 => _135(existingItemIndex), 'optionalAccess', _136 => _136._parentPos]);
|
|
6935
|
+
const after2 = _optionalChain([this, 'access', _137 => _137.#items, 'access', _138 => _138.at, 'call', _139 => _139(existingItemIndex + 1), 'optionalAccess', _140 => _140._parentPos]);
|
|
7162
6936
|
newKey = makePosition(before2, after2);
|
|
7163
6937
|
child._setParentLink(this, newKey);
|
|
7164
6938
|
}
|
|
@@ -7172,7 +6946,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7172
6946
|
#applySetUndoRedo(op) {
|
|
7173
6947
|
const { id, parentKey: key } = op;
|
|
7174
6948
|
const child = creationOpToLiveNode(op);
|
|
7175
|
-
if (_optionalChain([this, 'access',
|
|
6949
|
+
if (_optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.getNode, 'call', _143 => _143(id)]) !== void 0) {
|
|
7176
6950
|
return { modified: false };
|
|
7177
6951
|
}
|
|
7178
6952
|
const indexOfItemWithSameKey = this._indexOfPosition(key);
|
|
@@ -7293,7 +7067,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7293
7067
|
} else {
|
|
7294
7068
|
this.#updateItemPositionAt(
|
|
7295
7069
|
existingItemIndex,
|
|
7296
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
7070
|
+
makePosition(newKey, _optionalChain([this, 'access', _144 => _144.#items, 'access', _145 => _145.at, 'call', _146 => _146(existingItemIndex + 1), 'optionalAccess', _147 => _147._parentPos]))
|
|
7297
7071
|
);
|
|
7298
7072
|
const previousIndex = this.#items.findIndex((item) => item === child);
|
|
7299
7073
|
this.#updateItemPosition(child, newKey);
|
|
@@ -7320,7 +7094,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7320
7094
|
this,
|
|
7321
7095
|
makePosition(
|
|
7322
7096
|
newKey,
|
|
7323
|
-
_optionalChain([this, 'access',
|
|
7097
|
+
_optionalChain([this, 'access', _148 => _148.#items, 'access', _149 => _149.at, 'call', _150 => _150(existingItemIndex + 1), 'optionalAccess', _151 => _151._parentPos])
|
|
7324
7098
|
)
|
|
7325
7099
|
);
|
|
7326
7100
|
this.#items.reposition(existingItem);
|
|
@@ -7344,7 +7118,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7344
7118
|
existingItemIndex,
|
|
7345
7119
|
makePosition(
|
|
7346
7120
|
newKey,
|
|
7347
|
-
_optionalChain([this, 'access',
|
|
7121
|
+
_optionalChain([this, 'access', _152 => _152.#items, 'access', _153 => _153.at, 'call', _154 => _154(existingItemIndex + 1), 'optionalAccess', _155 => _155._parentPos])
|
|
7348
7122
|
)
|
|
7349
7123
|
);
|
|
7350
7124
|
}
|
|
@@ -7372,7 +7146,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7372
7146
|
if (existingItemIndex !== -1) {
|
|
7373
7147
|
actualNewKey = makePosition(
|
|
7374
7148
|
newKey,
|
|
7375
|
-
_optionalChain([this, 'access',
|
|
7149
|
+
_optionalChain([this, 'access', _156 => _156.#items, 'access', _157 => _157.at, 'call', _158 => _158(existingItemIndex + 1), 'optionalAccess', _159 => _159._parentPos])
|
|
7376
7150
|
);
|
|
7377
7151
|
}
|
|
7378
7152
|
this.#updateItemPosition(child, actualNewKey);
|
|
@@ -7446,14 +7220,14 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7446
7220
|
* instead of resolving its position against the client's stale view.
|
|
7447
7221
|
*/
|
|
7448
7222
|
#injectAt(element, index, intent) {
|
|
7449
|
-
_optionalChain([this, 'access',
|
|
7223
|
+
_optionalChain([this, 'access', _160 => _160._pool, 'optionalAccess', _161 => _161.assertStorageIsWritable, 'call', _162 => _162()]);
|
|
7450
7224
|
if (index < 0 || index > this.#items.length) {
|
|
7451
7225
|
throw new Error(
|
|
7452
7226
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
7453
7227
|
);
|
|
7454
7228
|
}
|
|
7455
|
-
const before2 = _optionalChain([this, 'access',
|
|
7456
|
-
const after2 = _optionalChain([this, 'access',
|
|
7229
|
+
const before2 = _optionalChain([this, 'access', _163 => _163.#items, 'access', _164 => _164.at, 'call', _165 => _165(index - 1), 'optionalAccess', _166 => _166._parentPos]);
|
|
7230
|
+
const after2 = _optionalChain([this, 'access', _167 => _167.#items, 'access', _168 => _168.at, 'call', _169 => _169(index), 'optionalAccess', _170 => _170._parentPos]);
|
|
7457
7231
|
const position = makePosition(before2, after2);
|
|
7458
7232
|
const value = lsonToLiveNode(element);
|
|
7459
7233
|
value._setParentLink(this, position);
|
|
@@ -7477,7 +7251,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7477
7251
|
* @param targetIndex The index where the element should be after moving.
|
|
7478
7252
|
*/
|
|
7479
7253
|
move(index, targetIndex) {
|
|
7480
|
-
_optionalChain([this, 'access',
|
|
7254
|
+
_optionalChain([this, 'access', _171 => _171._pool, 'optionalAccess', _172 => _172.assertStorageIsWritable, 'call', _173 => _173()]);
|
|
7481
7255
|
if (targetIndex < 0) {
|
|
7482
7256
|
throw new Error("targetIndex cannot be less than 0");
|
|
7483
7257
|
}
|
|
@@ -7495,11 +7269,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7495
7269
|
let beforePosition = null;
|
|
7496
7270
|
let afterPosition = null;
|
|
7497
7271
|
if (index < targetIndex) {
|
|
7498
|
-
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access',
|
|
7272
|
+
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access', _174 => _174.#items, 'access', _175 => _175.at, 'call', _176 => _176(targetIndex + 1), 'optionalAccess', _177 => _177._parentPos]);
|
|
7499
7273
|
beforePosition = this.#items.at(targetIndex)._parentPos;
|
|
7500
7274
|
} else {
|
|
7501
7275
|
afterPosition = this.#items.at(targetIndex)._parentPos;
|
|
7502
|
-
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access',
|
|
7276
|
+
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access', _178 => _178.#items, 'access', _179 => _179.at, 'call', _180 => _180(targetIndex - 1), 'optionalAccess', _181 => _181._parentPos]);
|
|
7503
7277
|
}
|
|
7504
7278
|
const position = makePosition(beforePosition, afterPosition);
|
|
7505
7279
|
const item = this.#items.at(index);
|
|
@@ -7534,7 +7308,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7534
7308
|
* @param index The index of the element to delete
|
|
7535
7309
|
*/
|
|
7536
7310
|
delete(index) {
|
|
7537
|
-
_optionalChain([this, 'access',
|
|
7311
|
+
_optionalChain([this, 'access', _182 => _182._pool, 'optionalAccess', _183 => _183.assertStorageIsWritable, 'call', _184 => _184()]);
|
|
7538
7312
|
if (index < 0 || index >= this.#items.length) {
|
|
7539
7313
|
throw new Error(
|
|
7540
7314
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7567,7 +7341,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7567
7341
|
}
|
|
7568
7342
|
}
|
|
7569
7343
|
clear() {
|
|
7570
|
-
_optionalChain([this, 'access',
|
|
7344
|
+
_optionalChain([this, 'access', _185 => _185._pool, 'optionalAccess', _186 => _186.assertStorageIsWritable, 'call', _187 => _187()]);
|
|
7571
7345
|
if (this._pool) {
|
|
7572
7346
|
const ops = [];
|
|
7573
7347
|
const reverseOps = [];
|
|
@@ -7601,7 +7375,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7601
7375
|
}
|
|
7602
7376
|
}
|
|
7603
7377
|
set(index, item) {
|
|
7604
|
-
_optionalChain([this, 'access',
|
|
7378
|
+
_optionalChain([this, 'access', _188 => _188._pool, 'optionalAccess', _189 => _189.assertStorageIsWritable, 'call', _190 => _190()]);
|
|
7605
7379
|
if (index < 0 || index >= this.#items.length) {
|
|
7606
7380
|
throw new Error(
|
|
7607
7381
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7760,7 +7534,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7760
7534
|
#shiftItemPosition(index, key) {
|
|
7761
7535
|
const shiftedPosition = makePosition(
|
|
7762
7536
|
key,
|
|
7763
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
7537
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _191 => _191.#items, 'access', _192 => _192.at, 'call', _193 => _193(index + 1), 'optionalAccess', _194 => _194._parentPos]) : void 0
|
|
7764
7538
|
);
|
|
7765
7539
|
this.#updateItemPositionAt(index, shiftedPosition);
|
|
7766
7540
|
}
|
|
@@ -8009,7 +7783,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8009
7783
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
8010
7784
|
*/
|
|
8011
7785
|
set(key, value) {
|
|
8012
|
-
_optionalChain([this, 'access',
|
|
7786
|
+
_optionalChain([this, 'access', _195 => _195._pool, 'optionalAccess', _196 => _196.assertStorageIsWritable, 'call', _197 => _197()]);
|
|
8013
7787
|
const oldValue = this.#map.get(key);
|
|
8014
7788
|
if (oldValue) {
|
|
8015
7789
|
oldValue._detach();
|
|
@@ -8055,7 +7829,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8055
7829
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
8056
7830
|
*/
|
|
8057
7831
|
delete(key) {
|
|
8058
|
-
_optionalChain([this, 'access',
|
|
7832
|
+
_optionalChain([this, 'access', _198 => _198._pool, 'optionalAccess', _199 => _199.assertStorageIsWritable, 'call', _200 => _200()]);
|
|
8059
7833
|
const item = this.#map.get(key);
|
|
8060
7834
|
if (item === void 0) {
|
|
8061
7835
|
return false;
|
|
@@ -8667,20 +8441,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8667
8441
|
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8668
8442
|
*/
|
|
8669
8443
|
setLocal(key, value) {
|
|
8670
|
-
_optionalChain([this, 'access',
|
|
8444
|
+
_optionalChain([this, 'access', _201 => _201._pool, 'optionalAccess', _202 => _202.assertStorageIsWritable, 'call', _203 => _203()]);
|
|
8671
8445
|
const deleteResult = this.#prepareDelete(key);
|
|
8672
8446
|
this.#local.set(key, value);
|
|
8673
8447
|
this.invalidate();
|
|
8674
8448
|
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8675
|
-
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8676
|
-
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8677
|
-
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8449
|
+
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _204 => _204[0]]), () => ( []));
|
|
8450
|
+
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _205 => _205[1]]), () => ( []));
|
|
8451
|
+
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _206 => _206[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8678
8452
|
const existing = storageUpdates.get(this._id);
|
|
8679
8453
|
storageUpdates.set(this._id, {
|
|
8680
8454
|
node: this,
|
|
8681
8455
|
type: "LiveObject",
|
|
8682
8456
|
updates: {
|
|
8683
|
-
..._optionalChain([existing, 'optionalAccess',
|
|
8457
|
+
..._optionalChain([existing, 'optionalAccess', _207 => _207.updates]),
|
|
8684
8458
|
[key]: { type: "update" }
|
|
8685
8459
|
}
|
|
8686
8460
|
});
|
|
@@ -8700,7 +8474,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8700
8474
|
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8701
8475
|
*/
|
|
8702
8476
|
#prepareDelete(key) {
|
|
8703
|
-
_optionalChain([this, 'access',
|
|
8477
|
+
_optionalChain([this, 'access', _208 => _208._pool, 'optionalAccess', _209 => _209.assertStorageIsWritable, 'call', _210 => _210()]);
|
|
8704
8478
|
const k = key;
|
|
8705
8479
|
if (this.#local.has(k) && !this.#synced.has(k)) {
|
|
8706
8480
|
const oldValue2 = this.#local.get(k);
|
|
@@ -8776,7 +8550,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8776
8550
|
const result = this.#prepareDelete(key);
|
|
8777
8551
|
if (result) {
|
|
8778
8552
|
const [ops, reverse, storageUpdates] = result;
|
|
8779
|
-
_optionalChain([this, 'access',
|
|
8553
|
+
_optionalChain([this, 'access', _211 => _211._pool, 'optionalAccess', _212 => _212.dispatch, 'call', _213 => _213(ops, reverse, storageUpdates)]);
|
|
8780
8554
|
}
|
|
8781
8555
|
}
|
|
8782
8556
|
/**
|
|
@@ -8784,7 +8558,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8784
8558
|
* @param patch The object used to overrides properties
|
|
8785
8559
|
*/
|
|
8786
8560
|
update(patch) {
|
|
8787
|
-
_optionalChain([this, 'access',
|
|
8561
|
+
_optionalChain([this, 'access', _214 => _214._pool, 'optionalAccess', _215 => _215.assertStorageIsWritable, 'call', _216 => _216()]);
|
|
8788
8562
|
if (_LiveObject.detectLargeObjects) {
|
|
8789
8563
|
const data = {};
|
|
8790
8564
|
for (const [key, value] of this.#synced) {
|
|
@@ -8990,8 +8764,6 @@ function creationOpToLiveNode(op) {
|
|
|
8990
8764
|
}
|
|
8991
8765
|
function creationOpToLson(op) {
|
|
8992
8766
|
switch (op.type) {
|
|
8993
|
-
case OpCode.CREATE_FILE:
|
|
8994
|
-
return new LiveFile(op.data);
|
|
8995
8767
|
case OpCode.CREATE_REGISTER:
|
|
8996
8768
|
return op.data;
|
|
8997
8769
|
case OpCode.CREATE_OBJECT:
|
|
@@ -9022,8 +8794,6 @@ function deserialize(node, parentToChildren, pool) {
|
|
|
9022
8794
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
9023
8795
|
} else if (isRegisterStorageNode(node)) {
|
|
9024
8796
|
return LiveRegister._deserialize(node, parentToChildren, pool);
|
|
9025
|
-
} else if (isFileStorageNode(node)) {
|
|
9026
|
-
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
9027
8797
|
} else {
|
|
9028
8798
|
throw new Error("Unexpected CRDT type");
|
|
9029
8799
|
}
|
|
@@ -9037,14 +8807,12 @@ function deserializeToLson(node, parentToChildren, pool) {
|
|
|
9037
8807
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
9038
8808
|
} else if (isRegisterStorageNode(node)) {
|
|
9039
8809
|
return node[1].data;
|
|
9040
|
-
} else if (isFileStorageNode(node)) {
|
|
9041
|
-
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
9042
8810
|
} else {
|
|
9043
8811
|
throw new Error("Unexpected CRDT type");
|
|
9044
8812
|
}
|
|
9045
8813
|
}
|
|
9046
8814
|
function isLiveStructure(value) {
|
|
9047
|
-
return isLiveList(value) || isLiveMap(value) || isLiveObject(value)
|
|
8815
|
+
return isLiveList(value) || isLiveMap(value) || isLiveObject(value);
|
|
9048
8816
|
}
|
|
9049
8817
|
function isLiveNode(value) {
|
|
9050
8818
|
return isLiveStructure(value) || isLiveRegister(value);
|
|
@@ -9058,9 +8826,6 @@ function isLiveMap(value) {
|
|
|
9058
8826
|
function isLiveObject(value) {
|
|
9059
8827
|
return value instanceof LiveObject;
|
|
9060
8828
|
}
|
|
9061
|
-
function isLiveFile(value) {
|
|
9062
|
-
return value instanceof LiveFile;
|
|
9063
|
-
}
|
|
9064
8829
|
function isLiveRegister(value) {
|
|
9065
8830
|
return value instanceof LiveRegister;
|
|
9066
8831
|
}
|
|
@@ -9070,14 +8835,14 @@ function cloneLson(value) {
|
|
|
9070
8835
|
function liveNodeToLson(obj) {
|
|
9071
8836
|
if (obj instanceof LiveRegister) {
|
|
9072
8837
|
return obj.data;
|
|
9073
|
-
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject
|
|
8838
|
+
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject) {
|
|
9074
8839
|
return obj;
|
|
9075
8840
|
} else {
|
|
9076
8841
|
return assertNever(obj, "Unknown AbstractCrdt");
|
|
9077
8842
|
}
|
|
9078
8843
|
}
|
|
9079
8844
|
function lsonToLiveNode(value) {
|
|
9080
|
-
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList
|
|
8845
|
+
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList) {
|
|
9081
8846
|
return value;
|
|
9082
8847
|
} else {
|
|
9083
8848
|
return new LiveRegister(value);
|
|
@@ -9094,8 +8859,6 @@ function dumpPool(pool) {
|
|
|
9094
8859
|
value = "<LiveList>";
|
|
9095
8860
|
} else if (node instanceof LiveMap) {
|
|
9096
8861
|
value = "<LiveMap>";
|
|
9097
|
-
} else if (node instanceof LiveFile) {
|
|
9098
|
-
value = stringifyOrLog(node.data);
|
|
9099
8862
|
} else {
|
|
9100
8863
|
value = "<LiveObject>";
|
|
9101
8864
|
}
|
|
@@ -9192,15 +8955,6 @@ function diffNodeMap(prev, next) {
|
|
|
9192
8955
|
data: crdt.data
|
|
9193
8956
|
});
|
|
9194
8957
|
break;
|
|
9195
|
-
case CrdtType.FILE:
|
|
9196
|
-
ops.push({
|
|
9197
|
-
type: OpCode.CREATE_FILE,
|
|
9198
|
-
id,
|
|
9199
|
-
parentId: crdt.parentId,
|
|
9200
|
-
parentKey: crdt.parentKey,
|
|
9201
|
-
data: crdt.data
|
|
9202
|
-
});
|
|
9203
|
-
break;
|
|
9204
8958
|
case CrdtType.LIST:
|
|
9205
8959
|
ops.push({
|
|
9206
8960
|
type: OpCode.CREATE_LIST,
|
|
@@ -9291,7 +9045,7 @@ function sendToPanel(message, options) {
|
|
|
9291
9045
|
...message,
|
|
9292
9046
|
source: "liveblocks-devtools-client"
|
|
9293
9047
|
};
|
|
9294
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
9048
|
+
if (!(_optionalChain([options, 'optionalAccess', _217 => _217.force]) || _bridgeActive)) {
|
|
9295
9049
|
return;
|
|
9296
9050
|
}
|
|
9297
9051
|
window.postMessage(fullMsg, "*");
|
|
@@ -9299,7 +9053,7 @@ function sendToPanel(message, options) {
|
|
|
9299
9053
|
var eventSource = makeEventSource();
|
|
9300
9054
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
9301
9055
|
window.addEventListener("message", (event) => {
|
|
9302
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
9056
|
+
if (event.source === window && _optionalChain([event, 'access', _218 => _218.data, 'optionalAccess', _219 => _219.source]) === "liveblocks-devtools-panel") {
|
|
9303
9057
|
eventSource.notify(event.data);
|
|
9304
9058
|
} else {
|
|
9305
9059
|
}
|
|
@@ -9441,7 +9195,7 @@ function fullSync(room) {
|
|
|
9441
9195
|
msg: "room::sync::full",
|
|
9442
9196
|
roomId: room.id,
|
|
9443
9197
|
status: room.getStatus(),
|
|
9444
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
9198
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _220 => _220.toTreeNode, 'call', _221 => _221("root"), 'access', _222 => _222.payload]), () => ( null)),
|
|
9445
9199
|
me,
|
|
9446
9200
|
others
|
|
9447
9201
|
});
|
|
@@ -10098,9 +9852,6 @@ function defaultMessageFromContext(context) {
|
|
|
10098
9852
|
|
|
10099
9853
|
// src/room.ts
|
|
10100
9854
|
var FEEDS_TIMEOUT = 5e3;
|
|
10101
|
-
function getLiveFileId(file) {
|
|
10102
|
-
return typeof file === "string" ? file : file.id;
|
|
10103
|
-
}
|
|
10104
9855
|
function connectionAccessFromScopes(scopes) {
|
|
10105
9856
|
const roomPermissions = normalizeRoomPermissions(scopes);
|
|
10106
9857
|
const matrix = permissionMatrixFromScopes(roomPermissions);
|
|
@@ -10131,15 +9882,15 @@ function installBackgroundTabSpy() {
|
|
|
10131
9882
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10132
9883
|
const inBackgroundSince = { current: null };
|
|
10133
9884
|
function onVisibilityChange() {
|
|
10134
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
9885
|
+
if (_optionalChain([doc, 'optionalAccess', _223 => _223.visibilityState]) === "hidden") {
|
|
10135
9886
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
10136
9887
|
} else {
|
|
10137
9888
|
inBackgroundSince.current = null;
|
|
10138
9889
|
}
|
|
10139
9890
|
}
|
|
10140
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9891
|
+
_optionalChain([doc, 'optionalAccess', _224 => _224.addEventListener, 'call', _225 => _225("visibilitychange", onVisibilityChange)]);
|
|
10141
9892
|
const unsub = () => {
|
|
10142
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9893
|
+
_optionalChain([doc, 'optionalAccess', _226 => _226.removeEventListener, 'call', _227 => _227("visibilitychange", onVisibilityChange)]);
|
|
10143
9894
|
};
|
|
10144
9895
|
return [inBackgroundSince, unsub];
|
|
10145
9896
|
}
|
|
@@ -10163,7 +9914,7 @@ function makeNodeMapBuffer() {
|
|
|
10163
9914
|
function topLevelKeysOf(nodes) {
|
|
10164
9915
|
const keys2 = /* @__PURE__ */ new Set();
|
|
10165
9916
|
const root = nodes.get("root");
|
|
10166
|
-
for (const key in _optionalChain([root, 'optionalAccess',
|
|
9917
|
+
for (const key in _optionalChain([root, 'optionalAccess', _228 => _228.data])) {
|
|
10167
9918
|
keys2.add(key);
|
|
10168
9919
|
}
|
|
10169
9920
|
for (const node of nodes.values()) {
|
|
@@ -10346,7 +10097,7 @@ function createRoom(options, config) {
|
|
|
10346
10097
|
}
|
|
10347
10098
|
}
|
|
10348
10099
|
function isStorageWritable() {
|
|
10349
|
-
const permissionMatrix = _optionalChain([context, 'access',
|
|
10100
|
+
const permissionMatrix = _optionalChain([context, 'access', _229 => _229.dynamicSessionInfoSig, 'access', _230 => _230.get, 'call', _231 => _231(), 'optionalAccess', _232 => _232.permissionMatrix]);
|
|
10350
10101
|
return permissionMatrix !== void 0 ? hasPermissionAccess(permissionMatrix, "storage", "write") : true;
|
|
10351
10102
|
}
|
|
10352
10103
|
const eventHub = {
|
|
@@ -10458,7 +10209,7 @@ function createRoom(options, config) {
|
|
|
10458
10209
|
context.pool
|
|
10459
10210
|
);
|
|
10460
10211
|
}
|
|
10461
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
10212
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _233 => _233.get, 'call', _234 => _234(), 'optionalAccess', _235 => _235.canWrite]), () => ( true));
|
|
10462
10213
|
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
10463
10214
|
const root = context.root;
|
|
10464
10215
|
disableHistory(() => {
|
|
@@ -10590,7 +10341,7 @@ function createRoom(options, config) {
|
|
|
10590
10341
|
);
|
|
10591
10342
|
output.reverse.pushLeft(applyOpResult.reverse);
|
|
10592
10343
|
}
|
|
10593
|
-
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT
|
|
10344
|
+
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
10594
10345
|
createdNodeIds.add(op.id);
|
|
10595
10346
|
}
|
|
10596
10347
|
}
|
|
@@ -10634,7 +10385,6 @@ function createRoom(options, config) {
|
|
|
10634
10385
|
case OpCode.CREATE_OBJECT:
|
|
10635
10386
|
case OpCode.CREATE_LIST:
|
|
10636
10387
|
case OpCode.CREATE_MAP:
|
|
10637
|
-
case OpCode.CREATE_FILE:
|
|
10638
10388
|
case OpCode.CREATE_REGISTER: {
|
|
10639
10389
|
if (op.parentId === void 0) {
|
|
10640
10390
|
return { modified: false };
|
|
@@ -10665,7 +10415,7 @@ function createRoom(options, config) {
|
|
|
10665
10415
|
}
|
|
10666
10416
|
context.myPresence.patch(patch);
|
|
10667
10417
|
if (context.activeBatch) {
|
|
10668
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10418
|
+
if (_optionalChain([options2, 'optionalAccess', _236 => _236.addToHistory])) {
|
|
10669
10419
|
context.activeBatch.reverseOps.pushLeft({
|
|
10670
10420
|
type: "presence",
|
|
10671
10421
|
data: oldValues
|
|
@@ -10674,7 +10424,7 @@ function createRoom(options, config) {
|
|
|
10674
10424
|
context.activeBatch.updates.presence = true;
|
|
10675
10425
|
} else {
|
|
10676
10426
|
flushNowOrSoon();
|
|
10677
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10427
|
+
if (_optionalChain([options2, 'optionalAccess', _237 => _237.addToHistory])) {
|
|
10678
10428
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
10679
10429
|
}
|
|
10680
10430
|
notify({ presence: true });
|
|
@@ -10853,11 +10603,11 @@ function createRoom(options, config) {
|
|
|
10853
10603
|
break;
|
|
10854
10604
|
}
|
|
10855
10605
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
10856
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
10606
|
+
_optionalChain([stopwatch, 'optionalAccess', _238 => _238.lap, 'call', _239 => _239()]);
|
|
10857
10607
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
10858
10608
|
break;
|
|
10859
10609
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
10860
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
10610
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _240 => _240.stop, 'call', _241 => _241()]);
|
|
10861
10611
|
if (timing) {
|
|
10862
10612
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
10863
10613
|
const rest = timing.laps.slice(1);
|
|
@@ -10992,11 +10742,11 @@ function createRoom(options, config) {
|
|
|
10992
10742
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
10993
10743
|
const pending = pendingFeedsRequests.get(requestId);
|
|
10994
10744
|
pendingFeedsRequests.delete(requestId);
|
|
10995
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10745
|
+
_optionalChain([pending, 'optionalAccess', _242 => _242.reject, 'call', _243 => _243(err)]);
|
|
10996
10746
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
10997
10747
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
10998
10748
|
pendingFeedMessagesRequests.delete(requestId);
|
|
10999
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10749
|
+
_optionalChain([pending, 'optionalAccess', _244 => _244.reject, 'call', _245 => _245(err)]);
|
|
11000
10750
|
}
|
|
11001
10751
|
eventHub.feeds.notify(message);
|
|
11002
10752
|
break;
|
|
@@ -11150,10 +10900,10 @@ function createRoom(options, config) {
|
|
|
11150
10900
|
timeoutId,
|
|
11151
10901
|
kind,
|
|
11152
10902
|
feedId,
|
|
11153
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
11154
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
10903
|
+
messageId: _optionalChain([options2, 'optionalAccess', _246 => _246.messageId]),
|
|
10904
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _247 => _247.expectedClientMessageId])
|
|
11155
10905
|
});
|
|
11156
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
10906
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _248 => _248.expectedClientMessageId]) === void 0) {
|
|
11157
10907
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
11158
10908
|
q.push(requestId);
|
|
11159
10909
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -11204,10 +10954,10 @@ function createRoom(options, config) {
|
|
|
11204
10954
|
}
|
|
11205
10955
|
if (!matched) {
|
|
11206
10956
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
11207
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
10957
|
+
const headId = _optionalChain([q, 'optionalAccess', _249 => _249[0]]);
|
|
11208
10958
|
if (headId !== void 0) {
|
|
11209
10959
|
const pending = pendingFeedMutations.get(headId);
|
|
11210
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
10960
|
+
if (_optionalChain([pending, 'optionalAccess', _250 => _250.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
11211
10961
|
settleFeedMutation(headId, "ok");
|
|
11212
10962
|
}
|
|
11213
10963
|
}
|
|
@@ -11243,7 +10993,7 @@ function createRoom(options, config) {
|
|
|
11243
10993
|
const unacknowledgedOps2 = [...context.unacknowledgedOps.values()];
|
|
11244
10994
|
createOrUpdateRootFromMessage(nodes);
|
|
11245
10995
|
applyAndSendOfflineOps(unacknowledgedOps2);
|
|
11246
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
10996
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _251 => _251()]);
|
|
11247
10997
|
notifyStorageStatus();
|
|
11248
10998
|
eventHub.storageDidLoad.notify();
|
|
11249
10999
|
}
|
|
@@ -11252,7 +11002,7 @@ function createRoom(options, config) {
|
|
|
11252
11002
|
if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
11253
11003
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
11254
11004
|
nodeMapBuffer.take();
|
|
11255
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
11005
|
+
_optionalChain([stopwatch, 'optionalAccess', _252 => _252.start, 'call', _253 => _253()]);
|
|
11256
11006
|
}
|
|
11257
11007
|
}
|
|
11258
11008
|
function startLoadingStorage() {
|
|
@@ -11306,10 +11056,10 @@ function createRoom(options, config) {
|
|
|
11306
11056
|
const message = {
|
|
11307
11057
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
11308
11058
|
requestId,
|
|
11309
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11310
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11311
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11312
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11059
|
+
cursor: _optionalChain([options2, 'optionalAccess', _254 => _254.cursor]),
|
|
11060
|
+
since: _optionalChain([options2, 'optionalAccess', _255 => _255.since]),
|
|
11061
|
+
limit: _optionalChain([options2, 'optionalAccess', _256 => _256.limit]),
|
|
11062
|
+
metadata: _optionalChain([options2, 'optionalAccess', _257 => _257.metadata])
|
|
11313
11063
|
};
|
|
11314
11064
|
context.buffer.messages.push(message);
|
|
11315
11065
|
flushNowOrSoon();
|
|
@@ -11329,9 +11079,9 @@ function createRoom(options, config) {
|
|
|
11329
11079
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
11330
11080
|
requestId,
|
|
11331
11081
|
feedId,
|
|
11332
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11333
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11334
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11082
|
+
cursor: _optionalChain([options2, 'optionalAccess', _258 => _258.cursor]),
|
|
11083
|
+
since: _optionalChain([options2, 'optionalAccess', _259 => _259.since]),
|
|
11084
|
+
limit: _optionalChain([options2, 'optionalAccess', _260 => _260.limit])
|
|
11335
11085
|
};
|
|
11336
11086
|
context.buffer.messages.push(message);
|
|
11337
11087
|
flushNowOrSoon();
|
|
@@ -11350,8 +11100,8 @@ function createRoom(options, config) {
|
|
|
11350
11100
|
type: ClientMsgCode.ADD_FEED,
|
|
11351
11101
|
requestId,
|
|
11352
11102
|
feedId,
|
|
11353
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11354
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11103
|
+
metadata: _optionalChain([options2, 'optionalAccess', _261 => _261.metadata]),
|
|
11104
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _262 => _262.createdAt])
|
|
11355
11105
|
};
|
|
11356
11106
|
context.buffer.messages.push(message);
|
|
11357
11107
|
flushNowOrSoon();
|
|
@@ -11385,15 +11135,15 @@ function createRoom(options, config) {
|
|
|
11385
11135
|
function addFeedMessage(feedId, data, options2) {
|
|
11386
11136
|
const requestId = nanoid();
|
|
11387
11137
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
11388
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
11138
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _263 => _263.id])
|
|
11389
11139
|
});
|
|
11390
11140
|
const message = {
|
|
11391
11141
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
11392
11142
|
requestId,
|
|
11393
11143
|
feedId,
|
|
11394
11144
|
data,
|
|
11395
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
11396
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11145
|
+
id: _optionalChain([options2, 'optionalAccess', _264 => _264.id]),
|
|
11146
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _265 => _265.createdAt])
|
|
11397
11147
|
};
|
|
11398
11148
|
context.buffer.messages.push(message);
|
|
11399
11149
|
flushNowOrSoon();
|
|
@@ -11410,7 +11160,7 @@ function createRoom(options, config) {
|
|
|
11410
11160
|
feedId,
|
|
11411
11161
|
messageId,
|
|
11412
11162
|
data,
|
|
11413
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
11163
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _266 => _266.updatedAt])
|
|
11414
11164
|
};
|
|
11415
11165
|
context.buffer.messages.push(message);
|
|
11416
11166
|
flushNowOrSoon();
|
|
@@ -11617,8 +11367,8 @@ function createRoom(options, config) {
|
|
|
11617
11367
|
async function getThreads(options2) {
|
|
11618
11368
|
return httpClient.getThreads({
|
|
11619
11369
|
roomId,
|
|
11620
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
11621
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11370
|
+
query: _optionalChain([options2, 'optionalAccess', _267 => _267.query]),
|
|
11371
|
+
cursor: _optionalChain([options2, 'optionalAccess', _268 => _268.cursor])
|
|
11622
11372
|
});
|
|
11623
11373
|
}
|
|
11624
11374
|
async function getThread(threadId) {
|
|
@@ -11738,21 +11488,10 @@ function createRoom(options, config) {
|
|
|
11738
11488
|
function getAttachmentUrl(attachmentId) {
|
|
11739
11489
|
return httpClient.getAttachmentUrl({ roomId, attachmentId });
|
|
11740
11490
|
}
|
|
11741
|
-
async function uploadFile(file, options2 = {}) {
|
|
11742
|
-
const data = await httpClient.uploadFile({
|
|
11743
|
-
roomId,
|
|
11744
|
-
file,
|
|
11745
|
-
signal: options2.signal
|
|
11746
|
-
});
|
|
11747
|
-
return new LiveFile(data);
|
|
11748
|
-
}
|
|
11749
|
-
function getFileUrl(file) {
|
|
11750
|
-
return httpClient.getFileUrl({ roomId, fileId: getLiveFileId(file) });
|
|
11751
|
-
}
|
|
11752
11491
|
function getSubscriptionSettings(options2) {
|
|
11753
11492
|
return httpClient.getSubscriptionSettings({
|
|
11754
11493
|
roomId,
|
|
11755
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
11494
|
+
signal: _optionalChain([options2, 'optionalAccess', _269 => _269.signal])
|
|
11756
11495
|
});
|
|
11757
11496
|
}
|
|
11758
11497
|
function updateSubscriptionSettings(settings) {
|
|
@@ -11774,7 +11513,7 @@ function createRoom(options, config) {
|
|
|
11774
11513
|
{
|
|
11775
11514
|
[kInternal]: {
|
|
11776
11515
|
get presenceBuffer() {
|
|
11777
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
11516
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _270 => _270.buffer, 'access', _271 => _271.presenceUpdates, 'optionalAccess', _272 => _272.data]), () => ( null)));
|
|
11778
11517
|
},
|
|
11779
11518
|
// prettier-ignore
|
|
11780
11519
|
get undoStack() {
|
|
@@ -11789,15 +11528,15 @@ function createRoom(options, config) {
|
|
|
11789
11528
|
return context.yjsProvider;
|
|
11790
11529
|
},
|
|
11791
11530
|
setYjsProvider(newProvider) {
|
|
11792
|
-
_optionalChain([context, 'access',
|
|
11531
|
+
_optionalChain([context, 'access', _273 => _273.yjsProvider, 'optionalAccess', _274 => _274.off, 'call', _275 => _275("status", yjsStatusDidChange)]);
|
|
11793
11532
|
context.yjsProvider = newProvider;
|
|
11794
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
11533
|
+
_optionalChain([newProvider, 'optionalAccess', _276 => _276.on, 'call', _277 => _277("status", yjsStatusDidChange)]);
|
|
11795
11534
|
context.yjsProviderDidChange.notify();
|
|
11796
11535
|
},
|
|
11797
11536
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
11798
11537
|
// send metadata when using a text editor
|
|
11799
11538
|
reportTextEditor,
|
|
11800
|
-
getPermissionMatrix: () => _optionalChain([context, 'access',
|
|
11539
|
+
getPermissionMatrix: () => _optionalChain([context, 'access', _278 => _278.dynamicSessionInfoSig, 'access', _279 => _279.get, 'call', _280 => _280(), 'optionalAccess', _281 => _281.permissionMatrix]),
|
|
11801
11540
|
// create a text mention when using a text editor
|
|
11802
11541
|
createTextMention,
|
|
11803
11542
|
// delete a text mention when using a text editor
|
|
@@ -11822,8 +11561,7 @@ function createRoom(options, config) {
|
|
|
11822
11561
|
rawSend: (data) => managedSocket.send(data),
|
|
11823
11562
|
incomingMessage: (data) => handleServerMessage(new MessageEvent("message", { data }))
|
|
11824
11563
|
},
|
|
11825
|
-
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
11826
|
-
fileUrlsStore: httpClient.getOrCreateFileUrlsStore(roomId)
|
|
11564
|
+
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
11827
11565
|
},
|
|
11828
11566
|
id: roomId,
|
|
11829
11567
|
subscribe: makeClassicSubscribeFn(
|
|
@@ -11853,7 +11591,7 @@ ${dumpPool(
|
|
|
11853
11591
|
source.dispose();
|
|
11854
11592
|
}
|
|
11855
11593
|
eventHub.roomWillDestroy.notify();
|
|
11856
|
-
_optionalChain([context, 'access',
|
|
11594
|
+
_optionalChain([context, 'access', _282 => _282.yjsProvider, 'optionalAccess', _283 => _283.off, 'call', _284 => _284("status", yjsStatusDidChange)]);
|
|
11857
11595
|
syncSourceForStorage.destroy();
|
|
11858
11596
|
syncSourceForYjs.destroy();
|
|
11859
11597
|
uninstallBgTabSpy();
|
|
@@ -11921,8 +11659,6 @@ ${dumpPool(
|
|
|
11921
11659
|
prepareAttachment,
|
|
11922
11660
|
uploadAttachment,
|
|
11923
11661
|
getAttachmentUrl,
|
|
11924
|
-
uploadFile,
|
|
11925
|
-
getFileUrl,
|
|
11926
11662
|
// Notifications
|
|
11927
11663
|
getNotificationSettings: getSubscriptionSettings,
|
|
11928
11664
|
getSubscriptionSettings,
|
|
@@ -12017,7 +11753,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
12017
11753
|
}
|
|
12018
11754
|
if (isLiveNode(first)) {
|
|
12019
11755
|
const node = first;
|
|
12020
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11756
|
+
if (_optionalChain([options, 'optionalAccess', _285 => _285.isDeep])) {
|
|
12021
11757
|
const storageCallback = second;
|
|
12022
11758
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
12023
11759
|
} else {
|
|
@@ -12107,8 +11843,8 @@ function createClient(options) {
|
|
|
12107
11843
|
const authManager = createAuthManager(options, (token) => {
|
|
12108
11844
|
currentUserId.set(() => token.uid);
|
|
12109
11845
|
});
|
|
12110
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
12111
|
-
_optionalChain([globalThis, 'access',
|
|
11846
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _286 => _286.polyfills, 'optionalAccess', _287 => _287.fetch]) || /* istanbul ignore next */
|
|
11847
|
+
_optionalChain([globalThis, 'access', _288 => _288.fetch, 'optionalAccess', _289 => _289.bind, 'call', _290 => _290(globalThis)]);
|
|
12112
11848
|
const httpClient = createApiClient({
|
|
12113
11849
|
baseUrl,
|
|
12114
11850
|
fetchPolyfill,
|
|
@@ -12125,7 +11861,7 @@ function createClient(options) {
|
|
|
12125
11861
|
delegates: {
|
|
12126
11862
|
createSocket: makeCreateSocketDelegateForAi(
|
|
12127
11863
|
baseUrl,
|
|
12128
|
-
_optionalChain([clientOptions, 'access',
|
|
11864
|
+
_optionalChain([clientOptions, 'access', _291 => _291.polyfills, 'optionalAccess', _292 => _292.WebSocket])
|
|
12129
11865
|
),
|
|
12130
11866
|
authenticate: async () => {
|
|
12131
11867
|
const resp = await authManager.getAuthValue({
|
|
@@ -12196,7 +11932,7 @@ function createClient(options) {
|
|
|
12196
11932
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
12197
11933
|
roomId,
|
|
12198
11934
|
baseUrl,
|
|
12199
|
-
_optionalChain([clientOptions, 'access',
|
|
11935
|
+
_optionalChain([clientOptions, 'access', _293 => _293.polyfills, 'optionalAccess', _294 => _294.WebSocket])
|
|
12200
11936
|
),
|
|
12201
11937
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
12202
11938
|
})),
|
|
@@ -12218,7 +11954,7 @@ function createClient(options) {
|
|
|
12218
11954
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
12219
11955
|
if (shouldConnect) {
|
|
12220
11956
|
if (typeof atob === "undefined") {
|
|
12221
|
-
if (_optionalChain([clientOptions, 'access',
|
|
11957
|
+
if (_optionalChain([clientOptions, 'access', _295 => _295.polyfills, 'optionalAccess', _296 => _296.atob]) === void 0) {
|
|
12222
11958
|
throw new Error(
|
|
12223
11959
|
"You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
|
|
12224
11960
|
);
|
|
@@ -12230,7 +11966,7 @@ function createClient(options) {
|
|
|
12230
11966
|
return leaseRoom(newRoomDetails);
|
|
12231
11967
|
}
|
|
12232
11968
|
function getRoom(roomId) {
|
|
12233
|
-
const room = _optionalChain([roomsById, 'access',
|
|
11969
|
+
const room = _optionalChain([roomsById, 'access', _297 => _297.get, 'call', _298 => _298(roomId), 'optionalAccess', _299 => _299.room]);
|
|
12234
11970
|
return room ? room : null;
|
|
12235
11971
|
}
|
|
12236
11972
|
function logout() {
|
|
@@ -12246,7 +11982,7 @@ function createClient(options) {
|
|
|
12246
11982
|
const batchedResolveUsers = new Batch(
|
|
12247
11983
|
async (batchedUserIds) => {
|
|
12248
11984
|
const userIds = batchedUserIds.flat();
|
|
12249
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
11985
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _300 => _300({ userIds })]);
|
|
12250
11986
|
warnOnceIf(
|
|
12251
11987
|
!resolveUsers,
|
|
12252
11988
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -12263,7 +11999,7 @@ function createClient(options) {
|
|
|
12263
11999
|
const batchedResolveRoomsInfo = new Batch(
|
|
12264
12000
|
async (batchedRoomIds) => {
|
|
12265
12001
|
const roomIds = batchedRoomIds.flat();
|
|
12266
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
12002
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _301 => _301({ roomIds })]);
|
|
12267
12003
|
warnOnceIf(
|
|
12268
12004
|
!resolveRoomsInfo,
|
|
12269
12005
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -12280,7 +12016,7 @@ function createClient(options) {
|
|
|
12280
12016
|
const batchedResolveGroupsInfo = new Batch(
|
|
12281
12017
|
async (batchedGroupIds) => {
|
|
12282
12018
|
const groupIds = batchedGroupIds.flat();
|
|
12283
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
12019
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _302 => _302({ groupIds })]);
|
|
12284
12020
|
warnOnceIf(
|
|
12285
12021
|
!resolveGroupsInfo,
|
|
12286
12022
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -12339,7 +12075,7 @@ function createClient(options) {
|
|
|
12339
12075
|
}
|
|
12340
12076
|
};
|
|
12341
12077
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12342
|
-
_optionalChain([win, 'optionalAccess',
|
|
12078
|
+
_optionalChain([win, 'optionalAccess', _303 => _303.addEventListener, 'call', _304 => _304("beforeunload", maybePreventClose)]);
|
|
12343
12079
|
}
|
|
12344
12080
|
async function getNotificationSettings(options2) {
|
|
12345
12081
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -12467,7 +12203,7 @@ var commentBodyElementsTypes = {
|
|
|
12467
12203
|
mention: "inline"
|
|
12468
12204
|
};
|
|
12469
12205
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
12470
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
12206
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _305 => _305.content])) {
|
|
12471
12207
|
return;
|
|
12472
12208
|
}
|
|
12473
12209
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -12477,13 +12213,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
12477
12213
|
for (const block of body.content) {
|
|
12478
12214
|
if (type === "all" || type === "block") {
|
|
12479
12215
|
if (guard(block)) {
|
|
12480
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12216
|
+
_optionalChain([visitor, 'optionalCall', _306 => _306(block)]);
|
|
12481
12217
|
}
|
|
12482
12218
|
}
|
|
12483
12219
|
if (type === "all" || type === "inline") {
|
|
12484
12220
|
for (const inline of block.children) {
|
|
12485
12221
|
if (guard(inline)) {
|
|
12486
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12222
|
+
_optionalChain([visitor, 'optionalCall', _307 => _307(inline)]);
|
|
12487
12223
|
}
|
|
12488
12224
|
}
|
|
12489
12225
|
}
|
|
@@ -12653,7 +12389,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
12653
12389
|
text: ({ element }) => element.text,
|
|
12654
12390
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
12655
12391
|
mention: ({ element, user, group }) => {
|
|
12656
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12392
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _308 => _308.name]), () => ( _optionalChain([group, 'optionalAccess', _309 => _309.name]))), () => ( element.id))}`;
|
|
12657
12393
|
}
|
|
12658
12394
|
};
|
|
12659
12395
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -12683,7 +12419,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
12683
12419
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
12684
12420
|
},
|
|
12685
12421
|
mention: ({ element, user, group }) => {
|
|
12686
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
12422
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _310 => _310.name]) ? html`${_optionalChain([user, 'optionalAccess', _311 => _311.name])}` : _optionalChain([group, 'optionalAccess', _312 => _312.name]) ? html`${_optionalChain([group, 'optionalAccess', _313 => _313.name])}` : element.id}</span>`;
|
|
12687
12423
|
}
|
|
12688
12424
|
};
|
|
12689
12425
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -12713,20 +12449,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
12713
12449
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
12714
12450
|
},
|
|
12715
12451
|
mention: ({ element, user, group }) => {
|
|
12716
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12452
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _314 => _314.name]), () => ( _optionalChain([group, 'optionalAccess', _315 => _315.name]))), () => ( element.id))}`;
|
|
12717
12453
|
}
|
|
12718
12454
|
};
|
|
12719
12455
|
async function stringifyCommentBody(body, options) {
|
|
12720
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12721
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12456
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _316 => _316.format]), () => ( "plain"));
|
|
12457
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
12722
12458
|
const elements = {
|
|
12723
12459
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
12724
|
-
..._optionalChain([options, 'optionalAccess',
|
|
12460
|
+
..._optionalChain([options, 'optionalAccess', _318 => _318.elements])
|
|
12725
12461
|
};
|
|
12726
12462
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
12727
12463
|
body,
|
|
12728
|
-
_optionalChain([options, 'optionalAccess',
|
|
12729
|
-
_optionalChain([options, 'optionalAccess',
|
|
12464
|
+
_optionalChain([options, 'optionalAccess', _319 => _319.resolveUsers]),
|
|
12465
|
+
_optionalChain([options, 'optionalAccess', _320 => _320.resolveGroupsInfo])
|
|
12730
12466
|
);
|
|
12731
12467
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
12732
12468
|
switch (block.type) {
|
|
@@ -12808,11 +12544,6 @@ function toPlainLson(lson) {
|
|
|
12808
12544
|
liveblocksType: "LiveList",
|
|
12809
12545
|
data: [...lson].map((item) => toPlainLson(item))
|
|
12810
12546
|
};
|
|
12811
|
-
} else if (lson instanceof LiveFile) {
|
|
12812
|
-
return {
|
|
12813
|
-
liveblocksType: "LiveFile",
|
|
12814
|
-
data: lson.data
|
|
12815
|
-
};
|
|
12816
12547
|
} else {
|
|
12817
12548
|
return lson;
|
|
12818
12549
|
}
|
|
@@ -12866,9 +12597,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12866
12597
|
const startTime = performance.now();
|
|
12867
12598
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
12868
12599
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12869
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12600
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _321 => _321.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
12870
12601
|
const context = {
|
|
12871
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
12602
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _322 => _322.visibilityState]) !== "hidden",
|
|
12872
12603
|
lastSuccessfulPollAt: startTime,
|
|
12873
12604
|
count: 0,
|
|
12874
12605
|
backoff: 0
|
|
@@ -12949,11 +12680,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12949
12680
|
pollNowIfStale();
|
|
12950
12681
|
}
|
|
12951
12682
|
function onVisibilityChange() {
|
|
12952
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
12683
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _323 => _323.visibilityState]) !== "hidden");
|
|
12953
12684
|
}
|
|
12954
|
-
_optionalChain([doc, 'optionalAccess',
|
|
12955
|
-
_optionalChain([win, 'optionalAccess',
|
|
12956
|
-
_optionalChain([win, 'optionalAccess',
|
|
12685
|
+
_optionalChain([doc, 'optionalAccess', _324 => _324.addEventListener, 'call', _325 => _325("visibilitychange", onVisibilityChange)]);
|
|
12686
|
+
_optionalChain([win, 'optionalAccess', _326 => _326.addEventListener, 'call', _327 => _327("online", onVisibilityChange)]);
|
|
12687
|
+
_optionalChain([win, 'optionalAccess', _328 => _328.addEventListener, 'call', _329 => _329("focus", pollNowIfStale)]);
|
|
12957
12688
|
fsm.start();
|
|
12958
12689
|
return {
|
|
12959
12690
|
inc,
|
|
@@ -13098,8 +12829,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
13098
12829
|
|
|
13099
12830
|
|
|
13100
12831
|
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; exports.HttpError = HttpError; exports.LiveFile = LiveFile; 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.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.compactNodesToNodeStream = compactNodesToNodeStream; 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.createStorageFileId = createStorageFileId; exports.createThreadId = createThreadId; exports.deepLiveify = deepLiveify; 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.hasPermissionAccess = hasPermissionAccess; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isFileStorageNode = isFileStorageNode; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.mergeRoomPermissionScopes = mergeRoomPermissionScopes; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.normalizeRoomAccesses = normalizeRoomAccesses; exports.normalizeRoomPermissions = normalizeRoomPermissions; exports.normalizeUpdateRoomAccesses = normalizeUpdateRoomAccesses; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.permissionMatrixFromScopes = permissionMatrixFromScopes; 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.validatePermissionsSet = validatePermissionsSet; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
12832
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; 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.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.compactNodesToNodeStream = compactNodesToNodeStream; 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.deepLiveify = deepLiveify; 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.hasPermissionAccess = hasPermissionAccess; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.mergeRoomPermissionScopes = mergeRoomPermissionScopes; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.normalizeRoomAccesses = normalizeRoomAccesses; exports.normalizeRoomPermissions = normalizeRoomPermissions; exports.normalizeUpdateRoomAccesses = normalizeUpdateRoomAccesses; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.permissionMatrixFromScopes = permissionMatrixFromScopes; 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.validatePermissionsSet = validatePermissionsSet; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
13105
12833
|
//# sourceMappingURL=index.cjs.map
|