@liveblocks/core 3.21.0-rc1 → 3.21.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 +102 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -36
- package/dist/index.d.ts +18 -36
- package/dist/index.js +38 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1602,6 +1602,14 @@ type UrlMetadata = {
|
|
|
1602
1602
|
icon?: string;
|
|
1603
1603
|
};
|
|
1604
1604
|
|
|
1605
|
+
type HistoryVersion = {
|
|
1606
|
+
id: `vh_${string}`;
|
|
1607
|
+
createdAt: Date;
|
|
1608
|
+
authors: {
|
|
1609
|
+
id: string;
|
|
1610
|
+
}[];
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1605
1613
|
/**
|
|
1606
1614
|
* Represents a user connected in a room. Treated as immutable.
|
|
1607
1615
|
*/
|
|
@@ -1848,11 +1856,11 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1848
1856
|
roomId: string;
|
|
1849
1857
|
mentionId: string;
|
|
1850
1858
|
}): Promise<void>;
|
|
1851
|
-
|
|
1859
|
+
getYjsHistoryVersion({ roomId, versionId, }: {
|
|
1852
1860
|
roomId: string;
|
|
1853
1861
|
versionId: string;
|
|
1854
1862
|
}): Promise<Response>;
|
|
1855
|
-
|
|
1863
|
+
createVersionHistorySnapshot({ roomId }: {
|
|
1856
1864
|
roomId: string;
|
|
1857
1865
|
}): Promise<void>;
|
|
1858
1866
|
reportTextEditor({ roomId, type, rootKey, }: {
|
|
@@ -1860,34 +1868,18 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1860
1868
|
type: TextEditorType;
|
|
1861
1869
|
rootKey: string;
|
|
1862
1870
|
}): Promise<void>;
|
|
1863
|
-
|
|
1871
|
+
listHistoryVersions({ roomId }: {
|
|
1864
1872
|
roomId: string;
|
|
1865
1873
|
}): Promise<{
|
|
1866
|
-
versions:
|
|
1867
|
-
type: "historyVersion";
|
|
1868
|
-
kind: "yjs";
|
|
1869
|
-
id: string;
|
|
1870
|
-
authors: {
|
|
1871
|
-
id: string;
|
|
1872
|
-
}[];
|
|
1873
|
-
createdAt: Date;
|
|
1874
|
-
}[];
|
|
1874
|
+
versions: HistoryVersion[];
|
|
1875
1875
|
requestedAt: Date;
|
|
1876
1876
|
}>;
|
|
1877
|
-
|
|
1877
|
+
listHistoryVersionsSince({ roomId, since, signal, }: {
|
|
1878
1878
|
roomId: string;
|
|
1879
1879
|
since: Date;
|
|
1880
1880
|
signal?: AbortSignal;
|
|
1881
1881
|
}): Promise<{
|
|
1882
|
-
versions:
|
|
1883
|
-
type: "historyVersion";
|
|
1884
|
-
kind: "yjs";
|
|
1885
|
-
id: string;
|
|
1886
|
-
authors: {
|
|
1887
|
-
id: string;
|
|
1888
|
-
}[];
|
|
1889
|
-
createdAt: Date;
|
|
1890
|
-
}[];
|
|
1882
|
+
versions: HistoryVersion[];
|
|
1891
1883
|
requestedAt: Date;
|
|
1892
1884
|
}>;
|
|
1893
1885
|
streamStorage(options: {
|
|
@@ -3242,16 +3234,6 @@ type FeedMessagesDeletedServerMsg = {
|
|
|
3242
3234
|
readonly messageIds: readonly string[];
|
|
3243
3235
|
};
|
|
3244
3236
|
|
|
3245
|
-
type HistoryVersion = {
|
|
3246
|
-
type: "historyVersion";
|
|
3247
|
-
kind: "yjs";
|
|
3248
|
-
createdAt: Date;
|
|
3249
|
-
id: string;
|
|
3250
|
-
authors: {
|
|
3251
|
-
id: string;
|
|
3252
|
-
}[];
|
|
3253
|
-
};
|
|
3254
|
-
|
|
3255
3237
|
type JsonTreeNode = {
|
|
3256
3238
|
readonly type: "Json";
|
|
3257
3239
|
readonly id: string;
|
|
@@ -4159,16 +4141,16 @@ type PrivateRoomApi = {
|
|
|
4159
4141
|
getPermissionMatrix(): PermissionMatrix | undefined;
|
|
4160
4142
|
createTextMention(mentionId: string, mention: MentionData): Promise<void>;
|
|
4161
4143
|
deleteTextMention(mentionId: string): Promise<void>;
|
|
4162
|
-
|
|
4144
|
+
listHistoryVersions(): Promise<{
|
|
4163
4145
|
versions: HistoryVersion[];
|
|
4164
4146
|
requestedAt: Date;
|
|
4165
4147
|
}>;
|
|
4166
|
-
|
|
4148
|
+
listHistoryVersionsSince(options: ListTextVersionsSinceOptions): Promise<{
|
|
4167
4149
|
versions: HistoryVersion[];
|
|
4168
4150
|
requestedAt: Date;
|
|
4169
4151
|
}>;
|
|
4170
|
-
|
|
4171
|
-
|
|
4152
|
+
getYjsHistoryVersion(versionId: string): Promise<Response>;
|
|
4153
|
+
createVersionHistorySnapshot(): Promise<void>;
|
|
4172
4154
|
executeContextualPrompt(options: {
|
|
4173
4155
|
prompt: string;
|
|
4174
4156
|
context: ContextualPromptContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -1602,6 +1602,14 @@ type UrlMetadata = {
|
|
|
1602
1602
|
icon?: string;
|
|
1603
1603
|
};
|
|
1604
1604
|
|
|
1605
|
+
type HistoryVersion = {
|
|
1606
|
+
id: `vh_${string}`;
|
|
1607
|
+
createdAt: Date;
|
|
1608
|
+
authors: {
|
|
1609
|
+
id: string;
|
|
1610
|
+
}[];
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1605
1613
|
/**
|
|
1606
1614
|
* Represents a user connected in a room. Treated as immutable.
|
|
1607
1615
|
*/
|
|
@@ -1848,11 +1856,11 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1848
1856
|
roomId: string;
|
|
1849
1857
|
mentionId: string;
|
|
1850
1858
|
}): Promise<void>;
|
|
1851
|
-
|
|
1859
|
+
getYjsHistoryVersion({ roomId, versionId, }: {
|
|
1852
1860
|
roomId: string;
|
|
1853
1861
|
versionId: string;
|
|
1854
1862
|
}): Promise<Response>;
|
|
1855
|
-
|
|
1863
|
+
createVersionHistorySnapshot({ roomId }: {
|
|
1856
1864
|
roomId: string;
|
|
1857
1865
|
}): Promise<void>;
|
|
1858
1866
|
reportTextEditor({ roomId, type, rootKey, }: {
|
|
@@ -1860,34 +1868,18 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
|
|
|
1860
1868
|
type: TextEditorType;
|
|
1861
1869
|
rootKey: string;
|
|
1862
1870
|
}): Promise<void>;
|
|
1863
|
-
|
|
1871
|
+
listHistoryVersions({ roomId }: {
|
|
1864
1872
|
roomId: string;
|
|
1865
1873
|
}): Promise<{
|
|
1866
|
-
versions:
|
|
1867
|
-
type: "historyVersion";
|
|
1868
|
-
kind: "yjs";
|
|
1869
|
-
id: string;
|
|
1870
|
-
authors: {
|
|
1871
|
-
id: string;
|
|
1872
|
-
}[];
|
|
1873
|
-
createdAt: Date;
|
|
1874
|
-
}[];
|
|
1874
|
+
versions: HistoryVersion[];
|
|
1875
1875
|
requestedAt: Date;
|
|
1876
1876
|
}>;
|
|
1877
|
-
|
|
1877
|
+
listHistoryVersionsSince({ roomId, since, signal, }: {
|
|
1878
1878
|
roomId: string;
|
|
1879
1879
|
since: Date;
|
|
1880
1880
|
signal?: AbortSignal;
|
|
1881
1881
|
}): Promise<{
|
|
1882
|
-
versions:
|
|
1883
|
-
type: "historyVersion";
|
|
1884
|
-
kind: "yjs";
|
|
1885
|
-
id: string;
|
|
1886
|
-
authors: {
|
|
1887
|
-
id: string;
|
|
1888
|
-
}[];
|
|
1889
|
-
createdAt: Date;
|
|
1890
|
-
}[];
|
|
1882
|
+
versions: HistoryVersion[];
|
|
1891
1883
|
requestedAt: Date;
|
|
1892
1884
|
}>;
|
|
1893
1885
|
streamStorage(options: {
|
|
@@ -3242,16 +3234,6 @@ type FeedMessagesDeletedServerMsg = {
|
|
|
3242
3234
|
readonly messageIds: readonly string[];
|
|
3243
3235
|
};
|
|
3244
3236
|
|
|
3245
|
-
type HistoryVersion = {
|
|
3246
|
-
type: "historyVersion";
|
|
3247
|
-
kind: "yjs";
|
|
3248
|
-
createdAt: Date;
|
|
3249
|
-
id: string;
|
|
3250
|
-
authors: {
|
|
3251
|
-
id: string;
|
|
3252
|
-
}[];
|
|
3253
|
-
};
|
|
3254
|
-
|
|
3255
3237
|
type JsonTreeNode = {
|
|
3256
3238
|
readonly type: "Json";
|
|
3257
3239
|
readonly id: string;
|
|
@@ -4159,16 +4141,16 @@ type PrivateRoomApi = {
|
|
|
4159
4141
|
getPermissionMatrix(): PermissionMatrix | undefined;
|
|
4160
4142
|
createTextMention(mentionId: string, mention: MentionData): Promise<void>;
|
|
4161
4143
|
deleteTextMention(mentionId: string): Promise<void>;
|
|
4162
|
-
|
|
4144
|
+
listHistoryVersions(): Promise<{
|
|
4163
4145
|
versions: HistoryVersion[];
|
|
4164
4146
|
requestedAt: Date;
|
|
4165
4147
|
}>;
|
|
4166
|
-
|
|
4148
|
+
listHistoryVersionsSince(options: ListTextVersionsSinceOptions): Promise<{
|
|
4167
4149
|
versions: HistoryVersion[];
|
|
4168
4150
|
requestedAt: Date;
|
|
4169
4151
|
}>;
|
|
4170
|
-
|
|
4171
|
-
|
|
4152
|
+
getYjsHistoryVersion(versionId: string): Promise<Response>;
|
|
4153
|
+
createVersionHistorySnapshot(): Promise<void>;
|
|
4172
4154
|
executeContextualPrompt(options: {
|
|
4173
4155
|
prompt: string;
|
|
4174
4156
|
context: ContextualPromptContext;
|
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 = "3.21.0
|
|
9
|
+
var PKG_VERSION = "3.21.0";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2132,9 +2132,9 @@ function createApiClient({
|
|
|
2132
2132
|
})
|
|
2133
2133
|
);
|
|
2134
2134
|
}
|
|
2135
|
-
async function
|
|
2135
|
+
async function getYjsHistoryVersion(options) {
|
|
2136
2136
|
return httpClient.rawGet(
|
|
2137
|
-
url`/v2/c/rooms/${options.roomId}/
|
|
2137
|
+
url`/v2/c/rooms/${options.roomId}/versions/${options.versionId}/yjs`,
|
|
2138
2138
|
await authManager.getAuthValue({
|
|
2139
2139
|
roomId: options.roomId,
|
|
2140
2140
|
resource: "storage",
|
|
@@ -2142,9 +2142,9 @@ function createApiClient({
|
|
|
2142
2142
|
})
|
|
2143
2143
|
);
|
|
2144
2144
|
}
|
|
2145
|
-
async function
|
|
2145
|
+
async function createVersionHistorySnapshot(options) {
|
|
2146
2146
|
await httpClient.rawPost(
|
|
2147
|
-
url`/v2/c/rooms/${options.roomId}/
|
|
2147
|
+
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
2148
2148
|
await authManager.getAuthValue({
|
|
2149
2149
|
roomId: options.roomId,
|
|
2150
2150
|
resource: "storage",
|
|
@@ -2190,7 +2190,7 @@ function createApiClient({
|
|
|
2190
2190
|
}
|
|
2191
2191
|
return result.content[0].text;
|
|
2192
2192
|
}
|
|
2193
|
-
async function
|
|
2193
|
+
async function listHistoryVersions(options) {
|
|
2194
2194
|
const result = await httpClient.get(
|
|
2195
2195
|
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
2196
2196
|
await authManager.getAuthValue({
|
|
@@ -2209,7 +2209,7 @@ function createApiClient({
|
|
|
2209
2209
|
requestedAt: new Date(result.meta.requestedAt)
|
|
2210
2210
|
};
|
|
2211
2211
|
}
|
|
2212
|
-
async function
|
|
2212
|
+
async function listHistoryVersionsSince(options) {
|
|
2213
2213
|
const result = await httpClient.get(
|
|
2214
2214
|
url`/v2/c/rooms/${options.roomId}/versions/delta`,
|
|
2215
2215
|
await authManager.getAuthValue({
|
|
@@ -2475,11 +2475,11 @@ function createApiClient({
|
|
|
2475
2475
|
// Room text editor
|
|
2476
2476
|
createTextMention,
|
|
2477
2477
|
deleteTextMention,
|
|
2478
|
-
|
|
2479
|
-
|
|
2478
|
+
getYjsHistoryVersion,
|
|
2479
|
+
createVersionHistorySnapshot,
|
|
2480
2480
|
reportTextEditor,
|
|
2481
|
-
|
|
2482
|
-
|
|
2481
|
+
listHistoryVersions,
|
|
2482
|
+
listHistoryVersionsSince,
|
|
2483
2483
|
// Room attachments
|
|
2484
2484
|
getAttachmentUrl,
|
|
2485
2485
|
uploadAttachment,
|
|
@@ -9911,6 +9911,19 @@ function makeNodeMapBuffer() {
|
|
|
9911
9911
|
}
|
|
9912
9912
|
};
|
|
9913
9913
|
}
|
|
9914
|
+
function topLevelKeysOf(nodes) {
|
|
9915
|
+
const keys2 = /* @__PURE__ */ new Set();
|
|
9916
|
+
const root = nodes.get("root");
|
|
9917
|
+
for (const key in root?.data) {
|
|
9918
|
+
keys2.add(key);
|
|
9919
|
+
}
|
|
9920
|
+
for (const node of nodes.values()) {
|
|
9921
|
+
if (node.parentId === "root") {
|
|
9922
|
+
keys2.add(node.parentKey);
|
|
9923
|
+
}
|
|
9924
|
+
}
|
|
9925
|
+
return keys2;
|
|
9926
|
+
}
|
|
9914
9927
|
function createRoom(options, config) {
|
|
9915
9928
|
const roomId = config.roomId;
|
|
9916
9929
|
const initialPresence = options.initialPresence;
|
|
@@ -10113,21 +10126,21 @@ function createRoom(options, config) {
|
|
|
10113
10126
|
async function reportTextEditor(type, rootKey) {
|
|
10114
10127
|
await httpClient.reportTextEditor({ roomId, type, rootKey });
|
|
10115
10128
|
}
|
|
10116
|
-
async function
|
|
10117
|
-
return httpClient.
|
|
10129
|
+
async function listHistoryVersions() {
|
|
10130
|
+
return httpClient.listHistoryVersions({ roomId });
|
|
10118
10131
|
}
|
|
10119
|
-
async function
|
|
10120
|
-
return httpClient.
|
|
10132
|
+
async function listHistoryVersionsSince(options2) {
|
|
10133
|
+
return httpClient.listHistoryVersionsSince({
|
|
10121
10134
|
roomId,
|
|
10122
10135
|
since: options2.since,
|
|
10123
10136
|
signal: options2.signal
|
|
10124
10137
|
});
|
|
10125
10138
|
}
|
|
10126
|
-
async function
|
|
10127
|
-
return httpClient.
|
|
10139
|
+
async function getYjsHistoryVersion(versionId) {
|
|
10140
|
+
return httpClient.getYjsHistoryVersion({ roomId, versionId });
|
|
10128
10141
|
}
|
|
10129
|
-
async function
|
|
10130
|
-
return httpClient.
|
|
10142
|
+
async function createVersionHistorySnapshot() {
|
|
10143
|
+
return httpClient.createVersionHistorySnapshot({ roomId });
|
|
10131
10144
|
}
|
|
10132
10145
|
async function executeContextualPrompt(options2) {
|
|
10133
10146
|
return httpClient.executeContextualPrompt({
|
|
@@ -10197,10 +10210,11 @@ function createRoom(options, config) {
|
|
|
10197
10210
|
);
|
|
10198
10211
|
}
|
|
10199
10212
|
const canWrite = self.get()?.canWrite ?? true;
|
|
10213
|
+
const serverTopLevelKeys = topLevelKeysOf(nodes);
|
|
10200
10214
|
const root = context.root;
|
|
10201
10215
|
disableHistory(() => {
|
|
10202
10216
|
for (const key in context.initialStorage) {
|
|
10203
|
-
if (
|
|
10217
|
+
if (!serverTopLevelKeys.has(key)) {
|
|
10204
10218
|
if (canWrite) {
|
|
10205
10219
|
root.set(key, cloneLson(context.initialStorage[key]));
|
|
10206
10220
|
} else {
|
|
@@ -11528,13 +11542,13 @@ function createRoom(options, config) {
|
|
|
11528
11542
|
// delete a text mention when using a text editor
|
|
11529
11543
|
deleteTextMention,
|
|
11530
11544
|
// list versions of the document
|
|
11531
|
-
|
|
11545
|
+
listHistoryVersions,
|
|
11532
11546
|
// List versions of the document since the specified date
|
|
11533
|
-
|
|
11547
|
+
listHistoryVersionsSince,
|
|
11534
11548
|
// get a specific version
|
|
11535
|
-
|
|
11549
|
+
getYjsHistoryVersion,
|
|
11536
11550
|
// create a version
|
|
11537
|
-
|
|
11551
|
+
createVersionHistorySnapshot,
|
|
11538
11552
|
// execute a contextual prompt
|
|
11539
11553
|
executeContextualPrompt,
|
|
11540
11554
|
// Support for the Liveblocks browser extension
|