@tldraw/editor 5.5.0-canary.ffd1e744a5b4 → 5.5.0-internal.a0bd7b4737ef

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.
Files changed (108) hide show
  1. package/dist-cjs/index.d.ts +47 -23
  2. package/dist-cjs/index.js +1 -1
  3. package/dist-cjs/index.js.map +2 -2
  4. package/dist-cjs/lib/TldrawEditor.js.map +2 -2
  5. package/dist-cjs/lib/components/default-components/DefaultCanvas.js +5 -1
  6. package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
  7. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +2 -5
  8. package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +3 -3
  9. package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +2 -2
  10. package/dist-cjs/lib/editor/Editor.js +32 -29
  11. package/dist-cjs/lib/editor/Editor.js.map +2 -2
  12. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +3 -2
  13. package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
  14. package/dist-cjs/lib/editor/managers/EditorManager.js +11 -2
  15. package/dist-cjs/lib/editor/managers/EditorManager.js.map +2 -2
  16. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +49 -63
  17. package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +2 -2
  18. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js +1 -1
  19. package/dist-cjs/lib/editor/managers/ScribbleManager/ScribbleManager.js.map +2 -2
  20. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +24 -24
  21. package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
  22. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +7 -1
  23. package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
  24. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +4 -3
  25. package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +2 -2
  26. package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
  27. package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
  28. package/dist-cjs/lib/utils/debug-flags.js +0 -6
  29. package/dist-cjs/lib/utils/debug-flags.js.map +2 -2
  30. package/dist-cjs/lib/utils/deepLinks.js +2 -1
  31. package/dist-cjs/lib/utils/deepLinks.js.map +2 -2
  32. package/dist-cjs/lib/utils/sync/LocalIndexedDb.js +19 -8
  33. package/dist-cjs/lib/utils/sync/LocalIndexedDb.js.map +2 -2
  34. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
  35. package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
  36. package/dist-cjs/version.js +3 -3
  37. package/dist-cjs/version.js.map +1 -1
  38. package/dist-esm/index.d.mts +47 -23
  39. package/dist-esm/index.mjs +4 -2
  40. package/dist-esm/index.mjs.map +2 -2
  41. package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
  42. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +5 -1
  43. package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
  44. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +2 -5
  45. package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +3 -3
  46. package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
  47. package/dist-esm/lib/editor/Editor.mjs +32 -29
  48. package/dist-esm/lib/editor/Editor.mjs.map +2 -2
  49. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +3 -2
  50. package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
  51. package/dist-esm/lib/editor/managers/EditorManager.mjs +11 -2
  52. package/dist-esm/lib/editor/managers/EditorManager.mjs.map +2 -2
  53. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +49 -63
  54. package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +2 -2
  55. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs +1 -1
  56. package/dist-esm/lib/editor/managers/ScribbleManager/ScribbleManager.mjs.map +2 -2
  57. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +24 -24
  58. package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
  59. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +7 -1
  60. package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
  61. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +4 -3
  62. package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +2 -2
  63. package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
  64. package/dist-esm/lib/utils/debug-flags.mjs +0 -6
  65. package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
  66. package/dist-esm/lib/utils/deepLinks.mjs +2 -1
  67. package/dist-esm/lib/utils/deepLinks.mjs.map +2 -2
  68. package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs +19 -8
  69. package/dist-esm/lib/utils/sync/LocalIndexedDb.mjs.map +2 -2
  70. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
  71. package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
  72. package/dist-esm/version.mjs +3 -3
  73. package/dist-esm/version.mjs.map +1 -1
  74. package/editor.css +9 -1
  75. package/package.json +17 -22
  76. package/src/index.ts +5 -1
  77. package/src/lib/TldrawEditor.tsx +8 -6
  78. package/src/lib/components/default-components/DefaultCanvas.tsx +7 -1
  79. package/src/lib/components/default-components/DefaultErrorFallback.tsx +13 -5
  80. package/src/lib/components/default-components/DefaultSpinner.tsx +4 -1
  81. package/src/lib/editor/Editor.test.ts +45 -0
  82. package/src/lib/editor/Editor.ts +53 -37
  83. package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +1 -0
  84. package/src/lib/editor/managers/ClickManager/ClickManager.ts +3 -2
  85. package/src/lib/editor/managers/EditorManager.test.ts +32 -1
  86. package/src/lib/editor/managers/EditorManager.ts +15 -3
  87. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +80 -0
  88. package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +54 -81
  89. package/src/lib/editor/managers/ScribbleManager/ScribbleManager.ts +1 -1
  90. package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +32 -36
  91. package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +13 -2
  92. package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +13 -0
  93. package/src/lib/editor/managers/SnapManager/SnapManager.ts +6 -4
  94. package/src/lib/editor/types/external-content.ts +5 -0
  95. package/src/lib/hooks/EditorComponentsContext.tsx +2 -1
  96. package/src/lib/utils/debug-flags.ts +0 -6
  97. package/src/lib/utils/deepLinks.test.ts +15 -0
  98. package/src/lib/utils/deepLinks.ts +8 -3
  99. package/src/lib/utils/sync/LocalIndexedDb.test.ts +93 -1
  100. package/src/lib/utils/sync/LocalIndexedDb.ts +23 -8
  101. package/src/lib/utils/sync/TLLocalSyncClient.test.ts +21 -1
  102. package/src/lib/utils/sync/TLLocalSyncClient.ts +6 -0
  103. package/src/version.ts +3 -3
  104. package/dist-cjs/lib/primitives/geometry/geometry.bench.js +0 -133
  105. package/dist-cjs/lib/primitives/geometry/geometry.bench.js.map +0 -7
  106. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs +0 -132
  107. package/dist-esm/lib/primitives/geometry/geometry.bench.mjs.map +0 -7
  108. package/src/lib/primitives/geometry/geometry.bench.ts +0 -179
