@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 ADDED
@@ -0,0 +1,16 @@
1
+ Copyright 2021-present Liveblocks
2
+
3
+ This repository contains software under two licenses:
4
+
5
+ 1. Most of the code in this repository is licensed under the
6
+ Apache License 2.0 — see licenses/LICENSE-APACHE-2.0 for the
7
+ full license text.
8
+
9
+ 2. The following components are licensed under the
10
+ GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
11
+ — see licenses/LICENSE-AGPL-3.0 for the full license text:
12
+
13
+ - packages/liveblocks-server (published as @liveblocks/server)
14
+ - tools/liveblocks-cli (published as liveblocks)
15
+
16
+ Each package's own LICENSE or package.json specifies its applicable license.
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.18.1";
9
+ var PKG_VERSION = "3.18.3-test1";
10
10
  var PKG_FORMAT = "cjs";
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 (e) {
185
+ } catch (e2) {
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 (err) {
201
+ } catch (e3) {
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;
@@ -1018,7 +1018,7 @@ var HttpError = class _HttpError extends Error {
1018
1018
  let bodyAsText;
1019
1019
  try {
1020
1020
  bodyAsText = await response.text();
1021
- } catch (e2) {
1021
+ } catch (e4) {
1022
1022
  }
1023
1023
  const bodyAsJson = bodyAsText ? tryParseJson(bodyAsText) : void 0;
1024
1024
  let bodyAsJsonObject;
@@ -1035,7 +1035,7 @@ var HttpError = class _HttpError extends Error {
1035
1035
  let path;
1036
1036
  try {
1037
1037
  path = new URL(response.url).pathname;
1038
- } catch (e3) {
1038
+ } catch (e5) {
1039
1039
  }
1040
1040
  message += path !== void 0 ? ` (got status ${response.status} from ${path})` : ` (got status ${response.status})`;
1041
1041
  const details = bodyAsJsonObject;
@@ -1524,7 +1524,7 @@ function sanitizeUrl(url2) {
1524
1524
  urlObject.hash
1525
1525
  );
1526
1526
  return sanitizedUrl !== "" ? sanitizedUrl : null;
1527
- } catch (e4) {
1527
+ } catch (e6) {
1528
1528
  return null;
1529
1529
  }
1530
1530
  }
@@ -1547,7 +1547,7 @@ function isUrl(string) {
1547
1547
  try {
1548
1548
  new URL(string);
1549
1549
  return true;
1550
- } catch (_) {
1550
+ } catch (e7) {
1551
1551
  return false;
1552
1552
  }
1553
1553
  }
@@ -1976,7 +1976,7 @@ function createApiClient({
1976
1976
  roomId
1977
1977
  })
1978
1978
  );
1979
- } catch (error4) {
1979
+ } catch (e8) {
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 (err2) {
2078
+ } catch (e9) {
2079
2079
  }
2080
2080
  throw err;
2081
2081
  }
@@ -2631,7 +2631,7 @@ var HttpClient = class {
2631
2631
  let body;
2632
2632
  try {
2633
2633
  body = await response.json();
2634
- } catch (e5) {
2634
+ } catch (e10) {
2635
2635
  body = {};
2636
2636
  }
2637
2637
  return body;
@@ -3807,7 +3807,7 @@ var ManagedSocket = class {
3807
3807
  getStatus() {
3808
3808
  try {
3809
3809
  return toNewConnectionStatus(this.#machine);
3810
- } catch (e6) {
3810
+ } catch (e11) {
3811
3811
  return "initial";
3812
3812
  }
3813
3813
  }
@@ -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 = _nullishCoalesce(_optionalChain([self, 'access', _217 => _217.get, 'call', _218 => _218(), 'optionalAccess', _219 => _219.canWrite]), () => ( true));
9560
9560
  const root = context.root;
9561
- withoutHistory(() => {
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
- function withoutHistory(fn) {
10636
- const undoBefore = context.undoStack.length;
10637
- const redoBefore = context.redoStack.length;
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
- context.undoStack.length = undoBefore;
10642
- context.redoStack.length = redoBefore;
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
- [kInternal]: {
10952
- withoutHistory
10953
- }
10962
+ disable: disableHistory
10954
10963
  },
10955
10964
  fetchYDoc,
10956
10965
  fetchFeeds,
@@ -11157,7 +11166,7 @@ function getBaseUrl(baseUrl) {
11157
11166
  function isLocalhost(url2) {
11158
11167
  try {
11159
11168
  return new URL(url2).hostname === "localhost";
11160
- } catch (e7) {
11169
+ } catch (e12) {
11161
11170
  return false;
11162
11171
  }
11163
11172
  }