@tldraw/editor 3.13.0-canary.d403fcffd1eb → 3.13.0-canary.dc099cf30823

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.
@@ -22,10 +22,10 @@ __export(version_exports, {
22
22
  version: () => version
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const version = "3.13.0-canary.d403fcffd1eb";
25
+ const version = "3.13.0-canary.dc099cf30823";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-04-17T07:29:28.021Z",
29
- patch: "2025-04-17T07:29:28.021Z"
28
+ minor: "2025-04-17T14:42:12.602Z",
29
+ patch: "2025-04-17T14:42:12.602Z"
30
30
  };
31
31
  //# sourceMappingURL=version.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.d403fcffd1eb'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-17T07:29:28.021Z',\n\tpatch: '2025-04-17T07:29:28.021Z',\n}\n"],
4
+ "sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.13.0-canary.dc099cf30823'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-17T14:42:12.602Z',\n\tpatch: '2025-04-17T14:42:12.602Z',\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1844,6 +1844,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
1844
1844
  * @public
1845
1845
  */
1846
1846
  getCamera(): TLCamera;
1847
+ private _getFollowingPresence;
1847
1848
  private getViewportPageBoundsForFollowing;
1848
1849
  private getCameraForFollowing;
1849
1850
  /**
@@ -303,7 +303,7 @@ function debugEnableLicensing() {
303
303
  }
304
304
  registerTldrawLibraryVersion(
305
305
  "@tldraw/editor",
306
- "3.13.0-canary.d403fcffd1eb",
306
+ "3.13.0-canary.dc099cf30823",
307
307
  "esm"
308
308
  );
309
309
  export {
@@ -1381,8 +1381,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1381
1381
  return this.getCurrentPageState().selectedShapeIds;
1382
1382
  }
1383
1383
  getSelectedShapes() {
1384
- const { selectedShapeIds } = this.getCurrentPageState();
1385
- return compact(selectedShapeIds.map((id) => this.store.get(id)));
1384
+ return compact(this.getSelectedShapeIds().map((id) => this.store.get(id)));
1386
1385
  }
1387
1386
  /**
1388
1387
  * Select one or more shapes.
@@ -1984,12 +1983,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1984
1983
  }
1985
1984
  return baseCamera;
1986
1985
  }
1986
+ _getFollowingPresence(targetUserId) {
1987
+ const visited = [this.user.getId()];
1988
+ const collaborators = this.getCollaborators();
1989
+ let leaderPresence = null;
1990
+ while (targetUserId && !visited.includes(targetUserId)) {
1991
+ leaderPresence = collaborators.find((c) => c.userId === targetUserId) ?? null;
1992
+ targetUserId = leaderPresence?.followingUserId ?? null;
1993
+ if (leaderPresence) {
1994
+ visited.push(leaderPresence.userId);
1995
+ }
1996
+ }
1997
+ return leaderPresence;
1998
+ }
1987
1999
  getViewportPageBoundsForFollowing() {
1988
- const followingUserId = this.getInstanceState().followingUserId;
1989
- if (!followingUserId) return null;
1990
- const leaderPresence = this.getCollaborators().find((c) => c.userId === followingUserId);
1991
- if (!leaderPresence) return null;
1992
- if (!leaderPresence.camera || !leaderPresence.screenBounds) return null;
2000
+ const leaderPresence = this._getFollowingPresence(this.getInstanceState().followingUserId);
2001
+ if (!leaderPresence?.camera || !leaderPresence?.screenBounds) return null;
1993
2002
  const { w: lw, h: lh } = leaderPresence.screenBounds;
1994
2003
  const { x: lx, y: ly, z: lz } = leaderPresence.camera;
1995
2004
  const theirViewport = new Box(-lx, -ly, lw / lz, lh / lz);
@@ -2896,34 +2905,30 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2896
2905
  */
2897
2906
  startFollowingUser(userId) {
2898
2907
  this.stopFollowingUser();
2899
- const leaderPresences = this._getCollaboratorsQuery().get().filter((p) => p.userId === userId);
2900
- if (!leaderPresences.length) {
2901
- console.warn("User not found");
2902
- return this;
2903
- }
2904
2908
  const thisUserId = this.user.getId();
2905
2909
  if (!thisUserId) {
2906
2910
  console.warn("You should set the userId for the current instance before following a user");
2907
2911
  }
2908
- if (leaderPresences.some((p) => p.followingUserId === thisUserId)) {
2912
+ const leaderPresence = this._getFollowingPresence(userId);
2913
+ if (!leaderPresence) {
2909
2914
  return this;
2910
2915
  }
2911
2916
  const latestLeaderPresence = computed("latestLeaderPresence", () => {
2912
- return this.getCollaborators().find((p) => p.userId === userId);
2917
+ return this._getFollowingPresence(userId);
2913
2918
  });
2914
2919
  transact(() => {
2915
2920
  this.updateInstanceState({ followingUserId: userId }, { history: "ignore" });
2916
2921
  const dispose = react("update current page", () => {
2917
- const leaderPresence = latestLeaderPresence.get();
2918
- if (!leaderPresence) {
2922
+ const leaderPresence2 = latestLeaderPresence.get();
2923
+ if (!leaderPresence2) {
2919
2924
  this.stopFollowingUser();
2920
2925
  return;
2921
2926
  }
2922
- if (leaderPresence.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence.currentPageId)) {
2927
+ if (leaderPresence2.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence2.currentPageId)) {
2923
2928
  this.run(
2924
2929
  () => {
2925
2930
  this.store.put([
2926
- { ...this.getInstanceState(), currentPageId: leaderPresence.currentPageId }
2931
+ { ...this.getInstanceState(), currentPageId: leaderPresence2.currentPageId }
2927
2932
  ]);
2928
2933
  this._isLockedOnFollowingUser.set(true);
2929
2934
  },
@@ -2938,8 +2943,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2938
2943
  this.off("stop-following", cancel);
2939
2944
  };
2940
2945
  const moveTowardsUser = () => {
2941
- const leaderPresence = latestLeaderPresence.get();
2942
- if (!leaderPresence) {
2946
+ const leaderPresence2 = latestLeaderPresence.get();
2947
+ if (!leaderPresence2) {
2943
2948
  this.stopFollowingUser();
2944
2949
  return;
2945
2950
  }