@tldraw/editor 4.6.0-canary.9f8f5f13d2db → 4.6.0-canary.a034dd0dfdbd
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-cjs/index.d.ts +80 -8
- package/dist-cjs/index.js +4 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +17 -14
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +58 -48
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +98 -0
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +49 -68
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +2 -2
- package/dist-cjs/lib/exports/fetchCache.js +1 -1
- package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +80 -8
- package/dist-esm/index.mjs +6 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +17 -14
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +58 -52
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +83 -0
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +49 -68
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +2 -0
- package/src/lib/components/default-components/DefaultCanvas.tsx +19 -14
- package/src/lib/editor/Editor.ts +33 -43
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +98 -0
- package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +80 -94
- package/src/lib/exports/fetchCache.ts +2 -4
- package/src/lib/utils/sync/TLLocalSyncClient.ts +3 -0
- package/src/version.ts +3 -3
|
@@ -65,7 +65,6 @@ var import_utils2 = require("../primitives/utils");
|
|
|
65
65
|
var import_Vec = require("../primitives/Vec");
|
|
66
66
|
var import_areShapesContentEqual = require("../utils/areShapesContentEqual");
|
|
67
67
|
var import_assets = require("../utils/assets");
|
|
68
|
-
var import_collaboratorState = require("../utils/collaboratorState");
|
|
69
68
|
var import_debug_flags = require("../utils/debug-flags");
|
|
70
69
|
var import_deepLinks = require("../utils/deepLinks");
|
|
71
70
|
var import_getIncrementedName = require("../utils/getIncrementedName");
|
|
@@ -78,6 +77,7 @@ var import_notVisibleShapes = require("./derivations/notVisibleShapes");
|
|
|
78
77
|
var import_parentsToChildren = require("./derivations/parentsToChildren");
|
|
79
78
|
var import_shapeIdsInCurrentPage = require("./derivations/shapeIdsInCurrentPage");
|
|
80
79
|
var import_ClickManager = require("./managers/ClickManager/ClickManager");
|
|
80
|
+
var import_CollaboratorsManager = require("./managers/CollaboratorsManager/CollaboratorsManager");
|
|
81
81
|
var import_EdgeScrollManager = require("./managers/EdgeScrollManager/EdgeScrollManager");
|
|
82
82
|
var import_FocusManager = require("./managers/FocusManager/FocusManager");
|
|
83
83
|
var import_FontManager = require("./managers/FontManager/FontManager");
|
|
@@ -161,9 +161,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
161
161
|
this.inputs = new import_InputsManager.InputsManager(this);
|
|
162
162
|
this.performance = new import_PerformanceManager.PerformanceManager(this);
|
|
163
163
|
this.disposables.add(() => this.performance.dispose());
|
|
164
|
-
this.
|
|
165
|
-
this._collaboratorVisibilityClock.set(Date.now());
|
|
166
|
-
}, this.options.collaboratorCheckIntervalMs);
|
|
164
|
+
this.collaborators = new import_CollaboratorsManager.CollaboratorsManager(this);
|
|
167
165
|
class NewRoot extends import_RootState.RootState {
|
|
168
166
|
static initial = initialState ?? "";
|
|
169
167
|
}
|
|
@@ -683,8 +681,12 @@ class Editor extends import_eventemitter3.default {
|
|
|
683
681
|
* @public
|
|
684
682
|
*/
|
|
685
683
|
timers = import_time.tltime.forContext(this.contextId);
|
|
686
|
-
/**
|
|
687
|
-
|
|
684
|
+
/**
|
|
685
|
+
* A manager for remote peer collaborators connected to this editor.
|
|
686
|
+
*
|
|
687
|
+
* @public
|
|
688
|
+
*/
|
|
689
|
+
collaborators;
|
|
688
690
|
/**
|
|
689
691
|
* A manager for the user and their preferences.
|
|
690
692
|
*
|
|
@@ -1369,11 +1371,20 @@ class Editor extends import_eventemitter3.default {
|
|
|
1369
1371
|
/**
|
|
1370
1372
|
* Set the cursor.
|
|
1371
1373
|
*
|
|
1374
|
+
* No-op when the partial wouldn't change the current cursor — `setCursor`
|
|
1375
|
+
* is called from pointer-move hot paths (see `updateHoveredOverlayId`,
|
|
1376
|
+
* various tool states) and skipping redundant writes avoids needlessly
|
|
1377
|
+
* dirtying instance state.
|
|
1378
|
+
*
|
|
1372
1379
|
* @param cursor - The cursor to set.
|
|
1373
1380
|
* @public
|
|
1374
1381
|
*/
|
|
1375
1382
|
setCursor(cursor) {
|
|
1376
|
-
|
|
1383
|
+
const current = this.getInstanceState().cursor;
|
|
1384
|
+
if ((cursor.type === void 0 || cursor.type === current.type) && (cursor.rotation === void 0 || cursor.rotation === current.rotation)) {
|
|
1385
|
+
return this;
|
|
1386
|
+
}
|
|
1387
|
+
this.updateInstanceState({ cursor: { ...current, ...cursor } });
|
|
1377
1388
|
return this;
|
|
1378
1389
|
}
|
|
1379
1390
|
getPageStates() {
|
|
@@ -3039,39 +3050,53 @@ class Editor extends import_eventemitter3.default {
|
|
|
3039
3050
|
const { x: cx, y: cy, z: cz = 1 } = this.getCamera();
|
|
3040
3051
|
return new import_Vec.Vec((point.x + cx) * cz, (point.y + cy) * cz, point.z ?? 0.5);
|
|
3041
3052
|
}
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3053
|
+
// Collaborators
|
|
3054
|
+
/**
|
|
3055
|
+
* Returns a list of presence records for all peer collaborators.
|
|
3056
|
+
* This will return the latest presence record for each connected user.
|
|
3057
|
+
*
|
|
3058
|
+
* Convenience wrapper for {@link CollaboratorsManager.getCollaborators}.
|
|
3059
|
+
*
|
|
3060
|
+
* @public
|
|
3061
|
+
*/
|
|
3047
3062
|
getCollaborators() {
|
|
3048
|
-
|
|
3049
|
-
if (!allPresenceRecords.length) return import_state.EMPTY_ARRAY;
|
|
3050
|
-
const userIds = [...new Set(allPresenceRecords.map((c) => c.userId))].sort();
|
|
3051
|
-
return userIds.map((id) => {
|
|
3052
|
-
const latestPresence = (0, import_utils.maxBy)(
|
|
3053
|
-
allPresenceRecords.filter((c) => c.userId === id),
|
|
3054
|
-
(p) => p.lastActivityTimestamp ?? 0
|
|
3055
|
-
);
|
|
3056
|
-
return latestPresence;
|
|
3057
|
-
});
|
|
3063
|
+
return this.collaborators.getCollaborators();
|
|
3058
3064
|
}
|
|
3065
|
+
/**
|
|
3066
|
+
* Returns a list of presence records for all peer collaborators on the current page.
|
|
3067
|
+
* This will return the latest presence record for each connected user.
|
|
3068
|
+
*
|
|
3069
|
+
* Convenience wrapper for {@link CollaboratorsManager.getCollaboratorsOnCurrentPage}.
|
|
3070
|
+
*
|
|
3071
|
+
* @public
|
|
3072
|
+
*/
|
|
3059
3073
|
getCollaboratorsOnCurrentPage() {
|
|
3060
|
-
|
|
3061
|
-
return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
|
|
3074
|
+
return this.collaborators.getCollaboratorsOnCurrentPage();
|
|
3062
3075
|
}
|
|
3076
|
+
/**
|
|
3077
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
3078
|
+
* shown in the UI. Filters {@link Editor.getCollaborators} by activity state
|
|
3079
|
+
* (active / idle / inactive) and visibility rules such as following and highlighted
|
|
3080
|
+
* users. Re-evaluates on the collaborator visibility clock, so callers don't need to
|
|
3081
|
+
* drive their own activity timer.
|
|
3082
|
+
*
|
|
3083
|
+
* Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaborators}.
|
|
3084
|
+
*
|
|
3085
|
+
* @public
|
|
3086
|
+
*/
|
|
3063
3087
|
getVisibleCollaborators() {
|
|
3064
|
-
this.
|
|
3065
|
-
const now = Date.now();
|
|
3066
|
-
return this.getCollaborators().filter((presence) => {
|
|
3067
|
-
const elapsed = Math.max(0, now - (presence.lastActivityTimestamp ?? Infinity));
|
|
3068
|
-
const state = (0, import_collaboratorState.getCollaboratorStateFromElapsedTime)(this, elapsed);
|
|
3069
|
-
return (0, import_collaboratorState.shouldShowCollaborator)(this, presence, state);
|
|
3070
|
-
});
|
|
3088
|
+
return this.collaborators.getVisibleCollaborators();
|
|
3071
3089
|
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Returns a list of presence records for peer collaborators who should currently be
|
|
3092
|
+
* shown in the UI, filtered to those on the current page.
|
|
3093
|
+
*
|
|
3094
|
+
* Convenience wrapper for {@link CollaboratorsManager.getVisibleCollaboratorsOnCurrentPage}.
|
|
3095
|
+
*
|
|
3096
|
+
* @public
|
|
3097
|
+
*/
|
|
3072
3098
|
getVisibleCollaboratorsOnCurrentPage() {
|
|
3073
|
-
|
|
3074
|
-
return this.getVisibleCollaborators().filter((c) => c.currentPageId === currentPageId);
|
|
3099
|
+
return this.collaborators.getVisibleCollaboratorsOnCurrentPage();
|
|
3075
3100
|
}
|
|
3076
3101
|
// Attribution
|
|
3077
3102
|
/**
|
|
@@ -8422,21 +8447,6 @@ __decorateClass([
|
|
|
8422
8447
|
__decorateClass([
|
|
8423
8448
|
import_state.computed
|
|
8424
8449
|
], Editor.prototype, "getViewportPageBounds", 1);
|
|
8425
|
-
__decorateClass([
|
|
8426
|
-
import_state.computed
|
|
8427
|
-
], Editor.prototype, "_getCollaboratorsQuery", 1);
|
|
8428
|
-
__decorateClass([
|
|
8429
|
-
import_state.computed
|
|
8430
|
-
], Editor.prototype, "getCollaborators", 1);
|
|
8431
|
-
__decorateClass([
|
|
8432
|
-
import_state.computed
|
|
8433
|
-
], Editor.prototype, "getCollaboratorsOnCurrentPage", 1);
|
|
8434
|
-
__decorateClass([
|
|
8435
|
-
import_state.computed
|
|
8436
|
-
], Editor.prototype, "getVisibleCollaborators", 1);
|
|
8437
|
-
__decorateClass([
|
|
8438
|
-
import_state.computed
|
|
8439
|
-
], Editor.prototype, "getVisibleCollaboratorsOnCurrentPage", 1);
|
|
8440
8450
|
__decorateClass([
|
|
8441
8451
|
import_state.computed
|
|
8442
8452
|
], Editor.prototype, "getRenderingShapes", 1);
|