@@ -43,10 +43,7 @@ var import_dom = require("../../utils/dom");
43
43
  var import_runtime = require("../../utils/runtime");
44
44
  var import_ErrorBoundary = require("../ErrorBoundary");
45
45
  const BASE_ERROR_URL = "https://github.com/tldraw/tldraw/issues/new";
46
- const DefaultErrorFallback = function DefaultErrorFallback2({
47
- error,
48
- editor
49
- }) {
46
+ function DefaultErrorFallback({ error, editor }) {
50
47
  const containerRef = (0, import_react.useRef)(null);
51
48
  const [shouldShowError, setShouldShowError] = (0, import_react.useState)(process.env.NODE_ENV === "development");
52
49
  const [didCopy, setDidCopy] = (0, import_react.useState)(false);
@@ -207,5 +204,5 @@ My browser: ${navigator.userAgent}`
207
204
  ]
208
205
  }
209
206
  );
210
- };
207
+ }
211
208
  //# sourceMappingURL=DefaultErrorFallback.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/components/default-components/DefaultErrorFallback.tsx"],
4
- "sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\n/** @public */\nexport type TLErrorFallbackComponent = ComponentType<{ error: unknown; editor?: Editor }>\n\n/** @public @react */\nexport const DefaultErrorFallback: TLErrorFallbackComponent = function DefaultErrorFallback({\n\terror,\n\teditor,\n}) {\n\tconst containerRef = useRef<HTMLDivElement>(null)\n\tconst [shouldShowError, setShouldShowError] = useState(process.env.NODE_ENV === 'development')\n\tconst [didCopy, setDidCopy] = useState(false)\n\tconst [shouldShowResetConfirmation, setShouldShowResetConfirmation] = useState(false)\n\n\tlet Canvas: React.ComponentType | null = null\n\ttry {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst components = useEditorComponents()\n\t\tCanvas = components.Canvas ?? null\n\t} catch {\n\t\t// allow this to fail silently\n\t}\n\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\tconst errorStack = error instanceof Error ? error.stack : null\n\n\tconst isDarkModeFromApp = useValue(\n\t\t'isDarkMode',\n\t\t() => {\n\t\t\ttry {\n\t\t\t\tif (editor) {\n\t\t\t\t\treturn editor.user.getIsDarkMode()\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we're in a funky error state so this might not work for spooky\n\t\t\t\t// reasons. if not, we'll have another attempt later:\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\t[editor]\n\t)\n\tconst [isDarkMode, setIsDarkMode] = useState<null | boolean>(null)\n\tuseLayoutEffect(() => {\n\t\t// if we found a theme class from the app, we can just use that\n\t\tif (isDarkModeFromApp !== null) {\n\t\t\tsetIsDarkMode(isDarkModeFromApp)\n\t\t}\n\n\t\t// do any of our parents have a theme class? if yes then we can just\n\t\t// rely on that and don't need to set our own class\n\t\tlet parent = containerRef.current?.parentElement\n\t\tlet foundParentThemeClass = false\n\t\twhile (parent) {\n\t\t\tif (\n\t\t\t\tparent.classList.contains('tl-theme__dark') ||\n\t\t\t\tparent.classList.contains('tl-theme__light')\n\t\t\t) {\n\t\t\t\tfoundParentThemeClass = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tparent = parent.parentElement\n\t\t}\n\t\tif (foundParentThemeClass) {\n\t\t\tsetIsDarkMode(null)\n\t\t\treturn\n\t\t}\n\n\t\t// if we can't find a theme class from the app or from a parent, we have\n\t\t// to fall back on using a media query:\n\t\tif (typeof window !== 'undefined' && getGlobalWindow().matchMedia) {\n\t\t\tsetIsDarkMode(getGlobalWindow().matchMedia('(prefers-color-scheme: dark)').matches)\n\t\t}\n\t}, [isDarkModeFromApp])\n\n\tuseEffect(() => {\n\t\tif (didCopy) {\n\t\t\tconst timeout = editor?.timers.setTimeout(() => {\n\t\t\t\tsetDidCopy(false)\n\t\t\t}, 2000)\n\t\t\treturn () => clearTimeout(timeout)\n\t\t}\n\t}, [didCopy, editor])\n\n\tconst copyError = () => {\n\t\tconst doc = getOwnerDocument(containerRef.current)\n\t\tconst textarea = doc.createElement('textarea')\n\t\ttextarea.value = errorStack ?? errorMessage\n\t\tdoc.body.appendChild(textarea)\n\t\ttextarea.select()\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tdoc.execCommand('copy')\n\t\ttextarea.remove()\n\t\tsetDidCopy(true)\n\t}\n\n\tconst refresh = () => {\n\t\trefreshPage()\n\t}\n\n\tconst resetLocalState = async () => {\n\t\thardResetEditor()\n\t}\n\n\tconst url = new URL(BASE_ERROR_URL)\n\turl.searchParams.set('title', errorMessage)\n\turl.searchParams.set('labels', `bug`)\n\turl.searchParams.set(\n\t\t'body',\n\t\t`Hey, I ran into an error while using tldraw:\n\n\\`\\`\\`js\n${errorStack ?? errorMessage}\n\\`\\`\\`\n\nMy browser: ${navigator.userAgent}`\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'tl-container tl-error-boundary',\n\t\t\t\t// error-boundary is sometimes used outside of the theme\n\t\t\t\t// container, so we need to provide it with a theme for our\n\t\t\t\t// styles to work correctly\n\t\t\t\tisDarkMode === null ? '' : isDarkMode ? 'tl-theme__dark' : 'tl-theme__light'\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"tl-error-boundary__overlay\" />\n\t\t\t{editor && (\n\t\t\t\t// opportunistically attempt to render the canvas to reassure\n\t\t\t\t// the user that their document is still there. there's a good\n\t\t\t\t// chance this won't work (ie the error that we're currently\n\t\t\t\t// notifying the user about originates in the canvas) so it's\n\t\t\t\t// not a big deal if it doesn't work - in that case we just have\n\t\t\t\t// a plain grey background.\n\t\t\t\t<ErrorBoundary onError={noop} fallback={() => null}>\n\t\t\t\t\t<EditorProvider editor={editor}>\n\t\t\t\t\t\t<div className=\"tl-overlay tl-error-boundary__canvas\">{Canvas ? <Canvas /> : null}</div>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</ErrorBoundary>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={classNames('tl-modal', 'tl-error-boundary__content', {\n\t\t\t\t\t'tl-error-boundary__content__expanded': shouldShowError && !shouldShowResetConfirmation,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{shouldShowResetConfirmation ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Are you sure?</h2>\n\t\t\t\t\t\t<p>Resetting your data will delete your drawing and cannot be undone.</p>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowResetConfirmation(false)}>\n\t\t\t\t\t\t\t\tCancel\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__reset\" onClick={resetLocalState}>\n\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Something went wrong</h2>\n\t\t\t\t\t\t<p>Please refresh your browser.</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tIf the issue continues after refreshing, you may need to reset the tldraw data stored\n\t\t\t\t\t\t\ton your device.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<strong>Note:</strong> Resetting will erase your current project and any unsaved work.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{process.env.NODE_ENV !== 'production' && (\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\tIf you&apos;re developing with the SDK and need help, join us on{' '}\n\t\t\t\t\t\t\t\t<a href=\"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen\">\n\t\t\t\t\t\t\t\t\tDiscord\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{shouldShowError && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\tMessage:\n\t\t\t\t\t\t\t\t<h4>\n\t\t\t\t\t\t\t\t\t<code>{errorMessage}</code>\n\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\tStack trace:\n\t\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__error\">\n\t\t\t\t\t\t\t\t\t<pre>\n\t\t\t\t\t\t\t\t\t\t<code>{errorStack ?? errorMessage}</code>\n\t\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={copyError}>\n\t\t\t\t\t\t\t\t\t\t{didCopy ? 'Copied!' : 'Copy'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowError(!shouldShowError)}>\n\t\t\t\t\t\t\t\t{shouldShowError ? 'Hide details' : 'Show details'}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__refresh\" onClick={refresh}>\n\t\t\t\t\t\t\t\t\tRefresh page\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],
5
- "mappings": ";;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A,iBACD;AAAA,cAED,6CAAC,SAAI,WAAU,uCACd;AAAA,4DAAC,YAAO,WAAU,eAAc,SAAS,MAAM,mBAAmB,CAAC,eAAe,GAChF,4BAAkB,iBAAiB,gBACrC;AAAA,gBACA,6CAAC,SAAI,WAAU,8CACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,SAAS,MAAM,+BAA+B,IAAI;AAAA,sBAClD;AAAA;AAAA,kBAED;AAAA,kBACA,4CAAC,YAAO,WAAU,0CAAyC,SAAS,SAAS,0BAE7E;AAAA,mBACD;AAAA,iBACD;AAAA,eACD;AAAA;AAAA,QAEF;AAAA;AAAA;AAAA,EACD;AAEF;",
6
- "names": ["DefaultErrorFallback", "classNames"]
4
+ "sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\n/** @public */\nexport interface TLErrorFallbackProps {\n\t/** The error that was caught. */\n\terror: unknown\n\t/**\n\t * Only set when the caller renders the fallback with an editor; the editor's own error\n\t * boundaries pass just `error`.\n\t */\n\teditor?: Editor\n}\n\n/** @public */\nexport type TLErrorFallbackComponent = ComponentType<TLErrorFallbackProps>\n\n/** @public @react */\nexport function DefaultErrorFallback({ error, editor }: TLErrorFallbackProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null)\n\tconst [shouldShowError, setShouldShowError] = useState(process.env.NODE_ENV === 'development')\n\tconst [didCopy, setDidCopy] = useState(false)\n\tconst [shouldShowResetConfirmation, setShouldShowResetConfirmation] = useState(false)\n\n\tlet Canvas: React.ComponentType | null = null\n\ttry {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst components = useEditorComponents()\n\t\tCanvas = components.Canvas ?? null\n\t} catch {\n\t\t// allow this to fail silently\n\t}\n\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\tconst errorStack = error instanceof Error ? error.stack : null\n\n\tconst isDarkModeFromApp = useValue(\n\t\t'isDarkMode',\n\t\t() => {\n\t\t\ttry {\n\t\t\t\tif (editor) {\n\t\t\t\t\treturn editor.user.getIsDarkMode()\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we're in a funky error state so this might not work for spooky\n\t\t\t\t// reasons. if not, we'll have another attempt later:\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\t[editor]\n\t)\n\tconst [isDarkMode, setIsDarkMode] = useState<null | boolean>(null)\n\tuseLayoutEffect(() => {\n\t\t// if we found a theme class from the app, we can just use that\n\t\tif (isDarkModeFromApp !== null) {\n\t\t\tsetIsDarkMode(isDarkModeFromApp)\n\t\t}\n\n\t\t// do any of our parents have a theme class? if yes then we can just\n\t\t// rely on that and don't need to set our own class\n\t\tlet parent = containerRef.current?.parentElement\n\t\tlet foundParentThemeClass = false\n\t\twhile (parent) {\n\t\t\tif (\n\t\t\t\tparent.classList.contains('tl-theme__dark') ||\n\t\t\t\tparent.classList.contains('tl-theme__light')\n\t\t\t) {\n\t\t\t\tfoundParentThemeClass = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tparent = parent.parentElement\n\t\t}\n\t\tif (foundParentThemeClass) {\n\t\t\tsetIsDarkMode(null)\n\t\t\treturn\n\t\t}\n\n\t\t// if we can't find a theme class from the app or from a parent, we have\n\t\t// to fall back on using a media query:\n\t\tif (typeof window !== 'undefined' && getGlobalWindow().matchMedia) {\n\t\t\tsetIsDarkMode(getGlobalWindow().matchMedia('(prefers-color-scheme: dark)').matches)\n\t\t}\n\t}, [isDarkModeFromApp])\n\n\tuseEffect(() => {\n\t\tif (didCopy) {\n\t\t\tconst timeout = editor?.timers.setTimeout(() => {\n\t\t\t\tsetDidCopy(false)\n\t\t\t}, 2000)\n\t\t\treturn () => clearTimeout(timeout)\n\t\t}\n\t}, [didCopy, editor])\n\n\tconst copyError = () => {\n\t\tconst doc = getOwnerDocument(containerRef.current)\n\t\tconst textarea = doc.createElement('textarea')\n\t\ttextarea.value = errorStack ?? errorMessage\n\t\tdoc.body.appendChild(textarea)\n\t\ttextarea.select()\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tdoc.execCommand('copy')\n\t\ttextarea.remove()\n\t\tsetDidCopy(true)\n\t}\n\n\tconst refresh = () => {\n\t\trefreshPage()\n\t}\n\n\tconst resetLocalState = async () => {\n\t\thardResetEditor()\n\t}\n\n\tconst url = new URL(BASE_ERROR_URL)\n\turl.searchParams.set('title', errorMessage)\n\turl.searchParams.set('labels', `bug`)\n\turl.searchParams.set(\n\t\t'body',\n\t\t`Hey, I ran into an error while using tldraw:\n\n\\`\\`\\`js\n${errorStack ?? errorMessage}\n\\`\\`\\`\n\nMy browser: ${navigator.userAgent}`\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'tl-container tl-error-boundary',\n\t\t\t\t// error-boundary is sometimes used outside of the theme\n\t\t\t\t// container, so we need to provide it with a theme for our\n\t\t\t\t// styles to work correctly\n\t\t\t\tisDarkMode === null ? '' : isDarkMode ? 'tl-theme__dark' : 'tl-theme__light'\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"tl-error-boundary__overlay\" />\n\t\t\t{editor && (\n\t\t\t\t// opportunistically attempt to render the canvas to reassure\n\t\t\t\t// the user that their document is still there. there's a good\n\t\t\t\t// chance this won't work (ie the error that we're currently\n\t\t\t\t// notifying the user about originates in the canvas) so it's\n\t\t\t\t// not a big deal if it doesn't work - in that case we just have\n\t\t\t\t// a plain grey background.\n\t\t\t\t<ErrorBoundary onError={noop} fallback={() => null}>\n\t\t\t\t\t<EditorProvider editor={editor}>\n\t\t\t\t\t\t<div className=\"tl-overlay tl-error-boundary__canvas\">{Canvas ? <Canvas /> : null}</div>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</ErrorBoundary>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={classNames('tl-modal', 'tl-error-boundary__content', {\n\t\t\t\t\t'tl-error-boundary__content__expanded': shouldShowError && !shouldShowResetConfirmation,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{shouldShowResetConfirmation ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Are you sure?</h2>\n\t\t\t\t\t\t<p>Resetting your data will delete your drawing and cannot be undone.</p>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowResetConfirmation(false)}>\n\t\t\t\t\t\t\t\tCancel\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__reset\" onClick={resetLocalState}>\n\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>Something went wrong</h2>\n\t\t\t\t\t\t<p>Please refresh your browser.</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\tIf the issue continues after refreshing, you may need to reset the tldraw data stored\n\t\t\t\t\t\t\ton your device.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<strong>Note:</strong> Resetting will erase your current project and any unsaved work.\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{process.env.NODE_ENV !== 'production' && (\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\tIf you&apos;re developing with the SDK and need help, join us on{' '}\n\t\t\t\t\t\t\t\t<a href=\"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen\">\n\t\t\t\t\t\t\t\t\tDiscord\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{shouldShowError && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\tMessage:\n\t\t\t\t\t\t\t\t<h4>\n\t\t\t\t\t\t\t\t\t<code>{errorMessage}</code>\n\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\tStack trace:\n\t\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__error\">\n\t\t\t\t\t\t\t\t\t<pre>\n\t\t\t\t\t\t\t\t\t\t<code>{errorStack ?? errorMessage}</code>\n\t\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={copyError}>\n\t\t\t\t\t\t\t\t\t\t{didCopy ? 'Copied!' : 'Copy'}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowError(!shouldShowError)}>\n\t\t\t\t\t\t\t\t{shouldShowError ? 'Hide details' : 'Show details'}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\tReset data\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__refresh\" onClick={refresh}>\n\t\t\t\t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AI,WAAU,qCACd;AAAA,8DAAC,SACA,sDAAC,UAAM,wBAAc,cAAa,GACnC;AAAA,kBACA,4CAAC,YAAO,WAAU,eAAc,SAAS,WACvC,oBAAU,YAAY,QACxB;AAAA,mBACD;AAAA,iBACD;AAAA,cAED,6CAAC,SAAI,WAAU,uCACd;AAAA,4DAAC,YAAO,WAAU,eAAc,SAAS,MAAM,mBAAmB,CAAC,eAAe,GAChF,4BAAkB,iBAAiB,gBACrC;AAAA,gBACA,6CAAC,SAAI,WAAU,8CACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,SAAS,MAAM,+BAA+B,IAAI;AAAA,sBAClD;AAAA;AAAA,kBAED;AAAA,kBACA,4CAAC,YAAO,WAAU,0CAAyC,SAAS,SAAS,0BAE7E;AAAA,mBACD;AAAA,iBACD;AAAA,eACD;AAAA;AAAA,QAEF;AAAA;AAAA;AAAA,EACD;AAEF;",
6
+ "names": ["classNames"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/components/default-components/DefaultSpinner.tsx"],
4
- "sourcesContent": ["import classNames from 'classnames'\n\n/** @public @react */\nexport function DefaultSpinner(props: React.SVGProps<SVGSVGElement>) {\n\treturn (\n\t\t<svg\n\t\t\twidth={16}\n\t\t\theight={16}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\taria-hidden=\"false\"\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-spinner', props.className)}\n\t\t>\n\t\t\t<g strokeWidth={2} fill=\"none\" fillRule=\"evenodd\">\n\t\t\t\t<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke=\"currentColor\" />\n\t\t\t\t<path strokeLinecap=\"round\" d=\"M15 8c0-4.5-4.5-7-7-7\" stroke=\"currentColor\" />\n\t\t\t</g>\n\t\t</svg>\n\t)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaG;AAbH,wBAAuB;AAGhB,SAAS,eAAe,OAAsC;AACpE,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA,MACJ,eAAW,kBAAAA,SAAW,cAAc,MAAM,SAAS;AAAA,MAEnD,uDAAC,OAAE,aAAa,GAAG,MAAK,QAAO,UAAS,WACvC;AAAA,oDAAC,YAAO,eAAe,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,QAAO,gBAAe;AAAA,QACvE,4CAAC,UAAK,eAAc,SAAQ,GAAE,yBAAwB,QAAO,gBAAe;AAAA,SAC7E;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["import classNames from 'classnames'\n\n/** @public */\nexport type TLSpinnerProps = React.SVGProps<SVGSVGElement>\n\n/** @public @react */\nexport function DefaultSpinner(props: TLSpinnerProps) {\n\treturn (\n\t\t<svg\n\t\t\twidth={16}\n\t\t\theight={16}\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\taria-hidden=\"false\"\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-spinner', props.className)}\n\t\t>\n\t\t\t<g strokeWidth={2} fill=\"none\" fillRule=\"evenodd\">\n\t\t\t\t<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke=\"currentColor\" />\n\t\t\t\t<path strokeLinecap=\"round\" d=\"M15 8c0-4.5-4.5-7-7-7\" stroke=\"currentColor\" />\n\t\t\t</g>\n\t\t</svg>\n\t)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBG;AAhBH,wBAAuB;AAMhB,SAAS,eAAe,OAAuB;AACrD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAQ;AAAA,MACR,eAAY;AAAA,MACX,GAAG;AAAA,MACJ,eAAW,kBAAAA,SAAW,cAAc,MAAM,SAAS;AAAA,MAEnD,uDAAC,OAAE,aAAa,GAAG,MAAK,QAAO,UAAS,WACvC;AAAA,oDAAC,YAAO,eAAe,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,QAAO,gBAAe;AAAA,QACvE,4CAAC,UAAK,eAAc,SAAQ,GAAE,yBAAwB,QAAO,gBAAe;AAAA,SAC7E;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["classNames"]
7
7
  }
@@ -1408,7 +1408,7 @@ class Editor extends import_eventemitter3.default {
1408
1408
  updateInstanceState(partial, historyOptions) {
1409
1409
  this._updateInstanceState(partial, { history: "ignore", ...historyOptions });
1410
1410
  if (partial.isChangingStyle !== void 0) {
1411
- clearTimeout(this._isChangingStyleTimeout);
1411
+ this.timers.clearTimeout(this._isChangingStyleTimeout);
1412
1412
  if (partial.isChangingStyle === true) {
1413
1413
  this._isChangingStyleTimeout = this.timers.setTimeout(() => {
1414
1414
  this._updateInstanceState({ isChangingStyle: false }, { history: "ignore" });
@@ -2801,11 +2801,14 @@ class Editor extends import_eventemitter3.default {
2801
2801
  _animateViewport(ms) {
2802
2802
  if (!this._viewportAnimation) return;
2803
2803
  this._viewportAnimation.elapsed += ms;
2804
- const { elapsed, easing, duration, start, end } = this._viewportAnimation;
2804
+ const { elapsed, easing, duration, start, end, opts } = this._viewportAnimation;
2805
2805
  if (elapsed > duration) {
2806
2806
  this.off("tick", this._animateViewport);
2807
2807
  this._viewportAnimation = null;
2808
- this._setCamera(new import_Vec.Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width));
2808
+ this._setCamera(
2809
+ new import_Vec.Vec(-end.x, -end.y, this.getViewportScreenBounds().width / end.width),
2810
+ opts
2811
+ );
2809
2812
  return;
2810
2813
  }
2811
2814
  const remaining = duration - elapsed;
@@ -2843,7 +2846,8 @@ class Editor extends import_eventemitter3.default {
2843
2846
  duration: duration / animationSpeed,
2844
2847
  easing,
2845
2848
  start: viewportPageBounds.clone(),
2846
- end: targetViewportPage.clone()
2849
+ end: targetViewportPage.clone(),
2850
+ opts: rest
2847
2851
  };
2848
2852
  this.once("stop-camera-animation", () => {
2849
2853
  this.off("tick", this._animateViewport);
@@ -7818,22 +7822,22 @@ class Editor extends import_eventemitter3.default {
7818
7822
  const releaseCtrl = this._ctrlKeyTimeout !== -1;
7819
7823
  const releaseMeta = this._metaKeyTimeout !== -1;
7820
7824
  if (releaseShift) {
7821
- clearTimeout(this._shiftKeyTimeout);
7825
+ this.timers.clearTimeout(this._shiftKeyTimeout);
7822
7826
  this._shiftKeyTimeout = -1;
7823
7827
  this.inputs.setShiftKey(false);
7824
7828
  }
7825
7829
  if (releaseAlt) {
7826
- clearTimeout(this._altKeyTimeout);
7830
+ this.timers.clearTimeout(this._altKeyTimeout);
7827
7831
  this._altKeyTimeout = -1;
7828
7832
  this.inputs.setAltKey(false);
7829
7833
  }
7830
7834
  if (releaseCtrl) {
7831
- clearTimeout(this._ctrlKeyTimeout);
7835
+ this.timers.clearTimeout(this._ctrlKeyTimeout);
7832
7836
  this._ctrlKeyTimeout = -1;
7833
7837
  this.inputs.setCtrlKey(false);
7834
7838
  }
7835
7839
  if (releaseMeta) {
7836
- clearTimeout(this._metaKeyTimeout);
7840
+ this.timers.clearTimeout(this._metaKeyTimeout);
7837
7841
  this._metaKeyTimeout = -1;
7838
7842
  this.inputs.setMetaKey(false);
7839
7843
  }
@@ -7947,28 +7951,28 @@ class Editor extends import_eventemitter3.default {
7947
7951
  return;
7948
7952
  }
7949
7953
  if (info.shiftKey) {
7950
- clearTimeout(this._shiftKeyTimeout);
7954
+ this.timers.clearTimeout(this._shiftKeyTimeout);
7951
7955
  this._shiftKeyTimeout = -1;
7952
7956
  inputs.setShiftKey(true);
7953
7957
  } else if (!info.shiftKey && inputs.getShiftKey() && this._shiftKeyTimeout === -1) {
7954
7958
  this._shiftKeyTimeout = this.timers.setTimeout(this._releaseShiftKey, 150);
7955
7959
  }
7956
7960
  if (info.altKey) {
7957
- clearTimeout(this._altKeyTimeout);
7961
+ this.timers.clearTimeout(this._altKeyTimeout);
7958
7962
  this._altKeyTimeout = -1;
7959
7963
  inputs.setAltKey(true);
7960
7964
  } else if (!info.altKey && inputs.getAltKey() && this._altKeyTimeout === -1) {
7961
7965
  this._altKeyTimeout = this.timers.setTimeout(this._releaseAltKey, 150);
7962
7966
  }
7963
7967
  if (info.ctrlKey) {
7964
- clearTimeout(this._ctrlKeyTimeout);
7968
+ this.timers.clearTimeout(this._ctrlKeyTimeout);
7965
7969
  this._ctrlKeyTimeout = -1;
7966
7970
  inputs.setCtrlKey(true);
7967
7971
  } else if (!info.ctrlKey && inputs.getCtrlKey() && this._ctrlKeyTimeout === -1) {
7968
7972
  this._ctrlKeyTimeout = this.timers.setTimeout(this._releaseCtrlKey, 150);
7969
7973
  }
7970
7974
  if (info.metaKey && info.name !== "key_up") {
7971
- clearTimeout(this._metaKeyTimeout);
7975
+ this.timers.clearTimeout(this._metaKeyTimeout);
7972
7976
  this._metaKeyTimeout = -1;
7973
7977
  inputs.setMetaKey(true);
7974
7978
  } else if (!info.metaKey && inputs.getMetaKey() && this._metaKeyTimeout === -1) {
@@ -7982,8 +7986,7 @@ class Editor extends import_eventemitter3.default {
7982
7986
  const cameraOptions = this._cameraOptions.__unsafe__getWithoutCapture();
7983
7987
  switch (type) {
7984
7988
  case "pinch": {
7985
- if (cameraOptions.isLocked) return;
7986
- clearTimeout(this._longPressTimeout);
7989
+ this.timers.clearTimeout(this._longPressTimeout);
7987
7990
  this.inputs.updateFromEvent(info);
7988
7991
  switch (info.name) {
7989
7992
  case "pinch_start": {
@@ -8004,6 +8007,7 @@ class Editor extends import_eventemitter3.default {
8004
8007
  }
8005
8008
  case "pinch": {
8006
8009
  if (!inputs.getIsPinching()) return;
8010
+ if (cameraOptions.isLocked) return;
8007
8011
  const {
8008
8012
  point: { z = 1 },
8009
8013
  delta: { x: dx, y: dy }
@@ -8059,7 +8063,7 @@ class Editor extends import_eventemitter3.default {
8059
8063
  const { panSpeed, zoomSpeed } = cameraOptions;
8060
8064
  let wheelBehavior = cameraOptions.wheelBehavior;
8061
8065
  const inputMode = this.user.getUserPreferences().inputMode;
8062
- if (inputMode !== null) {
8066
+ if (inputMode !== null && wheelBehavior !== "none") {
8063
8067
  wheelBehavior = inputMode === "trackpad" ? "pan" : "zoom";
8064
8068
  }
8065
8069
  if (wheelBehavior !== "none") {
@@ -8111,12 +8115,12 @@ class Editor extends import_eventemitter3.default {
8111
8115
  }
8112
8116
  case "pointer": {
8113
8117
  if (inputs.getIsPinching()) return;
8114
- this.inputs.updateFromEvent(info);
8115
8118
  const { isPen } = info;
8116
8119
  const { isPenMode } = instanceState;
8120
+ if (isPenMode && !isPen) return;
8121
+ this.inputs.updateFromEvent(info);
8117
8122
  switch (info.name) {
8118
8123
  case "pointer_down": {
8119
- if (isPenMode && !isPen) return;
8120
8124
  this._releaseDebouncedModifiers();
8121
8125
  if (!this.inputs.getIsPanning()) {
8122
8126
  this._longPressTimeout = this.timers.setTimeout(() => {
@@ -8140,11 +8144,12 @@ class Editor extends import_eventemitter3.default {
8140
8144
  inputs.buttons.add(info.button);
8141
8145
  inputs.setIsPointing(true);
8142
8146
  inputs.setIsDragging(false);
8147
+ this.stopCameraAnimation();
8143
8148
  if (!isPenMode && info.isPenDirect) {
8144
8149
  this.updateInstanceState({ isPenMode: true });
8145
8150
  this.interrupt();
8146
8151
  }
8147
- if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
8152
+ if (info.button === import_constants.STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
8148
8153
  this._restoreToolId = this.getCurrentToolId();
8149
8154
  this.complete();
8150
8155
  this.setCurrentTool("eraser");
@@ -8153,10 +8158,10 @@ class Editor extends import_eventemitter3.default {
8153
8158
  this._prevCursor = this.getInstanceState().cursor.type;
8154
8159
  }
8155
8160
  this.inputs.setIsPanning(true);
8156
- clearTimeout(this._longPressTimeout);
8161
+ this.timers.clearTimeout(this._longPressTimeout);
8157
8162
  } else if (info.button === import_constants.RIGHT_MOUSE_BUTTON && this.options.rightClickPanning) {
8158
8163
  this.inputs.setIsRightPointing(true);
8159
- clearTimeout(this._longPressTimeout);
8164
+ this.timers.clearTimeout(this._longPressTimeout);
8160
8165
  return this;
8161
8166
  }
8162
8167
  if (this.inputs.getIsPanning()) {
@@ -8167,7 +8172,6 @@ class Editor extends import_eventemitter3.default {
8167
8172
  break;
8168
8173
  }
8169
8174
  case "pointer_move": {
8170
- if (!isPen && isPenMode) return;
8171
8175
  const { x: cx, y: cy, z: cz } = (0, import_state.unsafe__withoutCapture)(() => this.getCamera());
8172
8176
  if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8173
8177
  const currentScreenPoint = this.inputs.getCurrentScreenPoint();
@@ -8198,16 +8202,15 @@ class Editor extends import_eventemitter3.default {
8198
8202
  }
8199
8203
  if (inputs.getIsPointing() && !inputs.getIsDragging() && import_Vec.Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
8200
8204
  inputs.setIsDragging(true);
8201
- clearTimeout(this._longPressTimeout);
8205
+ this.timers.clearTimeout(this._longPressTimeout);
8202
8206
  }
8203
8207
  break;
8204
8208
  }
8205
8209
  case "pointer_up": {
8206
8210
  inputs.setIsDragging(false);
8207
8211
  inputs.setIsPointing(false);
8208
- clearTimeout(this._longPressTimeout);
8212
+ this.timers.clearTimeout(this._longPressTimeout);
8209
8213
  inputs.buttons.delete(info.button);
8210
- if (instanceState.isPenMode && !isPen) return;
8211
8214
  if (this.inputs.getIsRightPointing() && !this.inputs.getIsPanning()) {
8212
8215
  this.inputs.setIsRightPointing(false);
8213
8216
  this._selectedShapeIdsAtPointerDown = [];
@@ -8263,7 +8266,7 @@ class Editor extends import_eventemitter3.default {
8263
8266
  });
8264
8267
  }
8265
8268
  } else {
8266
- if (info.button === import_constants.STYLUS_ERASER_BUTTON) {
8269
+ if (info.button === import_constants.STYLUS_ERASER_BUTTON && this.getStateDescendant("eraser")) {
8267
8270
  this.complete();
8268
8271
  this.setCurrentTool(this._restoreToolId);
8269
8272
  }
@@ -8290,7 +8293,7 @@ class Editor extends import_eventemitter3.default {
8290
8293
  }
8291
8294
  this.inputs.setIsPanning(true);
8292
8295
  this.inputs.setIsSpacebarPanning(true);
8293
- clearTimeout(this._longPressTimeout);
8296
+ this.timers.clearTimeout(this._longPressTimeout);
8294
8297
  this.setCursor({
8295
8298
  type: this.inputs.getIsPointing() ? "grabbing" : "grab",
8296
8299
  rotation: 0
@@ -8316,7 +8319,7 @@ class Editor extends import_eventemitter3.default {
8316
8319
  break;
8317
8320
  }
8318
8321
  }
8319
- if (offset) {
8322
+ if (offset && !cameraOptions.isLocked) {
8320
8323
  const bounds = this.getViewportPageBounds();
8321
8324
  const next = bounds.clone().translate(offset.mulV({ x: bounds.w, y: bounds.h }));
8322
8325
  this._animateToViewport(next, { animation: { duration: 320 } });
@@ -8356,7 +8359,7 @@ class Editor extends import_eventemitter3.default {
8356
8359
  this.setCurrentTool("select");
8357
8360
  }
8358
8361
  const { isPenMode } = this.store.unsafeGetWithoutCapture(import_tlschema.TLINSTANCE_ID);
8359
- if (info.isPen === isPenMode) {
8362
+ if (!isPenMode || info.isPen) {
8360
8363
  const clickInfo = this._clickManager.handlePointerEvent(info);
8361
8364
  if (info.name !== clickInfo.name) {
8362
8365
  this.root.handleEvent(info);
@@ -8378,7 +8381,7 @@ class Editor extends import_eventemitter3.default {
8378
8381
  maybeTrackPerformance(name) {
8379
8382
  if (import_debug_flags.debugFlags.measurePerformance.get()) {
8380
8383
  if (this.performanceTracker.isStarted()) {
8381
- clearTimeout(this.performanceTrackerTimeout);
8384
+ this.timers.clearTimeout(this.performanceTrackerTimeout);
8382
8385
  } else {
8383
8386
  this.performanceTracker.start(name);
8384
8387
  }