@liveblocks/core 3.18.1 → 3.18.3-test1
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/LICENSE +16 -0
- package/dist/index.cjs +37 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -8
- package/dist/index.d.ts +26 -8
- package/dist/index.js +31 -22
- package/dist/index.js.map +1 -1
- package/package.json +26 -23
package/dist/index.d.cts
CHANGED
|
@@ -1092,9 +1092,7 @@ type LiveNode = LiveStructure | LiveRegister<Json>;
|
|
|
1092
1092
|
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
1093
1093
|
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
1094
1094
|
*/
|
|
1095
|
-
type LsonObject =
|
|
1096
|
-
[key: string]: Lson | undefined;
|
|
1097
|
-
};
|
|
1095
|
+
type LsonObject = Record<string, Lson | undefined>;
|
|
1098
1096
|
/**
|
|
1099
1097
|
* Helper type to convert any valid Lson type to the equivalent Json type.
|
|
1100
1098
|
*
|
|
@@ -1110,8 +1108,10 @@ type LsonObject = {
|
|
|
1110
1108
|
* ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
1111
1109
|
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
1112
1110
|
*/
|
|
1113
|
-
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToJson<I>[] : L extends LiveObject<infer O
|
|
1114
|
-
readonly [
|
|
1111
|
+
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? LsonObject extends O ? ReadonlyJsonObject : {
|
|
1112
|
+
readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
|
|
1113
|
+
} : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
|
|
1114
|
+
readonly [K in KS]: ToJson<V>;
|
|
1115
1115
|
} : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
1116
1116
|
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
1117
1117
|
} : L extends Json ? L : never;
|
|
@@ -3288,9 +3288,27 @@ interface History {
|
|
|
3288
3288
|
* // room.getPresence() equals { cursor: { x: 0, y: 0 } }
|
|
3289
3289
|
*/
|
|
3290
3290
|
resume: () => void;
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3291
|
+
/**
|
|
3292
|
+
* Executes a callback with history tracking temporarily disabled. Any
|
|
3293
|
+
* storage mutations made inside the callback will be applied normally
|
|
3294
|
+
* but will not appear on the undo/redo stacks.
|
|
3295
|
+
*
|
|
3296
|
+
* This is useful for background or async writes that should not be
|
|
3297
|
+
* undoable, such as writing back results from an AI generation task
|
|
3298
|
+
* or reconciling state from an external source.
|
|
3299
|
+
*
|
|
3300
|
+
* Returns the callback's return value. If the callback throws, the
|
|
3301
|
+
* undo/redo stacks are left unchanged (as if the callback never ran).
|
|
3302
|
+
*
|
|
3303
|
+
* @example
|
|
3304
|
+
* room.history.disable(() => {
|
|
3305
|
+
* root.set("generatedText", result);
|
|
3306
|
+
* });
|
|
3307
|
+
*
|
|
3308
|
+
* @experimental This API is experimental and may change or be removed
|
|
3309
|
+
* in a future release without following semver guarantees.
|
|
3310
|
+
*/
|
|
3311
|
+
disable: <T>(fn: () => T) => T;
|
|
3294
3312
|
}
|
|
3295
3313
|
type HistoryEvent = {
|
|
3296
3314
|
canUndo: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1092,9 +1092,7 @@ type LiveNode = LiveStructure | LiveRegister<Json>;
|
|
|
1092
1092
|
* A mapping of keys to Lson values. A Lson value is any valid JSON
|
|
1093
1093
|
* value or a Live storage data structure (LiveMap, LiveList, etc.)
|
|
1094
1094
|
*/
|
|
1095
|
-
type LsonObject =
|
|
1096
|
-
[key: string]: Lson | undefined;
|
|
1097
|
-
};
|
|
1095
|
+
type LsonObject = Record<string, Lson | undefined>;
|
|
1098
1096
|
/**
|
|
1099
1097
|
* Helper type to convert any valid Lson type to the equivalent Json type.
|
|
1100
1098
|
*
|
|
@@ -1110,8 +1108,10 @@ type LsonObject = {
|
|
|
1110
1108
|
* ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
|
|
1111
1109
|
* // { readonly a: null, readonly b: readonly string[], readonly c?: number }
|
|
1112
1110
|
*/
|
|
1113
|
-
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I> ? readonly ToJson<I>[] : L extends LiveObject<infer O
|
|
1114
|
-
readonly [
|
|
1111
|
+
type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? LsonObject extends O ? ReadonlyJsonObject : {
|
|
1112
|
+
readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
|
|
1113
|
+
} : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
|
|
1114
|
+
readonly [K in KS]: ToJson<V>;
|
|
1115
1115
|
} : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
|
|
1116
1116
|
readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
|
|
1117
1117
|
} : L extends Json ? L : never;
|
|
@@ -3288,9 +3288,27 @@ interface History {
|
|
|
3288
3288
|
* // room.getPresence() equals { cursor: { x: 0, y: 0 } }
|
|
3289
3289
|
*/
|
|
3290
3290
|
resume: () => void;
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3291
|
+
/**
|
|
3292
|
+
* Executes a callback with history tracking temporarily disabled. Any
|
|
3293
|
+
* storage mutations made inside the callback will be applied normally
|
|
3294
|
+
* but will not appear on the undo/redo stacks.
|
|
3295
|
+
*
|
|
3296
|
+
* This is useful for background or async writes that should not be
|
|
3297
|
+
* undoable, such as writing back results from an AI generation task
|
|
3298
|
+
* or reconciling state from an external source.
|
|
3299
|
+
*
|
|
3300
|
+
* Returns the callback's return value. If the callback throws, the
|
|
3301
|
+
* undo/redo stacks are left unchanged (as if the callback never ran).
|
|
3302
|
+
*
|
|
3303
|
+
* @example
|
|
3304
|
+
* room.history.disable(() => {
|
|
3305
|
+
* root.set("generatedText", result);
|
|
3306
|
+
* });
|
|
3307
|
+
*
|
|
3308
|
+
* @experimental This API is experimental and may change or be removed
|
|
3309
|
+
* in a future release without following semver guarantees.
|
|
3310
|
+
*/
|
|
3311
|
+
disable: <T>(fn: () => T) => T;
|
|
3294
3312
|
}
|
|
3295
3313
|
type HistoryEvent = {
|
|
3296
3314
|
canUndo: boolean;
|
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.18.
|
|
9
|
+
var PKG_VERSION = "3.18.3-test1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -145,7 +145,7 @@ function makeBufferableEventSource() {
|
|
|
145
145
|
// src/lib/freeze.ts
|
|
146
146
|
var freeze = process.env.NODE_ENV === "production" ? (
|
|
147
147
|
/* istanbul ignore next */
|
|
148
|
-
(x) => x
|
|
148
|
+
((x) => x)
|
|
149
149
|
) : Object.freeze;
|
|
150
150
|
|
|
151
151
|
// src/lib/utils.ts
|
|
@@ -182,7 +182,7 @@ function mapValues(obj, mapFn) {
|
|
|
182
182
|
function tryParseJson(rawMessage) {
|
|
183
183
|
try {
|
|
184
184
|
return JSON.parse(rawMessage);
|
|
185
|
-
} catch
|
|
185
|
+
} catch {
|
|
186
186
|
return void 0;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -198,7 +198,7 @@ function b64decode(b64value) {
|
|
|
198
198
|
}).join("")
|
|
199
199
|
);
|
|
200
200
|
return decodedValue;
|
|
201
|
-
} catch
|
|
201
|
+
} catch {
|
|
202
202
|
return atob(b64value);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -266,8 +266,8 @@ function partition(iterable, predicate) {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
// src/lib/signals.ts
|
|
269
|
-
var kSinks = Symbol("kSinks");
|
|
270
|
-
var kTrigger = Symbol("kTrigger");
|
|
269
|
+
var kSinks = /* @__PURE__ */ Symbol("kSinks");
|
|
270
|
+
var kTrigger = /* @__PURE__ */ Symbol("kTrigger");
|
|
271
271
|
var signalsToTrigger = null;
|
|
272
272
|
var trackedReads = null;
|
|
273
273
|
function batch(callback) {
|
|
@@ -412,7 +412,7 @@ var PatchableSignal = class extends Signal {
|
|
|
412
412
|
super.set((old) => merge(old, patch));
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
|
-
var INITIAL = Symbol();
|
|
415
|
+
var INITIAL = /* @__PURE__ */ Symbol();
|
|
416
416
|
var DerivedSignal = class _DerivedSignal extends AbstractSignal {
|
|
417
417
|
#prevValue;
|
|
418
418
|
#dirty;
|
|
@@ -1547,7 +1547,7 @@ function isUrl(string) {
|
|
|
1547
1547
|
try {
|
|
1548
1548
|
new URL(string);
|
|
1549
1549
|
return true;
|
|
1550
|
-
} catch
|
|
1550
|
+
} catch {
|
|
1551
1551
|
return false;
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
@@ -1976,7 +1976,7 @@ function createApiClient({
|
|
|
1976
1976
|
roomId
|
|
1977
1977
|
})
|
|
1978
1978
|
);
|
|
1979
|
-
} catch
|
|
1979
|
+
} catch {
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
1982
|
throw error3;
|
|
@@ -2075,7 +2075,7 @@ function createApiClient({
|
|
|
2075
2075
|
url`/v2/c/chats/${chatId}/attachments/${attachment.id}/multipart/${multipartUpload.uploadId}`,
|
|
2076
2076
|
await authManager.getAuthValue({ requestedScope: "comments:read" })
|
|
2077
2077
|
);
|
|
2078
|
-
} catch
|
|
2078
|
+
} catch {
|
|
2079
2079
|
}
|
|
2080
2080
|
throw err;
|
|
2081
2081
|
}
|
|
@@ -3874,7 +3874,7 @@ var ManagedSocket = class {
|
|
|
3874
3874
|
};
|
|
3875
3875
|
|
|
3876
3876
|
// src/internal.ts
|
|
3877
|
-
var kInternal = Symbol();
|
|
3877
|
+
var kInternal = /* @__PURE__ */ Symbol();
|
|
3878
3878
|
|
|
3879
3879
|
// src/lib/IncrementalJsonParser.ts
|
|
3880
3880
|
var EMPTY_OBJECT = Object.freeze({});
|
|
@@ -4328,7 +4328,7 @@ function createStore_forKnowledge() {
|
|
|
4328
4328
|
function now() {
|
|
4329
4329
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4330
4330
|
}
|
|
4331
|
-
var kWILDCARD = Symbol("*");
|
|
4331
|
+
var kWILDCARD = /* @__PURE__ */ Symbol("*");
|
|
4332
4332
|
function createStore_forTools() {
|
|
4333
4333
|
const toolsByChatId\u03A3 = new DefaultMap(
|
|
4334
4334
|
(_chatId) => {
|
|
@@ -8646,7 +8646,7 @@ function warnOnceIf(condition, message, key = message) {
|
|
|
8646
8646
|
}
|
|
8647
8647
|
|
|
8648
8648
|
// src/protocol/NotificationSettings.ts
|
|
8649
|
-
var kPlain = Symbol("notification-settings-plain");
|
|
8649
|
+
var kPlain = /* @__PURE__ */ Symbol("notification-settings-plain");
|
|
8650
8650
|
function createNotificationSettings(plain) {
|
|
8651
8651
|
const channels = [
|
|
8652
8652
|
"email",
|
|
@@ -9558,7 +9558,7 @@ function createRoom(options, config) {
|
|
|
9558
9558
|
}
|
|
9559
9559
|
const canWrite = self.get()?.canWrite ?? true;
|
|
9560
9560
|
const root = context.root;
|
|
9561
|
-
|
|
9561
|
+
disableHistory(() => {
|
|
9562
9562
|
for (const key in context.initialStorage) {
|
|
9563
9563
|
if (root.get(key) === void 0) {
|
|
9564
9564
|
if (canWrite) {
|
|
@@ -9843,6 +9843,7 @@ function createRoom(options, config) {
|
|
|
9843
9843
|
return context.redoStack.length > 0;
|
|
9844
9844
|
}
|
|
9845
9845
|
function onHistoryChange() {
|
|
9846
|
+
if (historyDisabled > 0) return;
|
|
9846
9847
|
eventHub.history.notify({ canUndo: canUndo(), canRedo: canRedo() });
|
|
9847
9848
|
}
|
|
9848
9849
|
function onUserJoinedMessage(message) {
|
|
@@ -10632,14 +10633,24 @@ function createRoom(options, config) {
|
|
|
10632
10633
|
}
|
|
10633
10634
|
commitPausedHistoryToUndoStack();
|
|
10634
10635
|
}
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
const
|
|
10636
|
+
let historyDisabled = 0;
|
|
10637
|
+
function disableHistory(fn) {
|
|
10638
|
+
const origUndo = context.undoStack;
|
|
10639
|
+
const origRedo = context.redoStack;
|
|
10640
|
+
const tempUndo = [];
|
|
10641
|
+
const tempRedo = [];
|
|
10642
|
+
context.undoStack = tempUndo;
|
|
10643
|
+
context.redoStack = tempRedo;
|
|
10644
|
+
historyDisabled++;
|
|
10638
10645
|
try {
|
|
10639
10646
|
return fn();
|
|
10640
10647
|
} finally {
|
|
10641
|
-
|
|
10642
|
-
context.redoStack
|
|
10648
|
+
historyDisabled--;
|
|
10649
|
+
if (context.undoStack !== tempUndo || context.redoStack !== tempRedo) {
|
|
10650
|
+
throw new Error("unexpected stack swap during history.disable()");
|
|
10651
|
+
}
|
|
10652
|
+
context.undoStack = origUndo;
|
|
10653
|
+
context.redoStack = origRedo;
|
|
10643
10654
|
}
|
|
10644
10655
|
}
|
|
10645
10656
|
const syncSourceForStorage = config.createSyncSource();
|
|
@@ -10948,9 +10959,7 @@ function createRoom(options, config) {
|
|
|
10948
10959
|
clear,
|
|
10949
10960
|
pause: pauseHistory,
|
|
10950
10961
|
resume: resumeHistory,
|
|
10951
|
-
|
|
10952
|
-
withoutHistory
|
|
10953
|
-
}
|
|
10962
|
+
disable: disableHistory
|
|
10954
10963
|
},
|
|
10955
10964
|
fetchYDoc,
|
|
10956
10965
|
fetchFeeds,
|