@tldraw/editor 3.14.0-canary.8d29afff2d04 → 3.14.0-canary.ba221e7baf33

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.js CHANGED
@@ -361,7 +361,7 @@ function debugEnableLicensing() {
361
361
  }
362
362
  (0, import_utils.registerTldrawLibraryVersion)(
363
363
  "@tldraw/editor",
364
- "3.14.0-canary.8d29afff2d04",
364
+ "3.14.0-canary.ba221e7baf33",
365
365
  "cjs"
366
366
  );
367
367
  //# sourceMappingURL=index.js.map
@@ -22,28 +22,24 @@ __export(notVisibleShapes_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(notVisibleShapes_exports);
24
24
  var import_state = require("@tldraw/state");
25
- function isShapeNotVisible(editor, id, viewportPageBounds) {
26
- const maskedPageBounds = editor.getShapeMaskedPageBounds(id);
27
- if (maskedPageBounds === void 0) return true;
28
- return !viewportPageBounds.includes(maskedPageBounds);
25
+ function fromScratch(editor) {
26
+ const shapesIds = editor.getCurrentPageShapeIds();
27
+ const viewportPageBounds = editor.getViewportPageBounds();
28
+ const notVisibleShapes2 = /* @__PURE__ */ new Set();
29
+ shapesIds.forEach((id) => {
30
+ const pageBounds = editor.getShapePageBounds(id);
31
+ if (pageBounds === void 0 || !viewportPageBounds.includes(pageBounds)) {
32
+ notVisibleShapes2.add(id);
33
+ }
34
+ });
35
+ return notVisibleShapes2;
29
36
  }
30
- const notVisibleShapes = (editor) => {
31
- function fromScratch(editor2) {
32
- const shapes = editor2.getCurrentPageShapeIds();
33
- const viewportPageBounds = editor2.getViewportPageBounds();
34
- const notVisibleShapes2 = /* @__PURE__ */ new Set();
35
- shapes.forEach((id) => {
36
- if (isShapeNotVisible(editor2, id, viewportPageBounds)) {
37
- notVisibleShapes2.add(id);
38
- }
39
- });
40
- return notVisibleShapes2;
41
- }
42
- return (0, import_state.computed)("notVisibleShapes", (prevValue) => {
37
+ function notVisibleShapes(editor) {
38
+ return (0, import_state.computed)("notVisibleShapes", function updateNotVisibleShapes(prevValue) {
39
+ const nextValue = fromScratch(editor);
43
40
  if ((0, import_state.isUninitialized)(prevValue)) {
44
- return fromScratch(editor);
41
+ return nextValue;
45
42
  }
46
- const nextValue = fromScratch(editor);
47
43
  if (prevValue.size !== nextValue.size) return nextValue;
48
44
  for (const prev of prevValue) {
49
45
  if (!nextValue.has(prev)) {
@@ -52,5 +48,5 @@ const notVisibleShapes = (editor) => {
52
48
  }
53
49
  return prevValue;
54
50
  });
55
- };
51
+ }
56
52
  //# sourceMappingURL=notVisibleShapes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/editor/derivations/notVisibleShapes.ts"],
4
- "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShapeId } from '@tldraw/tlschema'\nimport { Box } from '../../primitives/Box'\nimport { Editor } from '../Editor'\n\nfunction isShapeNotVisible(editor: Editor, id: TLShapeId, viewportPageBounds: Box): boolean {\n\tconst maskedPageBounds = editor.getShapeMaskedPageBounds(id)\n\t// if the shape is fully outside of its parent's clipping bounds...\n\tif (maskedPageBounds === undefined) return true\n\n\t// if the shape is fully outside of the viewport page bounds...\n\treturn !viewportPageBounds.includes(maskedPageBounds)\n}\n\n/**\n * Incremental derivation of not visible shapes.\n * Non visible shapes are shapes outside of the viewport page bounds and shapes outside of parent's clipping bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport const notVisibleShapes = (editor: Editor) => {\n\tfunction fromScratch(editor: Editor): Set<TLShapeId> {\n\t\tconst shapes = editor.getCurrentPageShapeIds()\n\t\tconst viewportPageBounds = editor.getViewportPageBounds()\n\t\tconst notVisibleShapes = new Set<TLShapeId>()\n\t\tshapes.forEach((id) => {\n\t\t\tif (isShapeNotVisible(editor, id, viewportPageBounds)) {\n\t\t\t\tnotVisibleShapes.add(id)\n\t\t\t}\n\t\t})\n\t\treturn notVisibleShapes\n\t}\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', (prevValue) => {\n\t\tif (isUninitialized(prevValue)) {\n\t\t\treturn fromScratch(editor)\n\t\t}\n\n\t\tconst nextValue = fromScratch(editor)\n\n\t\tif (prevValue.size !== nextValue.size) return nextValue\n\t\tfor (const prev of prevValue) {\n\t\t\tif (!nextValue.has(prev)) {\n\t\t\t\treturn nextValue\n\t\t\t}\n\t\t}\n\t\treturn prevValue\n\t})\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAK1C,SAAS,kBAAkB,QAAgB,IAAe,oBAAkC;AAC3F,QAAM,mBAAmB,OAAO,yBAAyB,EAAE;AAE3D,MAAI,qBAAqB,OAAW,QAAO;AAG3C,SAAO,CAAC,mBAAmB,SAAS,gBAAgB;AACrD;AASO,MAAM,mBAAmB,CAAC,WAAmB;AACnD,WAAS,YAAYA,SAAgC;AACpD,UAAM,SAASA,QAAO,uBAAuB;AAC7C,UAAM,qBAAqBA,QAAO,sBAAsB;AACxD,UAAMC,oBAAmB,oBAAI,IAAe;AAC5C,WAAO,QAAQ,CAAC,OAAO;AACtB,UAAI,kBAAkBD,SAAQ,IAAI,kBAAkB,GAAG;AACtD,QAAAC,kBAAiB,IAAI,EAAE;AAAA,MACxB;AAAA,IACD,CAAC;AACD,WAAOA;AAAA,EACR;AACA,aAAO,uBAAyB,oBAAoB,CAAC,cAAc;AAClE,YAAI,8BAAgB,SAAS,GAAG;AAC/B,aAAO,YAAY,MAAM;AAAA,IAC1B;AAEA,UAAM,YAAY,YAAY,MAAM;AAEpC,QAAI,UAAU,SAAS,UAAU,KAAM,QAAO;AAC9C,eAAW,QAAQ,WAAW;AAC7B,UAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACzB,eAAO;AAAA,MACR;AAAA,IACD;AACA,WAAO;AAAA,EACR,CAAC;AACF;",
6
- "names": ["editor", "notVisibleShapes"]
4
+ "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShapeId } from '@tldraw/tlschema'\nimport { Editor } from '../Editor'\n\nfunction fromScratch(editor: Editor): Set<TLShapeId> {\n\tconst shapesIds = editor.getCurrentPageShapeIds()\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tconst notVisibleShapes = new Set<TLShapeId>()\n\tshapesIds.forEach((id) => {\n\t\t// If the shape is fully outside of the viewport page bounds, add it to the set.\n\t\t// We'll ignore masks here, since they're more expensive to compute and the overhead is not worth it.\n\t\tconst pageBounds = editor.getShapePageBounds(id)\n\t\tif (pageBounds === undefined || !viewportPageBounds.includes(pageBounds)) {\n\t\t\tnotVisibleShapes.add(id)\n\t\t}\n\t})\n\treturn notVisibleShapes\n}\n\n/**\n * Incremental derivation of not visible shapes.\n * Non visible shapes are shapes outside of the viewport page bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport function notVisibleShapes(editor: Editor) {\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', function updateNotVisibleShapes(prevValue) {\n\t\tconst nextValue = fromScratch(editor)\n\n\t\tif (isUninitialized(prevValue)) {\n\t\t\treturn nextValue\n\t\t}\n\n\t\t// If there are more or less shapes, we know there's a change\n\t\tif (prevValue.size !== nextValue.size) return nextValue\n\n\t\t// If any of the old shapes are not in the new set, we know there's a change\n\t\tfor (const prev of prevValue) {\n\t\t\tif (!nextValue.has(prev)) {\n\t\t\t\treturn nextValue\n\t\t\t}\n\t\t}\n\n\t\t// If we've made it here, we know that the set is the same\n\t\treturn prevValue\n\t})\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0C;AAI1C,SAAS,YAAY,QAAgC;AACpD,QAAM,YAAY,OAAO,uBAAuB;AAChD,QAAM,qBAAqB,OAAO,sBAAsB;AACxD,QAAMA,oBAAmB,oBAAI,IAAe;AAC5C,YAAU,QAAQ,CAAC,OAAO;AAGzB,UAAM,aAAa,OAAO,mBAAmB,EAAE;AAC/C,QAAI,eAAe,UAAa,CAAC,mBAAmB,SAAS,UAAU,GAAG;AACzE,MAAAA,kBAAiB,IAAI,EAAE;AAAA,IACxB;AAAA,EACD,CAAC;AACD,SAAOA;AACR;AASO,SAAS,iBAAiB,QAAgB;AAChD,aAAO,uBAAyB,oBAAoB,SAAS,uBAAuB,WAAW;AAC9F,UAAM,YAAY,YAAY,MAAM;AAEpC,YAAI,8BAAgB,SAAS,GAAG;AAC/B,aAAO;AAAA,IACR;AAGA,QAAI,UAAU,SAAS,UAAU,KAAM,QAAO;AAG9C,eAAW,QAAQ,WAAW;AAC7B,UAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACzB,eAAO;AAAA,MACR;AAAA,IACD;AAGA,WAAO;AAAA,EACR,CAAC;AACF;",
6
+ "names": ["notVisibleShapes"]
7
7
  }
@@ -22,10 +22,10 @@ __export(version_exports, {
22
22
  version: () => version
23
23
  });
24
24
  module.exports = __toCommonJS(version_exports);
25
- const version = "3.14.0-canary.8d29afff2d04";
25
+ const version = "3.14.0-canary.ba221e7baf33";
26
26
  const publishDates = {
27
27
  major: "2024-09-13T14:36:29.063Z",
28
- minor: "2025-05-27T13:18:08.385Z",
29
- patch: "2025-05-27T13:18:08.385Z"
28
+ minor: "2025-05-27T13:19:01.528Z",
29
+ patch: "2025-05-27T13:19:01.528Z"
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.14.0-canary.8d29afff2d04'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-27T13:18:08.385Z',\n\tpatch: '2025-05-27T13:18:08.385Z',\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.14.0-canary.ba221e7baf33'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-27T13:19:01.528Z',\n\tpatch: '2025-05-27T13:19:01.528Z',\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
  }
@@ -288,7 +288,7 @@ function debugEnableLicensing() {
288
288
  }
289
289
  registerTldrawLibraryVersion(
290
290
  "@tldraw/editor",
291
- "3.14.0-canary.8d29afff2d04",
291
+ "3.14.0-canary.ba221e7baf33",
292
292
  "esm"
293
293
  );
294
294
  export {
@@ -1,26 +1,22 @@
1
1
  import { computed, isUninitialized } from "@tldraw/state";
2
- function isShapeNotVisible(editor, id, viewportPageBounds) {
3
- const maskedPageBounds = editor.getShapeMaskedPageBounds(id);
4
- if (maskedPageBounds === void 0) return true;
5
- return !viewportPageBounds.includes(maskedPageBounds);
2
+ function fromScratch(editor) {
3
+ const shapesIds = editor.getCurrentPageShapeIds();
4
+ const viewportPageBounds = editor.getViewportPageBounds();
5
+ const notVisibleShapes2 = /* @__PURE__ */ new Set();
6
+ shapesIds.forEach((id) => {
7
+ const pageBounds = editor.getShapePageBounds(id);
8
+ if (pageBounds === void 0 || !viewportPageBounds.includes(pageBounds)) {
9
+ notVisibleShapes2.add(id);
10
+ }
11
+ });
12
+ return notVisibleShapes2;
6
13
  }
7
- const notVisibleShapes = (editor) => {
8
- function fromScratch(editor2) {
9
- const shapes = editor2.getCurrentPageShapeIds();
10
- const viewportPageBounds = editor2.getViewportPageBounds();
11
- const notVisibleShapes2 = /* @__PURE__ */ new Set();
12
- shapes.forEach((id) => {
13
- if (isShapeNotVisible(editor2, id, viewportPageBounds)) {
14
- notVisibleShapes2.add(id);
15
- }
16
- });
17
- return notVisibleShapes2;
18
- }
19
- return computed("notVisibleShapes", (prevValue) => {
14
+ function notVisibleShapes(editor) {
15
+ return computed("notVisibleShapes", function updateNotVisibleShapes(prevValue) {
16
+ const nextValue = fromScratch(editor);
20
17
  if (isUninitialized(prevValue)) {
21
- return fromScratch(editor);
18
+ return nextValue;
22
19
  }
23
- const nextValue = fromScratch(editor);
24
20
  if (prevValue.size !== nextValue.size) return nextValue;
25
21
  for (const prev of prevValue) {
26
22
  if (!nextValue.has(prev)) {
@@ -29,7 +25,7 @@ const notVisibleShapes = (editor) => {
29
25
  }
30
26
  return prevValue;
31
27
  });
32
- };
28
+ }
33
29
  export {
34
30
  notVisibleShapes
35
31
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/editor/derivations/notVisibleShapes.ts"],
4
- "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShapeId } from '@tldraw/tlschema'\nimport { Box } from '../../primitives/Box'\nimport { Editor } from '../Editor'\n\nfunction isShapeNotVisible(editor: Editor, id: TLShapeId, viewportPageBounds: Box): boolean {\n\tconst maskedPageBounds = editor.getShapeMaskedPageBounds(id)\n\t// if the shape is fully outside of its parent's clipping bounds...\n\tif (maskedPageBounds === undefined) return true\n\n\t// if the shape is fully outside of the viewport page bounds...\n\treturn !viewportPageBounds.includes(maskedPageBounds)\n}\n\n/**\n * Incremental derivation of not visible shapes.\n * Non visible shapes are shapes outside of the viewport page bounds and shapes outside of parent's clipping bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport const notVisibleShapes = (editor: Editor) => {\n\tfunction fromScratch(editor: Editor): Set<TLShapeId> {\n\t\tconst shapes = editor.getCurrentPageShapeIds()\n\t\tconst viewportPageBounds = editor.getViewportPageBounds()\n\t\tconst notVisibleShapes = new Set<TLShapeId>()\n\t\tshapes.forEach((id) => {\n\t\t\tif (isShapeNotVisible(editor, id, viewportPageBounds)) {\n\t\t\t\tnotVisibleShapes.add(id)\n\t\t\t}\n\t\t})\n\t\treturn notVisibleShapes\n\t}\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', (prevValue) => {\n\t\tif (isUninitialized(prevValue)) {\n\t\t\treturn fromScratch(editor)\n\t\t}\n\n\t\tconst nextValue = fromScratch(editor)\n\n\t\tif (prevValue.size !== nextValue.size) return nextValue\n\t\tfor (const prev of prevValue) {\n\t\t\tif (!nextValue.has(prev)) {\n\t\t\t\treturn nextValue\n\t\t\t}\n\t\t}\n\t\treturn prevValue\n\t})\n}\n"],
5
- "mappings": "AAAA,SAAS,UAAU,uBAAuB;AAK1C,SAAS,kBAAkB,QAAgB,IAAe,oBAAkC;AAC3F,QAAM,mBAAmB,OAAO,yBAAyB,EAAE;AAE3D,MAAI,qBAAqB,OAAW,QAAO;AAG3C,SAAO,CAAC,mBAAmB,SAAS,gBAAgB;AACrD;AASO,MAAM,mBAAmB,CAAC,WAAmB;AACnD,WAAS,YAAYA,SAAgC;AACpD,UAAM,SAASA,QAAO,uBAAuB;AAC7C,UAAM,qBAAqBA,QAAO,sBAAsB;AACxD,UAAMC,oBAAmB,oBAAI,IAAe;AAC5C,WAAO,QAAQ,CAAC,OAAO;AACtB,UAAI,kBAAkBD,SAAQ,IAAI,kBAAkB,GAAG;AACtD,QAAAC,kBAAiB,IAAI,EAAE;AAAA,MACxB;AAAA,IACD,CAAC;AACD,WAAOA;AAAA,EACR;AACA,SAAO,SAAyB,oBAAoB,CAAC,cAAc;AAClE,QAAI,gBAAgB,SAAS,GAAG;AAC/B,aAAO,YAAY,MAAM;AAAA,IAC1B;AAEA,UAAM,YAAY,YAAY,MAAM;AAEpC,QAAI,UAAU,SAAS,UAAU,KAAM,QAAO;AAC9C,eAAW,QAAQ,WAAW;AAC7B,UAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACzB,eAAO;AAAA,MACR;AAAA,IACD;AACA,WAAO;AAAA,EACR,CAAC;AACF;",
6
- "names": ["editor", "notVisibleShapes"]
4
+ "sourcesContent": ["import { computed, isUninitialized } from '@tldraw/state'\nimport { TLShapeId } from '@tldraw/tlschema'\nimport { Editor } from '../Editor'\n\nfunction fromScratch(editor: Editor): Set<TLShapeId> {\n\tconst shapesIds = editor.getCurrentPageShapeIds()\n\tconst viewportPageBounds = editor.getViewportPageBounds()\n\tconst notVisibleShapes = new Set<TLShapeId>()\n\tshapesIds.forEach((id) => {\n\t\t// If the shape is fully outside of the viewport page bounds, add it to the set.\n\t\t// We'll ignore masks here, since they're more expensive to compute and the overhead is not worth it.\n\t\tconst pageBounds = editor.getShapePageBounds(id)\n\t\tif (pageBounds === undefined || !viewportPageBounds.includes(pageBounds)) {\n\t\t\tnotVisibleShapes.add(id)\n\t\t}\n\t})\n\treturn notVisibleShapes\n}\n\n/**\n * Incremental derivation of not visible shapes.\n * Non visible shapes are shapes outside of the viewport page bounds.\n *\n * @param editor - Instance of the tldraw Editor.\n * @returns Incremental derivation of non visible shapes.\n */\nexport function notVisibleShapes(editor: Editor) {\n\treturn computed<Set<TLShapeId>>('notVisibleShapes', function updateNotVisibleShapes(prevValue) {\n\t\tconst nextValue = fromScratch(editor)\n\n\t\tif (isUninitialized(prevValue)) {\n\t\t\treturn nextValue\n\t\t}\n\n\t\t// If there are more or less shapes, we know there's a change\n\t\tif (prevValue.size !== nextValue.size) return nextValue\n\n\t\t// If any of the old shapes are not in the new set, we know there's a change\n\t\tfor (const prev of prevValue) {\n\t\t\tif (!nextValue.has(prev)) {\n\t\t\t\treturn nextValue\n\t\t\t}\n\t\t}\n\n\t\t// If we've made it here, we know that the set is the same\n\t\treturn prevValue\n\t})\n}\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,uBAAuB;AAI1C,SAAS,YAAY,QAAgC;AACpD,QAAM,YAAY,OAAO,uBAAuB;AAChD,QAAM,qBAAqB,OAAO,sBAAsB;AACxD,QAAMA,oBAAmB,oBAAI,IAAe;AAC5C,YAAU,QAAQ,CAAC,OAAO;AAGzB,UAAM,aAAa,OAAO,mBAAmB,EAAE;AAC/C,QAAI,eAAe,UAAa,CAAC,mBAAmB,SAAS,UAAU,GAAG;AACzE,MAAAA,kBAAiB,IAAI,EAAE;AAAA,IACxB;AAAA,EACD,CAAC;AACD,SAAOA;AACR;AASO,SAAS,iBAAiB,QAAgB;AAChD,SAAO,SAAyB,oBAAoB,SAAS,uBAAuB,WAAW;AAC9F,UAAM,YAAY,YAAY,MAAM;AAEpC,QAAI,gBAAgB,SAAS,GAAG;AAC/B,aAAO;AAAA,IACR;AAGA,QAAI,UAAU,SAAS,UAAU,KAAM,QAAO;AAG9C,eAAW,QAAQ,WAAW;AAC7B,UAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACzB,eAAO;AAAA,MACR;AAAA,IACD;AAGA,WAAO;AAAA,EACR,CAAC;AACF;",
6
+ "names": ["notVisibleShapes"]
7
7
  }
@@ -1,8 +1,8 @@
1
- const version = "3.14.0-canary.8d29afff2d04";
1
+ const version = "3.14.0-canary.ba221e7baf33";
2
2
  const publishDates = {
3
3
  major: "2024-09-13T14:36:29.063Z",
4
- minor: "2025-05-27T13:18:08.385Z",
5
- patch: "2025-05-27T13:18:08.385Z"
4
+ minor: "2025-05-27T13:19:01.528Z",
5
+ patch: "2025-05-27T13:19:01.528Z"
6
6
  };
7
7
  export {
8
8
  publishDates,
@@ -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.14.0-canary.8d29afff2d04'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-27T13:18:08.385Z',\n\tpatch: '2025-05-27T13:18:08.385Z',\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.14.0-canary.ba221e7baf33'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-05-27T13:19:01.528Z',\n\tpatch: '2025-05-27T13:19:01.528Z',\n}\n"],
5
5
  "mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tldraw/editor",
3
3
  "description": "A tiny little drawing app (editor).",
4
- "version": "3.14.0-canary.8d29afff2d04",
4
+ "version": "3.14.0-canary.ba221e7baf33",
5
5
  "author": {
6
6
  "name": "tldraw Inc.",
7
7
  "email": "hello@tldraw.com"
@@ -48,12 +48,12 @@
48
48
  "@tiptap/core": "^2.9.1",
49
49
  "@tiptap/pm": "^2.9.1",
50
50
  "@tiptap/react": "^2.9.1",
51
- "@tldraw/state": "3.14.0-canary.8d29afff2d04",
52
- "@tldraw/state-react": "3.14.0-canary.8d29afff2d04",
53
- "@tldraw/store": "3.14.0-canary.8d29afff2d04",
54
- "@tldraw/tlschema": "3.14.0-canary.8d29afff2d04",
55
- "@tldraw/utils": "3.14.0-canary.8d29afff2d04",
56
- "@tldraw/validate": "3.14.0-canary.8d29afff2d04",
51
+ "@tldraw/state": "3.14.0-canary.ba221e7baf33",
52
+ "@tldraw/state-react": "3.14.0-canary.ba221e7baf33",
53
+ "@tldraw/store": "3.14.0-canary.ba221e7baf33",
54
+ "@tldraw/tlschema": "3.14.0-canary.ba221e7baf33",
55
+ "@tldraw/utils": "3.14.0-canary.ba221e7baf33",
56
+ "@tldraw/validate": "3.14.0-canary.ba221e7baf33",
57
57
  "@types/core-js": "^2.5.8",
58
58
  "@use-gesture/react": "^10.3.1",
59
59
  "classnames": "^2.5.1",
@@ -1,49 +1,48 @@
1
1
  import { computed, isUninitialized } from '@tldraw/state'
2
2
  import { TLShapeId } from '@tldraw/tlschema'
3
- import { Box } from '../../primitives/Box'
4
3
  import { Editor } from '../Editor'
5
4
 
6
- function isShapeNotVisible(editor: Editor, id: TLShapeId, viewportPageBounds: Box): boolean {
7
- const maskedPageBounds = editor.getShapeMaskedPageBounds(id)
8
- // if the shape is fully outside of its parent's clipping bounds...
9
- if (maskedPageBounds === undefined) return true
10
-
11
- // if the shape is fully outside of the viewport page bounds...
12
- return !viewportPageBounds.includes(maskedPageBounds)
5
+ function fromScratch(editor: Editor): Set<TLShapeId> {
6
+ const shapesIds = editor.getCurrentPageShapeIds()
7
+ const viewportPageBounds = editor.getViewportPageBounds()
8
+ const notVisibleShapes = new Set<TLShapeId>()
9
+ shapesIds.forEach((id) => {
10
+ // If the shape is fully outside of the viewport page bounds, add it to the set.
11
+ // We'll ignore masks here, since they're more expensive to compute and the overhead is not worth it.
12
+ const pageBounds = editor.getShapePageBounds(id)
13
+ if (pageBounds === undefined || !viewportPageBounds.includes(pageBounds)) {
14
+ notVisibleShapes.add(id)
15
+ }
16
+ })
17
+ return notVisibleShapes
13
18
  }
14
19
 
15
20
  /**
16
21
  * Incremental derivation of not visible shapes.
17
- * Non visible shapes are shapes outside of the viewport page bounds and shapes outside of parent's clipping bounds.
22
+ * Non visible shapes are shapes outside of the viewport page bounds.
18
23
  *
19
24
  * @param editor - Instance of the tldraw Editor.
20
25
  * @returns Incremental derivation of non visible shapes.
21
26
  */
22
- export const notVisibleShapes = (editor: Editor) => {
23
- function fromScratch(editor: Editor): Set<TLShapeId> {
24
- const shapes = editor.getCurrentPageShapeIds()
25
- const viewportPageBounds = editor.getViewportPageBounds()
26
- const notVisibleShapes = new Set<TLShapeId>()
27
- shapes.forEach((id) => {
28
- if (isShapeNotVisible(editor, id, viewportPageBounds)) {
29
- notVisibleShapes.add(id)
30
- }
31
- })
32
- return notVisibleShapes
33
- }
34
- return computed<Set<TLShapeId>>('notVisibleShapes', (prevValue) => {
27
+ export function notVisibleShapes(editor: Editor) {
28
+ return computed<Set<TLShapeId>>('notVisibleShapes', function updateNotVisibleShapes(prevValue) {
29
+ const nextValue = fromScratch(editor)
30
+
35
31
  if (isUninitialized(prevValue)) {
36
- return fromScratch(editor)
32
+ return nextValue
37
33
  }
38
34
 
39
- const nextValue = fromScratch(editor)
40
-
35
+ // If there are more or less shapes, we know there's a change
41
36
  if (prevValue.size !== nextValue.size) return nextValue
37
+
38
+ // If any of the old shapes are not in the new set, we know there's a change
42
39
  for (const prev of prevValue) {
43
40
  if (!nextValue.has(prev)) {
44
41
  return nextValue
45
42
  }
46
43
  }
44
+
45
+ // If we've made it here, we know that the set is the same
47
46
  return prevValue
48
47
  })
49
48
  }
package/src/version.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated by internal/scripts/refresh-assets.ts.
2
2
  // Do not edit manually. Or do, I'm a comment, not a cop.
3
3
 
4
- export const version = '3.14.0-canary.8d29afff2d04'
4
+ export const version = '3.14.0-canary.ba221e7baf33'
5
5
  export const publishDates = {
6
6
  major: '2024-09-13T14:36:29.063Z',
7
- minor: '2025-05-27T13:18:08.385Z',
8
- patch: '2025-05-27T13:18:08.385Z',
7
+ minor: '2025-05-27T13:19:01.528Z',
8
+ patch: '2025-05-27T13:19:01.528Z',
9
9
  }