@liveblocks/core 1.2.0-internal1 → 1.2.0-internal2

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 CHANGED
@@ -686,11 +686,11 @@ declare function asArrayWithLegacyMethods<T>(arr: readonly T[]): ReadonlyArrayWi
686
686
  */
687
687
  declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta> = {
688
688
  /**
689
- * The connection id of the user. It is unique and increment at every new connection.
689
+ * The connection ID of the User. It is unique and increment at every new connection.
690
690
  */
691
691
  readonly connectionId: number;
692
692
  /**
693
- * The id of the user that has been set in the authentication endpoint.
693
+ * The ID of the User that has been set in the authentication endpoint.
694
694
  * Useful to get additional information about the connected user.
695
695
  */
696
696
  readonly id: TUserMeta["id"];
@@ -699,7 +699,7 @@ declare type User<TPresence extends JsonObject, TUserMeta extends BaseUserMeta>
699
699
  */
700
700
  readonly info: TUserMeta["info"];
701
701
  /**
702
- * The user presence.
702
+ * The user’s presence data.
703
703
  */
704
704
  readonly presence: TPresence;
705
705
  /**
@@ -1670,16 +1670,6 @@ declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
1670
1670
  scopes: string[];
1671
1671
  };
1672
1672
  };
1673
- /**
1674
- * Informs the client what their actor ID is.
1675
- * @since v1.2 (WS API v7)
1676
- */
1677
- readonly actor: number;
1678
- /**
1679
- * Informs the client whether their access is read-only.
1680
- * @since v1.2 (WS API v7)
1681
- */
1682
- readonly isReadOnly: boolean;
1683
1673
  };
1684
1674
  /**
1685
1675
  * Sent by the WebSocket server to a single client in response to the client
package/dist/index.js CHANGED
@@ -145,7 +145,7 @@ var onMessageFromPanel = eventSource.observable;
145
145
  // src/devtools/index.ts
146
146
  var VERSION = true ? (
147
147
  /* istanbul ignore next */
148
- "1.2.0-internal1"
148
+ "1.2.0-internal2"
149
149
  ) : "dev";
150
150
  var _devtoolsSetupHasRun = false;
151
151
  function setupDevTools(getAllRooms) {
@@ -3973,6 +3973,19 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
3973
3973
  return ServerMsgCode2;
3974
3974
  })(ServerMsgCode || {});
3975
3975
 
3976
+ // src/lib/LegacyArray.ts
3977
+ function asArrayWithLegacyMethods(arr) {
3978
+ Object.defineProperty(arr, "count", {
3979
+ value: arr.length,
3980
+ enumerable: false
3981
+ });
3982
+ Object.defineProperty(arr, "toArray", {
3983
+ value: () => arr,
3984
+ enumerable: false
3985
+ });
3986
+ return freeze(arr);
3987
+ }
3988
+
3976
3989
  // src/refs/ImmutableRef.ts
3977
3990
  function merge(target, patch) {
3978
3991
  let updated = false;
@@ -4010,42 +4023,6 @@ var ImmutableRef = class {
4010
4023
  }
4011
4024
  };
4012
4025
 
4013
- // src/refs/MeRef.ts
4014
- var MeRef = class extends ImmutableRef {
4015
- constructor(initialPresence) {
4016
- super();
4017
- this._me = freeze(compactObject(initialPresence));
4018
- }
4019
- /** @internal */
4020
- _toImmutable() {
4021
- return this._me;
4022
- }
4023
- /**
4024
- * Patches the current "me" instance.
4025
- */
4026
- patch(patch) {
4027
- const oldMe = this._me;
4028
- const newMe = merge(oldMe, patch);
4029
- if (oldMe !== newMe) {
4030
- this._me = freeze(newMe);
4031
- this.invalidate();
4032
- }
4033
- }
4034
- };
4035
-
4036
- // src/lib/LegacyArray.ts
4037
- function asArrayWithLegacyMethods(arr) {
4038
- Object.defineProperty(arr, "count", {
4039
- value: arr.length,
4040
- enumerable: false
4041
- });
4042
- Object.defineProperty(arr, "toArray", {
4043
- value: () => arr,
4044
- enumerable: false
4045
- });
4046
- return freeze(arr);
4047
- }
4048
-
4049
4026
  // src/refs/OthersRef.ts
