@liveblocks/core 1.1.4-internal1 → 1.1.5-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/dist/index.d.ts +213 -208
- package/dist/index.js +80 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -14
- package/dist/index.d.mts +0 -1894
- package/dist/index.mjs +0 -5903
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ var onMessageFromPanel = eventSource.observable;
|
|
|
103
103
|
// src/devtools/index.ts
|
|
104
104
|
var VERSION = true ? (
|
|
105
105
|
/* istanbul ignore next */
|
|
106
|
-
"1.1.
|
|
106
|
+
"1.1.5-test1"
|
|
107
107
|
) : "dev";
|
|
108
108
|
var _devtoolsSetupHasRun = false;
|
|
109
109
|
function setupDevTools(getAllRooms) {
|
|
@@ -726,6 +726,9 @@ function tryParseJson(rawMessage) {
|
|
|
726
726
|
return void 0;
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
+
function deepClone(items) {
|
|
730
|
+
return JSON.parse(JSON.stringify(items));
|
|
731
|
+
}
|
|
729
732
|
function b64decode(b64value) {
|
|
730
733
|
try {
|
|
731
734
|
const formattedValue = b64value.replace(/-/g, "+").replace(/_/g, "/");
|
|
@@ -865,11 +868,11 @@ var logPermanentClose = log(
|
|
|
865
868
|
1 /* WARN */,
|
|
866
869
|
"Connection to WebSocket closed permanently. Won't retry."
|
|
867
870
|
);
|
|
868
|
-
function isCloseEvent(
|
|
869
|
-
return !(
|
|
871
|
+
function isCloseEvent(error3) {
|
|
872
|
+
return !(error3 instanceof Error) && error3.type === "close";
|
|
870
873
|
}
|
|
871
|
-
function isCustomCloseEvent(
|
|
872
|
-
return isCloseEvent(
|
|
874
|
+
function isCustomCloseEvent(error3) {
|
|
875
|
+
return isCloseEvent(error3) && error3.code >= 4e3 && error3.code < 4100;
|
|
873
876
|
}
|
|
874
877
|
function enableTracing(machine) {
|
|
875
878
|
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
@@ -4070,10 +4073,10 @@ var PatchableRef = class extends ImmutableRef {
|
|
|
4070
4073
|
* Patches the current object.
|
|
4071
4074
|
*/
|
|
4072
4075
|
patch(patch) {
|
|
4073
|
-
const
|
|
4074
|
-
const
|
|
4075
|
-
if (
|
|
4076
|
-
this._data = freeze(
|
|
4076
|
+
const oldData = this._data;
|
|
4077
|
+
const newData = merge(oldData, patch);
|
|
4078
|
+
if (oldData !== newData) {
|
|
4079
|
+
this._data = freeze(newData);
|
|
4077
4080
|
this.invalidate();
|
|
4078
4081
|
}
|
|
4079
4082
|
}
|
|
@@ -4149,7 +4152,7 @@ function createRoom(options, config) {
|
|
|
4149
4152
|
buffer: {
|
|
4150
4153
|
flushTimerID: void 0,
|
|
4151
4154
|
lastFlushedAt: 0,
|
|
4152
|
-
|
|
4155
|
+
presenceUpdates: (
|
|
4153
4156
|
// Queue up the initial presence message as a Full Presence™ update
|
|
4154
4157
|
{
|
|
4155
4158
|
type: "full",
|
|
@@ -4230,7 +4233,7 @@ function createRoom(options, config) {
|
|
|
4230
4233
|
if (sessionInfo === null) {
|
|
4231
4234
|
throw new Error("Unexpected missing session info");
|
|
4232
4235
|
}
|
|
4233
|
-
context.buffer.
|
|
4236
|
+
context.buffer.presenceUpdates = {
|
|
4234
4237
|
type: "full",
|
|
4235
4238
|
data: (
|
|
4236
4239
|
// Because context.me.current is a readonly object, we'll have to
|
|
@@ -4461,11 +4464,11 @@ function createRoom(options, config) {
|
|
|
4461
4464
|
reverse.data[key] = context.me.current[key];
|
|
4462
4465
|
}
|
|
4463
4466
|
context.me.patch(op.data);
|
|
4464
|
-
if (context.buffer.
|
|
4465
|
-
context.buffer.
|
|
4467
|
+
if (context.buffer.presenceUpdates === null) {
|
|
4468
|
+
context.buffer.presenceUpdates = { type: "partial", data: op.data };
|
|
4466
4469
|
} else {
|
|
4467
4470
|
for (const key in op.data) {
|
|
4468
|
-
context.buffer.
|
|
4471
|
+
context.buffer.presenceUpdates.data[key] = op.data[key];
|
|
4469
4472
|
}
|
|
4470
4473
|
}
|
|
4471
4474
|
output.reverse.unshift(reverse);
|
|
@@ -4556,8 +4559,8 @@ function createRoom(options, config) {
|
|
|
4556
4559
|
}
|
|
4557
4560
|
function updatePresence(patch, options2) {
|
|
4558
4561
|
const oldValues = {};
|
|
4559
|
-
if (context.buffer.
|
|
4560
|
-
context.buffer.
|
|
4562
|
+
if (context.buffer.presenceUpdates === null) {
|
|
4563
|
+
context.buffer.presenceUpdates = {
|
|
4561
4564
|
type: "partial",
|
|
4562
4565
|
data: {}
|
|
4563
4566
|
};
|
|
@@ -4567,7 +4570,7 @@ function createRoom(options, config) {
|
|
|
4567
4570
|
if (overrideValue === void 0) {
|
|
4568
4571
|
continue;
|
|
4569
4572
|
}
|
|
4570
|
-
context.buffer.
|
|
4573
|
+
context.buffer.presenceUpdates.data[key] = overrideValue;
|
|
4571
4574
|
oldValues[key] = context.me.current[key];
|
|
4572
4575
|
}
|
|
4573
4576
|
context.me.patch(patch);
|
|
@@ -4745,7 +4748,7 @@ function createRoom(options, config) {
|
|
|
4745
4748
|
break;
|
|
4746
4749
|
}
|
|
4747
4750
|
case 300 /* UPDATE_YDOC */: {
|
|
4748
|
-
eventHub.ydoc.notify(message);
|
|
4751
|
+
eventHub.ydoc.notify(message.update);
|
|
4749
4752
|
break;
|
|
4750
4753
|
}
|
|
4751
4754
|
case 104 /* ROOM_STATE */: {
|
|
@@ -4828,7 +4831,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
4828
4831
|
lastFlushedAt: now,
|
|
4829
4832
|
messages: [],
|
|
4830
4833
|
storageOperations: [],
|
|
4831
|
-
|
|
4834
|
+
presenceUpdates: null
|
|
4832
4835
|
};
|
|
4833
4836
|
} else {
|
|
4834
4837
|
clearTimeout(context.buffer.flushTimerID);
|
|
@@ -4840,18 +4843,18 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
4840
4843
|
}
|
|
4841
4844
|
function serializeBuffer() {
|
|
4842
4845
|
const messages = [];
|
|
4843
|
-
if (context.buffer.
|
|
4846
|
+
if (context.buffer.presenceUpdates) {
|
|
4844
4847
|
messages.push(
|
|
4845
|
-
context.buffer.
|
|
4848
|
+
context.buffer.presenceUpdates.type === "full" ? {
|
|
4846
4849
|
type: 100 /* UPDATE_PRESENCE */,
|
|
4847
4850
|
// Populating the `targetActor` field turns this message into
|
|
4848
4851
|
// a Full Presence™ update message (not a patch), which will get
|
|
4849
4852
|
// interpreted by other clients as such.
|
|
4850
4853
|
targetActor: -1,
|
|
4851
|
-
data: context.buffer.
|
|
4854
|
+
data: context.buffer.presenceUpdates.data
|
|
4852
4855
|
} : {
|
|
4853
4856
|
type: 100 /* UPDATE_PRESENCE */,
|
|
4854
|
-
data: context.buffer.
|
|
4857
|
+
data: context.buffer.presenceUpdates.data
|
|
4855
4858
|
}
|
|
4856
4859
|
);
|
|
4857
4860
|
}
|
|
@@ -5064,12 +5067,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5064
5067
|
return {
|
|
5065
5068
|
/* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
|
|
5066
5069
|
__internal: {
|
|
5067
|
-
get
|
|
5068
|
-
return context.buffer;
|
|
5070
|
+
get presenceBuffer() {
|
|
5071
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _127 => _127.buffer, 'access', _128 => _128.presenceUpdates, 'optionalAccess', _129 => _129.data]), () => ( null)));
|
|
5069
5072
|
},
|
|
5070
5073
|
// prettier-ignore
|
|
5071
5074
|
get undoStack() {
|
|
5072
|
-
return context.undoStack;
|
|
5075
|
+
return deepClone(context.undoStack);
|
|
5073
5076
|
},
|
|
5074
5077
|
// prettier-ignore
|
|
5075
5078
|
get nodeCount() {
|
|
@@ -5192,7 +5195,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
5192
5195
|
}
|
|
5193
5196
|
if (isLiveNode(first)) {
|
|
5194
5197
|
const node = first;
|
|
5195
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
5198
|
+
if (_optionalChain([options, 'optionalAccess', _130 => _130.isDeep])) {
|
|
5196
5199
|
const storageCallback = second;
|
|
5197
5200
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
5198
5201
|
} else {
|
|
@@ -5219,10 +5222,10 @@ function makeCreateSocketDelegateForRoom(liveblocksServer, WebSocketPolyfill) {
|
|
|
5219
5222
|
return new ws(
|
|
5220
5223
|
`${liveblocksServer}/?token=${token}&version=${// prettier-ignore
|
|
5221
5224
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5222
|
-
// @ts-ignore (
|
|
5225
|
+
// @ts-ignore (PKG_VERSION will be injected by the build script)
|
|
5223
5226
|
true ? (
|
|
5224
5227
|
/* istanbul ignore next */
|
|
5225
|
-
"1.1.
|
|
5228
|
+
"1.1.5-test1"
|
|
5226
5229
|
) : "dev"}`
|
|
5227
5230
|
);
|
|
5228
5231
|
};
|
|
@@ -5361,7 +5364,7 @@ function createClient(options) {
|
|
|
5361
5364
|
polyfills: clientOptions.polyfills,
|
|
5362
5365
|
delegates: clientOptions.mockedDelegates,
|
|
5363
5366
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
5364
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
5367
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _131 => _131.unstable_batchedUpdates]),
|
|
5365
5368
|
liveblocksServer: getServerFromClientOptions(clientOptions),
|
|
5366
5369
|
authentication: prepareAuthentication(clientOptions, roomId),
|
|
5367
5370
|
httpSendEndpoint: buildLiveblocksHttpSendEndpoint(
|
|
@@ -5377,7 +5380,7 @@ function createClient(options) {
|
|
|
5377
5380
|
const shouldConnect = _nullishCoalesce(options2.shouldInitiallyConnect, () => ( true));
|
|
5378
5381
|
if (shouldConnect) {
|
|
5379
5382
|
if (typeof atob === "undefined") {
|
|
5380
|
-
if (_optionalChain([clientOptions, 'access',
|
|
5383
|
+
if (_optionalChain([clientOptions, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.atob]) === void 0) {
|
|
5381
5384
|
throw new Error(
|
|
5382
5385
|
"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"
|
|
5383
5386
|
);
|
|
@@ -5710,12 +5713,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
5710
5713
|
}
|
|
5711
5714
|
const newState = Object.assign({}, state);
|
|
5712
5715
|
for (const key in update.updates) {
|
|
5713
|
-
if (_optionalChain([update, 'access',
|
|
5716
|
+
if (_optionalChain([update, 'access', _134 => _134.updates, 'access', _135 => _135[key], 'optionalAccess', _136 => _136.type]) === "update") {
|
|
5714
5717
|
const val = update.node.get(key);
|
|
5715
5718
|
if (val !== void 0) {
|
|
5716
5719
|
newState[key] = lsonToJson(val);
|
|
5717
5720
|
}
|
|
5718
|
-
} else if (_optionalChain([update, 'access',
|
|
5721
|
+
} else if (_optionalChain([update, 'access', _137 => _137.updates, 'access', _138 => _138[key], 'optionalAccess', _139 => _139.type]) === "delete") {
|
|
5719
5722
|
delete newState[key];
|
|
5720
5723
|
}
|
|
5721
5724
|
}
|
|
@@ -5776,12 +5779,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
5776
5779
|
}
|
|
5777
5780
|
const newState = Object.assign({}, state);
|
|
5778
5781
|
for (const key in update.updates) {
|
|
5779
|
-
if (_optionalChain([update, 'access',
|
|
5782
|
+
if (_optionalChain([update, 'access', _140 => _140.updates, 'access', _141 => _141[key], 'optionalAccess', _142 => _142.type]) === "update") {
|
|
5780
5783
|
const value = update.node.get(key);
|
|
5781
5784
|
if (value !== void 0) {
|
|
5782
5785
|
newState[key] = lsonToJson(value);
|
|
5783
5786
|
}
|
|
5784
|
-
} else if (_optionalChain([update, 'access',
|
|
5787
|
+
} else if (_optionalChain([update, 'access', _143 => _143.updates, 'access', _144 => _144[key], 'optionalAccess', _145 => _145.type]) === "delete") {
|
|
5785
5788
|
delete newState[key];
|
|
5786
5789
|
}
|
|
5787
5790
|
}
|
|
@@ -5865,6 +5868,47 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
|
5865
5868
|
return WebsocketCloseCodes2;
|
|
5866
5869
|
})(WebsocketCloseCodes || {});
|
|
5867
5870
|
|
|
5871
|
+
// src/dupe-detection.ts
|
|
5872
|
+
var g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
5873
|
+
var crossLinkedDocs = "https://liveblocks.io/errors/cross-linked";
|
|
5874
|
+
var dupesDocs = "https://liveblocks.io/errors/dupes";
|
|
5875
|
+
function error2(msg) {
|
|
5876
|
+
if (process.env.NODE_ENV === "production") {
|
|
5877
|
+
console.error(msg);
|
|
5878
|
+
} else {
|
|
5879
|
+
throw new Error(msg);
|
|
5880
|
+
}
|
|
5881
|
+
}
|
|
5882
|
+
function detectDupes(pkgName, pkgVersion, pkgFormat) {
|
|
5883
|
+
const pkgId = Symbol.for(pkgName);
|
|
5884
|
+
const pkgBuildInfo = `${pkgVersion} (${pkgFormat})`;
|
|
5885
|
+
if (!g[pkgId]) {
|
|
5886
|
+
g[pkgId] = pkgBuildInfo;
|
|
5887
|
+
} else {
|
|
5888
|
+
const msg = `Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${dupesDocs}
|
|
5889
|
+
|
|
5890
|
+
Conflicting copies in your bundle:
|
|
5891
|
+
- ${pkgName} ${g[pkgId]} (already loaded)
|
|
5892
|
+
- ${pkgName} ${pkgBuildInfo} (trying to load this now)`;
|
|
5893
|
+
error2(msg);
|
|
5894
|
+
}
|
|
5895
|
+
if (pkgVersion !== "1.1.5-test1") {
|
|
5896
|
+
error2(
|
|
5897
|
+
`Cross-linked versions of Liveblocks found, which will cause issues! See ${crossLinkedDocs}
|
|
5898
|
+
|
|
5899
|
+
Conflicts:
|
|
5900
|
+
- @liveblocks/core is at ${"1.1.5-test1"}
|
|
5901
|
+
- ${pkgName} is at ${pkgVersion}
|
|
5902
|
+
|
|
5903
|
+
Always upgrade all Liveblocks packages to the same version number.`
|
|
5904
|
+
);
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
|
|
5908
|
+
// src/index.ts
|
|
5909
|
+
detectDupes("@liveblocks/core", "1.1.5-test1", "cjs");
|
|
5910
|
+
|
|
5911
|
+
|
|
5868
5912
|
|
|
5869
5913
|
|
|
5870
5914
|
|
|
@@ -5899,5 +5943,5 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
|
5899
5943
|
|
|
5900
5944
|
|
|
5901
5945
|
|
|
5902
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asArrayWithLegacyMethods = asArrayWithLegacyMethods; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.createClient = createClient; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.errorIf = errorIf; exports.freeze = freeze; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.shallow = shallow; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
|
|
5946
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asArrayWithLegacyMethods = asArrayWithLegacyMethods; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.createClient = createClient; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makePosition = makePosition; exports.nn = nn; exports.patchLiveObjectKey = patchLiveObjectKey; exports.shallow = shallow; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.withTimeout = withTimeout;
|
|
5903
5947
|
//# sourceMappingURL=index.js.map
|