@liveblocks/core 0.19.2 → 0.19.3-beta1

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/README.md CHANGED
@@ -3,3 +3,10 @@
3
3
  Shared code and foundational internals for all other Liveblocks packages. None
4
4
  of the APIs exposed by this package are considered stable or public. Please **do
5
5
  not import anything directly from this package**.
6
+
7
+ ## Run e2e tests locally
8
+
9
+ - At the `packages/liveblocks-core` root level, add a file `.env`
10
+ - In this file, add the environment variable:
11
+ `LIVEBLOCKS_PUBLIC_KEY="pk_YOUR_PUBLIC_API_KEY"`
12
+ - Run `npm run test:e2e`
package/dist/index.d.ts CHANGED
@@ -514,9 +514,15 @@ declare type RoomAuthToken = {
514
514
  scopes: string[];
515
515
  actor: number;
516
516
  maxConnectionsPerRoom?: number;
517
- id?: string;
518
517
  info?: Json;
519
- };
518
+ groupIds?: string[];
519
+ } & ({
520
+ id: string;
521
+ anonymousId?: never;
522
+ } | {
523
+ id?: never;
524
+ anonymousId: string;
525
+ });
520
526
  declare type AuthToken = AppOnlyAuthToken | RoomAuthToken;
521
527
  declare function isAppOnlyAuthToken(data: JsonObject): data is AppOnlyAuthToken;
522
528
  declare function isRoomAuthToken(data: JsonObject): data is RoomAuthToken;
@@ -962,6 +968,14 @@ declare type Room<TPresence extends JsonObject, TStorage extends LsonObject, TUs
962
968
  * });
963
969
  */
964
970
  batch<T>(fn: () => T): T;
971
+ /**
972
+ * Whether or not the room has storage modifications that have not been acknowledged by the server.
973
+ */
974
+ hasPendingStorageModifications(): boolean;
975
+ /**
976
+ * Close room connection and try to reconnect
977
+ */
978
+ reconnect(): void;
965
979
  };
966
980
  declare type Polyfills = {
967
981
  atob?: (data: string) => string;
package/dist/index.js CHANGED
@@ -3673,6 +3673,9 @@ function makeStateMachine(state, config, mockedEffects) {
3673
3673
  _addToRealUndoStack(historyOps, batchUpdates);
3674
3674
  }
3675
3675
  }
3676
+ function hasPendingStorageModifications() {
3677
+ return state.offlineOperations.size > 0;
3678
+ }
3676
3679
  function simulateSocketClose() {
3677
3680
  if (state.socket) {
3678
3681
  state.socket = null;
@@ -3694,6 +3697,7 @@ function makeStateMachine(state, config, mockedEffects) {
3694
3697
  getItemsCount: () => state.nodes.size,
3695
3698
  connect,
3696
3699
  disconnect,
3700
+ reconnect,
3697
3701
  subscribe,
3698
3702
  updatePresence,
3699
3703
  broadcastEvent,
@@ -3704,6 +3708,7 @@ function makeStateMachine(state, config, mockedEffects) {
3704
3708
  canRedo,
3705
3709
  pauseHistory,
3706
3710
  resumeHistory,
3711
+ hasPendingStorageModifications,
3707
3712
  getStorage,
3708
3713
  getStorageSnapshot,
3709
3714
  events: {
@@ -3779,6 +3784,7 @@ function createRoom(options, config) {
3779
3784
  getConnectionState: machine.getConnectionState,
3780
3785
  isSelfAware: machine.isSelfAware,
3781
3786
  getSelf: machine.getSelf,
3787
+ reconnect: machine.reconnect,
3782
3788
  subscribe: machine.subscribe,
3783
3789
  getPresence: machine.getPresence,
3784
3790
  updatePresence: machine.updatePresence,
@@ -3796,6 +3802,7 @@ function createRoom(options, config) {
3796
3802
  pause: machine.pauseHistory,
3797
3803
  resume: machine.resumeHistory
3798
3804
  },
3805
+ hasPendingStorageModifications: machine.hasPendingStorageModifications,
3799
3806
  __INTERNAL_DO_NOT_USE: {
3800
3807
  simulateCloseWebsocket: machine.simulateSocketClose,
3801
3808
  simulateSendCloseEvent: machine.simulateSendCloseEvent
@@ -3824,7 +3831,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
3824
3831
  const ws = WebSocketPolyfill || WebSocket;
3825
3832
  return (token) => {
3826
3833
  return new ws(
3827
- `${liveblocksServer}/?token=${token}&version=${true ? "0.19.2" : "dev"}`
3834
+ `${liveblocksServer}/?token=${token}&version=${true ? "0.19.3-beta1" : "dev"}`
3828
3835
  );
3829
3836
  };
3830
3837
  }
@@ -3874,6 +3881,7 @@ function fetchAuthEndpoint(fetch2, endpoint, body) {
3874
3881
  headers: {
3875
3882
  "Content-Type": "application/json"
3876
3883
  },
3884
+ credentials: "include",
3877
3885
  body: JSON.stringify(body)
3878
3886
  });
3879
3887
  if (!res.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "0.19.2",
3
+ "version": "0.19.3-beta1",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",