4050
4027
  function makeUser(conn, presence) {
4051
4028
  return freeze(compactObject(__spreadProps(__spreadValues({}, conn), { presence })));
@@ -4155,6 +4132,29 @@ var OthersRef = class extends ImmutableRef {
4155
4132
  }
4156
4133
  };
4157
4134
 
4135
+ // src/refs/PatchableRef.ts
4136
+ var PatchableRef = class extends ImmutableRef {
4137
+ constructor(data) {
4138
+ super();
4139
+ this._data = freeze(compactObject(data));
4140
+ }
4141
+ /** @internal */
4142
+ _toImmutable() {
4143
+ return this._data;
4144
+ }
4145
+ /**
4146
+ * Patches the current object.
4147
+ */
4148
+ patch(patch) {
4149
+ const oldMe = this._data;
4150
+ const newMe = merge(oldMe, patch);
4151
+ if (oldMe !== newMe) {
4152
+ this._data = freeze(newMe);
4153
+ this.invalidate();
4154
+ }
4155
+ }
4156
+ };
4157
+
4158
4158
  // src/refs/ValueRef.ts
4159
4159
  var ValueRef = class extends ImmutableRef {
4160
4160
  constructor(initialValue) {
@@ -4237,7 +4237,7 @@ function createRoom(options, config) {
4237
4237
  storageOperations: []
4238
4238
  },
4239
4239
  sessionInfo: new ValueRef(null),
4240
- me: new MeRef(initialPresence),
4240
+ me: new PatchableRef(initialPresence),
4241
4241
  others: new OthersRef(),
4242
4242
  initialStorage,
4243
4243
  idFactory: null,
@@ -4262,9 +4262,10 @@ function createRoom(options, config) {
4262
4262
  const token = (_a2 = managedSocket.token) == null ? void 0 : _a2.parsed;
4263
4263
  if (token !== void 0 && token !== lastToken) {
4264
4264
  context.sessionInfo.set({
4265
- id: token.actor,
4266
4265
  userInfo: token.info,
4267
4266
  userId: token.id,
4267
+ // NOTE: In the future, these fields will get assigned in the connection phase
4268
+ actor: token.actor,
4268
4269
  isReadOnly: isStorageReadOnly(token.scopes)
4269
4270
  });
4270
4271
  lastToken = token;
@@ -4316,7 +4317,7 @@ function createRoom(options, config) {
4316
4317
  __spreadValues({}, context.me.current)
4317
4318
  )
4318
4319
  };
4319
- context.idFactory = makeIdFactory(sessionInfo.id);
4320
+ context.idFactory = makeIdFactory(sessionInfo.actor);
4320
4321
  if (_getStorage$ !== null) {
4321
4322
  refreshStorage({ flush: false });
4322
4323
  }
@@ -4433,7 +4434,7 @@ function createRoom(options, config) {
4433
4434
  context.me,
4434
4435
  (info, me) => {
4435
4436
  return info !== null ? {
4436
- connectionId: info.id,
4437
+ connectionId: info.actor,
4437
4438
  id: info.userId,
4438
4439
  info: info.userInfo,
4439
4440
  presence: me,
@@ -4510,7 +4511,7 @@ function createRoom(options, config) {
4510
4511
  function getConnectionId() {
4511
4512
  const info = context.sessionInfo.current;
4512
4513
  if (info) {
4513
- return info.id;
4514
+ return info.actor;
4514
4515
  }
4515
4516
  throw new Error(
4516
4517
  "Internal. Tried to get connection id but connection was never open"
@@ -5304,7 +5305,7 @@ function makeCreateSocketDelegateForRoom(liveblocksServer, WebSocketPolyfill) {
5304
5305
  // @ts-ignore (__PACKAGE_VERSION__ will be injected by the build script)
5305
5306
  true ? (
5306
5307
  /* istanbul ignore next */
5307
- "1.2.0-internal1"
5308
+ "1.2.0-internal2"
5308
5309
  ) : "dev"}`
5309
5310
  );
5310
5311
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "1.2.0-internal1",
3
+ "version": "1.2.0-internal2",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",