@tldraw/editor 3.13.0-canary.a2884bb1bab2 → 3.13.0-canary.da15a0065ba5

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.a2884bb1bab2";
25
+ const version = "3.13.0-canary.da15a0065ba5";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-04-15T16:38:27.293Z",
29
- patch: "2025-04-15T16:38:27.293Z"
28
+ minor: "2025-04-17T09:56:11.498Z",
29
+ patch: "2025-04-17T09:56:11.498Z"
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.a2884bb1bab2'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-15T16:38:27.293Z',\n\tpatch: '2025-04-15T16:38:27.293Z',\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.da15a0065ba5'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-04-17T09:56:11.498Z',\n\tpatch: '2025-04-17T09:56:11.498Z',\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.a2884bb1bab2",
306
+ "3.13.0-canary.da15a0065ba5",
307
307
  "esm"
308
308
  );
309
309
  export {
@@ -1984,12 +1984,22 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
1984
1984
  }
1985
1985
  return baseCamera;
1986
1986
  }
1987
+ _getFollowingPresence(targetUserId) {
1988
+ const visited = [this.user.getId()];
1989
+ const collaborators = this.getCollaborators();
1990
+ let leaderPresence = null;
1991
+ while (targetUserId && !visited.includes(targetUserId)) {
1992
+ leaderPresence = collaborators.find((c) => c.userId === targetUserId) ?? null;
1993
+ targetUserId = leaderPresence?.followingUserId ?? null;
1994
+ if (leaderPresence) {
1995
+ visited.push(leaderPresence.userId);
1996
+ }
1997
+ }
1998
+ return leaderPresence;
1999
+ }
1987
2000
  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;
2001
+ const leaderPresence = this._getFollowingPresence(this.getInstanceState().followingUserId);
2002
+ if (!leaderPresence?.camera || !leaderPresence?.screenBounds) return null;
1993
2003
  const { w: lw, h: lh } = leaderPresence.screenBounds;
1994
2004
  const { x: lx, y: ly, z: lz } = leaderPresence.camera;
1995
2005
  const theirViewport = new Box(-lx, -ly, lw / lz, lh / lz);
@@ -2896,34 +2906,30 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2896
2906
  */
2897
2907
  startFollowingUser(userId) {
2898
2908
  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
2909
  const thisUserId = this.user.getId();
2905
2910
  if (!thisUserId) {
2906
2911
  console.warn("You should set the userId for the current instance before following a user");
2907
2912
  }
2908
- if (leaderPresences.some((p) => p.followingUserId === thisUserId)) {
2913
+ const leaderPresence = this._getFollowingPresence(userId);
2914
+ if (!leaderPresence) {
2909
2915
  return this;
2910
2916
  }
2911
2917
  const latestLeaderPresence = computed("latestLeaderPresence", () => {
2912
- return this.getCollaborators().find((p) => p.userId === userId);
2918
+ return this._getFollowingPresence(userId);
2913
2919
  });
2914
2920
  transact(() => {
2915
2921
  this.updateInstanceState({ followingUserId: userId }, { history: "ignore" });
2916
2922
  const dispose = react("update current page", () => {
2917
- const leaderPresence = latestLeaderPresence.get();
2918
- if (!leaderPresence) {
2923
+ const leaderPresence2 = latestLeaderPresence.get();
2924
+ if (!leaderPresence2) {
2919
2925
  this.stopFollowingUser();
2920
2926
  return;
2921
2927
  }
2922
- if (leaderPresence.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence.currentPageId)) {
2928
+ if (leaderPresence2.currentPageId !== this.getCurrentPageId() && this.getPage(leaderPresence2.currentPageId)) {
2923
2929
  this.run(
2924
2930
  () => {
2925
2931
  this.store.put([
2926
- { ...this.getInstanceState(), currentPageId: leaderPresence.currentPageId }
2932
+ { ...this.getInstanceState(), currentPageId: leaderPresence2.currentPageId }
2927
2933
  ]);
2928
2934
  this._isLockedOnFollowingUser.set(true);
2929
2935
  },
@@ -2938,8 +2944,8 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
2938
2944
  this.off("stop-following", cancel);
2939
2945
  };
2940
2946
  const moveTowardsUser = () => {
2941
- const leaderPresence = latestLeaderPresence.get();
2942
- if (!leaderPresence) {
2947
+ const leaderPresence2 = latestLeaderPresence.get();
2948
+ if (!leaderPresence2) {
2943
2949
  this.stopFollowingUser();
2944
2950
  return;
2945
2951
  }