@liveblocks/core 3.21.0-rc1 → 3.22.0-file1
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 +549 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +305 -252
- package/dist/index.d.ts +305 -252
- package/dist/index.js +452 -166
- 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.
|
|
9
|
+
var PKG_VERSION = "3.22.0-file1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1309,6 +1309,7 @@ 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";
|
|
1312
1313
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
1313
1314
|
function createOptimisticId(prefix) {
|
|
1314
1315
|
return `${prefix}_${nanoid()}`;
|
|
@@ -1322,6 +1323,9 @@ function createCommentId() {
|
|
|
1322
1323
|
function createCommentAttachmentId() {
|
|
1323
1324
|
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
1324
1325
|
}
|
|
1326
|
+
function createStorageFileId() {
|
|
1327
|
+
return createOptimisticId(STORAGE_FILE_ID_PREFIX);
|
|
1328
|
+
}
|
|
1325
1329
|
function createInboxNotificationId() {
|
|
1326
1330
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
1327
1331
|
}
|
|
@@ -1567,6 +1571,120 @@ function isUrl(string) {
|
|
|
1567
1571
|
}
|
|
1568
1572
|
|
|
1569
1573
|
// 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
|
+
}
|
|
1570
1688
|
function commentsResourceForVisibility(visibility) {
|
|
1571
1689
|
if (visibility === "private") {
|
|
1572
1690
|
return "comments:private";
|
|
@@ -1627,7 +1745,7 @@ function createApiClient({
|
|
|
1627
1745
|
url`/v2/c/rooms/${options.roomId}/threads`,
|
|
1628
1746
|
await authManager.getAuthValue({
|
|
1629
1747
|
roomId: options.roomId,
|
|
1630
|
-
resource: commentsResourceForVisibility(_optionalChain([options, 'access',
|
|
1748
|
+
resource: commentsResourceForVisibility(_optionalChain([options, 'access', _19 => _19.query, 'optionalAccess', _20 => _20.visibility])),
|
|
1631
1749
|
access: "read"
|
|
1632
1750
|
}),
|
|
1633
1751
|
{
|
|
@@ -1685,7 +1803,7 @@ function createApiClient({
|
|
|
1685
1803
|
hasMentions: options.query.hasMentions
|
|
1686
1804
|
})
|
|
1687
1805
|
},
|
|
1688
|
-
{ signal: _optionalChain([requestOptions, 'optionalAccess',
|
|
1806
|
+
{ signal: _optionalChain([requestOptions, 'optionalAccess', _21 => _21.signal]) }
|
|
1689
1807
|
);
|
|
1690
1808
|
return result;
|
|
1691
1809
|
}
|
|
@@ -1882,151 +2000,128 @@ function createApiClient({
|
|
|
1882
2000
|
}
|
|
1883
2001
|
async function uploadAttachment(options) {
|
|
1884
2002
|
const roomId = options.roomId;
|
|
1885
|
-
const abortSignal = options.signal;
|
|
1886
2003
|
const attachment = options.attachment;
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
access: "write"
|
|
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)}`,
|
|
2004
|
+
return uploadRoomFile({
|
|
2005
|
+
file: attachment.file,
|
|
2006
|
+
signal: options.signal,
|
|
2007
|
+
abortErrorMessage: `Upload of attachment ${attachment.id} was aborted.`,
|
|
2008
|
+
uploadSingle: async () => httpClient.putBlob(
|
|
2009
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
2010
|
+
await authManager.getAuthValue({
|
|
2011
|
+
roomId,
|
|
2012
|
+
resource: "comments",
|
|
2013
|
+
access: "write"
|
|
2014
|
+
}),
|
|
2015
|
+
attachment.file,
|
|
2016
|
+
{ fileSize: attachment.size },
|
|
2017
|
+
{ signal: options.signal }
|
|
2018
|
+
),
|
|
2019
|
+
createMultipartUpload: async () => httpClient.post(
|
|
2020
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
2021
|
+
await authManager.getAuthValue({
|
|
2022
|
+
roomId,
|
|
2023
|
+
resource: "comments",
|
|
2024
|
+
access: "write"
|
|
2025
|
+
}),
|
|
2026
|
+
void 0,
|
|
2027
|
+
{ signal: options.signal },
|
|
2028
|
+
{ fileSize: attachment.size }
|
|
2029
|
+
),
|
|
2030
|
+
uploadMultipartPart: async (uploadId, partNumber, part) => httpClient.putBlob(
|
|
2031
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/${String(partNumber)}`,
|
|
2032
|
+
await authManager.getAuthValue({
|
|
2033
|
+
roomId,
|
|
2034
|
+
resource: "comments",
|
|
2035
|
+
access: "write"
|
|
2036
|
+
}),
|
|
2037
|
+
part,
|
|
2038
|
+
void 0,
|
|
2039
|
+
{ signal: options.signal }
|
|
2040
|
+
),
|
|
2041
|
+
completeMultipartUpload: async (uploadId, parts) => httpClient.post(
|
|
2042
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
2043
|
+
await authManager.getAuthValue({
|
|
2044
|
+
roomId,
|
|
2045
|
+
resource: "comments",
|
|
2046
|
+
access: "write"
|
|
2047
|
+
}),
|
|
2048
|
+
{ parts },
|
|
2049
|
+
{ signal: options.signal }
|
|
2050
|
+
),
|
|
2051
|
+
abortMultipartUpload: async (uploadId) => {
|
|
2052
|
+
await httpClient.rawDelete(
|
|
2053
|
+
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
1953
2054
|
await authManager.getAuthValue({
|
|
1954
2055
|
roomId,
|
|
1955
2056
|
resource: "comments",
|
|
1956
2057
|
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
|
|
2058
|
+
})
|
|
2002
2059
|
);
|
|
2003
|
-
|
|
2004
|
-
|
|
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}`,
|
|
2005
2117
|
await authManager.getAuthValue({
|
|
2006
2118
|
roomId,
|
|
2007
|
-
resource: "
|
|
2119
|
+
resource: "storage",
|
|
2008
2120
|
access: "write"
|
|
2009
|
-
})
|
|
2010
|
-
{ parts: sortedUploadedParts },
|
|
2011
|
-
{ signal: abortSignal }
|
|
2121
|
+
})
|
|
2012
2122
|
);
|
|
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;
|
|
2028
2123
|
}
|
|
2029
|
-
}
|
|
2124
|
+
});
|
|
2030
2125
|
}
|
|
2031
2126
|
const attachmentUrlsBatchStoresByRoom = new DefaultMap((roomId) => {
|
|
2032
2127
|
const batch2 = new Batch(
|
|
@@ -2056,6 +2151,34 @@ function createApiClient({
|
|
|
2056
2151
|
const batch2 = getOrCreateAttachmentUrlsStore(options.roomId).batch;
|
|
2057
2152
|
return batch2.get(options.attachmentId);
|
|
2058
2153
|
}
|
|
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
|
+
}
|
|
2059
2182
|
async function getSubscriptionSettings(options) {
|
|
2060
2183
|
return httpClient.get(
|
|
2061
2184
|
url`/v2/c/rooms/${options.roomId}/subscription-settings`,
|
|
@@ -2132,9 +2255,9 @@ function createApiClient({
|
|
|
2132
2255
|
})
|
|
2133
2256
|
);
|
|
2134
2257
|
}
|
|
2135
|
-
async function
|
|
2258
|
+
async function getYjsHistoryVersion(options) {
|
|
2136
2259
|
return httpClient.rawGet(
|
|
2137
|
-
url`/v2/c/rooms/${options.roomId}/
|
|
2260
|
+
url`/v2/c/rooms/${options.roomId}/versions/${options.versionId}/yjs`,
|
|
2138
2261
|
await authManager.getAuthValue({
|
|
2139
2262
|
roomId: options.roomId,
|
|
2140
2263
|
resource: "storage",
|
|
@@ -2142,9 +2265,9 @@ function createApiClient({
|
|
|
2142
2265
|
})
|
|
2143
2266
|
);
|
|
2144
2267
|
}
|
|
2145
|
-
async function
|
|
2268
|
+
async function createVersionHistorySnapshot(options) {
|
|
2146
2269
|
await httpClient.rawPost(
|
|
2147
|
-
url`/v2/c/rooms/${options.roomId}/
|
|
2270
|
+
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
2148
2271
|
await authManager.getAuthValue({
|
|
2149
2272
|
roomId: options.roomId,
|
|
2150
2273
|
resource: "storage",
|
|
@@ -2190,7 +2313,7 @@ function createApiClient({
|
|
|
2190
2313
|
}
|
|
2191
2314
|
return result.content[0].text;
|
|
2192
2315
|
}
|
|
2193
|
-
async function
|
|
2316
|
+
async function listHistoryVersions(options) {
|
|
2194
2317
|
const result = await httpClient.get(
|
|
2195
2318
|
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
2196
2319
|
await authManager.getAuthValue({
|
|
@@ -2209,7 +2332,7 @@ function createApiClient({
|
|
|
2209
2332
|
requestedAt: new Date(result.meta.requestedAt)
|
|
2210
2333
|
};
|
|
2211
2334
|
}
|
|
2212
|
-
async function
|
|
2335
|
+
async function listHistoryVersionsSince(options) {
|
|
2213
2336
|
const result = await httpClient.get(
|
|
2214
2337
|
url`/v2/c/rooms/${options.roomId}/versions/delta`,
|
|
2215
2338
|
await authManager.getAuthValue({
|
|
@@ -2244,14 +2367,14 @@ function createApiClient({
|
|
|
2244
2367
|
async function getInboxNotifications(options) {
|
|
2245
2368
|
const PAGE_SIZE = 50;
|
|
2246
2369
|
let query;
|
|
2247
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2370
|
+
if (_optionalChain([options, 'optionalAccess', _22 => _22.query])) {
|
|
2248
2371
|
query = objectToQuery(options.query);
|
|
2249
2372
|
}
|
|
2250
2373
|
const json = await httpClient.get(
|
|
2251
2374
|
url`/v2/c/inbox-notifications`,
|
|
2252
2375
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2253
2376
|
{
|
|
2254
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2377
|
+
cursor: _optionalChain([options, 'optionalAccess', _23 => _23.cursor]),
|
|
2255
2378
|
limit: PAGE_SIZE,
|
|
2256
2379
|
query
|
|
2257
2380
|
}
|
|
@@ -2270,7 +2393,7 @@ function createApiClient({
|
|
|
2270
2393
|
}
|
|
2271
2394
|
async function getInboxNotificationsSince(options) {
|
|
2272
2395
|
let query;
|
|
2273
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2396
|
+
if (_optionalChain([options, 'optionalAccess', _24 => _24.query])) {
|
|
2274
2397
|
query = objectToQuery(options.query);
|
|
2275
2398
|
}
|
|
2276
2399
|
const json = await httpClient.get(
|
|
@@ -2299,14 +2422,14 @@ function createApiClient({
|
|
|
2299
2422
|
}
|
|
2300
2423
|
async function getUnreadInboxNotificationsCount(options) {
|
|
2301
2424
|
let query;
|
|
2302
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2425
|
+
if (_optionalChain([options, 'optionalAccess', _25 => _25.query])) {
|
|
2303
2426
|
query = objectToQuery(options.query);
|
|
2304
2427
|
}
|
|
2305
2428
|
const { count } = await httpClient.get(
|
|
2306
2429
|
url`/v2/c/inbox-notifications/count`,
|
|
2307
2430
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2308
2431
|
{ query },
|
|
2309
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2432
|
+
{ signal: _optionalChain([options, 'optionalAccess', _26 => _26.signal]) }
|
|
2310
2433
|
);
|
|
2311
2434
|
return count;
|
|
2312
2435
|
}
|
|
@@ -2356,7 +2479,7 @@ function createApiClient({
|
|
|
2356
2479
|
url`/v2/c/notification-settings`,
|
|
2357
2480
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2358
2481
|
void 0,
|
|
2359
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2482
|
+
{ signal: _optionalChain([options, 'optionalAccess', _27 => _27.signal]) }
|
|
2360
2483
|
);
|
|
2361
2484
|
}
|
|
2362
2485
|
async function updateNotificationSettings(settings) {
|
|
@@ -2368,7 +2491,7 @@ function createApiClient({
|
|
|
2368
2491
|
}
|
|
2369
2492
|
async function getUserThreads_experimental(options) {
|
|
2370
2493
|
let query;
|
|
2371
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2494
|
+
if (_optionalChain([options, 'optionalAccess', _28 => _28.query])) {
|
|
2372
2495
|
query = objectToQuery(options.query);
|
|
2373
2496
|
}
|
|
2374
2497
|
const PAGE_SIZE = 50;
|
|
@@ -2376,7 +2499,7 @@ function createApiClient({
|
|
|
2376
2499
|
url`/v2/c/threads`,
|
|
2377
2500
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2378
2501
|
{
|
|
2379
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2502
|
+
cursor: _optionalChain([options, 'optionalAccess', _29 => _29.cursor]),
|
|
2380
2503
|
query,
|
|
2381
2504
|
limit: PAGE_SIZE
|
|
2382
2505
|
}
|
|
@@ -2475,15 +2598,19 @@ function createApiClient({
|
|
|
2475
2598
|
// Room text editor
|
|
2476
2599
|
createTextMention,
|
|
2477
2600
|
deleteTextMention,
|
|
2478
|
-
|
|
2479
|
-
|
|
2601
|
+
getYjsHistoryVersion,
|
|
2602
|
+
createVersionHistorySnapshot,
|
|
2480
2603
|
reportTextEditor,
|
|
2481
|
-
|
|
2482
|
-
|
|
2604
|
+
listHistoryVersions,
|
|
2605
|
+
listHistoryVersionsSince,
|
|
2483
2606
|
// Room attachments
|
|
2484
2607
|
getAttachmentUrl,
|
|
2485
2608
|
uploadAttachment,
|
|
2486
2609
|
getOrCreateAttachmentUrlsStore,
|
|
2610
|
+
// Room storage files
|
|
2611
|
+
getFileUrl,
|
|
2612
|
+
uploadFile,
|
|
2613
|
+
getOrCreateFileUrlsStore,
|
|
2487
2614
|
// Room storage
|
|
2488
2615
|
streamStorage,
|
|
2489
2616
|
// Notifications
|
|
@@ -2549,7 +2676,7 @@ var HttpClient = class {
|
|
|
2549
2676
|
// These headers are default, but can be overriden by custom headers
|
|
2550
2677
|
"Content-Type": "application/json; charset=utf-8",
|
|
2551
2678
|
// Possible header overrides
|
|
2552
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2679
|
+
..._optionalChain([options, 'optionalAccess', _30 => _30.headers]),
|
|
2553
2680
|
// Cannot be overriden by custom headers
|
|
2554
2681
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2555
2682
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -2557,7 +2684,7 @@ var HttpClient = class {
|
|
|
2557
2684
|
});
|
|
2558
2685
|
const xwarn = response.headers.get("X-LB-Warn");
|
|
2559
2686
|
if (xwarn) {
|
|
2560
|
-
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2687
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _31 => _31.method, 'optionalAccess', _32 => _32.toUpperCase, 'call', _33 => _33()]), () => ( "GET"));
|
|
2561
2688
|
const msg = `${xwarn} (${method} ${endpoint})`;
|
|
2562
2689
|
if (response.ok) {
|
|
2563
2690
|
warn(msg);
|
|
@@ -3039,7 +3166,7 @@ var FSM = class {
|
|
|
3039
3166
|
});
|
|
3040
3167
|
}
|
|
3041
3168
|
#getTargetFn(eventName) {
|
|
3042
|
-
return _optionalChain([this, 'access',
|
|
3169
|
+
return _optionalChain([this, 'access', _34 => _34.#allowedTransitions, 'access', _35 => _35.get, 'call', _36 => _36(this.currentState), 'optionalAccess', _37 => _37.get, 'call', _38 => _38(eventName)]);
|
|
3043
3170
|
}
|
|
3044
3171
|
/**
|
|
3045
3172
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -3058,7 +3185,7 @@ var FSM = class {
|
|
|
3058
3185
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3059
3186
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
3060
3187
|
for (let i = 0; i < levels; i++) {
|
|
3061
|
-
_optionalChain([this, 'access',
|
|
3188
|
+
_optionalChain([this, 'access', _39 => _39.#cleanupStack, 'access', _40 => _40.pop, 'call', _41 => _41(), 'optionalCall', _42 => _42(patchableContext)]);
|
|
3062
3189
|
const entryTime = this.#entryTimesStack.pop();
|
|
3063
3190
|
if (entryTime !== void 0 && // ...but avoid computing state names if nobody is listening
|
|
3064
3191
|
this.#eventHub.didExitState.count() > 0) {
|
|
@@ -3086,7 +3213,7 @@ var FSM = class {
|
|
|
3086
3213
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3087
3214
|
for (const pattern of enterPatterns) {
|
|
3088
3215
|
const enterFn = this.#enterFns.get(pattern);
|
|
3089
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
3216
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _43 => _43(patchableContext)]);
|
|
3090
3217
|
if (typeof cleanupFn === "function") {
|
|
3091
3218
|
this.#cleanupStack.push(cleanupFn);
|
|
3092
3219
|
} else {
|
|
@@ -3513,7 +3640,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3513
3640
|
}
|
|
3514
3641
|
function waitForActorId(event) {
|
|
3515
3642
|
const serverMsg = tryParseJson(event.data);
|
|
3516
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
3643
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _44 => _44.type]) === ServerMsgCode.ROOM_STATE) {
|
|
3517
3644
|
if (options.enableDebugLogging && socketOpenAt !== null) {
|
|
3518
3645
|
const elapsed = performance.now() - socketOpenAt;
|
|
3519
3646
|
warn(
|
|
@@ -3641,12 +3768,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3641
3768
|
const sendHeartbeat = {
|
|
3642
3769
|
target: "@ok.awaiting-pong",
|
|
3643
3770
|
effect: (ctx) => {
|
|
3644
|
-
_optionalChain([ctx, 'access',
|
|
3771
|
+
_optionalChain([ctx, 'access', _45 => _45.socket, 'optionalAccess', _46 => _46.send, 'call', _47 => _47("ping")]);
|
|
3645
3772
|
}
|
|
3646
3773
|
};
|
|
3647
3774
|
const maybeHeartbeat = () => {
|
|
3648
3775
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
3649
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
3776
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _48 => _48.visibilityState]) === "hidden" && delegates.canZombie();
|
|
3650
3777
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
3651
3778
|
};
|
|
3652
3779
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -3686,7 +3813,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3686
3813
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
3687
3814
|
// not. When still OPEN, don't transition.
|
|
3688
3815
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
3689
|
-
if (_optionalChain([context, 'access',
|
|
3816
|
+
if (_optionalChain([context, 'access', _49 => _49.socket, 'optionalAccess', _50 => _50.readyState]) === 1) {
|
|
3690
3817
|
return IGNORE;
|
|
3691
3818
|
}
|
|
3692
3819
|
return {
|
|
@@ -3738,17 +3865,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3738
3865
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
3739
3866
|
}
|
|
3740
3867
|
function onVisibilityChange() {
|
|
3741
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
3868
|
+
if (_optionalChain([doc, 'optionalAccess', _51 => _51.visibilityState]) === "visible") {
|
|
3742
3869
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3743
3870
|
}
|
|
3744
3871
|
}
|
|
3745
|
-
_optionalChain([win, 'optionalAccess',
|
|
3746
|
-
_optionalChain([win, 'optionalAccess',
|
|
3747
|
-
_optionalChain([root, 'optionalAccess',
|
|
3872
|
+
_optionalChain([win, 'optionalAccess', _52 => _52.addEventListener, 'call', _53 => _53("online", onNetworkBackOnline)]);
|
|
3873
|
+
_optionalChain([win, 'optionalAccess', _54 => _54.addEventListener, 'call', _55 => _55("offline", onNetworkOffline)]);
|
|
3874
|
+
_optionalChain([root, 'optionalAccess', _56 => _56.addEventListener, 'call', _57 => _57("visibilitychange", onVisibilityChange)]);
|
|
3748
3875
|
return () => {
|
|
3749
|
-
_optionalChain([root, 'optionalAccess',
|
|
3750
|
-
_optionalChain([win, 'optionalAccess',
|
|
3751
|
-
_optionalChain([win, 'optionalAccess',
|
|
3876
|
+
_optionalChain([root, 'optionalAccess', _58 => _58.removeEventListener, 'call', _59 => _59("visibilitychange", onVisibilityChange)]);
|
|
3877
|
+
_optionalChain([win, 'optionalAccess', _60 => _60.removeEventListener, 'call', _61 => _61("online", onNetworkBackOnline)]);
|
|
3878
|
+
_optionalChain([win, 'optionalAccess', _62 => _62.removeEventListener, 'call', _63 => _63("offline", onNetworkOffline)]);
|
|
3752
3879
|
teardownSocket(ctx.socket);
|
|
3753
3880
|
};
|
|
3754
3881
|
});
|
|
@@ -3837,7 +3964,7 @@ var ManagedSocket = class {
|
|
|
3837
3964
|
* message if this is somehow impossible.
|
|
3838
3965
|
*/
|
|
3839
3966
|
send(data) {
|
|
3840
|
-
const socket = _optionalChain([this, 'access',
|
|
3967
|
+
const socket = _optionalChain([this, 'access', _64 => _64.#machine, 'access', _65 => _65.context, 'optionalAccess', _66 => _66.socket]);
|
|
3841
3968
|
if (socket === null) {
|
|
3842
3969
|
warn("Cannot send: not connected yet", data);
|
|
3843
3970
|
} else if (socket.readyState !== 1) {
|
|
@@ -4299,7 +4426,7 @@ function createStore_forKnowledge() {
|
|
|
4299
4426
|
}
|
|
4300
4427
|
function getKnowledgeForChat(chatId) {
|
|
4301
4428
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
4302
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
4429
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _67 => _67.get, 'call', _68 => _68(chatId), 'optionalAccess', _69 => _69.get, 'call', _70 => _70()]), () => ( []));
|
|
4303
4430
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
4304
4431
|
}
|
|
4305
4432
|
return {
|
|
@@ -4324,7 +4451,7 @@ function createStore_forTools() {
|
|
|
4324
4451
|
return DerivedSignal.from(() => {
|
|
4325
4452
|
return (
|
|
4326
4453
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4327
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4454
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _71 => _71.get, 'call', _72 => _72()]), () => ( // ...or a globally registered tool
|
|
4328
4455
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4329
4456
|
);
|
|
4330
4457
|
});
|
|
@@ -4354,8 +4481,8 @@ function createStore_forTools() {
|
|
|
4354
4481
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4355
4482
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4356
4483
|
return Array.from([
|
|
4357
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4358
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4484
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _73 => _73.entries, 'call', _74 => _74()]), () => ( [])),
|
|
4485
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _75 => _75.entries, 'call', _76 => _76()]), () => ( []))
|
|
4359
4486
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4360
4487
|
const tool = tool\u03A3.get();
|
|
4361
4488
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4458,7 +4585,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4458
4585
|
} else {
|
|
4459
4586
|
continue;
|
|
4460
4587
|
}
|
|
4461
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4588
|
+
const executeFn = _optionalChain([toolsStore, 'access', _77 => _77.getTool\u03A3, 'call', _78 => _78(toolInvocation.name, message.chatId), 'access', _79 => _79.get, 'call', _80 => _80(), 'optionalAccess', _81 => _81.execute]);
|
|
4462
4589
|
if (executeFn) {
|
|
4463
4590
|
(async () => {
|
|
4464
4591
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4557,8 +4684,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4557
4684
|
const spine = [];
|
|
4558
4685
|
let lastVisitedMessage = null;
|
|
4559
4686
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4560
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4561
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4687
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _82 => _82(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _83 => _83.id]), () => ( null));
|
|
4688
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _84 => _84(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _85 => _85.id]), () => ( null));
|
|
4562
4689
|
if (!message2.deletedAt || prev || next) {
|
|
4563
4690
|
const node = {
|
|
4564
4691
|
...message2,
|
|
@@ -4624,7 +4751,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4624
4751
|
const latest = pool.sorted.findRight(
|
|
4625
4752
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4626
4753
|
);
|
|
4627
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4754
|
+
return _optionalChain([latest, 'optionalAccess', _86 => _86.copilotId]);
|
|
4628
4755
|
}
|
|
4629
4756
|
return {
|
|
4630
4757
|
// Readers
|
|
@@ -4655,11 +4782,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4655
4782
|
*getAutoExecutingMessageIds() {
|
|
4656
4783
|
for (const messageId of myMessages) {
|
|
4657
4784
|
const message = getMessageById(messageId);
|
|
4658
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4785
|
+
if (_optionalChain([message, 'optionalAccess', _87 => _87.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4659
4786
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4660
4787
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4661
4788
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4662
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4789
|
+
return typeof _optionalChain([tool, 'optionalAccess', _88 => _88.execute]) === "function";
|
|
4663
4790
|
}
|
|
4664
4791
|
return false;
|
|
4665
4792
|
});
|
|
@@ -4807,7 +4934,7 @@ function createAi(config) {
|
|
|
4807
4934
|
flushPendingDeltas();
|
|
4808
4935
|
switch (msg.event) {
|
|
4809
4936
|
case "cmd-failed":
|
|
4810
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4937
|
+
_optionalChain([pendingCmd, 'optionalAccess', _89 => _89.reject, 'call', _90 => _90(new Error(msg.error))]);
|
|
4811
4938
|
break;
|
|
4812
4939
|
case "settle": {
|
|
4813
4940
|
context.messagesStore.upsert(msg.message);
|
|
@@ -4884,7 +5011,7 @@ function createAi(config) {
|
|
|
4884
5011
|
return assertNever(msg, "Unhandled case");
|
|
4885
5012
|
}
|
|
4886
5013
|
}
|
|
4887
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
5014
|
+
_optionalChain([pendingCmd, 'optionalAccess', _91 => _91.resolve, 'call', _92 => _92(msg)]);
|
|
4888
5015
|
}
|
|
4889
5016
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4890
5017
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4960,9 +5087,9 @@ function createAi(config) {
|
|
|
4960
5087
|
invocationId,
|
|
4961
5088
|
result,
|
|
4962
5089
|
generationOptions: {
|
|
4963
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4964
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4965
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
5090
|
+
copilotId: _optionalChain([options, 'optionalAccess', _93 => _93.copilotId]),
|
|
5091
|
+
stream: _optionalChain([options, 'optionalAccess', _94 => _94.stream]),
|
|
5092
|
+
timeout: _optionalChain([options, 'optionalAccess', _95 => _95.timeout]),
|
|
4966
5093
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4967
5094
|
// from the global context
|
|
4968
5095
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4980,7 +5107,7 @@ function createAi(config) {
|
|
|
4980
5107
|
}
|
|
4981
5108
|
}
|
|
4982
5109
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
4983
|
-
_optionalChain([win, 'optionalAccess',
|
|
5110
|
+
_optionalChain([win, 'optionalAccess', _96 => _96.addEventListener, 'call', _97 => _97("beforeunload", handleBeforeUnload, { once: true })]);
|
|
4984
5111
|
return Object.defineProperty(
|
|
4985
5112
|
{
|
|
4986
5113
|
[kInternal]: {
|
|
@@ -4999,7 +5126,7 @@ function createAi(config) {
|
|
|
4999
5126
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
5000
5127
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
5001
5128
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
5002
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
5129
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _98 => _98.knowledge]) || [];
|
|
5003
5130
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
5004
5131
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
5005
5132
|
messagesStore.markMine(targetMessageId);
|
|
@@ -5009,9 +5136,9 @@ function createAi(config) {
|
|
|
5009
5136
|
sourceMessage: userMessage,
|
|
5010
5137
|
targetMessageId,
|
|
5011
5138
|
generationOptions: {
|
|
5012
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5013
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5014
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
5139
|
+
copilotId: _optionalChain([options, 'optionalAccess', _99 => _99.copilotId]),
|
|
5140
|
+
stream: _optionalChain([options, 'optionalAccess', _100 => _100.stream]),
|
|
5141
|
+
timeout: _optionalChain([options, 'optionalAccess', _101 => _101.timeout]),
|
|
5015
5142
|
// Combine global knowledge with request-specific knowledge
|
|
5016
5143
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
5017
5144
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -5083,7 +5210,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
5083
5210
|
}
|
|
5084
5211
|
}
|
|
5085
5212
|
function closePart(prevPart, endedAt) {
|
|
5086
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
5213
|
+
if (_optionalChain([prevPart, 'optionalAccess', _102 => _102.type]) === "reasoning") {
|
|
5087
5214
|
prevPart.endedAt ??= endedAt;
|
|
5088
5215
|
}
|
|
5089
5216
|
}
|
|
@@ -5098,7 +5225,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5098
5225
|
const lastPart = parts[parts.length - 1];
|
|
5099
5226
|
switch (delta.type) {
|
|
5100
5227
|
case "text-delta":
|
|
5101
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5228
|
+
if (_optionalChain([lastPart, 'optionalAccess', _103 => _103.type]) === "text") {
|
|
5102
5229
|
lastPart.text += delta.textDelta;
|
|
5103
5230
|
} else {
|
|
5104
5231
|
closePart(lastPart, now2);
|
|
@@ -5106,7 +5233,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5106
5233
|
}
|
|
5107
5234
|
break;
|
|
5108
5235
|
case "reasoning-delta":
|
|
5109
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5236
|
+
if (_optionalChain([lastPart, 'optionalAccess', _104 => _104.type]) === "reasoning") {
|
|
5110
5237
|
lastPart.text += delta.textDelta;
|
|
5111
5238
|
} else {
|
|
5112
5239
|
closePart(lastPart, now2);
|
|
@@ -5126,8 +5253,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
5126
5253
|
break;
|
|
5127
5254
|
}
|
|
5128
5255
|
case "tool-delta": {
|
|
5129
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5130
|
-
_optionalChain([lastPart, 'access',
|
|
5256
|
+
if (_optionalChain([lastPart, 'optionalAccess', _105 => _105.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
5257
|
+
_optionalChain([lastPart, 'access', _106 => _106.__appendDelta, 'optionalCall', _107 => _107(delta.delta)]);
|
|
5131
5258
|
}
|
|
5132
5259
|
break;
|
|
5133
5260
|
}
|
|
@@ -5482,7 +5609,7 @@ function explicitAccessForResource(source, resource) {
|
|
|
5482
5609
|
}
|
|
5483
5610
|
function permissionForAccessLevel(resource, access, field = resource) {
|
|
5484
5611
|
const permissions = PERMISSIONS_BY_RESOURCE[resource][access];
|
|
5485
|
-
const permission = _optionalChain([permissions, 'optionalAccess',
|
|
5612
|
+
const permission = _optionalChain([permissions, 'optionalAccess', _108 => _108[0]]);
|
|
5486
5613
|
if (permission !== void 0) {
|
|
5487
5614
|
return permission;
|
|
5488
5615
|
}
|
|
@@ -5592,7 +5719,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5592
5719
|
return void 0;
|
|
5593
5720
|
}
|
|
5594
5721
|
async function makeAuthRequest(options) {
|
|
5595
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
5722
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _109 => _109.polyfills, 'optionalAccess', _110 => _110.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
5596
5723
|
if (authentication.type === "private") {
|
|
5597
5724
|
if (fetcher === void 0) {
|
|
5598
5725
|
throw new StopRetrying(
|
|
@@ -5605,14 +5732,14 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5605
5732
|
const parsed = parseAuthToken(response.token);
|
|
5606
5733
|
if (seenTokens.has(parsed.raw)) {
|
|
5607
5734
|
const cachedToken = getCachedToken(options);
|
|
5608
|
-
if (_optionalChain([cachedToken, 'optionalAccess',
|
|
5735
|
+
if (_optionalChain([cachedToken, 'optionalAccess', _111 => _111.raw]) === parsed.raw) {
|
|
5609
5736
|
return cachedToken;
|
|
5610
5737
|
}
|
|
5611
5738
|
throw new StopRetrying(
|
|
5612
5739
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
5613
5740
|
);
|
|
5614
5741
|
}
|
|
5615
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5742
|
+
_optionalChain([onAuthenticate, 'optionalCall', _112 => _112(parsed.parsed)]);
|
|
5616
5743
|
return parsed;
|
|
5617
5744
|
}
|
|
5618
5745
|
if (authentication.type === "custom") {
|
|
@@ -5620,7 +5747,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5620
5747
|
if (response && typeof response === "object") {
|
|
5621
5748
|
if (typeof response.token === "string") {
|
|
5622
5749
|
const parsed = parseAuthToken(response.token);
|
|
5623
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5750
|
+
_optionalChain([onAuthenticate, 'optionalCall', _113 => _113(parsed.parsed)]);
|
|
5624
5751
|
return parsed;
|
|
5625
5752
|
} else if (typeof response.error === "string") {
|
|
5626
5753
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5815,13 +5942,15 @@ var OpCode = Object.freeze({
|
|
|
5815
5942
|
DELETE_CRDT: 5,
|
|
5816
5943
|
DELETE_OBJECT_KEY: 6,
|
|
5817
5944
|
CREATE_MAP: 7,
|
|
5818
|
-
CREATE_REGISTER: 8
|
|
5945
|
+
CREATE_REGISTER: 8,
|
|
5946
|
+
// 9 and 10 are reserved for the parallel LiveText work.
|
|
5947
|
+
CREATE_FILE: 11
|
|
5819
5948
|
});
|
|
5820
5949
|
function isIgnoredOp(op) {
|
|
5821
5950
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5822
5951
|
}
|
|
5823
5952
|
function isCreateOp(op) {
|
|
5824
|
-
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_LIST;
|
|
5953
|
+
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.CREATE_FILE || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_LIST;
|
|
5825
5954
|
}
|
|
5826
5955
|
|
|
5827
5956
|
// src/protocol/StorageNode.ts
|
|
@@ -5829,7 +5958,9 @@ var CrdtType = Object.freeze({
|
|
|
5829
5958
|
OBJECT: 0,
|
|
5830
5959
|
LIST: 1,
|
|
5831
5960
|
MAP: 2,
|
|
5832
|
-
REGISTER: 3
|
|
5961
|
+
REGISTER: 3,
|
|
5962
|
+
// 4 is reserved for the parallel LiveText work.
|
|
5963
|
+
FILE: 5
|
|
5833
5964
|
});
|
|
5834
5965
|
function isRootStorageNode(node) {
|
|
5835
5966
|
return node[0] === "root";
|
|
@@ -5846,6 +5977,9 @@ function isMapStorageNode(node) {
|
|
|
5846
5977
|
function isRegisterStorageNode(node) {
|
|
5847
5978
|
return node[1].type === CrdtType.REGISTER;
|
|
5848
5979
|
}
|
|
5980
|
+
function isFileStorageNode(node) {
|
|
5981
|
+
return node[1].type === CrdtType.FILE;
|
|
5982
|
+
}
|
|
5849
5983
|
function isCompactRootNode(node) {
|
|
5850
5984
|
return node[0] === "root";
|
|
5851
5985
|
}
|
|
@@ -5868,6 +6002,9 @@ function* compactNodesToNodeStream(compactNodes) {
|
|
|
5868
6002
|
case CrdtType.REGISTER:
|
|
5869
6003
|
yield [cnode[0], { type: CrdtType.REGISTER, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
5870
6004
|
break;
|
|
6005
|
+
case CrdtType.FILE:
|
|
6006
|
+
yield [cnode[0], { type: CrdtType.FILE, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6007
|
+
break;
|
|
5871
6008
|
default:
|
|
5872
6009
|
}
|
|
5873
6010
|
}
|
|
@@ -5896,6 +6033,10 @@ function* nodeStreamToCompactNodes(nodes) {
|
|
|
5896
6033
|
const id = node[0];
|
|
5897
6034
|
const crdt = node[1];
|
|
5898
6035
|
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];
|
|
5899
6040
|
} else {
|
|
5900
6041
|
}
|
|
5901
6042
|
}
|
|
@@ -6134,12 +6275,12 @@ ${parentKey}`;
|
|
|
6134
6275
|
if (isCreateOp(op)) {
|
|
6135
6276
|
const posKey = this.#posKey(op.parentId, op.parentKey);
|
|
6136
6277
|
const atPosition = this.#createOpsByPosition.get(posKey);
|
|
6137
|
-
_optionalChain([atPosition, 'optionalAccess',
|
|
6278
|
+
_optionalChain([atPosition, 'optionalAccess', _114 => _114.delete, 'call', _115 => _115(opId)]);
|
|
6138
6279
|
if (atPosition !== void 0 && atPosition.size === 0) {
|
|
6139
6280
|
this.#createOpsByPosition.delete(posKey);
|
|
6140
6281
|
}
|
|
6141
6282
|
const inParent = this.#createOpsByParent.get(op.parentId);
|
|
6142
|
-
_optionalChain([inParent, 'optionalAccess',
|
|
6283
|
+
_optionalChain([inParent, 'optionalAccess', _116 => _116.delete, 'call', _117 => _117(opId)]);
|
|
6143
6284
|
if (inParent !== void 0 && inParent.size === 0) {
|
|
6144
6285
|
this.#createOpsByParent.delete(op.parentId);
|
|
6145
6286
|
}
|
|
@@ -6151,14 +6292,14 @@ ${parentKey}`;
|
|
|
6151
6292
|
* Empty if none.
|
|
6152
6293
|
*/
|
|
6153
6294
|
getByParentIdAndKey(parentId, parentKey) {
|
|
6154
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6295
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _118 => _118.#createOpsByPosition, 'access', _119 => _119.get, 'call', _120 => _120(this.#posKey(parentId, parentKey)), 'optionalAccess', _121 => _121.values, 'call', _122 => _122()]), () => ( []));
|
|
6155
6296
|
}
|
|
6156
6297
|
/**
|
|
6157
6298
|
* The still-unacknowledged Create ops with the given `parentId` (across all
|
|
6158
6299
|
* positions), in dispatch order. O(1) lookup. Empty if none.
|
|
6159
6300
|
*/
|
|
6160
6301
|
getByParentId(parentId) {
|
|
6161
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6302
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _123 => _123.#createOpsByParent, 'access', _124 => _124.get, 'call', _125 => _125(parentId), 'optionalAccess', _126 => _126.values, 'call', _127 => _127()]), () => ( []));
|
|
6162
6303
|
}
|
|
6163
6304
|
/** All still-unacknowledged ops, in dispatch order. */
|
|
6164
6305
|
values() {
|
|
@@ -6199,7 +6340,7 @@ function createManagedPool(roomId, options) {
|
|
|
6199
6340
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
6200
6341
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
6201
6342
|
dispatch(ops, reverse, storageUpdates) {
|
|
6202
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
6343
|
+
_optionalChain([onDispatch, 'optionalCall', _128 => _128(ops, reverse, storageUpdates)]);
|
|
6203
6344
|
},
|
|
6204
6345
|
assertStorageIsWritable: () => {
|
|
6205
6346
|
if (!isStorageWritable()) {
|
|
@@ -6408,6 +6549,91 @@ var AbstractCrdt = class {
|
|
|
6408
6549
|
}
|
|
6409
6550
|
};
|
|
6410
6551
|
|
|
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
|
+
|
|
6411
6637
|
// src/crdts/LiveRegister.ts
|
|
6412
6638
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
6413
6639
|
#data;
|
|
@@ -6923,7 +7149,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6923
7149
|
#applyInsertUndoRedo(op) {
|
|
6924
7150
|
const { id, parentKey: key } = op;
|
|
6925
7151
|
const child = creationOpToLiveNode(op);
|
|
6926
|
-
if (_optionalChain([this, 'access',
|
|
7152
|
+
if (_optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.getNode, 'call', _131 => _131(id)]) !== void 0) {
|
|
6927
7153
|
return { modified: false };
|
|
6928
7154
|
}
|
|
6929
7155
|
child._attach(id, nn(this._pool));
|
|
@@ -6931,8 +7157,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6931
7157
|
const existingItemIndex = this._indexOfPosition(key);
|
|
6932
7158
|
let newKey = key;
|
|
6933
7159
|
if (existingItemIndex !== -1) {
|
|
6934
|
-
const before2 = _optionalChain([this, 'access',
|
|
6935
|
-
const after2 = _optionalChain([this, 'access',
|
|
7160
|
+
const before2 = _optionalChain([this, 'access', _132 => _132.#items, 'access', _133 => _133.at, 'call', _134 => _134(existingItemIndex), 'optionalAccess', _135 => _135._parentPos]);
|
|
7161
|
+
const after2 = _optionalChain([this, 'access', _136 => _136.#items, 'access', _137 => _137.at, 'call', _138 => _138(existingItemIndex + 1), 'optionalAccess', _139 => _139._parentPos]);
|
|
6936
7162
|
newKey = makePosition(before2, after2);
|
|
6937
7163
|
child._setParentLink(this, newKey);
|
|
6938
7164
|
}
|
|
@@ -6946,7 +7172,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6946
7172
|
#applySetUndoRedo(op) {
|
|
6947
7173
|
const { id, parentKey: key } = op;
|
|
6948
7174
|
const child = creationOpToLiveNode(op);
|
|
6949
|
-
if (_optionalChain([this, 'access',
|
|
7175
|
+
if (_optionalChain([this, 'access', _140 => _140._pool, 'optionalAccess', _141 => _141.getNode, 'call', _142 => _142(id)]) !== void 0) {
|
|
6950
7176
|
return { modified: false };
|
|
6951
7177
|
}
|
|
6952
7178
|
const indexOfItemWithSameKey = this._indexOfPosition(key);
|
|
@@ -7067,7 +7293,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7067
7293
|
} else {
|
|
7068
7294
|
this.#updateItemPositionAt(
|
|
7069
7295
|
existingItemIndex,
|
|
7070
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
7296
|
+
makePosition(newKey, _optionalChain([this, 'access', _143 => _143.#items, 'access', _144 => _144.at, 'call', _145 => _145(existingItemIndex + 1), 'optionalAccess', _146 => _146._parentPos]))
|
|
7071
7297
|
);
|
|
7072
7298
|
const previousIndex = this.#items.findIndex((item) => item === child);
|
|
7073
7299
|
this.#updateItemPosition(child, newKey);
|
|
@@ -7094,7 +7320,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7094
7320
|
this,
|
|
7095
7321
|
makePosition(
|
|
7096
7322
|
newKey,
|
|
7097
|
-
_optionalChain([this, 'access',
|
|
7323
|
+
_optionalChain([this, 'access', _147 => _147.#items, 'access', _148 => _148.at, 'call', _149 => _149(existingItemIndex + 1), 'optionalAccess', _150 => _150._parentPos])
|
|
7098
7324
|
)
|
|
7099
7325
|
);
|
|
7100
7326
|
this.#items.reposition(existingItem);
|
|
@@ -7118,7 +7344,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7118
7344
|
existingItemIndex,
|
|
7119
7345
|
makePosition(
|
|
7120
7346
|
newKey,
|
|
7121
|
-
_optionalChain([this, 'access',
|
|
7347
|
+
_optionalChain([this, 'access', _151 => _151.#items, 'access', _152 => _152.at, 'call', _153 => _153(existingItemIndex + 1), 'optionalAccess', _154 => _154._parentPos])
|
|
7122
7348
|
)
|
|
7123
7349
|
);
|
|
7124
7350
|
}
|
|
@@ -7146,7 +7372,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7146
7372
|
if (existingItemIndex !== -1) {
|
|
7147
7373
|
actualNewKey = makePosition(
|
|
7148
7374
|
newKey,
|
|
7149
|
-
_optionalChain([this, 'access',
|
|
7375
|
+
_optionalChain([this, 'access', _155 => _155.#items, 'access', _156 => _156.at, 'call', _157 => _157(existingItemIndex + 1), 'optionalAccess', _158 => _158._parentPos])
|
|
7150
7376
|
);
|
|
7151
7377
|
}
|
|
7152
7378
|
this.#updateItemPosition(child, actualNewKey);
|
|
@@ -7220,14 +7446,14 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7220
7446
|
* instead of resolving its position against the client's stale view.
|
|
7221
7447
|
*/
|
|
7222
7448
|
#injectAt(element, index, intent) {
|
|
7223
|
-
_optionalChain([this, 'access',
|
|
7449
|
+
_optionalChain([this, 'access', _159 => _159._pool, 'optionalAccess', _160 => _160.assertStorageIsWritable, 'call', _161 => _161()]);
|
|
7224
7450
|
if (index < 0 || index > this.#items.length) {
|
|
7225
7451
|
throw new Error(
|
|
7226
7452
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
7227
7453
|
);
|
|
7228
7454
|
}
|
|
7229
|
-
const before2 = _optionalChain([this, 'access',
|
|
7230
|
-
const after2 = _optionalChain([this, 'access',
|
|
7455
|
+
const before2 = _optionalChain([this, 'access', _162 => _162.#items, 'access', _163 => _163.at, 'call', _164 => _164(index - 1), 'optionalAccess', _165 => _165._parentPos]);
|
|
7456
|
+
const after2 = _optionalChain([this, 'access', _166 => _166.#items, 'access', _167 => _167.at, 'call', _168 => _168(index), 'optionalAccess', _169 => _169._parentPos]);
|
|
7231
7457
|
const position = makePosition(before2, after2);
|
|
7232
7458
|
const value = lsonToLiveNode(element);
|
|
7233
7459
|
value._setParentLink(this, position);
|
|
@@ -7251,7 +7477,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7251
7477
|
* @param targetIndex The index where the element should be after moving.
|
|
7252
7478
|
*/
|
|
7253
7479
|
move(index, targetIndex) {
|
|
7254
|
-
_optionalChain([this, 'access',
|
|
7480
|
+
_optionalChain([this, 'access', _170 => _170._pool, 'optionalAccess', _171 => _171.assertStorageIsWritable, 'call', _172 => _172()]);
|
|
7255
7481
|
if (targetIndex < 0) {
|
|
7256
7482
|
throw new Error("targetIndex cannot be less than 0");
|
|
7257
7483
|
}
|
|
@@ -7269,11 +7495,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7269
7495
|
let beforePosition = null;
|
|
7270
7496
|
let afterPosition = null;
|
|
7271
7497
|
if (index < targetIndex) {
|
|
7272
|
-
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access',
|
|
7498
|
+
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access', _173 => _173.#items, 'access', _174 => _174.at, 'call', _175 => _175(targetIndex + 1), 'optionalAccess', _176 => _176._parentPos]);
|
|
7273
7499
|
beforePosition = this.#items.at(targetIndex)._parentPos;
|
|
7274
7500
|
} else {
|
|
7275
7501
|
afterPosition = this.#items.at(targetIndex)._parentPos;
|
|
7276
|
-
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access',
|
|
7502
|
+
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access', _177 => _177.#items, 'access', _178 => _178.at, 'call', _179 => _179(targetIndex - 1), 'optionalAccess', _180 => _180._parentPos]);
|
|
7277
7503
|
}
|
|
7278
7504
|
const position = makePosition(beforePosition, afterPosition);
|
|
7279
7505
|
const item = this.#items.at(index);
|
|
@@ -7308,7 +7534,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7308
7534
|
* @param index The index of the element to delete
|
|
7309
7535
|
*/
|
|
7310
7536
|
delete(index) {
|
|
7311
|
-
_optionalChain([this, 'access',
|
|
7537
|
+
_optionalChain([this, 'access', _181 => _181._pool, 'optionalAccess', _182 => _182.assertStorageIsWritable, 'call', _183 => _183()]);
|
|
7312
7538
|
if (index < 0 || index >= this.#items.length) {
|
|
7313
7539
|
throw new Error(
|
|
7314
7540
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7341,7 +7567,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7341
7567
|
}
|
|
7342
7568
|
}
|
|
7343
7569
|
clear() {
|
|
7344
|
-
_optionalChain([this, 'access',
|
|
7570
|
+
_optionalChain([this, 'access', _184 => _184._pool, 'optionalAccess', _185 => _185.assertStorageIsWritable, 'call', _186 => _186()]);
|
|
7345
7571
|
if (this._pool) {
|
|
7346
7572
|
const ops = [];
|
|
7347
7573
|
const reverseOps = [];
|
|
@@ -7375,7 +7601,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7375
7601
|
}
|
|
7376
7602
|
}
|
|
7377
7603
|
set(index, item) {
|
|
7378
|
-
_optionalChain([this, 'access',
|
|
7604
|
+
_optionalChain([this, 'access', _187 => _187._pool, 'optionalAccess', _188 => _188.assertStorageIsWritable, 'call', _189 => _189()]);
|
|
7379
7605
|
if (index < 0 || index >= this.#items.length) {
|
|
7380
7606
|
throw new Error(
|
|
7381
7607
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7534,7 +7760,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7534
7760
|
#shiftItemPosition(index, key) {
|
|
7535
7761
|
const shiftedPosition = makePosition(
|
|
7536
7762
|
key,
|
|
7537
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
7763
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _190 => _190.#items, 'access', _191 => _191.at, 'call', _192 => _192(index + 1), 'optionalAccess', _193 => _193._parentPos]) : void 0
|
|
7538
7764
|
);
|
|
7539
7765
|
this.#updateItemPositionAt(index, shiftedPosition);
|
|
7540
7766
|
}
|
|
@@ -7783,7 +8009,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7783
8009
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
7784
8010
|
*/
|
|
7785
8011
|
set(key, value) {
|
|
7786
|
-
_optionalChain([this, 'access',
|
|
8012
|
+
_optionalChain([this, 'access', _194 => _194._pool, 'optionalAccess', _195 => _195.assertStorageIsWritable, 'call', _196 => _196()]);
|
|
7787
8013
|
const oldValue = this.#map.get(key);
|
|
7788
8014
|
if (oldValue) {
|
|
7789
8015
|
oldValue._detach();
|
|
@@ -7829,7 +8055,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7829
8055
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
7830
8056
|
*/
|
|
7831
8057
|
delete(key) {
|
|
7832
|
-
_optionalChain([this, 'access',
|
|
8058
|
+
_optionalChain([this, 'access', _197 => _197._pool, 'optionalAccess', _198 => _198.assertStorageIsWritable, 'call', _199 => _199()]);
|
|
7833
8059
|
const item = this.#map.get(key);
|
|
7834
8060
|
if (item === void 0) {
|
|
7835
8061
|
return false;
|
|
@@ -8441,20 +8667,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8441
8667
|
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8442
8668
|
*/
|
|
8443
8669
|
setLocal(key, value) {
|
|
8444
|
-
_optionalChain([this, 'access',
|
|
8670
|
+
_optionalChain([this, 'access', _200 => _200._pool, 'optionalAccess', _201 => _201.assertStorageIsWritable, 'call', _202 => _202()]);
|
|
8445
8671
|
const deleteResult = this.#prepareDelete(key);
|
|
8446
8672
|
this.#local.set(key, value);
|
|
8447
8673
|
this.invalidate();
|
|
8448
8674
|
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8449
|
-
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8450
|
-
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8451
|
-
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess',
|
|
8675
|
+
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _203 => _203[0]]), () => ( []));
|
|
8676
|
+
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _204 => _204[1]]), () => ( []));
|
|
8677
|
+
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _205 => _205[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8452
8678
|
const existing = storageUpdates.get(this._id);
|
|
8453
8679
|
storageUpdates.set(this._id, {
|
|
8454
8680
|
node: this,
|
|
8455
8681
|
type: "LiveObject",
|
|
8456
8682
|
updates: {
|
|
8457
|
-
..._optionalChain([existing, 'optionalAccess',
|
|
8683
|
+
..._optionalChain([existing, 'optionalAccess', _206 => _206.updates]),
|
|
8458
8684
|
[key]: { type: "update" }
|
|
8459
8685
|
}
|
|
8460
8686
|
});
|
|
@@ -8474,7 +8700,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8474
8700
|
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8475
8701
|
*/
|
|
8476
8702
|
#prepareDelete(key) {
|
|
8477
|
-
_optionalChain([this, 'access',
|
|
8703
|
+
_optionalChain([this, 'access', _207 => _207._pool, 'optionalAccess', _208 => _208.assertStorageIsWritable, 'call', _209 => _209()]);
|
|
8478
8704
|
const k = key;
|
|
8479
8705
|
if (this.#local.has(k) && !this.#synced.has(k)) {
|
|
8480
8706
|
const oldValue2 = this.#local.get(k);
|
|
@@ -8550,7 +8776,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8550
8776
|
const result = this.#prepareDelete(key);
|
|
8551
8777
|
if (result) {
|
|
8552
8778
|
const [ops, reverse, storageUpdates] = result;
|
|
8553
|
-
_optionalChain([this, 'access',
|
|
8779
|
+
_optionalChain([this, 'access', _210 => _210._pool, 'optionalAccess', _211 => _211.dispatch, 'call', _212 => _212(ops, reverse, storageUpdates)]);
|
|
8554
8780
|
}
|
|
8555
8781
|
}
|
|
8556
8782
|
/**
|
|
@@ -8558,7 +8784,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8558
8784
|
* @param patch The object used to overrides properties
|
|
8559
8785
|
*/
|
|
8560
8786
|
update(patch) {
|
|
8561
|
-
_optionalChain([this, 'access',
|
|
8787
|
+
_optionalChain([this, 'access', _213 => _213._pool, 'optionalAccess', _214 => _214.assertStorageIsWritable, 'call', _215 => _215()]);
|
|
8562
8788
|
if (_LiveObject.detectLargeObjects) {
|
|
8563
8789
|
const data = {};
|
|
8564
8790
|
for (const [key, value] of this.#synced) {
|
|
@@ -8764,6 +8990,8 @@ function creationOpToLiveNode(op) {
|
|
|
8764
8990
|
}
|
|
8765
8991
|
function creationOpToLson(op) {
|
|
8766
8992
|
switch (op.type) {
|
|
8993
|
+
case OpCode.CREATE_FILE:
|
|
8994
|
+
return new LiveFile(op.data);
|
|
8767
8995
|
case OpCode.CREATE_REGISTER:
|
|
8768
8996
|
return op.data;
|
|
8769
8997
|
case OpCode.CREATE_OBJECT:
|
|
@@ -8794,6 +9022,8 @@ function deserialize(node, parentToChildren, pool) {
|
|
|
8794
9022
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8795
9023
|
} else if (isRegisterStorageNode(node)) {
|
|
8796
9024
|
return LiveRegister._deserialize(node, parentToChildren, pool);
|
|
9025
|
+
} else if (isFileStorageNode(node)) {
|
|
9026
|
+
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
8797
9027
|
} else {
|
|
8798
9028
|
throw new Error("Unexpected CRDT type");
|
|
8799
9029
|
}
|
|
@@ -8807,12 +9037,14 @@ function deserializeToLson(node, parentToChildren, pool) {
|
|
|
8807
9037
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8808
9038
|
} else if (isRegisterStorageNode(node)) {
|
|
8809
9039
|
return node[1].data;
|
|
9040
|
+
} else if (isFileStorageNode(node)) {
|
|
9041
|
+
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
8810
9042
|
} else {
|
|
8811
9043
|
throw new Error("Unexpected CRDT type");
|
|
8812
9044
|
}
|
|
8813
9045
|
}
|
|
8814
9046
|
function isLiveStructure(value) {
|
|
8815
|
-
return isLiveList(value) || isLiveMap(value) || isLiveObject(value);
|
|
9047
|
+
return isLiveList(value) || isLiveMap(value) || isLiveObject(value) || isLiveFile(value);
|
|
8816
9048
|
}
|
|
8817
9049
|
function isLiveNode(value) {
|
|
8818
9050
|
return isLiveStructure(value) || isLiveRegister(value);
|
|
@@ -8826,6 +9058,9 @@ function isLiveMap(value) {
|
|
|
8826
9058
|
function isLiveObject(value) {
|
|
8827
9059
|
return value instanceof LiveObject;
|
|
8828
9060
|
}
|
|
9061
|
+
function isLiveFile(value) {
|
|
9062
|
+
return value instanceof LiveFile;
|
|
9063
|
+
}
|
|
8829
9064
|
function isLiveRegister(value) {
|
|
8830
9065
|
return value instanceof LiveRegister;
|
|
8831
9066
|
}
|
|
@@ -8835,14 +9070,14 @@ function cloneLson(value) {
|
|
|
8835
9070
|
function liveNodeToLson(obj) {
|
|
8836
9071
|
if (obj instanceof LiveRegister) {
|
|
8837
9072
|
return obj.data;
|
|
8838
|
-
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject) {
|
|
9073
|
+
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject || obj instanceof LiveFile) {
|
|
8839
9074
|
return obj;
|
|
8840
9075
|
} else {
|
|
8841
9076
|
return assertNever(obj, "Unknown AbstractCrdt");
|
|
8842
9077
|
}
|
|
8843
9078
|
}
|
|
8844
9079
|
function lsonToLiveNode(value) {
|
|
8845
|
-
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList) {
|
|
9080
|
+
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList || value instanceof LiveFile) {
|
|
8846
9081
|
return value;
|
|
8847
9082
|
} else {
|
|
8848
9083
|
return new LiveRegister(value);
|
|
@@ -8859,6 +9094,8 @@ function dumpPool(pool) {
|
|
|
8859
9094
|
value = "<LiveList>";
|
|
8860
9095
|
} else if (node instanceof LiveMap) {
|
|
8861
9096
|
value = "<LiveMap>";
|
|
9097
|
+
} else if (node instanceof LiveFile) {
|
|
9098
|
+
value = stringifyOrLog(node.data);
|
|
8862
9099
|
} else {
|
|
8863
9100
|
value = "<LiveObject>";
|
|
8864
9101
|
}
|
|
@@ -8955,6 +9192,15 @@ function diffNodeMap(prev, next) {
|
|
|
8955
9192
|
data: crdt.data
|
|
8956
9193
|
});
|
|
8957
9194
|
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;
|
|
8958
9204
|
case CrdtType.LIST:
|
|
8959
9205
|
ops.push({
|
|
8960
9206
|
type: OpCode.CREATE_LIST,
|
|
@@ -9045,7 +9291,7 @@ function sendToPanel(message, options) {
|
|
|
9045
9291
|
...message,
|
|
9046
9292
|
source: "liveblocks-devtools-client"
|
|
9047
9293
|
};
|
|
9048
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
9294
|
+
if (!(_optionalChain([options, 'optionalAccess', _216 => _216.force]) || _bridgeActive)) {
|
|
9049
9295
|
return;
|
|
9050
9296
|
}
|
|
9051
9297
|
window.postMessage(fullMsg, "*");
|
|
@@ -9053,7 +9299,7 @@ function sendToPanel(message, options) {
|
|
|
9053
9299
|
var eventSource = makeEventSource();
|
|
9054
9300
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
9055
9301
|
window.addEventListener("message", (event) => {
|
|
9056
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
9302
|
+
if (event.source === window && _optionalChain([event, 'access', _217 => _217.data, 'optionalAccess', _218 => _218.source]) === "liveblocks-devtools-panel") {
|
|
9057
9303
|
eventSource.notify(event.data);
|
|
9058
9304
|
} else {
|
|
9059
9305
|
}
|
|
@@ -9195,7 +9441,7 @@ function fullSync(room) {
|
|
|
9195
9441
|
msg: "room::sync::full",
|
|
9196
9442
|
roomId: room.id,
|
|
9197
9443
|
status: room.getStatus(),
|
|
9198
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
9444
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _219 => _219.toTreeNode, 'call', _220 => _220("root"), 'access', _221 => _221.payload]), () => ( null)),
|
|
9199
9445
|
me,
|
|
9200
9446
|
others
|
|
9201
9447
|
});
|
|
@@ -9852,6 +10098,9 @@ function defaultMessageFromContext(context) {
|
|
|
9852
10098
|
|
|
9853
10099
|
// src/room.ts
|
|
9854
10100
|
var FEEDS_TIMEOUT = 5e3;
|
|
10101
|
+
function getLiveFileId(file) {
|
|
10102
|
+
return typeof file === "string" ? file : file.id;
|
|
10103
|
+
}
|
|
9855
10104
|
function connectionAccessFromScopes(scopes) {
|
|
9856
10105
|
const roomPermissions = normalizeRoomPermissions(scopes);
|
|
9857
10106
|
const matrix = permissionMatrixFromScopes(roomPermissions);
|
|
@@ -9882,15 +10131,15 @@ function installBackgroundTabSpy() {
|
|
|
9882
10131
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
9883
10132
|
const inBackgroundSince = { current: null };
|
|
9884
10133
|
function onVisibilityChange() {
|
|
9885
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
10134
|
+
if (_optionalChain([doc, 'optionalAccess', _222 => _222.visibilityState]) === "hidden") {
|
|
9886
10135
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
9887
10136
|
} else {
|
|
9888
10137
|
inBackgroundSince.current = null;
|
|
9889
10138
|
}
|
|
9890
10139
|
}
|
|
9891
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10140
|
+
_optionalChain([doc, 'optionalAccess', _223 => _223.addEventListener, 'call', _224 => _224("visibilitychange", onVisibilityChange)]);
|
|
9892
10141
|
const unsub = () => {
|
|
9893
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10142
|
+
_optionalChain([doc, 'optionalAccess', _225 => _225.removeEventListener, 'call', _226 => _226("visibilitychange", onVisibilityChange)]);
|
|
9894
10143
|
};
|
|
9895
10144
|
return [inBackgroundSince, unsub];
|
|
9896
10145
|
}
|
|
@@ -9911,6 +10160,19 @@ function makeNodeMapBuffer() {
|
|
|
9911
10160
|
}
|
|
9912
10161
|
};
|
|
9913
10162
|
}
|
|
10163
|
+
function topLevelKeysOf(nodes) {
|
|
10164
|
+
const keys2 = /* @__PURE__ */ new Set();
|
|
10165
|
+
const root = nodes.get("root");
|
|
10166
|
+
for (const key in _optionalChain([root, 'optionalAccess', _227 => _227.data])) {
|
|
10167
|
+
keys2.add(key);
|
|
10168
|
+
}
|
|
10169
|
+
for (const node of nodes.values()) {
|
|
10170
|
+
if (node.parentId === "root") {
|
|
10171
|
+
keys2.add(node.parentKey);
|
|
10172
|
+
}
|
|
10173
|
+
}
|
|
10174
|
+
return keys2;
|
|
10175
|
+
}
|
|
9914
10176
|
function createRoom(options, config) {
|
|
9915
10177
|
const roomId = config.roomId;
|
|
9916
10178
|
const initialPresence = options.initialPresence;
|
|
@@ -10113,21 +10375,21 @@ function createRoom(options, config) {
|
|
|
10113
10375
|
async function reportTextEditor(type, rootKey) {
|
|
10114
10376
|
await httpClient.reportTextEditor({ roomId, type, rootKey });
|
|
10115
10377
|
}
|
|
10116
|
-
async function
|
|
10117
|
-
return httpClient.
|
|
10378
|
+
async function listHistoryVersions() {
|
|
10379
|
+
return httpClient.listHistoryVersions({ roomId });
|
|
10118
10380
|
}
|
|
10119
|
-
async function
|
|
10120
|
-
return httpClient.
|
|
10381
|
+
async function listHistoryVersionsSince(options2) {
|
|
10382
|
+
return httpClient.listHistoryVersionsSince({
|
|
10121
10383
|
roomId,
|
|
10122
10384
|
since: options2.since,
|
|
10123
10385
|
signal: options2.signal
|
|
10124
10386
|
});
|
|
10125
10387
|
}
|
|
10126
|
-
async function
|
|
10127
|
-
return httpClient.
|
|
10388
|
+
async function getYjsHistoryVersion(versionId) {
|
|
10389
|
+
return httpClient.getYjsHistoryVersion({ roomId, versionId });
|
|
10128
10390
|
}
|
|
10129
|
-
async function
|
|
10130
|
-
return httpClient.
|
|
10391
|
+
async function createVersionHistorySnapshot() {
|
|
10392
|
+
return httpClient.createVersionHistorySnapshot({ roomId });
|
|
10131
10393
|
}
|
|
10132
10394
|
async function executeContextualPrompt(options2) {
|
|
10133
10395
|
return httpClient.executeContextualPrompt({
|
|
@@ -10197,10 +10459,11 @@ function createRoom(options, config) {
|
|
|
10197
10459
|
);
|
|
10198
10460
|
}
|
|
10199
10461
|
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _232 => _232.get, 'call', _233 => _233(), 'optionalAccess', _234 => _234.canWrite]), () => ( true));
|
|
10462
|
+
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
10200
10463
|
const root = context.root;
|
|
10201
10464
|
disableHistory(() => {
|
|
10202
10465
|
for (const key in context.initialStorage) {
|
|
10203
|
-
if (
|
|
10466
|
+
if (!serverTopLevelKeys.has(key)) {
|
|
10204
10467
|
if (canWrite) {
|
|
10205
10468
|
root.set(key, cloneLson(context.initialStorage[key]));
|
|
10206
10469
|
} else {
|
|
@@ -10327,7 +10590,7 @@ function createRoom(options, config) {
|
|
|
10327
10590
|
);
|
|
10328
10591
|
output.reverse.pushLeft(applyOpResult.reverse);
|
|
10329
10592
|
}
|
|
10330
|
-
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
10593
|
+
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_FILE) {
|
|
10331
10594
|
createdNodeIds.add(op.id);
|
|
10332
10595
|
}
|
|
10333
10596
|
}
|
|
@@ -10371,6 +10634,7 @@ function createRoom(options, config) {
|
|
|
10371
10634
|
case OpCode.CREATE_OBJECT:
|
|
10372
10635
|
case OpCode.CREATE_LIST:
|
|
10373
10636
|
case OpCode.CREATE_MAP:
|
|
10637
|
+
case OpCode.CREATE_FILE:
|
|
10374
10638
|
case OpCode.CREATE_REGISTER: {
|
|
10375
10639
|
if (op.parentId === void 0) {
|
|
10376
10640
|
return { modified: false };
|
|
@@ -11474,6 +11738,17 @@ function createRoom(options, config) {
|
|
|
11474
11738
|
function getAttachmentUrl(attachmentId) {
|
|
11475
11739
|
return httpClient.getAttachmentUrl({ roomId, attachmentId });
|
|
11476
11740
|
}
|
|
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
|
+
}
|
|
11477
11752
|
function getSubscriptionSettings(options2) {
|
|
11478
11753
|
return httpClient.getSubscriptionSettings({
|
|
11479
11754
|
roomId,
|
|
@@ -11528,13 +11803,13 @@ function createRoom(options, config) {
|
|
|
11528
11803
|
// delete a text mention when using a text editor
|
|
11529
11804
|
deleteTextMention,
|
|
11530
11805
|
// list versions of the document
|
|
11531
|
-
|
|
11806
|
+
listHistoryVersions,
|
|
11532
11807
|
// List versions of the document since the specified date
|
|
11533
|
-
|
|
11808
|
+
listHistoryVersionsSince,
|
|
11534
11809
|
// get a specific version
|
|
11535
|
-
|
|
11810
|
+
getYjsHistoryVersion,
|
|
11536
11811
|
// create a version
|
|
11537
|
-
|
|
11812
|
+
createVersionHistorySnapshot,
|
|
11538
11813
|
// execute a contextual prompt
|
|
11539
11814
|
executeContextualPrompt,
|
|
11540
11815
|
// Support for the Liveblocks browser extension
|
|
@@ -11547,7 +11822,8 @@ function createRoom(options, config) {
|
|
|
11547
11822
|
rawSend: (data) => managedSocket.send(data),
|
|
11548
11823
|
incomingMessage: (data) => handleServerMessage(new MessageEvent("message", { data }))
|
|
11549
11824
|
},
|
|
11550
|
-
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
11825
|
+
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId),
|
|
11826
|
+
fileUrlsStore: httpClient.getOrCreateFileUrlsStore(roomId)
|
|
11551
11827
|
},
|
|
11552
11828
|
id: roomId,
|
|
11553
11829
|
subscribe: makeClassicSubscribeFn(
|
|
@@ -11645,6 +11921,8 @@ ${dumpPool(
|
|
|
11645
11921
|
prepareAttachment,
|
|
11646
11922
|
uploadAttachment,
|
|
11647
11923
|
getAttachmentUrl,
|
|
11924
|
+
uploadFile,
|
|
11925
|
+
getFileUrl,
|
|
11648
11926
|
// Notifications
|
|
11649
11927
|
getNotificationSettings: getSubscriptionSettings,
|
|
11650
11928
|
getSubscriptionSettings,
|
|
@@ -12530,6 +12808,11 @@ function toPlainLson(lson) {
|
|
|
12530
12808
|
liveblocksType: "LiveList",
|
|
12531
12809
|
data: [...lson].map((item) => toPlainLson(item))
|
|
12532
12810
|
};
|
|
12811
|
+
} else if (lson instanceof LiveFile) {
|
|
12812
|
+
return {
|
|
12813
|
+
liveblocksType: "LiveFile",
|
|
12814
|
+
data: lson.data
|
|
12815
|
+
};
|
|
12533
12816
|
} else {
|
|
12534
12817
|
return lson;
|
|
12535
12818
|
}
|
|
@@ -12815,5 +13098,8 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
12815
13098
|
|
|
12816
13099
|
|
|
12817
13100
|
|
|
12818
|
-
|
|
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;
|
|
12819
13105
|
//# sourceMappingURL=index.cjs.map
|