@liveblocks/core 3.22.0-file1 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +447 -635
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +231 -292
- package/dist/index.d.ts +231 -292
- package/dist/index.js +285 -473
- 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";
|
|
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/${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/${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`,
|
|
@@ -2255,7 +2132,17 @@ function createApiClient({
|
|
|
2255
2132
|
})
|
|
2256
2133
|
);
|
|
2257
2134
|
}
|
|
2258
|
-
async function
|
|
2135
|
+
async function fetchStorageHistoryVersion(options) {
|
|
2136
|
+
return httpClient.rawGet(
|
|
2137
|
+
url`/v2/c/rooms/${options.roomId}/versions/${options.versionId}/storage`,
|
|
2138
|
+
await authManager.getAuthValue({
|
|
2139
|
+
roomId: options.roomId,
|
|
2140
|
+
resource: "storage",
|
|
2141
|
+
access: "read"
|
|
2142
|
+
})
|
|
2143
|
+
);
|
|
2144
|
+
}
|
|
2145
|
+
async function fetchYjsHistoryVersion(options) {
|
|
2259
2146
|
return httpClient.rawGet(
|
|
2260
2147
|
url`/v2/c/rooms/${options.roomId}/versions/${options.versionId}/yjs`,
|
|
2261
2148
|
await authManager.getAuthValue({
|
|
@@ -2275,6 +2162,16 @@ function createApiClient({
|
|
|
2275
2162
|
})
|
|
2276
2163
|
);
|
|
2277
2164
|
}
|
|
2165
|
+
async function deleteHistoryVersion(options) {
|
|
2166
|
+
await httpClient.delete(
|
|
2167
|
+
url`/v2/c/rooms/${options.roomId}/versions/${options.versionId}`,
|
|
2168
|
+
await authManager.getAuthValue({
|
|
2169
|
+
roomId: options.roomId,
|
|
2170
|
+
resource: "storage",
|
|
2171
|
+
access: "write"
|
|
2172
|
+
})
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2278
2175
|
async function reportTextEditor(options) {
|
|
2279
2176
|
await httpClient.rawPost(
|
|
2280
2177
|
url`/v2/c/rooms/${options.roomId}/text-metadata`,
|
|
@@ -2367,14 +2264,14 @@ function createApiClient({
|
|
|
2367
2264
|
async function getInboxNotifications(options) {
|
|
2368
2265
|
const PAGE_SIZE = 50;
|
|
2369
2266
|
let query;
|
|
2370
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2267
|
+
if (_optionalChain([options, 'optionalAccess', _23 => _23.query])) {
|
|
2371
2268
|
query = objectToQuery(options.query);
|
|
2372
2269
|
}
|
|
2373
2270
|
const json = await httpClient.get(
|
|
2374
2271
|
url`/v2/c/inbox-notifications`,
|
|
2375
2272
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2376
2273
|
{
|
|
2377
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2274
|
+
cursor: _optionalChain([options, 'optionalAccess', _24 => _24.cursor]),
|
|
2378
2275
|
limit: PAGE_SIZE,
|
|
2379
2276
|
query
|
|
2380
2277
|
}
|
|
@@ -2393,7 +2290,7 @@ function createApiClient({
|
|
|
2393
2290
|
}
|
|
2394
2291
|
async function getInboxNotificationsSince(options) {
|
|
2395
2292
|
let query;
|
|
2396
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2293
|
+
if (_optionalChain([options, 'optionalAccess', _25 => _25.query])) {
|
|
2397
2294
|
query = objectToQuery(options.query);
|
|
2398
2295
|
}
|
|
2399
2296
|
const json = await httpClient.get(
|
|
@@ -2422,14 +2319,14 @@ function createApiClient({
|
|
|
2422
2319
|
}
|
|
2423
2320
|
async function getUnreadInboxNotificationsCount(options) {
|
|
2424
2321
|
let query;
|
|
2425
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2322
|
+
if (_optionalChain([options, 'optionalAccess', _26 => _26.query])) {
|
|
2426
2323
|
query = objectToQuery(options.query);
|
|
2427
2324
|
}
|
|
2428
2325
|
const { count } = await httpClient.get(
|
|
2429
2326
|
url`/v2/c/inbox-notifications/count`,
|
|
2430
2327
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2431
2328
|
{ query },
|
|
2432
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2329
|
+
{ signal: _optionalChain([options, 'optionalAccess', _27 => _27.signal]) }
|
|
2433
2330
|
);
|
|
2434
2331
|
return count;
|
|
2435
2332
|
}
|
|
@@ -2479,7 +2376,7 @@ function createApiClient({
|
|
|
2479
2376
|
url`/v2/c/notification-settings`,
|
|
2480
2377
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2481
2378
|
void 0,
|
|
2482
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2379
|
+
{ signal: _optionalChain([options, 'optionalAccess', _28 => _28.signal]) }
|
|
2483
2380
|
);
|
|
2484
2381
|
}
|
|
2485
2382
|
async function updateNotificationSettings(settings) {
|
|
@@ -2491,7 +2388,7 @@ function createApiClient({
|
|
|
2491
2388
|
}
|
|
2492
2389
|
async function getUserThreads_experimental(options) {
|
|
2493
2390
|
let query;
|
|
2494
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2391
|
+
if (_optionalChain([options, 'optionalAccess', _29 => _29.query])) {
|
|
2495
2392
|
query = objectToQuery(options.query);
|
|
2496
2393
|
}
|
|
2497
2394
|
const PAGE_SIZE = 50;
|
|
@@ -2499,7 +2396,7 @@ function createApiClient({
|
|
|
2499
2396
|
url`/v2/c/threads`,
|
|
2500
2397
|
await authManager.getAuthValue({ resource: "personal", access: "write" }),
|
|
2501
2398
|
{
|
|
2502
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2399
|
+
cursor: _optionalChain([options, 'optionalAccess', _30 => _30.cursor]),
|
|
2503
2400
|
query,
|
|
2504
2401
|
limit: PAGE_SIZE
|
|
2505
2402
|
}
|
|
@@ -2598,8 +2495,10 @@ function createApiClient({
|
|
|
2598
2495
|
// Room text editor
|
|
2599
2496
|
createTextMention,
|
|
2600
2497
|
deleteTextMention,
|
|
2601
|
-
|
|
2498
|
+
fetchStorageHistoryVersion,
|
|
2499
|
+
fetchYjsHistoryVersion,
|
|
2602
2500
|
createVersionHistorySnapshot,
|
|
2501
|
+
deleteHistoryVersion,
|
|
2603
2502
|
reportTextEditor,
|
|
2604
2503
|
listHistoryVersions,
|
|
2605
2504
|
listHistoryVersionsSince,
|
|
@@ -2607,10 +2506,6 @@ function createApiClient({
|
|
|
2607
2506
|
getAttachmentUrl,
|
|
2608
2507
|
uploadAttachment,
|
|
2609
2508
|
getOrCreateAttachmentUrlsStore,
|
|
2610
|
-
// Room storage files
|
|
2611
|
-
getFileUrl,
|
|
2612
|
-
uploadFile,
|
|
2613
|
-
getOrCreateFileUrlsStore,
|
|
2614
2509
|
// Room storage
|
|
2615
2510
|
streamStorage,
|
|
2616
2511
|
// Notifications
|
|
@@ -2676,7 +2571,7 @@ var HttpClient = class {
|
|
|
2676
2571
|
// These headers are default, but can be overriden by custom headers
|
|
2677
2572
|
"Content-Type": "application/json; charset=utf-8",
|
|
2678
2573
|
// Possible header overrides
|
|
2679
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2574
|
+
..._optionalChain([options, 'optionalAccess', _31 => _31.headers]),
|
|
2680
2575
|
// Cannot be overriden by custom headers
|
|
2681
2576
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2682
2577
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -2684,7 +2579,7 @@ var HttpClient = class {
|
|
|
2684
2579
|
});
|
|
2685
2580
|
const xwarn = response.headers.get("X-LB-Warn");
|
|
2686
2581
|
if (xwarn) {
|
|
2687
|
-
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
2582
|
+
const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _32 => _32.method, 'optionalAccess', _33 => _33.toUpperCase, 'call', _34 => _34()]), () => ( "GET"));
|
|
2688
2583
|
const msg = `${xwarn} (${method} ${endpoint})`;
|
|
2689
2584
|
if (response.ok) {
|
|
2690
2585
|
warn(msg);
|
|
@@ -3166,7 +3061,7 @@ var FSM = class {
|
|
|
3166
3061
|
});
|
|
3167
3062
|
}
|
|
3168
3063
|
#getTargetFn(eventName) {
|
|
3169
|
-
return _optionalChain([this, 'access',
|
|
3064
|
+
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
3065
|
}
|
|
3171
3066
|
/**
|
|
3172
3067
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -3185,7 +3080,7 @@ var FSM = class {
|
|
|
3185
3080
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3186
3081
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
3187
3082
|
for (let i = 0; i < levels; i++) {
|
|
3188
|
-
_optionalChain([this, 'access',
|
|
3083
|
+
_optionalChain([this, 'access', _40 => _40.#cleanupStack, 'access', _41 => _41.pop, 'call', _42 => _42(), 'optionalCall', _43 => _43(patchableContext)]);
|
|
3189
3084
|
const entryTime = this.#entryTimesStack.pop();
|
|
3190
3085
|
if (entryTime !== void 0 && // ...but avoid computing state names if nobody is listening
|
|
3191
3086
|
this.#eventHub.didExitState.count() > 0) {
|
|
@@ -3213,7 +3108,7 @@ var FSM = class {
|
|
|
3213
3108
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3214
3109
|
for (const pattern of enterPatterns) {
|
|
3215
3110
|
const enterFn = this.#enterFns.get(pattern);
|
|
3216
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
3111
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _44 => _44(patchableContext)]);
|
|
3217
3112
|
if (typeof cleanupFn === "function") {
|
|
3218
3113
|
this.#cleanupStack.push(cleanupFn);
|
|
3219
3114
|
} else {
|
|
@@ -3640,7 +3535,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3640
3535
|
}
|
|
3641
3536
|
function waitForActorId(event) {
|
|
3642
3537
|
const serverMsg = tryParseJson(event.data);
|
|
3643
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
3538
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _45 => _45.type]) === ServerMsgCode.ROOM_STATE) {
|
|
3644
3539
|
if (options.enableDebugLogging && socketOpenAt !== null) {
|
|
3645
3540
|
const elapsed = performance.now() - socketOpenAt;
|
|
3646
3541
|
warn(
|
|
@@ -3768,12 +3663,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3768
3663
|
const sendHeartbeat = {
|
|
3769
3664
|
target: "@ok.awaiting-pong",
|
|
3770
3665
|
effect: (ctx) => {
|
|
3771
|
-
_optionalChain([ctx, 'access',
|
|
3666
|
+
_optionalChain([ctx, 'access', _46 => _46.socket, 'optionalAccess', _47 => _47.send, 'call', _48 => _48("ping")]);
|
|
3772
3667
|
}
|
|
3773
3668
|
};
|
|
3774
3669
|
const maybeHeartbeat = () => {
|
|
3775
3670
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
3776
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
3671
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _49 => _49.visibilityState]) === "hidden" && delegates.canZombie();
|
|
3777
3672
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
3778
3673
|
};
|
|
3779
3674
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -3813,7 +3708,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3813
3708
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
3814
3709
|
// not. When still OPEN, don't transition.
|
|
3815
3710
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
3816
|
-
if (_optionalChain([context, 'access',
|
|
3711
|
+
if (_optionalChain([context, 'access', _50 => _50.socket, 'optionalAccess', _51 => _51.readyState]) === 1) {
|
|
3817
3712
|
return IGNORE;
|
|
3818
3713
|
}
|
|
3819
3714
|
return {
|
|
@@ -3865,17 +3760,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3865
3760
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
3866
3761
|
}
|
|
3867
3762
|
function onVisibilityChange() {
|
|
3868
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
3763
|
+
if (_optionalChain([doc, 'optionalAccess', _52 => _52.visibilityState]) === "visible") {
|
|
3869
3764
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3870
3765
|
}
|
|
3871
3766
|
}
|
|
3872
|
-
_optionalChain([win, 'optionalAccess',
|
|
3873
|
-
_optionalChain([win, 'optionalAccess',
|
|
3874
|
-
_optionalChain([root, 'optionalAccess',
|
|
3767
|
+
_optionalChain([win, 'optionalAccess', _53 => _53.addEventListener, 'call', _54 => _54("online", onNetworkBackOnline)]);
|
|
3768
|
+
_optionalChain([win, 'optionalAccess', _55 => _55.addEventListener, 'call', _56 => _56("offline", onNetworkOffline)]);
|
|
3769
|
+
_optionalChain([root, 'optionalAccess', _57 => _57.addEventListener, 'call', _58 => _58("visibilitychange", onVisibilityChange)]);
|
|
3875
3770
|
return () => {
|
|
3876
|
-
_optionalChain([root, 'optionalAccess',
|
|
3877
|
-
_optionalChain([win, 'optionalAccess',
|
|
3878
|
-
_optionalChain([win, 'optionalAccess',
|
|
3771
|
+
_optionalChain([root, 'optionalAccess', _59 => _59.removeEventListener, 'call', _60 => _60("visibilitychange", onVisibilityChange)]);
|
|
3772
|
+
_optionalChain([win, 'optionalAccess', _61 => _61.removeEventListener, 'call', _62 => _62("online", onNetworkBackOnline)]);
|
|
3773
|
+
_optionalChain([win, 'optionalAccess', _63 => _63.removeEventListener, 'call', _64 => _64("offline", onNetworkOffline)]);
|
|
3879
3774
|
teardownSocket(ctx.socket);
|
|
3880
3775
|
};
|
|
3881
3776
|
});
|
|
@@ -3964,7 +3859,7 @@ var ManagedSocket = class {
|
|
|
3964
3859
|
* message if this is somehow impossible.
|
|
3965
3860
|
*/
|
|
3966
3861
|
send(data) {
|
|
3967
|
-
const socket = _optionalChain([this, 'access',
|
|
3862
|
+
const socket = _optionalChain([this, 'access', _65 => _65.#machine, 'access', _66 => _66.context, 'optionalAccess', _67 => _67.socket]);
|
|
3968
3863
|
if (socket === null) {
|
|
3969
3864
|
warn("Cannot send: not connected yet", data);
|
|
3970
3865
|
} else if (socket.readyState !== 1) {
|
|
@@ -4426,7 +4321,7 @@ function createStore_forKnowledge() {
|
|
|
4426
4321
|
}
|
|
4427
4322
|
function getKnowledgeForChat(chatId) {
|
|
4428
4323
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
4429
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
4324
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _68 => _68.get, 'call', _69 => _69(chatId), 'optionalAccess', _70 => _70.get, 'call', _71 => _71()]), () => ( []));
|
|
4430
4325
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
4431
4326
|
}
|
|
4432
4327
|
return {
|
|
@@ -4451,7 +4346,7 @@ function createStore_forTools() {
|
|
|
4451
4346
|
return DerivedSignal.from(() => {
|
|
4452
4347
|
return (
|
|
4453
4348
|
// 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',
|
|
4349
|
+
_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
4350
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4456
4351
|
);
|
|
4457
4352
|
});
|
|
@@ -4481,8 +4376,8 @@ function createStore_forTools() {
|
|
|
4481
4376
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4482
4377
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4483
4378
|
return Array.from([
|
|
4484
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4485
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4379
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _74 => _74.entries, 'call', _75 => _75()]), () => ( [])),
|
|
4380
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _76 => _76.entries, 'call', _77 => _77()]), () => ( []))
|
|
4486
4381
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4487
4382
|
const tool = tool\u03A3.get();
|
|
4488
4383
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4585,7 +4480,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4585
4480
|
} else {
|
|
4586
4481
|
continue;
|
|
4587
4482
|
}
|
|
4588
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4483
|
+
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
4484
|
if (executeFn) {
|
|
4590
4485
|
(async () => {
|
|
4591
4486
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4684,8 +4579,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4684
4579
|
const spine = [];
|
|
4685
4580
|
let lastVisitedMessage = null;
|
|
4686
4581
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4687
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4688
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4582
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _83 => _83(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _84 => _84.id]), () => ( null));
|
|
4583
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _85 => _85(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _86 => _86.id]), () => ( null));
|
|
4689
4584
|
if (!message2.deletedAt || prev || next) {
|
|
4690
4585
|
const node = {
|
|
4691
4586
|
...message2,
|
|
@@ -4751,7 +4646,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4751
4646
|
const latest = pool.sorted.findRight(
|
|
4752
4647
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4753
4648
|
);
|
|
4754
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4649
|
+
return _optionalChain([latest, 'optionalAccess', _87 => _87.copilotId]);
|
|
4755
4650
|
}
|
|
4756
4651
|
return {
|
|
4757
4652
|
// Readers
|
|
@@ -4782,11 +4677,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4782
4677
|
*getAutoExecutingMessageIds() {
|
|
4783
4678
|
for (const messageId of myMessages) {
|
|
4784
4679
|
const message = getMessageById(messageId);
|
|
4785
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4680
|
+
if (_optionalChain([message, 'optionalAccess', _88 => _88.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4786
4681
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4787
4682
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4788
4683
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4789
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4684
|
+
return typeof _optionalChain([tool, 'optionalAccess', _89 => _89.execute]) === "function";
|
|
4790
4685
|
}
|
|
4791
4686
|
return false;
|
|
4792
4687
|
});
|
|
@@ -4934,7 +4829,7 @@ function createAi(config) {
|
|
|
4934
4829
|
flushPendingDeltas();
|
|
4935
4830
|
switch (msg.event) {
|
|
4936
4831
|
case "cmd-failed":
|
|
4937
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4832
|
+
_optionalChain([pendingCmd, 'optionalAccess', _90 => _90.reject, 'call', _91 => _91(new Error(msg.error))]);
|
|
4938
4833
|
break;
|
|
4939
4834
|
case "settle": {
|
|
4940
4835
|
context.messagesStore.upsert(msg.message);
|
|
@@ -5011,7 +4906,7 @@ function createAi(config) {
|
|
|
5011
4906
|
return assertNever(msg, "Unhandled case");
|
|
5012
4907
|
}
|
|
5013
4908
|
}
|
|
5014
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4909
|
+
_optionalChain([pendingCmd, 'optionalAccess', _92 => _92.resolve, 'call', _93 => _93(msg)]);
|
|
5015
4910
|
}
|
|
5016
4911
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
5017
4912
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -5087,9 +4982,9 @@ function createAi(config) {
|
|
|
5087
4982
|
invocationId,
|
|
5088
4983
|
result,
|
|
5089
4984
|
generationOptions: {
|
|
5090
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5091
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5092
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4985
|
+
copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
|
|
4986
|
+
stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
|
|
4987
|
+
timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
|
|
5093
4988
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
5094
4989
|
// from the global context
|
|
5095
4990
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -5107,7 +5002,7 @@ function createAi(config) {
|
|
|
5107
5002
|
}
|
|
5108
5003
|
}
|
|
5109
5004
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
5110
|
-
_optionalChain([win, 'optionalAccess',
|
|
5005
|
+
_optionalChain([win, 'optionalAccess', _97 => _97.addEventListener, 'call', _98 => _98("beforeunload", handleBeforeUnload, { once: true })]);
|
|
5111
5006
|
return Object.defineProperty(
|
|
5112
5007
|
{
|
|
5113
5008
|
[kInternal]: {
|
|
@@ -5126,7 +5021,7 @@ function createAi(config) {
|
|
|
5126
5021
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
5127
5022
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
5128
5023
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
5129
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
5024
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _99 => _99.knowledge]) || [];
|
|
5130
5025
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
5131
5026
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
5132
5027
|
messagesStore.markMine(targetMessageId);
|
|
@@ -5136,9 +5031,9 @@ function createAi(config) {
|
|
|
5136
5031
|
sourceMessage: userMessage,
|
|
5137
5032
|
targetMessageId,
|
|
5138
5033
|
generationOptions: {
|
|
5139
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
5140
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
5141
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
5034
|
+
copilotId: _optionalChain([options, 'optionalAccess', _100 => _100.copilotId]),
|
|
5035
|
+
stream: _optionalChain([options, 'optionalAccess', _101 => _101.stream]),
|
|
5036
|
+
timeout: _optionalChain([options, 'optionalAccess', _102 => _102.timeout]),
|
|
5142
5037
|
// Combine global knowledge with request-specific knowledge
|
|
5143
5038
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
5144
5039
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -5210,7 +5105,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
5210
5105
|
}
|
|
5211
5106
|
}
|
|
5212
5107
|
function closePart(prevPart, endedAt) {
|
|
5213
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
5108
|
+
if (_optionalChain([prevPart, 'optionalAccess', _103 => _103.type]) === "reasoning") {
|
|
5214
5109
|
prevPart.endedAt ??= endedAt;
|
|
5215
5110
|
}
|
|
5216
5111
|
}
|
|
@@ -5225,7 +5120,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5225
5120
|
const lastPart = parts[parts.length - 1];
|
|
5226
5121
|
switch (delta.type) {
|
|
5227
5122
|
case "text-delta":
|
|
5228
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5123
|
+
if (_optionalChain([lastPart, 'optionalAccess', _104 => _104.type]) === "text") {
|
|
5229
5124
|
lastPart.text += delta.textDelta;
|
|
5230
5125
|
} else {
|
|
5231
5126
|
closePart(lastPart, now2);
|
|
@@ -5233,7 +5128,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
5233
5128
|
}
|
|
5234
5129
|
break;
|
|
5235
5130
|
case "reasoning-delta":
|
|
5236
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5131
|
+
if (_optionalChain([lastPart, 'optionalAccess', _105 => _105.type]) === "reasoning") {
|
|
5237
5132
|
lastPart.text += delta.textDelta;
|
|
5238
5133
|
} else {
|
|
5239
5134
|
closePart(lastPart, now2);
|
|
@@ -5253,8 +5148,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
5253
5148
|
break;
|
|
5254
5149
|
}
|
|
5255
5150
|
case "tool-delta": {
|
|
5256
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
5257
|
-
_optionalChain([lastPart, 'access',
|
|
5151
|
+
if (_optionalChain([lastPart, 'optionalAccess', _106 => _106.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
5152
|
+
_optionalChain([lastPart, 'access', _107 => _107.__appendDelta, 'optionalCall', _108 => _108(delta.delta)]);
|
|
5258
5153
|
}
|
|
5259
5154
|
break;
|
|
5260
5155
|
}
|
|
@@ -5609,7 +5504,7 @@ function explicitAccessForResource(source, resource) {
|
|
|
5609
5504
|
}
|
|
5610
5505
|
function permissionForAccessLevel(resource, access, field = resource) {
|
|
5611
5506
|
const permissions = PERMISSIONS_BY_RESOURCE[resource][access];
|
|
5612
|
-
const permission = _optionalChain([permissions, 'optionalAccess',
|
|
5507
|
+
const permission = _optionalChain([permissions, 'optionalAccess', _109 => _109[0]]);
|
|
5613
5508
|
if (permission !== void 0) {
|
|
5614
5509
|
return permission;
|
|
5615
5510
|
}
|
|
@@ -5719,7 +5614,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5719
5614
|
return void 0;
|
|
5720
5615
|
}
|
|
5721
5616
|
async function makeAuthRequest(options) {
|
|
5722
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
5617
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _110 => _110.polyfills, 'optionalAccess', _111 => _111.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
5723
5618
|
if (authentication.type === "private") {
|
|
5724
5619
|
if (fetcher === void 0) {
|
|
5725
5620
|
throw new StopRetrying(
|
|
@@ -5732,14 +5627,14 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5732
5627
|
const parsed = parseAuthToken(response.token);
|
|
5733
5628
|
if (seenTokens.has(parsed.raw)) {
|
|
5734
5629
|
const cachedToken = getCachedToken(options);
|
|
5735
|
-
if (_optionalChain([cachedToken, 'optionalAccess',
|
|
5630
|
+
if (_optionalChain([cachedToken, 'optionalAccess', _112 => _112.raw]) === parsed.raw) {
|
|
5736
5631
|
return cachedToken;
|
|
5737
5632
|
}
|
|
5738
5633
|
throw new StopRetrying(
|
|
5739
5634
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
5740
5635
|
);
|
|
5741
5636
|
}
|
|
5742
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5637
|
+
_optionalChain([onAuthenticate, 'optionalCall', _113 => _113(parsed.parsed)]);
|
|
5743
5638
|
return parsed;
|
|
5744
5639
|
}
|
|
5745
5640
|
if (authentication.type === "custom") {
|
|
@@ -5747,7 +5642,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
5747
5642
|
if (response && typeof response === "object") {
|
|
5748
5643
|
if (typeof response.token === "string") {
|
|
5749
5644
|
const parsed = parseAuthToken(response.token);
|
|
5750
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5645
|
+
_optionalChain([onAuthenticate, 'optionalCall', _114 => _114(parsed.parsed)]);
|
|
5751
5646
|
return parsed;
|
|
5752
5647
|
} else if (typeof response.error === "string") {
|
|
5753
5648
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5942,15 +5837,13 @@ var OpCode = Object.freeze({
|
|
|
5942
5837
|
DELETE_CRDT: 5,
|
|
5943
5838
|
DELETE_OBJECT_KEY: 6,
|
|
5944
5839
|
CREATE_MAP: 7,
|
|
5945
|
-
CREATE_REGISTER: 8
|
|
5946
|
-
// 9 and 10 are reserved for the parallel LiveText work.
|
|
5947
|
-
CREATE_FILE: 11
|
|
5840
|
+
CREATE_REGISTER: 8
|
|
5948
5841
|
});
|
|
5949
5842
|
function isIgnoredOp(op) {
|
|
5950
5843
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5951
5844
|
}
|
|
5952
5845
|
function isCreateOp(op) {
|
|
5953
|
-
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.
|
|
5846
|
+
return op.type === OpCode.CREATE_OBJECT || op.type === OpCode.CREATE_REGISTER || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_LIST;
|
|
5954
5847
|
}
|
|
5955
5848
|
|
|
5956
5849
|
// src/protocol/StorageNode.ts
|
|
@@ -5958,9 +5851,7 @@ var CrdtType = Object.freeze({
|
|
|
5958
5851
|
OBJECT: 0,
|
|
5959
5852
|
LIST: 1,
|
|
5960
5853
|
MAP: 2,
|
|
5961
|
-
REGISTER: 3
|
|
5962
|
-
// 4 is reserved for the parallel LiveText work.
|
|
5963
|
-
FILE: 5
|
|
5854
|
+
REGISTER: 3
|
|
5964
5855
|
});
|
|
5965
5856
|
function isRootStorageNode(node) {
|
|
5966
5857
|
return node[0] === "root";
|
|
@@ -5977,9 +5868,6 @@ function isMapStorageNode(node) {
|
|
|
5977
5868
|
function isRegisterStorageNode(node) {
|
|
5978
5869
|
return node[1].type === CrdtType.REGISTER;
|
|
5979
5870
|
}
|
|
5980
|
-
function isFileStorageNode(node) {
|
|
5981
|
-
return node[1].type === CrdtType.FILE;
|
|
5982
|
-
}
|
|
5983
5871
|
function isCompactRootNode(node) {
|
|
5984
5872
|
return node[0] === "root";
|
|
5985
5873
|
}
|
|
@@ -6002,9 +5890,6 @@ function* compactNodesToNodeStream(compactNodes) {
|
|
|
6002
5890
|
case CrdtType.REGISTER:
|
|
6003
5891
|
yield [cnode[0], { type: CrdtType.REGISTER, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6004
5892
|
break;
|
|
6005
|
-
case CrdtType.FILE:
|
|
6006
|
-
yield [cnode[0], { type: CrdtType.FILE, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6007
|
-
break;
|
|
6008
5893
|
default:
|
|
6009
5894
|
}
|
|
6010
5895
|
}
|
|
@@ -6033,10 +5918,6 @@ function* nodeStreamToCompactNodes(nodes) {
|
|
|
6033
5918
|
const id = node[0];
|
|
6034
5919
|
const crdt = node[1];
|
|
6035
5920
|
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
5921
|
} else {
|
|
6041
5922
|
}
|
|
6042
5923
|
}
|
|
@@ -6275,12 +6156,12 @@ ${parentKey}`;
|
|
|
6275
6156
|
if (isCreateOp(op)) {
|
|
6276
6157
|
const posKey = this.#posKey(op.parentId, op.parentKey);
|
|
6277
6158
|
const atPosition = this.#createOpsByPosition.get(posKey);
|
|
6278
|
-
_optionalChain([atPosition, 'optionalAccess',
|
|
6159
|
+
_optionalChain([atPosition, 'optionalAccess', _115 => _115.delete, 'call', _116 => _116(opId)]);
|
|
6279
6160
|
if (atPosition !== void 0 && atPosition.size === 0) {
|
|
6280
6161
|
this.#createOpsByPosition.delete(posKey);
|
|
6281
6162
|
}
|
|
6282
6163
|
const inParent = this.#createOpsByParent.get(op.parentId);
|
|
6283
|
-
_optionalChain([inParent, 'optionalAccess',
|
|
6164
|
+
_optionalChain([inParent, 'optionalAccess', _117 => _117.delete, 'call', _118 => _118(opId)]);
|
|
6284
6165
|
if (inParent !== void 0 && inParent.size === 0) {
|
|
6285
6166
|
this.#createOpsByParent.delete(op.parentId);
|
|
6286
6167
|
}
|
|
@@ -6292,14 +6173,14 @@ ${parentKey}`;
|
|
|
6292
6173
|
* Empty if none.
|
|
6293
6174
|
*/
|
|
6294
6175
|
getByParentIdAndKey(parentId, parentKey) {
|
|
6295
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6176
|
+
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
6177
|
}
|
|
6297
6178
|
/**
|
|
6298
6179
|
* The still-unacknowledged Create ops with the given `parentId` (across all
|
|
6299
6180
|
* positions), in dispatch order. O(1) lookup. Empty if none.
|
|
6300
6181
|
*/
|
|
6301
6182
|
getByParentId(parentId) {
|
|
6302
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
6183
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _124 => _124.#createOpsByParent, 'access', _125 => _125.get, 'call', _126 => _126(parentId), 'optionalAccess', _127 => _127.values, 'call', _128 => _128()]), () => ( []));
|
|
6303
6184
|
}
|
|
6304
6185
|
/** All still-unacknowledged ops, in dispatch order. */
|
|
6305
6186
|
values() {
|
|
@@ -6321,7 +6202,7 @@ ${parentKey}`;
|
|
|
6321
6202
|
};
|
|
6322
6203
|
|
|
6323
6204
|
// src/crdts/AbstractCrdt.ts
|
|
6324
|
-
function createManagedPool(
|
|
6205
|
+
function createManagedPool(options) {
|
|
6325
6206
|
const {
|
|
6326
6207
|
getCurrentConnectionId,
|
|
6327
6208
|
onDispatch,
|
|
@@ -6332,7 +6213,6 @@ function createManagedPool(roomId, options) {
|
|
|
6332
6213
|
let opClock = 0;
|
|
6333
6214
|
const nodes = /* @__PURE__ */ new Map();
|
|
6334
6215
|
return {
|
|
6335
|
-
roomId,
|
|
6336
6216
|
nodes,
|
|
6337
6217
|
getNode: (id) => nodes.get(id),
|
|
6338
6218
|
addNode: (id, node) => void nodes.set(id, node),
|
|
@@ -6340,7 +6220,7 @@ function createManagedPool(roomId, options) {
|
|
|
6340
6220
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
6341
6221
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
6342
6222
|
dispatch(ops, reverse, storageUpdates) {
|
|
6343
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
6223
|
+
_optionalChain([onDispatch, 'optionalCall', _129 => _129(ops, reverse, storageUpdates)]);
|
|
6344
6224
|
},
|
|
6345
6225
|
assertStorageIsWritable: () => {
|
|
6346
6226
|
if (!isStorageWritable()) {
|
|
@@ -6397,9 +6277,6 @@ var AbstractCrdt = class {
|
|
|
6397
6277
|
get _pool() {
|
|
6398
6278
|
return this.#pool;
|
|
6399
6279
|
}
|
|
6400
|
-
get roomId() {
|
|
6401
|
-
return this.#pool ? this.#pool.roomId : null;
|
|
6402
|
-
}
|
|
6403
6280
|
/** @internal */
|
|
6404
6281
|
get _id() {
|
|
6405
6282
|
return this.#id;
|
|
@@ -6549,91 +6426,6 @@ var AbstractCrdt = class {
|
|
|
6549
6426
|
}
|
|
6550
6427
|
};
|
|
6551
6428
|
|
|
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
6429
|
// src/crdts/LiveRegister.ts
|
|
6638
6430
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
6639
6431
|
#data;
|
|
@@ -7149,7 +6941,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7149
6941
|
#applyInsertUndoRedo(op) {
|
|
7150
6942
|
const { id, parentKey: key } = op;
|
|
7151
6943
|
const child = creationOpToLiveNode(op);
|
|
7152
|
-
if (_optionalChain([this, 'access',
|
|
6944
|
+
if (_optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.getNode, 'call', _132 => _132(id)]) !== void 0) {
|
|
7153
6945
|
return { modified: false };
|
|
7154
6946
|
}
|
|
7155
6947
|
child._attach(id, nn(this._pool));
|
|
@@ -7157,8 +6949,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7157
6949
|
const existingItemIndex = this._indexOfPosition(key);
|
|
7158
6950
|
let newKey = key;
|
|
7159
6951
|
if (existingItemIndex !== -1) {
|
|
7160
|
-
const before2 = _optionalChain([this, 'access',
|
|
7161
|
-
const after2 = _optionalChain([this, 'access',
|
|
6952
|
+
const before2 = _optionalChain([this, 'access', _133 => _133.#items, 'access', _134 => _134.at, 'call', _135 => _135(existingItemIndex), 'optionalAccess', _136 => _136._parentPos]);
|
|
6953
|
+
const after2 = _optionalChain([this, 'access', _137 => _137.#items, 'access', _138 => _138.at, 'call', _139 => _139(existingItemIndex + 1), 'optionalAccess', _140 => _140._parentPos]);
|
|
7162
6954
|
newKey = makePosition(before2, after2);
|
|
7163
6955
|
child._setParentLink(this, newKey);
|
|
7164
6956
|
}
|
|
@@ -7172,7 +6964,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7172
6964
|
#applySetUndoRedo(op) {
|
|
7173
6965
|
const { id, parentKey: key } = op;
|
|
7174
6966
|
const child = creationOpToLiveNode(op);
|
|
7175
|
-
if (_optionalChain([this, 'access',
|
|
6967
|
+
if (_optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.getNode, 'call', _143 => _143(id)]) !== void 0) {
|
|
7176
6968
|
return { modified: false };
|
|
7177
6969
|
}
|
|
7178
6970
|
const indexOfItemWithSameKey = this._indexOfPosition(key);
|
|
@@ -7293,7 +7085,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7293
7085
|
} else {
|
|
7294
7086
|
this.#updateItemPositionAt(
|
|
7295
7087
|
existingItemIndex,
|
|
7296
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
7088
|
+
makePosition(newKey, _optionalChain([this, 'access', _144 => _144.#items, 'access', _145 => _145.at, 'call', _146 => _146(existingItemIndex + 1), 'optionalAccess', _147 => _147._parentPos]))
|
|
7297
7089
|
);
|
|
7298
7090
|
const previousIndex = this.#items.findIndex((item) => item === child);
|
|
7299
7091
|
this.#updateItemPosition(child, newKey);
|
|
@@ -7320,7 +7112,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7320
7112
|
this,
|
|
7321
7113
|
makePosition(
|
|
7322
7114
|
newKey,
|
|
7323
|
-
_optionalChain([this, 'access',
|
|
7115
|
+
_optionalChain([this, 'access', _148 => _148.#items, 'access', _149 => _149.at, 'call', _150 => _150(existingItemIndex + 1), 'optionalAccess', _151 => _151._parentPos])
|
|
7324
7116
|
)
|
|
7325
7117
|
);
|
|
7326
7118
|
this.#items.reposition(existingItem);
|
|
@@ -7344,7 +7136,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7344
7136
|
existingItemIndex,
|
|
7345
7137
|
makePosition(
|
|
7346
7138
|
newKey,
|
|
7347
|
-
_optionalChain([this, 'access',
|
|
7139
|
+
_optionalChain([this, 'access', _152 => _152.#items, 'access', _153 => _153.at, 'call', _154 => _154(existingItemIndex + 1), 'optionalAccess', _155 => _155._parentPos])
|
|
7348
7140
|
)
|
|
7349
7141
|
);
|
|
7350
7142
|
}
|
|
@@ -7372,7 +7164,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7372
7164
|
if (existingItemIndex !== -1) {
|
|
7373
7165
|
actualNewKey = makePosition(
|
|
7374
7166
|
newKey,
|
|
7375
|
-
_optionalChain([this, 'access',
|
|
7167
|
+
_optionalChain([this, 'access', _156 => _156.#items, 'access', _157 => _157.at, 'call', _158 => _158(existingItemIndex + 1), 'optionalAccess', _159 => _159._parentPos])
|
|
7376
7168
|
);
|
|
7377
7169
|
}
|
|
7378
7170
|
this.#updateItemPosition(child, actualNewKey);
|
|
@@ -7446,14 +7238,14 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7446
7238
|
* instead of resolving its position against the client's stale view.
|
|
7447
7239
|
*/
|
|
7448
7240
|
#injectAt(element, index, intent) {
|
|
7449
|
-
_optionalChain([this, 'access',
|
|
7241
|
+
_optionalChain([this, 'access', _160 => _160._pool, 'optionalAccess', _161 => _161.assertStorageIsWritable, 'call', _162 => _162()]);
|
|
7450
7242
|
if (index < 0 || index > this.#items.length) {
|
|
7451
7243
|
throw new Error(
|
|
7452
7244
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
7453
7245
|
);
|
|
7454
7246
|
}
|
|
7455
|
-
const before2 = _optionalChain([this, 'access',
|
|
7456
|
-
const after2 = _optionalChain([this, 'access',
|
|
7247
|
+
const before2 = _optionalChain([this, 'access', _163 => _163.#items, 'access', _164 => _164.at, 'call', _165 => _165(index - 1), 'optionalAccess', _166 => _166._parentPos]);
|
|
7248
|
+
const after2 = _optionalChain([this, 'access', _167 => _167.#items, 'access', _168 => _168.at, 'call', _169 => _169(index), 'optionalAccess', _170 => _170._parentPos]);
|
|
7457
7249
|
const position = makePosition(before2, after2);
|
|
7458
7250
|
const value = lsonToLiveNode(element);
|
|
7459
7251
|
value._setParentLink(this, position);
|
|
@@ -7477,7 +7269,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7477
7269
|
* @param targetIndex The index where the element should be after moving.
|
|
7478
7270
|
*/
|
|
7479
7271
|
move(index, targetIndex) {
|
|
7480
|
-
_optionalChain([this, 'access',
|
|
7272
|
+
_optionalChain([this, 'access', _171 => _171._pool, 'optionalAccess', _172 => _172.assertStorageIsWritable, 'call', _173 => _173()]);
|
|
7481
7273
|
if (targetIndex < 0) {
|
|
7482
7274
|
throw new Error("targetIndex cannot be less than 0");
|
|
7483
7275
|
}
|
|
@@ -7495,11 +7287,11 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7495
7287
|
let beforePosition = null;
|
|
7496
7288
|
let afterPosition = null;
|
|
7497
7289
|
if (index < targetIndex) {
|
|
7498
|
-
afterPosition = targetIndex === this.#items.length - 1 ? void 0 : _optionalChain([this, 'access',
|
|
7290
|
+
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
7291
|
beforePosition = this.#items.at(targetIndex)._parentPos;
|
|
7500
7292
|
} else {
|
|
7501
7293
|
afterPosition = this.#items.at(targetIndex)._parentPos;
|
|
7502
|
-
beforePosition = targetIndex === 0 ? void 0 : _optionalChain([this, 'access',
|
|
7294
|
+
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
7295
|
}
|
|
7504
7296
|
const position = makePosition(beforePosition, afterPosition);
|
|
7505
7297
|
const item = this.#items.at(index);
|
|
@@ -7534,7 +7326,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7534
7326
|
* @param index The index of the element to delete
|
|
7535
7327
|
*/
|
|
7536
7328
|
delete(index) {
|
|
7537
|
-
_optionalChain([this, 'access',
|
|
7329
|
+
_optionalChain([this, 'access', _182 => _182._pool, 'optionalAccess', _183 => _183.assertStorageIsWritable, 'call', _184 => _184()]);
|
|
7538
7330
|
if (index < 0 || index >= this.#items.length) {
|
|
7539
7331
|
throw new Error(
|
|
7540
7332
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7567,7 +7359,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7567
7359
|
}
|
|
7568
7360
|
}
|
|
7569
7361
|
clear() {
|
|
7570
|
-
_optionalChain([this, 'access',
|
|
7362
|
+
_optionalChain([this, 'access', _185 => _185._pool, 'optionalAccess', _186 => _186.assertStorageIsWritable, 'call', _187 => _187()]);
|
|
7571
7363
|
if (this._pool) {
|
|
7572
7364
|
const ops = [];
|
|
7573
7365
|
const reverseOps = [];
|
|
@@ -7601,7 +7393,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7601
7393
|
}
|
|
7602
7394
|
}
|
|
7603
7395
|
set(index, item) {
|
|
7604
|
-
_optionalChain([this, 'access',
|
|
7396
|
+
_optionalChain([this, 'access', _188 => _188._pool, 'optionalAccess', _189 => _189.assertStorageIsWritable, 'call', _190 => _190()]);
|
|
7605
7397
|
if (index < 0 || index >= this.#items.length) {
|
|
7606
7398
|
throw new Error(
|
|
7607
7399
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -7760,7 +7552,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
7760
7552
|
#shiftItemPosition(index, key) {
|
|
7761
7553
|
const shiftedPosition = makePosition(
|
|
7762
7554
|
key,
|
|
7763
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
7555
|
+
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
7556
|
);
|
|
7765
7557
|
this.#updateItemPositionAt(index, shiftedPosition);
|
|
7766
7558
|
}
|
|
@@ -8009,7 +7801,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8009
7801
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
8010
7802
|
*/
|
|
8011
7803
|
set(key, value) {
|
|
8012
|
-
_optionalChain([this, 'access',
|
|
7804
|
+
_optionalChain([this, 'access', _195 => _195._pool, 'optionalAccess', _196 => _196.assertStorageIsWritable, 'call', _197 => _197()]);
|
|
8013
7805
|
const oldValue = this.#map.get(key);
|
|
8014
7806
|
if (oldValue) {
|
|
8015
7807
|
oldValue._detach();
|
|
@@ -8055,7 +7847,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
8055
7847
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
8056
7848
|
*/
|
|
8057
7849
|
delete(key) {
|
|
8058
|
-
_optionalChain([this, 'access',
|
|
7850
|
+
_optionalChain([this, 'access', _198 => _198._pool, 'optionalAccess', _199 => _199.assertStorageIsWritable, 'call', _200 => _200()]);
|
|
8059
7851
|
const item = this.#map.get(key);
|
|
8060
7852
|
if (item === void 0) {
|
|
8061
7853
|
return false;
|
|
@@ -8667,20 +8459,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8667
8459
|
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8668
8460
|
*/
|
|
8669
8461
|
setLocal(key, value) {
|
|
8670
|
-
_optionalChain([this, 'access',
|
|
8462
|
+
_optionalChain([this, 'access', _201 => _201._pool, 'optionalAccess', _202 => _202.assertStorageIsWritable, 'call', _203 => _203()]);
|
|
8671
8463
|
const deleteResult = this.#prepareDelete(key);
|
|
8672
8464
|
this.#local.set(key, value);
|
|
8673
8465
|
this.invalidate();
|
|
8674
8466
|
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',
|
|
8467
|
+
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _204 => _204[0]]), () => ( []));
|
|
8468
|
+
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _205 => _205[1]]), () => ( []));
|
|
8469
|
+
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _206 => _206[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8678
8470
|
const existing = storageUpdates.get(this._id);
|
|
8679
8471
|
storageUpdates.set(this._id, {
|
|
8680
8472
|
node: this,
|
|
8681
8473
|
type: "LiveObject",
|
|
8682
8474
|
updates: {
|
|
8683
|
-
..._optionalChain([existing, 'optionalAccess',
|
|
8475
|
+
..._optionalChain([existing, 'optionalAccess', _207 => _207.updates]),
|
|
8684
8476
|
[key]: { type: "update" }
|
|
8685
8477
|
}
|
|
8686
8478
|
});
|
|
@@ -8700,7 +8492,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8700
8492
|
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8701
8493
|
*/
|
|
8702
8494
|
#prepareDelete(key) {
|
|
8703
|
-
_optionalChain([this, 'access',
|
|
8495
|
+
_optionalChain([this, 'access', _208 => _208._pool, 'optionalAccess', _209 => _209.assertStorageIsWritable, 'call', _210 => _210()]);
|
|
8704
8496
|
const k = key;
|
|
8705
8497
|
if (this.#local.has(k) && !this.#synced.has(k)) {
|
|
8706
8498
|
const oldValue2 = this.#local.get(k);
|
|
@@ -8776,7 +8568,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8776
8568
|
const result = this.#prepareDelete(key);
|
|
8777
8569
|
if (result) {
|
|
8778
8570
|
const [ops, reverse, storageUpdates] = result;
|
|
8779
|
-
_optionalChain([this, 'access',
|
|
8571
|
+
_optionalChain([this, 'access', _211 => _211._pool, 'optionalAccess', _212 => _212.dispatch, 'call', _213 => _213(ops, reverse, storageUpdates)]);
|
|
8780
8572
|
}
|
|
8781
8573
|
}
|
|
8782
8574
|
/**
|
|
@@ -8784,7 +8576,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8784
8576
|
* @param patch The object used to overrides properties
|
|
8785
8577
|
*/
|
|
8786
8578
|
update(patch) {
|
|
8787
|
-
_optionalChain([this, 'access',
|
|
8579
|
+
_optionalChain([this, 'access', _214 => _214._pool, 'optionalAccess', _215 => _215.assertStorageIsWritable, 'call', _216 => _216()]);
|
|
8788
8580
|
if (_LiveObject.detectLargeObjects) {
|
|
8789
8581
|
const data = {};
|
|
8790
8582
|
for (const [key, value] of this.#synced) {
|
|
@@ -8990,8 +8782,6 @@ function creationOpToLiveNode(op) {
|
|
|
8990
8782
|
}
|
|
8991
8783
|
function creationOpToLson(op) {
|
|
8992
8784
|
switch (op.type) {
|
|
8993
|
-
case OpCode.CREATE_FILE:
|
|
8994
|
-
return new LiveFile(op.data);
|
|
8995
8785
|
case OpCode.CREATE_REGISTER:
|
|
8996
8786
|
return op.data;
|
|
8997
8787
|
case OpCode.CREATE_OBJECT:
|
|
@@ -9013,6 +8803,16 @@ function isSameNodeOrChildOf(node, parent) {
|
|
|
9013
8803
|
}
|
|
9014
8804
|
return false;
|
|
9015
8805
|
}
|
|
8806
|
+
function liveObjectFromNodeStream(nodes) {
|
|
8807
|
+
const pool = createManagedPool({
|
|
8808
|
+
getCurrentConnectionId: () => {
|
|
8809
|
+
throw new Error(
|
|
8810
|
+
"Cannot mutate a historic storage version: it is a read-only snapshot"
|
|
8811
|
+
);
|
|
8812
|
+
}
|
|
8813
|
+
});
|
|
8814
|
+
return LiveObject._fromItems(nodes, pool);
|
|
8815
|
+
}
|
|
9016
8816
|
function deserialize(node, parentToChildren, pool) {
|
|
9017
8817
|
if (isObjectStorageNode(node)) {
|
|
9018
8818
|
return LiveObject._deserialize(node, parentToChildren, pool);
|
|
@@ -9022,8 +8822,6 @@ function deserialize(node, parentToChildren, pool) {
|
|
|
9022
8822
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
9023
8823
|
} else if (isRegisterStorageNode(node)) {
|
|
9024
8824
|
return LiveRegister._deserialize(node, parentToChildren, pool);
|
|
9025
|
-
} else if (isFileStorageNode(node)) {
|
|
9026
|
-
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
9027
8825
|
} else {
|
|
9028
8826
|
throw new Error("Unexpected CRDT type");
|
|
9029
8827
|
}
|
|
@@ -9037,14 +8835,12 @@ function deserializeToLson(node, parentToChildren, pool) {
|
|
|
9037
8835
|
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
9038
8836
|
} else if (isRegisterStorageNode(node)) {
|
|
9039
8837
|
return node[1].data;
|
|
9040
|
-
} else if (isFileStorageNode(node)) {
|
|
9041
|
-
return LiveFile._deserialize(node, parentToChildren, pool);
|
|
9042
8838
|
} else {
|
|
9043
8839
|
throw new Error("Unexpected CRDT type");
|
|
9044
8840
|
}
|
|
9045
8841
|
}
|
|
9046
8842
|
function isLiveStructure(value) {
|
|
9047
|
-
return isLiveList(value) || isLiveMap(value) || isLiveObject(value)
|
|
8843
|
+
return isLiveList(value) || isLiveMap(value) || isLiveObject(value);
|
|
9048
8844
|
}
|
|
9049
8845
|
function isLiveNode(value) {
|
|
9050
8846
|
return isLiveStructure(value) || isLiveRegister(value);
|
|
@@ -9058,9 +8854,6 @@ function isLiveMap(value) {
|
|
|
9058
8854
|
function isLiveObject(value) {
|
|
9059
8855
|
return value instanceof LiveObject;
|
|
9060
8856
|
}
|
|
9061
|
-
function isLiveFile(value) {
|
|
9062
|
-
return value instanceof LiveFile;
|
|
9063
|
-
}
|
|
9064
8857
|
function isLiveRegister(value) {
|
|
9065
8858
|
return value instanceof LiveRegister;
|
|
9066
8859
|
}
|
|
@@ -9070,14 +8863,14 @@ function cloneLson(value) {
|
|
|
9070
8863
|
function liveNodeToLson(obj) {
|
|
9071
8864
|
if (obj instanceof LiveRegister) {
|
|
9072
8865
|
return obj.data;
|
|
9073
|
-
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject
|
|
8866
|
+
} else if (obj instanceof LiveList || obj instanceof LiveMap || obj instanceof LiveObject) {
|
|
9074
8867
|
return obj;
|
|
9075
8868
|
} else {
|
|
9076
8869
|
return assertNever(obj, "Unknown AbstractCrdt");
|
|
9077
8870
|
}
|
|
9078
8871
|
}
|
|
9079
8872
|
function lsonToLiveNode(value) {
|
|
9080
|
-
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList
|
|
8873
|
+
if (value instanceof LiveObject || value instanceof LiveMap || value instanceof LiveList) {
|
|
9081
8874
|
return value;
|
|
9082
8875
|
} else {
|
|
9083
8876
|
return new LiveRegister(value);
|
|
@@ -9094,8 +8887,6 @@ function dumpPool(pool) {
|
|
|
9094
8887
|
value = "<LiveList>";
|
|
9095
8888
|
} else if (node instanceof LiveMap) {
|
|
9096
8889
|
value = "<LiveMap>";
|
|
9097
|
-
} else if (node instanceof LiveFile) {
|
|
9098
|
-
value = stringifyOrLog(node.data);
|
|
9099
8890
|
} else {
|
|
9100
8891
|
value = "<LiveObject>";
|
|
9101
8892
|
}
|
|
@@ -9146,6 +8937,61 @@ function diffNodeMap(prev, next) {
|
|
|
9146
8937
|
ops.push({ type: OpCode.DELETE_CRDT, id });
|
|
9147
8938
|
}
|
|
9148
8939
|
});
|
|
8940
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
8941
|
+
function emitCreate(id, crdt) {
|
|
8942
|
+
if (emitted.has(id)) {
|
|
8943
|
+
return;
|
|
8944
|
+
}
|
|
8945
|
+
emitted.add(id);
|
|
8946
|
+
const parentId = crdt.parentId;
|
|
8947
|
+
if (parentId !== void 0 && !prev.has(parentId)) {
|
|
8948
|
+
const parentCrdt = next.get(parentId);
|
|
8949
|
+
if (parentCrdt !== void 0) {
|
|
8950
|
+
emitCreate(parentId, parentCrdt);
|
|
8951
|
+
}
|
|
8952
|
+
}
|
|
8953
|
+
switch (crdt.type) {
|
|
8954
|
+
case CrdtType.REGISTER:
|
|
8955
|
+
ops.push({
|
|
8956
|
+
type: OpCode.CREATE_REGISTER,
|
|
8957
|
+
id,
|
|
8958
|
+
parentId: crdt.parentId,
|
|
8959
|
+
parentKey: crdt.parentKey,
|
|
8960
|
+
data: crdt.data
|
|
8961
|
+
});
|
|
8962
|
+
break;
|
|
8963
|
+
case CrdtType.LIST:
|
|
8964
|
+
ops.push({
|
|
8965
|
+
type: OpCode.CREATE_LIST,
|
|
8966
|
+
id,
|
|
8967
|
+
parentId: crdt.parentId,
|
|
8968
|
+
parentKey: crdt.parentKey
|
|
8969
|
+
});
|
|
8970
|
+
break;
|
|
8971
|
+
case CrdtType.OBJECT:
|
|
8972
|
+
if (crdt.parentId === void 0 || crdt.parentKey === void 0) {
|
|
8973
|
+
throw new Error(
|
|
8974
|
+
"Internal error. Cannot serialize storage root into an operation"
|
|
8975
|
+
);
|
|
8976
|
+
}
|
|
8977
|
+
ops.push({
|
|
8978
|
+
type: OpCode.CREATE_OBJECT,
|
|
8979
|
+
id,
|
|
8980
|
+
parentId: crdt.parentId,
|
|
8981
|
+
parentKey: crdt.parentKey,
|
|
8982
|
+
data: crdt.data
|
|
8983
|
+
});
|
|
8984
|
+
break;
|
|
8985
|
+
case CrdtType.MAP:
|
|
8986
|
+
ops.push({
|
|
8987
|
+
type: OpCode.CREATE_MAP,
|
|
8988
|
+
id,
|
|
8989
|
+
parentId: crdt.parentId,
|
|
8990
|
+
parentKey: crdt.parentKey
|
|
8991
|
+
});
|
|
8992
|
+
break;
|
|
8993
|
+
}
|
|
8994
|
+
}
|
|
9149
8995
|
next.forEach((crdt, id) => {
|
|
9150
8996
|
const currentCrdt = prev.get(id);
|
|
9151
8997
|
if (currentCrdt) {
|
|
@@ -9182,56 +9028,7 @@ function diffNodeMap(prev, next) {
|
|
|
9182
9028
|
});
|
|
9183
9029
|
}
|
|
9184
9030
|
} else {
|
|
9185
|
-
|
|
9186
|
-
case CrdtType.REGISTER:
|
|
9187
|
-
ops.push({
|
|
9188
|
-
type: OpCode.CREATE_REGISTER,
|
|
9189
|
-
id,
|
|
9190
|
-
parentId: crdt.parentId,
|
|
9191
|
-
parentKey: crdt.parentKey,
|
|
9192
|
-
data: crdt.data
|
|
9193
|
-
});
|
|
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;
|
|
9204
|
-
case CrdtType.LIST:
|
|
9205
|
-
ops.push({
|
|
9206
|
-
type: OpCode.CREATE_LIST,
|
|
9207
|
-
id,
|
|
9208
|
-
parentId: crdt.parentId,
|
|
9209
|
-
parentKey: crdt.parentKey
|
|
9210
|
-
});
|
|
9211
|
-
break;
|
|
9212
|
-
case CrdtType.OBJECT:
|
|
9213
|
-
if (crdt.parentId === void 0 || crdt.parentKey === void 0) {
|
|
9214
|
-
throw new Error(
|
|
9215
|
-
"Internal error. Cannot serialize storage root into an operation"
|
|
9216
|
-
);
|
|
9217
|
-
}
|
|
9218
|
-
ops.push({
|
|
9219
|
-
type: OpCode.CREATE_OBJECT,
|
|
9220
|
-
id,
|
|
9221
|
-
parentId: crdt.parentId,
|
|
9222
|
-
parentKey: crdt.parentKey,
|
|
9223
|
-
data: crdt.data
|
|
9224
|
-
});
|
|
9225
|
-
break;
|
|
9226
|
-
case CrdtType.MAP:
|
|
9227
|
-
ops.push({
|
|
9228
|
-
type: OpCode.CREATE_MAP,
|
|
9229
|
-
id,
|
|
9230
|
-
parentId: crdt.parentId,
|
|
9231
|
-
parentKey: crdt.parentKey
|
|
9232
|
-
});
|
|
9233
|
-
break;
|
|
9234
|
-
}
|
|
9031
|
+
emitCreate(id, crdt);
|
|
9235
9032
|
}
|
|
9236
9033
|
});
|
|
9237
9034
|
return ops;
|
|
@@ -9291,7 +9088,7 @@ function sendToPanel(message, options) {
|
|
|
9291
9088
|
...message,
|
|
9292
9089
|
source: "liveblocks-devtools-client"
|
|
9293
9090
|
};
|
|
9294
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
9091
|
+
if (!(_optionalChain([options, 'optionalAccess', _217 => _217.force]) || _bridgeActive)) {
|
|
9295
9092
|
return;
|
|
9296
9093
|
}
|
|
9297
9094
|
window.postMessage(fullMsg, "*");
|
|
@@ -9299,7 +9096,7 @@ function sendToPanel(message, options) {
|
|
|
9299
9096
|
var eventSource = makeEventSource();
|
|
9300
9097
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
9301
9098
|
window.addEventListener("message", (event) => {
|
|
9302
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
9099
|
+
if (event.source === window && _optionalChain([event, 'access', _218 => _218.data, 'optionalAccess', _219 => _219.source]) === "liveblocks-devtools-panel") {
|
|
9303
9100
|
eventSource.notify(event.data);
|
|
9304
9101
|
} else {
|
|
9305
9102
|
}
|
|
@@ -9441,7 +9238,7 @@ function fullSync(room) {
|
|
|
9441
9238
|
msg: "room::sync::full",
|
|
9442
9239
|
roomId: room.id,
|
|
9443
9240
|
status: room.getStatus(),
|
|
9444
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
9241
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _220 => _220.toTreeNode, 'call', _221 => _221("root"), 'access', _222 => _222.payload]), () => ( null)),
|
|
9445
9242
|
me,
|
|
9446
9243
|
others
|
|
9447
9244
|
});
|
|
@@ -10098,9 +9895,6 @@ function defaultMessageFromContext(context) {
|
|
|
10098
9895
|
|
|
10099
9896
|
// src/room.ts
|
|
10100
9897
|
var FEEDS_TIMEOUT = 5e3;
|
|
10101
|
-
function getLiveFileId(file) {
|
|
10102
|
-
return typeof file === "string" ? file : file.id;
|
|
10103
|
-
}
|
|
10104
9898
|
function connectionAccessFromScopes(scopes) {
|
|
10105
9899
|
const roomPermissions = normalizeRoomPermissions(scopes);
|
|
10106
9900
|
const matrix = permissionMatrixFromScopes(roomPermissions);
|
|
@@ -10131,15 +9925,15 @@ function installBackgroundTabSpy() {
|
|
|
10131
9925
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10132
9926
|
const inBackgroundSince = { current: null };
|
|
10133
9927
|
function onVisibilityChange() {
|
|
10134
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
9928
|
+
if (_optionalChain([doc, 'optionalAccess', _223 => _223.visibilityState]) === "hidden") {
|
|
10135
9929
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
10136
9930
|
} else {
|
|
10137
9931
|
inBackgroundSince.current = null;
|
|
10138
9932
|
}
|
|
10139
9933
|
}
|
|
10140
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9934
|
+
_optionalChain([doc, 'optionalAccess', _224 => _224.addEventListener, 'call', _225 => _225("visibilitychange", onVisibilityChange)]);
|
|
10141
9935
|
const unsub = () => {
|
|
10142
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9936
|
+
_optionalChain([doc, 'optionalAccess', _226 => _226.removeEventListener, 'call', _227 => _227("visibilitychange", onVisibilityChange)]);
|
|
10143
9937
|
};
|
|
10144
9938
|
return [inBackgroundSince, unsub];
|
|
10145
9939
|
}
|
|
@@ -10163,7 +9957,7 @@ function makeNodeMapBuffer() {
|
|
|
10163
9957
|
function topLevelKeysOf(nodes) {
|
|
10164
9958
|
const keys2 = /* @__PURE__ */ new Set();
|
|
10165
9959
|
const root = nodes.get("root");
|
|
10166
|
-
for (const key in _optionalChain([root, 'optionalAccess',
|
|
9960
|
+
for (const key in _optionalChain([root, 'optionalAccess', _228 => _228.data])) {
|
|
10167
9961
|
keys2.add(key);
|
|
10168
9962
|
}
|
|
10169
9963
|
for (const node of nodes.values()) {
|
|
@@ -10222,7 +10016,7 @@ function createRoom(options, config) {
|
|
|
10222
10016
|
yjsProvider: void 0,
|
|
10223
10017
|
yjsProviderDidChange: makeEventSource(),
|
|
10224
10018
|
// Storage
|
|
10225
|
-
pool: createManagedPool(
|
|
10019
|
+
pool: createManagedPool({
|
|
10226
10020
|
getCurrentConnectionId,
|
|
10227
10021
|
onDispatch,
|
|
10228
10022
|
isStorageWritable,
|
|
@@ -10346,7 +10140,7 @@ function createRoom(options, config) {
|
|
|
10346
10140
|
}
|
|
10347
10141
|
}
|
|
10348
10142
|
function isStorageWritable() {
|
|
10349
|
-
const permissionMatrix = _optionalChain([context, 'access',
|
|
10143
|
+
const permissionMatrix = _optionalChain([context, 'access', _229 => _229.dynamicSessionInfoSig, 'access', _230 => _230.get, 'call', _231 => _231(), 'optionalAccess', _232 => _232.permissionMatrix]);
|
|
10350
10144
|
return permissionMatrix !== void 0 ? hasPermissionAccess(permissionMatrix, "storage", "write") : true;
|
|
10351
10145
|
}
|
|
10352
10146
|
const eventHub = {
|
|
@@ -10385,12 +10179,18 @@ function createRoom(options, config) {
|
|
|
10385
10179
|
signal: options2.signal
|
|
10386
10180
|
});
|
|
10387
10181
|
}
|
|
10388
|
-
async function
|
|
10389
|
-
return httpClient.
|
|
10182
|
+
async function fetchStorageHistoryVersion(versionId) {
|
|
10183
|
+
return httpClient.fetchStorageHistoryVersion({ roomId, versionId });
|
|
10184
|
+
}
|
|
10185
|
+
async function fetchYjsHistoryVersion(versionId) {
|
|
10186
|
+
return httpClient.fetchYjsHistoryVersion({ roomId, versionId });
|
|
10390
10187
|
}
|
|
10391
10188
|
async function createVersionHistorySnapshot() {
|
|
10392
10189
|
return httpClient.createVersionHistorySnapshot({ roomId });
|
|
10393
10190
|
}
|
|
10191
|
+
async function deleteHistoryVersion(versionId) {
|
|
10192
|
+
return httpClient.deleteHistoryVersion({ roomId, versionId });
|
|
10193
|
+
}
|
|
10394
10194
|
async function executeContextualPrompt(options2) {
|
|
10395
10195
|
return httpClient.executeContextualPrompt({
|
|
10396
10196
|
roomId,
|
|
@@ -10440,17 +10240,19 @@ function createRoom(options, config) {
|
|
|
10440
10240
|
self,
|
|
10441
10241
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
10442
10242
|
);
|
|
10243
|
+
function diffCurrentStorageAgainst(target) {
|
|
10244
|
+
const current = /* @__PURE__ */ new Map();
|
|
10245
|
+
for (const [id, crdt] of context.pool.nodes) {
|
|
10246
|
+
current.set(id, crdt._serialize());
|
|
10247
|
+
}
|
|
10248
|
+
return diffNodeMap(current, target);
|
|
10249
|
+
}
|
|
10443
10250
|
function createOrUpdateRootFromMessage(nodes) {
|
|
10444
10251
|
if (nodes.size === 0) {
|
|
10445
10252
|
throw new Error("Internal error: cannot load storage without items");
|
|
10446
10253
|
}
|
|
10447
10254
|
if (context.root !== void 0) {
|
|
10448
|
-
const
|
|
10449
|
-
for (const [id, crdt] of context.pool.nodes) {
|
|
10450
|
-
currentItems.set(id, crdt._serialize());
|
|
10451
|
-
}
|
|
10452
|
-
const ops = diffNodeMap(currentItems, nodes);
|
|
10453
|
-
const result = applyRemoteOps(ops);
|
|
10255
|
+
const result = applyRemoteOps(diffCurrentStorageAgainst(nodes));
|
|
10454
10256
|
notify(result.updates);
|
|
10455
10257
|
} else {
|
|
10456
10258
|
context.root = LiveObject._fromItems(
|
|
@@ -10458,7 +10260,7 @@ function createRoom(options, config) {
|
|
|
10458
10260
|
context.pool
|
|
10459
10261
|
);
|
|
10460
10262
|
}
|
|
10461
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
10263
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _233 => _233.get, 'call', _234 => _234(), 'optionalAccess', _235 => _235.canWrite]), () => ( true));
|
|
10462
10264
|
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
10463
10265
|
const root = context.root;
|
|
10464
10266
|
disableHistory(() => {
|
|
@@ -10475,6 +10277,28 @@ function createRoom(options, config) {
|
|
|
10475
10277
|
}
|
|
10476
10278
|
});
|
|
10477
10279
|
}
|
|
10280
|
+
function reconcileStorageWithNodes(nodes) {
|
|
10281
|
+
if (context.root === void 0) {
|
|
10282
|
+
throw new Error("Cannot reconcile storage before it is loaded");
|
|
10283
|
+
}
|
|
10284
|
+
const ops = diffCurrentStorageAgainst(
|
|
10285
|
+
new Map(nodes)
|
|
10286
|
+
);
|
|
10287
|
+
if (ops.length === 0) {
|
|
10288
|
+
return;
|
|
10289
|
+
}
|
|
10290
|
+
const result = applyLocalOps(ops);
|
|
10291
|
+
if (result.reverse.length > 0) {
|
|
10292
|
+
addToUndoStack(result.reverse);
|
|
10293
|
+
}
|
|
10294
|
+
context.redoStack.length = 0;
|
|
10295
|
+
for (const op of result.opsToEmit) {
|
|
10296
|
+
context.buffer.storageOperations.push(op);
|
|
10297
|
+
}
|
|
10298
|
+
notify(result.updates);
|
|
10299
|
+
onHistoryChange();
|
|
10300
|
+
flushNowOrSoon();
|
|
10301
|
+
}
|
|
10478
10302
|
function _addToRealUndoStack(frames) {
|
|
10479
10303
|
if (context.undoStack.length >= 50) {
|
|
10480
10304
|
context.undoStack.shift();
|
|
@@ -10590,7 +10414,7 @@ function createRoom(options, config) {
|
|
|
10590
10414
|
);
|
|
10591
10415
|
output.reverse.pushLeft(applyOpResult.reverse);
|
|
10592
10416
|
}
|
|
10593
|
-
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT
|
|
10417
|
+
if (op.type === OpCode.CREATE_LIST || op.type === OpCode.CREATE_MAP || op.type === OpCode.CREATE_OBJECT) {
|
|
10594
10418
|
createdNodeIds.add(op.id);
|
|
10595
10419
|
}
|
|
10596
10420
|
}
|
|
@@ -10634,7 +10458,6 @@ function createRoom(options, config) {
|
|
|
10634
10458
|
case OpCode.CREATE_OBJECT:
|
|
10635
10459
|
case OpCode.CREATE_LIST:
|
|
10636
10460
|
case OpCode.CREATE_MAP:
|
|
10637
|
-
case OpCode.CREATE_FILE:
|
|
10638
10461
|
case OpCode.CREATE_REGISTER: {
|
|
10639
10462
|
if (op.parentId === void 0) {
|
|
10640
10463
|
return { modified: false };
|
|
@@ -10645,6 +10468,10 @@ function createRoom(options, config) {
|
|
|
10645
10468
|
}
|
|
10646
10469
|
return parentNode._attachChild(op, source);
|
|
10647
10470
|
}
|
|
10471
|
+
// Unknown op codes can be received when older and newer clients are
|
|
10472
|
+
// both present in a same room. Older clients simply ignore them.
|
|
10473
|
+
default:
|
|
10474
|
+
return { modified: false };
|
|
10648
10475
|
}
|
|
10649
10476
|
}
|
|
10650
10477
|
function updatePresence(patch, options2) {
|
|
@@ -10665,7 +10492,7 @@ function createRoom(options, config) {
|
|
|
10665
10492
|
}
|
|
10666
10493
|
context.myPresence.patch(patch);
|
|
10667
10494
|
if (context.activeBatch) {
|
|
10668
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10495
|
+
if (_optionalChain([options2, 'optionalAccess', _236 => _236.addToHistory])) {
|
|
10669
10496
|
context.activeBatch.reverseOps.pushLeft({
|
|
10670
10497
|
type: "presence",
|
|
10671
10498
|
data: oldValues
|
|
@@ -10674,7 +10501,7 @@ function createRoom(options, config) {
|
|
|
10674
10501
|
context.activeBatch.updates.presence = true;
|
|
10675
10502
|
} else {
|
|
10676
10503
|
flushNowOrSoon();
|
|
10677
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
10504
|
+
if (_optionalChain([options2, 'optionalAccess', _237 => _237.addToHistory])) {
|
|
10678
10505
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
10679
10506
|
}
|
|
10680
10507
|
notify({ presence: true });
|
|
@@ -10853,11 +10680,11 @@ function createRoom(options, config) {
|
|
|
10853
10680
|
break;
|
|
10854
10681
|
}
|
|
10855
10682
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
10856
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
10683
|
+
_optionalChain([stopwatch, 'optionalAccess', _238 => _238.lap, 'call', _239 => _239()]);
|
|
10857
10684
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
10858
10685
|
break;
|
|
10859
10686
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
10860
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
10687
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _240 => _240.stop, 'call', _241 => _241()]);
|
|
10861
10688
|
if (timing) {
|
|
10862
10689
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
10863
10690
|
const rest = timing.laps.slice(1);
|
|
@@ -10992,11 +10819,11 @@ function createRoom(options, config) {
|
|
|
10992
10819
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
10993
10820
|
const pending = pendingFeedsRequests.get(requestId);
|
|
10994
10821
|
pendingFeedsRequests.delete(requestId);
|
|
10995
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10822
|
+
_optionalChain([pending, 'optionalAccess', _242 => _242.reject, 'call', _243 => _243(err)]);
|
|
10996
10823
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
10997
10824
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
10998
10825
|
pendingFeedMessagesRequests.delete(requestId);
|
|
10999
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10826
|
+
_optionalChain([pending, 'optionalAccess', _244 => _244.reject, 'call', _245 => _245(err)]);
|
|
11000
10827
|
}
|
|
11001
10828
|
eventHub.feeds.notify(message);
|
|
11002
10829
|
break;
|
|
@@ -11150,10 +10977,10 @@ function createRoom(options, config) {
|
|
|
11150
10977
|
timeoutId,
|
|
11151
10978
|
kind,
|
|
11152
10979
|
feedId,
|
|
11153
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
11154
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
10980
|
+
messageId: _optionalChain([options2, 'optionalAccess', _246 => _246.messageId]),
|
|
10981
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _247 => _247.expectedClientMessageId])
|
|
11155
10982
|
});
|
|
11156
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
10983
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _248 => _248.expectedClientMessageId]) === void 0) {
|
|
11157
10984
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
11158
10985
|
q.push(requestId);
|
|
11159
10986
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -11204,10 +11031,10 @@ function createRoom(options, config) {
|
|
|
11204
11031
|
}
|
|
11205
11032
|
if (!matched) {
|
|
11206
11033
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
11207
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
11034
|
+
const headId = _optionalChain([q, 'optionalAccess', _249 => _249[0]]);
|
|
11208
11035
|
if (headId !== void 0) {
|
|
11209
11036
|
const pending = pendingFeedMutations.get(headId);
|
|
11210
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
11037
|
+
if (_optionalChain([pending, 'optionalAccess', _250 => _250.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
11211
11038
|
settleFeedMutation(headId, "ok");
|
|
11212
11039
|
}
|
|
11213
11040
|
}
|
|
@@ -11243,7 +11070,7 @@ function createRoom(options, config) {
|
|
|
11243
11070
|
const unacknowledgedOps2 = [...context.unacknowledgedOps.values()];
|
|
11244
11071
|
createOrUpdateRootFromMessage(nodes);
|
|
11245
11072
|
applyAndSendOfflineOps(unacknowledgedOps2);
|
|
11246
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
11073
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _251 => _251()]);
|
|
11247
11074
|
notifyStorageStatus();
|
|
11248
11075
|
eventHub.storageDidLoad.notify();
|
|
11249
11076
|
}
|
|
@@ -11252,7 +11079,7 @@ function createRoom(options, config) {
|
|
|
11252
11079
|
if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
11253
11080
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
11254
11081
|
nodeMapBuffer.take();
|
|
11255
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
11082
|
+
_optionalChain([stopwatch, 'optionalAccess', _252 => _252.start, 'call', _253 => _253()]);
|
|
11256
11083
|
}
|
|
11257
11084
|
}
|
|
11258
11085
|
function startLoadingStorage() {
|
|
@@ -11306,10 +11133,10 @@ function createRoom(options, config) {
|
|
|
11306
11133
|
const message = {
|
|
11307
11134
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
11308
11135
|
requestId,
|
|
11309
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11310
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11311
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11312
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11136
|
+
cursor: _optionalChain([options2, 'optionalAccess', _254 => _254.cursor]),
|
|
11137
|
+
since: _optionalChain([options2, 'optionalAccess', _255 => _255.since]),
|
|
11138
|
+
limit: _optionalChain([options2, 'optionalAccess', _256 => _256.limit]),
|
|
11139
|
+
metadata: _optionalChain([options2, 'optionalAccess', _257 => _257.metadata])
|
|
11313
11140
|
};
|
|
11314
11141
|
context.buffer.messages.push(message);
|
|
11315
11142
|
flushNowOrSoon();
|
|
@@ -11329,9 +11156,9 @@ function createRoom(options, config) {
|
|
|
11329
11156
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
11330
11157
|
requestId,
|
|
11331
11158
|
feedId,
|
|
11332
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11333
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
11334
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
11159
|
+
cursor: _optionalChain([options2, 'optionalAccess', _258 => _258.cursor]),
|
|
11160
|
+
since: _optionalChain([options2, 'optionalAccess', _259 => _259.since]),
|
|
11161
|
+
limit: _optionalChain([options2, 'optionalAccess', _260 => _260.limit])
|
|
11335
11162
|
};
|
|
11336
11163
|
context.buffer.messages.push(message);
|
|
11337
11164
|
flushNowOrSoon();
|
|
@@ -11350,8 +11177,8 @@ function createRoom(options, config) {
|
|
|
11350
11177
|
type: ClientMsgCode.ADD_FEED,
|
|
11351
11178
|
requestId,
|
|
11352
11179
|
feedId,
|
|
11353
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
11354
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11180
|
+
metadata: _optionalChain([options2, 'optionalAccess', _261 => _261.metadata]),
|
|
11181
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _262 => _262.createdAt])
|
|
11355
11182
|
};
|
|
11356
11183
|
context.buffer.messages.push(message);
|
|
11357
11184
|
flushNowOrSoon();
|
|
@@ -11385,15 +11212,15 @@ function createRoom(options, config) {
|
|
|
11385
11212
|
function addFeedMessage(feedId, data, options2) {
|
|
11386
11213
|
const requestId = nanoid();
|
|
11387
11214
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
11388
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
11215
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _263 => _263.id])
|
|
11389
11216
|
});
|
|
11390
11217
|
const message = {
|
|
11391
11218
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
11392
11219
|
requestId,
|
|
11393
11220
|
feedId,
|
|
11394
11221
|
data,
|
|
11395
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
11396
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
11222
|
+
id: _optionalChain([options2, 'optionalAccess', _264 => _264.id]),
|
|
11223
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _265 => _265.createdAt])
|
|
11397
11224
|
};
|
|
11398
11225
|
context.buffer.messages.push(message);
|
|
11399
11226
|
flushNowOrSoon();
|
|
@@ -11410,7 +11237,7 @@ function createRoom(options, config) {
|
|
|
11410
11237
|
feedId,
|
|
11411
11238
|
messageId,
|
|
11412
11239
|
data,
|
|
11413
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
11240
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _266 => _266.updatedAt])
|
|
11414
11241
|
};
|
|
11415
11242
|
context.buffer.messages.push(message);
|
|
11416
11243
|
flushNowOrSoon();
|
|
@@ -11617,8 +11444,8 @@ function createRoom(options, config) {
|
|
|
11617
11444
|
async function getThreads(options2) {
|
|
11618
11445
|
return httpClient.getThreads({
|
|
11619
11446
|
roomId,
|
|
11620
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
11621
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
11447
|
+
query: _optionalChain([options2, 'optionalAccess', _267 => _267.query]),
|
|
11448
|
+
cursor: _optionalChain([options2, 'optionalAccess', _268 => _268.cursor])
|
|
11622
11449
|
});
|
|
11623
11450
|
}
|
|
11624
11451
|
async function getThread(threadId) {
|
|
@@ -11738,21 +11565,10 @@ function createRoom(options, config) {
|
|
|
11738
11565
|
function getAttachmentUrl(attachmentId) {
|
|
11739
11566
|
return httpClient.getAttachmentUrl({ roomId, attachmentId });
|
|
11740
11567
|
}
|
|
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
11568
|
function getSubscriptionSettings(options2) {
|
|
11753
11569
|
return httpClient.getSubscriptionSettings({
|
|
11754
11570
|
roomId,
|
|
11755
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
11571
|
+
signal: _optionalChain([options2, 'optionalAccess', _269 => _269.signal])
|
|
11756
11572
|
});
|
|
11757
11573
|
}
|
|
11758
11574
|
function updateSubscriptionSettings(settings) {
|
|
@@ -11774,7 +11590,7 @@ function createRoom(options, config) {
|
|
|
11774
11590
|
{
|
|
11775
11591
|
[kInternal]: {
|
|
11776
11592
|
get presenceBuffer() {
|
|
11777
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
11593
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _270 => _270.buffer, 'access', _271 => _271.presenceUpdates, 'optionalAccess', _272 => _272.data]), () => ( null)));
|
|
11778
11594
|
},
|
|
11779
11595
|
// prettier-ignore
|
|
11780
11596
|
get undoStack() {
|
|
@@ -11789,15 +11605,15 @@ function createRoom(options, config) {
|
|
|
11789
11605
|
return context.yjsProvider;
|
|
11790
11606
|
},
|
|
11791
11607
|
setYjsProvider(newProvider) {
|
|
11792
|
-
_optionalChain([context, 'access',
|
|
11608
|
+
_optionalChain([context, 'access', _273 => _273.yjsProvider, 'optionalAccess', _274 => _274.off, 'call', _275 => _275("status", yjsStatusDidChange)]);
|
|
11793
11609
|
context.yjsProvider = newProvider;
|
|
11794
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
11610
|
+
_optionalChain([newProvider, 'optionalAccess', _276 => _276.on, 'call', _277 => _277("status", yjsStatusDidChange)]);
|
|
11795
11611
|
context.yjsProviderDidChange.notify();
|
|
11796
11612
|
},
|
|
11797
11613
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
11798
11614
|
// send metadata when using a text editor
|
|
11799
11615
|
reportTextEditor,
|
|
11800
|
-
getPermissionMatrix: () => _optionalChain([context, 'access',
|
|
11616
|
+
getPermissionMatrix: () => _optionalChain([context, 'access', _278 => _278.dynamicSessionInfoSig, 'access', _279 => _279.get, 'call', _280 => _280(), 'optionalAccess', _281 => _281.permissionMatrix]),
|
|
11801
11617
|
// create a text mention when using a text editor
|
|
11802
11618
|
createTextMention,
|
|
11803
11619
|
// delete a text mention when using a text editor
|
|
@@ -11807,9 +11623,16 @@ function createRoom(options, config) {
|
|
|
11807
11623
|
// List versions of the document since the specified date
|
|
11808
11624
|
listHistoryVersionsSince,
|
|
11809
11625
|
// get a specific version
|
|
11810
|
-
|
|
11626
|
+
fetchStorageHistoryVersion,
|
|
11627
|
+
fetchYjsHistoryVersion,
|
|
11628
|
+
// reconstruct a storage version's nodes into a read-only LiveObject tree
|
|
11629
|
+
liveObjectFromNodeStream,
|
|
11630
|
+
// restore live storage to match a version's nodes
|
|
11631
|
+
reconcileStorageWithNodes,
|
|
11811
11632
|
// create a version
|
|
11812
11633
|
createVersionHistorySnapshot,
|
|
11634
|
+
// delete a version
|
|
11635
|
+
deleteHistoryVersion,
|
|
11813
11636
|
// execute a contextual prompt
|
|
11814
11637
|
executeContextualPrompt,
|
|
11815
11638
|
// Support for the Liveblocks browser extension
|
|
@@ -11822,8 +11645,7 @@ function createRoom(options, config) {
|
|
|
11822
11645
|
rawSend: (data) => managedSocket.send(data),
|
|
11823
11646
|
incomingMessage: (data) => handleServerMessage(new MessageEvent("message", { data }))
|
|
11824
11647
|
},
|
|
11825
|
-
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
11826
|
-
fileUrlsStore: httpClient.getOrCreateFileUrlsStore(roomId)
|
|
11648
|
+
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
11827
11649
|
},
|
|
11828
11650
|
id: roomId,
|
|
11829
11651
|
subscribe: makeClassicSubscribeFn(
|
|
@@ -11853,7 +11675,7 @@ ${dumpPool(
|
|
|
11853
11675
|
source.dispose();
|
|
11854
11676
|
}
|
|
11855
11677
|
eventHub.roomWillDestroy.notify();
|
|
11856
|
-
_optionalChain([context, 'access',
|
|
11678
|
+
_optionalChain([context, 'access', _282 => _282.yjsProvider, 'optionalAccess', _283 => _283.off, 'call', _284 => _284("status", yjsStatusDidChange)]);
|
|
11857
11679
|
syncSourceForStorage.destroy();
|
|
11858
11680
|
syncSourceForYjs.destroy();
|
|
11859
11681
|
uninstallBgTabSpy();
|
|
@@ -11921,8 +11743,6 @@ ${dumpPool(
|
|
|
11921
11743
|
prepareAttachment,
|
|
11922
11744
|
uploadAttachment,
|
|
11923
11745
|
getAttachmentUrl,
|
|
11924
|
-
uploadFile,
|
|
11925
|
-
getFileUrl,
|
|
11926
11746
|
// Notifications
|
|
11927
11747
|
getNotificationSettings: getSubscriptionSettings,
|
|
11928
11748
|
getSubscriptionSettings,
|
|
@@ -12017,7 +11837,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
12017
11837
|
}
|
|
12018
11838
|
if (isLiveNode(first)) {
|
|
12019
11839
|
const node = first;
|
|
12020
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11840
|
+
if (_optionalChain([options, 'optionalAccess', _285 => _285.isDeep])) {
|
|
12021
11841
|
const storageCallback = second;
|
|
12022
11842
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
12023
11843
|
} else {
|
|
@@ -12107,8 +11927,8 @@ function createClient(options) {
|
|
|
12107
11927
|
const authManager = createAuthManager(options, (token) => {
|
|
12108
11928
|
currentUserId.set(() => token.uid);
|
|
12109
11929
|
});
|
|
12110
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
12111
|
-
_optionalChain([globalThis, 'access',
|
|
11930
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _286 => _286.polyfills, 'optionalAccess', _287 => _287.fetch]) || /* istanbul ignore next */
|
|
11931
|
+
_optionalChain([globalThis, 'access', _288 => _288.fetch, 'optionalAccess', _289 => _289.bind, 'call', _290 => _290(globalThis)]);
|
|
12112
11932
|
const httpClient = createApiClient({
|
|
12113
11933
|
baseUrl,
|
|
12114
11934
|
fetchPolyfill,
|
|
@@ -12125,7 +11945,7 @@ function createClient(options) {
|
|
|
12125
11945
|
delegates: {
|
|
12126
11946
|
createSocket: makeCreateSocketDelegateForAi(
|
|
12127
11947
|
baseUrl,
|
|
12128
|
-
_optionalChain([clientOptions, 'access',
|
|
11948
|
+
_optionalChain([clientOptions, 'access', _291 => _291.polyfills, 'optionalAccess', _292 => _292.WebSocket])
|
|
12129
11949
|
),
|
|
12130
11950
|
authenticate: async () => {
|
|
12131
11951
|
const resp = await authManager.getAuthValue({
|
|
@@ -12196,7 +12016,7 @@ function createClient(options) {
|
|
|
12196
12016
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
12197
12017
|
roomId,
|
|
12198
12018
|
baseUrl,
|
|
12199
|
-
_optionalChain([clientOptions, 'access',
|
|
12019
|
+
_optionalChain([clientOptions, 'access', _293 => _293.polyfills, 'optionalAccess', _294 => _294.WebSocket])
|
|
12200
12020
|
),
|
|
12201
12021
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
12202
12022
|
})),
|
|
@@ -12218,7 +12038,7 @@ function createClient(options) {
|
|
|
12218
12038
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
12219
12039
|
if (shouldConnect) {
|
|
12220
12040
|
if (typeof atob === "undefined") {
|
|
12221
|
-
if (_optionalChain([clientOptions, 'access',
|
|
12041
|
+
if (_optionalChain([clientOptions, 'access', _295 => _295.polyfills, 'optionalAccess', _296 => _296.atob]) === void 0) {
|
|
12222
12042
|
throw new Error(
|
|
12223
12043
|
"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
12044
|
);
|
|
@@ -12230,7 +12050,7 @@ function createClient(options) {
|
|
|
12230
12050
|
return leaseRoom(newRoomDetails);
|
|
12231
12051
|
}
|
|
12232
12052
|
function getRoom(roomId) {
|
|
12233
|
-
const room = _optionalChain([roomsById, 'access',
|
|
12053
|
+
const room = _optionalChain([roomsById, 'access', _297 => _297.get, 'call', _298 => _298(roomId), 'optionalAccess', _299 => _299.room]);
|
|
12234
12054
|
return room ? room : null;
|
|
12235
12055
|
}
|
|
12236
12056
|
function logout() {
|
|
@@ -12246,7 +12066,7 @@ function createClient(options) {
|
|
|
12246
12066
|
const batchedResolveUsers = new Batch(
|
|
12247
12067
|
async (batchedUserIds) => {
|
|
12248
12068
|
const userIds = batchedUserIds.flat();
|
|
12249
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
12069
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _300 => _300({ userIds })]);
|
|
12250
12070
|
warnOnceIf(
|
|
12251
12071
|
!resolveUsers,
|
|
12252
12072
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -12263,7 +12083,7 @@ function createClient(options) {
|
|
|
12263
12083
|
const batchedResolveRoomsInfo = new Batch(
|
|
12264
12084
|
async (batchedRoomIds) => {
|
|
12265
12085
|
const roomIds = batchedRoomIds.flat();
|
|
12266
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
12086
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _301 => _301({ roomIds })]);
|
|
12267
12087
|
warnOnceIf(
|
|
12268
12088
|
!resolveRoomsInfo,
|
|
12269
12089
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -12280,7 +12100,7 @@ function createClient(options) {
|
|
|
12280
12100
|
const batchedResolveGroupsInfo = new Batch(
|
|
12281
12101
|
async (batchedGroupIds) => {
|
|
12282
12102
|
const groupIds = batchedGroupIds.flat();
|
|
12283
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
12103
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _302 => _302({ groupIds })]);
|
|
12284
12104
|
warnOnceIf(
|
|
12285
12105
|
!resolveGroupsInfo,
|
|
12286
12106
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -12339,7 +12159,7 @@ function createClient(options) {
|
|
|
12339
12159
|
}
|
|
12340
12160
|
};
|
|
12341
12161
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12342
|
-
_optionalChain([win, 'optionalAccess',
|
|
12162
|
+
_optionalChain([win, 'optionalAccess', _303 => _303.addEventListener, 'call', _304 => _304("beforeunload", maybePreventClose)]);
|
|
12343
12163
|
}
|
|
12344
12164
|
async function getNotificationSettings(options2) {
|
|
12345
12165
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -12467,7 +12287,7 @@ var commentBodyElementsTypes = {
|
|
|
12467
12287
|
mention: "inline"
|
|
12468
12288
|
};
|
|
12469
12289
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
12470
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
12290
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _305 => _305.content])) {
|
|
12471
12291
|
return;
|
|
12472
12292
|
}
|
|
12473
12293
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -12477,13 +12297,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
12477
12297
|
for (const block of body.content) {
|
|
12478
12298
|
if (type === "all" || type === "block") {
|
|
12479
12299
|
if (guard(block)) {
|
|
12480
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12300
|
+
_optionalChain([visitor, 'optionalCall', _306 => _306(block)]);
|
|
12481
12301
|
}
|
|
12482
12302
|
}
|
|
12483
12303
|
if (type === "all" || type === "inline") {
|
|
12484
12304
|
for (const inline of block.children) {
|
|
12485
12305
|
if (guard(inline)) {
|
|
12486
|
-
_optionalChain([visitor, 'optionalCall',
|
|
12306
|
+
_optionalChain([visitor, 'optionalCall', _307 => _307(inline)]);
|
|
12487
12307
|
}
|
|
12488
12308
|
}
|
|
12489
12309
|
}
|
|
@@ -12653,7 +12473,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
12653
12473
|
text: ({ element }) => element.text,
|
|
12654
12474
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
12655
12475
|
mention: ({ element, user, group }) => {
|
|
12656
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12476
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _308 => _308.name]), () => ( _optionalChain([group, 'optionalAccess', _309 => _309.name]))), () => ( element.id))}`;
|
|
12657
12477
|
}
|
|
12658
12478
|
};
|
|
12659
12479
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -12683,7 +12503,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
12683
12503
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
12684
12504
|
},
|
|
12685
12505
|
mention: ({ element, user, group }) => {
|
|
12686
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
12506
|
+
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
12507
|
}
|
|
12688
12508
|
};
|
|
12689
12509
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -12713,20 +12533,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
12713
12533
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
12714
12534
|
},
|
|
12715
12535
|
mention: ({ element, user, group }) => {
|
|
12716
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
12536
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _314 => _314.name]), () => ( _optionalChain([group, 'optionalAccess', _315 => _315.name]))), () => ( element.id))}`;
|
|
12717
12537
|
}
|
|
12718
12538
|
};
|
|
12719
12539
|
async function stringifyCommentBody(body, options) {
|
|
12720
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12721
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12540
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _316 => _316.format]), () => ( "plain"));
|
|
12541
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
12722
12542
|
const elements = {
|
|
12723
12543
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
12724
|
-
..._optionalChain([options, 'optionalAccess',
|
|
12544
|
+
..._optionalChain([options, 'optionalAccess', _318 => _318.elements])
|
|
12725
12545
|
};
|
|
12726
12546
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
12727
12547
|
body,
|
|
12728
|
-
_optionalChain([options, 'optionalAccess',
|
|
12729
|
-
_optionalChain([options, 'optionalAccess',
|
|
12548
|
+
_optionalChain([options, 'optionalAccess', _319 => _319.resolveUsers]),
|
|
12549
|
+
_optionalChain([options, 'optionalAccess', _320 => _320.resolveGroupsInfo])
|
|
12730
12550
|
);
|
|
12731
12551
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
12732
12552
|
switch (block.type) {
|
|
@@ -12808,11 +12628,6 @@ function toPlainLson(lson) {
|
|
|
12808
12628
|
liveblocksType: "LiveList",
|
|
12809
12629
|
data: [...lson].map((item) => toPlainLson(item))
|
|
12810
12630
|
};
|
|
12811
|
-
} else if (lson instanceof LiveFile) {
|
|
12812
|
-
return {
|
|
12813
|
-
liveblocksType: "LiveFile",
|
|
12814
|
-
data: lson.data
|
|
12815
|
-
};
|
|
12816
12631
|
} else {
|
|
12817
12632
|
return lson;
|
|
12818
12633
|
}
|
|
@@ -12866,9 +12681,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12866
12681
|
const startTime = performance.now();
|
|
12867
12682
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
12868
12683
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12869
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12684
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _321 => _321.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
12870
12685
|
const context = {
|
|
12871
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
12686
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _322 => _322.visibilityState]) !== "hidden",
|
|
12872
12687
|
lastSuccessfulPollAt: startTime,
|
|
12873
12688
|
count: 0,
|
|
12874
12689
|
backoff: 0
|
|
@@ -12949,11 +12764,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12949
12764
|
pollNowIfStale();
|
|
12950
12765
|
}
|
|
12951
12766
|
function onVisibilityChange() {
|
|
12952
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
12767
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _323 => _323.visibilityState]) !== "hidden");
|
|
12953
12768
|
}
|
|
12954
|
-
_optionalChain([doc, 'optionalAccess',
|
|
12955
|
-
_optionalChain([win, 'optionalAccess',
|
|
12956
|
-
_optionalChain([win, 'optionalAccess',
|
|
12769
|
+
_optionalChain([doc, 'optionalAccess', _324 => _324.addEventListener, 'call', _325 => _325("visibilitychange", onVisibilityChange)]);
|
|
12770
|
+
_optionalChain([win, 'optionalAccess', _326 => _326.addEventListener, 'call', _327 => _327("online", onVisibilityChange)]);
|
|
12771
|
+
_optionalChain([win, 'optionalAccess', _328 => _328.addEventListener, 'call', _329 => _329("focus", pollNowIfStale)]);
|
|
12957
12772
|
fsm.start();
|
|
12958
12773
|
return {
|
|
12959
12774
|
inc,
|
|
@@ -13098,8 +12913,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
13098
12913
|
|
|
13099
12914
|
|
|
13100
12915
|
|
|
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;
|
|
12916
|
+
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
12917
|
//# sourceMappingURL=index.cjs.map
|