@liveblocks/core 2.15.2 → 2.16.0-toolbars1

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.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 = "2.15.2";
9
+ var PKG_VERSION = "2.16.0-toolbars1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -170,9 +170,6 @@ var errorWithTitle = wrapWithTitle("error");
170
170
  function raise(msg) {
171
171
  throw new Error(msg);
172
172
  }
173
- function isPlainObject(blob) {
174
- return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
175
- }
176
173
  function entries(obj) {
177
174
  return Object.entries(obj);
178
175
  }
@@ -914,6 +911,14 @@ var DefaultMap = class extends Map {
914
911
  }
915
912
  };
916
913
 
914
+ // src/lib/guards.ts
915
+ function isPlainObject(blob) {
916
+ return blob !== null && typeof blob === "object" && Object.prototype.toString.call(blob) === "[object Object]";
917
+ }
918
+ function isStartsWithOperator(blob) {
919
+ return isPlainObject(blob) && typeof blob.startsWith === "string";
920
+ }
921
+
917
922
  // src/lib/objectToQuery.ts
918
923
  var identifierRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
919
924
  function objectToQuery(obj) {
@@ -928,10 +933,12 @@ function objectToQuery(obj) {
928
933
  }
929
934
  if (isSimpleValue(value)) {
930
935
  keyValuePairs.push([key, value]);
931
- } else if (isValueWithOperator(value)) {
932
- keyValuePairsWithOperator.push([key, value]);
933
- } else if (typeof value === "object" && !("startsWith" in value)) {
934
- indexedKeys.push([key, value]);
936
+ } else if (isPlainObject(value)) {
937
+ if (isStartsWithOperator(value)) {
938
+ keyValuePairsWithOperator.push([key, value]);
939
+ } else {
940
+ indexedKeys.push([key, value]);
941
+ }
935
942
  }
936
943
  });
937
944
  filterList = [
@@ -948,7 +955,7 @@ function objectToQuery(obj) {
948
955
  }
949
956
  if (isSimpleValue(nestedValue)) {
950
957
  nKeyValuePairs.push([formatFilterKey(key, nestedKey), nestedValue]);
951
- } else if (isValueWithOperator(nestedValue)) {
958
+ } else if (isStartsWithOperator(nestedValue)) {
952
959
  nKeyValuePairsWithOperator.push([
953
960
  formatFilterKey(key, nestedKey),
954
961
  nestedValue
@@ -990,16 +997,7 @@ var getFiltersFromKeyValuePairsWithOperator = (keyValuePairsWithOperator) => {
990
997
  return filters;
991
998
  };
992
999
  var isSimpleValue = (value) => {
993
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
994
- return true;
995
- }
996
- return false;
997
- };
998
- var isValueWithOperator = (value) => {
999
- if (typeof value === "object" && value !== null && "startsWith" in value) {
1000
- return true;
1001
- }
1002
- return false;
1000
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
1003
1001
  };
1004
1002
  var formatFilter = (key, operator, value) => {
1005
1003
  return `${key}${operator}${value}`;
@@ -2480,6 +2478,7 @@ function toNewConnectionStatus(machine) {
2480
2478
  return machine.context.successCount > 0 ? "reconnecting" : "connecting";
2481
2479
  case "@idle.failed":
2482
2480
  return "disconnected";
2481
+ // istanbul ignore next
2483
2482
  default:
2484
2483
  return assertNever(state, "Unknown state");
2485
2484
  }
@@ -3360,6 +3359,12 @@ function setupDevTools(getAllRooms) {
3360
3359
  _devtoolsSetupHasRun = true;
3361
3360
  onMessageFromPanel.subscribe((msg) => {
3362
3361
  switch (msg.msg) {
3362
+ // When a devtool panel sends an explicit "connect" message back to this
3363
+ // live running client (in response to the "wake-up-devtools" message,
3364
+ // or when the devtool panel is opened for the first time), it means that it's okay to
3365
+ // start emitting messages.
3366
+ // Before this explicit acknowledgement, any call to sendToPanel() will
3367
+ // be a no-op.
3363
3368
  case "connect": {
3364
3369
  activateBridge(true);
3365
3370
  for (const roomId of getAllRooms()) {
@@ -3500,6 +3505,8 @@ function linkDevTools(roomId, room) {
3500
3505
  // roomChannelListeners registry
3501
3506
  onMessageFromPanel.subscribe((msg) => {
3502
3507
  switch (msg.msg) {
3508
+ // Sent by the devtool panel when it wants to receive the sync stream
3509
+ // for a room
3503
3510
  case "room::subscribe": {
3504
3511
  if (msg.roomId === roomId) {
3505
3512
  startSyncStream(room);
@@ -6942,6 +6949,7 @@ function createRoom(options, config) {
6942
6949
  processInitialStorage(message);
6943
6950
  break;
6944
6951
  }
6952
+ // Write event
6945
6953
  case 201 /* UPDATE_STORAGE */: {
6946
6954
  const applyResult = applyOps(message.ops, false);
6947
6955
  for (const [key, value] of applyResult.updates.storageUpdates) {
@@ -6952,6 +6960,11 @@ function createRoom(options, config) {
6952
6960
  }
6953
6961
  break;
6954
6962
  }
6963
+ // Receiving a RejectedOps message in the client means that the server is no
6964
+ // longer in sync with the client. Trying to synchronize the client again by
6965
+ // rolling back particular Ops may be hard/impossible. It's fine to not try and
6966
+ // accept the out-of-sync reality and throw an error. We look at this kind of bug
6967
+ // as a developer-owned bug. In production, these errors are not expected to happen.
6955
6968
  case 299 /* REJECT_STORAGE_OP */: {
6956
6969
  errorWithTitle(
6957
6970
  "Storage mutation rejection error",
@@ -7613,6 +7626,7 @@ function makeClassicSubscribeFn(events) {
7613
7626
  return events.comments.subscribe(
7614
7627
  callback
7615
7628
  );
7629
+ // istanbul ignore next
7616
7630
  default:
7617
7631
  return assertNever(
7618
7632
  first,
@@ -8976,5 +8990,6 @@ var NotificationsApiError = HttpError;
8976
8990
 
8977
8991
 
8978
8992
 
8979
- exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.unstringify = unstringify; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
8993
+
8994
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.unstringify = unstringify; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
8980
8995
  //# sourceMappingURL=index.js.map