@liveblocks/core 1.8.1 → 1.9.0-example1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +148 -14
- package/dist/index.d.ts +148 -14
- package/dist/index.js +456 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +407 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
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 = "1.
|
|
9
|
+
var PKG_VERSION = "1.9.0-example1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1744,6 +1744,359 @@ function errorIf(condition, message) {
|
|
|
1744
1744
|
}
|
|
1745
1745
|
}
|
|
1746
1746
|
|
|
1747
|
+
// src/comments/comment-body.ts
|
|
1748
|
+
function isCommentBodyParagraph(element) {
|
|
1749
|
+
return "type" in element && element.type === "mention";
|
|
1750
|
+
}
|
|
1751
|
+
function isCommentBodyText(element) {
|
|
1752
|
+
return "text" in element && typeof element.text === "string";
|
|
1753
|
+
}
|
|
1754
|
+
function isCommentBodyMention(element) {
|
|
1755
|
+
return "type" in element && element.type === "mention";
|
|
1756
|
+
}
|
|
1757
|
+
function isCommentBodyLink(element) {
|
|
1758
|
+
return "type" in element && element.type === "link";
|
|
1759
|
+
}
|
|
1760
|
+
var commentBodyElementsGuards = {
|
|
1761
|
+
paragraph: isCommentBodyParagraph,
|
|
1762
|
+
text: isCommentBodyText,
|
|
1763
|
+
link: isCommentBodyLink,
|
|
1764
|
+
mention: isCommentBodyMention
|
|
1765
|
+
};
|
|
1766
|
+
var commentBodyElementsTypes = {
|
|
1767
|
+
paragraph: "block",
|
|
1768
|
+
text: "inline",
|
|
1769
|
+
link: "inline",
|
|
1770
|
+
mention: "inline"
|
|
1771
|
+
};
|
|
1772
|
+
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
1773
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _44 => _44.content])) {
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
1777
|
+
const type = element ? commentBodyElementsTypes[element] : "all";
|
|
1778
|
+
const guard = element ? commentBodyElementsGuards[element] : () => true;
|
|
1779
|
+
const visitor = typeof elementOrVisitor === "function" ? elementOrVisitor : possiblyVisitor;
|
|
1780
|
+
for (const block of body.content) {
|
|
1781
|
+
if (type === "all" || type === "block") {
|
|
1782
|
+
if (guard(block)) {
|
|
1783
|
+
_optionalChain([visitor, 'optionalCall', _45 => _45(block)]);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
if (type === "all" || type === "inline") {
|
|
1787
|
+
for (const inline of block.children) {
|
|
1788
|
+
if (guard(inline)) {
|
|
1789
|
+
_optionalChain([visitor, 'optionalCall', _46 => _46(inline)]);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
function getMentionedIdsFromCommentBody(body) {
|
|
1796
|
+
const mentionedIds = /* @__PURE__ */ new Set();
|
|
1797
|
+
traverseCommentBody(
|
|
1798
|
+
body,
|
|
1799
|
+
"mention",
|
|
1800
|
+
(mention) => mentionedIds.add(mention.id)
|
|
1801
|
+
);
|
|
1802
|
+
return Array.from(mentionedIds);
|
|
1803
|
+
}
|
|
1804
|
+
async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
1805
|
+
const resolvedUsers = /* @__PURE__ */ new Map();
|
|
1806
|
+
if (!resolveUsers) {
|
|
1807
|
+
return resolvedUsers;
|
|
1808
|
+
}
|
|
1809
|
+
const userIds = getMentionedIdsFromCommentBody(body);
|
|
1810
|
+
const users = await resolveUsers({
|
|
1811
|
+
userIds
|
|
1812
|
+
});
|
|
1813
|
+
for (const [index, userId] of userIds.entries()) {
|
|
1814
|
+
const user = _optionalChain([users, 'optionalAccess', _47 => _47[index]]);
|
|
1815
|
+
if (user) {
|
|
1816
|
+
resolvedUsers.set(userId, user);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
return resolvedUsers;
|
|
1820
|
+
}
|
|
1821
|
+
var htmlEscapables = {
|
|
1822
|
+
"&": "&",
|
|
1823
|
+
"<": "<",
|
|
1824
|
+
">": ">",
|
|
1825
|
+
'"': """,
|
|
1826
|
+
"'": "'"
|
|
1827
|
+
};
|
|
1828
|
+
var htmlEscapablesRegex = new RegExp(
|
|
1829
|
+
Object.keys(htmlEscapables).map((entity) => `\\${entity}`).join("|"),
|
|
1830
|
+
"g"
|
|
1831
|
+
);
|
|
1832
|
+
function htmlSafe(value) {
|
|
1833
|
+
return new HtmlSafeString([String(value)], []);
|
|
1834
|
+
}
|
|
1835
|
+
function joinHtml(strings) {
|
|
1836
|
+
if (strings.length <= 0) {
|
|
1837
|
+
return new HtmlSafeString([""], []);
|
|
1838
|
+
}
|
|
1839
|
+
return new HtmlSafeString(
|
|
1840
|
+
["", ...Array(strings.length - 1).fill(""), ""],
|
|
1841
|
+
strings
|
|
1842
|
+
);
|
|
1843
|
+
}
|
|
1844
|
+
function escapeHtml(value) {
|
|
1845
|
+
if (value instanceof HtmlSafeString) {
|
|
1846
|
+
return value.toString();
|
|
1847
|
+
}
|
|
1848
|
+
if (Array.isArray(value)) {
|
|
1849
|
+
return joinHtml(value).toString();
|
|
1850
|
+
}
|
|
1851
|
+
return String(value).replace(
|
|
1852
|
+
htmlEscapablesRegex,
|
|
1853
|
+
(character) => htmlEscapables[character]
|
|
1854
|
+
);
|
|
1855
|
+
}
|
|
1856
|
+
var HtmlSafeString = class {
|
|
1857
|
+
constructor(strings, values) {
|
|
1858
|
+
this._strings = strings;
|
|
1859
|
+
this._values = values;
|
|
1860
|
+
}
|
|
1861
|
+
toString() {
|
|
1862
|
+
return this._strings.reduce((result, str, i) => {
|
|
1863
|
+
return result + escapeHtml(nn(this._values[i - 1])) + str;
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
function html(strings, ...values) {
|
|
1868
|
+
return new HtmlSafeString(strings, values);
|
|
1869
|
+
}
|
|
1870
|
+
var markdownEscapables = {
|
|
1871
|
+
_: "\\_",
|
|
1872
|
+
"*": "\\*",
|
|
1873
|
+
"#": "\\#",
|
|
1874
|
+
"`": "\\`",
|
|
1875
|
+
"~": "\\~",
|
|
1876
|
+
"!": "\\!",
|
|
1877
|
+
"|": "\\|",
|
|
1878
|
+
"(": "\\(",
|
|
1879
|
+
")": "\\)",
|
|
1880
|
+
"{": "\\{",
|
|
1881
|
+
"}": "\\}",
|
|
1882
|
+
"[": "\\[",
|
|
1883
|
+
"]": "\\]"
|
|
1884
|
+
};
|
|
1885
|
+
var markdownEscapablesRegex = new RegExp(
|
|
1886
|
+
Object.keys(markdownEscapables).map((entity) => `\\${entity}`).join("|"),
|
|
1887
|
+
"g"
|
|
1888
|
+
);
|
|
1889
|
+
function joinMarkdown(strings) {
|
|
1890
|
+
if (strings.length <= 0) {
|
|
1891
|
+
return new MarkdownSafeString([""], []);
|
|
1892
|
+
}
|
|
1893
|
+
return new MarkdownSafeString(
|
|
1894
|
+
["", ...Array(strings.length - 1).fill(""), ""],
|
|
1895
|
+
strings
|
|
1896
|
+
);
|
|
1897
|
+
}
|
|
1898
|
+
function escapeMarkdown(value) {
|
|
1899
|
+
if (value instanceof MarkdownSafeString) {
|
|
1900
|
+
return value.toString();
|
|
1901
|
+
}
|
|
1902
|
+
if (Array.isArray(value)) {
|
|
1903
|
+
return joinMarkdown(value).toString();
|
|
1904
|
+
}
|
|
1905
|
+
return String(value).replace(
|
|
1906
|
+
markdownEscapablesRegex,
|
|
1907
|
+
(character) => markdownEscapables[character]
|
|
1908
|
+
);
|
|
1909
|
+
}
|
|
1910
|
+
var MarkdownSafeString = class {
|
|
1911
|
+
constructor(strings, values) {
|
|
1912
|
+
this._strings = strings;
|
|
1913
|
+
this._values = values;
|
|
1914
|
+
}
|
|
1915
|
+
toString() {
|
|
1916
|
+
return this._strings.reduce((result, str, i) => {
|
|
1917
|
+
return result + escapeMarkdown(nn(this._values[i - 1])) + str;
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
function markdown(strings, ...values) {
|
|
1922
|
+
return new MarkdownSafeString(strings, values);
|
|
1923
|
+
}
|
|
1924
|
+
function toAbsoluteUrl(url) {
|
|
1925
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
1926
|
+
return url;
|
|
1927
|
+
} else if (url.startsWith("www.")) {
|
|
1928
|
+
return "https://" + url;
|
|
1929
|
+
}
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1932
|
+
var stringifyCommentBodyPlainElements = {
|
|
1933
|
+
paragraph: ({ children }) => children,
|
|
1934
|
+
text: ({ element }) => element.text,
|
|
1935
|
+
link: ({ element }) => element.url,
|
|
1936
|
+
mention: ({ element, user }) => {
|
|
1937
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _48 => _48.name]), () => ( element.id))}`;
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
var stringifyCommentBodyHtmlElements = {
|
|
1941
|
+
paragraph: ({ children }) => {
|
|
1942
|
+
return children ? html`<p>${htmlSafe(children)}</p>` : children;
|
|
1943
|
+
},
|
|
1944
|
+
text: ({ element }) => {
|
|
1945
|
+
let children = element.text;
|
|
1946
|
+
if (!children) {
|
|
1947
|
+
return children;
|
|
1948
|
+
}
|
|
1949
|
+
if (element.bold) {
|
|
1950
|
+
children = html`<strong>${children}</strong>`;
|
|
1951
|
+
}
|
|
1952
|
+
if (element.italic) {
|
|
1953
|
+
children = html`<em>${children}</em>`;
|
|
1954
|
+
}
|
|
1955
|
+
if (element.strikethrough) {
|
|
1956
|
+
children = html`<s>${children}</s>`;
|
|
1957
|
+
}
|
|
1958
|
+
if (element.code) {
|
|
1959
|
+
children = html`<code>${children}</code>`;
|
|
1960
|
+
}
|
|
1961
|
+
return children;
|
|
1962
|
+
},
|
|
1963
|
+
link: ({ element, href }) => {
|
|
1964
|
+
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.url}</a>`;
|
|
1965
|
+
},
|
|
1966
|
+
mention: ({ element, user }) => {
|
|
1967
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _49 => _49.name]), () => ( element.id))}</span>`;
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
var stringifyCommentBodyMarkdownElements = {
|
|
1971
|
+
paragraph: ({ children }) => {
|
|
1972
|
+
return children;
|
|
1973
|
+
},
|
|
1974
|
+
text: ({ element }) => {
|
|
1975
|
+
let children = element.text;
|
|
1976
|
+
if (!children) {
|
|
1977
|
+
return children;
|
|
1978
|
+
}
|
|
1979
|
+
if (element.bold) {
|
|
1980
|
+
children = markdown`**${children}**`;
|
|
1981
|
+
}
|
|
1982
|
+
if (element.italic) {
|
|
1983
|
+
children = markdown`_${children}_`;
|
|
1984
|
+
}
|
|
1985
|
+
if (element.strikethrough) {
|
|
1986
|
+
children = markdown`~~${children}~~`;
|
|
1987
|
+
}
|
|
1988
|
+
if (element.code) {
|
|
1989
|
+
children = markdown`\`${children}\``;
|
|
1990
|
+
}
|
|
1991
|
+
return children;
|
|
1992
|
+
},
|
|
1993
|
+
link: ({ element, href }) => {
|
|
1994
|
+
return markdown`[${element.url}](${href})`;
|
|
1995
|
+
},
|
|
1996
|
+
mention: ({ element, user }) => {
|
|
1997
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _50 => _50.name]), () => ( element.id))}`;
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
async function stringifyCommentBody(body, options) {
|
|
2001
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _51 => _51.format]), () => ( "plain"));
|
|
2002
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _52 => _52.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
2003
|
+
const elements = {
|
|
2004
|
+
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
2005
|
+
..._optionalChain([options, 'optionalAccess', _53 => _53.elements])
|
|
2006
|
+
};
|
|
2007
|
+
const resolvedUsers = await resolveUsersInCommentBody(
|
|
2008
|
+
body,
|
|
2009
|
+
_optionalChain([options, 'optionalAccess', _54 => _54.resolveUsers])
|
|
2010
|
+
);
|
|
2011
|
+
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
2012
|
+
switch (block.type) {
|
|
2013
|
+
case "paragraph": {
|
|
2014
|
+
const inlines = block.children.flatMap((inline, inlineIndex) => {
|
|
2015
|
+
if (isCommentBodyMention(inline)) {
|
|
2016
|
+
return inline.id ? [
|
|
2017
|
+
elements.mention(
|
|
2018
|
+
{
|
|
2019
|
+
element: inline,
|
|
2020
|
+
user: resolvedUsers.get(inline.id)
|
|
2021
|
+
},
|
|
2022
|
+
inlineIndex
|
|
2023
|
+
)
|
|
2024
|
+
] : [];
|
|
2025
|
+
}
|
|
2026
|
+
if (isCommentBodyLink(inline)) {
|
|
2027
|
+
return [
|
|
2028
|
+
elements.link(
|
|
2029
|
+
{
|
|
2030
|
+
element: inline,
|
|
2031
|
+
href: _nullishCoalesce(toAbsoluteUrl(inline.url), () => ( inline.url))
|
|
2032
|
+
},
|
|
2033
|
+
inlineIndex
|
|
2034
|
+
)
|
|
2035
|
+
];
|
|
2036
|
+
}
|
|
2037
|
+
if (isCommentBodyText(inline)) {
|
|
2038
|
+
return [elements.text({ element: inline }, inlineIndex)];
|
|
2039
|
+
}
|
|
2040
|
+
return [];
|
|
2041
|
+
});
|
|
2042
|
+
return [
|
|
2043
|
+
elements.paragraph(
|
|
2044
|
+
{ element: block, children: inlines.join("") },
|
|
2045
|
+
blockIndex
|
|
2046
|
+
)
|
|
2047
|
+
];
|
|
2048
|
+
}
|
|
2049
|
+
default:
|
|
2050
|
+
return [];
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
return blocks.join(separator);
|
|
2054
|
+
}
|
|
2055
|
+
function convertToCommentData(data) {
|
|
2056
|
+
const editedAt = data.editedAt ? new Date(data.editedAt) : void 0;
|
|
2057
|
+
const createdAt = new Date(data.createdAt);
|
|
2058
|
+
const reactions = data.reactions.map((reaction) => ({
|
|
2059
|
+
...reaction,
|
|
2060
|
+
createdAt: new Date(reaction.createdAt)
|
|
2061
|
+
}));
|
|
2062
|
+
if (data.body) {
|
|
2063
|
+
return {
|
|
2064
|
+
...data,
|
|
2065
|
+
reactions,
|
|
2066
|
+
createdAt,
|
|
2067
|
+
editedAt
|
|
2068
|
+
};
|
|
2069
|
+
} else {
|
|
2070
|
+
const deletedAt = new Date(data.deletedAt);
|
|
2071
|
+
return {
|
|
2072
|
+
...data,
|
|
2073
|
+
reactions,
|
|
2074
|
+
createdAt,
|
|
2075
|
+
editedAt,
|
|
2076
|
+
deletedAt
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
function convertToThreadData(data) {
|
|
2081
|
+
const updatedAt = data.updatedAt ? new Date(data.updatedAt) : void 0;
|
|
2082
|
+
const createdAt = new Date(data.createdAt);
|
|
2083
|
+
const comments = data.comments.map(
|
|
2084
|
+
(comment) => convertToCommentData(comment)
|
|
2085
|
+
);
|
|
2086
|
+
return {
|
|
2087
|
+
...data,
|
|
2088
|
+
createdAt,
|
|
2089
|
+
updatedAt,
|
|
2090
|
+
comments
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
function convertToCommentUserReaction(data) {
|
|
2094
|
+
return {
|
|
2095
|
+
...data,
|
|
2096
|
+
createdAt: new Date(data.createdAt)
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
|
|
1747
2100
|
// src/comments/index.ts
|
|
1748
2101
|
function getAuthBearerHeaderFromAuthValue(authValue) {
|
|
1749
2102
|
if (authValue.type === "public") {
|
|
@@ -1796,7 +2149,7 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1796
2149
|
return await fetch(url, {
|
|
1797
2150
|
...options,
|
|
1798
2151
|
headers: {
|
|
1799
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2152
|
+
..._optionalChain([options, 'optionalAccess', _55 => _55.headers]),
|
|
1800
2153
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
1801
2154
|
}
|
|
1802
2155
|
});
|
|
@@ -1805,39 +2158,43 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1805
2158
|
const response = await fetchApi(roomId, "/threads");
|
|
1806
2159
|
if (response.ok) {
|
|
1807
2160
|
const json = await response.json();
|
|
1808
|
-
return json.data;
|
|
2161
|
+
return json.data.map((thread) => convertToThreadData(thread));
|
|
1809
2162
|
} else if (response.status === 404) {
|
|
1810
2163
|
return [];
|
|
1811
2164
|
} else {
|
|
1812
2165
|
throw new Error("There was an error while getting threads.");
|
|
1813
2166
|
}
|
|
1814
2167
|
}
|
|
1815
|
-
function createThread({
|
|
2168
|
+
async function createThread({
|
|
1816
2169
|
metadata,
|
|
1817
2170
|
body,
|
|
1818
2171
|
commentId,
|
|
1819
2172
|
threadId
|
|
1820
2173
|
}) {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
id: threadId,
|
|
1828
|
-
comment: {
|
|
1829
|
-
id: commentId,
|
|
1830
|
-
body
|
|
2174
|
+
const thread = await fetchJson(
|
|
2175
|
+
"/threads",
|
|
2176
|
+
{
|
|
2177
|
+
method: "POST",
|
|
2178
|
+
headers: {
|
|
2179
|
+
"Content-Type": "application/json"
|
|
1831
2180
|
},
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
2181
|
+
body: JSON.stringify({
|
|
2182
|
+
id: threadId,
|
|
2183
|
+
comment: {
|
|
2184
|
+
id: commentId,
|
|
2185
|
+
body
|
|
2186
|
+
},
|
|
2187
|
+
metadata
|
|
2188
|
+
})
|
|
2189
|
+
}
|
|
2190
|
+
);
|
|
2191
|
+
return convertToThreadData(thread);
|
|
1835
2192
|
}
|
|
1836
|
-
function editThreadMetadata({
|
|
2193
|
+
async function editThreadMetadata({
|
|
1837
2194
|
metadata,
|
|
1838
2195
|
threadId
|
|
1839
2196
|
}) {
|
|
1840
|
-
return fetchJson(
|
|
2197
|
+
return await fetchJson(
|
|
1841
2198
|
`/threads/${encodeURIComponent(threadId)}/metadata`,
|
|
1842
2199
|
{
|
|
1843
2200
|
method: "POST",
|
|
@@ -1848,12 +2205,12 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1848
2205
|
}
|
|
1849
2206
|
);
|
|
1850
2207
|
}
|
|
1851
|
-
function createComment({
|
|
2208
|
+
async function createComment({
|
|
1852
2209
|
threadId,
|
|
1853
2210
|
commentId,
|
|
1854
2211
|
body
|
|
1855
2212
|
}) {
|
|
1856
|
-
|
|
2213
|
+
const comment = await fetchJson(
|
|
1857
2214
|
`/threads/${encodeURIComponent(threadId)}/comments`,
|
|
1858
2215
|
{
|
|
1859
2216
|
method: "POST",
|
|
@@ -1866,13 +2223,14 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1866
2223
|
})
|
|
1867
2224
|
}
|
|
1868
2225
|
);
|
|
2226
|
+
return convertToCommentData(comment);
|
|
1869
2227
|
}
|
|
1870
|
-
function editComment({
|
|
2228
|
+
async function editComment({
|
|
1871
2229
|
threadId,
|
|
1872
2230
|
commentId,
|
|
1873
2231
|
body
|
|
1874
2232
|
}) {
|
|
1875
|
-
|
|
2233
|
+
const comment = await fetchJson(
|
|
1876
2234
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
1877
2235
|
commentId
|
|
1878
2236
|
)}`,
|
|
@@ -1886,6 +2244,7 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1886
2244
|
})
|
|
1887
2245
|
}
|
|
1888
2246
|
);
|
|
2247
|
+
return convertToCommentData(comment);
|
|
1889
2248
|
}
|
|
1890
2249
|
async function deleteComment({
|
|
1891
2250
|
threadId,
|
|
@@ -1900,12 +2259,12 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1900
2259
|
}
|
|
1901
2260
|
);
|
|
1902
2261
|
}
|
|
1903
|
-
function addReaction({
|
|
2262
|
+
async function addReaction({
|
|
1904
2263
|
threadId,
|
|
1905
2264
|
commentId,
|
|
1906
2265
|
emoji
|
|
1907
2266
|
}) {
|
|
1908
|
-
|
|
2267
|
+
const reaction = await fetchJson(
|
|
1909
2268
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
1910
2269
|
commentId
|
|
1911
2270
|
)}/reactions`,
|
|
@@ -1917,13 +2276,14 @@ function createCommentsApi(roomId, getAuthValue, config) {
|
|
|
1917
2276
|
body: JSON.stringify({ emoji })
|
|
1918
2277
|
}
|
|
1919
2278
|
);
|
|
2279
|
+
return convertToCommentUserReaction(reaction);
|
|
1920
2280
|
}
|
|
1921
|
-
function removeReaction({
|
|
2281
|
+
async function removeReaction({
|
|
1922
2282
|
threadId,
|
|
1923
2283
|
commentId,
|
|
1924
2284
|
emoji
|
|
1925
2285
|
}) {
|
|
1926
|
-
|
|
2286
|
+
await fetchJson(
|
|
1927
2287
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
1928
2288
|
commentId
|
|
1929
2289
|
)}/reactions/${encodeURIComponent(emoji)}`,
|
|
@@ -2309,7 +2669,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
2309
2669
|
return [
|
|
2310
2670
|
{
|
|
2311
2671
|
type: 8 /* CREATE_REGISTER */,
|
|
2312
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2672
|
+
opId: _optionalChain([pool, 'optionalAccess', _56 => _56.generateOpId, 'call', _57 => _57()]),
|
|
2313
2673
|
id: this._id,
|
|
2314
2674
|
parentId,
|
|
2315
2675
|
parentKey,
|
|
@@ -2411,7 +2771,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2411
2771
|
const ops = [];
|
|
2412
2772
|
const op = {
|
|
2413
2773
|
id: this._id,
|
|
2414
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2774
|
+
opId: _optionalChain([pool, 'optionalAccess', _58 => _58.generateOpId, 'call', _59 => _59()]),
|
|
2415
2775
|
type: 2 /* CREATE_LIST */,
|
|
2416
2776
|
parentId,
|
|
2417
2777
|
parentKey
|
|
@@ -2688,7 +3048,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2688
3048
|
_applyInsertUndoRedo(op) {
|
|
2689
3049
|
const { id, parentKey: key } = op;
|
|
2690
3050
|
const child = creationOpToLiveNode(op);
|
|
2691
|
-
if (_optionalChain([this, 'access',
|
|
3051
|
+
if (_optionalChain([this, 'access', _60 => _60._pool, 'optionalAccess', _61 => _61.getNode, 'call', _62 => _62(id)]) !== void 0) {
|
|
2692
3052
|
return { modified: false };
|
|
2693
3053
|
}
|
|
2694
3054
|
child._attach(id, nn(this._pool));
|
|
@@ -2696,8 +3056,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2696
3056
|
const existingItemIndex = this._indexOfPosition(key);
|
|
2697
3057
|
let newKey = key;
|
|
2698
3058
|
if (existingItemIndex !== -1) {
|
|
2699
|
-
const before2 = _optionalChain([this, 'access',
|
|
2700
|
-
const after2 = _optionalChain([this, 'access',
|
|
3059
|
+
const before2 = _optionalChain([this, 'access', _63 => _63._items, 'access', _64 => _64[existingItemIndex], 'optionalAccess', _65 => _65._parentPos]);
|
|
3060
|
+
const after2 = _optionalChain([this, 'access', _66 => _66._items, 'access', _67 => _67[existingItemIndex + 1], 'optionalAccess', _68 => _68._parentPos]);
|
|
2701
3061
|
newKey = makePosition(before2, after2);
|
|
2702
3062
|
child._setParentLink(this, newKey);
|
|
2703
3063
|
}
|
|
@@ -2712,7 +3072,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2712
3072
|
_applySetUndoRedo(op) {
|
|
2713
3073
|
const { id, parentKey: key } = op;
|
|
2714
3074
|
const child = creationOpToLiveNode(op);
|
|
2715
|
-
if (_optionalChain([this, 'access',
|
|
3075
|
+
if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
|
|
2716
3076
|
return { modified: false };
|
|
2717
3077
|
}
|
|
2718
3078
|
this._unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -2834,7 +3194,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2834
3194
|
} else {
|
|
2835
3195
|
this._items[existingItemIndex]._setParentLink(
|
|
2836
3196
|
this,
|
|
2837
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3197
|
+
makePosition(newKey, _optionalChain([this, 'access', _72 => _72._items, 'access', _73 => _73[existingItemIndex + 1], 'optionalAccess', _74 => _74._parentPos]))
|
|
2838
3198
|
);
|
|
2839
3199
|
const previousIndex = this._items.indexOf(child);
|
|
2840
3200
|
child._setParentLink(this, newKey);
|
|
@@ -2860,7 +3220,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2860
3220
|
if (existingItemIndex !== -1) {
|
|
2861
3221
|
this._items[existingItemIndex]._setParentLink(
|
|
2862
3222
|
this,
|
|
2863
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3223
|
+
makePosition(newKey, _optionalChain([this, 'access', _75 => _75._items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]))
|
|
2864
3224
|
);
|
|
2865
3225
|
}
|
|
2866
3226
|
child._setParentLink(this, newKey);
|
|
@@ -2879,7 +3239,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2879
3239
|
if (existingItemIndex !== -1) {
|
|
2880
3240
|
this._items[existingItemIndex]._setParentLink(
|
|
2881
3241
|
this,
|
|
2882
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3242
|
+
makePosition(newKey, _optionalChain([this, 'access', _78 => _78._items, 'access', _79 => _79[existingItemIndex + 1], 'optionalAccess', _80 => _80._parentPos]))
|
|
2883
3243
|
);
|
|
2884
3244
|
}
|
|
2885
3245
|
child._setParentLink(this, newKey);
|
|
@@ -2907,7 +3267,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2907
3267
|
if (existingItemIndex !== -1) {
|
|
2908
3268
|
this._items[existingItemIndex]._setParentLink(
|
|
2909
3269
|
this,
|
|
2910
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3270
|
+
makePosition(newKey, _optionalChain([this, 'access', _81 => _81._items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
|
|
2911
3271
|
);
|
|
2912
3272
|
}
|
|
2913
3273
|
child._setParentLink(this, newKey);
|
|
@@ -2965,7 +3325,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2965
3325
|
* @param element The element to add to the end of the LiveList.
|
|
2966
3326
|
*/
|
|
2967
3327
|
push(element) {
|
|
2968
|
-
_optionalChain([this, 'access',
|
|
3328
|
+
_optionalChain([this, 'access', _84 => _84._pool, 'optionalAccess', _85 => _85.assertStorageIsWritable, 'call', _86 => _86()]);
|
|
2969
3329
|
return this.insert(element, this.length);
|
|
2970
3330
|
}
|
|
2971
3331
|
/**
|
|
@@ -2974,7 +3334,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2974
3334
|
* @param index The index at which you want to insert the element.
|
|
2975
3335
|
*/
|
|
2976
3336
|
insert(element, index) {
|
|
2977
|
-
_optionalChain([this, 'access',
|
|
3337
|
+
_optionalChain([this, 'access', _87 => _87._pool, 'optionalAccess', _88 => _88.assertStorageIsWritable, 'call', _89 => _89()]);
|
|
2978
3338
|
if (index < 0 || index > this._items.length) {
|
|
2979
3339
|
throw new Error(
|
|
2980
3340
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
|
|
@@ -3004,7 +3364,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3004
3364
|
* @param targetIndex The index where the element should be after moving.
|
|
3005
3365
|
*/
|
|
3006
3366
|
move(index, targetIndex) {
|
|
3007
|
-
_optionalChain([this, 'access',
|
|
3367
|
+
_optionalChain([this, 'access', _90 => _90._pool, 'optionalAccess', _91 => _91.assertStorageIsWritable, 'call', _92 => _92()]);
|
|
3008
3368
|
if (targetIndex < 0) {
|
|
3009
3369
|
throw new Error("targetIndex cannot be less than 0");
|
|
3010
3370
|
}
|
|
@@ -3062,10 +3422,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3062
3422
|
* @param index The index of the element to delete
|
|
3063
3423
|
*/
|
|
3064
3424
|
delete(index) {
|
|
3065
|
-
_optionalChain([this, 'access',
|
|
3425
|
+
_optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
|
|
3066
3426
|
if (index < 0 || index >= this._items.length) {
|
|
3067
3427
|
throw new Error(
|
|
3068
|
-
`Cannot delete list item at index "
|
|
3428
|
+
`Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
3069
3429
|
);
|
|
3070
3430
|
}
|
|
3071
3431
|
const item = this._items[index];
|
|
@@ -3095,7 +3455,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3095
3455
|
}
|
|
3096
3456
|
}
|
|
3097
3457
|
clear() {
|
|
3098
|
-
_optionalChain([this, 'access',
|
|
3458
|
+
_optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
|
|
3099
3459
|
if (this._pool) {
|
|
3100
3460
|
const ops = [];
|
|
3101
3461
|
const reverseOps = [];
|
|
@@ -3129,7 +3489,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3129
3489
|
}
|
|
3130
3490
|
}
|
|
3131
3491
|
set(index, item) {
|
|
3132
|
-
_optionalChain([this, 'access',
|
|
3492
|
+
_optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
|
|
3133
3493
|
if (index < 0 || index >= this._items.length) {
|
|
3134
3494
|
throw new Error(
|
|
3135
3495
|
`Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3277,7 +3637,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3277
3637
|
_shiftItemPosition(index, key) {
|
|
3278
3638
|
const shiftedPosition = makePosition(
|
|
3279
3639
|
key,
|
|
3280
|
-
this._items.length > index + 1 ? _optionalChain([this, 'access',
|
|
3640
|
+
this._items.length > index + 1 ? _optionalChain([this, 'access', _102 => _102._items, 'access', _103 => _103[index + 1], 'optionalAccess', _104 => _104._parentPos]) : void 0
|
|
3281
3641
|
);
|
|
3282
3642
|
this._items[index]._setParentLink(this, shiftedPosition);
|
|
3283
3643
|
}
|
|
@@ -3406,7 +3766,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3406
3766
|
const ops = [];
|
|
3407
3767
|
const op = {
|
|
3408
3768
|
id: this._id,
|
|
3409
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
3769
|
+
opId: _optionalChain([pool, 'optionalAccess', _105 => _105.generateOpId, 'call', _106 => _106()]),
|
|
3410
3770
|
type: 7 /* CREATE_MAP */,
|
|
3411
3771
|
parentId,
|
|
3412
3772
|
parentKey
|
|
@@ -3553,7 +3913,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3553
3913
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
3554
3914
|
*/
|
|
3555
3915
|
set(key, value) {
|
|
3556
|
-
_optionalChain([this, 'access',
|
|
3916
|
+
_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.assertStorageIsWritable, 'call', _109 => _109()]);
|
|
3557
3917
|
const oldValue = this._map.get(key);
|
|
3558
3918
|
if (oldValue) {
|
|
3559
3919
|
oldValue._detach();
|
|
@@ -3599,7 +3959,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3599
3959
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
3600
3960
|
*/
|
|
3601
3961
|
delete(key) {
|
|
3602
|
-
_optionalChain([this, 'access',
|
|
3962
|
+
_optionalChain([this, 'access', _110 => _110._pool, 'optionalAccess', _111 => _111.assertStorageIsWritable, 'call', _112 => _112()]);
|
|
3603
3963
|
const item = this._map.get(key);
|
|
3604
3964
|
if (item === void 0) {
|
|
3605
3965
|
return false;
|
|
@@ -3778,7 +4138,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
3778
4138
|
if (this._id === void 0) {
|
|
3779
4139
|
throw new Error("Cannot serialize item is not attached");
|
|
3780
4140
|
}
|
|
3781
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
4141
|
+
const opId = _optionalChain([pool, 'optionalAccess', _113 => _113.generateOpId, 'call', _114 => _114()]);
|
|
3782
4142
|
const ops = [];
|
|
3783
4143
|
const op = {
|
|
3784
4144
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -4056,7 +4416,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4056
4416
|
* @param value The value of the property to add
|
|
4057
4417
|
*/
|
|
4058
4418
|
set(key, value) {
|
|
4059
|
-
_optionalChain([this, 'access',
|
|
4419
|
+
_optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
|
|
4060
4420
|
this.update({ [key]: value });
|
|
4061
4421
|
}
|
|
4062
4422
|
/**
|
|
@@ -4071,7 +4431,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4071
4431
|
* @param key The key of the property to delete
|
|
4072
4432
|
*/
|
|
4073
4433
|
delete(key) {
|
|
4074
|
-
_optionalChain([this, 'access',
|
|
4434
|
+
_optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.assertStorageIsWritable, 'call', _120 => _120()]);
|
|
4075
4435
|
const keyAsString = key;
|
|
4076
4436
|
const oldValue = this._map.get(keyAsString);
|
|
4077
4437
|
if (oldValue === void 0) {
|
|
@@ -4124,7 +4484,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4124
4484
|
* @param patch The object used to overrides properties
|
|
4125
4485
|
*/
|
|
4126
4486
|
update(patch) {
|
|
4127
|
-
_optionalChain([this, 'access',
|
|
4487
|
+
_optionalChain([this, 'access', _121 => _121._pool, 'optionalAccess', _122 => _122.assertStorageIsWritable, 'call', _123 => _123()]);
|
|
4128
4488
|
if (this._pool === void 0 || this._id === void 0) {
|
|
4129
4489
|
for (const key in patch) {
|
|
4130
4490
|
const newValue = patch[key];
|
|
@@ -4768,15 +5128,15 @@ function installBackgroundTabSpy() {
|
|
|
4768
5128
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
4769
5129
|
const inBackgroundSince = { current: null };
|
|
4770
5130
|
function onVisibilityChange() {
|
|
4771
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
5131
|
+
if (_optionalChain([doc, 'optionalAccess', _124 => _124.visibilityState]) === "hidden") {
|
|
4772
5132
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
4773
5133
|
} else {
|
|
4774
5134
|
inBackgroundSince.current = null;
|
|
4775
5135
|
}
|
|
4776
5136
|
}
|
|
4777
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5137
|
+
_optionalChain([doc, 'optionalAccess', _125 => _125.addEventListener, 'call', _126 => _126("visibilitychange", onVisibilityChange)]);
|
|
4778
5138
|
const unsub = () => {
|
|
4779
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5139
|
+
_optionalChain([doc, 'optionalAccess', _127 => _127.removeEventListener, 'call', _128 => _128("visibilitychange", onVisibilityChange)]);
|
|
4780
5140
|
};
|
|
4781
5141
|
return [inBackgroundSince, unsub];
|
|
4782
5142
|
}
|
|
@@ -4965,7 +5325,7 @@ function createRoom(options, config) {
|
|
|
4965
5325
|
}
|
|
4966
5326
|
},
|
|
4967
5327
|
assertStorageIsWritable: () => {
|
|
4968
|
-
const scopes = _optionalChain([context, 'access',
|
|
5328
|
+
const scopes = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.scopes]);
|
|
4969
5329
|
if (scopes === void 0) {
|
|
4970
5330
|
return;
|
|
4971
5331
|
}
|
|
@@ -4995,12 +5355,16 @@ function createRoom(options, config) {
|
|
|
4995
5355
|
ydoc: makeEventSource(),
|
|
4996
5356
|
comments: makeEventSource()
|
|
4997
5357
|
};
|
|
4998
|
-
async function
|
|
5358
|
+
async function httpPostToRoom(endpoint, body) {
|
|
5359
|
+
if (!managedSocket.authValue) {
|
|
5360
|
+
throw new Error("Not authorized");
|
|
5361
|
+
}
|
|
5362
|
+
const authTokenOrPublicApiKey = managedSocket.authValue.type === "public" ? managedSocket.authValue.publicApiKey : managedSocket.authValue.token.raw;
|
|
4999
5363
|
const url = new URL(
|
|
5000
|
-
`/v2/c/rooms/${encodeURIComponent(roomId)}
|
|
5364
|
+
`/v2/c/rooms/${encodeURIComponent(config.roomId)}${endpoint}`,
|
|
5001
5365
|
config.baseUrl
|
|
5002
5366
|
).toString();
|
|
5003
|
-
const fetcher = _optionalChain([config, 'access',
|
|
5367
|
+
const fetcher = _optionalChain([config, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.fetch]) || /* istanbul ignore next */
|
|
5004
5368
|
fetch;
|
|
5005
5369
|
return fetcher(url, {
|
|
5006
5370
|
method: "POST",
|
|
@@ -5008,25 +5372,22 @@ function createRoom(options, config) {
|
|
|
5008
5372
|
"Content-Type": "application/json",
|
|
5009
5373
|
Authorization: `Bearer ${authTokenOrPublicApiKey}`
|
|
5010
5374
|
},
|
|
5011
|
-
body: JSON.stringify(
|
|
5375
|
+
body: JSON.stringify(body)
|
|
5012
5376
|
});
|
|
5013
5377
|
}
|
|
5014
5378
|
function sendMessages(messages) {
|
|
5015
5379
|
const serializedPayload = JSON.stringify(messages);
|
|
5016
|
-
const nonce = _optionalChain([context, 'access',
|
|
5017
|
-
if (config.unstable_fallbackToHTTP &&
|
|
5380
|
+
const nonce = _optionalChain([context, 'access', _134 => _134.dynamicSessionInfo, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.nonce]);
|
|
5381
|
+
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5018
5382
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5019
5383
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
5020
|
-
void
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
).then((resp) => {
|
|
5026
|
-
if (!resp.ok && resp.status === 403) {
|
|
5027
|
-
managedSocket.reconnect();
|
|
5384
|
+
void httpPostToRoom("/send-message", { nonce, messages }).then(
|
|
5385
|
+
(resp) => {
|
|
5386
|
+
if (!resp.ok && resp.status === 403) {
|
|
5387
|
+
managedSocket.reconnect();
|
|
5388
|
+
}
|
|
5028
5389
|
}
|
|
5029
|
-
|
|
5390
|
+
);
|
|
5030
5391
|
warn(
|
|
5031
5392
|
"Message was too large for websockets and sent over HTTP instead"
|
|
5032
5393
|
);
|
|
@@ -5278,7 +5639,7 @@ function createRoom(options, config) {
|
|
|
5278
5639
|
}
|
|
5279
5640
|
context.myPresence.patch(patch);
|
|
5280
5641
|
if (context.activeBatch) {
|
|
5281
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5642
|
+
if (_optionalChain([options2, 'optionalAccess', _137 => _137.addToHistory])) {
|
|
5282
5643
|
context.activeBatch.reverseOps.unshift({
|
|
5283
5644
|
type: "presence",
|
|
5284
5645
|
data: oldValues
|
|
@@ -5288,7 +5649,7 @@ function createRoom(options, config) {
|
|
|
5288
5649
|
} else {
|
|
5289
5650
|
flushNowOrSoon();
|
|
5290
5651
|
batchUpdates(() => {
|
|
5291
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5652
|
+
if (_optionalChain([options2, 'optionalAccess', _138 => _138.addToHistory])) {
|
|
5292
5653
|
addToUndoStack(
|
|
5293
5654
|
[{ type: "presence", data: oldValues }],
|
|
5294
5655
|
doNotBatchUpdates
|
|
@@ -5468,7 +5829,7 @@ function createRoom(options, config) {
|
|
|
5468
5829
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
5469
5830
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
5470
5831
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
5471
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
5832
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _139 => _139()]);
|
|
5472
5833
|
notifyStorageStatus();
|
|
5473
5834
|
eventHub.storageDidLoad.notify();
|
|
5474
5835
|
break;
|
|
@@ -5491,7 +5852,7 @@ function createRoom(options, config) {
|
|
|
5491
5852
|
if (process.env.NODE_ENV !== "production") {
|
|
5492
5853
|
const traces = /* @__PURE__ */ new Set();
|
|
5493
5854
|
for (const opId of message.opIds) {
|
|
5494
|
-
const trace = _optionalChain([context, 'access',
|
|
5855
|
+
const trace = _optionalChain([context, 'access', _140 => _140.opStackTraces, 'optionalAccess', _141 => _141.get, 'call', _142 => _142(opId)]);
|
|
5495
5856
|
if (trace) {
|
|
5496
5857
|
traces.add(trace);
|
|
5497
5858
|
}
|
|
@@ -5539,7 +5900,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5539
5900
|
}
|
|
5540
5901
|
const now = Date.now();
|
|
5541
5902
|
const elapsedMillis = now - context.buffer.lastFlushedAt;
|
|
5542
|
-
if (elapsedMillis
|
|
5903
|
+
if (elapsedMillis >= config.throttleDelay) {
|
|
5543
5904
|
const messagesToFlush = serializeBuffer();
|
|
5544
5905
|
if (messagesToFlush.length === 0) {
|
|
5545
5906
|
return;
|
|
@@ -5804,7 +6165,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5804
6165
|
/* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
|
|
5805
6166
|
__internal: {
|
|
5806
6167
|
get presenceBuffer() {
|
|
5807
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6168
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _143 => _143.buffer, 'access', _144 => _144.presenceUpdates, 'optionalAccess', _145 => _145.data]), () => ( null)));
|
|
5808
6169
|
},
|
|
5809
6170
|
// prettier-ignore
|
|
5810
6171
|
get undoStack() {
|
|
@@ -5946,7 +6307,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
5946
6307
|
}
|
|
5947
6308
|
if (isLiveNode(first)) {
|
|
5948
6309
|
const node = first;
|
|
5949
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6310
|
+
if (_optionalChain([options, 'optionalAccess', _146 => _146.isDeep])) {
|
|
5950
6311
|
const storageCallback = second;
|
|
5951
6312
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
5952
6313
|
} else {
|
|
@@ -6071,12 +6432,12 @@ function createClient(options) {
|
|
|
6071
6432
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
6072
6433
|
roomId,
|
|
6073
6434
|
baseUrl,
|
|
6074
|
-
_optionalChain([clientOptions, 'access',
|
|
6435
|
+
_optionalChain([clientOptions, 'access', _147 => _147.polyfills, 'optionalAccess', _148 => _148.WebSocket])
|
|
6075
6436
|
),
|
|
6076
6437
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
6077
6438
|
})),
|
|
6078
6439
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
6079
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
6440
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _149 => _149.unstable_batchedUpdates]),
|
|
6080
6441
|
baseUrl,
|
|
6081
6442
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP
|
|
6082
6443
|
}
|
|
@@ -6091,7 +6452,7 @@ function createClient(options) {
|
|
|
6091
6452
|
const shouldConnect = _nullishCoalesce(_nullishCoalesce(options2.autoConnect, () => ( options2.shouldInitiallyConnect)), () => ( true));
|
|
6092
6453
|
if (shouldConnect) {
|
|
6093
6454
|
if (typeof atob === "undefined") {
|
|
6094
|
-
if (_optionalChain([clientOptions, 'access',
|
|
6455
|
+
if (_optionalChain([clientOptions, 'access', _150 => _150.polyfills, 'optionalAccess', _151 => _151.atob]) === void 0) {
|
|
6095
6456
|
throw new Error(
|
|
6096
6457
|
"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"
|
|
6097
6458
|
);
|
|
@@ -6107,11 +6468,11 @@ function createClient(options) {
|
|
|
6107
6468
|
return room;
|
|
6108
6469
|
}
|
|
6109
6470
|
function getRoom(roomId) {
|
|
6110
|
-
const room = _optionalChain([roomsById, 'access',
|
|
6471
|
+
const room = _optionalChain([roomsById, 'access', _152 => _152.get, 'call', _153 => _153(roomId), 'optionalAccess', _154 => _154.room]);
|
|
6111
6472
|
return room ? room : null;
|
|
6112
6473
|
}
|
|
6113
6474
|
function forceLeave(roomId) {
|
|
6114
|
-
const unsubs = _nullishCoalesce(_optionalChain([roomsById, 'access',
|
|
6475
|
+
const unsubs = _nullishCoalesce(_optionalChain([roomsById, 'access', _155 => _155.get, 'call', _156 => _156(roomId), 'optionalAccess', _157 => _157.unsubs]), () => ( /* @__PURE__ */ new Set()));
|
|
6115
6476
|
for (const unsub of unsubs) {
|
|
6116
6477
|
unsub();
|
|
6117
6478
|
}
|
|
@@ -6392,12 +6753,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
6392
6753
|
}
|
|
6393
6754
|
const newState = Object.assign({}, state);
|
|
6394
6755
|
for (const key in update.updates) {
|
|
6395
|
-
if (_optionalChain([update, 'access',
|
|
6756
|
+
if (_optionalChain([update, 'access', _158 => _158.updates, 'access', _159 => _159[key], 'optionalAccess', _160 => _160.type]) === "update") {
|
|
6396
6757
|
const val = update.node.get(key);
|
|
6397
6758
|
if (val !== void 0) {
|
|
6398
6759
|
newState[key] = lsonToJson(val);
|
|
6399
6760
|
}
|
|
6400
|
-
} else if (_optionalChain([update, 'access',
|
|
6761
|
+
} else if (_optionalChain([update, 'access', _161 => _161.updates, 'access', _162 => _162[key], 'optionalAccess', _163 => _163.type]) === "delete") {
|
|
6401
6762
|
delete newState[key];
|
|
6402
6763
|
}
|
|
6403
6764
|
}
|
|
@@ -6458,12 +6819,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
6458
6819
|
}
|
|
6459
6820
|
const newState = Object.assign({}, state);
|
|
6460
6821
|
for (const key in update.updates) {
|
|
6461
|
-
if (_optionalChain([update, 'access',
|
|
6822
|
+
if (_optionalChain([update, 'access', _164 => _164.updates, 'access', _165 => _165[key], 'optionalAccess', _166 => _166.type]) === "update") {
|
|
6462
6823
|
const value = update.node.get(key);
|
|
6463
6824
|
if (value !== void 0) {
|
|
6464
6825
|
newState[key] = lsonToJson(value);
|
|
6465
6826
|
}
|
|
6466
|
-
} else if (_optionalChain([update, 'access',
|
|
6827
|
+
} else if (_optionalChain([update, 'access', _167 => _167.updates, 'access', _168 => _168[key], 'optionalAccess', _169 => _169.type]) === "delete") {
|
|
6467
6828
|
delete newState[key];
|
|
6468
6829
|
}
|
|
6469
6830
|
}
|
|
@@ -6553,7 +6914,7 @@ function createCacheItem(key, asyncFunction, options) {
|
|
|
6553
6914
|
let previousState = { isLoading: false };
|
|
6554
6915
|
const eventSource2 = makeEventSource();
|
|
6555
6916
|
function notify() {
|
|
6556
|
-
const isEqual = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
6917
|
+
const isEqual = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.isStateEqual]), () => ( isShallowEqual));
|
|
6557
6918
|
if (!isEqual(previousState, state)) {
|
|
6558
6919
|
previousState = state;
|
|
6559
6920
|
eventSource2.notify(state);
|
|
@@ -6621,7 +6982,7 @@ function createAsyncCache(asyncFunction, options) {
|
|
|
6621
6982
|
return create(key).get();
|
|
6622
6983
|
}
|
|
6623
6984
|
function getState(key) {
|
|
6624
|
-
return _optionalChain([cache, 'access',
|
|
6985
|
+
return _optionalChain([cache, 'access', _171 => _171.get, 'call', _172 => _172(key), 'optionalAccess', _173 => _173.getState, 'call', _174 => _174()]);
|
|
6625
6986
|
}
|
|
6626
6987
|
function revalidate(key) {
|
|
6627
6988
|
return create(key).revalidate();
|
|
@@ -6801,5 +7162,10 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
6801
7162
|
|
|
6802
7163
|
|
|
6803
7164
|
|
|
6804
|
-
|
|
7165
|
+
|
|
7166
|
+
|
|
7167
|
+
|
|
7168
|
+
|
|
7169
|
+
|
|
7170
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToThreadData = convertToThreadData; exports.createAsyncCache = createAsyncCache; exports.createClient = createClient; exports.createCommentsApi = createCommentsApi; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
|
|
6805
7171
|
//# sourceMappingURL=index.js.map
|